summaryrefslogtreecommitdiff
path: root/tests/strace-p-Y-p.test
blob: 95bc7fe642232e6d7a860431d5d56817aeb8bbfa (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
#!/bin/sh
#
# Check that -p pid1 -Y -p pid2 prints /proc/$pid1/comm properly.
#
# Copyright (c) 2021 Dmitry V. Levin <ldv@strace.io>
# All rights reserved.
#
# SPDX-License-Identifier: GPL-2.0-or-later

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

run_prog_skip_if_failed kill -0 $$
run_prog ../strace-p1-Y-p 0 > /dev/null 3>&1
run_prog ../strace-p-Y-p2 0 > /dev/null 3>&1

run_tracee()
{
	local file
	file="$1"; shift
	../set_ptracer_any "$@" > /dev/null 3> "$file" &
	pid=$!
	while ! [ -s "$file" ]; do
		kill -0 $pid 2> /dev/null ||
			fail_ 'set_ptracer_any "$*" failed'
	done
}

run_tracee "$EXP" ../strace-p1-Y-p 2
pid1=$pid

run_tracee "$OUT" ../strace-p-Y-p2 3
pid2=$pid

run_strace -enone -p "$pid1" -Y -p "$pid2"

# merge expected output
cat "$OUT" >> "$EXP"

# filter out unrelated strace output
grep -F +++ "$LOG" > "$OUT"

match_diff "$OUT" "$EXP"