testsuite: add sorting test scripts 84/180084/5
authorMaciej Slodczyk <m.slodczyk2@partner.samsung.com>
Fri, 25 May 2018 18:24:55 +0000 (20:24 +0200)
committerMichal Bloch <m.bloch@samsung.com>
Wed, 30 May 2018 11:10:52 +0000 (13:10 +0200)
Change-Id: Ia91e649af6c0aa191b9034445813ccca6fd2fd6e
Signed-off-by: Maciej Slodczyk <m.slodczyk2@partner.samsung.com>
tests/dlog_test_pipe.in

index 1b6ab0d..8d0fcab 100644 (file)
@@ -89,6 +89,35 @@ dlogutil -f $TESTDIR/dlog_mt_test &
 MT_TEST=$!
 test_libdlog && ok || fail
 
+# 21: test sorting
+dlogutil -c
+prev_ts=0
+unsorted=""
+prev_line=""
+SPAWN_CNT=1000
+
+# spawn logging scripts and wait for them to finish
+for i in `seq 1 $SPAWN_CNT`; do
+       delay=$(( (RANDOM) % 50 ))
+       ( sleep $delay && dlogsend -b main -t DLOG_TESTSUITE $delay ) &
+done
+sleep 60
+
+# collect data and analyze timestamps
+lines=`dlogutil -d -v recv_realtime`
+while read line; do
+       time=`echo $line | awk '{split($0, l, " "); print l[2]}'`
+       ts=`date +%s%N -d $time`
+       if [ "$ts" -ge "$prev_ts" ]; then
+               prev_ts=$ts
+       else
+               printf -v unsorted '%s\n\n%s\n%s' "$unsorted" "$prev_line" "$line"
+       fi
+       prev_line=$line
+done <<< "$lines"
+
+[ -z "$unsorted" ] && ok || fail
+
 # show results and clean up
 
 echo "$OKS / $TOTAL tests passed"