Skip to contentSkip to conversation

check: factor out get_sub_group_list() helper

PATCH In review Amir Goldstein 2 participants 5 messages Jan 2, 2017 – Jan 3, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 check: factor out get_sub_group_list() helper

This helper gets a list of tests that belong to a group under a specific tests subdir.

---
 check | 23 +++++++++++++++++------
 1 file changed, 17 insertions(+), 6 deletions(-)
check +17 -6
index cf6379b..faf6281 100755
@@ -87,19 +87,30 @@ testlist options
 	    exit 0
 }
 
+get_sub_group_list()
+{
+	local d=$1
+	local grp=$2
+
+	test -s "$SRC_DIR/$d/group" || return 1
+
+	local grpl=$(sed -n < $SRC_DIR/$d/group \
+		-e 's/#.*//' \
+		-e 's/$/ /' \
+		-e "s;^\($VALID_TEST_NAME\).* $grp .*;$SRC_DIR/$d/\1;p")
+	echo $grpl
+}
+
 get_group_list()
 {
-	grp=$1
+	local grp=$1
+	local grpl=""
 
 	for d in $SRC_GROUPS $FSTYP; do
 		if ! test -d "$SRC_DIR/$d" ; then
 			continue
 		fi
-		l=$(sed -n < $SRC_DIR/$d/group \
-			-e 's/#.*//' \
-			-e 's/$/ /' \
-			-e "s;^\($VALID_TEST_NAME\).* $grp .*;$SRC_DIR/$d/\1;p")
-		grpl="$grpl $l"
+		grpl="$grpl $(get_sub_group_list $d $grp)"
 	done
 	echo $grpl
 }
Signature · 1 line
2.7.4
#1 lore raw

PATCH 2/2 check: support include/exclude of sub groups

Allow including and/or excluding tests by test dir and group. -g and -x command line arguments can take the form of <subdir>/<group>.

For example:

./check -n -g xfs/quick
./check -n -g stress -x xfs/stress
./check -n -g xfs/punch -x dangerous_fuzzers

---
 check | 8 ++++++++
 1 file changed, 8 insertions(+)
check +8 -0
index faf6281..8d1ec71 100755
@@ -105,6 +105,14 @@ get_group_list()
 {
 	local grp=$1
 	local grpl=""
+	local sub=$(dirname $grp)
+
+	if [ -n "$sub" -a "$sub" != "." -a -d "$SRC_DIR/$sub" ]; then
+		# group is given as <subdir>/<group> (e.g. xfs/quick)
+		grp=$(basename $grp)
+		get_sub_group_list $sub $grp
+		return
+	fi
 
 	for d in $SRC_GROUPS $FSTYP; do
 		if ! test -d "$SRC_DIR/$d" ; then
Signature · 1 line
2.7.4
#2 lore raw

Re: [PATCH 2/2] check: support include/exclude of sub groups

Quoted 11 lines · Amir Goldstein

Allow including and/or excluding tests by test dir and group. -g and -x command line arguments can take the form of <subdir>/<group>.

For example:

./check -n -g xfs/quick
./check -n -g stress -x xfs/stress
./check -n -g xfs/punch -x dangerous_fuzzers

This looks handy to me! Mention this usage in usage() function too?

Thanks,
Eryu

Quoted 26 lines
---
 check | 8 ++++++++
 1 file changed, 8 insertions(+)
check +8 -0
index faf6281..8d1ec71 100755
@@ -105,6 +105,14 @@ get_group_list()
 {
 	local grp=$1
 	local grpl=""
+	local sub=$(dirname $grp)
+
+	if [ -n "$sub" -a "$sub" != "." -a -d "$SRC_DIR/$sub" ]; then
+		# group is given as <subdir>/<group> (e.g. xfs/quick)
+		grp=$(basename $grp)
+		get_sub_group_list $sub $grp
+		return
+	fi
 
 	for d in $SRC_GROUPS $FSTYP; do
 		if ! test -d "$SRC_DIR/$d" ; then
Signature · 1 line
2.7.4
#3 lore raw

Re: [PATCH 2/2] check: support include/exclude of sub groups

Quoted 7 lines · Eryu Guan
Quoted 6 lines · Amir Goldstein

Allow including and/or excluding tests by test dir and group. -g and -x command line arguments can take the form of <subdir>/<group>.

For example:

Quoted 8 lines
Quoted 5 lines

./check -n -g xfs/quick
./check -n -g stress -x xfs/stress
./check -n -g xfs/punch -x dangerous_fuzzers

This looks handy to me! Mention this usage in usage() function too?

usage() is so far behind and cryptic (what is the difference between -E and -X?) I will send a separate patch to address these and the new subgroup as well.

Quoted 29 lines

Thanks,
Eryu

Quoted 26 lines
---
 check | 8 ++++++++
 1 file changed, 8 insertions(+)
check +8 -1
index faf6281..8d1ec71 100755
@@ -105,6 +105,14 @@ get_group_list()
 {
      local grp=$1
      local grpl=""
+     local sub=$(dirname $grp)
+
+     if [ -n "$sub" -a "$sub" != "." -a -d "$SRC_DIR/$sub" ]; then
+             # group is given as <subdir>/<group> (e.g. xfs/quick)
+             grp=$(basename $grp)
+             get_sub_group_list $sub $grp
+             return
+     fi
 
      for d in $SRC_GROUPS $FSTYP; do
              if ! test -d "$SRC_DIR/$d" ; then
--

2.7.4

#4 lore raw

PATCH 3/3 check: document tests include/exclude options

In reply to Amir Goldstein

Add argument description and examples to usage() for the various tests include and exclude options.

---
 check | 29 ++++++++++++++++++++++++++++-
 1 file changed, 28 insertions(+), 1 deletion(-)
check +28 -1
index 8d1ec71..5a93c94 100755
@@ -80,9 +80,36 @@ check options
 testlist options
     -g group[,group...]	include tests from these groups
     -x group[,group...]	exclude tests from these groups
-    -X file		exclude individual tests
+    -X exclude_file	exclude individual tests
     -E external_file	exclude individual tests
     [testlist]		include tests matching names in testlist
+
+testlist argument is a list of tests in the form of <test dir>/<test name>.
+
+<test dir> is a directory under tests that contains a group file,
+with a list of the names of the tests in that directory.
+
+<test name> may be either a specific test file name (e.g. xfs/001) or
+a test file name match pattern (e.g. xfs/*).
+
+group argument is either a name of a tests group to collect from all
+the test dirs (e.g. quick) or a name of a tests group to collect from
+a specific tests dir in the form of <test dir>/<group name> (e.g. xfs/quick).
+
+exclude_file argument refers to a name of a file inside each test directory.
+for every test dir where this file is found, the listed test names are
+excluded from the list of tests to run from that test dir.
+
+external_file argument is a path to a single file containing a list of tests
+to exclude in the form of <test dir>/<test name>.
+
+examples:
+ check xfs/001
+ check -g quick
+ check -g xfs/quick
+ check -x stress xfs/*
+ check -X .exclude -g auto
+ check -E ~/.xfstests.exclude
 '
 	    exit 0
 }
Signature · 1 line
2.7.4