|
|
d8307d |
commit 561b0bec4448f0302cb4915bf67c919bde4a1c57
|
|
|
d8307d |
Author: DJ Delorie <dj@redhat.com>
|
|
|
d8307d |
Date: Fri Jul 6 01:10:41 2018 -0400
|
|
|
d8307d |
|
|
|
d8307d |
Add test-in-container infrastructure.
|
|
|
d8307d |
|
|
|
d8307d |
* Makefile (testroot.pristine): New rules to initialize the
|
|
|
d8307d |
test-in-container "testroot".
|
|
|
d8307d |
* Makerules (all-testsuite): Add tests-container.
|
|
|
d8307d |
* Rules (tests-expected): Add tests-container.
|
|
|
d8307d |
(binaries-all-tests): Likewise.
|
|
|
d8307d |
(tests-container): New, run these tests in the testroot container.
|
|
|
d8307d |
* support/links-dso-program-c.c: New.
|
|
|
d8307d |
* support/links-dso-program.cc: New.
|
|
|
d8307d |
* support/test-container.c: New.
|
|
|
d8307d |
* support/shell-container.c: New.
|
|
|
d8307d |
* support/echo-container.c: New.
|
|
|
d8307d |
* support/true-container.c: New.
|
|
|
d8307d |
* support/xmkdirp.c: New.
|
|
|
d8307d |
* support/xsymlink.c: New.
|
|
|
d8307d |
* support/support_paths.c: New.
|
|
|
d8307d |
* support/support.h: Add support paths prototypes.
|
|
|
d8307d |
* support/xunistd.h: Add xmkdirp () and xsymlink ().
|
|
|
d8307d |
|
|
|
d8307d |
* nss/tst-nss-test3.c: Convert to test-in-container.
|
|
|
d8307d |
* nss/tst-nss-test3.root/: New.
|
|
|
d8307d |
|
|
|
d8307d |
(note: support/ already present, not needed; sample test not included)
|
|
|
d8307d |
|
|
|
d8307d |
diff --git a/Makefile b/Makefile
|
|
|
d8307d |
index d3f25a5..3df55e6 100644
|
|
|
d8307d |
--- a/Makefile
|
|
|
d8307d |
+++ b/Makefile
|
|
|
d8307d |
@@ -340,6 +340,62 @@ define summarize-tests
|
|
|
d8307d |
@! egrep -q -v '^(X?PASS|XFAIL|UNSUPPORTED):' $(objpfx)$1
|
|
|
d8307d |
endef
|
|
|
d8307d |
|
|
|
d8307d |
+# The intention here is to do ONE install of our build into the
|
|
|
d8307d |
+# testroot.pristine/ directory, then rsync (internal to
|
|
|
d8307d |
+# support/test-container) that to testroot.root/ at the start of each
|
|
|
d8307d |
+# test. That way we can promise each test a "clean" install, without
|
|
|
d8307d |
+# having to do the install for each test.
|
|
|
d8307d |
+#
|
|
|
d8307d |
+# In addition, we have to copy some files (which we build) into this
|
|
|
d8307d |
+# root in addition to what glibc installs. For example, many tests
|
|
|
d8307d |
+# require additional programs including /bin/sh, /bin/true, and
|
|
|
d8307d |
+# /bin/echo, all of which we build below to limit library dependencies
|
|
|
d8307d |
+# to just those things in glibc and language support libraries which
|
|
|
d8307d |
+# we also copy into the into the rootfs. To determine what language
|
|
|
d8307d |
+# support libraries we need we build a "test" program in either C or
|
|
|
d8307d |
+# (if available) C++ just so we can copy in any shared objects
|
|
|
d8307d |
+# (which we do not build) that GCC-compiled programs depend on.
|
|
|
d8307d |
+
|
|
|
d8307d |
+
|
|
|
d8307d |
+ifeq (,$(CXX))
|
|
|
d8307d |
+LINKS_DSO_PROGRAM = links-dso-program-c
|
|
|
d8307d |
+else
|
|
|
d8307d |
+LINKS_DSO_PROGRAM = links-dso-program
|
|
|
d8307d |
+endif
|
|
|
d8307d |
+
|
|
|
d8307d |
+$(tests-container) $(addsuffix /tests,$(subdirs)) : \
|
|
|
d8307d |
+ $(objpfx)testroot.pristine/install.stamp
|
|
|
d8307d |
+$(objpfx)testroot.pristine/install.stamp :
|
|
|
d8307d |
+ test -d $(objpfx)testroot.pristine || \
|
|
|
d8307d |
+ mkdir $(objpfx)testroot.pristine
|
|
|
d8307d |
+ # We need a working /bin/sh for some of the tests.
|
|
|
d8307d |
+ test -d $(objpfx)testroot.pristine/bin || \
|
|
|
d8307d |
+ mkdir $(objpfx)testroot.pristine/bin
|
|
|
d8307d |
+ cp $(objpfx)support/shell-container $(objpfx)testroot.pristine/bin/sh
|
|
|
d8307d |
+ cp $(objpfx)support/echo-container $(objpfx)testroot.pristine/bin/echo
|
|
|
d8307d |
+ cp $(objpfx)support/true-container $(objpfx)testroot.pristine/bin/true
|
|
|
d8307d |
+ # Copy these DSOs first so we can overwrite them with our own.
|
|
|
d8307d |
+ for dso in `$(test-wrapper-env) LD_TRACE_LOADED_OBJECTS=1 \
|
|
|
d8307d |
+ $(objpfx)elf/$(rtld-installed-name) \
|
|
|
d8307d |
+ $(objpfx)testroot.pristine/bin/sh \
|
|
|
d8307d |
+ | grep / | sed 's/^[^/]*//' | sed 's/ .*//'` ;\
|
|
|
d8307d |
+ do \
|
|
|
d8307d |
+ test -d `dirname $(objpfx)testroot.pristine$$dso` || \
|
|
|
d8307d |
+ mkdir -p `dirname $(objpfx)testroot.pristine$$dso` ;\
|
|
|
d8307d |
+ $(test-wrapper) cp $$dso $(objpfx)testroot.pristine$$dso ;\
|
|
|
d8307d |
+ done
|
|
|
d8307d |
+ for dso in `$(test-wrapper-env) LD_TRACE_LOADED_OBJECTS=1 \
|
|
|
d8307d |
+ $(objpfx)elf/$(rtld-installed-name) \
|
|
|
d8307d |
+ $(objpfx)support/$(LINKS_DSO_PROGRAM) \
|
|
|
d8307d |
+ | grep / | sed 's/^[^/]*//' | sed 's/ .*//'` ;\
|
|
|
d8307d |
+ do \
|
|
|
d8307d |
+ test -d `dirname $(objpfx)testroot.pristine$$dso` || \
|
|
|
d8307d |
+ mkdir -p `dirname $(objpfx)testroot.pristine$$dso` ;\
|
|
|
d8307d |
+ $(test-wrapper) cp $$dso $(objpfx)testroot.pristine$$dso ;\
|
|
|
d8307d |
+ done
|
|
|
d8307d |
+ $(MAKE) install DESTDIR=$(objpfx)testroot.pristine
|
|
|
d8307d |
+ touch $(objpfx)testroot.pristine/install.stamp
|
|
|
d8307d |
+
|
|
|
d8307d |
tests-special-notdir = $(patsubst $(objpfx)%, %, $(tests-special))
|
|
|
d8307d |
tests: $(tests-special)
|
|
|
d8307d |
$(..)scripts/merge-test-results.sh -s $(objpfx) "" \
|
|
|
d8307d |
diff --git a/Makerules b/Makerules
|
|
|
d8307d |
index a10a0b4..5d6434c 100644
|
|
|
d8307d |
--- a/Makerules
|
|
|
d8307d |
+++ b/Makerules
|
|
|
d8307d |
@@ -1369,7 +1369,8 @@ xcheck: xtests
|
|
|
d8307d |
# The only difference between MODULE_NAME=testsuite and MODULE_NAME=nonlib is
|
|
|
d8307d |
# that almost all internal declarations from config.h, libc-symbols.h, and
|
|
|
d8307d |
# include/*.h are not available to 'testsuite' code, but are to 'nonlib' code.
|
|
|
d8307d |
-all-testsuite := $(strip $(tests) $(xtests) $(test-srcs) $(test-extras))
|
|
|
d8307d |
+all-testsuite := $(strip $(tests) $(xtests) $(test-srcs) $(test-extras) \
|
|
|
d8307d |
+ $(tests-container))
|
|
|
d8307d |
ifneq (,$(all-testsuite))
|
|
|
d8307d |
cpp-srcs-left = $(all-testsuite)
|
|
|
d8307d |
lib := testsuite
|
|
|
d8307d |
diff --git a/Rules b/Rules
|
|
|
d8307d |
index 706c8a7..5abb727 100644
|
|
|
d8307d |
--- a/Rules
|
|
|
d8307d |
+++ b/Rules
|
|
|
d8307d |
@@ -130,12 +130,14 @@ others: $(py-const)
|
|
|
d8307d |
|
|
|
d8307d |
ifeq ($(run-built-tests),no)
|
|
|
d8307d |
tests: $(addprefix $(objpfx),$(filter-out $(tests-unsupported), \
|
|
|
d8307d |
- $(tests) $(tests-internal)) \
|
|
|
d8307d |
+ $(tests) $(tests-internal) \
|
|
|
d8307d |
+ $(tests-container)) \
|
|
|
d8307d |
$(test-srcs)) $(tests-special) \
|
|
|
d8307d |
$(tests-printers-programs)
|
|
|
d8307d |
xtests: tests $(xtests-special)
|
|
|
d8307d |
else
|
|
|
d8307d |
tests: $(tests:%=$(objpfx)%.out) $(tests-internal:%=$(objpfx)%.out) \
|
|
|
d8307d |
+ $(tests-container:%=$(objpfx)%.out) \
|
|
|
d8307d |
$(tests-special) $(tests-printers-out)
|
|
|
d8307d |
xtests: tests $(xtests:%=$(objpfx)%.out) $(xtests-special)
|
|
|
d8307d |
endif
|
|
|
d8307d |
@@ -145,7 +147,8 @@ xtests-special-notdir = $(patsubst $(objpfx)%, %, $(xtests-special))
|
|
|
d8307d |
ifeq ($(run-built-tests),no)
|
|
|
d8307d |
tests-expected =
|
|
|
d8307d |
else
|
|
|
d8307d |
-tests-expected = $(tests) $(tests-internal) $(tests-printers)
|
|
|
d8307d |
+tests-expected = $(tests) $(tests-internal) $(tests-printers) \
|
|
|
d8307d |
+ $(tests-container)
|
|
|
d8307d |
endif
|
|
|
d8307d |
tests:
|
|
|
d8307d |
$(..)scripts/merge-test-results.sh -s $(objpfx) $(subdir) \
|
|
|
d8307d |
@@ -158,7 +161,8 @@ xtests:
|
|
|
d8307d |
|
|
|
d8307d |
ifeq ($(build-programs),yes)
|
|
|
d8307d |
binaries-all-notests = $(others) $(sysdep-others)
|
|
|
d8307d |
-binaries-all-tests = $(tests) $(tests-internal) $(xtests) $(test-srcs)
|
|
|
d8307d |
+binaries-all-tests = $(tests) $(tests-internal) $(xtests) $(test-srcs) \
|
|
|
d8307d |
+ $(tests-container)
|
|
|
d8307d |
binaries-all = $(binaries-all-notests) $(binaries-all-tests)
|
|
|
d8307d |
binaries-static-notests = $(others-static)
|
|
|
d8307d |
binaries-static-tests = $(tests-static) $(xtests-static)
|
|
|
d8307d |
@@ -248,6 +252,17 @@ $(objpfx)%.out: /dev/null $(objpfx)% # Make it 2nd arg for canned sequence.
|
|
|
d8307d |
$(make-test-out) > $@; \
|
|
|
d8307d |
$(evaluate-test)
|
|
|
d8307d |
|
|
|
d8307d |
+
|
|
|
d8307d |
+# Any tests that require an isolated container (filesystem, network
|
|
|
d8307d |
+# and pid namespaces) in which to run, should be added to
|
|
|
d8307d |
+# tests-container.
|
|
|
d8307d |
+$(tests-container:%=$(objpfx)%.out): $(objpfx)%.out : $(if $(wildcard $(objpfx)%.files),$(objpfx)%.files,/dev/null) $(objpfx)%
|
|
|
d8307d |
+ $(test-wrapper-env) $(run-program-env) $(run-via-rtld-prefix) \
|
|
|
d8307d |
+ $(common-objpfx)support/test-container env $(run-program-env) $($*-ENV) \
|
|
|
d8307d |
+ $(host-test-program-cmd) $($*-ARGS) > $@; \
|
|
|
d8307d |
+ $(evaluate-test)
|
|
|
d8307d |
+
|
|
|
d8307d |
+
|
|
|
d8307d |
# tests-unsupported lists tests that we will not try to build at all in
|
|
|
d8307d |
# this configuration. Note this runs every time because it does not
|
|
|
d8307d |
# actually create its target. The dependency on Makefile is meant to
|