]> granicus.if.org Git - strace/commitdiff
tests: fix expected output in strace-ttt.test
authorDmitry V. Levin <ldv@altlinux.org>
Tue, 6 Dec 2016 08:55:41 +0000 (08:55 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Tue, 6 Dec 2016 15:27:21 +0000 (15:27 +0000)
If strace -ttt is running too long, it might happen that time stamps
before and after its invocation differ for more than a second.
Adjust expected output to handle this rare but possible case.

* tests/strace-ttt.test: Allow any time stamp between start and finish
of strace invocation.

tests/strace-ttt.test

index 8b0032a2d71d38f54a2a05532f3bbbba8a0f20cc..4439715b5ce21e29db8387855c2b5fdb01420933 100755 (executable)
@@ -7,14 +7,20 @@
 run_prog_skip_if_failed date +%s > /dev/null
 run_prog ./sleep 0
 
-t0="$(date +%s)"
+s0="$(date +%s)"
 run_strace -ttt -eexecve $args
-t1="$(date +%s)"
+s1="$(date +%s)"
 
-EXPECTED="$LOG.expected"
-cat > "$EXPECTED" << __EOF__
-($t0|$t1)\\.[[:digit:]]{6} execve\\("\\./sleep", \\["\\./sleep", "0"\\], \\[/\\* [[:digit:]]+ vars \\*/\\]\\) = 0
+s="$s0"
+t_reg=
+while [ "$s" -le "$s1" ]; do
+       [ -z "$t_reg" ] && t_reg="$s" || t_reg="$t_reg|$s"
+       s=$(($s + 1))
+done
+
+cat > "$EXP" << __EOF__
+($t_reg)\\.[[:digit:]]{6} execve\\("\\./sleep", \\["\\./sleep", "0"\\], \\[/\\* [[:digit:]]+ vars \\*/\\]\\) = 0
 __EOF__
 
-match_grep "$LOG" "$EXPECTED"
-rm -f "$EXPECTED"
+match_grep "$LOG" "$EXP"
+rm -f "$EXP"