cluster-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
From: Steven Whitehouse <swhiteho@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [PATCH] gfs2-utils tests: Add a script to exercise the utils
Date: Fri, 14 Dec 2012 13:33:38 +0000	[thread overview]
Message-ID: <1355492018.2709.17.camel@menhir> (raw)
In-Reply-To: <1355491317-8733-1-git-send-email-anprice@redhat.com>

Hi,

On Fri, 2012-12-14 at 13:21 +0000, Andrew Price wrote:
> Add a test script to make it easy to run gfs2 utils with various options
> and check their exit codes in sequence. The script is plugged into the
> test suite and is run with 'make check'.
> 
> Signed-off-by: Andrew Price <anprice@redhat.com>
> ---
>  tests/Makefile.am   |  4 +++-
>  tests/tool_tests.sh | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 65 insertions(+), 1 deletion(-)
>  create mode 100755 tests/tool_tests.sh
> 
> diff --git a/tests/Makefile.am b/tests/Makefile.am
> index 71c1e08..d8aa8f2 100644
> --- a/tests/Makefile.am
> +++ b/tests/Makefile.am
> @@ -1,4 +1,6 @@
> -TESTS			= check_libgfs2
> +TESTS_ENVIRONMENT	= TOPBUILDDIR=$(top_builddir)
> +TESTS			= check_libgfs2 tool_tests.sh
> +EXTRA_DIST		= tool_tests.sh
>  check_PROGRAMS		= check_libgfs2
>  check_libgfs2_SOURCES	= check_meta.c \
>  			  $(top_srcdir)/gfs2/libgfs2/libgfs2.h
> diff --git a/tests/tool_tests.sh b/tests/tool_tests.sh
> new file mode 100755
> index 0000000..791b071
> --- /dev/null
> +++ b/tests/tool_tests.sh
> @@ -0,0 +1,62 @@
> +#!/bin/sh
> +
> +# This script runs gfs2 utils with various options, checking exit codes against
> +# expected values. If any test fails to exit with an expected code, the exit code
> +# of the whole script will be non-zero but the tests will continue to be run. The
> +# sparse file which is used as the target of the tests can be configured by
> +# setting the environment variables TEST_TARGET (the filename) and TEST_TARGET_SZ
> +# (its apparent size in gigabytes). Defaults to "test_sparse" and 10GB.
> +
> +MKFS="${TOPBUILDDIR}/gfs2/mkfs/mkfs.gfs2 -qO"
> +FSCK="${TOPBUILDDIR}/gfs2/fsck/fsck.gfs2 -qn"
> +
> +# Name of the sparse file we'll use for testing
> +TEST_TARGET=${TEST_TARGET:-test_sparse}
> +# Size, in GB, of the sparse file we'll create to run the tests
> +TEST_TARGET_SZ=${TEST_TARGET_SZ:-10}
> +[ $TEST_TARGET_SZ -gt 0 ] || { echo "Target size (in GB) must be greater than 0" >&2; exit 1; }
> +# Overall success (so we can keep going if one test fails)
> +TEST_RET=0
> +
> +fn_test()
> +{
> +	local expected="$1"
> +	local cmd="$2"
> +	echo -n "Running '$cmd' - (Exp: $expected Got: "
> +	$cmd &> /dev/null;
> +	local ret=$?
> +	echo -n "$ret) "
> +	if [ "$ret" != "$expected" ];
> +	then
> +		echo "FAIL"
> +		TEST_RET=1
> +		TEST_GRP_RET=1
> +	else
> +		echo "PASS"
> +	fi
> +}
> +
> +fn_rm_target()
> +{
> +	fn_test 0 "rm -f $TEST_TARGET"
> +}
> +
> +fn_recreate_target()
> +{
> +	fn_rm_target
> +	fn_test 0 "dd if=/dev/null of=$TEST_TARGET bs=1 count=0 seek=${TEST_TARGET_SZ}G"

This doesn't look very sparse, shouldn't we be creating it with truncate
rather than dd?

Steve.


> +}
> +
> +
> +# Tests start here
> +fn_recreate_target
> +fn_test 0 "$MKFS -p lock_nolock $TEST_TARGET"
> +fn_test 0 "$MKFS -p lock_dlm -t foo:bar $TEST_TARGET"
> +fn_test 255 "$MKFS -p badprotocol $TEST_TARGET"
> +fn_test 0 "$FSCK $TEST_TARGET"
> +
> +# Tests end here
> +
> +# Clean up
> +fn_test 0 "rm -f $TEST_TARGET"
> +exit $TEST_RET




  reply	other threads:[~2012-12-14 13:33 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-12 16:09 [Cluster-devel] [PATCH] gfs2-utils: Add the beginnings of a test suite Andrew Price
2012-12-13 10:58 ` Steven Whitehouse
2012-12-14 13:21   ` [Cluster-devel] [PATCH] gfs2-utils tests: Add a script to exercise the utils Andrew Price
2012-12-14 13:33     ` Steven Whitehouse [this message]
2012-12-14 13:44       ` Andrew Price
2012-12-14 13:45         ` Steven Whitehouse

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1355492018.2709.17.camel@menhir \
    --to=swhiteho@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).