From d0e1a8471d1b79e75ae12e8a68596b4b2ebf9ec6 Mon Sep 17 00:00:00 2001 From: Ian Wienand Date: Wed, 23 May 2018 12:08:10 +1000 Subject: [PATCH] Rename output log files Rename output log files so they can be quickly identified as passing or failing logs just by the filename. Put them all in the same directory for similar reasons. Change-Id: I75bbe724e0d20c6561c2bf93857499cc49474250 --- tests/run_functests.sh | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/tests/run_functests.sh b/tests/run_functests.sh index a51b860b..30c11c33 100755 --- a/tests/run_functests.sh +++ b/tests/run_functests.sh @@ -106,6 +106,22 @@ function wait_minus_n { fi } +# This takes the status and the "$logfile" argument passed to +# disk-image-create and renames the file, so you can quickly see +# in results which tests have failed. +function logfile_status { + local status="$1" + local arg="$2" + local filename + if [[ -z "${arg// }" ]]; then + return + fi + + filename="$(echo $arg | cut -f2 -d' ')" + echo "Moving ${filename} to ${filename/.log/.$status.log}" + mv "$filename" ${filename/.log/.$status.log} +} + # run_disk_element_test # Run a disk-image-build build of ELEMENT including any elements # specified by TEST_ELEMENT. Pass OUTPUT_FORMAT to "-t" @@ -141,6 +157,7 @@ function run_disk_element_test() { if ! [ -f "$dest_dir/image.qcow2" ]; then echo "Error: qcow2 build failed for element: $element, test-element: $test_element." echo "No image $dest_dir/image.qcow2 found!" + logfile_status "FAIL" "${logfile}" exit 1 fi fi @@ -149,20 +166,25 @@ function run_disk_element_test() { if ! [ -f "$dest_dir/image.tar" ]; then echo "Error: Build failed for element: $element, test-element: $test_element." echo "No image $dest_dir/image.tar found!" + logfile_status "FAIL" "${logfile}" exit 1 else if tar -tf $dest_dir/image.tar | grep -q /tmp/dib-test-should-fail; then echo "Error: Element: $element, test-element $test_element should have failed, but passed." + logfile_status "FAIL" "${logfile}" exit 1 else echo "PASS: Element $element, test-element: $test_element" + logfile_status "PASS" "${logfile}" fi fi else if [ -f "${dest_dir}/dib-test-should-fail" ]; then echo "PASS: Element $element, test-element: $test_element" + logfile_status "PASS" "${logfile}" else echo "Error: Build failed for element: $element, test-element: $test_element." + logfile_status "FAIL" "${logfile}" exit 1 fi fi @@ -379,8 +401,7 @@ for test in "${TESTS_TO_RUN[@]}"; do log_argument=' ' if [[ -n "${LOG_DIRECTORY}" ]]; then - mkdir -p "${LOG_DIRECTORY}/${element}" - log_argument="--logfile ${LOG_DIRECTORY}/${element}/${test_element}.log" + log_argument="--logfile ${LOG_DIRECTORY}/${element}_${test_element}.log" fi echo "Running $test ($element_type)"