]> granicus.if.org Git - strace/blob - tests/strace-S.test
Remove XLAT_END
[strace] / tests / strace-S.test
1 #!/bin/sh
2 #
3 # Check -S option.
4 #
5 # Copyright (c) 2016-2019 The strace developers.
6 # All rights reserved.
7 #
8 # SPDX-License-Identifier: GPL-2.0-or-later
9
10 . "${srcdir=.}/init.sh"
11
12 run_prog ../readv > /dev/null
13
14 test_c()
15 {
16         local sortby sortopts sedexpr
17         sortby="$1"; shift
18         sortopts="$1"; shift
19         sedexpr="$1"; shift
20
21         run_strace -c -w ${sortby:+-S} $sortby ../readv > /dev/null
22         sed -r -n -e "$sedexpr" < "$LOG" > "$OUT"
23
24         [ -s "$OUT" ] ||
25                 fail_ "$STRACE $args output mismatch"
26         LC_ALL=C sort -c $sortopts "$OUT" || {
27                 echo 'Actual output:'
28                 cat < "$LOG"
29                 fail_ "$STRACE $args output not sorted properly"
30         }
31 }
32
33 c='[[:space:]]+([^[:space:]]+)'
34 for s in '' time time_total total_time; do
35         test_c "$s" '-n -r' \
36                 's/^[[:space:]]+([0-9]+)[.,]([0-9]+)[[:space:]].*/\1\t\2/p'
37 done
38 for s in calls count; do
39         test_c "$s" '-n -r' \
40                 '/^[[:space:]]+[0-9]/ s/^'"$c$c$c$c"'[[:space:]].*/\4/p'
41 done
42 for s in name syscall syscall_name; do
43         test_c "$s" '' \
44                 '/^[[:space:]]+[0-9]/ s/^'"$c$c$c$c"'([[:space:]]+[0-9]+)?'"$c"'$/\6/p'
45 done
46 for s in error errors; do
47         test_c "$s" '-n -r' \
48                 '/^[[:space:]]+[0-9]/ s/^'"$c$c$c$c"'([[:space:]]+([0-9]+))?'"$c"'$/\6/p'
49 done