blob: 467f370141ec816df22dc57b1b0192737c5057eb [file] [log] [blame]
Dmitry V. Levinaa801922015-02-07 18:48:55 +00001#!/bin/sh
2
3# Check -bexecve behavior.
4
5. "${srcdir=.}/init.sh"
6
Dmitry V. Levin8f546642015-03-17 17:07:57 +00007run_strace_redir()
8{
9 args="$*"
10 $STRACE "$@" 2> "$LOG"
Dmitry V. Levinaa801922015-02-07 18:48:55 +000011}
12
Dmitry V. Levinb704e8f2015-04-14 16:04:08 +000013run_strace_redir -enone ./set_ptracer_any true ||
14 dump_log_and_fail_with "$STRACE $args: unexpected exit status"
15
16run_strace_redir -enone ./set_ptracer_any false
Dmitry V. Levin8f546642015-03-17 17:07:57 +000017[ $? -eq 1 ] ||
18 dump_log_and_fail_with "$STRACE $args: unexpected exit status"
19
Dmitry V. Levinb704e8f2015-04-14 16:04:08 +000020run_strace_redir -bexecve -enone ./set_ptracer_any false ||
Dmitry V. Levin8f546642015-03-17 17:07:57 +000021 dump_log_and_fail_with "$STRACE $args: unexpected exit status"
22
Dmitry V. Levinb704e8f2015-04-14 16:04:08 +000023pattern_detached='Process [1-9][0-9]* detached'
24pattern_personality='\[ Process PID=[1-9][0-9]* runs in .* mode. \]'
Dmitry V. Levinaa801922015-02-07 18:48:55 +000025
Dmitry V. Levinb704e8f2015-04-14 16:04:08 +000026LC_ALL=C grep -x "$pattern_detached" "$LOG" > /dev/null ||
Dmitry V. Levin8f546642015-03-17 17:07:57 +000027 dump_log_and_fail_with "$STRACE $args: output mismatch"
Dmitry V. Levinaa801922015-02-07 18:48:55 +000028
Dmitry V. Levinb704e8f2015-04-14 16:04:08 +000029if LC_ALL=C grep -E -v -x "($pattern_detached|$pattern_personality)" "$LOG" > /dev/null; then
Dmitry V. Levin8f546642015-03-17 17:07:57 +000030 dump_log_and_fail_with "$STRACE $args: unexpected output"
Dmitry V. Levinaa801922015-02-07 18:48:55 +000031fi
32
33exit 0