grub-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] tests: Let grub_cmd_cryptomount by default operate in /tmp r


From: Daniel Kiper
Subject: Re: [PATCH] tests: Let grub_cmd_cryptomount by default operate in /tmp rather than in /
Date: Tue, 13 Aug 2024 15:59:25 +0200
User-agent: NeoMutt/20170113 (1.7.2)

On Wed, Jul 24, 2024 at 06:48:45PM +0200, Thomas Schmitt via Grub-devel wrote:
> 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"

s/rmdir/rm -rf/?

Daniel



reply via email to

[Prev in Thread] Current Thread [Next in Thread]