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: 9ebdd88475bb ("automated: linux: pmqtest: add iterations")
Signed-off-by: Anders Roxell <anders.roxell@linaro.org>
diff --git a/automated/linux/pmqtest/pmqtest.sh b/automated/linux/pmqtest/pmqtest.sh
index fc7068a..5edd6de 100755
--- a/automated/linux/pmqtest/pmqtest.sh
+++ b/automated/linux/pmqtest/pmqtest.sh
@@ -8,6 +8,8 @@
 OUTPUT="${TEST_DIR}/output"
 LOGFILE="${OUTPUT}/pmqtest"
 RESULT_FILE="${OUTPUT}/result.txt"
+TMP_RESULT_FILE="${OUTPUT}/tmp_result.txt"
+
 DURATION="5m"
 BACKGROUND_CMD=""
 ITERATIONS=1
@@ -49,9 +51,10 @@
 # Parse test log.
 for i in $(seq ${ITERATIONS}); do
     ../../lib/parse_rt_tests_results.py pmqtest "${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