Dmitry V. Levin
8f54664d68
Factor out shell code used in several tests to common functions. * tests/fanotify_mark.expected: New file. * tests/ioctl.expected: New file. * tests/net-fd.expected: New file. * tests/net.expected: New file. * tests/statfs.expected: New file. * tests/sun_path.expected: New file. * tests/uio.expected: New file. * tests/ipc.sh: New file. * tests/Makefile.am (EXTRA_DIST): Add them. * tests/init.sh (dump_log_and_fail_with, run_prog, run_prog_skip_if_failed, run_strace, run_strace_merge, match_awk, match_diff, match_grep): New functions. * tests/*.test: Use them.
37 lines
1.1 KiB
Bash
Executable File
37 lines
1.1 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
# Check -i option.
|
|
|
|
. "${srcdir=.}/init.sh"
|
|
|
|
check_prog sed
|
|
|
|
run_prog > /dev/null
|
|
|
|
args="-if $args"
|
|
$STRACE $args 2> "$LOG" ||
|
|
dump_log_and_fail_with "$STRACE $args failed"
|
|
|
|
len="$(sed -n 's/^\[[[:xdigit:]]\+\] write(-1, NULL, \([[:digit:]]\{1,2\}\))[[:space:]]\+= -1 .*/\1/p' "$LOG")" &&
|
|
[ -n "$len" ] &&
|
|
pid="$(sed -n 's/^\[[[:xdigit:]]\{'"$len"'\}\] --- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_\(KILLED\|DUMPED\), si_pid=\([[:digit:]]\+\), .*/\2/p' "$LOG")" &&
|
|
[ -n "$pid" ] &&
|
|
ip="$(sed -n 's/^\[pid \+'"$pid"'\] \[\([[:xdigit:]]\{'"$len"'\}\)] --- SIGSEGV {.*} ---$/\1/p' "$LOG")" &&
|
|
[ -n "$ip" ] &&
|
|
addr="$(echo "$ip" |sed 's/^0\+//')" &&
|
|
[ -n "$addr" ] ||
|
|
dump_log_and_fail_with
|
|
|
|
EXPECTED="$LOG.expected"
|
|
cat > "$EXPECTED" << __EOF__
|
|
\\[[[:xdigit:]]{$len}\\] munmap\\(0x[[:xdigit:]]+, 0\\) += -1 .*
|
|
\\[pid +$pid\\] \\[$ip\\] --- SIGSEGV \\{si_signo=SIGSEGV, si_code=SEGV_MAPERR, si_addr=0x$addr\\} ---
|
|
\\[pid +$pid\\] \\[\\?{$len}\\] \\+\\+\\+ killed by SIGSEGV( \\(core dumped\\))? \\+\\+\\+
|
|
\\[\\?{$len}\\] \\+\\+\\+ exited with 0 \\+\\+\\+
|
|
__EOF__
|
|
|
|
match_grep "$LOG" "$EXPECTED"
|
|
rm -f "$EXPECTED"
|
|
|
|
exit 0
|