[LTP] [PATCH v3 01/10] tst_test.sh: Fix tst_mkfs() for tmpfs

Petr Vorel pvorel@suse.cz
Thu Aug 4 14:19:37 CEST 2022


+ add test for it.

This has been broken since ever, but get more problematic when
$TST_FORMAT_DEVICE got introduced.

Fixes: 7783ac3a0 ("lib/tst_test.sh: Add new shell library")
Fixes: 95734791c ("tst_test.sh: Add $TST_FORMAT_DEVICE and related vars")

Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
New in v3

 lib/newlib_tests/shell/tst_mount_device_tmpfs.sh | 15 +++++++++++++++
 testcases/lib/tst_test.sh                        |  5 +++++
 2 files changed, 20 insertions(+)
 create mode 100755 lib/newlib_tests/shell/tst_mount_device_tmpfs.sh

diff --git a/lib/newlib_tests/shell/tst_mount_device_tmpfs.sh b/lib/newlib_tests/shell/tst_mount_device_tmpfs.sh
new file mode 100755
index 000000000..36a78bc85
--- /dev/null
+++ b/lib/newlib_tests/shell/tst_mount_device_tmpfs.sh
@@ -0,0 +1,15 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (c) 2022 Petr Vorel <pvorel@suse.cz>
+
+TST_MOUNT_DEVICE=1
+TST_FS_TYPE=tmpfs
+TST_TESTFUNC=test
+
+test()
+{
+	EXPECT_PASS "cd $TST_MNTPOINT"
+}
+
+. tst_test.sh
+tst_run
diff --git a/testcases/lib/tst_test.sh b/testcases/lib/tst_test.sh
index a35fa2e7b..b7cf5f3d4 100644
--- a/testcases/lib/tst_test.sh
+++ b/testcases/lib/tst_test.sh
@@ -351,6 +351,11 @@ tst_mkfs()
 
 	opts="$@"
 
+	if [ "$fs_type" = tmpfs ]; then
+		tst_res TINFO "Skipping mkfs for TMPFS filesystem"
+		return
+	fi
+
 	if [ -z "$opts" ]; then
 		if [ "$TST_NEEDS_DEVICE" != 1 ]; then
 			tst_brk "Using default parameters in tst_mkfs requires TST_NEEDS_DEVICE=1"
-- 
2.37.1



More information about the ltp mailing list