Commit Graph

63 Commits

Author SHA1 Message Date
Joseph Myers
bfff8b1bec Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
Florian Weimer
c23de0aacb 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.
2016-12-09 08:18:27 +01:00
Zack Weinberg
b964e06640 Minor problems exposed by compiling C++ tests under _ISOMAC.
* libio/libio.h: Use __USE_GNU, not _GNU_SOURCE, in a conditional.
	* test-skeleton.c: Include stdint.h to ensure uintptr_t is available.
2016-11-27 12:36:16 -05:00
Steve Ellcey
5ffc980589 Document do_test in test-skeleton.c
* test-skeleton.c: Document do_test usage.
2016-11-07 08:28:52 -08:00
Adhemerval Zanella
6c63e2d8df Consolidate fallocate{64} implementations
This patch consolidates all the fallocate{64} implementation for Linux
in only one (sysdeps/unix/sysv/linux/fallocate{64}.c).  It also removes the
syscall from the auto-generation using assembly macros.

The new macro SYSCALL_LL{64} is used to handle the offset argument.

Checked on x86_64, x32, i386, aarch64, and ppc64le.

	* sysdeps/unix/sysv/linux/Makefile (test): Add tst-fallocate and
	tst-fallocate64.
	* sysdeps/unix/sysv/linux/tst-fallocate.c: New file.
	* sysdeps/unix/sysv/linux/tst-fallocate64.c: Likewise.
	* sysdeps/unix/sysv/linux/tst-fallocate-common.c: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips64/n32/fallocate.c: Remove file.
	* sysdeps/unix/sysv/linux/mips/mips64/n32/fallocate64.c: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips64/n64/fallocate.c: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips64/n64/fallocate64.c: Likewise.
	* sysdeps/unix/sysv/linux/wordsize-64/fallocate.c: Likewise.
	* sysdeps/unix/sysv/linux/wordsize-64/fallocate64.c: Likewise.
	* sysdeps/unix/sysv/linux/fallocate.c (fallocate): Use SYSCALL_LL
	macro on offset argument.
	* sysdeps/unix/sysv/linux/fallocate64.c (fallocate64): Use
	SYSCALL_LL64 on offset argument.
	* test-skeleton.c (FAIL_RET): Add macro.
	(FAIL_EXIT): Likewise.
	(FAIL_EXIT1): Likewise.
	(_FAIL): Likewise.
2016-10-07 14:16:36 -03:00
Florian Weimer
51364ff23e test-skeleton.c: Remove unintended #include <stdarg.h>. 2016-09-23 09:41:35 +02:00
Florian Weimer
85f7554cd9 Add test case for O_TMPFILE handling in open, openat
Also put xasprintf into test-skeleton.c (written in such a way that
including <stdarg.h> is not needed).
2016-09-21 15:24:01 +02:00
Adhemerval Zanella
21e79af4cf Fix test-skeleton C99 designed initialization
ISO C forbids empty initializer braces (6.7.9 initializer-list must
contain at least one initializer). However GCC allows it, generating
a warning depending of the version.

With GCC 4.8 on ARM I noticed tst-initializers1.c fails to build with:

In file included from tst-initializers1.c:60:0:
../test-skeleton.c: In function 'delayed_exit_thread':
../test-skeleton.c:687:10: error: missing initializer for field 'tv_sec' of 'struct timespec' [-Werror=missing-field-initializers]
   struct timespec remaining = {}

While with GCC 5.1 the same warning is just spilled with -pedantic.
To be safe this patch just zero initialize the struct as expected.

Tested on armhf.

	* test-skeleton.c (delayed_exit_thread): Add initializer on struct
	timespec C99 designated initialization.
2016-08-26 17:33:47 -03:00
Florian Weimer
7e625f7e85 nptl: Avoid expected SIGALRM in most tests [BZ #20432]
Before this change, several tests did not detect early deadlocks
because they used SIGALRM as the expected signal, and they ran
for the full default TIMEOUT seconds.

This commit adds a new delayed_exit function to the test skeleton,
along with several error-checking wrappers to pthread functions.
Additional error checking is introduced into several tests.
2016-08-26 19:40:17 +02:00
Florian Weimer
f690b56979 malloc: Run tests without calling mallopt [BZ #19469]
The compiled tests no longer refer to the mallopt symbol
from their main functions.  (Some tests still call mallopt
explicitly, which is fine.)
2016-08-02 17:06:11 +02:00
Florian Weimer
64ba17317d test-skeleton.c (xrealloc): Support realloc-as-free
If the requested size is zero, realloc returns NULL, but the
deallocation is still successful, unless the pointer is also
NULL, when realloc behaves as malloc (0).
2016-06-23 16:12:48 +02:00
Florian Weimer
9d52cb01f2 test-skeleton.c: xmalloc, xcalloc, xrealloc are potentially unused
__attribute__ ((used)) means that the function has to be
emitted in assembly because it is referenced in ways the
compiler cannot detect (such as asm statements, or some
post-processing on the generated assembly).

The unused attribute needs to come first, otherwise it is
applied to the return type and not the function definition.
2016-06-23 11:01:21 +02:00
Florian Weimer
14699b6e37 test-skeleton.c: Add write_message function 2016-06-23 11:00:36 +02:00
Paul Pluzhnikov
530bb2bf3b 2016-06-09 Paul Pluzhnikov <ppluzhnikov@gmail.com>
* test-skeleton.c (oom_error, xmalloc, xcalloc, xrealloc):
	New functions.
	(add_temp_file): Use them.
2016-06-08 21:36:37 -07:00
Florian Weimer
900056024b test-skeleton.c: Do not set RLIMIT_DATA [BZ #19648]
With older kernels, it is mostly ineffective because it causes malloc
to switch from sbrk to mmap (potentially invalidating malloc testing
compared to what real appliations do).  With newer kernels which
have switched to enforcing RLIMIT_DATA for mmap as well, some test
cases will fail in an unintended fashion because the limit which was
set previously does not include room for all mmap mappings.
2016-03-07 13:48:47 +01:00
Mike Frysinger
a28605b229 test-skeleton: increase default TIMEOUT to 20 seconds
The vast majority of timeouts I've seen w/glibc tests are due to:
 - slow system (e.g. <1 GHz cpu)
 - loaded system (e.g. lots of parallelism)
Even then, I've seen timeouts on system I don't generally consider
slow, or even loaded, and considering TIMEOUT is set to <=10 in ~60
tests (and <=20 in ~75 tests), it seems I'm not alone.  I've just
gotten in the habit of doing `export TIMEOUTFACTOR=10` on all my
setups.

In the edge case where there is a bug in the test and the timeout is
hit, I think we all agree that's either a problem with the test or a
real bug in the library somewhere.  In either case, the incident rate
should be low, so catering to that seems like the wrong trade-off.

Other developers too usually set large timeout factors.  Increase the
default to 20 seconds to match reality.
2016-02-19 13:48:56 -05:00
Joseph Myers
f7a9f785e5 Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
Mike Frysinger
496405af79 test-skeleton: add usage information
I keep trying to run tests with --help and then remembering that does
nothing when it throws an error.  That means I have to dig into the
source when I want to refer to flags or env vars and re-read a good
amount of code to find the nested locations.

Make this all much more user friendly with a usage screen that gets
printed out whenever an unknown option is specified.
2015-08-05 04:40:00 -04:00
Tulio Magno Quites Machado Filho
02242448bf Avoid outputting to TTY after an expected memory corruption in testcase
Protect TTY against an expected memory corruption from testcase
tst-malloc-backtrace, which is expected to SIGABRT after a forced memory
corruption.
2015-06-05 09:39:49 -03:00
Arjun Shankar
330fadfc62 Ensure `wint_t' is defined before use in include/stdio.h
While trying to get nptl/tst-initializers1.c to include the test skeleton, I
came across a couple of speed bumps. Firstly: after making the appropriate
changes to the test, running `make check' led to this error:

> In file included from ../malloc/malloc.h:24:0,
..
>                  from tst-initializers1.c:60:
> ../include/stdio.h:111:1: error: unknown type name `wint_t'
>  extern wint_t __getwc_unlocked (FILE *__fp);

So, `wint_t' is used before being defined. Question: Why did test-skeleton.c
not cause this error in any of the other tests that include it?

Anyway, I noticed include/stdio.h includes stddef.h, which in turn defines
`wint_t', but only if `__need_wint_t' is defined. So I put in a
`#define __need_wint_t' before the include to get rid of the error. Is that
the correct fix?

A subsequent `make && make check' led to this second error:

>                  from tst-initializers1-c89.c:1:
> ../test-skeleton.c: In function `main':
> ../test-skeleton.c:356:11: error: `for' loop initial declarations are only
>  allowed in C99 mode
>            for (struct temp_name_list *n = temp_name_list;

Although there seem to be several other C89 no-noes in test-skeleton.c, I
needed only to fix this specific one for gcc-4.8.3 to stop complaining.
2015-05-18 12:28:06 +05:30
Florian Weimer
cc8dcf96e7 test-skeleton: Support temporary files without memory leaks [BZ#18333]
add_temp_file now makes a copy which is freed by delete_temp_files.
Callers to create_temp_file can now free the returned file name to
avoid the memory leak.  These changes do not affect the leak behavior
of existing code.

Also address a NULL pointer derefence in tzset after a memoru allocation
failure, found during testing.
2015-04-27 16:19:55 +02:00
Roland McGrath
b0b88abc1c Make test-skeleton.c grok TEST_DIRECT magic environment variable. 2015-04-09 11:15:17 -07:00
Joseph Myers
b168057aaa Update copyright dates with scripts/update-copyrights. 2015-01-02 16:29:47 +00:00
Leonhard Holz
fffa1cf8a7 Fix tst-strcoll-overflow returning before timeout (BZ #17506)
Modifies the test examination in test-skeleton.c so that a test can be
successful if it is interrupted or it returns uninterrupted with the
expected status. For this both EXPECTED_SIGNAL and EXPECTED_STATUS
have to be set, as is done in tst-strcoll-overflow.c.
2014-11-12 17:10:21 +05:30
Maciej W. Rozycki
d7a05d0728 test-skeleton: Kill any child process's offspring
This makes sure any subprocesses created by the program being tested get
killed as well if their parent times out.  Otherwise if they are really
stuck, they may remain there running forever after the test case and
then the whole test suite has completed, until killed by hand.

	* test-skeleton.c (signal_handler): Kill the whole process group
	before killing the child individually.
	(main): Report any failure on `setpgid'.
2014-06-30 20:11:56 +01:00
Will Newton
c5c1335513 test-skeleton.c: Use stdout for error messages
At the moment the test skeleton uses a mixture of stdout and
stderr for error message output. Using stdout for all test output
keeps all output correctly ordered and properly redirected to the
output file. The suggestion to use stdout is also made on the wiki:

https://sourceware.org/glibc/wiki/Testing/Testsuite#Writing_a_test_case

ChangeLog:

2014-06-23  Will Newton  <will.newton@linaro.org>

	* test-skeleton.c (signal_handler): Use printf and %m
	rather than perror.  Use printf rather than fprintf to
	stderr.  Use puts rather than fputs to stderr.
	(main): Likewise.
2014-06-23 11:21:31 +01:00
Mike Frysinger
c5bb8e2399 tests: unify fortification handler logic
We have multiple tests that copy & paste the same logic for disabling the
fortification output.  Let's unify this in the test-skeleton instead.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2014-02-08 06:58:43 -05:00
Allan McRae
d4697bc93d Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
Joseph Myers
568035b787 Update copyright notices with scripts/update-copyrights. 2013-01-02 19:05:09 +00:00
Paul Eggert
59ba27a63a Replace FSF snail mail address with URLs. 2012-02-09 23:18:22 +00:00
Ulrich Drepper
85fda49b96 Improve test-skeleton.c to clean up after dead parent. 2009-08-14 00:42:51 -07:00
Ulrich Drepper
331926097f (timeout_handler): Rewrite ts initialization for C++. 2005-12-23 01:03:28 +00:00
Ulrich Drepper
854278dff8 * malloc/arena.c (ptmalloc_init): Recognize MALLOC_PERTURB_ and call
mallopt appropriately.
	* malloc/malloc.h: Define M_PERTURB.
	* malloc/malloc.c (perturb_byte): New variable.
	(alloc_perturb, free_perturb): New macros.
	(_int_malloc): Before returning, overwrite the memory if this is
	requested.
	(_int_free): Overwrite freed memory if requested.
	(mALLOPt): Handle M_PERTURB.
	* test-skeleton.c: Add call to mallopt with M_PERTURB command.
2005-03-08 00:50:21 +00:00
Ulrich Drepper
a334319f65 (CFLAGS-tst-align.c): Add -mpreferred-stack-boundary=4. 2004-12-22 20:10:10 +00:00
Jakub Jelinek
0ecb606cb6 2.5-18.1 2007-07-12 18:26:36 +00:00
Ulrich Drepper
dc39124662 Update.
2004-02-18  Carlos O'Donell  <carlos@baldric.uwo.ca>

	* test-skeleton.c (main): If set, use environment variable
	TIMEOUTFACTOR to scale test TIMEOUT.
2004-02-19 00:55:28 +00:00
Ulrich Drepper
520ec963af Update.
* inet/rcmd.c: Provide better error message in case of unknown
	host.  Remove USE_IN_LIBIO.

	* nscd/nscd.init: Updated version, more conforming with current
	init file standards.

	* nscd/nscd-client.h (_PATH_NSCDPID): Move the file into
	/var/run/nscd directory.
	(_PATH_NSCDSOCKET): Likewise.

	* test-skeleton.c (timeout_handler): Fix error message.
2003-12-31 21:44:08 +00:00
Andreas Jaeger
fa4a36fdff * posix/transbug.c: Include <string.h> for memset and strlen
declarations.
	* stdio-common/tst-sprintf.c: Include <stdlib.h> for free declaration.

	* stdlib/tst-strtod.c (main): Pass long double value.

	* test-skeleton.c: Include <time.h> for nanosleep declaration.
2003-06-25  Andreas Jaeger  <aj@suse.de>

	* posix/transbug.c: Include <string.h> for memset and strlen
	declarations.

	* stdio-common/tst-sprintf.c: Include <stdlib.h> for free declaration.

	* stdlib/tst-strtod.c (main): Pass long double value.

	* test-skeleton.c: Include <time.h> for nanosleep declaration.
2003-06-25 11:04:58 +00:00
Ulrich Drepper
6d0e6e844d Update.
2003-06-19  Jakub Jelinek  <jakub@redhat.com>

	* test-skeleton.c (timeout_handler): If waitpid returned 0,
	retry once after a second.  If killed == 0, assume
	WTERMSIG (status) == SIGKILL.
2003-06-25 07:46:45 +00:00
Ulrich Drepper
ede0f73aea Update.
* test-skeleton.c (main): If EXPECTED_STATUS is defined check that
	returned status from child matches.
2003-06-07 23:24:07 +00:00
Ulrich Drepper
e1d8e1b7c5 Update.
2003-06-07  Ulrich Drepper  <drepper@redhat.com>

	* Makeconfig (gnulib): Add -lgcc_eh once again.
2003-06-07 09:40:26 +00:00
Ulrich Drepper
5385447635 Update.
* test-skeleton.c (main): Use TEMP_FAILURE_RETRY with waitpid.
2003-06-07 00:40:13 +00:00
Ulrich Drepper
6f1acb30c1 Update.
* test-skeleton.c (main): Request getopt to not reorder the
	command line.
2003-06-01 18:07:34 +00:00
Ulrich Drepper
55033a44cb Update.
* test-skeleton.c (main): Make sure correct value is seen as
	argv[0] after adjustment of argv, and argc.
2002-12-19 17:11:28 +00:00
Roland McGrath
63b11dd19b * posix/bug-regex15.c: New file.
* posix/Makefile (tests): Add it.

	* test-skeleton.c (TEST_DATA_LIMIT): New macro, default to 64MB.
	(main): Set RLIMIT_DATA limit to TEST_DATA_LIMIT (or lower if need be).
2002-12-13 21:32:16 +00:00
Ulrich Drepper
4614167ae7 Update.
* test-skeleton.c (timeout_handler): Allow expected signal to be
	SIGALRM.
2002-12-07 05:39:20 +00:00
Roland McGrath
b79e3737ac 2002-09-29 Roland McGrath <roland@redhat.com>
* test-skeleton.c (timeout_handler): Use WUNTRACED flag in waitpid.
	Examine the child's status and print something different if it wasn't
	just killed by our SIGKILL.
	(main): In the child process call setpgid to put it in its own pgrp.
2002-09-30 00:22:13 +00:00
Ulrich Drepper
608c5afdcc Update.
* test-skeleton.c (main): Provide more information in case waitpid
	fails.
2002-09-15 04:25:03 +00:00
Ulrich Drepper
3fc65a7735 (main): Improve error message for unexpected signal case. 2002-09-06 09:15:54 +00:00
Ulrich Drepper
10e6256460 (create_temp_file): New function. 2002-07-22 22:18:27 +00:00