diff options
author | Stefan Metzmacher <metze@samba.org> | 2018-09-04 10:38:44 +0200 |
---|---|---|
committer | Stefan Metzmacher <metze@samba.org> | 2018-09-05 13:35:30 +0200 |
commit | 5f8978321fea94bab94810bda4ea4b16928fd150 (patch) | |
tree | de94c38e1ec1540b3368412095a104abc404e7d7 | |
parent | fab6d42c6b98e5809d2abef886b16fb73fa27d7b (diff) | |
download | samba-5f8978321fea94bab94810bda4ea4b16928fd150.tar.gz |
testprogs/blackbox: add testit[_expect_failure]_grep() to subunit.sh
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13539
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
(cherry picked from commit 8526feb100e59bc5a15ceb940e6cecce0de59247)
-rwxr-xr-x | testprogs/blackbox/subunit.sh | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/testprogs/blackbox/subunit.sh b/testprogs/blackbox/subunit.sh index aca53f72536..bcc5bd6a928 100755 --- a/testprogs/blackbox/subunit.sh +++ b/testprogs/blackbox/subunit.sh @@ -90,6 +90,31 @@ testit () { return $status } +# This returns 0 if the command gave success and the grep value was found +# all other cases return != 0 +testit_grep () { + name="$1" + shift + grep="$1" + shift + cmdline="$@" + subunit_start_test "$name" + output=`$cmdline 2>&1` + status=$? + if [ x$status != x0 ]; then + printf '%s' "$output" | subunit_fail_test "$name" + return $status + fi + printf '%s' "$output" | grep -q "$grep" + gstatus=$? + if [ x$gstatus = x0 ]; then + subunit_pass_test "$name" + else + printf 'GREP: "%s" not found in output:\n%s' "$grep" "$output" | subunit_fail_test "$name" + fi + return $status +} + testit_expect_failure () { name="$1" shift @@ -105,6 +130,31 @@ testit_expect_failure () { return $status } +# This returns 0 if the command gave a failure and the grep value was found +# all other cases return != 0 +testit_expect_failure_grep () { + name="$1" + shift + grep="$1" + shift + cmdline="$@" + subunit_start_test "$name" + output=`$cmdline 2>&1` + status=$? + if [ x$status = x0 ]; then + printf '%s' "$output" | subunit_fail_test "$name" + return 1 + fi + printf '%s' "$output" | grep -q "$grep" + gstatus=$? + if [ x$gstatus = x0 ]; then + subunit_pass_test "$name" + else + printf 'GREP: "%s" not found in output:\n%s' "$grep" "$output" | subunit_fail_test "$name" + fi + return $status +} + testok () { name=`basename $1` failed=$2 |