]> git.ipfire.org Git - thirdparty/kmod.git/blobdiff - Makefile.am
testsuite: port alias-to-none test to module-playground
[thirdparty/kmod.git] / Makefile.am
index 8a69fbcbf26d86d5c77e7ff843896e535e1483d2..a99a5a2360a03f1fba1d7bd1bca8702bb5361c7c 100644 (file)
@@ -16,14 +16,12 @@ export GCC_COLORS
 
 AM_CPPFLAGS = \
        -include $(top_builddir)/config.h \
-       -I$(top_srcdir)/libkmod \
        -I$(top_srcdir) \
        -DSYSCONFDIR=\""$(sysconfdir)"\" \
-       -DLIBEXECDIR=\""$(libexecdir)"\" \
        ${zlib_CFLAGS}
 
-AM_CFLAGS = $(WARNINGFLAGS)
-AM_LDFLAGS = $(GCLDFLAGS)
+AM_CFLAGS = $(OUR_CFLAGS)
+AM_LDFLAGS = $(OUR_LDFLAGS)
 
 SED_PROCESS = \
        $(AM_V_GEN)$(MKDIR_P) $(dir $@) && $(SED) \
@@ -210,16 +208,30 @@ endif
 # TESTSUITE
 # ------------------------------------------------------------------------------
 
+EXTRA_DIST += testsuite/populate-modules.sh
+
+MODULE_PLAYGROUND = testsuite/module-playground
 ROOTFS = testsuite/rootfs
 ROOTFS_PRISTINE = $(top_srcdir)/testsuite/rootfs-pristine
 CREATE_ROOTFS = $(AM_V_GEN) ( $(RM) -rf $(ROOTFS) && mkdir -p $(dir $(ROOTFS)) && \
                                cp -r $(ROOTFS_PRISTINE) $(ROOTFS) && \
-                               touch testsuite/stamp-rootfs && \
-                               find $(ROOTFS) -type d -exec chmod +w {} \; )
-
-rootfs:
+                               find $(ROOTFS) -type d -exec chmod +w {} \; && \
+                               $(top_srcdir)/testsuite/populate-modules.sh \
+                                       $(MODULE_PLAYGROUND) $(ROOTFS) ) && \
+                               touch testsuite/stamp-rootfs
+
+build-module-playground:
+       $(AM_V_GEN)if test "$(top_srcdir)" != "$(top_builddir)"; then \
+               $(RM) -rf testsuite/module-playground && \
+               cp -r $(top_srcdir)/$(MODULE_PLAYGROUND) $(top_builddir)/$(MODULE_PLAYGROUND) && \
+               find $(top_builddir)/$(MODULE_PLAYGROUND) -type d -exec chmod +w {} \; ; \
+               fi
+       $(MAKE) -C $(MODULE_PLAYGROUND)
+
+rootfs: build-module-playground
        $(CREATE_ROOTFS)
-.PHONY: rootfs
+
+.PHONY: rootfs build-playground
 
 $(ROOTFS): $(ROOTFS_PRISTINE)
        $(CREATE_ROOTFS)
@@ -240,9 +252,19 @@ check-sysconfdir:
 check-am: rootfs check-sysconfdir
 
 
+EXTRA_DIST += testsuite/module-playground/Makefile \
+             testsuite/module-playground/mod-foo.c \
+             testsuite/module-playground/mod-foo-a.c \
+             testsuite/module-playground/mod-foo-b.c \
+             testsuite/module-playground/mod-foo-c.c \
+             testsuite/module-playground/mod-simple.c
+
+
 check_LTLIBRARIES = $(TESTSUITE_OVERRIDE_LIBS)
 
 testsuite_uname_la_LDFLAGS = $(TESTSUITE_OVERRIDE_LIBS_LDFLAGS)
+testsuite_path_la_CPPFLAGS = $(AM_CPPFLAGS) \
+       -DABS_TOP_BUILDDIR=\"$(abs_top_builddir)\"
 testsuite_path_la_LDFLAGS = $(TESTSUITE_OVERRIDE_LIBS_LDFLAGS)
 
 testsuite_delete_module_la_LDFLAGS = $(TESTSUITE_OVERRIDE_LIBS_LDFLAGS)
@@ -273,7 +295,8 @@ TESTSUITE = \
        testsuite/test-init testsuite/test-testsuite testsuite/test-loaded \
        testsuite/test-modinfo testsuite/test-util testsuite/test-new-module \
        testsuite/test-modprobe testsuite/test-blacklist \
-       testsuite/test-dependencies testsuite/test-depmod
+       testsuite/test-dependencies testsuite/test-depmod \
+       testsuite/test-list
 
 check_PROGRAMS = $(TESTSUITE)
 TESTS = $(TESTSUITE)
@@ -309,10 +332,16 @@ testsuite_test_dependencies_LDADD = $(TESTSUITE_LDADD)
 testsuite_test_dependencies_CPPFLAGS = $(TESTSUITE_CPPFLAGS)
 testsuite_test_depmod_LDADD = $(TESTSUITE_LDADD)
 testsuite_test_depmod_CPPFLAGS = $(TESTSUITE_CPPFLAGS)
+testsuite_test_list_LDADD = $(TESTSUITE_LDADD)
+testsuite_test_list_CPPFLAGS = $(TESTSUITE_CPPFLAGS)
 
 testsuite-distclean:
        $(RM) -r $(ROOTFS)
        $(RM) testsuite/stamp-rootfs
+       $(MAKE) -C testsuite/module-playground/ clean
+       if test "$(top_srcdir)" != "$(top_builddir)"; then \
+               $(RM) -rf testsuite/module-playground; \
+       fi
 
 DISTCLEAN_LOCAL_HOOKS += testsuite-distclean
 EXTRA_DIST += testsuite/rootfs-pristine
@@ -326,6 +355,45 @@ distclean-local: $(DISTCLEAN_LOCAL_HOOKS)
 buildtest-TESTS:
        $(MAKE) $(AM_MAKEFLAGS) $(check_LTLIBRARIES) $(check_PROGRAMS)
 
+# ------------------------------------------------------------------------------
+# coverage
+# ------------------------------------------------------------------------------
+
+# .PHONY so it always rebuilds it
+.PHONY: coverage lcov-run lcov-report coverage-sync
+
+# run lcov from scratch, always
+coverage: all
+       $(MAKE) lcov-run
+       $(MAKE) lcov-report
+
+coverage_dir = coverage
+coverage_opts = --base-directory $(srcdir) --directory $(builddir) \
+               --rc 'geninfo_adjust_src_path=$(abspath $(srcdir))=>$(abspath $(builddir))'
+
+if ENABLE_COVERAGE
+# reset run coverage tests
+lcov-run:
+       @rm -rf $(coverage_dir)
+       lcov $(coverage_opts) --zerocounters
+       -$(MAKE) check
+
+# generate report based on current coverage data
+lcov-report:
+       $(MKDIR_P) $(coverage_dir)
+       lcov $(coverage_opts) --capture --no-external --ignore-errors graph \
+               | sed 's|$(abspath $(builddir))|$(abspath $(srcdir))|' > $(coverage_dir)/.lcov.info
+       lcov --remove $(coverage_dir)/.lcov.info --output-file $(coverage_dir)/.lcov-clean.info 'test-*'
+       genhtml -t "kmod test coverage" -o $(coverage_dir) $(coverage_dir)/.lcov-clean.info
+       @echo "Coverage report generated in $(abs_builddir)/$(coverage_dir)/index.html"
+
+else
+
+lcov-run lcov-report:
+       echo "Need to reconfigure with --enable-coverage"
+
+endif
+
 # ------------------------------------------------------------------------------
 # custom release helpers
 # ------------------------------------------------------------------------------