blob: dff1eb89e3ab4bf4e4f10bb022c153132267a5a5 (
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
#!/bin/sh
#
# Define syntax testing primitives.
#
# Copyright (c) 2016 Dmitry V. Levin <ldv@strace.io>
# Copyright (c) 2016-2020 The strace developers.
# All rights reserved.
#
# SPDX-License-Identifier: GPL-2.0-or-later
. "${srcdir=.}/init.sh"
log_sfx()
{
printf "%.128s" "$*" | tr -c '0-9A-Za-z-=,' '_'
}
check_exit_status_and_stderr()
{
local sfx
sfx="$1"; shift
$STRACE "$@" 2> "$LOG.$sfx" && {
cat "$LOG.$sfx" >&2
fail_ "strace $* failed to handle the error properly"
}
match_diff "$LOG.$sfx" "$EXP.$sfx" \
"strace $* failed to print expected diagnostics"
}
check_exit_status_and_stderr_using_grep()
{
local sfx
sfx="$1"; shift
$STRACE "$@" 2> "$LOG.$sfx" && {
cat "$LOG.$sfx" >&2
fail_ "strace $* failed to handle the error properly"
}
match_grep "$LOG.$sfx" "$EXP.$sfx" \
"strace $* failed to print expected diagnostics"
}
check_e()
{
local pattern sfx
pattern="$1"; shift
sfx="$(log_sfx "$*")"
cat > "$EXP.$sfx" << __EOF__
$STRACE_EXE: $pattern
__EOF__
check_exit_status_and_stderr "$sfx" "$@"
}
check_e_using_grep()
{
local pattern sfx
pattern="$1"; shift
sfx="$(log_sfx "$*")"
cat > "$EXP.$sfx" << __EOF__
$STRACE_EXE: $pattern
__EOF__
check_exit_status_and_stderr_using_grep "$sfx" "$@"
}
check_h()
{
local patterns sfx
patterns="$1"; shift
sfx="$(log_sfx "$*")"
{
local pattern
printf '%s\n' "$patterns" |
while read -r pattern; do
printf '%s: %s\n' "$STRACE_EXE" "$pattern"
done
printf "Try '%s -h' for more information.\\n" "$STRACE_EXE"
} > "$EXP.$sfx"
check_exit_status_and_stderr "$sfx" "$@"
}
|