public inbox for [email protected]
 help / color / mirror / Atom feed
* [PATCH liburing] test: use a map to define test files / devices we need
@ 2020-12-08 12:28 Hao Xu
  2020-12-15  2:44 ` Hao Xu
  0 siblings, 1 reply; 6+ messages in thread
From: Hao Xu @ 2020-12-08 12:28 UTC (permalink / raw)
  To: Jens Axboe; +Cc: io-uring, Joseph Qi

Different tests need different files / devices, use a map to indicate
what each test need.

Signed-off-by: Hao Xu <[email protected]>
---

the former implementation use a array for the global list TEST_FILES,
which may causes this:
	TEST_FILES="dev0 dev1"
	dev0 required by test0
	dev1 required by test1
In the <for tst in $TESTS> loop, we run the test for each $dev, which
makes <test0 dev1> and <test1 dev0> run, these are not expected.
Currently I see that statx.c accept argv[1] as a file_name, if someone
writes another test which defines a device(say nvme0n1) in TEST_FILES,
it may cause issues.

 test/config      |  2 +-
 test/runtests.sh | 13 ++++++-------
 2 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/test/config b/test/config
index cab270359155..1bd9b40207bb 100644
--- a/test/config
+++ b/test/config
@@ -4,4 +4,4 @@
 # TEST_EXCLUDE=""
 #
 # Define raw test devices (or files) for test cases, if any
-# TEST_FILES="/dev/nvme0n1p2 /data/file"
+# declare -A TEST_FILES=()
diff --git a/test/runtests.sh b/test/runtests.sh
index fa240f205542..1a6905b42768 100755
--- a/test/runtests.sh
+++ b/test/runtests.sh
@@ -5,10 +5,10 @@ RET=0
 TIMEOUT=60
 DMESG_FILTER="cat"
 TEST_DIR=$(dirname $0)
-TEST_FILES=""
 FAILED=""
 SKIPPED=""
 MAYBE_FAILED=""
+declare -A TEST_FILES
 
 # Only use /dev/kmsg if running as root
 DO_KMSG="1"
@@ -17,7 +17,7 @@ DO_KMSG="1"
 # Include config.local if exists and check TEST_FILES for valid devices
 if [ -f "$TEST_DIR/config.local" ]; then
 	. $TEST_DIR/config.local
-	for dev in $TEST_FILES; do
+	for dev in ${TEST_FILES[@]}; do
 		if [ ! -e "$dev" ]; then
 			echo "Test file $dev not valid"
 			exit 1
@@ -109,11 +109,10 @@ run_test()
 
 # Run all specified tests
 for tst in $TESTS; do
-	run_test $tst
-	if [ ! -z "$TEST_FILES" ]; then
-		for dev in $TEST_FILES; do
-			run_test $tst $dev
-		done
+	if [ ! -n "${TEST_FILES[$tst]}" ]; then
+		run_test $tst
+	else
+		run_test $tst ${TEST_FILES[$tst]}
 	fi
 done
 
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-01-27 12:07 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-12-08 12:28 [PATCH liburing] test: use a map to define test files / devices we need Hao Xu
2020-12-15  2:44 ` Hao Xu
2020-12-22  3:03   ` Hao Xu
2021-01-26  6:18     ` Hao Xu
2021-01-26 17:59       ` Jens Axboe
2021-01-27 12:04         ` Hao Xu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox