From 19aa272831c770b7660f116c6897c88dc9163c64 Mon Sep 17 00:00:00 2001 From: Pavel Raiskup Date: Thu, 6 Nov 2014 14:12:57 +0100 Subject: tester/run: fix --listonly option Do not try to put some output into YML file when we are only listing. That could cause 'Permision denied' errors even if the permission is actually not needed. * tester/run (__result_yml_print): New local function. (die, run_test): Call __result_yml_print instead of hand touching the yml file. --- tester/run | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/tester/run b/tester/run index d892a7c..896375a 100755 --- a/tester/run +++ b/tester/run @@ -28,6 +28,12 @@ export DTF_TASKS=${DTF_TASKS-$srcdir/tasks} export DTF_RESULTDIR=${DTF_RESULTDIR-/var/tmp/dtf} export DTF_RESULTS_YML=${DTF_RESULTDIR}/result.yml +__result_yml_print() +{ + test "$dtf_option_listonly" -eq 0 && \ + echo 2>/dev/null "$1" >> "$DTF_RESULTS_YML" +} + # when exists per-testsuite config.sh, source it here test -r "$srcdir/config.sh" && . "$srcdir/config.sh" @@ -50,7 +56,7 @@ info() die() { echo "$@" >&2 - echo 2>/dev/null "exit_status: 2" >> "$DTF_RESULTS_YML" + __result_yml_print "exit_status: 2" exit 2 } @@ -94,7 +100,6 @@ run_test() result_dir="$DTF_RESULTDIR/tasks/$DTF_TEST_ID" - mkdir -p "$result_dir" || exit outlog="$result_dir/run.log" output_wrapper="cat > $outlog" @@ -111,6 +116,8 @@ run_test() || exit $DTF_RESULT_TS_SKIP fi + mkdir -p "$result_dir" || exit $DTF_RESULT_TS_CONFIG + printf "%-40s" "RUN $DTF_TEST_ID ..." set -o pipefail @@ -205,8 +212,8 @@ done test $dtf_option_listonly -ne 1 && prepare_resultdir +__result_yml_print "$(date -u "+date: \"%Y%m%d_%H%M%S_UTC\"")" -date -u "+date: \"%Y%m%d_%H%M%S_UTC\"" > "$DTF_RESULTS_YML" result=0 while read i; do testdir=$(dirname "$i") @@ -233,6 +240,6 @@ while read i; do esac done <<<"$(find "$DTF_TASKS" -name runtest.sh)" -echo "exit_status: $result" >> "$DTF_RESULTS_YML" +__result_yml_print "exit_status: $result" exit $result -- cgit