Thread (12 messages) 12 messages, 4 authors, 2024-02-02

Re: [PATCH net-next 5/5] selftests/net: Adding test cases of replacing routes and route advertisements.

From: Hangbin Liu <hidden>
Date: 2024-02-02 02:25:51

On Thu, Feb 01, 2024 at 09:14:17AM -0800, Kui-Feng Lee wrote:
quoted
quoted
+	N_EXP=$($IP -6 route list |grep expires|wc -l)
+	if [ $N_EXP -ne 0 ]; then
+	    echo "FAIL: expected 0 routes with expires, got $N_EXP"
  	    ret=1
  	else
  	    ret=0
  	fi
+	log_test $ret 0 "ipv6 route garbage collection"
+
+	reset_dummy_10
Since you reset the dummy device and will not affect the later tests. Maybe
you can log the test directly, e.g.

	if [ "$($IP -6 route list |grep expires|wc -l)" -ne 0 ]; then
		log_test $ret 0 "ipv6 route garbage collection"
	fi

Or, if you want to keep ret and also report passed log, you can wrapper the
number checking like

check_exp_number()
{
	local exp=$1
	local n_exp=$($IP -6 route list |grep expires|wc -l)
	if [ "$n_exp" -ne "$exp" ]; then
		echo "FAIL: expected $exp routes with expires, got $n_exp"
		ret=1
	else
		ret=0
	fi
}

Then we can call it without repeating the if/else lines

	check_exp_number 0
	log_test $ret 0 "ipv6 route garbage collection"
If I read it correctly, the point here is too many boilerplate checks,
and you prefer to reduce them. Right?
No problem! I will do it.
Yes, thanks!

Hangbin
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help