On Wed, Jan 12, 2022 at 09:59:42PM -0600, Glenn Washburn wrote:
> When all tests complete successfully, filesystems mounted by grub-fs-tester
> will be unmounted before exiting. However, on certain test failures the
> tester will exit with a failure code and not unmount previously mounted
> filesystems. Now keep track of mounts and umounts and run an exit handler
> on exit or process interruption that will umount all mounts that haven't
> already been unmounted.
>
> Signed-off-by: Glenn Washburn <developm...@efficientek.com>
> ---
>  tests/util/grub-fs-tester.in | 30 +++++++++++++++++++++++++++---
>  1 file changed, 27 insertions(+), 3 deletions(-)
>
> diff --git a/tests/util/grub-fs-tester.in b/tests/util/grub-fs-tester.in
> index a1f3f299b..b39831f27 100644
> --- a/tests/util/grub-fs-tester.in
> +++ b/tests/util/grub-fs-tester.in
> @@ -13,6 +13,17 @@ tempdir=`mktemp -d "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"` ||
>  # FSLABEL. This is especially needed for the conversion to Joliet UCS-2.
>  XORRISOFS_CHARSET="-input-charset UTF-8 -output-charset UTF-8"
>
> +MOUNTS=
> +umount_all() {

I would do s/umount_all/cleanup/ here and avoid rename in the next patch.

> +    for MOUNT in $MOUNTS; do

for i in $MOUNTS; do

It is a bit difficult to differentiate MOUNT and MOUNTS.

> +     umount "$MOUNT" &&
> +     MOUNTS="$(echo ${MOUNTS} | sed "s|$MOUNT||g;")"

I think this is unneeded. Is it?

> +    done
> +}
> +trap umount_all EXIT INT
> +# This is for bash, dash and ash do not recognize ERR
> +trap umount_all ERR || :

Daniel

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

Reply via email to