Gitweb:
http://git.fedorahosted.org/git/?p=gfs2-utils.git;a=commitdiff;h=0352f737...
Commit: 0352f73791b80745c17f651f55faf7ce3a28d435
Parent: 7a54f62b693f4b9e89de20c29e5d8db6d8ced34d
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Wed Jan 14 15:05:25 2015 +0000
Committer: Andrew Price <anprice(a)redhat.com>
CommitterDate: Fri Jan 16 12:04:19 2015 +0000
gfs2-utils tests: Skip unit tests if check is not found
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(a)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