summaryrefslogtreecommitdiffstats
path: root/tests/test-lib.sh
diff options
context:
space:
mode:
authorJeff Layton <jlayton@redhat.com>2010-01-11 20:27:54 -0500
committerSteve Dickson <steved@redhat.com>2010-01-12 06:01:29 -0500
commit3b2a15cc391a008b3c1f1c617b8224004b391004 (patch)
treec73f43c6d2c3070d0d45d4ea9a6e4adf6cc526a7 /tests/test-lib.sh
parent8aca027278a79b1a13f26e6ba8009a076c802b43 (diff)
downloadnfs-utils-3b2a15cc391a008b3c1f1c617b8224004b391004.tar.gz
nfs-utils-3b2a15cc391a008b3c1f1c617b8224004b391004.tar.xz
nfs-utils-3b2a15cc391a008b3c1f1c617b8224004b391004.zip
nfs-utils: add initial tests for statd that run via "make check"
Leverage the support that automake already has for running tests via make check. Add a simple test that just checks that the statd mon and unmon calls actually work. Adding more tests should be a simple matter of adding new scripts exit 0 on success and non-zero on fail, and adding those to the Makefile.am. Signed-off-by: Jeff Layton <jlayton@redhat.com> Signed-off-by: Steve Dickson <steved@redhat.com>
Diffstat (limited to 'tests/test-lib.sh')
-rw-r--r--tests/test-lib.sh60
1 files changed, 60 insertions, 0 deletions
diff --git a/tests/test-lib.sh b/tests/test-lib.sh
new file mode 100644
index 0000000..3d47264
--- /dev/null
+++ b/tests/test-lib.sh
@@ -0,0 +1,60 @@
+#!/bin/bash
+#
+# test-lib.sh -- library of functions for nfs-utils tests
+#
+# Copyright (C) 2010 Red Hat, Jeff Layton <jlayton@redhat.com>
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+
+# make sure $srcdir is set and sanity check it
+srcdir=${srcdir-.}
+if [ ! -d ${srcdir} ]; then
+ echo "***ERROR***: bad installation -- \$srcdir=${srcdir}"
+ exit 1
+fi
+
+export PATH=$PATH:${srcdir}:${srcdir}/nsm_client
+
+# Some tests require root privileges. Check for them and skip the test (exit 77)
+# if the caller doesn't have them.
+check_root() {
+ if [ $EUID -ne 0 ]; then
+ echo "*** Skipping this test as it requires root privs ***"
+ exit 77
+ fi
+}
+
+# is lockd registered as a service?
+lockd_registered() {
+ rpcinfo -p | grep -q nlockmgr
+ return $?
+}
+
+# start up statd
+start_statd() {
+ rpcinfo -u 127.0.0.1 status 1 &> /dev/null
+ if [ $? -eq 0 ]; then
+ echo "***ERROR***: statd is already running and should "
+ echo " be down when starting this test"
+ return 1
+ fi
+ $srcdir/../utils/statd/statd --no-notify
+}
+
+# shut down statd
+kill_statd() {
+ kill `cat /var/run/rpc.statd.pid`
+}