.../testing/selftests/net/mptcp/mptcp_lib.sh | 38 +++++++++---------- 1 file changed, 19 insertions(+), 19 deletions(-)
mptcp_lib_print_ok prints unexpected green color at the beginning of
the next line. If a system time like [14:38:45.388] is printed at the
beginning of the next line, then it, along with the following '#',
will be in green. Such as the outputs below, where the first column
is mostly green:
[14:38:30.356] + tee /tmp/cirrus-ci-build/selftest_mptcp_join.tap.tmp
[14:38:32.089] # 001 no JOIN
[14:38:45.388] # syn [ ok ]
[14:38:46.038] # synack [ ok ]
[14:38:46.457] # ack [ ok ]
[14:38:46.465] # 002 single subflow, limited by client
[14:39:00.617] # syn [ ok ]
[14:39:01.250] # synack [ ok ]
[14:39:01.685] # ack [ ok ]
[14:39:01.693] # 003 single subflow, limited by server
With this change, the first column will be printed without color
normally.
Please update the commit log:
'''
The helpers mptcp_lib_print_* print the text with a newline, but
sometimes this EOL dosen't needed. So this patch adds another set
of helpers mptcp_lib_echo_*, do not output the trailing newline.
Use 'echo -n' in mptcp_lib_print_color() to skip the newline, it's
invoked directly in mptcp_lib_echo_ok(), _warn(), _info() and _err()
with different colors to print colored text without newline.
The original helpers mptcp_lib_print_ok(), _warn(), _info() and _err()
invoke mptcp_lib_print_color() with different colors to print the text,
and after it print a '\n' with MPTCP_LIB_COLOR_RESET, that is a newline
without color.
'''
Signed-off-by: Geliang Tang <geliang.tang@suse.com>
---
.../testing/selftests/net/mptcp/mptcp_lib.sh | 38 +++++++++----------
1 file changed, 19 insertions(+), 19 deletions(-)
diff --git a/tools/testing/selftests/net/mptcp/mptcp_lib.sh b/tools/testing/selftests/net/mptcp/mptcp_lib.sh
index 7a68791c5773..69d7af1a9f03 100644
--- a/tools/testing/selftests/net/mptcp/mptcp_lib.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_lib.sh
@@ -33,43 +33,43 @@ else
readonly MPTCP_LIB_COLOR_RESET=
fi
-# mptcp_lib_echo_*: do not output the trailing newline
# $1: color, $2: text
-mptcp_lib_echo_color() {
+mptcp_lib_print_color() {
echo -n -e "${MPTCP_LIB_START_PRINT:-}${*}${MPTCP_LIB_COLOR_RESET}"
}
-mptcp_lib_echo_ok() {
- mptcp_lib_echo_color "${MPTCP_LIB_COLOR_GREEN}${*}"
+# mptcp_lib_print_*: output with EOL
+mptcp_lib_print_ok() {
+ mptcp_lib_print_color "${MPTCP_LIB_COLOR_GREEN}${*}${MPTCP_LIB_COLOR_RESET}\n"
}
-mptcp_lib_echo_warn() {
- mptcp_lib_echo_color "${MPTCP_LIB_COLOR_YELLOW}${*}"
+mptcp_lib_print_warn() {
+ mptcp_lib_print_color "${MPTCP_LIB_COLOR_YELLOW}${*}${MPTCP_LIB_COLOR_RESET}\n"
}
-mptcp_lib_echo_info() {
- mptcp_lib_echo_color "${MPTCP_LIB_COLOR_BLUE}${*}"
+mptcp_lib_print_info() {
+ mptcp_lib_print_color "${MPTCP_LIB_COLOR_BLUE}${*}${MPTCP_LIB_COLOR_RESET}\n"
}
-mptcp_lib_echo_err() {
- mptcp_lib_echo_color "${MPTCP_LIB_COLOR_RED}${*}"
+mptcp_lib_print_err() {
+ mptcp_lib_print_color "${MPTCP_LIB_COLOR_RED}${*}${MPTCP_LIB_COLOR_RESET}\n"
}
-# mptcp_lib_print_*: output with EOL
-mptcp_lib_print_ok() {
- mptcp_lib_echo_ok "${*}\n"
+# mptcp_lib_echo_*: do not output the trailing newline
+mptcp_lib_echo_ok() {
+ mptcp_lib_print_color "${MPTCP_LIB_COLOR_GREEN}${*}"
}
-mptcp_lib_print_warn() {
- mptcp_lib_echo_warn "${*}\n"
+mptcp_lib_echo_warn() {
+ mptcp_lib_print_color "${MPTCP_LIB_COLOR_YELLOW}${*}"
}
-mptcp_lib_print_info() {
- mptcp_lib_echo_info "${*}\n"
+mptcp_lib_echo_info() {
+ mptcp_lib_print_color "${MPTCP_LIB_COLOR_BLUE}${*}"
}
-mptcp_lib_print_err() {
- mptcp_lib_echo_err "${*}\n"
+mptcp_lib_echo_err() {
+ mptcp_lib_print_color "${MPTCP_LIB_COLOR_RED}${*}"
}
# SELFTESTS_MPTCP_LIB_EXPECT_ALL_FEATURES env var can be set when validating all
--
2.35.3
© 2016 - 2024 Red Hat, Inc.