All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Schmitt via Grub-devel <grub-devel@gnu.org>
To: grub-devel@gnu.org
Cc: Thomas Schmitt <scdbackup@gmx.net>,
	development@efficientek.co, dkiper@net-space.pl
Subject: Re: [PATCH] tests: Let grub_cmd_cryptomount by default operate in /tmp rather than in /
Date: Tue, 13 Aug 2024 17:11:34 +0200	[thread overview]
Message-ID: <185630397967478553@scdbackup.webframe.org> (raw)
In-Reply-To: <20240813135925.ag7ta3ftsea4icgo@tomti.i.net-space.pl>

Hi,

i wrote:
> > Further delete each created directory as soon as the command of its
> > test case is finished.
> > [...]
> >      mkdir -p "$TMPDIR"
> >
> >      output=`"$@" 2>&1` || res=$?
> > +
> > +    rmdir "$TMPDIR"

Daniel Kiper wrote:
> s/rmdir/rm -rf/?

This is equivalent to the question whether remaining content shall be
removed silently. In my case the directories were all empty.

The worker in TMPDIR is  @builddir@/grub-shell-luks-tester  which stems
from  tests/util/grub-shell-luks-tester.in . It shows own effort to leave
a clean TMPDIR:

  cleanup() {
      ...
      if [ -z "$debug" ] && [ "${RET:-1}" -eq 0 ]; then
          rm -rf "$lukstestdir" || :
      fi
  }
  trap cleanup EXIT INT TERM KILL QUIT
  ...
  lukstestdir="`mktemp -d "${TMPDIR:-/tmp}/$(basename "$0").XXXXXXXXXX"`" || exit 20

Seeing the condition before "rm -rf", i guess tests/grub_cmd_cryptomount
should rather not remove the directory if it is not empty. A smarter way
than letting rmdir loudly fail seems appropriate, though.

If you agree to my assessment i will try to propose one in v2.

-----------------------------------------------------------------------
Self criticism:

I have recognized meanwhile that the proposed gesture

> > +    : ${TMPDIR:=/tmp}

stems from the gnulib subdirectory and is not tradition in the rest
of the GRUB git repo.
GRUB test tradition seems to be temporary defaulting of TMPDIR like in
line 174 of tests/grub_cmd_cryptomount.in :

  csscript=`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"` || exit 99

Indeed the patch would be less needy of a lengthy comment if i propose
something like this yet untested change instead:

-    TMPDIR=$TMPDIR/`echo -n "$(date +%s).$LOGPREFIX" | sed -e 's,[ /],_,g' -e 's,:$,,g'`
+    TMPDIR="${TMPDIR:-/tmp}"/`echo -n "$(date +%s).$LOGPREFIX" | sed -e 's,[ /],_,g' -e 's,:$,,g'`

If you agree to my assessment, i will propose this in patch v2.
(Tested, of course.)


Have a nice day :)

Thomas


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

  reply	other threads:[~2024-08-13 15:12 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=185630397967478553@scdbackup.webframe.org \
    --to=grub-devel@gnu.org \
    --cc=development@efficientek.co \
    --cc=dkiper@net-space.pl \
    --cc=scdbackup@gmx.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.