Skip to content

Commit 339c225

Browse files
Geliang Tangkuba-moo
authored andcommitted
selftests: mptcp: call test_fail without argument
This patch modifies test_fail() to call mptcp_lib_pr_fail() only if there are arguments (if [ ${#} -gt 0 ]) in userspace_pm.sh, add arguments "unexpected type: ${type}" when calling test_fail() from test_remove(). Then mptcp_lib_pr_fail() can be used in check_expected_one() instead of test_fail(). The same in mptcp_join.sh, calling fail_test() without argument, and adapt this helper not to call print_fail() in this case. Signed-off-by: Geliang Tang <[email protected]> Reviewed-by: Matthieu Baerts (NGI0) <[email protected]> Signed-off-by: Matthieu Baerts (NGI0) <[email protected]> Link: https://lore.kernel.org/r/20240308-upstream-net-next-20240308-selftests-mptcp-unification-v1-10-4f42c347b653@kernel.org Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 747ba87 commit 339c225

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

tools/testing/selftests/net/mptcp/mptcp_join.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,9 @@ fail_test()
452452
{
453453
ret=1
454454

455-
print_fail "${@}"
455+
if [ ${#} -gt 0 ]; then
456+
print_fail "${@}"
457+
fi
456458

457459
# just in case a test is marked twice as failed
458460
if [ ${last_test_failed} -eq 0 ]; then
@@ -2834,7 +2836,8 @@ verify_listener_events()
28342836
print_ok
28352837
return 0
28362838
fi
2837-
fail_test "$e_type:$type $e_family:$family $e_saddr:$saddr $e_sport:$sport"
2839+
print_fail "$e_type:$type $e_family:$family $e_saddr:$saddr $e_sport:$sport"
2840+
fail_test
28382841
}
28392842

28402843
add_addr_ports_tests()

tools/testing/selftests/net/mptcp/userspace_pm.sh

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,10 @@ test_skip()
8585
# $1: msg
8686
test_fail()
8787
{
88-
mptcp_lib_pr_fail "${@}"
88+
if [ ${#} -gt 0 ]
89+
then
90+
mptcp_lib_pr_fail "${@}"
91+
fi
8992
ret=1
9093
mptcp_lib_result_fail "${test_name}"
9194
}
@@ -239,7 +242,7 @@ check_expected_one()
239242

240243
if [ "${prev_ret}" = "0" ]
241244
then
242-
test_fail
245+
mptcp_lib_pr_fail
243246
fi
244247

245248
mptcp_lib_print_err "\tExpected value for '${var}': '${!exp}', got '${!var}'."
@@ -263,6 +266,7 @@ check_expected()
263266
return 0
264267
fi
265268

269+
test_fail
266270
return 1
267271
}
268272

@@ -412,7 +416,7 @@ test_remove()
412416
then
413417
test_pass
414418
else
415-
test_fail
419+
test_fail "unexpected type: ${type}"
416420
fi
417421

418422
# RM_ADDR using an invalid addr id should result in no action
@@ -425,7 +429,7 @@ test_remove()
425429
then
426430
test_pass
427431
else
428-
test_fail
432+
test_fail "unexpected type: ${type}"
429433
fi
430434

431435
# RM_ADDR from the client to server machine

0 commit comments

Comments
 (0)