strace/tests/match.awk
Dmitry V. Levin 226bf1c21b tests: factor out common awk code
Factor out awk code used in several tests to match.awk.

* tests/match.awk: New file.
* tests/Makefile.am (EXTRA_DIST): Add it.
* tests/caps.awk: Use it.
* tests/getdents.awk: Likewise.
* tests/getrandom.awk: Likewise.
* tests/select.awk: Likewise.
* tests/sigaction.awk: Likewise.
* tests/init.sh (match_awk): Use gawk not awk.  Define AWKPATH.
* tests/getdents.test: Likewise.
2015-03-18 22:41:17 +00:00

27 lines
436 B
Awk

# s[] is array of match strings
# r[] is array of match patterns
NR > lines { next }
{
if (s[NR]) {
if ($0 == s[NR])
next
print "Line " NR " does not match expected string: " s[NR]
} else {
if (match($0, r[NR]))
next
print "Line " NR " does not match expected pattern: " r[NR]
}
fail = 1
}
END {
if (fail == 0 && NR != lines) {
fail = 1
print "Expected " lines " lines, found " NR " line(s)."
}
exit fail
}