From: Lucas De Marchi Date: Tue, 3 Feb 2015 00:26:06 +0000 (-0200) Subject: testsuite: beef up module-playground in the build system X-Git-Tag: v20~58 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4002d77affb2cd16b12a1d2e58ba619a247b840c;p=thirdparty%2Fkmod.git testsuite: beef up module-playground in the build system Instead of shipping pre-compiled module, this prepares the build system to be able to compile the necessary modules from module-playground. This preparations starts by replacing md5.ko with our own dummy mod-simple.ko, built from source. It works by copying the modules to their final location while preparing the rootfs. --- diff --git a/Makefile.am b/Makefile.am index 1f35939c..97a96310 100644 --- a/Makefile.am +++ b/Makefile.am @@ -208,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) ) + +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) @@ -238,6 +252,10 @@ check-sysconfdir: check-am: rootfs check-sysconfdir +EXTRA_DIST += testsuite/module-playground/Makefile \ + testsuite/module-playground/mod-simple.c + + check_LTLIBRARIES = $(TESTSUITE_OVERRIDE_LIBS) testsuite_uname_la_LDFLAGS = $(TESTSUITE_OVERRIDE_LIBS_LDFLAGS) @@ -316,6 +334,10 @@ 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 diff --git a/testsuite/module-playground/Makefile b/testsuite/module-playground/Makefile index f606823c..b8b465a6 100644 --- a/testsuite/module-playground/Makefile +++ b/testsuite/module-playground/Makefile @@ -1,22 +1,14 @@ ifneq ($(KERNELRELEASE),) # kbuild part of makefile -obj-m := moduleA.o moduleB.o moduleC.o +obj-m := mod-simple.o else # normal makefile KDIR ?= /lib/modules/`uname -r`/build KVER ?= `uname -r` -TESTDIR_BASE := /tmp/test-kmod -TESTDIR := $(TESTDIR_BASE)/lib/modules/$(KVER)/ default: $(MAKE) -C $(KDIR) M=$$PWD -install: default - mkdir -p $(TESTDIR)/kernel/ - cp *.ko $(TESTDIR)/kernel/ - cp modules.order $(TESTDIR) - depmod -a -b $(TESTDIR_BASE) $(KVER) - clean: $(MAKE) -C $(KDIR) M=$$PWD clean diff --git a/testsuite/module-playground/mod-simple.c b/testsuite/module-playground/mod-simple.c new file mode 100644 index 00000000..cb385807 --- /dev/null +++ b/testsuite/module-playground/mod-simple.c @@ -0,0 +1,16 @@ +#include +#include + +static int __init test_module_init(void) +{ + return 0; +} + +static void test_module_exit(void) +{ +} +module_init(test_module_init); +module_exit(test_module_exit); + +MODULE_AUTHOR("Lucas De Marchi "); +MODULE_LICENSE("LGPL"); diff --git a/testsuite/module-playground/moduleA.c b/testsuite/module-playground/moduleA.c deleted file mode 100644 index f1041aca..00000000 --- a/testsuite/module-playground/moduleA.c +++ /dev/null @@ -1,24 +0,0 @@ -#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt - -#include -#include -#include - -#include "printmodule.h" - -static int __init test_module_init(void) -{ - printA(); - printB(); - return 0; -} -module_init(test_module_init); - -void printA(void) -{ - pr_warn("Hello, world A\n"); -} -EXPORT_SYMBOL(printA); - -MODULE_AUTHOR("Lucas De Marchi "); -MODULE_LICENSE("GPL"); diff --git a/testsuite/module-playground/moduleB.c b/testsuite/module-playground/moduleB.c deleted file mode 100644 index ae13f535..00000000 --- a/testsuite/module-playground/moduleB.c +++ /dev/null @@ -1,25 +0,0 @@ -#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt - -#include -#include -#include - -#include "printmodule.h" - -static int __init test_module_init(void) -{ - printB(); - printC(); - - return 0; -} -module_init(test_module_init); - -void printB(void) -{ - pr_warn("Hello, world B\n"); -} -EXPORT_SYMBOL(printB); - -MODULE_AUTHOR("Lucas De Marchi "); -MODULE_LICENSE("GPL"); diff --git a/testsuite/module-playground/moduleC.c b/testsuite/module-playground/moduleC.c deleted file mode 100644 index b74cb072..00000000 --- a/testsuite/module-playground/moduleC.c +++ /dev/null @@ -1,24 +0,0 @@ -#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt - -#include -#include -#include - -#include "printmodule.h" - -static int __init test_module_init(void) -{ - printC(); - printB(); - return 0; -} -module_init(test_module_init); - -void printC(void) -{ - pr_warn("Hello, world C\n"); -} -EXPORT_SYMBOL(printC); - -MODULE_AUTHOR("Lucas De Marchi "); -MODULE_LICENSE("GPL"); diff --git a/testsuite/module-playground/printmodule.h b/testsuite/module-playground/printmodule.h deleted file mode 100644 index 85053777..00000000 --- a/testsuite/module-playground/printmodule.h +++ /dev/null @@ -1,5 +0,0 @@ -#pragma once - -void printA(void); -void printB(void); -void printC(void); diff --git a/testsuite/populate-modules.sh b/testsuite/populate-modules.sh new file mode 100755 index 00000000..48b6a6fc --- /dev/null +++ b/testsuite/populate-modules.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +set -e + +MODULE_PLAYGROUND=$1 +ROOTFS=$2 + +declare -A map +map=( + ["test-depmod/search-order-simple/lib/modules/4.4.4/kernel/crypto/"]="mod-simple.ko" + ["test-depmod/search-order-simple/lib/modules/4.4.4/updates/"]="mod-simple.ko" +) + +for k in ${!map[@]}; do + dst=${ROOTFS}/$k + src=${MODULE_PLAYGROUND}/${map[$k]} + + install -d $dst + install -t $dst $src +done diff --git a/testsuite/rootfs-pristine/test-depmod/search-order-simple/lib/modules/4.4.4/correct-modules.dep b/testsuite/rootfs-pristine/test-depmod/search-order-simple/lib/modules/4.4.4/correct-modules.dep index 3386e87d..c5bba99c 100644 --- a/testsuite/rootfs-pristine/test-depmod/search-order-simple/lib/modules/4.4.4/correct-modules.dep +++ b/testsuite/rootfs-pristine/test-depmod/search-order-simple/lib/modules/4.4.4/correct-modules.dep @@ -1 +1 @@ -updates/md5.ko: +updates/mod-simple.ko: diff --git a/testsuite/rootfs-pristine/test-depmod/search-order-simple/lib/modules/4.4.4/kernel/crypto/md5.ko b/testsuite/rootfs-pristine/test-depmod/search-order-simple/lib/modules/4.4.4/kernel/crypto/md5.ko deleted file mode 100644 index b568f479..00000000 Binary files a/testsuite/rootfs-pristine/test-depmod/search-order-simple/lib/modules/4.4.4/kernel/crypto/md5.ko and /dev/null differ diff --git a/testsuite/rootfs-pristine/test-depmod/search-order-simple/lib/modules/4.4.4/updates/md5.ko b/testsuite/rootfs-pristine/test-depmod/search-order-simple/lib/modules/4.4.4/updates/md5.ko deleted file mode 100644 index b568f479..00000000 Binary files a/testsuite/rootfs-pristine/test-depmod/search-order-simple/lib/modules/4.4.4/updates/md5.ko and /dev/null differ