Commit 422122c1 authored by Geliang Tang's avatar Geliang Tang
Browse files

selftests: mptcp: call test_fail without argument

mainline inclusion
from mainline-v6.9-rc1
commit 339c225e2e03a41aa716038b7de2051a930603de
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I9VYQ9
CVE: NA

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=339c225e2e03a41aa716038b7de2051a930603de



--------------------------------

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: default avatarGeliang Tang <tanggeliang@kylinos.cn>
Reviewed-by: default avatarMatthieu Baerts (NGI0) <matttbe@kernel.org>
Signed-off-by: default avatarMatthieu Baerts (NGI0) <matttbe@kernel.org>
Link: https://lore.kernel.org/r/20240308-upstream-net-next-20240308-selftests-mptcp-unification-v1-10-4f42c347b653@kernel.org


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
Reviewed-by: default avatarJackie Liu <liuyun01@kylinos.cn>
Signed-off-by: default avatarGeliang Tang <tanggeliang@kylinos.cn>
parent d5149319
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -453,7 +453,9 @@ fail_test()
{
	ret=1

	if [ ${#} -gt 0 ]; then
		print_fail "${@}"
	fi

	# just in case a test is marked twice as failed
	if [ ${last_test_failed} -eq 0 ]; then
@@ -2900,7 +2902,8 @@ verify_listener_events()
		print_ok
		return 0
	fi
	fail_test "$e_type:$type $e_family:$family $e_saddr:$saddr $e_sport:$sport"
	print_fail "$e_type:$type $e_family:$family $e_saddr:$saddr $e_sport:$sport"
	fail_test
}

add_addr_ports_tests()
+8 −4
Original line number Diff line number Diff line
@@ -85,7 +85,10 @@ test_skip()
# $1: msg
test_fail()
{
	if [ ${#} -gt 0 ]
	then
		mptcp_lib_pr_fail "${@}"
	fi
	ret=1
	mptcp_lib_result_fail "${test_name}"
}
@@ -242,7 +245,7 @@ check_expected_one()

	if [ "${prev_ret}" = "0" ]
	then
		test_fail
		mptcp_lib_pr_fail
	fi

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

	test_fail
	return 1
}

@@ -415,7 +419,7 @@ test_remove()
	then
		test_pass
	else
		test_fail
		test_fail "unexpected type: ${type}"
	fi

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

	# RM_ADDR from the client to server machine