diff mbox series

[4/5] Add support for setting loop device size in shell tests

Message ID 20241101141111.104803-5-mdoucha@suse.cz
State Accepted
Headers show
Series Add LVM and NFS tests for file data integrity | expand

Commit Message

Martin Doucha Nov. 1, 2024, 2:11 p.m. UTC
Add TST_DEVICE_SIZE variable to set loop device size.

Signed-off-by: Martin Doucha <mdoucha@suse.cz>
---
 doc/developers/writing_tests.rst | 2 +-
 testcases/lib/tst_test.sh        | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

Comments

Petr Vorel Nov. 1, 2024, 10:45 p.m. UTC | #1
Hi Martin,

> Add TST_DEVICE_SIZE variable to set loop device size.

obviously correct, thanks!
Reviewed-by: Petr Vorel <pvorel@suse.cz>

Maybe we should (later) add trivial shell API test into lib/newlib_tests/shell,
which creates the device and tests if the size is expected.

Kind regards,
Petr
Petr Vorel Nov. 28, 2024, 8:19 a.m. UTC | #2
Hi Martin,

merged previous commit (fsplough) and this one. Thanks!

Kind regards,
Petr
diff mbox series

Patch

diff --git a/doc/developers/writing_tests.rst b/doc/developers/writing_tests.rst
index 2293800a1..ab633121e 100644
--- a/doc/developers/writing_tests.rst
+++ b/doc/developers/writing_tests.rst
@@ -390,7 +390,7 @@  LTP C And Shell Test API Comparison
       - TST_FS_TYPE
 
     * - .dev_min_size
-      - not applicable
+      - TST_DEVICE_SIZE
 
     * - .format_device
       - TST_FORMAT_DEVICE
diff --git a/testcases/lib/tst_test.sh b/testcases/lib/tst_test.sh
index c19c30b76..cfdae0230 100644
--- a/testcases/lib/tst_test.sh
+++ b/testcases/lib/tst_test.sh
@@ -687,6 +687,7 @@  tst_run()
 			CHECKPOINT_WAKE2|CHECKPOINT_WAKE_AND_WAIT);;
 			DEV_EXTRA_OPTS|DEV_FS_OPTS|FORMAT_DEVICE|MOUNT_DEVICE);;
 			SKIP_FILESYSTEMS|SKIP_IN_LOCKDOWN|SKIP_IN_SECUREBOOT);;
+			DEVICE_SIZE);;
 			*) tst_res TWARN "Reserved variable TST_$_tst_i used!";;
 			esac
 		done
@@ -750,7 +751,7 @@  tst_run()
 
 	# 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)
+		TST_DEVICE=$(tst_device acquire $TST_DEVICE_SIZE)
 
 		if [ ! -b "$TST_DEVICE" -o $? -ne 0 ]; then
 			unset TST_DEVICE