From f2eaa978402bd342ec84425f0722af709dd02e48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Sat, 26 Feb 2022 20:19:05 +0100 Subject: [PATCH] Fix FreeBSD reporting on reruns MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Turns out, when your test-suite fails on FreeBSD the rerun logic would fail as follows: Results Summary PASS 1358 FAIL 7 SKIP 47 Running Time: 04:00:02 Percent passed: 96.2% Log directory: /var/tmp/test_results/20220225T092538 mktemp: illegal option -- p usage: mktemp [-d] [-q] [-t prefix] [-u] template ... mktemp [-d] [-q] [-u] -t prefix mktemp: illegal option -- p usage: mktemp [-d] [-q] [-t prefix] [-u] template ... mktemp [-d] [-q] [-u] -t prefix /usr/local/share/zfs/zfs-tests.sh: cannot create : No such file or directory ... This change resolves a flaw from the original commit, 2320e6eb4 ("Add zfs-test facility to automatically rerun failing tests") Reviewed by: Brian Behlendorf Signed-off-by: Ahelenia ZiemiaƄska Closes #13156 --- scripts/zfs-tests.sh | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/scripts/zfs-tests.sh b/scripts/zfs-tests.sh index f871a51d3..aa0829b28 100755 --- a/scripts/zfs-tests.sh +++ b/scripts/zfs-tests.sh @@ -680,14 +680,16 @@ export __ZFS_POOL_EXCLUDE export TESTFAIL_CALLBACKS export PATH=$STF_PATH -if [ "$UNAME" = "FreeBSD" ] ; then - mkdir -p "$FILEDIR" || true - RESULTS_FILE=$(mktemp -u "${FILEDIR}/zts-results.XXXXXX") - REPORT_FILE=$(mktemp -u "${FILEDIR}/zts-report.XXXXXX") -else - RESULTS_FILE=$(mktemp -u -t zts-results.XXXXXX -p "$FILEDIR") - REPORT_FILE=$(mktemp -u -t zts-report.XXXXXX -p "$FILEDIR") -fi +mktemp_file() { + if [ "$UNAME" = "FreeBSD" ]; then + mktemp -u "${FILEDIR}/$1.XXXXXX" + else + mktemp -ut "$1.XXXXXX" -p "$FILEDIR" + fi +} +mkdir -p "$FILEDIR" || : +RESULTS_FILE=$(mktemp_file zts-results) +REPORT_FILE=$(mktemp_file zts-report) # # Run all the tests as specified. @@ -711,8 +713,8 @@ RESULT=$? if [ "$RESULT" -eq "2" ] && [ -n "$RERUN" ]; then MAYBES="$($ZTS_REPORT --list-maybes)" - TEMP_RESULTS_FILE=$(mktemp -u -t zts-results-tmp.XXXXX -p "$FILEDIR") - TEST_LIST=$(mktemp -u -t test-list.XXXXX -p "$FILEDIR") + TEMP_RESULTS_FILE=$(mktemp_file zts-results-tmp) + TEST_LIST=$(mktemp_file test-list) grep "^Test:.*\[FAIL\]" "$RESULTS_FILE" >"$TEMP_RESULTS_FILE" for test_name in $MAYBES; do grep "$test_name " "$TEMP_RESULTS_FILE" >>"$TEST_LIST"