diff mbox series

[ima-evm-utils,v2,5/9] Introduce TST_LIST variable to select a test to execute

Message ID 20230112122426.3759938-6-roberto.sassu@huaweicloud.com (mailing list archive)
State New, archived
Headers show
Series Support testing with UML kernel | expand

Commit Message

Roberto Sassu Jan. 12, 2023, 12:24 p.m. UTC
From: Roberto Sassu <roberto.sassu@huawei.com>

It might be desirable, due to restrictions in the testing environment, to
execute tests individually. Introduce the TST_LIST variable, which can be
set with the name of the test to execute. If the variable is set,
expect_pass and expect_fail automatically skip the tests when the first
argument of those functions does not match the value of TST_LIST.

TST_LIST can be also used in conjunction with the UML kernel. It is
sufficient to add it to the kernel command line.

Signed-off-by: Roberto Sassu <roberto.sassu@huawei.com>
---
 tests/functions.sh | 12 ++++++++++++
 1 file changed, 12 insertions(+)

Comments

Stefan Berger Jan. 12, 2023, 3:07 p.m. UTC | #1
On 1/12/23 07:24, Roberto Sassu wrote:
> From: Roberto Sassu <roberto.sassu@huawei.com>
> 
> It might be desirable, due to restrictions in the testing environment, to
> execute tests individually. Introduce the TST_LIST variable, which can be
> set with the name of the test to execute. If the variable is set,
> expect_pass and expect_fail automatically skip the tests when the first
> argument of those functions does not match the value of TST_LIST.
> 
> TST_LIST can be also used in conjunction with the UML kernel. It is
> sufficient to add it to the kernel command line.
> 
> Signed-off-by: Roberto Sassu <roberto.sassu@huawei.com>
> ---
>   tests/functions.sh | 12 ++++++++++++
>   1 file changed, 12 insertions(+)
> 
> diff --git a/tests/functions.sh b/tests/functions.sh
> index 98829d94fae1..298c30393ce6 100755
> --- a/tests/functions.sh
> +++ b/tests/functions.sh
> @@ -72,6 +72,12 @@ declare -i TNESTED=0 # just for sanity checking
>   expect_pass() {
>     local -i ret
>   
> +  if [ -n "$TST_LIST" ] && [ "${TST_LIST/$1/}" = $TST_LIST ]; then

"$TSR_LIST" for consistency and if it comes to shellcheck also to address "Double quote to prevent globbing and word splitting."

> +    [ "$VERBOSE" -gt 1 ] && echo "____ SKIP test: $*"
> +    testsskip+=1
> +    return $SKIP
> +  fi
> +
>     if [ $TNESTED -gt 0 ]; then
>       echo $RED"expect_pass should not be run nested"$NORM
>       testsfail+=1
> @@ -98,6 +104,12 @@ expect_pass() {
>   expect_fail() {
>     local ret
>   
> +  if [ -n "$TST_LIST" ] && [ "${TST_LIST/$1/}" = $TST_LIST ]; then

Same here.

> +    [ "$VERBOSE" -gt 1 ] && echo "____ SKIP test: $*"
> +    testsskip+=1
> +    return $SKIP
> +  fi
> +
>     if [ $TNESTED -gt 0 ]; then
>       echo $RED"expect_fail should not be run nested"$NORM
>       testsfail+=1
diff mbox series

Patch

diff --git a/tests/functions.sh b/tests/functions.sh
index 98829d94fae1..298c30393ce6 100755
--- a/tests/functions.sh
+++ b/tests/functions.sh
@@ -72,6 +72,12 @@  declare -i TNESTED=0 # just for sanity checking
 expect_pass() {
   local -i ret
 
+  if [ -n "$TST_LIST" ] && [ "${TST_LIST/$1/}" = $TST_LIST ]; then
+    [ "$VERBOSE" -gt 1 ] && echo "____ SKIP test: $*"
+    testsskip+=1
+    return $SKIP
+  fi
+
   if [ $TNESTED -gt 0 ]; then
     echo $RED"expect_pass should not be run nested"$NORM
     testsfail+=1
@@ -98,6 +104,12 @@  expect_pass() {
 expect_fail() {
   local ret
 
+  if [ -n "$TST_LIST" ] && [ "${TST_LIST/$1/}" = $TST_LIST ]; then
+    [ "$VERBOSE" -gt 1 ] && echo "____ SKIP test: $*"
+    testsskip+=1
+    return $SKIP
+  fi
+
   if [ $TNESTED -gt 0 ]; then
     echo $RED"expect_fail should not be run nested"$NORM
     testsfail+=1