[Cluster-devel] [PATCH 4/5] gfs2-utils tests: Skip unit tests if check is not found
Andrew Price
anprice at redhat.com
Wed Jan 14 16:16:20 UTC 2015
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 at 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
More information about the Cluster-devel
mailing list