From mboxrd@z Thu Jan 1 00:00:00 1970 From: Steve Dickson Subject: Re: [PATCH 3/3] nfs-utils: add initial tests for statd that run via "make check" Date: Tue, 05 Jan 2010 11:37:39 -0500 Message-ID: <4B436AD3.2080107@RedHat.com> References: <1262706035-4929-1-git-send-email-jlayton@redhat.com> <1262706035-4929-4-git-send-email-jlayton@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Cc: chuck.lever@oracle.com, linux-nfs@vger.kernel.org To: Jeff Layton Return-path: Received: from mx1.redhat.com ([209.132.183.28]:4924 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754317Ab0AEQh4 (ORCPT ); Tue, 5 Jan 2010 11:37:56 -0500 In-Reply-To: <1262706035-4929-4-git-send-email-jlayton@redhat.com> Sender: linux-nfs-owner@vger.kernel.org List-ID: On 01/05/2010 10:40 AM, Jeff Layton wrote: > 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 > --- > tests/Makefile.am | 2 + > tests/t0001-statd-basic-mon-unmon.sh | 55 ++++++++++++++++++++++++++++++++++ > tests/test-lib.sh | 41 +++++++++++++++++++++++++ > 3 files changed, 98 insertions(+), 0 deletions(-) > create mode 100755 tests/t0001-statd-basic-mon-unmon.sh > create mode 100755 tests/test-lib.sh > > diff --git a/tests/Makefile.am b/tests/Makefile.am > index a20b42b..faa8197 100644 > --- a/tests/Makefile.am > +++ b/tests/Makefile.am > @@ -9,3 +9,5 @@ statdb_dump_LDADD = ../support/nfs/libnfs.a \ > SUBDIRS = nsm_client > > MAINTAINERCLEANFILES = Makefile.in > + > +TESTS = t0001-statd-basic-mon-unmon.sh > diff --git a/tests/t0001-statd-basic-mon-unmon.sh b/tests/t0001-statd-basic-mon-unmon.sh > new file mode 100755 > index 0000000..6e0b869 > --- /dev/null > +++ b/tests/t0001-statd-basic-mon-unmon.sh > @@ -0,0 +1,55 @@ > +#!/bin/bash > +# > +# statd_basic_mon_unmon -- test basic mon/unmon functionality with statd > +# > +# Copyright (C) 2010 Red Hat, Jeff Layton > +# > +# 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. > +# > + > +. ./test-lib.sh > + > +start_statd > +if [ $? -ne 0 ]; then > + echo "FAIL: problem starting statd" > + exit 1 > +fi > + > +COOKIE=`echo $$ | md5sum | cut -d' ' -f1` > +MON_NAME=`hostname` > + > +nsm_client mon $MON_NAME $COOKIE > +if [ $? -ne 0 ]; then > + echo "FAIL: mon failed" > + kill_statd > + exit 1 > +fi > + > +./statdb_dump | grep $MON_NAME | grep -q $COOKIE > +if [ $? -ne 0 ]; then > + echo "FAIL: monitor DB doesn't seem to contain entry" > + kill_statd > + exit 1 > +fi > + > +nsm_client unmon $MON_NAME > +if [ $? -ne 0 ]; then > + echo "FAIL: unmon failed" > + kill_statd > + exit 1 > +fi > + > +kill_statd > + > diff --git a/tests/test-lib.sh b/tests/test-lib.sh > new file mode 100755 > index 0000000..e509859 > --- /dev/null > +++ b/tests/test-lib.sh > @@ -0,0 +1,41 @@ > +#!/bin/bash > +# > +# test-lib.sh -- library of functions for nfs-utils tests > +# > +# Copyright (C) 2010 Red Hat, Jeff Layton > +# > +# 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. > +# > + > +export PATH=$PATH:$srcdir/nsm_client How or Where is '$srcdir' set?? steved.