common: fix excluding test groups
PATCH 1/1 common: fix excluding test groups
The -x flag is used to exclude tests that belong to certain groups from the test args list.
When the test args list is expressed as a match pattern, -x fails to exclude the tests that match the pattern and belong to excluded groups.
For example:
$ ./check -n -x xfs/??? | wc -l 341 $ ./check -n -x fuzzers,dangerous_fuzzers xfs/??? | wc -l 341
After the fix:
$ ./check -n -x fuzzers,dangerous_fuzzers xfs/??? | wc -l 315
This bug seems to date back to this git repo epoc.
--- check | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
check +6 -3
@@ -158,11 +158,14 @@ _timestamp() _prepare_test_list() { unset list + touch $tmp.list # Tests specified on the command line if [ -s $tmp.arglist ]; then - cat $tmp.arglist > $tmp.list - else - touch $tmp.list + # flatten multi tests line (tests/$fs/???) to 1 test per line + list=$(cat $tmp.arglist) + for t in $list; do + echo "$t" >> $tmp.list + done fi # Specified groups to include
Signature · 1 line
2.7.4
Quoted 9 lines · Amir Goldstein
The -x flag is used to exclude tests that belong to certain groups from the test args list.
When the test args list is expressed as a match pattern, -x fails to exclude the tests that match the pattern and belong to excluded groups.
For example:
$ ./check -n -x xfs/??? | wc -l
You mean "./check -n -x fuzzers,dangerous_fuzzers | wc -l" here?
Quoted 24 lines
341
$ ./check -n -x fuzzers,dangerous_fuzzers xfs/??? | wc -l 341After the fix:
$ ./check -n -x fuzzers,dangerous_fuzzers xfs/??? | wc -l 315This bug seems to date back to this git repo epoc.
Signed-off-by Amir Goldstein <[email protected]>--- check | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)check +1
-0@@ -158,11 +158,14 @@ _timestamp() _prepare_test_list() { unset list + touch $tmp.list
check _timestamp() · line 168
Quoted 10 lines
check +5
-3# Tests specified on the command line if [ -s $tmp.arglist ]; then - cat $tmp.arglist > $tmp.list - else - touch $tmp.list + # flatten multi tests line (tests/$fs/???) to 1 test per line + list=$(cat $tmp.arglist) + for t in $list; do + echo "$t" >> $tmp.list + done
Perhaps a sed is more efficient? e.g.
- cat $tmp.arglist > $tmp.list
+ sed 's/ \+/\n/g' $tmp.arglist > $tmp.list
Thanks,
Eryu
Quoted 4 lines · Eryu Guan
Quoted 3 lines · Amir Goldstein
The -x flag is used to exclude tests that belong to certain groups from the test args list.
Quoted 9 lines
Quoted 6 lines
When the test args list is expressed as a match pattern, -x fails to exclude the tests that match the pattern and belong to excluded groups.
For example:
$ ./check -n -x xfs/??? | wc -lYou mean "./check -n -x fuzzers,dangerous_fuzzers | wc -l" here?
No. I just wanted to present the total number of tests that match the pattern to show in the next line that -x does not exclude any tests.
Quoted 38 lines
Quoted 24 lines
341
$ ./check -n -x fuzzers,dangerous_fuzzers xfs/??? | wc -l 341After the fix:
$ ./check -n -x fuzzers,dangerous_fuzzers xfs/??? | wc -l 315This bug seems to date back to this git repo epoc.
Signed-off-by Amir Goldstein <[email protected]>--- check | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)check +1
-0@@ -158,11 +158,14 @@ _timestamp() _prepare_test_list() { unset list + touch $tmp.listcheck _timestamp() · line 168
Quoted 10 lines
check +5
-3# Tests specified on the command line if [ -s $tmp.arglist ]; then - cat $tmp.arglist > $tmp.list - else - touch $tmp.list + # flatten multi tests line (tests/$fs/???) to 1 test per line + list=$(cat $tmp.arglist) + for t in $list; do + echo "$t" >> $tmp.list + donePerhaps a sed is more efficient? e.g.
Review
Quoted 2 lines
(quoted diff) +1
-1- cat $tmp.arglist > $tmp.list + sed 's/ \+/\n/g' $tmp.arglist > $tmp.list
I have considered that and decided that efficiency is not an issue here and better have the robustness of the shell parser without having to worry about all the possible whitespace cases that I may be missing. Besides, this is exactly the same as the population of $tmp.arglist when the args list is expanded by the shell, which is BTW a workaround for this issue, e.g.:
$ ln -s tests/xfs xfs $ ./check -n -x fuzzers,dangerous_fuzzers xfs/??? | wc -l 315
Check gets the explicit list of tests in this case and not the match pattern.
Amir.
Quoted 9 lines · Amir Goldstein
Quoted 8 lines · Eryu Guan
Quoted 7 lines · Amir Goldstein
The -x flag is used to exclude tests that belong to certain groups from the test args list.
When the test args list is expressed as a match pattern, -x fails to exclude the tests that match the pattern and belong to excluded groups.
Quoted 9 lines
Quoted 5 lines
Quoted 2 lines
For example:
$ ./check -n -x xfs/??? | wc -lYou mean "./check -n -x fuzzers,dangerous_fuzzers | wc -l" here?
No. I just wanted to present the total number of tests that match the pattern to show in the next line that -x does not exclude any tests.
And yes, I have typo. Should be:
$ ./check -n xfs/??? | wc -l
Quoted 37 lines
Quoted 37 lines
Quoted 24 lines
341
$ ./check -n -x fuzzers,dangerous_fuzzers xfs/??? | wc -l 341After the fix:
$ ./check -n -x fuzzers,dangerous_fuzzers xfs/??? | wc -l 315This bug seems to date back to this git repo epoc.
Signed-off-by Amir Goldstein <[email protected]>--- check | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)check +1
-0@@ -158,11 +158,14 @@ _timestamp() _prepare_test_list() { unset list + touch $tmp.listcheck _timestamp() · line 168
Quoted 10 lines
check +5
-3# Tests specified on the command line if [ -s $tmp.arglist ]; then - cat $tmp.arglist > $tmp.list - else - touch $tmp.list + # flatten multi tests line (tests/$fs/???) to 1 test per line + list=$(cat $tmp.arglist) + for t in $list; do + echo "$t" >> $tmp.list + donePerhaps a sed is more efficient? e.g.
Quoted 7 lines
Review
Quoted 3 lines
(quoted diff) +1
-1- cat $tmp.arglist > $tmp.list + sed 's/ \+/\n/g' $tmp.arglist > $tmp.listI have considered that and decided that efficiency is not an issue here and better have the robustness of the shell parser without having to worry about all the possible whitespace cases that I may be missing.
But maybe that just because I am not confident enough about my regexp skills. If folks feel confident about the sed variant, I have no objection.
Quoted 11 lines
Besides, this is exactly the same as the population of $tmp.arglist when the args list is expanded by the shell, which is BTW a workaround for this issue, e.g.:
$ ln -s tests/xfs xfs $ ./check -n -x fuzzers,dangerous_fuzzers xfs/??? | wc -l 315Check gets the explicit list of tests in this case and not the match pattern.
Amir.
Quoted 33 lines · Amir Goldstein
The -x flag is used to exclude tests that belong to certain groups from the test args list.
When the test args list is expressed as a match pattern, -x fails to exclude the tests that match the pattern and belong to excluded groups.
For example:
$ ./check -n -x xfs/??? | wc -l 341 $ ./check -n -x fuzzers,dangerous_fuzzers xfs/??? | wc -l 341After the fix:
$ ./check -n -x fuzzers,dangerous_fuzzers xfs/??? | wc -l 315This bug seems to date back to this git repo epoc.
Signed-off-by Amir Goldstein <[email protected]>--- check | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)check +1
-0@@ -158,11 +158,14 @@ _timestamp() _prepare_test_list() { unset list + touch $tmp.list
check _timestamp() · line 168
Quoted 10 lines
check +5
-3# Tests specified on the command line if [ -s $tmp.arglist ]; then - cat $tmp.arglist > $tmp.list - else - touch $tmp.list + # flatten multi tests line (tests/$fs/???) to 1 test per line + list=$(cat $tmp.arglist) + for t in $list; do + echo "$t" >> $tmp.list + done
Shouldn't the wildcard be evaluated when the CLI argument is being processed and cheked against the group file contents, not hidden in this code? i.e. in the CLI argument processing section starting here:
# Process tests from command line now.
if $have_test_arg; then
....
Cheers,
Dave.
Signature · 2 lines
Dave Chinner [email protected]
Quoted 16 lines · Amir Goldstein
Quoted 15 lines · Amir Goldstein
Quoted 13 lines · Eryu Guan
Quoted 9 lines · Amir Goldstein
The -x flag is used to exclude tests that belong to certain groups from the test args list.
When the test args list is expressed as a match pattern, -x fails to exclude the tests that match the pattern and belong to excluded groups.
For example:
$ ./check -n -x xfs/??? | wc -lYou mean "./check -n -x fuzzers,dangerous_fuzzers | wc -l" here?
Quoted 6 lines
Quoted 3 lines
No. I just wanted to present the total number of tests that match the pattern to show in the next line that -x does not exclude any tests.
And yes, I have typo. Should be:
$ ./check -n xfs/??? | wc -l
I meant for this, and I pasted the wrong cmdline too.. sorry.
Quoted 42 lines
Quoted 42 lines
Quoted 41 lines
Quoted 25 lines
341
$ ./check -n -x fuzzers,dangerous_fuzzers xfs/??? | wc -l 341After the fix:
$ ./check -n -x fuzzers,dangerous_fuzzers xfs/??? | wc -l 315This bug seems to date back to this git repo epoc.
Signed-off-by Amir Goldstein <[email protected]>--- check | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)check +1
-0@@ -158,11 +158,14 @@ _timestamp() _prepare_test_list() { unset list + touch $tmp.listcheck _timestamp() · line 168
Quoted 10 lines
check +5
-3# Tests specified on the command line if [ -s $tmp.arglist ]; then - cat $tmp.arglist > $tmp.list - else - touch $tmp.list + # flatten multi tests line (tests/$fs/???) to 1 test per line + list=$(cat $tmp.arglist) + for t in $list; do + echo "$t" >> $tmp.list + donePerhaps a sed is more efficient? e.g.
(quoted diff) +1
-1- cat $tmp.arglist > $tmp.list + sed 's/ \+/\n/g' $tmp.arglist > $tmp.list
Quoted 6 lines
Quoted 3 lines
I have considered that and decided that efficiency is not an issue here and better have the robustness of the shell parser without having to worry about all the possible whitespace cases that I may be missing.
But maybe that just because I am not confident enough about my regexp skills. If folks feel confident about the sed variant, I have no objection.
$tmp.arglist is populated by
echo $SRC_DIR/$test_dir/$test_name >> $tmp.arglist
which actually is "echo tests/xfs/???", and it is expended to multiple tests in one line by bash in one shot, seperated by only one space. So I think it's safe & quick to do a sed on $tmp.arglist.
Quoted 8 lines
Quoted 8 lines
Besides, this is exactly the same as the population of $tmp.arglist when the args list is expanded by the shell, which is BTW a workaround for this issue, e.g.:
$ ln -s tests/xfs xfs $ ./check -n -x fuzzers,dangerous_fuzzers xfs/??? | wc -l 315
This is different, "xfs/???" is expended first by your interactive shell before passing it to check, so check sees multiple tests and iterates over them.
Thanks,
Eryu
Quoted 50 lines · Dave Chinner
Quoted 33 lines · Amir Goldstein
The -x flag is used to exclude tests that belong to certain groups from the test args list.
When the test args list is expressed as a match pattern, -x fails to exclude the tests that match the pattern and belong to excluded groups.
For example:
$ ./check -n -x xfs/??? | wc -l 341 $ ./check -n -x fuzzers,dangerous_fuzzers xfs/??? | wc -l 341After the fix:
$ ./check -n -x fuzzers,dangerous_fuzzers xfs/??? | wc -l 315This bug seems to date back to this git repo epoc.
Signed-off-by Amir Goldstein <[email protected]>--- check | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)check +1
-0@@ -158,11 +158,14 @@ _timestamp() _prepare_test_list() { unset list + touch $tmp.listcheck _timestamp() · line 168
Quoted 10 lines
check +5
-3# Tests specified on the command line if [ -s $tmp.arglist ]; then - cat $tmp.arglist > $tmp.list - else - touch $tmp.list + # flatten multi tests line (tests/$fs/???) to 1 test per line + list=$(cat $tmp.arglist) + for t in $list; do + echo "$t" >> $tmp.list + doneShouldn't the wildcard be evaluated when the CLI argument is being processed and cheked against the group file contents, not hidden in this code? i.e. in the CLI argument processing section starting here:
Quoted 4 lines
# Process tests from command line now.
if $have_test_arg; then
....
Yes, you are right.
The test:
if egrep "^$test_name" $group_file >/dev/null ; then
# in group file ... OK
is lousy if $test_name is ???
I moved the expansion to the right place.