testsuite: Move setup-rootfs logic from Makefile to script
PATCH 1/2 testsuite: Move setup-rootfs logic from Makefile to script
It's easier to implement the logic outside of the Makefile, so rename the populate-modules.sh script to setup-rootfs.sh and move the additional logic from the makefile to the script.
---
Makefile.am | 10 ++--------
.../{populate-modules.sh => setup-rootfs.sh} | 19 +++++++++++++++++--
2 files changed, 19 insertions(+), 10 deletions(-)
rename testsuite/{populate-modules.sh => setup-rootfs.sh} (94%)Makefile.am +2 -8
@@ -239,18 +239,12 @@ endif # TESTSUITE # ------------------------------------------------------------------------------ -EXTRA_DIST += testsuite/populate-modules.sh +EXTRA_DIST += testsuite/setup-rootfs.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) && \ - find $(ROOTFS) -type d -exec chmod +w {} \; && \ - find $(ROOTFS) -type f -name .gitignore -exec rm -f {} \; && \ - $(top_srcdir)/testsuite/populate-modules.sh \ - $(MODULE_PLAYGROUND) $(ROOTFS) $(top_builddir)/config.h ) && \ - touch testsuite/stamp-rootfs +CREATE_ROOTFS = $(AM_V_GEN) $(top_srcdir)/testsuite/setup-rootfs.sh $(ROOTFS_PRISTINE) $(ROOTFS) $(MODULE_PLAYGROUND) $(top_builddir)/config.h build-module-playground: $(AM_V_GEN)if test "$(top_srcdir)" != "$(top_builddir)"; then \
testsuite/setup-rootfs.sh renamed from testsuite/populate-modules.sh +17 -2
@@ -2,9 +2,20 @@ set -e -MODULE_PLAYGROUND=$1 +ROOTFS_PRISTINE=$1 ROOTFS=$2 -CONFIG_H=$3 +MODULE_PLAYGROUND=$3 +CONFIG_H=$4 + +# create rootfs from rootfs-pristine + +create_rootfs() { + rm -rf "$ROOTFS" + mkdir -p $(dirname "$ROOTFS") + cp -r "$ROOTFS_PRISTINE" "$ROOTFS" + find "$ROOTFS" -type d -exec chmod +w {} \; + find "$ROOTFS" -type f -name .gitignore -exec rm -f {} \; +} feature_enabled() { local feature=$1
@@ -99,6 +110,8 @@ attach_pkcs7_array=( "test-modinfo/mod-simple-pkcs7.ko" ) +create_rootfs + for k in "${!map[@]}"; do dst=${ROOTFS}/$k src=${MODULE_PLAYGROUND}/${map[$k]}
@@ -143,3 +156,5 @@ done for m in "${attach_pkcs7_array[@]}"; do cat "${MODULE_PLAYGROUND}/dummy.pkcs7" >>"${ROOTFS}/$m" done + +touch testsuite/stamp-rootfs
Signature · 1 line
2.39.1
PATCH 2/2 testsuite: Handle different sysconfdir
Instead of skipping tests if sysconfdir isn't /etc, just handle it during the rootfs setup logic.
--- Makefile.am | 6 +----- configure.ac | 3 --- testsuite/setup-rootfs.sh | 8 ++++++++ testsuite/test-blacklist.c | 3 --- testsuite/test-depmod.c | 15 --------------- testsuite/test-modprobe.c | 6 ------ 6 files changed, 9 insertions(+), 32 deletions(-)
Makefile.am +1 -5
@@ -244,7 +244,7 @@ EXTRA_DIST += testsuite/setup-rootfs.sh MODULE_PLAYGROUND = testsuite/module-playground ROOTFS = testsuite/rootfs ROOTFS_PRISTINE = $(top_srcdir)/testsuite/rootfs-pristine -CREATE_ROOTFS = $(AM_V_GEN) $(top_srcdir)/testsuite/setup-rootfs.sh $(ROOTFS_PRISTINE) $(ROOTFS) $(MODULE_PLAYGROUND) $(top_builddir)/config.h +CREATE_ROOTFS = $(AM_V_GEN) $(top_srcdir)/testsuite/setup-rootfs.sh $(ROOTFS_PRISTINE) $(ROOTFS) $(MODULE_PLAYGROUND) $(top_builddir)/config.h $(sysconfdir) build-module-playground: $(AM_V_GEN)if test "$(top_srcdir)" != "$(top_builddir)"; then \
@@ -330,10 +330,6 @@ TESTSUITE_LDADD = \ testsuite/libtestsuite.la libkmod/libkmod-internal.la \ shared/libshared.la -if KMOD_SYSCONFDIR_NOT_ETC -TESTSUITE_CPPFLAGS += -DKMOD_SYSCONFDIR_NOT_ETC -endif - check_LTLIBRARIES += testsuite/libtestsuite.la testsuite_libtestsuite_la_SOURCES = \ testsuite/testsuite.c testsuite/testsuite.h
configure.ac +0 -3
@@ -225,9 +225,6 @@ GTK_DOC_CHECK([1.14],[--flavour no-tmpl-flat]) ], [ AM_CONDITIONAL([ENABLE_GTK_DOC], false)]) -# Some tests are skipped when sysconfdir != /etc. -AM_CONDITIONAL([KMOD_SYSCONFDIR_NOT_ETC], [test "x$sysconfdir" != "x/etc"]) - ##################################################################### # Default CFLAGS and LDFLAGS #####################################################################
testsuite/setup-rootfs.sh +8 -0
@@ -6,6 +6,7 @@ ROOTFS_PRISTINE=$1 ROOTFS=$2 MODULE_PLAYGROUND=$3 CONFIG_H=$4 +SYSCONFDIR=$5 # create rootfs from rootfs-pristine
@@ -15,6 +16,13 @@ create_rootfs() { cp -r "$ROOTFS_PRISTINE" "$ROOTFS" find "$ROOTFS" -type d -exec chmod +w {} \; find "$ROOTFS" -type f -name .gitignore -exec rm -f {} \; + + if [ "$SYSCONFDIR" != "/etc" ]; then + find "$ROOTFS" -type d -name etc -printf "%h\n" | while read -r e; do + mkdir -p "$(dirname $e/$SYSCONFDIR)" + mv $e/{etc,$SYSCONFDIR} + done + fi } feature_enabled() {
testsuite/test-blacklist.c +0 -3
@@ -95,9 +95,6 @@ fail_lookup: } DEFINE_TEST(blacklist_1, -#if defined(KMOD_SYSCONFDIR_NOT_ETC) - .skip = true, -#endif .description = "check if modules are correctly blacklisted", .config = { [TC_ROOTFS] = TESTSUITE_ROOTFS "test-blacklist/",
testsuite/test-depmod.c +0 -15
@@ -41,9 +41,6 @@ static noreturn int depmod_modules_order_for_compressed(const struct test *t) } DEFINE_TEST(depmod_modules_order_for_compressed, -#if defined(KMOD_SYSCONFDIR_NOT_ETC) - .skip = true, -#endif .description = "check if depmod let aliases in right order when using compressed modules", .config = { [TC_UNAME_R] = MODULES_UNAME,
@@ -74,9 +71,6 @@ static noreturn int depmod_modules_outdir(const struct test *t) } DEFINE_TEST(depmod_modules_outdir, -#if defined(KMOD_SYSCONFDIR_NOT_ETC) - .skip = true, -#endif .description = "check if depmod honours the outdir option", .config = { [TC_UNAME_R] = MODULES_UNAME,
@@ -159,9 +153,6 @@ static noreturn int depmod_detect_loop(const struct test *t)exit (EXIT_FAILURE ); } DEFINE_TEST(depmod_detect_loop, -#if defined(KMOD_SYSCONFDIR_NOT_ETC) - .skip = true, -#endif .description = "check if depmod detects module loops correctly", .config = { [TC_UNAME_R] = MODULES_UNAME,
@@ -186,9 +177,6 @@ static noreturn int depmod_search_order_external_first(const struct test *t)exit (EXIT_FAILURE ); } DEFINE_TEST(depmod_search_order_external_first, -#if defined(KMOD_SYSCONFDIR_NOT_ETC) - .skip = true, -#endif .description = "check if depmod honor external keyword with higher priority", .config = { [TC_UNAME_R] = MODULES_UNAME,
@@ -243,9 +231,6 @@ static noreturn int depmod_search_order_override(const struct test *t)exit (EXIT_FAILURE ); } DEFINE_TEST(depmod_search_order_override, -#if defined(KMOD_SYSCONFDIR_NOT_ETC) - .skip = true, -#endif .description = "check if depmod honor override keyword", .config = { [TC_UNAME_R] = MODULES_UNAME,
testsuite/test-modprobe.c +0 -6
@@ -83,9 +83,6 @@ static noreturn int modprobe_show_alias_to_none(const struct test *t)exit (EXIT_FAILURE ); } DEFINE_TEST(modprobe_show_alias_to_none, -#if defined(KMOD_SYSCONFDIR_NOT_ETC) - .skip = true, -#endif .description = "check if modprobe --show-depends doesn't explode with an alias to nothing", .config = { [TC_UNAME_R] = "4.4.4",
@@ -175,9 +172,6 @@ static noreturn int modprobe_softdep_loop(const struct test *t)exit (EXIT_FAILURE ); } DEFINE_TEST(modprobe_softdep_loop, -#if defined(KMOD_SYSCONFDIR_NOT_ETC) - .skip = true, -#endif .description = "check if modprobe breaks softdep loop", .config = { [TC_UNAME_R] = "4.4.4",
Signature · 1 line
2.39.1
Re: [PATCH 2/2] testsuite: Handle different sysconfdir
Quoted 4 lines · Lucas De Marchi
Instead of skipping tests if sysconfdir isn't /etc, just handle it during the rootfs setup logic.
Nice. I'm far from an expert in the kmod codebase but the series looks good IMHO. For the two:
SIde note: while looking through the Makefile.am I've noticed we're doig manual SED substitution. Didn't look too closely but it should be possible to:
- add respective files to the AC_CONFIG_FILES section (barring .in suffix)
- drop the explicit makefile rules, sed command and extra_dist/cleanfiles
Don't think I'll have the time to submit a patch, I'm literally on the train right now heading out for a while.
HTH
Emil
Lucas De Marchi
AppliedRe: [PATCH 2/2] testsuite: Handle different sysconfdir
Quoted 10 lines · Emil Velikov
Quoted 4 lines · Lucas De Marchi
Instead of skipping tests if sysconfdir isn't /etc, just handle it during the rootfs setup logic.
Nice. I'm far from an expert in the kmod codebase but the series looks good IMHO. For the two:
Reviewed-by Emil Velikov <[email protected]>
Quoted 8 lines
SIde note: while looking through the Makefile.am I've noticed we're doig manual SED substitution. Didn't look too closely but it should be possible to:
- add respective files to theAC_CONFIG_FILESsection (barring .in suffix)
- drop the explicit makefile rules, sed command and extra_dist/cleanfilesDon't think I'll have the time to submit a patch, I'm literally on the train right now heading out for a while.
no rush, we can improve it later.
Applied both patches, thanks.
Lucas De Marchi
Quoted 3 lines
HTH
Emil