Skip to contentSkip to conversation

check: fix excluded tests are only expunged in the first iteration

PATCH Superseded [email protected] 4 participants 6 messages Jun 30, 2023 – Jul 4, 2023

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 check: fix excluded tests are only expunged in the first iteration

From: Yuezhang Mo <[email protected]>

If iterating more than once and excluding some tests, the excluded tests are expunged in the first iteration, but run in subsequent iterations. This is not expected.

The problem was caused by the temporary file saving the excluded tests being deleted at the end of the first iteration.

This commit saves the excluded tests into a variable instead of a temp file.

---
 check | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)
check +10 -10
index e36978c1..a8071121 100755
@@ -27,6 +27,7 @@ DUMP_OUTPUT=false
 iterations=1
 istop=false
 loop_on_fail=0
+exclude_tests=()
 
 # This is a global variable used to pass test failure text to reporting gunk
 _err_msg=""
@@ -46,7 +47,7 @@ export DIFF_LENGTH=${DIFF_LENGTH:=10}
 # by default don't output timestamps
 timestamp=${TIMESTAMP:=false}
 
-rm -f $tmp.list $tmp.tmp $tmp.grep $here/$iam.out $tmp.xlist $tmp.report.* $tmp.arglist
+rm -f $tmp.list $tmp.tmp $tmp.grep $here/$iam.out $tmp.report.* $tmp.arglist
 
 SRC_GROUPS="generic shared"
 export SRC_DIR="tests"
@@ -302,13 +303,13 @@ while [ $# -gt 0 ]; do
 		;;
 	-e)
 		xfile=$2; shift ;
-		echo "$xfile" | tr ', ' '\n\n' >> $tmp.xlist
+		exclude_tests+=($(echo "$xfile" | tr ', ' '\n\n'))
 		;;
 
 	-E)	xfile=$2; shift ;
 		if [ -f $xfile ]; then
-			sed "s/#.*$//" "$xfile" >> $tmp.xlist
-	        fi
+			exclude_tests+=($(sed "s/#.*$//" "$xfile"))
+		fi
 		;;
 	-s)	RUN_SECTION="$RUN_SECTION $2"; shift ;;
 	-S)	EXCLUDE_SECTION="$EXCLUDE_SECTION $2"; shift ;;
@@ -383,7 +384,7 @@ if [ -n "$subdir_xfile" ]; then
 	for d in $SRC_GROUPS $FSTYP; do
 		[ -f $SRC_DIR/$d/$subdir_xfile ] || continue
 		for f in `sed "s/#.*$//" $SRC_DIR/$d/$subdir_xfile`; do
-			echo $d/$f >> $tmp.xlist
+			exclude_tests+=($d/$f)
 		done
 	done
 fi
@@ -570,11 +571,10 @@ _check_filesystems()
 _expunge_test()
 {
 	local TEST_ID="$1"
-	if [ -s $tmp.xlist ]; then
-		if grep -q $TEST_ID $tmp.xlist; then
-			echo "       [expunged]"
-			return 1
-		fi
+
+	if echo ${exclude_tests[*]} | grep -q $TEST_ID; then
+		echo "       [expunged]"
+		return 1
 	fi
 	return 0
 }
Signature · 1 line
2.25.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · On Fri, Jun 30, 2023 at 08:28:29PM +0800, [email protected] wrote:

From: Yuezhang Mo <[email protected]>

If iterating more than once and excluding some tests, the excluded tests are expunged in the first iteration, but run in subsequent iterations. This is not expected.

Quoted 7 lines

The problem was caused by the temporary file saving the excluded tests being deleted at the end of the first iteration.

This commit saves the excluded tests into a variable instead of a temp file.

Makes sense.

Quoted 70 lines
---
 check | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)
check +10 -10
index e36978c1..a8071121 100755
@@ -27,6 +27,7 @@ DUMP_OUTPUT=false
 iterations=1
 istop=false
 loop_on_fail=0
+exclude_tests=()
 
 # This is a global variable used to pass test failure text to reporting gunk
 _err_msg=""
@@ -46,7 +47,7 @@ export DIFF_LENGTH=${DIFF_LENGTH:=10}
 # by default don't output timestamps
 timestamp=${TIMESTAMP:=false}
 
-rm -f $tmp.list $tmp.tmp $tmp.grep $here/$iam.out $tmp.xlist $tmp.report.* $tmp.arglist
+rm -f $tmp.list $tmp.tmp $tmp.grep $here/$iam.out $tmp.report.* $tmp.arglist
 
 SRC_GROUPS="generic shared"
 export SRC_DIR="tests"
@@ -302,13 +303,13 @@ while [ $# -gt 0 ]; do
 		;;
 	-e)
 		xfile=$2; shift ;
-		echo "$xfile" | tr ', ' '\n\n' >> $tmp.xlist
+		exclude_tests+=($(echo "$xfile" | tr ', ' '\n\n'))
 		;;
 
 	-E)	xfile=$2; shift ;
 		if [ -f $xfile ]; then
-			sed "s/#.*$//" "$xfile" >> $tmp.xlist
-	        fi
+			exclude_tests+=($(sed "s/#.*$//" "$xfile"))
+		fi
 		;;
 	-s)	RUN_SECTION="$RUN_SECTION $2"; shift ;;
 	-S)	EXCLUDE_SECTION="$EXCLUDE_SECTION $2"; shift ;;
@@ -383,7 +384,7 @@ if [ -n "$subdir_xfile" ]; then
 	for d in $SRC_GROUPS $FSTYP; do
 		[ -f $SRC_DIR/$d/$subdir_xfile ] || continue
 		for f in `sed "s/#.*$//" $SRC_DIR/$d/$subdir_xfile`; do
-			echo $d/$f >> $tmp.xlist
+			exclude_tests+=($d/$f)
 		done
 	done
 fi
@@ -570,11 +571,10 @@ _check_filesystems()
 _expunge_test()
 {
 	local TEST_ID="$1"
-	if [ -s $tmp.xlist ]; then
-		if grep -q $TEST_ID $tmp.xlist; then
-			echo "       [expunged]"
-			return 1
-		fi
+
+	if echo ${exclude_tests[*]} | grep -q $TEST_ID; then
+		echo "       [expunged]"
+		return 1
 	fi
 	return 0
 }
Signature · 1 line
2.25.1
#2 lore raw
In reply to [email protected]
Quoted 5 lines · On Fri, Jun 30, 2023 at 08:28:29PM +0800, [email protected] wrote:

From: Yuezhang Mo <[email protected]>

If iterating more than once and excluding some tests, the excluded tests are expunged in the first iteration, but run in subsequent iterations. This is not expected.

I don't get it. ./check only deletes $tmp.xlist at startup time, not between iterations. Is there somewhere that ./check exec's itself when you run ./check -i 5 ?

Quoted 33 lines

The problem was caused by the temporary file saving the excluded tests being deleted at the end of the first iteration.

This commit saves the excluded tests into a variable instead of a temp file.

---
 check | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)
check +2 -1
index e36978c1..a8071121 100755
@@ -27,6 +27,7 @@ DUMP_OUTPUT=false
 iterations=1
 istop=false
 loop_on_fail=0
+exclude_tests=()
 
 # This is a global variable used to pass test failure text to reporting gunk
 _err_msg=""
@@ -46,7 +47,7 @@ export DIFF_LENGTH=${DIFF_LENGTH:=10}
 # by default don't output timestamps
 timestamp=${TIMESTAMP:=false}
 
-rm -f $tmp.list $tmp.tmp $tmp.grep $here/$iam.out $tmp.xlist $tmp.report.* $tmp.arglist
+rm -f $tmp.list $tmp.tmp $tmp.grep $here/$iam.out $tmp.report.* $tmp.arglist
 
 SRC_GROUPS="generic shared"
 export SRC_DIR="tests"

check while [ $# -gt 0 ]; do · line 306

Quoted 5 lines
check +1 -1
@@ -302,13 +303,13 @@ while [ $# -gt 0 ]; do
 		;;
 	-e)
 		xfile=$2; shift ;
-		echo "$xfile" | tr ', ' '\n\n' >> $tmp.xlist
+		exclude_tests+=($(echo "$xfile" | tr ', ' '\n\n'))

Please use readarray/mapfile for storing to a bash array, please.

--D

Quoted 39 lines
check +7 -8
 		;;
 
 	-E)	xfile=$2; shift ;
 		if [ -f $xfile ]; then
-			sed "s/#.*$//" "$xfile" >> $tmp.xlist
-	        fi
+			exclude_tests+=($(sed "s/#.*$//" "$xfile"))
+		fi
 		;;
 	-s)	RUN_SECTION="$RUN_SECTION $2"; shift ;;
 	-S)	EXCLUDE_SECTION="$EXCLUDE_SECTION $2"; shift ;;
@@ -383,7 +384,7 @@ if [ -n "$subdir_xfile" ]; then
 	for d in $SRC_GROUPS $FSTYP; do
 		[ -f $SRC_DIR/$d/$subdir_xfile ] || continue
 		for f in `sed "s/#.*$//" $SRC_DIR/$d/$subdir_xfile`; do
-			echo $d/$f >> $tmp.xlist
+			exclude_tests+=($d/$f)
 		done
 	done
 fi
@@ -570,11 +571,10 @@ _check_filesystems()
 _expunge_test()
 {
 	local TEST_ID="$1"
-	if [ -s $tmp.xlist ]; then
-		if grep -q $TEST_ID $tmp.xlist; then
-			echo "       [expunged]"
-			return 1
-		fi
+
+	if echo ${exclude_tests[*]} | grep -q $TEST_ID; then
+		echo "       [expunged]"
+		return 1
 	fi
 	return 0
 }
Signature · 1 line
2.25.1
#3 lore raw
In reply to [email protected]
Quoted 5 lines · On Fri, Jun 30, 2023 at 08:28:29PM +0800, [email protected] wrote:

From: Yuezhang Mo <[email protected]>

If iterating more than once and excluding some tests, the excluded tests are expunged in the first iteration, but run in subsequent iterations. This is not expected.

Can you provide an example about how to reproduce the issue you metioned above.

Quoted 34 lines

The problem was caused by the temporary file saving the excluded tests being deleted at the end of the first iteration.

This commit saves the excluded tests into a variable instead of a temp file.

---
 check | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)
check +2 -1
index e36978c1..a8071121 100755
@@ -27,6 +27,7 @@ DUMP_OUTPUT=false
 iterations=1
 istop=false
 loop_on_fail=0
+exclude_tests=()
 
 # This is a global variable used to pass test failure text to reporting gunk
 _err_msg=""
@@ -46,7 +47,7 @@ export DIFF_LENGTH=${DIFF_LENGTH:=10}
 # by default don't output timestamps
 timestamp=${TIMESTAMP:=false}
 
-rm -f $tmp.list $tmp.tmp $tmp.grep $here/$iam.out $tmp.xlist $tmp.report.* $tmp.arglist
+rm -f $tmp.list $tmp.tmp $tmp.grep $here/$iam.out $tmp.report.* $tmp.arglist
 
 SRC_GROUPS="generic shared"
 export SRC_DIR="tests"

check while [ $# -gt 0 ]; do · line 306

Quoted 5 lines
check +1 -1
@@ -302,13 +303,13 @@ while [ $# -gt 0 ]; do
 		;;
 	-e)
 		xfile=$2; shift ;
-		echo "$xfile" | tr ', ' '\n\n' >> $tmp.xlist
+		exclude_tests+=($(echo "$xfile" | tr ', ' '\n\n'))

If print to a file, I don't mind above way. But if to an array, how about:

  read -a tmpxlist < <(echo "$xfile" | tr ',' ' ')
  exclude_tests+=(${tmpxlist[@]})

check while [ $# -gt 0 ]; do · line 312

Quoted 8 lines
check +2 -2
 		;;
 
 	-E)	xfile=$2; shift ;
 		if [ -f $xfile ]; then
-			sed "s/#.*$//" "$xfile" >> $tmp.xlist
-	        fi
+			exclude_tests+=($(sed "s/#.*$//" "$xfile"))
+		fi

Similar as above, how about:

  readarray tmpxlist < <(sed "s/#.*$//" $xfile)
  exclude_tests+=(${tmpxlist[@]})

Feel free to provide better methods if anyone has.

Quoted 13 lines
check +1 -1
 		;;
 	-s)	RUN_SECTION="$RUN_SECTION $2"; shift ;;
 	-S)	EXCLUDE_SECTION="$EXCLUDE_SECTION $2"; shift ;;
@@ -383,7 +384,7 @@ if [ -n "$subdir_xfile" ]; then
 	for d in $SRC_GROUPS $FSTYP; do
 		[ -f $SRC_DIR/$d/$subdir_xfile ] || continue
 		for f in `sed "s/#.*$//" $SRC_DIR/$d/$subdir_xfile`; do
-			echo $d/$f >> $tmp.xlist
+			exclude_tests+=($d/$f)
 		done
 	done
 fi

check _check_filesystems() · line 575

Quoted 10 lines
check +2 -5
@@ -570,11 +571,10 @@ _check_filesystems()
 _expunge_test()
 {
 	local TEST_ID="$1"
-	if [ -s $tmp.xlist ]; then
-		if grep -q $TEST_ID $tmp.xlist; then
-			echo "       [expunged]"
-			return 1
-		fi
+
+	if echo ${exclude_tests[*]} | grep -q $TEST_ID; then

How about using the "-w" option to grep. Due to the number of fstests' cases will out of 999 (I'm thinking about how to deal with it), we might have generic/1000 in one day. If so "grep generic/100" will match generic/1000 and generic/100 both.

Thanks,
Zorro

Quoted 8 lines
check +2 -0
+		echo "       [expunged]"
+		return 1
 	fi
 	return 0
 }
Signature · 1 line
2.25.1
#4 lore raw
Quoted 51 lines · Zorro Lang
Quoted 5 lines · On Fri, Jun 30, 2023 at 08:28:29PM +0800, [email protected] wrote:

From: Yuezhang Mo <[email protected]>

If iterating more than once and excluding some tests, the excluded tests are expunged in the first iteration, but run in subsequent iterations. This is not expected.

Can you provide an example about how to reproduce the issue you metioned above.

Quoted 34 lines

The problem was caused by the temporary file saving the excluded tests being deleted at the end of the first iteration.

This commit saves the excluded tests into a variable instead of a temp file.

---
 check | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)
check +2 -1
index e36978c1..a8071121 100755
@@ -27,6 +27,7 @@ DUMP_OUTPUT=false
 iterations=1
 istop=false
 loop_on_fail=0
+exclude_tests=()
 
 # This is a global variable used to pass test failure text to reporting gunk
 _err_msg=""
@@ -46,7 +47,7 @@ export DIFF_LENGTH=${DIFF_LENGTH:=10}
 # by default don't output timestamps
 timestamp=${TIMESTAMP:=false}
 
-rm -f $tmp.list $tmp.tmp $tmp.grep $here/$iam.out $tmp.xlist $tmp.report.* $tmp.arglist
+rm -f $tmp.list $tmp.tmp $tmp.grep $here/$iam.out $tmp.report.* $tmp.arglist
 
 SRC_GROUPS="generic shared"
 export SRC_DIR="tests"

check while [ $# -gt 0 ]; do · line 306

Quoted 5 lines
check +1 -1
@@ -302,13 +303,13 @@ while [ $# -gt 0 ]; do
 		;;
 	-e)
 		xfile=$2; shift ;
-		echo "$xfile" | tr ', ' '\n\n' >> $tmp.xlist
+		exclude_tests+=($(echo "$xfile" | tr ', ' '\n\n'))

If print to a file, I don't mind above way. But if to an array, how about:

Quoted 2 lines
  read -a tmpxlist < <(echo "$xfile" | tr ',' ' ')
  exclude_tests+=(${tmpxlist[@]})

readarray -t -O "${#exclude_tests[@]}" exclude_tests < <(echo "$xfile" | tr ',' ' '))

Quoted 35 lines

check while [ $# -gt 0 ]; do · line 312

Quoted 8 lines
check +2 -2
 		;;
 
 	-E)	xfile=$2; shift ;
 		if [ -f $xfile ]; then
-			sed "s/#.*$//" "$xfile" >> $tmp.xlist
-	        fi
+			exclude_tests+=($(sed "s/#.*$//" "$xfile"))
+		fi

Similar as above, how about:

  readarray tmpxlist < <(sed "s/#.*$//" $xfile)
  exclude_tests+=(${tmpxlist[@]})

Feel free to provide better methods if anyone has.

Quoted 19 lines
check +1 -4
 		;;
 	-s)	RUN_SECTION="$RUN_SECTION $2"; shift ;;
 	-S)	EXCLUDE_SECTION="$EXCLUDE_SECTION $2"; shift ;;
@@ -383,7 +384,7 @@ if [ -n "$subdir_xfile" ]; then
 	for d in $SRC_GROUPS $FSTYP; do
 		[ -f $SRC_DIR/$d/$subdir_xfile ] || continue
 		for f in `sed "s/#.*$//" $SRC_DIR/$d/$subdir_xfile`; do
-			echo $d/$f >> $tmp.xlist
+			exclude_tests+=($d/$f)
 		done
 	done
 fi
@@ -570,11 +571,10 @@ _check_filesystems()
 _expunge_test()
 {
 	local TEST_ID="$1"
-	if [ -s $tmp.xlist ]; then
-		if grep -q $TEST_ID $tmp.xlist; then
-			echo "       [expunged]"
Quoted 8 lines

check _check_filesystems() · line 575

Quoted 4 lines
check +2 -2
-			return 1
-		fi
+
+	if echo ${exclude_tests[*]} | grep -q $TEST_ID; then

How about using the "-w" option to grep. Due to the number of fstests' cases will out of 999 (I'm thinking about how to deal with it), we might have generic/1000 in one day.

Four digit ids work fine; I've had xfs/12xx and xfs/15xx in djwong-dev for years now with no problems.

Quoted 2 lines

If so "grep generic/100" will match generic/1000 and generic/100 both.

Yeah, that grep string ought to be grep -q "^$TEST_ID$" or something.

Or

is_excluded() {
	for f in "${exclude_tests[@]}"; do
		[[ "$f" == "$1" ]] && return 0
	done
	return 1
}

(Though saving the overhead of one fork/exec is probably minimal.)

	if is_excluded "$TEST_ID"; then ...

--D

Quoted 12 lines

Thanks,
Zorro

Quoted 8 lines
check +2 -0
+		echo "       [expunged]"
+		return 1
 	fi
 	return 0
 }
Signature · 1 line
2.25.1
#5 lore raw
In reply to Zorro Lang
Quoted 8 lines · On Fri, Jun 30, 2023 at 08:28:29PM +0800, [email protected] wrote:
Quoted 5 lines

From: Yuezhang Mo <[email protected]>

If iterating more than once and excluding some tests, the excluded tests are expunged in the first iteration, but run in subsequent iterations. This is not expected.

Can you provide an example about how to reproduce the issue you metioned above.

If run ./check -i 5 -e generic/013.

- generic/013 is expunged in the iteration 1.
generic/013 [expunged]

- But generic/013 is not expunged in the iteration 2/3/4/5. generic/013 76s ... 78s

Quoted 23 lines
Quoted 4 lines

  -e)
  xfile=$2; shift ;
- echo "$xfile" | tr ', ' '\n\n' >> $tmp.xlist
+ exclude_tests+=($(echo "$xfile" | tr ', ' '\n\n'))

If print to a file, I don't mind above way. But if to an array, how about:

read -a tmpxlist < <(echo "$xfile" | tr ',' ' ')
 exclude_tests+=(${tmpxlist[@]})

Quoted 3 lines

+ exclude_tests+=($(sed "s/#.*$//" "$xfile"))

+ fi

Similar as above, how about:

readarray tmpxlist < <(sed "s/#.*$//" $xfile)
exclude_tests+=(${tmpxlist[@]})

Feel free to provide better methods if anyone has.

Quoted 8 lines
Quoted 1 line

+ if echo ${exclude_tests[*]} | grep -q $TEST_ID; then

How about using the "-w" option to grep. Due to the number of fstests' cases will out of 999 (I'm thinking about how to deal with it), we might have generic/1000 in one day. If so "grep generic/100" will match generic/1000 and

generic/100 both.

OK, I will update the patch.