From: Glenn Washburn Date: Mon, 3 Mar 2025 08:12:02 +0000 (-0600) Subject: tests: Cleanup generated files on expected failure in grub_cmd_cryptomount X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c188ca5d5ee692d15a433b4e2a44d2deb6b680a2;p=thirdparty%2Fgrub.git tests: Cleanup generated files on expected failure in grub_cmd_cryptomount grub-shell-luks-tester only cleans up generated files when the test it runs returns success. Sometimes tests are run that should fail. Add a --xfail argument to grub-shell-luks-tester and pass it from grub_cmd_cryptomount when invoking a test that is expected to fail. Reported-by: Thomas Schmitt Signed-off-by: Glenn Washburn Tested-by: Thomas Schmitt Reviewed-by: Daniel Kiper --- diff --git a/tests/grub_cmd_cryptomount.in b/tests/grub_cmd_cryptomount.in index f4d8f3547..63ed8e51b 100644 --- a/tests/grub_cmd_cryptomount.in +++ b/tests/grub_cmd_cryptomount.in @@ -48,6 +48,7 @@ _testcase() { _TMPDIR=$TMPDIR TMPDIR=$TMPDIR/`echo -n "$(date +%s).$LOGPREFIX" | sed -e 's,[ /],_,g' -e 's,:$,,g'` mkdir -p "$TMPDIR" + set -- "$@" $([ "${EXPECTEDRES}" -eq 1 ] && echo "--xfail") output=`"$@" 2>&1` || res=$? TMPDIR=$_TMPDIR diff --git a/tests/util/grub-shell-luks-tester.in b/tests/util/grub-shell-luks-tester.in index e695b9435..aa454d136 100644 --- a/tests/util/grub-shell-luks-tester.in +++ b/tests/util/grub-shell-luks-tester.in @@ -37,6 +37,7 @@ keyfile= keyfile_offset= keyfile_size= KEYFILE_SIZE_MAX=4096 +expected_res=0 debug="${GRUB_SHELL_LUKS_DEFAULT_DEBUG:-$GRUB_TEST_DEFAULT_DEBUG}" GRUB_SHELL_LUKS_TIMEOUT=${GRUB_SHELL_LUKS_TIMEOUT:-${GRUB_SHELL_DEFAULT_TIMEOUT:-600s}} @@ -59,6 +60,7 @@ running in a QEMU instance. --detached-header Use a detached header --keyfile[=FILE] Use a randomly generated key file of size $KEYFILE_SIZE_MAX if not given a FILE to use as the key file. + --xfail Expected failure, so cleanup as if on success $0 creates a LUKS disk with cryptsetup, then verify that it is accessible by grub running in a QEMU instance. @@ -107,6 +109,8 @@ for option in "$@"; do --disksize=*) qs=`echo "$option" | sed -e 's/--disksize=//'` disksize="$qs" ;; + --xfail) + expected_res=1 ;; -*) echo "Unrecognized option \`$option'" 1>&2 usage @@ -136,7 +140,7 @@ cleanup() { if [ -e "$luksdev" ]; then cryptsetup close "$luksdev" fi - if [ -z "$debug" ] && [ "${RET:-1}" -eq 0 ]; then + if [ -z "$debug" ] && [ "$RET" -eq "$expected_res" ]; then rm -rf "$lukstestdir" || : fi }