define_test "not managed, check no-op"
-setup_samba "down"
+setup "down"
ok_null
define_test "all OK"
-setup_samba
+setup
ok_null
define_test "port 445 down"
-setup_samba
+setup
+
tcp_port_down 445
required_result 1 "samba not listening on TCP port 445"
define_test "port 139 down"
-setup_samba
+setup
+
tcp_port_down 139
required_result 1 "samba not listening on TCP port 139"
define_test "non-existent share path"
-setup_samba
+setup
out=$(shares_missing "ERROR: samba directory \"%s\" not available" 2)
define_test "non-existent share - not checked"
-setup_samba
+setup
-export CTDB_SAMBA_SKIP_SHARE_CHECK="yes"
+CTDB_SAMBA_SKIP_SHARE_CHECK="yes"
ok_null
define_test "testparm fails"
-setup_samba
+setup
export FAKE_TESTPARM_FAIL="yes"
required_result 1 <<EOF
define_test "testparm fails on 2nd time through"
-setup_samba
+setup
ok_null
simple_test
define_test "testparm times out"
-setup_samba
+setup
export FAKE_TIMEOUT="yes"
required_result 1 <<EOF
define_test "testparm times out on 2nd time through"
-setup_samba
+setup
ok_null
simple_test
define_test "shutdown, simple"
-setup_samba
+setup
ok <<EOF
Stopping smb: OK
define_test "shutdown, simple"
-setup_samba
+setup
samba_setup_fake_threads 1 2 3 4 5 6
define_test "shutdown, Debian init style"
-setup_samba
+setup
export EVENTSCRIPT_TESTS_INIT_STYLE="debian"
define_test "shutdown, Debian init style"
-setup_samba
+setup
export EVENTSCRIPT_TESTS_INIT_STYLE="debian"
-setup_samba ()
+setup ()
{
- setup_ctdb
-
service_name="samba"
if [ "$1" != "down" ] ; then
service "$i" force-started
done
- export CTDB_SAMBA_SKIP_SHARE_CHECK="no"
export CTDB_MANAGES_SAMBA="yes"
- export FAKE_TCP_LISTEN="0.0.0.0:445 0.0.0.0:139"
- export FAKE_WBINFO_FAIL="no"
+ setup_tcp_listen 445 139
# Some things in 50.samba are backgrounded and waited
# for. If we don't sleep at all then timeouts can
service "$i" force-stopped
done
- export CTDB_SAMBA_SKIP_SHARE_CHECK="no"
export CTDB_MANAGES_SAMBA=""
- export FAKE_TCP_LISTEN=""
- export FAKE_WBINFO_FAIL="yes"
+ setup_tcp_listen
fi
+
+ export CTDB_SAMBA_SKIP_SHARE_CHECK="no"
+
+ setup_shares
+
}
samba_setup_fake_threads ()
setup_shares
setup_dbdir
setup_date
+}
+
+setup_tcp_listen ()
+{
+ export FAKE_TCP_LISTEN="$*"
+}
- export FAKE_TCP_LISTEN
+tcp_port_listening ()
+{
+ for _i ; do
+ FAKE_TCP_LISTEN="${FAKE_TCP_LISTEN} ${_i}"
+ done
}
tcp_port_down ()
{
- for _i ; do
- debug "Marking TCP port \"${_i}\" as not listening"
- FAKE_TCP_LISTEN=$(echo "$FAKE_TCP_LISTEN" | sed -r -e "s@[[:space:]]*[\.0-9]+:${_i}@@g")
- done
+ _port="$1"
+ debug "Marking TCP port \"${_port}\" as not listening"
+
+ _t=""
+ for _i in $FAKE_TCP_LISTEN ; do
+ if [ "$_i" = "$_port" ] ; then
+ continue
+ fi
+ _t="${_t} ${_i}"
+ done
+
+ FAKE_TCP_LISTEN="$_t"
}
setup_unix_listen ()
_port="$1"
for _i in $FAKE_TCP_LISTEN ; do
- if [ "$_port" = "${_i##*:}" ] ; then
+ if [ "$_port" = "$_i" ] ; then
exit 98
fi
done