automated: linux: rt-migrate-test: parse: fix iteration parsing

automated: linux: pmqtest: parse: fix iteration parsing

If iterations > 1, the tests will be named 'iteration-<number>' where
number = iterations that was passed in, so all the other iterations will
be overwritten. mening if iterations=3, then it will look like this:

iteration-3-t0-min-latency: pass

And no iterations-1-* or iterations-2-*.

Solve this by manipulating a temporary file and extend the result file
with the temporary file.

Fixes: 8ed13f7e1663 ("automated: linux: rt-migrate-test: add iterations")
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 5ab04c4..c3ab0af 100755
--- a/automated/linux/rt-migrate-test/rt-migrate-test.sh
+++ b/automated/linux/rt-migrate-test/rt-migrate-test.sh
@@ -7,6 +7,8 @@
 OUTPUT="$(pwd)/output"
 LOGFILE="${OUTPUT}/rt-migrate-test"
 RESULT_FILE="${OUTPUT}/result.txt"
+TMP_RESULT_FILE="${OUTPUT}/tmp_result.txt"
+
 PRIORITY="51"
 DURATION="1m"
 BACKGROUND_CMD=""
@@ -49,9 +51,10 @@
 # Parse test log.
 for i in $(seq ${ITERATIONS}); do
     ../../lib/parse_rt_tests_results.py rt-migrate-test "${LOGFILE}-${i}.json" \
-        | tee "${RESULT_FILE}"
+        | tee "${TMP_RESULT_FILE}"
 
     if [ ${ITERATIONS} -ne 1 ]; then
-        sed -i "s|^|iteration-${i}-|g" "${RESULT_FILE}"
+        sed -i "s|^|iteration-${i}-|g" "${TMP_RESULT_FILE}"
     fi
+    cat "${TMP_RESULT_FILE}" | tee -a "${RESULT_FILE}"
 done