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"