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 <scdbac...@gmx.net>
Signed-off-by: Glenn Washburn <developm...@efficientek.com>
---
 tests/grub_cmd_cryptomount.in        | 1 +
 tests/util/grub-shell-luks-tester.in | 6 +++++-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/tests/grub_cmd_cryptomount.in b/tests/grub_cmd_cryptomount.in
index f4d8f35473d0..63ed8e51bec3 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 855ad39c19c3..abb0013e4387 100644
--- a/tests/util/grub-shell-luks-tester.in
+++ b/tests/util/grub-shell-luks-tester.in
@@ -36,6 +36,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}}
@@ -58,6 +59,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.
@@ -118,6 +120,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
@@ -147,7 +151,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
 }
-- 
2.34.1


_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel

Reply via email to