diff --git a/testprogs/blackbox/common_test_fns.inc b/testprogs/blackbox/common_test_fns.inc index 7e54c673777..f77879ae39f 100755 --- a/testprogs/blackbox/common_test_fns.inc +++ b/testprogs/blackbox/common_test_fns.inc @@ -36,3 +36,55 @@ test_smbclient_expect_failure() { fi return $status } + +test_rpcclient_grep() { + name="$1" + cmd="$2" + srv="$3" + grep="$4" + shift + shift + shift + shift + subunit_start_test "$name" + output=`$VALGRIND $rpcclient $CONFIGURATION "$srv" -c "$cmd" $@ 2>&1` + status=$? + if [ x$status != x0 ]; then + echo "$output" | subunit_fail_test "$name" + return $status + fi + echo "$output" | grep -q "$grep" + gstatus=$? + if [ x$gstatus = x0 ]; then + subunit_pass_test "$name" + else + echo "$output" | subunit_fail_test "$name" + fi + return $status +} + +test_rpcclient_expect_failure_grep() { + name="$1" + cmd="$2" + srv="$3" + grep="$4" + shift + shift + shift + shift + subunit_start_test "$name" + output=`$VALGRIND $rpcclient $CONFIGURATION "$srv" -c "$cmd" $@ 2>&1` + status=$? + if [ x$status = x0 ]; then + echo "$output" | subunit_fail_test "$name" + return $status + fi + echo "$output" | grep -q "$grep" + gstatus=$? + if [ x$gstatus = x0 ]; then + subunit_pass_test "$name" + else + echo "$output" | subunit_fail_test "$name" + fi + return $status +}