]> git.decadent.org.uk Git - nfs-utils.git/blob - tests/test-lib.sh
sm-notify: sm-notify leaves monitor records in sm.bak
[nfs-utils.git] / tests / test-lib.sh
1 #!/bin/bash
2 #
3 # test-lib.sh -- library of functions for nfs-utils tests
4 #
5 # Copyright (C) 2010  Red Hat, Jeff Layton <jlayton@redhat.com>
6 #
7 # This program is free software; you can redistribute it and/or
8 # modify it under the terms of the GNU General Public License
9 # as published by the Free Software Foundation; either version 2
10 # of the License, or (at your option) any later version.
11 #
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 # GNU General Public License for more details.
16 #
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 0211-1301 USA
20 #
21
22 # make sure $srcdir is set and sanity check it
23 srcdir=${srcdir-.}
24 if [ ! -d ${srcdir} ]; then
25         echo "***ERROR***: bad installation -- \$srcdir=${srcdir}"
26         exit 1
27 fi
28
29 export PATH=$PATH:${srcdir}:${srcdir}/nsm_client
30
31 # Some tests require root privileges. Check for them and skip the test (exit 77)
32 # if the caller doesn't have them.
33 check_root() {
34         if [ $EUID -ne 0 ]; then
35                 echo "*** Skipping this test as it requires root privs ***"
36                 exit 77
37         fi
38 }
39
40 # is lockd registered as a service?
41 lockd_registered() {
42         rpcinfo -p | grep -q nlockmgr
43         return $?
44 }
45
46 # start up statd
47 start_statd() {
48         rpcinfo -u 127.0.0.1 status 1 &> /dev/null
49         if [ $? -eq 0 ]; then
50                 echo "***ERROR***: statd is already running and should "
51                 echo "             be down when starting this test"
52                 return 1
53         fi
54         $srcdir/../utils/statd/statd --no-notify
55 }
56
57 # shut down statd
58 kill_statd() {
59         kill `cat /var/run/rpc.statd.pid`
60 }