mirror of
https://github.com/samba-team/samba.git
synced 2024-12-22 13:34:15 +03:00
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>
This commit is contained in:
parent
39c281a236
commit
8526feb100
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user