[PATCH mptcp-next v8 09/22] selftests: mptcp: pm_netlink: print colored output

Geliang Tang posted 22 patches 2 years, 2 months ago
Maintainers: Matthieu Baerts <matttbe@kernel.org>, Mat Martineau <martineau@kernel.org>, "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, Shuah Khan <shuah@kernel.org>, Geliang Tang <geliang.tang@suse.com>
There is a newer version of this series
[PATCH mptcp-next v8 09/22] selftests: mptcp: pm_netlink: print colored output
Posted by Geliang Tang 2 years, 2 months ago
The helper check() will be moved into mptcp_lib.sh, and be used by two
scripts mptcp_join.sh and pm_netlink.sh. The former prints colored
output while the latter is not. It makes sense to unify them.

Use mptcp_lib_print_ok(), mptcp_lib_print_err, and mptcp_lib_echo_err
helpers in script pm_netlink.sh to print test results with colors.

Having colors helps to quickly identify issues when looking at a long
list of output logs and results.

Signed-off-by: Geliang Tang <geliang.tang@suse.com>
---
 tools/testing/selftests/net/mptcp/pm_netlink.sh | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/tools/testing/selftests/net/mptcp/pm_netlink.sh b/tools/testing/selftests/net/mptcp/pm_netlink.sh
index 8f4ff123a7eb..b1155f4a8504 100755
--- a/tools/testing/selftests/net/mptcp/pm_netlink.sh
+++ b/tools/testing/selftests/net/mptcp/pm_netlink.sh
@@ -60,16 +60,15 @@ check()
 
 	printf "%-50s" "$msg"
 	if [ $cmd_ret -ne 0 ]; then
-		echo "[FAIL] command execution '$cmd' stderr "
+		mptcp_lib_print_err "[FAIL] command execution '$cmd' stderr "
 		cat $err
 		mptcp_lib_result_fail "${msg} # error ${cmd_ret}"
 		ret=1
 	elif [ "$out" = "$expected" ]; then
-		echo "[ OK ]"
+		mptcp_lib_print_ok "[ OK ]"
 		mptcp_lib_result_pass "${msg}"
 	else
-		echo -n "[FAIL] "
-		echo "expected '$expected' got '$out'"
+		mptcp_lib_print_err "[FAIL] expected '$expected' got '$out'"
 		mptcp_lib_result_fail "${msg} # different output"
 		ret=1
 	fi
-- 
2.35.3