summaryrefslogtreecommitdiff
path: root/tests/strace-S.test
blob: 4b5be6d904c2c67a5649536ae58932f17311237b (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
#!/bin/sh
#
# Check -S option.
#
# Copyright (c) 2016-2018 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 -S "$sortby" ../readv > /dev/null
	sed -r -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:]]+)'
test_c calls '-n -r' '/^[[:space:]]+[0-9]/ s/^'"$c$c$c$c"'[[:space:]].*/\4/p'
test_c name '' '/^[[:space:]]+[0-9]/ s/^'"$c$c$c$c"'([[:space:]]+[0-9]+)?'"$c"'$/\6/p'