diff options
author | Eugene Syromyatnikov <evgsyr@gmail.com> | 2019-02-22 18:46:07 +0100 |
---|---|---|
committer | Dmitry V. Levin <ldv@altlinux.org> | 2019-05-21 23:30:35 +0000 |
commit | 784670bf77bfdc3a0f6c4e59f2d1305198ac7134 (patch) | |
tree | f8c96005475c6fdee7f0aa50647bca4dd3ec2ae3 | |
parent | 95259713fc31d58969928542008185239eeae192 (diff) | |
download | strace-784670bf77bfdc3a0f6c4e59f2d1305198ac7134.tar.gz |
tests: add support for negative match patterns to match_grep
For the cases when we want that some patterns do not appear in the
output.
* tests/init.sh (match_grep): Add res and negated local variables; set
negated to 1 if pattern starts with "!", otherwise to 0; fail if negated
pattern has been matched.
-rw-r--r-- | tests/init.sh | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/tests/init.sh b/tests/init.sh index 40e621889..7c5824c41 100644 --- a/tests/init.sh +++ b/tests/init.sh @@ -161,7 +161,7 @@ match_diff() # dump both files and fail with ERROR_MESSAGE. match_grep() { - local output patterns error pattern cnt failed= + local output patterns error pattern cnt failed= res negated if [ $# -eq 0 ]; then output="$LOG" else @@ -183,7 +183,20 @@ match_grep() cnt=1 while read -r pattern; do - LC_ALL=C grep -E -x -e "$pattern" < "$output" > /dev/null || { + negated=0 + [ "x${pattern#!}" = "x${pattern}" ] || { + negated=1 + pattern="${pattern}" + } + + if LC_ALL=C grep -E -x -e "${pattern#!}" < "$output" > /dev/null + then + res="$((!negated))" + else + res="$negated" + fi + + [ 1 = "$res" ] || { test -n "$failed" || { echo 'Failed patterns of expected output:' failed=1 |