r9618: adding get/put tests from Don Watson
[Samba/gbeck.git] / source / script / tests / functions
blob0981d9e29e149770853ac3060b22576a6cb29ff5
1 ##
2 ## library file for test functions
3 ##
6 SMBCONTROL="smbcontrol -t 3"
8 ##
9 ## start/stop smbd daemon
11 check_smbd_running()
13         ## the smbcontrol ping will return a 0 on success
14         $SMBCONTROL $CONFIGURATION smbd ping 2>&1 > /dev/null
17 start_smbd()
19         echo "Starting smbd...."
21         smbd $CONFIGURATION || return $?
23         sleep 1
25         $SMBCONTROL $CONFIGURATION `cat $PIDDIR/smbd.pid` ping 2>&1 > /dev/null || return $?
28 stop_smbd()
30         smbd_pid=`cat $PIDDIR/smbd.pid`
31         echo "Shutting down smbd (pid $smbd_pid)..."
33         ## belt and braces; first kill and then send a shutdown message
35         kill -TERM $smbd_pid
36         $SMBCONTROL $CONFIGURATION smbd shutdown
38         ## check to see if smbd is already running
39         check_smbd_running
40         if test $? == 0; then
41                 echo "Unable to stop smbd!"
42                 exit 2
43         fi
46 check_ret_value()
48         ret=$@
50         if test $ret != 0; then
51                 stop_smbd
52                 exit $ret
53         fi
57 ## start/stop nmbd daemon
59 check_nmbd_running()
61         ## the smbcontrol ping will return a 0 on success
62         $SMBCONTROL $CONFIGURATION nmbd ping 2>&1 > /dev/null
65 start_nmbd()
67         echo "Starting nmbd...."
69         nmbd $CONFIGURATION || return $?
71         sleep 1
73         # smbcontrol $CONFIGURATION `cat $PIDDIR/nmbd.pid` ping 2>&1 > /dev/null || return $?
74         kill -0 `cat $PIDDIR/nmbd.pid`
77 stop_nmbd()
79         nmbd_pid=`cat $PIDDIR/nmbd.pid`
80         echo "Shutting down nmbd (pid $nmbd_pid)..."
82         ## belt and braces; first kill and then send a shutdown message
84         kill -TERM $nmbd_pid 2> /dev/null
85         sleep 1
87         ## check to see if smbd is already running
88         kill -0 $nmbd_pid 2> /dev/null
89         if test $? == 0; then
90                 echo "Unable to stop nmbd!"
91                 exit 2
92         fi