From b465f2329183adf9735c81e98500cee93eb720c9 Mon Sep 17 00:00:00 2001 From: Paul Moore Date: Tue, 3 Aug 2021 11:07:43 -0400 Subject: tests: allow multiple test types using comma separated values You can now run multiple test types using the '-T' argument and the LIBSECCOMP_TSTCFG_TYPE environment variable, for example: % cd tests % ./regression -T bpf-valgrind,live Acked-by: Tom Hromatka Signed-off-by: Paul Moore --- tests/regression | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/regression b/tests/regression index 53dab75..09ac643 100755 --- a/tests/regression +++ b/tests/regression @@ -113,6 +113,21 @@ optional arguments: EOF } +# +# Match on a single word/column in a CSV string +# +# Arguments: +# 1 string containing the CSV +# 2 string containing the word to match +# +# Returns true/0 if a match is found false/1 otherwise. +# +function match_csv_word() { + [[ -z $1 || -z $2 ]] && return 1 + + echo "$1" | sed 's/,/ /g' | grep -w "$2" +} + # # Generate a string representing the test number # @@ -852,7 +867,9 @@ function run_test() { local testnumstr=$(generate_test_num "$1" $2 1) # ensure we only run tests which match the specified type - [[ -n $type && "$4" != "$type" ]] && return + match_csv_word "$type" "$4" + local type_match=$? + [[ -n $type && $type_match -eq 1 ]] && return # execute the function corresponding to the test type if [[ "$4" == "basic" ]]; then -- cgit v1.2.1