aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLucas De Marchi <lucas.de.marchi@gmail.com>2012-05-24 01:31:36 -0300
committerLucas De Marchi <lucas.de.marchi@gmail.com>2012-06-05 00:54:47 -0300
commit0de690c96c15bdbe2ea04e81092b14dc8b3cfd86 (patch)
tree78060d27fa401ad4bee2018cfad1fc16a7899f3d
parentada9719942856f7ddce83034db219d765094b41c (diff)
downloadkmod-0de690c96c15bdbe2ea04e81092b14dc8b3cfd86.tar.gz
testsuite: check if rootfs dir is dirty before running
Keep around a stamp-rootfs file that is generated together with the rootfs. testsuite checks each test directory if its mtime is greater than stamp's mtime, deciding if rootfs should be re-generated.
-rw-r--r--Makefile.am17
-rw-r--r--testsuite/.gitignore1
-rw-r--r--testsuite/testsuite.c24
3 files changed, 38 insertions, 4 deletions
diff --git a/Makefile.am b/Makefile.am
index 4dba42b..223e319 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -128,9 +128,16 @@ endif
# ------------------------------------------------------------------------------
ROOTFS = testsuite/rootfs
+ROOTFS_PRISTINE = $(top_srcdir)/testsuite/rootfs-pristine
+CREATE_ROOTFS = $(AM_V_GEN) ( $(RM) -rf $(ROOTFS) && \
+ cp -r $(ROOTFS_PRISTINE) $(ROOTFS) && \
+ touch testsuite/stamp-rootfs )
-$(ROOTFS): $(top_srcdir)/testsuite/rootfs-pristine
- $(AM_V_GEN) cp -r $< $@
+rootfs:
+ $(CREATE_ROOTFS)
+
+$(ROOTFS): $(ROOTFS_PRISTINE)
+ $(CREATE_ROOTFS)
TESTSUITE_OVERRIDE_LIBS = testsuite/uname.la testsuite/path.la \
testsuite/init_module.la \
@@ -152,7 +159,8 @@ testsuite_init_module_la_LIBADD = libkmod/libkmod-private.la
TESTSUITE_CPPFLAGS = $(AM_CPPFLAGS) \
-DTESTSUITE_ROOTFS=\"$(abs_top_builddir)/$(ROOTFS)/\" \
-DABS_TOP_BUILDDIR=\"$(abs_top_builddir)\"
-TESTSUITE_LDADD = testsuite/libtestsuite.la libkmod/libkmod-private.la
+TESTSUITE_LDADD = testsuite/libtestsuite.la libkmod/libkmod-private.la \
+ libkmod/libkmod-util.la
check_LTLIBRARIES += testsuite/libtestsuite.la
testsuite_libtestsuite_la_SOURCES = testsuite/testsuite.c \
@@ -167,7 +175,7 @@ TESTSUITE = testsuite/test-init testsuite/test-testsuite testsuite/test-loaded \
check_PROGRAMS = $(TESTSUITE)
TESTS = $(TESTSUITE)
-testsuite_test_testsuite_LDADD = testsuite/libtestsuite.la
+testsuite_test_testsuite_LDADD = testsuite/libtestsuite.la libkmod/libkmod-util.la
testsuite_test_testsuite_CPPFLAGS = $(TESTSUITE_CPPFLAGS)
testsuite_test_init_LDADD = $(TESTSUITE_LDADD)
testsuite_test_init_CPPFLAGS = $(TESTSUITE_CPPFLAGS)
@@ -189,6 +197,7 @@ testsuite_test_dependencies_CPPFLAGS = $(TESTSUITE_CPPFLAGS)
testsuite-distclean:
-find $(ROOTFS) -type d -exec chmod +w {} \;
-$(RM) -rf $(ROOTFS)
+ -$(RM) testsuite/stamp-rootfs
DISTCLEAN_LOCAL_HOOKS += testsuite-distclean
EXTRA_DIST += testsuite/rootfs-pristine
diff --git a/testsuite/.gitignore b/testsuite/.gitignore
index 8e6a6ac..61c79e1 100644
--- a/testsuite/.gitignore
+++ b/testsuite/.gitignore
@@ -12,3 +12,4 @@
/test-testsuite
/test-modprobe
/rootfs
+/stamp-rootfs
diff --git a/testsuite/testsuite.c b/testsuite/testsuite.c
index 9efe8de..c00746d 100644
--- a/testsuite/testsuite.c
+++ b/testsuite/testsuite.c
@@ -26,8 +26,10 @@
#include <unistd.h>
#include <sys/epoll.h>
#include <sys/prctl.h>
+#include <sys/stat.h>
#include <sys/wait.h>
+#include "libkmod-util.h"
#include "testsuite.h"
static const char *ANSI_HIGHLIGHT_GREEN_ON = "\x1B[1;32m";
@@ -218,6 +220,28 @@ static inline int test_run_child(const struct test *t, int fdout[2],
}
}
+ if (t->config[TC_ROOTFS] != NULL) {
+ const char *stamp = TESTSUITE_ROOTFS "../stamp-rootfs";
+ const char *rootfs = t->config[TC_ROOTFS];
+ struct stat rootfsst, stampst;
+
+ if (stat(stamp, &stampst) != 0) {
+ ERR("could not stat %s\n - %m", stamp);
+ exit(EXIT_FAILURE);
+ }
+
+ if (stat(rootfs, &rootfsst) != 0) {
+ ERR("could not stat %s\n - %m", rootfs);
+ exit(EXIT_FAILURE);
+ }
+
+ if (stat_mstamp(&rootfsst) > stat_mstamp(&stampst)) {
+ ERR("rootfs %s is dirty, please run 'make rootfs' before runnning this test\n",
+ rootfs);
+ exit(EXIT_FAILURE);
+ }
+ }
+
if (t->need_spawn)
return test_spawn_test(t);
else