aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog80
-rw-r--r--Makeconfig26
-rw-r--r--dirent/opendir-tst1.c8
-rw-r--r--dlfcn/Makefile1
-rw-r--r--dlfcn/bug-atexit3-lib.cc7
-rw-r--r--elf/Makefile1
-rw-r--r--extra-lib.mk5
-rw-r--r--io/tst-open-tmpfile.c7
-rw-r--r--io/tst-posix_fallocate-common.c26
-rw-r--r--libio/tst-fseek.c8
-rw-r--r--malloc/tst-malloc-backtrace.c14
-rw-r--r--malloc/tst-malloc-fork-deadlock.c32
-rw-r--r--malloc/tst-malloc-thread-exit.c121
-rw-r--r--nptl/tst-cancel7.c44
-rw-r--r--nptl/tst-cleanup0.c3
-rw-r--r--posix/tst-posix_fadvise-common.c21
-rw-r--r--rt/tst-shm.c10
-rw-r--r--stdlib/tst-secure-getenv.c26
-rw-r--r--support/Makefile64
-rw-r--r--support/README29
-rw-r--r--support/README-testing.c19
-rw-r--r--support/check.c53
-rw-r--r--support/check.h49
-rw-r--r--support/delayed_exit.c57
-rw-r--r--support/ignore_stderr.c38
-rw-r--r--support/oom_error.c29
-rw-r--r--support/set_fortify_handler.c34
-rw-r--r--support/support.h58
-rw-r--r--support/support_test_main.c406
-rw-r--r--support/temp_file-internal.h31
-rw-r--r--support/temp_file.c125
-rw-r--r--support/temp_file.h37
-rw-r--r--support/test-driver.c158
-rw-r--r--support/test-driver.h68
-rw-r--r--support/write_message.c29
-rw-r--r--support/xasprintf.c38
-rw-r--r--support/xcalloc.c34
-rw-r--r--support/xmalloc.c34
-rw-r--r--support/xpthread_barrier_destroy.c26
-rw-r--r--support/xpthread_barrier_init.c27
-rw-r--r--support/xpthread_barrier_wait.c28
-rw-r--r--support/xpthread_cancel.c25
-rw-r--r--support/xpthread_check_return.c34
-rw-r--r--support/xpthread_cond_wait.c26
-rw-r--r--support/xpthread_create.c29
-rw-r--r--support/xpthread_detach.c25
-rw-r--r--support/xpthread_join.c27
-rw-r--r--support/xpthread_mutex_lock.c25
-rw-r--r--support/xpthread_mutex_unlock.c25
-rw-r--r--support/xpthread_sigmask.c34
-rw-r--r--support/xpthread_spin_lock.c25
-rw-r--r--support/xpthread_spin_unlock.c25
-rw-r--r--support/xrealloc.c32
-rw-r--r--support/xsignal.h34
-rw-r--r--support/xthread.h61
-rw-r--r--sysdeps/unix/sysv/linux/tst-fallocate-common.c27
-rw-r--r--sysdeps/unix/sysv/linux/tst-sync_file_range.c20
-rw-r--r--test-skeleton.c751
-rw-r--r--time/bug-getdate1.c24
59 files changed, 2198 insertions, 962 deletions
diff --git a/ChangeLog b/ChangeLog
index e19db5d054..fa3c109180 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,83 @@
+2016-12-09 Florian Weimer <fweimer@redhat.com>
+
+ New subdirectory support for build and test infrastructure.
+ * extra-libs.mk (extra-libs-noinstall): Add variable. Use it when
+ setting install-lib.
+ * Makeconfig (link-extra-libs-tests): Define.
+ (+link-pie-tests, +link-static-tests, +link-tests): Use
+ link-extra-libs-tests.
+ (rpath-dirs, all-subdirs): Add support.
+ (built-modules): Add libsupport.
+ (libsupport): Define.
+ * support: New directory.
+ * support/Makefile: New file.
+ * support/check.c: Likewise.
+ * support/check.h: Likewise.
+ * support/delayed_exit.c: Likewise.
+ * support/ignore_stderr.c: Likewise.
+ * support/oom_error.c: Likewise.
+ * support/set_fortify_handler.c: Likewise.
+ * support/support.h: Likewise.
+ * support/temp_file-internal.h: Likewise.
+ * support/temp_file.c: Likewise.
+ * support/test-driver.c: Likewise.
+ * support/test-driver.h: Likewise.
+ * support/test_main.c: Likewise.
+ * support/write_message.c: Likewise.
+ * support/xasprintf.c: Likewise.
+ * support/xcalloc.c: Likewise.
+ * support/xmalloc.c: Likewise.
+ * support/xpthread_barrier_destroy.c: Likewise.
+ * support/xpthread_barrier_init.c: Likewise.
+ * support/xpthread_barrier_wait.c: Likewise.
+ * support/xpthread_cancel.c: Likewise.
+ * support/xpthread_check_return.c: Likewise.
+ * support/xpthread_cond_wait.c: Likewise.
+ * support/xpthread_create.c: Likewise.
+ * support/xpthread_detach.c: Likewise.
+ * support/xpthread_join.c: Likewise.
+ * support/xpthread_mutex_lock.c: Likewise.
+ * support/xpthread_mutex_unlock.c: Likewise.
+ * support/xpthread_sigmask.c: Likewise.
+ * support/xpthread_spin_lock.c: Likewise.
+ * support/xpthread_spin_unlock.c: Likewise.
+ * support/xrealloc.c: Likweise.
+ * support/xsignal.h: Likewise.
+ * support/xthread.h: Likewise.
+ * support_tempfile.h: Likewise.
+ * test-skeleton.c: Include <support/support.h>, <support/xsignal.h>.
+ (TEST_DATA_LIMIT): Remove unused macro.
+ (_FAIL, FAIL_RET, FAIL_EXIT, FAIL_EXIT1): Remove. Now in
+ <support/check.h>.
+ (oom_error, xmalloc, xcalloc, xrealloc, xasprintf, write_message)
+ (ignore_stderr, set_fortify_handler): Remove. Now in
+ <support/support.h>.
+ (xpthread_sigmask): Remove. Now in <support/xsignal.h>.
+ (xpthread_mutex_lock, xpthread_spin_lock, xpthread_cond_wait)
+ (xpthread_barrier_wait, xpthread_create, xpthread_detach)
+ (xpthread_join): Remove. Now in <support/xthread.h>.
+ (TEST_FUNCTION, PREPARE, CLEANUP_HANDLER, CMDLINE_PROCESS):
+ Introduce legacy wrappers.
+ * dlfcn/Makefile (bug-atexit3-lib.so): Link with $(libsupport).
+ * dlfcn/bug-atexit3-lib.cc: Include <support/support.h>.
+ (write_message): Remove.
+ * dirent/opendir-tst1.c: Use <support/test-driver.h> instead of
+ test-skeleton.c.
+ * io/test-open-tmpfile: Likewise.
+ * io/tst-posix_fallocate-common.c: Likewise.
+ * libio/tst-fseek.c: Likewise.
+ * malloc/tst-malloc-backtrace.c: Likewise.
+ * malloc/tst-malloc-fork-deadlock.c: Likewise.
+ * malloc/tst-malloc-thread-exit.c: Likewise.
+ * nptl/tst-cancel7.c: Likewise.
+ * nptl/tst-cleanup0.c: Likewise.
+ * posix/tst-posix_fadvise-common.c: Likewise.
+ * rt/tst-shm.c: Likewise.
+ * time/bug-getdate1.c: Likewise.
+ * sysdeps/unix/sysv/linux/tst-fallocate-common.c: Likewise.
+ * sysdeps/unix/sysv/linux/tst-sync_file_range.c: Likewise.
+ * elf/Makefile (tst-piemod1.so): Link against libsupport.
+
2016-12-08 Joseph Myers <joseph@codesourcery.com>
* Rules [$(run-built-tests) != no] (tests-expected): Add
diff --git a/Makeconfig b/Makeconfig
index e9d8da9d60..be45c3a0b9 100644
--- a/Makeconfig
+++ b/Makeconfig
@@ -394,6 +394,9 @@ ifndef after-link
after-link =
endif
+# Additional libraries to link into every test.
+link-extra-libs-tests = $(libsupport)
+
# Command for linking PIE programs with the C library.
ifndef +link-pie
+link-pie-before-libc = $(CC) -pie -Wl,-O1 -nostdlib -nostartfiles -o $@ \
@@ -412,8 +415,8 @@ $(+link-pie-before-libc) $(rtld-LDFLAGS) $(link-libc) $(+link-pie-after-libc)
$(call after-link,$@)
endef
define +link-pie-tests
-$(+link-pie-before-libc) $(rtld-tests-LDFLAGS) $(link-libc-tests) \
- $(+link-pie-after-libc)
+$(+link-pie-before-libc) $(link-extra-libs-tests) \
+ $(rtld-tests-LDFLAGS) $(link-libc-tests) $(+link-pie-after-libc)
$(call after-link,$@)
endef
define +link-pie-printers-tests
@@ -439,7 +442,8 @@ $(+link-static-before-libc) $(link-libc-static) $(+link-static-after-libc)
$(call after-link,$@)
endef
define +link-static-tests
-$(+link-static-before-libc) $(link-libc-static-tests) $(+link-static-after-libc)
+$(+link-static-before-libc) $(link-extra-libs-tests) \
+ $(link-libc-static-tests) $(+link-static-after-libc)
$(call after-link,$@)
endef
endif
@@ -468,8 +472,8 @@ $(+link-before-libc) $(rtld-LDFLAGS) $(link-libc) $(+link-after-libc)
$(call after-link,$@)
endef
define +link-tests
-$(+link-before-libc) $(rtld-tests-LDFLAGS) $(link-libc-tests) \
- $(+link-after-libc)
+$(+link-before-libc) $(link-extra-libs-tests) \
+ $(rtld-tests-LDFLAGS) $(link-libc-tests) $(+link-after-libc)
$(call after-link,$@)
endef
define +link-printers-tests
@@ -545,7 +549,7 @@ link-libc-printers-tests = $(link-libc-rpath) \
$(link-libc-tests-after-rpath-link)
# This is how to find at build-time things that will be installed there.
-rpath-dirs = math elf dlfcn nss nis rt resolv crypt mathvec
+rpath-dirs = math elf dlfcn nss nis rt resolv crypt mathvec support
rpath-link = \
$(common-objdir):$(subst $(empty) ,:,$(patsubst ../$(subdir),.,$(rpath-dirs:%=$(common-objpfx)%)))
else # build-static
@@ -892,7 +896,7 @@ libio-include = -I$(..)libio
# List of non-library modules that we build.
built-modules = iconvprogs iconvdata ldconfig lddlibc4 libmemusage \
libSegFault libpcprofile librpcsvc locale-programs \
- memusagestat nonlib nscd extramodules libnldbl
+ memusagestat nonlib nscd extramodules libnldbl libsupport
in-module = $(subst -,_,$(firstword $(libof-$(basename $(@F))) \
$(libof-$(<F)) \
@@ -1133,6 +1137,12 @@ libm = $(common-objpfx)math/libm.a
libmvec = $(common-objpfx)mathvec/libmvec.a
endif
+ifeq ($(build-shared),yes)
+libsupport = $(common-objpfx)support/libsupport_nonshared.a
+else
+libsupport = $(common-objpfx)support/libsupport.a
+endif
+
# These are the subdirectories containing the library source. The order
# is more or less arbitrary. The sorting step will take care of the
# dependencies.
@@ -1140,7 +1150,7 @@ all-subdirs = csu assert ctype locale intl catgets math setjmp signal \
stdlib stdio-common libio malloc string wcsmbs time dirent \
grp pwd posix io termios resource misc socket sysvipc gmon \
gnulib iconv iconvdata wctype manual shadow gshadow po argp \
- crypt localedata timezone rt conform debug mathvec \
+ crypt localedata timezone rt conform debug mathvec support \
$(add-on-subdirs) dlfcn elf
ifndef avoid-generated
diff --git a/dirent/opendir-tst1.c b/dirent/opendir-tst1.c
index e96a817398..bb23234623 100644
--- a/dirent/opendir-tst1.c
+++ b/dirent/opendir-tst1.c
@@ -58,7 +58,7 @@ real_test (void)
static int
-do_test (int argc, char *argv[])
+do_test (void)
{
int retval;
@@ -89,8 +89,6 @@ do_cleanup (void)
{
remove (tmpname);
}
-#define CLEANUP_HANDLER do_cleanup ()
+#define CLEANUP_HANDLER do_cleanup
-
-/* Include the test skeleton. */
-#include <test-skeleton.c>
+#include <support/test-driver.c>
diff --git a/dlfcn/Makefile b/dlfcn/Makefile
index deab96e6a7..713e555b82 100644
--- a/dlfcn/Makefile
+++ b/dlfcn/Makefile
@@ -139,6 +139,7 @@ $(objpfx)bug-atexit2.out: $(objpfx)bug-atexit2-lib.so
ifneq (,$(CXX))
LDLIBS-bug-atexit3-lib.so = -lstdc++ -lgcc_eh
+$(objpfx)bug-atexit3-lib.so: $(libsupport)
$(objpfx)bug-atexit3: $(libdl)
$(objpfx)bug-atexit3.out: $(objpfx)bug-atexit3-lib.so
endif
diff --git a/dlfcn/bug-atexit3-lib.cc b/dlfcn/bug-atexit3-lib.cc
index aba772004d..ed3334709a 100644
--- a/dlfcn/bug-atexit3-lib.cc
+++ b/dlfcn/bug-atexit3-lib.cc
@@ -1,12 +1,7 @@
#include <unistd.h>
#include <string.h>
-static void
-write_message (const char *message)
-{
- ssize_t unused __attribute__ ((unused));
- unused = write (STDOUT_FILENO, message, strlen (message));
-}
+#include <support/support.h>
struct statclass
{
diff --git a/elf/Makefile b/elf/Makefile
index f57927f403..330397e5d8 100644
--- a/elf/Makefile
+++ b/elf/Makefile
@@ -981,6 +981,7 @@ $(objpfx)tst-array5-static-cmp.out: tst-array5-static.exp \
CFLAGS-tst-pie1.c += $(pie-ccflag)
CFLAGS-tst-pie2.c += $(pie-ccflag)
+$(objpfx)tst-piemod1.so: $(libsupport)
$(objpfx)tst-pie1: $(objpfx)tst-piemod1.so
ifeq (yes,$(build-shared))
diff --git a/extra-lib.mk b/extra-lib.mk
index b10748d185..2552049135 100644
--- a/extra-lib.mk
+++ b/extra-lib.mk
@@ -5,6 +5,9 @@
# The variable $($(lib)-routines) defines the list of modules
# to be included in that library. A sysdep Makefile can add to
# $(lib)-sysdep_routines to include additional modules.
+#
+# Libraries listed in $(extra-libs-noinstall) are built, but not
+# installed.
lib := $(firstword $(extra-libs-left))
extra-libs-left := $(filter-out $(lib),$(extra-libs-left))
@@ -28,7 +31,9 @@ extra-objs := $(extra-objs)
all-$(lib)-routines := $($(lib)-routines) $($(lib)-sysdep_routines)
# Add each flavor of library to the lists of things to build and install.
+ifeq (,$(filter $(lib), $(extra-libs-noinstall)))
install-lib += $(foreach o,$(object-suffixes-$(lib)),$(lib:lib%=$(libtype$o)))
+endif
extra-objs += $(foreach o,$(filter-out .os .oS,$(object-suffixes-$(lib))),\
$(patsubst %,%$o,$(filter-out \
$($(lib)-shared-only-routines),\
diff --git a/io/tst-open-tmpfile.c b/io/tst-open-tmpfile.c
index 9242d62392..23fa819c3c 100644
--- a/io/tst-open-tmpfile.c
+++ b/io/tst-open-tmpfile.c
@@ -28,10 +28,7 @@
#include <sys/stat.h>
#include <unistd.h>
-static int do_test (void);
-
-#define TEST_FUNCTION do_test ()
-#include "../test-skeleton.c"
+#include <support/support.h>