From: Jonathan Lebon Date: Thu, 11 Jan 2018 20:54:26 +0000 (+0000) Subject: tests/libtest-core: support multiple literal checks X-Git-Tag: archive/raspbian/2022.1-3+rpi1~1^2~4^2~27^2~4 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=854a823e05d6fe8b610c02c2a71eaeb2bf1e98a6;p=ostree.git tests/libtest-core: support multiple literal checks `grep` supports checking multiple fixed strings separated by newlines, but it's mostly just easier to pass them as separate arguments, so let's support that. This is now at parity with the similar `assert_file_has_content`. Closes: #1409 Approved by: cgwalters --- diff --git a/tests/libtest-core.sh b/tests/libtest-core.sh index 2144e1ac..7223f4d2 100644 --- a/tests/libtest-core.sh +++ b/tests/libtest-core.sh @@ -112,9 +112,12 @@ assert_file_has_content () { } assert_file_has_content_literal () { - if ! grep -q -F -e "$2" "$1"; then - _fatal_print_file "$1" "File '$1' doesn't match fixed string list '$2'" - fi + fpath=$1; shift + for s in "$@"; do + if ! grep -q -F -e "$s" "$fpath"; then + _fatal_print_file "$fpath" "File '$fpath' doesn't match fixed string list '$s'" + fi + done } assert_file_has_mode () {