automated: linux: rt-migrate-test: add iterations

This will make it possible to run multiple iterations to gather multiple
min/max/avg values.

Signed-off-by: Anders Roxell <anders.roxell@linaro.org>
diff --git a/automated/linux/rt-migrate-test/rt-migrate-test.sh b/automated/linux/rt-migrate-test/rt-migrate-test.sh
index d53e8ca..5ab04c4 100755
--- a/automated/linux/rt-migrate-test/rt-migrate-test.sh
+++ b/automated/linux/rt-migrate-test/rt-migrate-test.sh
@@ -5,22 +5,24 @@
 . ../../lib/sh-test-lib
 
 OUTPUT="$(pwd)/output"
-LOGFILE="${OUTPUT}/rt-migrate-test.json"
+LOGFILE="${OUTPUT}/rt-migrate-test"
 RESULT_FILE="${OUTPUT}/result.txt"
 PRIORITY="51"
 DURATION="1m"
 BACKGROUND_CMD=""
+ITERATIONS=1
 
 usage() {
-    echo "Usage: $0 [-p priority] [-D duration] [-w background_cmd]" 1>&2
+    echo "Usage: $0 [-p priority] [-D duration] [-w background_cmd] [-i iterations]" 1>&2
     exit 1
 }
 
-while getopts ":l:p:D:w:" opt; do
+while getopts ":l:p:D:w:i:" opt; do
     case "${opt}" in
         p) PRIORITY="${OPTARG}" ;;
         D) DURATION="${OPTARG}" ;;
         w) BACKGROUND_CMD="${OPTARG}" ;;
+        i) ITERATIONS="${OPTARG}" ;;
         *) usage ;;
     esac
 done
@@ -37,10 +39,19 @@
 
 background_process_start bgcmd --cmd "${BACKGROUND_CMD}"
 
-"${binary}" -q -p "${PRIORITY}" -D "${DURATION}" -c --json="${LOGFILE}"
+for i in $(seq ${ITERATIONS}); do
+    "${binary}" -q -p "${PRIORITY}" -D "${DURATION}" -c --json="${LOGFILE}-${i}.json"
+done
+
 
 background_process_stop bgcmd
 
 # Parse test log.
-../../lib/parse_rt_tests_results.py rt-migrate-test "${LOGFILE}" \
-    | tee -a "${RESULT_FILE}"
+for i in $(seq ${ITERATIONS}); do
+    ../../lib/parse_rt_tests_results.py rt-migrate-test "${LOGFILE}-${i}.json" \
+        | tee "${RESULT_FILE}"
+
+    if [ ${ITERATIONS} -ne 1 ]; then
+        sed -i "s|^|iteration-${i}-|g" "${RESULT_FILE}"
+    fi
+done
diff --git a/automated/linux/rt-migrate-test/rt-migrate-test.yaml b/automated/linux/rt-migrate-test/rt-migrate-test.yaml
index 8646ef6..6674447 100644
--- a/automated/linux/rt-migrate-test/rt-migrate-test.yaml
+++ b/automated/linux/rt-migrate-test/rt-migrate-test.yaml
@@ -37,10 +37,11 @@
     # Refer to https://validation.linaro.org/static/docs/v2/publishing-artifacts.html
     ARTIFACTORIAL_URL: "https://archive.validation.linaro.org/artifacts/team/qa/"
     ARTIFACTORIAL_TOKEN: ""
+    ITERATIONS: 1
 
 run:
     steps:
         - cd ./automated/linux/rt-migrate-test/
-        - ./rt-migrate-test.sh -p "${PRIORITY}" -D "${DURATION}" -w "${BACKGROUND_CMD}"
+        - ./rt-migrate-test.sh -p "${PRIORITY}" -D "${DURATION}" -i "${ITERATIONS}" -w "${BACKGROUND_CMD}"
         - ../../utils/upload-to-artifactorial.sh -a "output/rt-migrate-test.json" -u "${ARTIFACTORIAL_URL}" -t "${ARTIFACTORIAL_TOKEN}"
         - ../../utils/send-to-lava.sh ./output/result.txt