From: Dmitry V. Levin Date: Sat, 19 Sep 2015 00:11:07 +0000 (+0000) Subject: tests/init.sh: enhance match_grep error diagnostics X-Git-Tag: v4.11~165 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3b731941f35465533376a9f4ac0d48baeb0b7e07;p=strace tests/init.sh: enhance match_grep error diagnostics * tests/init.sh (match_grep): Check patterns one by one, output only those patterns that didn't match. --- diff --git a/tests/init.sh b/tests/init.sh index 0ff513fc..8de74575 100644 --- a/tests/init.sh +++ b/tests/init.sh @@ -136,7 +136,7 @@ match_diff() # dump both files and fail with ERROR_MESSAGE. match_grep() { - local output patterns error expected matched + local output patterns error pattern failed= if [ $# -eq 0 ]; then output="$LOG" else @@ -156,11 +156,16 @@ match_grep() check_prog wc check_prog grep - expected=$(wc -l < "$patterns") && - matched=$(LC_ALL=C grep -c -E -x -f "$patterns" < "$output") && - test "$expected" -eq "$matched" || { - echo 'Patterns of expected output:' - cat < "$patterns" + while read -r pattern; do + LC_ALL=C grep -E -x -e "$pattern" < "$output" > /dev/null || { + test -n "$failed" || { + echo 'Failed patterns of expected output:' + failed=1 + } + printf '%s\n' "$pattern" + } + done < "$patterns" + test -z "$failed" || { echo 'Actual output:' cat < "$output" fail_ "$error"