summaryrefslogtreecommitdiff
path: root/tests/strace-ttt.test
blob: 7794d3327da1786ecf4cceca444c2dc57f7d2981 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/bin/sh
#
# Check -ttt option.
#
# Copyright (c) 2016-2020 The strace developers.
# All rights reserved.
#
# SPDX-License-Identifier: GPL-2.0-or-later

. "${srcdir=.}/init.sh"

precision="${1:-6}"
[ x0 = "x$#" ] || shift
opts="${*:--ttt}"

run_prog_skip_if_failed date +%s > /dev/null
run_prog ../sleep 0

s0="$(date +%s)"
run_strace $opts -eexecve $args
s1="$(date +%s)"

s="$s0"
t_reg=
while [ "$s" -le "$s1" ]; do
	[ -z "$t_reg" ] && t_reg="$s" || t_reg="$t_reg|$s"
	s=$((s + 1))
done

if [ x0 = "x${precision}" ]; then
	subsec_re=""
else
	subsec_re="\\.[[:digit:]]{${precision}}"
fi

cat > "$EXP" << __EOF__
($t_reg)${subsec_re} execve\\("\\.\\./sleep", \\["\\.\\./sleep", "0"\\], 0x[[:xdigit:]]* /\\* [[:digit:]]+ vars \\*/\\) = 0
__EOF__

match_grep "$LOG" "$EXP"