Skip to content

Commit 6c4c945

Browse files
committed
tst_test.sh: Fix missing cleanup run from setup
There was a regression on tests which don't use TST_ALL_FILESYSTEMS=1 when the cleanup function was not run when test called tst_brk in the setup function. This broke DCCP tests on kernels without dccp_ipv6 module: ./dccp_ipsec_vti.sh; ltp_file -p esp -m tunnel -s 100:500:1000:R1000 dccp_ipsec_vti 1 TINFO: Test vti + IPsec[esp/tunnel] ... netstress.c:970: TCONF: Failed to load dccp_ipv6 module Summary: passed 0 failed 0 broken 0 skipped 1 warnings 0 netstress.c:970: TCONF: Failed to load dccp_ipv6 module dccp_ipsec_vti 1 TCONF: server failed ./dccp4_ipsec02 dccp_ipsec.sh -p ah -m transport -s 100:500:1000:R1000 ... dccp_ipsec_vti 1 TINFO: Test vti + IPsec[esp/tunnel] dccp_ipsec_vti 1 TBROK: ip link add ltp_vti0 type vti local 10.0.0.2 remote 10.0.0.1 key 10 dev ltp_ns_veth2 failed: RTNETLINK answers: File exists The reason was that cleanup function call was moved from _tst_do_exit() to _tst_run_iterations() created for TST_ALL_FILESYSTEMS. But cleanup function still needs to be run in _tst_do_exit() (but only) if it weren't called before. Fixes: 1f6bd6e ("tst_test.sh: Add $TST_ALL_FILESYSTEMS") Reported-by: Martin Doucha <[email protected]> Reviewed-by: Cyril Hrubis <[email protected]> Signed-off-by: Petr Vorel <[email protected]>
1 parent 9b2d7d8 commit 6c4c945

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

testcases/lib/tst_test.sh

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,25 @@ export TST_LIB_LOADED=1
2424
trap "tst_brk TBROK 'test interrupted'" INT
2525
trap "unset _tst_setup_timer_pid; tst_brk TBROK 'test terminated'" TERM
2626

27+
_tst_do_cleanup()
28+
{
29+
if [ -n "$TST_DO_CLEANUP" -a -n "$TST_CLEANUP" -a -z "$TST_NO_CLEANUP" ]; then
30+
if command -v $TST_CLEANUP >/dev/null 2>/dev/null; then
31+
$TST_CLEANUP
32+
else
33+
tst_res TWARN "TST_CLEANUP=$TST_CLEANUP declared, but function not defined (or cmd not found)"
34+
fi
35+
fi
36+
TST_DO_CLEANUP=
37+
}
38+
2739
_tst_do_exit()
2840
{
2941
local ret=0
3042
TST_DO_EXIT=1
3143

44+
_tst_do_cleanup
45+
3246
cd "$LTPROOT"
3347
[ "$TST_MOUNT_FLAG" = 1 ] && tst_umount
3448

@@ -785,13 +799,7 @@ _tst_run_iterations()
785799
_tst_i=$((_tst_i-1))
786800
done
787801

788-
if [ -n "$TST_DO_CLEANUP" -a -n "$TST_CLEANUP" -a -z "$TST_NO_CLEANUP" ]; then
789-
if command -v $TST_CLEANUP >/dev/null 2>/dev/null; then
790-
$TST_CLEANUP
791-
else
792-
tst_res TWARN "TST_CLEANUP=$TST_CLEANUP declared, but function not defined (or cmd not found)"
793-
fi
794-
fi
802+
_tst_do_cleanup
795803

796804
if [ "$TST_MOUNT_FLAG" = 1 ]; then
797805
cd "$LTPROOT"

0 commit comments

Comments
 (0)