All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] tests: Let grub_cmd_cryptomount by default operate in /tmp rather than in /
@ 2024-07-24 16:48 Thomas Schmitt via Grub-devel
  2024-08-13 13:59 ` Daniel Kiper
  0 siblings, 1 reply; 9+ messages in thread
From: Thomas Schmitt via Grub-devel @ 2024-07-24 16:48 UTC (permalink / raw)
  To: grub-devel; +Cc: Thomas Schmitt, development

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 <scdbackup@gmx.net>
---
 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
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2024-09-23  5:57 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-24 16:48 [PATCH] tests: Let grub_cmd_cryptomount by default operate in /tmp rather than in / Thomas Schmitt via Grub-devel
2024-08-13 13:59 ` Daniel Kiper
2024-08-13 15:11   ` Thomas Schmitt via Grub-devel
2024-08-14 11:50     ` Daniel Kiper
2024-08-13 16:14   ` Thomas Schmitt via Grub-devel
2024-08-14 11:54     ` Daniel Kiper
2024-08-18 20:09       ` Thomas Schmitt via Grub-devel
2024-08-18 21:41         ` Thomas Schmitt via Grub-devel
2024-09-23  5:57           ` Glenn Washburn

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.