Dmitry V. Levin | aa80192 | 2015-02-07 18:48:55 +0000 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
| 3 | # Check -bexecve behavior. |
| 4 | |
| 5 | . "${srcdir=.}/init.sh" |
| 6 | |
Dmitry V. Levin | 8f54664 | 2015-03-17 17:07:57 +0000 | [diff] [blame] | 7 | run_strace_redir() |
| 8 | { |
| 9 | args="$*" |
| 10 | $STRACE "$@" 2> "$LOG" |
Dmitry V. Levin | aa80192 | 2015-02-07 18:48:55 +0000 | [diff] [blame] | 11 | } |
| 12 | |
Dmitry V. Levin | b704e8f | 2015-04-14 16:04:08 +0000 | [diff] [blame] | 13 | run_strace_redir -enone ./set_ptracer_any true || |
| 14 | dump_log_and_fail_with "$STRACE $args: unexpected exit status" |
| 15 | |
| 16 | run_strace_redir -enone ./set_ptracer_any false |
Dmitry V. Levin | 8f54664 | 2015-03-17 17:07:57 +0000 | [diff] [blame] | 17 | [ $? -eq 1 ] || |
| 18 | dump_log_and_fail_with "$STRACE $args: unexpected exit status" |
| 19 | |
Dmitry V. Levin | b704e8f | 2015-04-14 16:04:08 +0000 | [diff] [blame] | 20 | run_strace_redir -bexecve -enone ./set_ptracer_any false || |
Dmitry V. Levin | 8f54664 | 2015-03-17 17:07:57 +0000 | [diff] [blame] | 21 | dump_log_and_fail_with "$STRACE $args: unexpected exit status" |
| 22 | |
Dmitry V. Levin | b704e8f | 2015-04-14 16:04:08 +0000 | [diff] [blame] | 23 | pattern_detached='Process [1-9][0-9]* detached' |
| 24 | pattern_personality='\[ Process PID=[1-9][0-9]* runs in .* mode. \]' |
Dmitry V. Levin | aa80192 | 2015-02-07 18:48:55 +0000 | [diff] [blame] | 25 | |
Dmitry V. Levin | b704e8f | 2015-04-14 16:04:08 +0000 | [diff] [blame] | 26 | LC_ALL=C grep -x "$pattern_detached" "$LOG" > /dev/null || |
Dmitry V. Levin | 8f54664 | 2015-03-17 17:07:57 +0000 | [diff] [blame] | 27 | dump_log_and_fail_with "$STRACE $args: output mismatch" |
Dmitry V. Levin | aa80192 | 2015-02-07 18:48:55 +0000 | [diff] [blame] | 28 | |
Dmitry V. Levin | b704e8f | 2015-04-14 16:04:08 +0000 | [diff] [blame] | 29 | if LC_ALL=C grep -E -v -x "($pattern_detached|$pattern_personality)" "$LOG" > /dev/null; then |
Dmitry V. Levin | 8f54664 | 2015-03-17 17:07:57 +0000 | [diff] [blame] | 30 | dump_log_and_fail_with "$STRACE $args: unexpected output" |
Dmitry V. Levin | aa80192 | 2015-02-07 18:48:55 +0000 | [diff] [blame] | 31 | fi |
| 32 | |
| 33 | exit 0 |