tests: change the way test msg is being displayed 57/288857/6
authorMichal Bloch <m.bloch@samsung.com>
Thu, 11 Jan 2024 15:01:41 +0000 (16:01 +0100)
committerMichal Bloch <m.bloch@samsung.com>
Fri, 12 Jan 2024 22:05:56 +0000 (23:05 +0100)
Now each script has its own local TOTAL, OKS, FAILS
variables, and display messages consist of test name,
whether script failed or succeded and its local value
of TOTAL variable.

Change-Id: Ie48f10eb14220089a684dcc4b374b51cdd6d4bda

tests/dlog_test_header.in

index 4e34daf..730ce3a 100644 (file)
@@ -7,6 +7,21 @@ OKS=0
 TOTAL=0
 LOG_DETAILS=
 
+######## Relevant pids default vals
+
+if [ -z ${UTIL_PID} ]; then UTIL_PID=-1; fi
+if [ -z ${DLOGSEND_PID} ]; then DLOGSEND_PID=-1; fi
+if [ -z ${MT_TEST} ]; then MT_TEST=-1; fi
+if [ -z ${LOGGER} ]; then LOGGER=-1; fi
+
+export LOGGER
+export UTIL_PID
+export DLOGSEND_PID
+export MT_TEST
+
+SCRIPT_NAME=$(basename $0)
+USAGE_MESSAGE="usage: $0 [--verbose] [--quick] pipe|logger"
+
 check_daemon() {
        ret=1
        if [ "$LOGGER" -ne -1 ] && [ -z "$(ps -o pid= -p "$LOGGER")" ]; then
@@ -20,7 +35,7 @@ fail() {
 
        FAILS=$((FAILS + 1))
        TOTAL=$((TOTAL + 1))
-       printf "[%02d] FAILED: %s %s\n" "$TOTAL" "$LOG_DETAILS" "$daemon_status"
+       printf "[$SCRIPT_NAME %03d] \033[0;31mFAILED\033[0;m: %s %s\n" "$TOTAL" "$LOG_DETAILS" "$daemon_status"
        LOG_DETAILS=
 }
 
@@ -29,7 +44,7 @@ ok() {
 
        OKS=$((OKS + 1))
        TOTAL=$((TOTAL + 1))
-       printf "[%02d] PASSED: %s %s\n" "$TOTAL" "$LOG_DETAILS" "$daemon_status"
+       printf "[$SCRIPT_NAME %03d] \033[0;32mPASSED\033[0;m: %s %s\n" "$TOTAL" "$LOG_DETAILS" "$daemon_status"
        LOG_DETAILS=
 }