testprogs: Return the correct error status code
[samba.git] / testprogs / blackbox / common_test_fns.inc
index f77879ae39fe1c58745071d8231dd48483518dd3..a5611c63fa044336d74985ded4d63111706ae5e5 100755 (executable)
@@ -14,7 +14,7 @@ test_smbclient() {
        if [ x$status = x0 ]; then
                subunit_pass_test "$name"
        else
-               echo "$output" | subunit_fail_test "$name"
+               printf '%s' "$output" | subunit_fail_test "$name"
        fi
        return $status
 }
@@ -30,7 +30,7 @@ test_smbclient_expect_failure() {
        output=`$VALGRIND $smbclient $CONFIGURATION "$unc" -c "$cmd" $@ 2>&1`
        status=$?
        if [ x$status = x0 ]; then
-               echo "$output" | subunit_fail_test "$name"
+               printf '%s' "$output" | subunit_fail_test "$name"
        else
                subunit_pass_test "$name"
        fi
@@ -50,15 +50,15 @@ test_rpcclient_grep() {
        output=`$VALGRIND $rpcclient $CONFIGURATION "$srv" -c "$cmd" $@ 2>&1`
        status=$?
        if [ x$status != x0 ]; then
-               echo "$output" | subunit_fail_test "$name"
+               printf '%s' "$output" | subunit_fail_test "$name"
                return $status
        fi
-       echo "$output" | grep -q "$grep"
+       printf '%s' "$output" | grep -q "$grep"
        gstatus=$?
        if [ x$gstatus = x0 ]; then
                subunit_pass_test "$name"
        else
-               echo "$output" | subunit_fail_test "$name"
+               printf '%s' "$output" | subunit_fail_test "$name"
        fi
        return $status
 }
@@ -76,15 +76,34 @@ test_rpcclient_expect_failure_grep() {
        output=`$VALGRIND $rpcclient $CONFIGURATION "$srv" -c "$cmd" $@ 2>&1`
        status=$?
        if [ x$status = x0 ]; then
-               echo "$output" | subunit_fail_test "$name"
+               printf '%s' "$output" | subunit_fail_test "$name"
                return $status
        fi
-       echo "$output" | grep -q "$grep"
+       printf '%s' "$output" | grep -q "$grep"
        gstatus=$?
        if [ x$gstatus = x0 ]; then
                subunit_pass_test "$name"
        else
-               echo "$output" | subunit_fail_test "$name"
+               printf '%s' "$output" | subunit_fail_test "$name"
+       fi
+       return $status
+}
+
+kerberos_kinit() {
+       kinit_tool="${1}"
+       principal="${2}"
+       password="${3}"
+       shift 3
+       kbase=$(basename ${kinit_tool})
+       if [ "${kbase}" = "samba4kinit" ]; then
+               kpassfile=$(mktemp)
+               echo $password > ${kpassfile}
+               $kinit_tool --password-file=${kpassfile} $principal $@
+               status=$?
+               rm -f ${kpassfile}
+       else
+               echo $password | $kinit_tool $principal $@
+               status=$?
        fi
        return $status
 }