automated: linux: pi-stress: 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: 970fdbc85abd ("automated: linux: pi-stress: add iterations")
Signed-off-by: Anders Roxell <anders.roxell@linaro.org>
diff --git a/automated/linux/pi-stress/pi-stress.sh b/automated/linux/pi-stress/pi-stress.sh
index a030e4c..dfa935f 100755
--- a/automated/linux/pi-stress/pi-stress.sh
+++ b/automated/linux/pi-stress/pi-stress.sh
@@ -9,6 +9,7 @@
 OUTPUT="$(pwd)/output"
 LOGFILE="${OUTPUT}/pi-stress"
 RESULT_FILE="${OUTPUT}/result.txt"
+TMP_RESULT_FILE="${OUTPUT}/tmp_result.txt"
 export RESULT_FILE
 
 DURATION="5m"
@@ -68,9 +69,10 @@
 # Parse test log.
 for i in $(seq ${ITERATIONS}); do
     ../../lib/parse_rt_tests_results.py pi-stress "${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