-# Copyright (C) 1991-2017 Free Software Foundation, Inc.
+# Copyright (C) 1991-2019 Free Software Foundation, Inc.
# This file is part of the GNU C Library.
# The GNU C Library is free software; you can redistribute it and/or
lib: $(common-objpfx)libc.so $(common-objpfx)linkobj/libc.so
endif # $(build-shared)
+# Used to build testrun.sh.
+define testrun-script
+#!/bin/bash
+builddir=`dirname "$$0"`
+GCONV_PATH="$${builddir}/iconvdata"
+
+usage () {
+ echo "usage: $$0 [--tool=strace] PROGRAM [ARGUMENTS...]" 2>&1
+ echo " $$0 --tool=valgrind PROGRAM [ARGUMENTS...]" 2>&1
+ exit 1
+}
+
+toolname=default
+while test $$# -gt 0 ; do
+ case "$$1" in
+ --tool=*)
+ toolname="$${1:7}"
+ shift
+ ;;
+ --*)
+ usage
+ ;;
+ *)
+ break
+ ;;
+ esac
+done
+
+if test $$# -eq 0 ; then
+ usage
+fi
+
+case "$$toolname" in
+ default)
+ exec $(subst $(common-objdir),"$${builddir}", $(test-program-prefix)) \
+ $${1+"$$@"}
+ ;;
+ strace)
+ exec strace $(patsubst %, -E%, $(run-program-env)) \
+ $(test-via-rtld-prefix) $${1+"$$@"}
+ ;;
+ valgrind)
+ exec env $(run-program-env) valgrind $(test-via-rtld-prefix) $${1+"$$@"}
+ ;;
+ *)
+ usage
+ ;;
+esac
+endef
# This is a handy script for running any dynamically linked program against
# the current libc build for testing.
$(common-objpfx)testrun.sh: $(common-objpfx)config.make \
$(..)Makeconfig $(..)Makefile
- (echo '#!/bin/sh'; \
- echo 'builddir=`dirname "$$0"`'; \
- echo 'GCONV_PATH="$${builddir}/iconvdata" \'; \
- echo 'exec $(subst $(common-objdir),"$${builddir}",\
- $(test-program-prefix)) $${1+"$$@"}'; \
- ) > $@T
+ $(file >$@T,$(testrun-script))
chmod a+x $@T
mv -f $@T $@
postclean-generated += testrun.sh
ifneq "$(headers)" ""
# Special test of all the installed headers in this directory.
tests-special += $(objpfx)check-installed-headers-c.out
-libof-check-installed-headers-c := nonlib
+libof-check-installed-headers-c := testsuite
$(objpfx)check-installed-headers-c.out: \
scripts/check-installed-headers.sh $(headers)
$(SHELL) $(..)scripts/check-installed-headers.sh c \
ifneq "$(CXX)" ""
tests-special += $(objpfx)check-installed-headers-cxx.out
-libof-check-installed-headers-cxx := nonlib
+libof-check-installed-headers-cxx := testsuite
$(objpfx)check-installed-headers-cxx.out: \
scripts/check-installed-headers.sh $(headers)
$(SHELL) $(..)scripts/check-installed-headers.sh c++ \
"$(CXX) $(filter-out -std=%,$(CXXFLAGS)) -D_ISOMAC $(+includes)" \
$(headers) > $@; \
$(evaluate-test)
-endif
-endif
+endif # $(CXX)
+
+tests-special += $(objpfx)check-wrapper-headers.out
+$(objpfx)check-wrapper-headers.out: scripts/check-wrapper-headers.py $(headers)
+ $(PYTHON) $< --root=. --subdir=. $(headers) \
+ --generated $(common-generated) > $@; $(evaluate-test)
+endif # $(headers)
define summarize-tests
@egrep -v '^(PASS|XFAIL):' $(objpfx)$1 || true
@! egrep -q -v '^(X?PASS|XFAIL|UNSUPPORTED):' $(objpfx)$1
endef
+# The intention here is to do ONE install of our build into the
+# testroot.pristine/ directory, then rsync (internal to
+# support/test-container) that to testroot.root/ at the start of each
+# test. That way we can promise each test a "clean" install, without
+# having to do the install for each test.
+#
+# In addition, we have to copy some files (which we build) into this
+# root in addition to what glibc installs. For example, many tests
+# require additional programs including /bin/sh, /bin/true, and
+# /bin/echo, all of which we build below to limit library dependencies
+# to just those things in glibc and language support libraries which
+# we also copy into the into the rootfs. To determine what language
+# support libraries we need we build a "test" program in either C or
+# (if available) C++ just so we can copy in any shared objects
+# (which we do not build) that GCC-compiled programs depend on.
+
+
+ifeq (,$(CXX))
+LINKS_DSO_PROGRAM = links-dso-program-c
+else
+LINKS_DSO_PROGRAM = links-dso-program
+endif
+
+$(tests-container) $(addsuffix /tests,$(subdirs)) : \
+ $(objpfx)testroot.pristine/install.stamp
+$(objpfx)testroot.pristine/install.stamp :
+ test -d $(objpfx)testroot.pristine || \
+ mkdir $(objpfx)testroot.pristine
+ # We need a working /bin/sh for some of the tests.
+ test -d $(objpfx)testroot.pristine/bin || \
+ mkdir $(objpfx)testroot.pristine/bin
+ cp $(objpfx)support/shell-container $(objpfx)testroot.pristine/bin/sh
+ cp $(objpfx)support/echo-container $(objpfx)testroot.pristine/bin/echo
+ cp $(objpfx)support/true-container $(objpfx)testroot.pristine/bin/true
+ifeq ($(run-built-tests),yes)
+ # Copy these DSOs first so we can overwrite them with our own.
+ for dso in `$(test-wrapper-env) LD_TRACE_LOADED_OBJECTS=1 \
+ $(objpfx)elf/$(rtld-installed-name) \
+ $(objpfx)testroot.pristine/bin/sh \
+ | grep / | sed 's/^[^/]*//' | sed 's/ .*//'` ;\
+ do \
+ test -d `dirname $(objpfx)testroot.pristine$$dso` || \
+ mkdir -p `dirname $(objpfx)testroot.pristine$$dso` ;\
+ $(test-wrapper) cp $$dso $(objpfx)testroot.pristine$$dso ;\
+ done
+ for dso in `$(test-wrapper-env) LD_TRACE_LOADED_OBJECTS=1 \
+ $(objpfx)elf/$(rtld-installed-name) \
+ $(objpfx)support/$(LINKS_DSO_PROGRAM) \
+ | grep / | sed 's/^[^/]*//' | sed 's/ .*//'` ;\
+ do \
+ test -d `dirname $(objpfx)testroot.pristine$$dso` || \
+ mkdir -p `dirname $(objpfx)testroot.pristine$$dso` ;\
+ $(test-wrapper) cp $$dso $(objpfx)testroot.pristine$$dso ;\
+ done
+endif
+ $(MAKE) install DESTDIR=$(objpfx)testroot.pristine
+ touch $(objpfx)testroot.pristine/install.stamp
+
tests-special-notdir = $(patsubst $(objpfx)%, %, $(tests-special))
tests: $(tests-special)
$(..)scripts/merge-test-results.sh -s $(objpfx) "" \
# Regenerate stuff, then error if these things are not committed yet.
dist-prepare: $(files-for-dist)
- conf=`find sysdeps $(addsuffix /sysdeps,$(sysdeps-add-ons)) \
- -name configure`; \
+ conf=`find sysdeps -name configure`; \
$(MAKE) $$conf && \
git diff --stat HEAD -- $^ $$conf \
| $(AWK) '{ print; rc=1 } END { exit rc }'