2016-04-24 21:09:05 +03:00
# Common tests
# Pulled out of existing tests to prevent duplication.
#
test_smbclient () {
name = " $ 1 "
cmd = " $ 2 "
unc = " $ 3 "
shift
shift
shift
2017-03-29 12:53:18 +03:00
subunit_start_test " $name "
output = `$VALGRIND $smbclient $CONFIGURATION "$unc" -c "$cmd" $@ 2>&1`
2016-04-24 21:09:05 +03:00
status = $ ?
if [ x $status = x0 ]; then
2017-03-29 12:53:18 +03:00
subunit_pass_test " $name "
2016-04-24 21:09:05 +03:00
else
2018-02-27 01:58:20 +03:00
printf '%s' " $output " | subunit_fail_test " $name "
2016-04-24 21:09:05 +03:00
fi
return $status
}
2016-09-06 09:56:47 +03:00
test_smbclient_expect_failure () {
name = " $ 1 "
cmd = " $ 2 "
unc = " $ 3 "
shift
shift
shift
2017-03-29 12:53:18 +03:00
subunit_start_test " $name "
output = `$VALGRIND $smbclient $CONFIGURATION "$unc" -c "$cmd" $@ 2>&1`
2016-09-06 09:56:47 +03:00
status = $ ?
if [ x $status = x0 ]; then
2018-02-27 01:58:20 +03:00
printf '%s' " $output " | subunit_fail_test " $name "
2016-09-06 09:56:47 +03:00
else
2017-03-29 12:53:18 +03:00
subunit_pass_test " $name "
2016-09-06 09:56:47 +03:00
fi
return $status
}
2017-03-29 12:53:41 +03:00
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
2018-02-27 01:58:20 +03:00
printf '%s' " $output " | subunit_fail_test " $name "
2017-03-29 12:53:41 +03:00
return $status
fi
2018-02-27 01:58:20 +03:00
printf '%s' " $output " | grep - q " $grep "
2017-03-29 12:53:41 +03:00
gstatus = $ ?
if [ x $gstatus = x0 ]; then
subunit_pass_test " $name "
else
2018-02-27 01:58:20 +03:00
printf '%s' " $output " | subunit_fail_test " $name "
2017-03-29 12:53:41 +03:00
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
2018-02-27 01:58:20 +03:00
printf '%s' " $output " | subunit_fail_test " $name "
2017-03-29 12:53:41 +03:00
return $status
fi
2018-02-27 01:58:20 +03:00
printf '%s' " $output " | grep - q " $grep "
2017-03-29 12:53:41 +03:00
gstatus = $ ?
if [ x $gstatus = x0 ]; then
subunit_pass_test " $name "
else
2018-02-27 01:58:20 +03:00
printf '%s' " $output " | subunit_fail_test " $name "
2017-03-29 12:53:41 +03:00
fi
return $status
}
2016-09-13 09:24:06 +03:00
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 $ @
2018-03-01 12:54:52 +03:00
status = $ ?
2016-09-13 09:24:06 +03:00
rm - f $ { kpassfile }
else
echo $password | $kinit_tool $principal $ @
2018-03-01 12:54:52 +03:00
status = $ ?
2016-09-13 09:24:06 +03:00
fi
2018-03-01 12:54:52 +03:00
return $status
2016-09-13 09:24:06 +03:00
}
2020-10-22 12:39:04 +03:00
remove_directory () {
local xdir = $ { 1 }
shift
if [ " $xdir " == " / " ] || [ ! - d " $xdir " ] || [ ! $ ( ls - A " $xdir " ) ]; then
return
fi
rm - rf " $xdir "
}