]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
testsuite: beef up module-playground in the build system
authorLucas De Marchi <lucas.demarchi@intel.com>
Tue, 3 Feb 2015 00:26:06 +0000 (22:26 -0200)
committerLucas De Marchi <lucas.demarchi@intel.com>
Tue, 3 Feb 2015 03:09:17 +0000 (01:09 -0200)
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.

Makefile.am
testsuite/module-playground/Makefile
testsuite/module-playground/mod-simple.c [new file with mode: 0644]
testsuite/module-playground/moduleA.c [deleted file]
testsuite/module-playground/moduleB.c [deleted file]
testsuite/module-playground/moduleC.c [deleted file]
testsuite/module-playground/printmodule.h [deleted file]
testsuite/populate-modules.sh [new file with mode: 0755]
testsuite/rootfs-pristine/test-depmod/search-order-simple/lib/modules/4.4.4/correct-modules.dep
testsuite/rootfs-pristine/test-depmod/search-order-simple/lib/modules/4.4.4/kernel/crypto/md5.ko [deleted file]
testsuite/rootfs-pristine/test-depmod/search-order-simple/lib/modules/4.4.4/updates/md5.ko [deleted file]

index 1f35939c593582fbcec7f28f670c711ad2bfbf0c..97a963104ae3381b42e307e5febe12e940e311f5 100644 (file)
@@ -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
index f606823c5d73b72869c5ecdbbe669618d21fd048..b8b465a62795cf0d019a550d9deab2936204b361 100644 (file)
@@ -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 (file)
index 0000000..cb38580
--- /dev/null
@@ -0,0 +1,16 @@
+#include <linux/init.h>
+#include <linux/module.h>
+
+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 <lucas.demarchi@intel.com>");
+MODULE_LICENSE("LGPL");
diff --git a/testsuite/module-playground/moduleA.c b/testsuite/module-playground/moduleA.c
deleted file mode 100644 (file)
index f1041ac..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
-
-#include <linux/init.h>
-#include <linux/module.h>
-#include <linux/printk.h>
-
-#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 <lucas.demarchi@intel.com>");
-MODULE_LICENSE("GPL");
diff --git a/testsuite/module-playground/moduleB.c b/testsuite/module-playground/moduleB.c
deleted file mode 100644 (file)
index ae13f53..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
-
-#include <linux/init.h>
-#include <linux/module.h>
-#include <linux/printk.h>
-
-#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 <lucas.demarchi@intel.com>");
-MODULE_LICENSE("GPL");
diff --git a/testsuite/module-playground/moduleC.c b/testsuite/module-playground/moduleC.c
deleted file mode 100644 (file)
index b74cb07..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
-
-#include <linux/init.h>
-#include <linux/module.h>
-#include <linux/printk.h>
-
-#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 <lucas.demarchi@intel.com>");
-MODULE_LICENSE("GPL");
diff --git a/testsuite/module-playground/printmodule.h b/testsuite/module-playground/printmodule.h
deleted file mode 100644 (file)
index 8505377..0000000
+++ /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 (executable)
index 0000000..48b6a6f
--- /dev/null
@@ -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/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 (file)
index b568f47..0000000
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 (file)
index b568f47..0000000
Binary files a/testsuite/rootfs-pristine/test-depmod/search-order-simple/lib/modules/4.4.4/updates/md5.ko and /dev/null differ