diff mbox series

[1/1] tst_test.sh: Create (again) loop device in $TST_TMPDIR

Message ID 20221010085944.26814-1-pvorel@suse.cz
State Accepted
Headers show
Series [1/1] tst_test.sh: Create (again) loop device in $TST_TMPDIR | expand

Commit Message

Petr Vorel Oct. 10, 2022, 8:59 a.m. UTC
Before 1f6bd6e66 loop device for testing test_dev.img was created in
shell API after cd to $TST_TMPDIR, therefore automatically removed
during the cleanup in _tst_do_exit(). This got broken in 1f6bd6e66,
fix it.

Although it'd be good not relying on this order (full path could be kept
and then pass to rm), it's better to have all LTP temporary files under
$TST_TMPDIR, thus just restore the order.

Fixes: 1f6bd6e66 ("tst_test.sh: Add $TST_ALL_FILESYSTEMS")

Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
Hi,

I'm sorry for introducing yet another regression in
$TST_ALL_FILESYSTEMS.

Kind regards,
Petr

 testcases/lib/tst_test.sh | 27 ++++++++++++++-------------
 1 file changed, 14 insertions(+), 13 deletions(-)

Comments

Li Wang Oct. 11, 2022, 2:55 a.m. UTC | #1
Reviewed-by: Li Wang <liwang@redhat.com>
Cyril Hrubis Oct. 11, 2022, 9:58 a.m. UTC | #2
Hi!
Reviewed-by: Cyril Hrubis <chrubis@suse.cz>
Petr Vorel Oct. 11, 2022, 12:17 p.m. UTC | #3
Hi all,

thanks for your review, merged.

Kind regards,
Petr
diff mbox series

Patch

diff --git a/testcases/lib/tst_test.sh b/testcases/lib/tst_test.sh
index 033491b08..5af345938 100644
--- a/testcases/lib/tst_test.sh
+++ b/testcases/lib/tst_test.sh
@@ -716,6 +716,20 @@  tst_run()
 	[ "$TST_FORMAT_DEVICE" = 1 -o "$TST_ALL_FILESYSTEMS" = 1 ] && TST_NEEDS_DEVICE=1
 	[ "$TST_NEEDS_DEVICE" = 1 ] && TST_NEEDS_TMPDIR=1
 
+	if [ "$TST_NEEDS_TMPDIR" = 1 ]; then
+		if [ -z "$TMPDIR" ]; then
+			export TMPDIR="/tmp"
+		fi
+
+		TST_TMPDIR=$(mktemp -d "$TMPDIR/LTP_$TST_ID.XXXXXXXXXX")
+
+		chmod 777 "$TST_TMPDIR"
+
+		TST_STARTWD=$(pwd)
+		cd "$TST_TMPDIR"
+	fi
+
+	# needs to be after cd $TST_TMPDIR to keep test_dev.img under $TST_TMPDIR
 	if [ "$TST_NEEDS_DEVICE" = 1 ]; then
 		TST_DEVICE=$(tst_device acquire)
 
@@ -730,19 +744,6 @@  tst_run()
 		fi
 	fi
 
-	if [ "$TST_NEEDS_TMPDIR" = 1 ]; then
-		if [ -z "$TMPDIR" ]; then
-			export TMPDIR="/tmp"
-		fi
-
-		TST_TMPDIR=$(mktemp -d "$TMPDIR/LTP_$TST_ID.XXXXXXXXXX")
-
-		chmod 777 "$TST_TMPDIR"
-
-		TST_STARTWD=$(pwd)
-		cd "$TST_TMPDIR"
-	fi
-
 	if [ "$TST_ALL_FILESYSTEMS" != 1 -a "$TST_SKIP_FILESYSTEMS" ]; then
 		if ! tst_supported_fs -s "$TST_SKIP_FILESYSTEMS" -d . > /dev/null; then
 			tst_brk TCONF "filesystem is not supported by the test"