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
This commit is contained in:
Ian Wienand 2017-06-07 11:47:12 +10:00
parent 7661da1341
commit 3886d5e206

View File

@ -102,7 +102,9 @@ function run_disk_element_test() {
local use_tmp_flag="" local use_tmp_flag=""
local dest_dir=$(mktemp -d) local dest_dir=$(mktemp -d)
if [[ ${KEEP_OUTPUT} -ne 1 ]]; then
trap "rm -rf $dest_dir" EXIT trap "rm -rf $dest_dir" EXIT
fi
if [ "${dont_use_tmp}" = "yes" ]; then if [ "${dont_use_tmp}" = "yes" ]; then
use_tmp_flag="--no-tmpfs" use_tmp_flag="--no-tmpfs"
@ -147,8 +149,13 @@ function run_disk_element_test() {
fi fi
fi fi
rm -f /tmp/dib-test-should-fail
if [[ ${KEEP_OUTPUT} -ne 1 ]]; then
# reset trap and cleanup
trap EXIT trap EXIT
rm -rf $dest_dir /tmp/dib-test-should-fail rm -rf $dest_dir
fi
} }
# run_ramdisk_element_test <test_element> <element> # run_ramdisk_element_test <test_element> <element>
@ -196,6 +203,7 @@ done
# #
JOB_MAX_CNT=1 JOB_MAX_CNT=1
LOG_DATESTAMP=0 LOG_DATESTAMP=0
KEEP_OUTPUT=0
# #
# Parse args # Parse args
@ -208,6 +216,7 @@ while getopts ":hlj:t" opt; do
echo " -l : list available tests" echo " -l : list available tests"
echo " -j : parallel job count (default to 1)" echo " -j : parallel job count (default to 1)"
echo " -t : prefix log messages with timestamp" echo " -t : prefix log messages with timestamp"
echo " -k : keep output directories"
echo " <test> : functional test to run" echo " <test> : functional test to run"
echo " Special test 'all' will run all tests" echo " Special test 'all' will run all tests"
exit 0 exit 0
@ -233,6 +242,9 @@ while getopts ":hlj:t" opt; do
t) t)
LOG_DATESTAMP=1 LOG_DATESTAMP=1
;; ;;
k)
KEEP_OUTPUT=1
;;
\?) \?)
echo "Invalid option: -$OPTARG" echo "Invalid option: -$OPTARG"
exit 1 exit 1