Skip to contentSkip to conversation

LVM2 test/Makefile.in ./Makefile.in ./configur ...

PATCH [email protected] 1 participant 1 message Nov 20, 2011 Kbuild

lore
Share & tools
lore
#0 lore raw

CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: mornfall at sourceware.org 2011-11-20 21:43:20

Modified files:
test : Makefile.in
. : Makefile.in configure.in
Added files:
test/unit : Makefile.in bitset_t.c matcher_data.h
matcher_t.c run.c

Log message:
Implement a CUnit-based runner for unit tests. Copy and adapt (actual unit) tests from unit-tests/*/*_t.c (now under test/unit). The valgrind/pool test is missing, since it's not really a unit test and probably not too valuable either. Available via "make unit" (and if --enable-testing was passed to configure, also executed by make check).

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/Makefile.in.diff?cvsroot=lvm2&r1=1.60&r2=1.61
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/Makefile.in.diff?cvsroot=lvm2&r1=1.65&r2=1.66
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/configure.in.diff?cvsroot=lvm2&r1=1.174&r2=1.175
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/unit/Makefile.in.diff?cvsroot=lvm2&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/unit/bitset_t.c.diff?cvsroot=lvm2&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/unit/matcher_data.h.diff?cvsroot=lvm2&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/unit/matcher_t.c.diff?cvsroot=lvm2&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/unit/run.c.diff?cvsroot=lvm2&r1=NONE&r2=1.1

test/Makefile.in +10 -0
@@ -43,7 +43,12 @@
 all: check
 
 check: .tests-stamp
+	@echo Running API (liblvm2app) tests
 	make -C api tests
+ifeq ("$(TESTING)", "yes")
+	@echo Running unit tests
+	make unit
+endif
 	@echo Testing with locking_type 1
 	VERBOSE=$(VERBOSE) ./lib/harness $(RUN_BASE)
 	@echo Testing with locking_type 3
@@ -111,6 +116,11 @@
 	make -C api clean
 	test "$(srcdir)" != . && rm -f $(RUN_BASE) lvm2app.sh
 
+.PHONY: unit
+
+unit:
+	make -C unit $(@)
+
 CLEAN_TARGETS += .lib-dir-stamp .tests-stamp $(LIB) $(addprefix lib/,$(CMDS)) \
 	lib/clvmd lib/dmeventd lib/dmsetup lib/lvmetad lib/fsadm lib/vgimportclone
 
Makefile.in +1 -1
@@ -79,7 +79,7 @@
 endif
 DISTCLEAN_TARGETS += cscope.out
 
-check check_cluster check_local: all
+check check_cluster check_local unit: all
 	$(MAKE) -C test $(@)
 
 install_system_dirs:
configure.in +1 -0
@@ -1450,6 +1450,7 @@
 scripts/Makefile
 test/Makefile
 test/api/Makefile
+test/unit/Makefile
 tools/Makefile
 udev/Makefile
 unit-tests/datastruct/Makefile

/cvs/lvm2/LVM2/test/unit/Makefile.in,v --> standard output revision 1.1

- renamed from test/unit/Makefile.in +25 -0
@@ -0,0 +1,25 @@
+# Copyright (C) 2011 Red Hat, Inc. All rights reserved.
+#
+# This file is part of LVM2.
+#
+# This copyrighted material is made available to anyone wishing to use,
+# modify, copy, or redistribute it subject to the terms and conditions
+# of the GNU General Public License v.2.
+#
+# 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+srcdir = @srcdir@
+top_srcdir = @top_srcdir@
+top_builddir = @top_builddir@
+VPATH = @srcdir@
+
+SOURCES = bitset_t.c matcher_t.c run.c
+TARGETS = run
+
+LDFLAGS = -ldevmapper -lcunit
+include $(top_builddir)/make.tmpl
+
+unit: run
+	LD_LIBRARY_PATH=$(top_builddir)/libdm ./run

/cvs/lvm2/LVM2/test/unit/bitset_t.c,v --> standard output revision 1.1

- renamed from test/unit/bitset_t.c +134 -0

134 lines not on this page · raw message

/cvs/lvm2/LVM2/test/unit/matcher_data.h,v --> standard output revision 1.1

- renamed from test/unit/matcher_data.h +1013 -0

1,013 lines not on this page · raw message

/cvs/lvm2/LVM2/test/unit/matcher_t.c,v --> standard output revision 1.1

- renamed from test/unit/matcher_t.c +84 -0

84 lines not on this page · raw message

/cvs/lvm2/LVM2/test/unit/run.c,v --> standard output revision 1.1

- renamed from test/unit/run.c +25 -0
@@ -0,0 +1,25 @@
+#include <CUnit/CUnit.h>
+#include <CUnit/Basic.h>
+
+#define DECL(n) \
+	extern CU_TestInfo n ## _list[]; \
+	int n ## _init(); \
+	int n ## _fini();
+#define USE(n) { (char*) #n, n##_init, n##_fini, n##_list }
+
+DECL(bitset);
+DECL(regex);
+
+CU_SuiteInfo suites[] = {
+	USE(bitset),
+	USE(regex),
+	CU_SUITE_INFO_NULL
+};
+
+int main() {
+	CU_initialize_registry();
+	CU_register_suites(suites);
+	CU_basic_set_mode(CU_BRM_VERBOSE);
+	CU_basic_run_tests();
+	return CU_get_number_of_failures() != 0;
+}