Add padding tests for the pipe backend 89/236489/3
authorMateusz Majewski <m.majewski2@samsung.com>
Wed, 17 Jun 2020 09:30:39 +0000 (11:30 +0200)
committerMichal Bloch <m.bloch@partner.samsung.com>
Wed, 17 Jun 2020 13:59:57 +0000 (13:59 +0000)
Change-Id: I3ed63bf55e129f26af6a0418d3ea4a2390570686

tests/dlog_test.in

index 10e07c4..687cfc7 100644 (file)
@@ -573,6 +573,33 @@ dlogsend -b main -t DLOG_TESTSUITE rawformatTEST
 line=`$cmd_prefix $format`
 [[ "$line" == "rawformatTEST" ]] && ok || fail
 
+if [ $type == "pipe" ]; then
+       for format in raw brief long; do
+               for i in {1..8} 10 15 20 25; do
+                       LOG_DETAILS="testing if padding works correctly (format $format/count $i)"
+                       log=$(printf '%0.s&' $(seq 1 $i)) # Print the '&' character $i times
+
+                       dlogutil -c
+                       dlogsend -b main $log
+                       line=$($cmd_prefix $format | tr '\n' '@')
+
+                       case $format in
+                               raw)
+                                       REGEX="s/$log@/1/g"
+                                       ;;
+                               brief)
+                                       REGEX="s/I\/DLOG_SEND\([0-9[:space:]]{5,}\):\s{1}$log@$/1/g"
+                                       ;;
+                               long)
+                                       REGEX="s/\[\s{1}$regex_time.[0-9]{3,}\s{1}I\/DLOG_SEND\s{1}$regex_pidtid\]@$log@@/1/g"
+                                       ;;
+                       esac
+
+                       [[ $(echo "$line" | sed -re $REGEX) == "1" ]] && ok || fail
+               done
+       done
+fi
+
 LOG_DETAILS="testing if KMSG works in the default format"
 # We check if the command returns at least 100 logs. This seems to be a safe value.
 # Feel free to change it to a reasonable yet lower value if the test happens to fail otherwise.