blob: 670e3621eee8d2ba7ba2280d7ac2b9fd73d36d53 (
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
|
#!/bin/sh
#
# Check -S option.
#
# Copyright (c) 2016-2023 The strace developers.
# All rights reserved.
#
# SPDX-License-Identifier: GPL-2.0-or-later
. "${srcdir=.}/init.sh"
run_prog ../readv > /dev/null
test_c()
{
local sortby sortopts sedexpr
sortby="$1"; shift
sortopts="$1"; shift
sedexpr="$1"; shift
run_strace -c -w $sortby ../readv > /dev/null
sed -E -n -e "$sedexpr" < "$LOG" > "$OUT"
[ -s "$OUT" ] ||
fail_ "$STRACE $args output mismatch"
LC_ALL=C sort -c $sortopts "$OUT" || {
echo 'Actual output:'
cat < "$LOG"
fail_ "$STRACE $args output not sorted properly"
}
}
c='[[:space:]]+([^[:space:]]+)'
for s in '' '-S time' --summary-sort-by=time_total '-S total_time'; do
test_c "$s" '-n -r' \
's/^[[:space:]]+([0-9]+)[.,]([0-9]+)[[:space:]].*/\1\t\2/p'
done
for s in '-S avg_time' --summary-sort-by=time_avg; do
test_c "$s" '-n -r' \
'/^[[:space:]]+[0-9]/ s/^'"$c$c$c$c"'[[:space:]].*/\3/p'
done
for s in '-S calls' --summary-sort-by=count; do
test_c "$s" '-n -r' \
'/^[[:space:]]+[0-9]/ s/^'"$c$c$c$c"'[[:space:]].*/\4/p'
done
for s in '-S name' --summary-sort-by=syscall '-S syscall_name'; do
test_c "$s" '' \
'/^[[:space:]]+[0-9]/ s/^'"$c$c$c$c"'([[:space:]]+[0-9]+)?'"$c"'$/\6/p'
done
for s in '-S error' --summary-sort-by=errors; do
test_c "$s" '-n -r' \
'/^[[:space:]]+[0-9]/ s/^'"$c$c$c$c"'([[:space:]]+([0-9]+))?'"$c"'$/\6/p'
done
for s in '--summary-columns=time,time-max,name -S max_time' '-U time-percent,max_time,syscall_name --summary-sort-by=longest'; do
test_c "$s" '-n -r' \
'/^[[:space:]]+[0-9]/ s/^'"$c$c"'[[:space:]].*/\2/p'
done
for s in '--summary-columns=time,time_min,name -S min-time' '-U time_percent,min_time,syscall-name --summary-sort-by=shortest'; do
test_c "$s" '-n -r' \
'/^[[:space:]]+[0-9]/ s/^'"$c$c"'[[:space:]].*/\2/p'
done
|