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

* Re: [PATCH liburing] test: use a map to define test files / devices we need
  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
  0 siblings, 1 reply; 6+ messages in thread
From: Hao Xu @ 2020-12-15  2:44 UTC (permalink / raw)
  To: Jens Axboe; +Cc: io-uring, Joseph Qi

在 2020/12/8 下午8:28, Hao Xu 写道:
ping...
> 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
>   
> 


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

* Re: [PATCH liburing] test: use a map to define test files / devices we need
  2020-12-15  2:44 ` Hao Xu
@ 2020-12-22  3:03   ` Hao Xu
  2021-01-26  6:18     ` Hao Xu
  0 siblings, 1 reply; 6+ messages in thread
From: Hao Xu @ 2020-12-22  3:03 UTC (permalink / raw)
  To: Jens Axboe; +Cc: io-uring, Joseph Qi

在 2020/12/15 上午10:44, Hao Xu 写道:
> 在 2020/12/8 下午8:28, Hao Xu 写道:
> ping...
Hi Jens,
I'm currently develop a test which need a device arg, so I
leverage TEST_FILES, I found it may be better to form
TEST_FILES as a key-value structure.
Thanks && Regards,
Hao
>> 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
>>


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

* Re: [PATCH liburing] test: use a map to define test files / devices we need
  2020-12-22  3:03   ` Hao Xu
@ 2021-01-26  6:18     ` Hao Xu
  2021-01-26 17:59       ` Jens Axboe
  0 siblings, 1 reply; 6+ messages in thread
From: Hao Xu @ 2021-01-26  6:18 UTC (permalink / raw)
  To: Jens Axboe; +Cc: io-uring, Joseph Qi

在 2020/12/22 上午11:03, Hao Xu 写道:
> 在 2020/12/15 上午10:44, Hao Xu 写道:
>> 在 2020/12/8 下午8:28, Hao Xu 写道:
>> ping...
> Hi Jens,
> I'm currently develop a test which need a device arg, so I
> leverage TEST_FILES, I found it may be better to form
> TEST_FILES as a key-value structure.
> Thanks && Regards,
> Hao
ping again..
>>> 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
>>>


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

* Re: [PATCH liburing] test: use a map to define test files / devices we need
  2021-01-26  6:18     ` Hao Xu
@ 2021-01-26 17:59       ` Jens Axboe
  2021-01-27 12:04         ` Hao Xu
  0 siblings, 1 reply; 6+ messages in thread
From: Jens Axboe @ 2021-01-26 17:59 UTC (permalink / raw)
  To: Hao Xu; +Cc: io-uring, Joseph Qi

On 1/25/21 11:18 PM, Hao Xu wrote:
> 在 2020/12/22 上午11:03, Hao Xu 写道:
>> 在 2020/12/15 上午10:44, Hao Xu 写道:
>>> 在 2020/12/8 下午8:28, Hao Xu 写道:
>>> ping...
>> Hi Jens,
>> I'm currently develop a test which need a device arg, so I
>> leverage TEST_FILES, I found it may be better to form
>> TEST_FILES as a key-value structure.
>> Thanks && Regards,
>> Hao
> ping again..

Sorry about the delay - I have applied it, thanks.

-- 
Jens Axboe


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

* Re: [PATCH liburing] test: use a map to define test files / devices we need
  2021-01-26 17:59       ` Jens Axboe
@ 2021-01-27 12:04         ` Hao Xu
  0 siblings, 0 replies; 6+ messages in thread
From: Hao Xu @ 2021-01-27 12:04 UTC (permalink / raw)
  To: Jens Axboe; +Cc: io-uring, Joseph Qi

在 2021/1/27 上午1:59, Jens Axboe 写道:
> On 1/25/21 11:18 PM, Hao Xu wrote:
>> 在 2020/12/22 上午11:03, Hao Xu 写道:
>>> 在 2020/12/15 上午10:44, Hao Xu 写道:
>>>> 在 2020/12/8 下午8:28, Hao Xu 写道:
>>>> ping...
>>> Hi Jens,
>>> I'm currently develop a test which need a device arg, so I
>>> leverage TEST_FILES, I found it may be better to form
>>> TEST_FILES as a key-value structure.
>>> Thanks && Regards,
>>> Hao
>> ping again..
> 
> Sorry about the delay - I have applied it, thanks.
> 
No worries. Thanks, Jens.

^ permalink raw reply	[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