If not TMPDIR is set by the user then the test grub_cmd_cryptomount
creates about 20 directories named *LUKS*_test* in the root directory
and leaves them there when the test ends.
Initialize in the test script the variable TMPDIR to /tmp if it is not
set or if it set to empty text. To be consistent with the usage of
${TMPDIR:-/tmp} in the script, use ${TMPDIR:=/tmp} not ${TMPDIR=/tmp}.
Further delete each created directory as soon as the command of its
test case is finished.
Signed-off-by: Thomas Schmitt <[email protected]>
---
tests/grub_cmd_cryptomount.in | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/tests/grub_cmd_cryptomount.in b/tests/grub_cmd_cryptomount.in
index f4d8f3547..696e61e96 100644
--- a/tests/grub_cmd_cryptomount.in
+++ b/tests/grub_cmd_cryptomount.in
@@ -44,12 +44,23 @@ _testcase() {
local output
shift 2
+ # Use the environment variable TMPDIR, falling back to /tmp. This allows
+ # users to specify a different temporary directory, for example, if their
+ # /tmp is filled up or too small.
+ # Some other GRUB tests use this gesture with "=" rather than ":=".
+ # But in sync with the many occurences of ${TMPDIR:-/tmp}, this test uses
+ # ":=" to fill empty TMPDIR with "/tmp", regardless whether TMPDIR was
+ # set to empty or was not set at all.
+ : ${TMPDIR:=/tmp}
+
# Create a subdir in TMPDIR for each testcase
_TMPDIR=$TMPDIR
TMPDIR=$TMPDIR/`echo -n "$(date +%s).$LOGPREFIX" | sed -e 's,[ /],_,g' -e
's,:$,,g'`
mkdir -p "$TMPDIR"
output=`"$@" 2>&1` || res=$?
+
+ rmdir "$TMPDIR"
TMPDIR=$_TMPDIR
if [ "$res" -eq "$EXPECTEDRES" ]; then
--
2.39.2
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel