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.
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.
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).
__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.
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.
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.
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.
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.
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.
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.
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'.
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.
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>
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.
* 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.
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-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.
* 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).
* 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.
2001-07-06 Paul Eggert <eggert@twinsun.com>
* manual/argp.texi: Remove ignored LGPL copyright notice; it's
not appropriate for documentation anyway.
* manual/libc-texinfo.sh: "Library General Public License" ->
"Lesser General Public License".
2001-07-06 Andreas Jaeger <aj@suse.de>
* All files under GPL/LGPL version 2: Place under LGPL version
2.1.
* test-skeleton.c: Mark local functions as static to avoid warnings.
2000-11-23 H.J. Lu <hjl@gnu.org>
* rt/tst-aio6.c (do_test): Use pipe instead of STDIN_FILENO to
support the background job.
Fix a typo.
2000-11-24 Ulrich Drepper <drepper@redhat.com>
has same names but lower cost.
2000-04-11 Ulrich Drepper <drepper@redhat.com>
* posix/globtest.sh: Fix last change.
2000-04-10 Philip Blundell <philb@gnu.org>
* sysdeps/unix/sysv/linux/bits/in.h (IPV6_JOIN_GROUP,
IPV6_LEAVE_GROUP): New names for IPV6_ADD_MEMBERSHIP,
IPV6_DROP_MEMBERSHIP.
* sysdeps/generic/bits/in.h (IPV6_JOIN_GROUP, IPV6_LEAVE_GROUP):
Likewise.
2000-04-11 Ulrich Drepper <drepper@redhat.com>
* elf/readlib (process_file): Close streams in case of an error.
2000-04-09 Andreas Jaeger <aj@suse.de>
* elf/readlib.c (process_file): Check if file is big enough to
contain aout and ELF headers.
Reported by Reinhard Moosauer <RMoosauer@steinecker.com>.
2000-04-10 Jes Sorensen <Jes.Sorensen@cern.ch>
* elf/dl-fini.c: Include alloca.h to get proper prototype for alloca().
2000-04-11 Ulrich Drepper <drepper@redhat.com>
* test-skeleton.c (main): If STDOUT_UNBUFFERED is defined, make stdout
stream unbuffered.
* rt/Makefile (tests): Add tst-clock.
Add rules to build tst-clock.
* rt/tst-clock.c: New file.
* sysdeps/unix/i386/i586/clock_getres.c: Correct expression to decide
about initialization of nsec.
* sysdeps/unix/i386/i586/clock_gettime.c: Correct expression to decide
about initialization of freq. Set retval to zero if successful.
* sysdeps/unix/sysv/linux/i386/get_clockfreq.c: Cache result.