]> granicus.if.org Git - strace/commitdiff
tests/init.sh: enhance match_grep error diagnostics
authorDmitry V. Levin <ldv@altlinux.org>
Sat, 19 Sep 2015 00:11:07 +0000 (00:11 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Sat, 19 Sep 2015 01:04:49 +0000 (04:04 +0300)
* tests/init.sh (match_grep): Check patterns one by one,
output only those patterns that didn't match.

tests/init.sh

index 0ff513fced8d1a270ec1b8b93080191284e01e3e..8de745753952a4424d67f094149a432f8836f7cc 100644 (file)
@@ -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"