cluster-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
From: Andrew Price <anprice@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [PATCH 4/5] gfs2-utils tests: Skip unit tests if check is not found
Date: Wed, 14 Jan 2015 16:16:20 +0000	[thread overview]
Message-ID: <1421252181-20776-4-git-send-email-anprice@redhat.com> (raw)
In-Reply-To: <1421252181-20776-1-git-send-email-anprice@redhat.com>

The check package (check-devel in Fedora) is required for building the
unit tests. When the configure script doesn't find check, it prevents
the unit tests from being built, but the test suite still tries to run
the unit tests. Introduce a wrapper m4 macro GFS_UNIT_TEST to set up
unit test test groups which will be skipped if check was not found in
the configure stage.

Signed-off-by: Andrew Price <anprice@redhat.com>
---
 configure.ac       |  2 +-
 tests/Makefile.am  | 13 +++++++------
 tests/libgfs2.at   |  6 ++----
 tests/testsuite.at |  8 ++++++++
 4 files changed, 18 insertions(+), 11 deletions(-)

diff --git a/configure.ac b/configure.ac
index 2341730..a523be3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -97,7 +97,7 @@ AC_ARG_ENABLE([gcov],
 PKG_CHECK_MODULES([check], [check >= 0.9.8],
                   [have_check=yes],
                   [have_check=no])
-AM_CONDITIONAL([BUILD_TESTS], [test "x$have_check" = "xyes"])
+AM_CONDITIONAL([HAVE_CHECK], [test "x$have_check" = "xyes"])
 
 PKG_CHECK_MODULES([zlib],[zlib])
 PKG_CHECK_MODULES([blkid],[blkid])
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 475f4a7..3abb640 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -2,7 +2,7 @@ EXTRA_DIST = $(TESTSUITE_AT) package.m4 $(TESTSUITE) atlocal atconfig
 DISTCLEANFILES = atlocal atconfig
 CLEANFILES = testvol
 
-if BUILD_TESTS
+if HAVE_CHECK
 UNIT_TESTS = \
 	check_meta \
 	check_rgrp
@@ -55,19 +55,20 @@ TESTSUITE_AT = \
 	testsuite.at \
 	mkfs.at \
 	fsck.at \
-	edit.at
+	edit.at \
+	libgfs2.at
 
-if BUILD_TESTS
-TESTSUITE_AT += libgfs2.at
+if HAVE_CHECK
+ENABLE_UNIT=yes
 endif
 
 TESTSUITE = $(srcdir)/testsuite
 
 check-local: atconfig atlocal $(TESTSUITE)
-	$(SHELL) '$(TESTSUITE)' $(TOPTS)
+	$(SHELL) '$(TESTSUITE)' ENABLE_UNIT_TESTS=$(ENABLE_UNIT) $(TOPTS)
 
 installcheck-local: atconfig atlocal $(TESTSUITE)
-	$(SHELL) '$(TESTSUITE)' AUTOTEST_PATH='$(sbindir):tests' $(TOPTS)
+	$(SHELL) '$(TESTSUITE)' AUTOTEST_PATH='$(sbindir):tests' ENABLE_UNIT_TESTS=$(ENABLE_UNIT) $(TOPTS)
 
 clean-local:
 	test ! -f '$(TESTSUITE)' || $(SHELL) '$(TESTSUITE)' --clean
diff --git a/tests/libgfs2.at b/tests/libgfs2.at
index a5bee87..1d2243c 100644
--- a/tests/libgfs2.at
+++ b/tests/libgfs2.at
@@ -1,11 +1,9 @@
 AT_BANNER([libgfs2 unit tests])
 
-AT_SETUP([meta.c])
-AT_KEYWORDS(libgfs2)
+GFS_UNIT_TEST([meta.c],[libgfs2])
 AT_CHECK([check_meta], 0, [ignore], [ignore])
 AT_CLEANUP
 
-AT_SETUP([rgrp.c])
-AT_KEYWORDS(libgfs2)
+GFS_UNIT_TEST([rgrp.c],[libgfs2])
 AT_CHECK([check_rgrp], 0, [ignore], [ignore])
 AT_CLEANUP
diff --git a/tests/testsuite.at b/tests/testsuite.at
index fe781a7..aa86966 100644
--- a/tests/testsuite.at
+++ b/tests/testsuite.at
@@ -17,6 +17,14 @@ AT_CHECK([echo "$2" | gfs2l ${GFS_TGT}], 0, [ignore], [ignore])
 AT_CHECK([fsck.gfs2 -y $GFS_TGT], 1, [ignore], [ignore])
 AT_CHECK([fsck.gfs2 -n $GFS_TGT], 0, [ignore], [ignore])])
 
+# Set up a unit test, skipping if unit tests are disabled
+# Usage: GFS_UNIT_TEST ([name], [keywords])
+m4_define([GFS_UNIT_TEST],
+[AT_SETUP($1)
+AT_KEYWORDS($2)
+AT_CHECK([test x"$ENABLE_UNIT_TESTS" = "xyes" || exit 77])])
+
+# Test suite begins here
 AT_INIT([])
 AT_COLOR_TESTS
 
-- 
1.9.3



  parent reply	other threads:[~2015-01-14 16:16 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-14 16:16 [Cluster-devel] [PATCH 1/5] gfs2-utils tests: Add keywords to tests Andrew Price
2015-01-14 16:16 ` [Cluster-devel] [PATCH 2/5] gfs2-utils tests: Shorten TESTSUITEFLAGS to TOPTS Andrew Price
2015-01-14 16:16 ` [Cluster-devel] [PATCH 3/5] gfs2-utils tests: Improve docs Andrew Price
2015-01-14 16:16 ` Andrew Price [this message]
2015-01-14 16:16 ` [Cluster-devel] [PATCH 5/5] gfs2-utils tests: Document usage of convenience macros Andrew Price

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=1421252181-20776-4-git-send-email-anprice@redhat.com \
    --to=anprice@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).