Skip to content

Commit a68eed9

Browse files
dmendes-rhdavem330
authored andcommitted
kselftest: rtnetlink: add pause and pause on fail flag
'Pause' prompts the user to press Enter to continue running tests once one test has finished. Pause on fail on prompts the user to press enter only when a test fails. Modifications to kci_test_addrlft() and kci_test_ipsec_offload() ensure that whenever end_test is called, [$ret -ne 0] indicates failure. This allows end_test to really easily implement pause on fail functionality. Signed-off-by: Daniel Mendes <dmendes@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 9c2a19f commit a68eed9

1 file changed

Lines changed: 23 additions & 4 deletions

File tree

tools/testing/selftests/net/rtnetlink.sh

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ ALL_TESTS="
3232

3333
devdummy="test-dummy0"
3434
VERBOSE=0
35+
PAUSE=no
36+
PAUSE_ON_FAIL=no
3537

3638
# Kselftest framework requirement - SKIP code is 4.
3739
ksft_skip=4
@@ -112,6 +114,17 @@ end_test()
112114
{
113115
echo "$*"
114116
[ "${VERBOSE}" = "1" ] && echo
117+
118+
if [[ $ret -ne 0 ]] && [[ "${PAUSE_ON_FAIL}" = "yes" ]]; then
119+
echo "Hit enter to continue"
120+
read a
121+
fi;
122+
123+
if [ "${PAUSE}" = "yes" ]; then
124+
echo "Hit enter to continue"
125+
read a
126+
fi
127+
115128
}
116129

117130

@@ -286,8 +299,8 @@ kci_test_addrlft()
286299
sleep 5
287300
run_cmd_grep "10.23.11." ip addr show dev "$devdummy"
288301
if [ $? -eq 0 ]; then
289-
end_test "FAIL: preferred_lft addresses remaining"
290302
check_err 1
303+
end_test "FAIL: preferred_lft addresses remaining"
291304
return
292305
fi
293306

@@ -779,8 +792,8 @@ kci_test_ipsec_offload()
779792
# does offload show up in ip output
780793
lines=`ip x s list | grep -c "crypto offload parameters: dev $dev dir"`
781794
if [ $lines -ne 2 ] ; then
782-
end_test "FAIL: ipsec_offload SA offload missing from list output"
783795
check_err 1
796+
end_test "FAIL: ipsec_offload SA offload missing from list output"
784797
fi
785798

786799
# use ping to exercise the Tx path
@@ -806,8 +819,8 @@ EOF
806819
ip x p flush
807820
lines=`grep -c "SA count=0" $sysfsf`
808821
if [ $lines -ne 1 ] ; then
809-
end_test "FAIL: ipsec_offload SA not removed from driver"
810822
check_err 1
823+
end_test "FAIL: ipsec_offload SA not removed from driver"
811824
fi
812825

813826
# clean up any leftovers
@@ -1254,6 +1267,8 @@ usage: ${0##*/} OPTS
12541267
-t <test> Test(s) to run (default: all)
12551268
(options: $(echo $ALL_TESTS))
12561269
-v Verbose mode (show commands and output)
1270+
-P Pause after every test
1271+
-p Pause after every failing test before cleanup (for debugging)
12571272
EOF
12581273
}
12591274

@@ -1271,15 +1286,19 @@ for x in ip tc;do
12711286
fi
12721287
done
12731288

1274-
while getopts t:hv o; do
1289+
while getopts t:hvpP o; do
12751290
case $o in
12761291
t) TESTS=$OPTARG;;
12771292
v) VERBOSE=1;;
1293+
p) PAUSE_ON_FAIL=yes;;
1294+
P) PAUSE=yes;;
12781295
h) usage; exit 0;;
12791296
*) usage; exit 1;;
12801297
esac
12811298
done
12821299

1300+
[ $PAUSE = "yes" ] && PAUSE_ON_FAIL="no"
1301+
12831302
kci_test_rtnl
12841303

12851304
exit $?

0 commit comments

Comments
 (0)