Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
| 3 | # Check how strace -e abbrev=set, -e raw=set, -e trace=set, |
| 4 | # and -e verbose=set work. |
| 5 | |
| 6 | . "${srcdir=.}/init.sh" |
| 7 | |
Elliott Hughes | 39bac05 | 2017-05-25 16:56:11 -0700 | [diff] [blame] | 8 | run_prog ../umovestr |
| 9 | pattern_abbrev_verbose='execve("\.\./umovestr", \["\.\./umovestr"\], 0x[[:xdigit:]]* /\* [[:digit:]]* vars \*/) = 0' |
| 10 | pattern_nonabbrev_verbose='execve("\.\./umovestr", \["\.\./umovestr"\], \[".*\"\(\.\.\.\)\?\]) = 0' |
| 11 | pattern_nonverbose='execve("\.\./umovestr", 0x[[:xdigit:]]*, 0x[[:xdigit:]]*) = 0' |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 12 | pattern_raw='execve(0x[[:xdigit:]]*, 0x[[:xdigit:]]*, 0x[[:xdigit:]]*) = 0' |
| 13 | |
| 14 | check_output_mismatch() |
| 15 | { |
| 16 | local pattern |
| 17 | pattern="$1"; shift |
Elliott Hughes | 39bac05 | 2017-05-25 16:56:11 -0700 | [diff] [blame] | 18 | run_strace "$@" ../umovestr |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 19 | LC_ALL=C grep -x "$pattern" "$LOG" > /dev/null || { |
| 20 | printf '%s\n%s\n' \ |
| 21 | 'Failed patterns of expected output:' "$pattern" |
| 22 | dump_log_and_fail_with "$STRACE $args output mismatch" |
| 23 | } |
| 24 | } |
| 25 | |
| 26 | check_output_mismatch "$pattern_abbrev_verbose" -e execve |
| 27 | LC_ALL=C grep -v -x "$pattern_abbrev_verbose" "$LOG" | |
| 28 | LC_ALL=C grep '^[[:alnum:]_]*(' > /dev/null && |
| 29 | dump_log_and_fail_with "$STRACE $args unexpected output" |
| 30 | |
Elliott Hughes | 39bac05 | 2017-05-25 16:56:11 -0700 | [diff] [blame] | 31 | check_output_mismatch "$pattern_abbrev_verbose" -e trace=%process |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 32 | LC_ALL=C grep '^chdir' "$LOG" > /dev/null && |
| 33 | dump_log_and_fail_with "$STRACE $args unexpected output" |
| 34 | |
Elliott Hughes | 39bac05 | 2017-05-25 16:56:11 -0700 | [diff] [blame] | 35 | run_strace -e 42 ../umovestr |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 36 | LC_ALL=C grep '^[[:alnum:]_]*(' "$LOG" > /dev/null && |
| 37 | dump_log_and_fail_with "$STRACE $args unexpected output" |
| 38 | |
Elliott Hughes | 39bac05 | 2017-05-25 16:56:11 -0700 | [diff] [blame] | 39 | run_strace -e/ -e42 ../umovestr |
| 40 | LC_ALL=C grep '^[[:alnum:]_]*(' "$LOG" > /dev/null && |
| 41 | dump_log_and_fail_with "$STRACE $args unexpected output" |
| 42 | |
| 43 | for a in execve \!chdir /. all \!none \ |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 44 | file process \!desc \!ipc \!memory \!network \!signal; do |
| 45 | check_output_mismatch \ |
| 46 | "$pattern_abbrev_verbose" -e abbrev="$a" -e execve |
| 47 | check_output_mismatch \ |
| 48 | "$pattern_raw" -a22 -e raw="$a" -e execve |
| 49 | check_output_mismatch \ |
| 50 | "$pattern_abbrev_verbose" -e verbose="$a" -e execve |
| 51 | done |
| 52 | |
| 53 | for a in \!execve chdir 42 \!all none \ |
| 54 | \!file \!process desc ipc memory network signal; do |
| 55 | check_output_mismatch \ |
| 56 | "$pattern_nonabbrev_verbose" -e abbrev="$a" -e execve |
| 57 | check_output_mismatch \ |
| 58 | "$pattern_abbrev_verbose" -e raw="$a" -e execve |
| 59 | check_output_mismatch \ |
| 60 | "$pattern_nonverbose" -a31 -e verbose="$a" -e execve |
| 61 | done |
| 62 | |
| 63 | exit 0 |