[PATCH nft 1/1] tests/shell: accept name of dump files in place of test names

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]


Imagine you have the filename of a dump file at hand. For example, because
it shows up in `git status` and you can copy it from the terminal.

If you want to run the corresponding test, that was cumbersome. It
involved editing the command line (removing the /dumps/ directory and
the file suffix).

Instead, let "run-tests.sh" do that automatically. There is little value
in bothering the user with a failure:


  $ ./tests/shell/run-tests.sh tests/shell/testcases/optionals/dumps/comments_table_0.json-nft -L
  E: Unknown test "tests/shell/testcases/optionals/dumps/comments_table_0.json-nft"

  $ ./tests/shell/run-tests.sh tests/shell/testcases/optionals/dumps/comments_table_0.json-nft -L

Signed-off-by: Thomas Haller <thaller@xxxxxxxxxx>
 tests/shell/run-tests.sh | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/tests/shell/run-tests.sh b/tests/shell/run-tests.sh
index 3cde97b7ea17..c26142b7ff17 100755
--- a/tests/shell/run-tests.sh
+++ b/tests/shell/run-tests.sh
@@ -431,6 +431,19 @@ for t in "${TESTSOLD[@]}" ; do
 	elif [ -d "$t" ] ; then
 		TESTS+=( $(find_tests "$t") )
+		if [ -f "$t" ] ; then
+			# If the test name looks like a dumps file, autodetect
+			# the correct test name. It's not useful to bother the
+			# user with a failure in this case.
+			rx="^(.*/)?dumps/([^/]+)\\.(nodump|nft|json-nft)$"
+			if [[ "$t" =~ $rx ]] ; then
+				t2="${BASH_REMATCH[1]}${BASH_REMATCH[2]}"
+				if [ -f "$t2" -a -x "$t2" ] ; then
+					TESTS+=( "$t2" )
+					continue
+				fi
+			fi
+		fi
 		msg_error "Unknown test \"$t\""

[Index of Archives]     [Netfitler Users]     [Berkeley Packet Filter]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux