about summary refs log tree commit diff
path: root/support/support.h
diff options
context:
space:
mode:
authorFlorian Weimer <fweimer@redhat.com>2016-12-09 08:18:27 +0100
committerFlorian Weimer <fweimer@redhat.com>2016-12-09 08:18:27 +0100
commitc23de0aacbeaa7a091609b35764bed931475a16d (patch)
treebe4396f71292ee7a509912d70e74323d1587d227 /support/support.h
parentc03073774f915fe7841c2b551fe304544143470f (diff)
downloadglibc-c23de0aacbeaa7a091609b35764bed931475a16d.tar.gz
glibc-c23de0aacbeaa7a091609b35764bed931475a16d.tar.xz
glibc-c23de0aacbeaa7a091609b35764bed931475a16d.zip
support: Introduce new subdirectory for test infrastructure
The new test driver in <support/test-driver.c> has feature parity with
the old one.  The main difference is that its hooking mechanism is
based on functions and function pointers instead of macros.  This
commit also implements a new environment variable, TEST_COREDUMPS,
which disables the code which disables coredumps (that is, it enables
them if the invocation environment has not disabled them).

<test-skeleton.c> defines wrapper functions so that it is possible to
use existing macros with the new-style hook functionality.

This commit changes only a few test cases to the new test driver, to
make sure that it works as expected.
Diffstat (limited to 'support/support.h')
-rw-r--r--support/support.h58
1 files changed, 58 insertions, 0 deletions
diff --git a/support/support.h b/support/support.h
new file mode 100644
index 0000000000..fc7fba9a3a
--- /dev/null
+++ b/support/support.h
@@ -0,0 +1,58 @@
+/* Common extra functions.
+   Copyright (C) 2016 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
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+/* This header file should only contain definitions compatible with
+   C90.  (Using __attribute__ is fine because <features.h> provides a
+   fallback.)  */
+
+#ifndef SUPPORT_H
+#define SUPPORT_H
+
+#include <stddef.h>
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+
+/* Write a message to standard output.  Can be used in signal
+   handlers.  */
+void write_message (const char *message) __attribute__ ((nonnull (1)));
+
+/* Avoid all the buffer overflow messages on stderr.  */
+void ignore_stderr (void);
+
+/* Set fortification error handler.  Used when tests want to verify that bad
+   code is caught by the library.  */
+void set_fortify_handler (void (*handler) (int sig));
+
+/* Report an out-of-memory error for the allocation of SIZE bytes in
+   FUNCTION, terminating the process.  */
+void oom_error (const char *function, size_t size)
+  __attribute__ ((nonnull (1)));
+
+/* Error-checking wrapper functions which terminate the process on
+   error.  */
+
+void *xmalloc (size_t) __attribute__ ((malloc));
+void *xcalloc (size_t n, size_t s) __attribute__ ((malloc));
+void *xrealloc (void *p, size_t n);
+char *xasprintf (const char *format, ...)
+  __attribute__ ((format (printf, 1, 2), malloc));
+
+__END_DECLS
+
+#endif /* SUPPORT_H */