tests: factor out common shell code to functions
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.
diff --git a/tests/uid.test b/tests/uid.test
index d8b0261..7bbcca7 100755
--- a/tests/uid.test
+++ b/tests/uid.test
@@ -4,29 +4,15 @@
. "${srcdir=.}/init.sh"
-check_prog gawk
-
s="${uid_syscall_suffix-}"
w="${uid_t_size-}"
-uid="uid$s$w"
-./"$uid" || {
- if [ $? -eq 77 ]; then
- framework_skip_ "some uid$s or uid${w}_t syscalls are not available"
- else
- fail_ "$uid failed"
- fi
-}
+
+run_prog ./uid$s$w
syscalls="getuid$s,setuid$s,getresuid$s,setreuid$s,setresuid$s,fchown$s,getgroups$s"
-args="-e trace=$syscalls"
-$STRACE -o "$LOG" $args ./"$uid"|| {
- cat "$LOG"
- fail_ "$STRACE $args ./$uid failed"
-}
+run_strace -e trace="$syscalls" $args
-gawk -f "$srcdir"/uid.awk -v suffix="$s" "$LOG" || {
- cat "$LOG"
- fail_ 'unexpected output'
-}
+AWK=gawk
+match_awk "$LOG" "$srcdir"/uid.awk "$STRACE $args output mismatch" -v suffix="$s"
exit 0