automated: workload-automation: allow for custom output path

In order to make result postprocessing possible in the LAVA job, WA
results can now be saved in the custom path that can be set as parameter

Change-Id: Id17a6dae15b9e5569270bd06722b9aa5d3a7b636
Signed-off-by: Milosz Wasilewski <milosz.wasilewski@linaro.org>
diff --git a/automated/android/workload-automation/workload-automation.sh b/automated/android/workload-automation/workload-automation.sh
index e273f4e..c31bccd 100755
--- a/automated/android/workload-automation/workload-automation.sh
+++ b/automated/android/workload-automation/workload-automation.sh
@@ -22,7 +22,7 @@
     exit 1
 }
 
-while getopts ":s:S:t:T:r:g:c:a:b:w:p:" opt; do
+while getopts ":s:S:t:T:r:g:c:a:b:w:p:o:" opt; do
     case "${opt}" in
         s) SKIP_INSTALL="${OPTARG}" ;;
         S) ANDROID_SERIAL="${OPTARG}" ;;
@@ -35,6 +35,7 @@
         b) BUILD_TOOLS_URL="${OPTARG}" ;;
         w) WA_HOME_URL="${OPTARG}" ;;
         p) PROBE="${OPTARG}" ;;
+        o) NEW_OUTPUT="${OPTARG}" ;;
         *) usage ;;
     esac
 done
@@ -43,6 +44,9 @@
 . "${TEST_DIR}/../../lib/android-test-lib"
 
 cd "${TEST_DIR}"
+if [ ! -z "${NEW_OUTPUT}" ]; then
+    OUTPUT="${NEW_OUTPUT}"
+fi
 create_out_dir "${OUTPUT}"
 
 if [ "${SKIP_INSTALL}" = "true" ] || [ "${SKIP_INSTALL}" = "True" ]; then
diff --git a/automated/android/workload-automation/workload-automation.yaml b/automated/android/workload-automation/workload-automation.yaml
index 4aa8a7e..4718c44 100644
--- a/automated/android/workload-automation/workload-automation.yaml
+++ b/automated/android/workload-automation/workload-automation.yaml
@@ -32,6 +32,9 @@
     # allow extra extenstions for WA
     WA_EXTENSION_PATHS: ""
     PROBE: ""
+    # directory where the WA results are stored
+    # defaults to {TEST_DIR}/output
+    OUTPUT: ""
     # Specify url and token for publishing artifacts.
     # For safety reasons, please set 'ARTIFACTORIAL_TOKEN' variable in job definition with
     # 'secrets' dictionary, and set job visibility to personal or group.
@@ -44,7 +47,7 @@
         - export WA_EXTENSION_PATHS=$WA_EXTENSION_PATHS
         - cd ./automated/android/workload-automation
         # Test run.
-        - ./workload-automation.sh -s "${SKIP_INSTALL}" -t "${BOOT_TIMEOUT}" -S "${ANDROID_SERIAL}" -T "${WA_TAG}" -r "${WA_TEMPLATES_REPO}" -g "${TEMPLATES_BRANCH}" -c "${CONFIG}" -a "${AGENDA}" -b "${BUILD_TOOLS_URL}" -w "${WA_HOME_URL}" -p "${PROBE}"
+        - ./workload-automation.sh -s "${SKIP_INSTALL}" -t "${BOOT_TIMEOUT}" -S "${ANDROID_SERIAL}" -T "${WA_TAG}" -r "${WA_TEMPLATES_REPO}" -g "${TEMPLATES_BRANCH}" -c "${CONFIG}" -a "${AGENDA}" -b "${BUILD_TOOLS_URL}" -w "${WA_HOME_URL}" -p "${PROBE}" -o "${OUTPUT}"
         # Upload test output to artifactorial.
         - tar caf "wa-output.tar.xz" "./output"
         - ../../utils/upload-to-artifactorial.sh -a "wa-output.tar.xz" -u "${ARTIFACTORIAL_URL}" -t "${ARTIFACTORIAL_TOKEN}"