summaryrefslogtreecommitdiff
path: root/tests/legacy_syscall_info.test
blob: b21cb271ad5b01aff31c8801b9fe688e879ad255 (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
#!/bin/sh -efu
#
# Check legacy code used for obtaining syscall number, arguments,
# and return value when modern ptrace API was not available yet.
#
# Copyright (c) 2017-2021 Dmitry V. Levin <ldv@strace.io>
# All rights reserved.
#
# SPDX-License-Identifier: GPL-2.0-or-later

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

check_prog grep
$STRACE -d -enone / > /dev/null 2> "$LOG" ||:
grep -x "[^:]*strace: PTRACE_GET_SYSCALL_INFO works" "$LOG" > /dev/null ||
        skip_ 'PTRACE_GET_SYSCALL_INFO does not work'

run_prog ../chdir > /dev/null

helper='../../disable_ptrace_get_syscall_info'
$helper $args > /dev/null ||
	skip_ "$helper does not work"

$helper $STRACE -d -enone / > /dev/null 2> "$LOG" ||:
grep -x "[^:]*strace: PTRACE_GET_SYSCALL_INFO does not work" "$LOG" > /dev/null ||
	fail_ "$helper does not work properly"

> "$LOG" || fail_ "failed to write $LOG"
set -- --trace=chdir -a10 $args
$helper $STRACE -o "$LOG" "$@" > "$EXP" ||
	dump_log_and_fail_with "$helper $STRACE $* failed with code $?"

match_diff "$LOG" "$EXP"

helper2='../../disable_ptrace_getregset'
$helper2 $helper $args > /dev/null ||
	exit 0 # the second part of the test is not applicable

$helper2 $helper $STRACE -d -enone / > /dev/null 2> "$LOG" ||:
grep -x "[^:]*strace: PTRACE_GET_SYSCALL_INFO does not work" "$LOG" > /dev/null ||
	fail_ "$helper2 $helper does not work properly"

> "$LOG" || fail_ "failed to write $LOG"
$helper2 $helper $STRACE -o "$LOG" "$@" > "$EXP" ||
	dump_log_and_fail_with "$helper2 $helper $STRACE $* failed with code $?"

match_diff "$LOG" "$EXP"