Skip to contentSkip to conversation

common: fix excluding test groups

PATCH Superseded Amir Goldstein 3 participants 7 messages Dec 8, 2016 – Dec 9, 2016

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

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
index 8f2a1bb..9732460 100755
@@ -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
#1 lore raw
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
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 +1 -0
index 8f2a1bb..9732460 100755
@@ -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

#2 lore raw
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 -l

You 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
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 +1 -0
index 8f2a1bb..9732460 100755
@@ -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.

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.

#3 lore raw
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 -l

You 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
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 +1 -0
index 8f2a1bb..9732460 100755
@@ -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.

Quoted 7 lines

Review

Quoted 3 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.

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
315

Check gets the explicit list of tests in this case and not the match pattern.

Amir.

#4 lore raw
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 -l

You 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
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 +1 -0
index 8f2a1bb..9732460 100755
@@ -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.

(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

#5 lore raw
In reply to Amir Goldstein
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
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 +1 -0
index 8f2a1bb..9732460 100755
@@ -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]
#6 lore raw
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
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 +1 -0
index 8f2a1bb..9732460 100755
@@ -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:

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.