From 3886d5e2062c42619757555a0fce34d7ed2ee5f7 Mon Sep 17 00:00:00 2001 From: Ian Wienand Date: Wed, 7 Jun 2017 11:47:12 +1000 Subject: [PATCH] Add a keep-output flag for functional tests Add a -k flag that disables deleting of of ${destdir} for tests. This should allow examination of the resulting images if required. Change-Id: I107c33e70100b21495a807f10762d3b6babe9bfe --- tests/run_functests.sh | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/tests/run_functests.sh b/tests/run_functests.sh index d2af48c4d..9e3ca9cc7 100755 --- a/tests/run_functests.sh +++ b/tests/run_functests.sh @@ -102,7 +102,9 @@ function run_disk_element_test() { local use_tmp_flag="" local dest_dir=$(mktemp -d) - trap "rm -rf $dest_dir" EXIT + if [[ ${KEEP_OUTPUT} -ne 1 ]]; then + trap "rm -rf $dest_dir" EXIT + fi if [ "${dont_use_tmp}" = "yes" ]; then use_tmp_flag="--no-tmpfs" @@ -147,8 +149,13 @@ function run_disk_element_test() { fi fi - trap EXIT - rm -rf $dest_dir /tmp/dib-test-should-fail + rm -f /tmp/dib-test-should-fail + + if [[ ${KEEP_OUTPUT} -ne 1 ]]; then + # reset trap and cleanup + trap EXIT + rm -rf $dest_dir + fi } # run_ramdisk_element_test @@ -196,6 +203,7 @@ done # JOB_MAX_CNT=1 LOG_DATESTAMP=0 +KEEP_OUTPUT=0 # # Parse args @@ -208,6 +216,7 @@ while getopts ":hlj:t" opt; do echo " -l : list available tests" echo " -j : parallel job count (default to 1)" echo " -t : prefix log messages with timestamp" + echo " -k : keep output directories" echo " : functional test to run" echo " Special test 'all' will run all tests" exit 0 @@ -233,6 +242,9 @@ while getopts ":hlj:t" opt; do t) LOG_DATESTAMP=1 ;; + k) + KEEP_OUTPUT=1 + ;; \?) echo "Invalid option: -$OPTARG" exit 1