From 609e2480915bc5705a8d6a36172d24d71f10eddd Mon Sep 17 00:00:00 2001 From: Mateusz Majewski Date: Wed, 17 Jun 2020 11:30:10 +0200 Subject: [PATCH] Use dlogutil builtin message count instead of head -n1 in tests Change-Id: I1bb1f28e73a7e31e78f59e4d9411b6bbe53ac820 --- tests/dlog_test.in | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/tests/dlog_test.in b/tests/dlog_test.in index c7043d2..10e07c4 100644 --- a/tests/dlog_test.in +++ b/tests/dlog_test.in @@ -438,8 +438,7 @@ TEST_LIBDLOGUTIL_PID=-1 LOG_DETAILS="testing if libdlogutil returns the correct buffer traits" test_libdlogutil traits $LIBDLOGUTIL_CORRECT_PID $type && ok || fail -cmd_prefix="dlogutil -d -u 0 -v" -cmd_postfix="head -n 1 " +cmd_prefix="dlogutil -t 1 -u 0 -v" format="process" regex_prio="[VDIWEFS]{1}" @@ -469,7 +468,7 @@ for PARAM in always auto none never; do fi # -t 1 instead of | head -n 1 because the `script` command can't cope with SIGPIPE. - COMMAND="$cmd_prefix $format -t 1" + COMMAND="$cmd_prefix $format" if [[ "$PARAM" == "none" ]]; then LOG_DETAILS="testing if color output is correct (implicit --color=auto/$PRIO priority/$OUTPUT output)" @@ -500,61 +499,61 @@ done REGEX="s/^$regex_prio\([0-9[:space:]]{5,}\)[[:print:]]*\([[:print:]]*\)$/1/g" LOG_DETAILS="testing if \"$format\" print format works" -line=`$cmd_prefix $format | $cmd_postfix` +line=`$cmd_prefix $format` [[ `echo "$line" | sed -re $REGEX` == "1" ]] && ok || fail format="tag" REGEX="s/^$regex_prio\/[[:print:]]{9,}:\s{1}[[:print:]]*$/1/g" LOG_DETAILS="testing if \"$format\" print format works" -line=`$cmd_prefix $format | $cmd_postfix` +line=`$cmd_prefix $format` [[ `echo "$line" | sed -re $REGEX` == "1" ]] && ok || fail format="thread" REGEX="s/^$regex_prio\($regex_pidtid\)\s{1}[[:print:]]*$/1/g" LOG_DETAILS="testing if \"$format\" print format works" -line=`$cmd_prefix $format | $cmd_postfix` +line=`$cmd_prefix $format` [[ `echo "$line" | sed -re $REGEX` == "1" ]] && ok || fail format="time" REGEX="s/^$regex_time.[0-9]{3}$regex_timezone\s{1}$regex_prio\/[[:print:]]{8,}\([0-9[:space:]]{5,}\):\s{1}[[:print:]]*$/1/g" LOG_DETAILS="testing if \"$format\" print format works" -line=`$cmd_prefix $format | $cmd_postfix` +line=`$cmd_prefix $format` [[ `echo "$line" | sed -re $REGEX` == "1" ]] && ok || fail format="threadtime" REGEX="s/^$regex_time.[0-9]{3}$regex_timezone\s{1}$regex_prio\/[[:print:]]{8,}\($regex_pidtid\):\s{1}[[:print:]]*$/1/g" LOG_DETAILS="testing if \"$format\" print format works" -line=`$cmd_prefix $format | $cmd_postfix` +line=`$cmd_prefix $format` [[ `echo "$line" | sed -re $REGEX` == "1" ]] && ok || fail format="kerneltime" REGEX="s/^[0-9[:space:]]{1,}.[0-9]{3,}\s{1}$regex_prio\/[[:print:]]{8,}\($regex_pidtid\):\s{1}[[:print:]]*$/1/g" LOG_DETAILS="testing if \"$format\" print format works" -line=`$cmd_prefix $format | $cmd_postfix` +line=`$cmd_prefix $format` [[ `echo "$line" | sed -re $REGEX` == "1" ]] && ok || fail format="recv_realtime" REGEX="s/^$regex_time.[0-9]{3}\s{1}$regex_prio\/[[:print:]]{8,}\($regex_pidtid\):\s{1}[[:print:]]*$/1/g" LOG_DETAILS="testing if \"$format\" print format works" -line=`$cmd_prefix $format | $cmd_postfix` +line=`$cmd_prefix $format` [[ `echo "$line" | sed -re $REGEX` == "1" ]] && ok || fail format="rwtime" REGEX="s/^$regex_time\s{1}\[[0-9[:space:]]{3,}.[0-9[:space:]]{3,}\]\s{1}$regex_prio\/[[:print:]]{8,}\($regex_pidtid\):\s{1}[[:print:]]*$/1/g" LOG_DETAILS="testing if \"$format\" print format works" -line=`$cmd_prefix $format | $cmd_postfix` +line=`$cmd_prefix $format` [[ `echo "$line" | sed -re $REGEX` == "1" ]] && ok || fail format="long" -REGEX="s/^\[\s{1}$regex_time.[0-9]{3,}\s{1}$regex_prio\/[[:print:]]{8,}\s{1}$regex_pidtid\]\s{1}[[:print:]]*$/1/g" +REGEX="s/^\[\s{1}$regex_time.[0-9]{3,}\s{1}$regex_prio\/[[:print:]]{8,}\s{1}$regex_pidtid\]@[[:print:]]+@$/1/g" LOG_DETAILS="testing if \"$format\" print format works" -line=`$cmd_prefix $format | $cmd_postfix` -[[ `echo "$line" | tr '\n' ' ' | sed -re $REGEX` == "1" ]] && ok || fail +line=`$cmd_prefix $format` +[[ `echo "$line" | tr '\n' '@' | sed -re $REGEX` == "1" ]] && ok || fail format="brief" REGEX="s/^$regex_prio\/[[:print:]]{8,}\([0-9[:space:]]{5,}\):\s{1}[[:print:]]*$/1/g" LOG_DETAILS="testing if \"$format\" print format works" -line=`$cmd_prefix $format | $cmd_postfix` +line=`$cmd_prefix $format` [[ `echo "$line" | sed -re $REGEX` == "1" ]] && ok || fail format="json" @@ -564,14 +563,14 @@ else REGEX="s/^\{\"priority\":\"(verbose|debug|info|warning|error|fatal|silent)\",\"pid\":[1-9][0-9]*,\"tid\":[1-9][0-9]*,\"sent_real\":\"[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}$regex_timezone\",\"tag\":\"[[:print:]]*\",\"msg\":\"[[:print:]]*\"\}$/1/g" fi LOG_DETAILS="testing if \"$format\" print format works" -line=`$cmd_prefix $format | $cmd_postfix` +line=`$cmd_prefix $format` [[ `echo "$line" | sed -re $REGEX` == "1" ]] && ok || fail format="raw" LOG_DETAILS="testing if \"$format\" print format works" dlogutil -c dlogsend -b main -t DLOG_TESTSUITE rawformatTEST -line=`$cmd_prefix $format | $cmd_postfix` +line=`$cmd_prefix $format` [[ "$line" == "rawformatTEST" ]] && ok || fail LOG_DETAILS="testing if KMSG works in the default format" -- 2.7.4