selftests: Declare local variable for pause in fcnal-test.sh
authorDavid Ahern <dsahern@kernel.org>
Tue, 30 Jan 2024 15:43:27 +0000 (08:43 -0700)
committerJakub Kicinski <kuba@kernel.org>
Thu, 1 Feb 2024 05:14:51 +0000 (21:14 -0800)
Running fcnal-test.sh script with -P argument is causing test failures:

  $ ./fcnal-test.sh -t ping -P
  TEST: ping out - ns-B IP                                       [ OK ]

  hit enter to continue, 'q' to quit

  fcnal-test.sh: line 106: [: ping: integer expression expected
  TEST: out,                                                     [FAIL]
      expected rc ping; actual rc 0

  hit enter to continue, 'q' to quit

The test functions use local variable 'a' for addresses and
then log_test is also using 'a' without a local declaration.
Fix by declaring a local variable and using 'ans' (for answer)
in the read.

Signed-off-by: David Ahern <dsahern@kernel.org>
Link: https://lore.kernel.org/r/20240130154327.33848-1-dsahern@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
tools/testing/selftests/net/fcnal-test.sh

index d7cfb7c2b427e80af7bedc68cf98f4bf129c8623..386ebd829df584ecd7a5ab1906b5f06f4c753fde 100755 (executable)
@@ -100,6 +100,7 @@ log_test()
        local rc=$1
        local expected=$2
        local msg="$3"
+       local ans
 
        [ "${VERBOSE}" = "1" ] && echo
 
@@ -113,16 +114,16 @@ log_test()
                if [ "${PAUSE_ON_FAIL}" = "yes" ]; then
                        echo
                        echo "hit enter to continue, 'q' to quit"
-                       read a
-                       [ "$a" = "q" ] && exit 1
+                       read ans
+                       [ "$ans" = "q" ] && exit 1
                fi
        fi
 
        if [ "${PAUSE}" = "yes" ]; then
                echo
                echo "hit enter to continue, 'q' to quit"
-               read a
-               [ "$a" = "q" ] && exit 1
+               read ans
+               [ "$ans" = "q" ] && exit 1
        fi
 
        kill_procs