Commit d8463d81 authored by Matthieu Baerts's avatar Matthieu Baerts Committed by David S. Miller

selftests: mptcp: userspace_pm: reduce dup code around printf

In this selftest, "printf" is always used with "stdbuf".

With a new helper, it is possible to call "stdbuf" only from one place.
This makes the code a bit clearer to read.
Acked-by: default avatarPaolo Abeni <pabeni@redhat.com>
Signed-off-by: default avatarMatthieu Baerts <matthieu.baerts@tessares.net>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent e198ad75
...@@ -59,21 +59,24 @@ rndh=$(printf %x "$sec")-$(mktemp -u XXXXXX) ...@@ -59,21 +59,24 @@ rndh=$(printf %x "$sec")-$(mktemp -u XXXXXX)
ns1="ns1-$rndh" ns1="ns1-$rndh"
ns2="ns2-$rndh" ns2="ns2-$rndh"
ret=0 ret=0
_printf() {
stdbuf -o0 -e0 printf "${@}"
}
print_title() print_title()
{ {
stdbuf -o0 -e0 printf "INFO: %s\n" "${1}" _printf "INFO: %s\n" "${1}"
} }
# $1: test name # $1: test name
print_test() print_test()
{ {
stdbuf -o0 -e0 printf "%-63s" "${1}" _printf "%-63s" "${1}"
} }
print_results() print_results()
{ {
stdbuf -o0 -e0 printf "[%s]\n" "${1}" _printf "[%s]\n" "${1}"
} }
test_pass() test_pass()
...@@ -93,7 +96,7 @@ test_fail() ...@@ -93,7 +96,7 @@ test_fail()
ret=1 ret=1
if [ -n "${1}" ]; then if [ -n "${1}" ]; then
stdbuf -o0 -e0 printf "\t%s\n" "${1}" _printf "\t%s\n" "${1}"
fi fi
} }
...@@ -127,7 +130,7 @@ cleanup() ...@@ -127,7 +130,7 @@ cleanup()
rm -rf $file $client_evts $server_evts rm -rf $file $client_evts $server_evts
stdbuf -o0 -e0 printf "Done\n" _printf "Done\n"
} }
trap cleanup EXIT trap cleanup EXIT
...@@ -288,7 +291,7 @@ check_expected_one() ...@@ -288,7 +291,7 @@ check_expected_one()
test_fail test_fail
fi fi
stdbuf -o0 -e0 printf "\tExpected value for '%s': '%s', got '%s'.\n" \ _printf "\tExpected value for '%s': '%s', got '%s'.\n" \
"${var}" "${!exp}" "${!var}" "${var}" "${!exp}" "${!var}"
return 1 return 1
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment