Commit Graph

247 Commits

Author SHA1 Message Date
Zack Weinberg 10a33cf8b4 getopt: eliminate __need_getopt by splitting up getopt.h.
__need_getopt is misnamed; what it really means is "we want only the
getopt features specified in POSIX, not the GNU extensions".  Because
this code is shared with gnulib, it winds up being cleanest to split
getopt.h into *four* headers.  getopt_core.h and getopt_ext.h will
be shared with gnulib, getopt_posix.h will be just for glibc, and
each project will have its own copy of getopt.h.

	* posix/bits/getopt_core.h, posix/bits/getopt_ext.h:
	New files, intended to be shared with gnulib.
	* posix/bits/getopt_posix.h:
	New file, not intended to be shared with gnulib.
	* posix/getopt.h: Now just includes features.h,
	bits/getopt_core.h, and bits/getopt_ext.h.  Will
	no longer be shared with gnulib.
	* include/bits/getopt_core.h, include/bits/getopt_ext.h
	* include/bits/getopt_posix.h: New wrappers.
	* posix/Makefile: Install new headers.
	* posix/unistd.h, libio/stdio.h:
	Include bits/getopt_posix.h instead of getopt.h.
2017-04-07 07:53:03 -04:00
Zack Weinberg 544ce845de getopt: clean up error reporting
getopt can print a whole bunch of error messages, and when used
standalone (from gnulib) it uses fprintf to do that.  But fprintf is a
cancellation point and getopt isn't, and also applying fprintf to a
stream in wide-character mode is not allowed.

glibc has an internal function called __fxprintf that writes a narrow
format string to a stream regardless of mode, but it only handles
ASCII format strings, and it's still a cancellation point.  getopt's
messages are translated, so they might not be ASCII.  So getopt has an
error message to an asprintf buffer, monkeys with internal flag bits
on stderr to disable cancellation, and then calls
__fxprintf(stderr, "%s", buffer).  There isn't even a helper function,
the code is duplicated every time.

This patch fixes __fxprintf to handle arbitrary multibyte format
strings, and adds a variant __fxprintf_nocancel that does the same
thing but also isn't a cancellation point.  (It still _works_ by
monkeying with internal flag bits on the FILE, but that's not really a
layering violation for code in stdio-common.)  All of the #ifdef _LIBC
blocks can then be reduced to their standalone versions with a little
help from some macros at the top of the file.

I also wrote a test case to verify that getopt really isn't a
cancellation point, and I'm glad I did, because it found two bugs, one
of which wasn't even to do with cancellation (see previous patch).

	* stdio-common/fxprintf.c (__fxprintf_nocancel): New function.
	(locked_vfxprintf): New helper function. Handle arbitrary
	multibyte strings, not just ASCII.
	* include/stdio.h: Declare __fxprintf_nocancel.

	* posix/getopt.c: When _LIBC is defined, define fprintf to
	__fxprintf_nocancel, flockfile to _IO_flockfile, and
	funlockfile to _IO_funlockfile.  When neither _LIBC nor
	_POSIX_THREAD_SAFE_FUNCTIONS is defined, define flockfile and
	funlockfile as no-ops.  (_getopt_internal_r): Remove all
	internal #ifdef _LIBC blocks; the standalone error-printing
	code can now be used for libc as well.  Add an
	flockfile/funlockfile pair around one case where the error
	message is printed in several chunks.  Don't use fputc.

	* posix/tst-getopt-cancel.c: New test.
	* posix/Makefile: Run it.
2017-04-07 07:48:57 -04:00
Zack Weinberg bf079e19f5 getopt: remove USE_NONOPTION_FLAGS
glibc's implementation of getopt includes code to parse an environment
variable named _XXX_GNU_nonoption_argv_flags_ (where XXX is the
current process's PID in decimal); but all of it has been #ifdefed out
since 2001, with no official way to turn it back on.

According to commentary in our config.h.in, bash version 2.0 set this
environment variable to indicate argv elements that were the result of
glob expansion and therefore should not be treated as options, but the
feature was "disabled later" because "it caused problems".  According
to bash's CHANGES file, "later" was release 2.01; it gives no more
detail about what the problems were.

Version 2.0 of bash was released on the last day of 1996, and version
2.01 in June of 1997.  Twenty years later, I think it is safe to
assume that this environment variable isn't coming back.

	* config.h.in (USE_NONOPTION_FLAGS): Remove.
	* csu/init-first.c: Remove all #ifdef USE_NONOPTION_FLAGS blocks.
	* sysdeps/mach/hurd/i386/init-first.c: Likewise.
	* posix/getopt_int.h: Likewise.
	* posix/getopt.c: Likewise. Also remove SWAP_FLAGS and the
	__libc_argc and __libc_argv externs, which were only used by
	#ifdef USE_NONOPTION_FLAGS blocks.
	* posix/getopt_init.c: Remove file.
	* posix/Makefile (routines): Remove getopt_init.
	* include/getopt.h: Don't declare __getopt_initialize_environment.
	* manual/getopt.texi: Remove mention of USE_NONOPTION_FLAGS in
	a comment.
2017-04-07 07:45:53 -04:00
Yury Norov 9a56f87183 Test for correct setting of errno.
This patch adds tests for POSIX and Linux specific syscalls
that implemented with syscall templates machinery. The reason
of tests is to receive the expected error code and test if
it's handled properly by glibc.

2017-03-08  Yury Norov <ynorov@caviumnetworks.com>
	    Zack Weinberg  <zackw@panix.com>

	* posix/test-errno.c: New file.
	* posix/Makefile (tests): Add test-errno.
	* sysdeps/unix/sysv/linux/test-errno.c: New file.
	* sysdeps/unix/sysv/linux/Makefile (tests): Add test-errno.
2017-03-08 11:19:47 -05:00
Joseph Myers bfff8b1bec Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
Adhemerval Zanella 96b7fe4243 Consolidate posix_fadvise implementations
This patch consolidates mostly of the Linux posix_fadvise{64} implementations
on sysdeps/unix/sysv/linux/posix_fadvise{64}.c.  It still keeps arch-specific
files for:

  * S390-32: it uses a packed structure to pass all the arguments on syscall.
    It is the only supported port that implements __NR_fadvise64_64 in this
    way.

  * ARM: it does not implement __NR_fadvise64 (as other 32-bits ports), so
    posix_fadvise calls internal posix_fadvise64 symbol.

  * MIPS64 n64: it requires a different version number that other ports.

The new macro SYSCALL_LL{64} is used to handle the offset argument and
INTERNAL_SYSCALL_CALL to handle passing the correct number of expect
arguments.

The default Linux adds two new defines a port can use to control how
__NR_fadvise64_64 passes the kernel arguments:

  * __ASSUME_FADVISE64_64_6ARG: the 'advise' argument is moved on second
    position.  This is the case of powerpc32 and arm to avoid implement
    7 argument syscall.

  * __ASSUME_FADVISE64_64_NO_ALIGN: for ABIs that defines
    __ASSUME_ALIGNED_REGISTER_PAIRS packs the offset without the leading
    '0'.  This is the case of tile 32 bits.

ARM also defines __NR_fadvise64_64 as __NR_arm_fadvise64_64 (which is also
handled on arch kernel-feature.h).

Tested on x86_64, x32, i686, armhf, and aarch64.

	* posix/Makefile (tests): Add tst-posix_fadvise and tst-posix_fadvise64.
	* posix/tst-posix_fadvise.c: New file.
	* posix/tst-posix_fadvise64.c: Likewise.
	* posix/tst-posix_fadvise-common.c: Likewise.
	* sysdeps/unix/sysv/linux/arm/kernel-features.h
	(__ASSUME_FADVISE64_64_6ARG): Define.
	* sysdeps/unix/sysv/linux/powerpc/kernel-features.h
	[!__powerpc64__] (__ASSUME_FADVISE64_64_6ARG): Add define.
	* sysdeps/unix/sysv/linux/arm/posix_fadvise64.c: Remove file.
	* sysdeps/unix/sysv/linux/generic/wordsize-32/posix_fadvise.c: Likewise.
	* sysdeps/unix/sysv/linux/i386/posix_fadvise64.S: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips32/posix_fadvise.c: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips32/posix_fadvise64.c: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips64/n32/posix_fadvise.c: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips64/n32/posix_fadvise64.c: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips64/n64/posix_fadvise.c: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/posix_fadvise.c: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/posix_fadvise64.c:
	Likewise.
	* sysdeps/unix/sysv/linux/wordsize-64/posix_fadvise.c: Likewise.
	* sysdeps/unix/sysv/linux/wordsize-64/posix_fadvise64.c: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips64/n64/posix_fadvise64.c
	(SHLIB_COMPAT(libc, GLIBC_2_2, GLIBC_2_3_3) [__posix_fadvise64_l64]:
	Alias to __posix_fadvise64_l32.
	(SHLIB_COMPAT(libc, GLIBC_2_2, GLIBC_2_3_3) [__posix_fadvise64_l32]:
	Add compat definition to posix_fadvise64.
	(SHLIB_COMPAT(libc, GLIBC_2_2, GLIBC_2_3_3) [__posix_fadvise64_l64]:
	Add versioned definition to posix_fadvise64.
	* sysdeps/unix/sysv/linux/posix_fadvise.c (posix_fadvise): Build iff
	__OFF_T_MATCHES_OFF64_T is defined, use INTERNAL_SYSCALL_CALL, add
	__ASSUME_FADVISE64_64_6ARG/__ASSUME_FADVISE64_64_NO_ALIGN support.
	* sysdeps/unix/sysv/linux/posix_fadvise64.c (posix_fadvise64): Add
	__ASSUME_FADVISE64_64_NO_ALIGN support and use INTERNAL_SYSCALL_CALL.
2016-10-07 14:16:41 -03:00
Adhemerval Zanella e83be73091 posix: Fix open file action for posix_spawn on Linux
On posix_spawn open file action (issued by posix_spawn_file_actions_addopen)
POSIX states that if fildes was already an open file descriptor, it shall be
closed before the new file is openedi [1].  This avoid pontential issues when
posix_spawn plus addopen action is called with the process already at maximum
number of file descriptor opened and also for multiple actions on single-open
special paths (like /dev/watchdog).

This fixes its behavior on Linux posix_spawn implementation and also adds
a tests to check for its behavior.

Checked on x86_64.

	* posix/Makefile (tests): Add tst-spawn3.
	* posix/tst-spawn3.c: New file.
	* sysdeps/unix/sysv/linux/spawni.c (__spawni_child): Close file descriptor
	if it is already opened for open action.

[1] http://pubs.opengroup.org/onlinepubs/9699919799/functions/posix_spawn_file_actions_addclose.html
2016-09-28 14:07:35 -07:00
Zack Weinberg 63eb8df85a Minimize sysdeps code involved in defining major/minor/makedev.
Presently sys/sysmacros.h is entirely defined in sysdeps.  This would
mean that the deprecation logic coming up in the next patch would have
to be written twice (in generic/ and unix/sysv/linux/).  To avoid that,
hoist all but the unavoidably system-dependent logic to misc/, leaving a
bits/ header behind.  This also promotes the Linux-specific encoding of
dev_t, which accommodates 32-bit major and minor numbers in a 64-bit dev_t,
to generic, as glibc's dev_t is always 64 bits wide.

The former Linux implementation used inline functions to avoid evaluating
arguments more than once.  After this change, all platforms use inline
functions, which means that three new symbols are added to the generic ABI.
(These symbols are in the user namespace, which is how they have always
been on Linux.  They begin with "gnu_dev_", so collisions with user code
are pretty unlikely.)

New ports henceforth need only provide a bits/sysmacros.h defining
internal macros __SYSMACROS_{DECLARE,DEFINE}_{MAJOR,MINOR,MAKEDEV}.
This is only necessary if the kernel encoding is incompatible with
the now-generic encoding (for instance, it would be necessary for
FreeBSD).

While I was at it, I added a basic round-trip test for these functions.

	* sysdeps/generic/sys/sysmacros.h: Delete file.
	* sysdeps/unix/sysv/linux/makedev.c: Delete file.
	* sysdeps/unix/sysv/linux/sys/sysmacros.h: Move file ...
	* bits/sysmacros.h: ... here; this encoding is now the generic
	encoding.  Now defines only the following macros:
	__SYSMACROS_DECLARE_MAJOR, __SYSMACROS_DEFINE_MAJOR,
	__SYSMACROS_DECLARE_MINOR, __SYSMACROS_DEFINE_MINOR,
	__SYSMACROS_DECLARE_MAKEDEV, __SYSMACROS_DEFINE_MAKEDEV.

	* misc/sys/sysmacros.h, misc/makedev.c: New files that use
	bits/sysmacros.h and the above new macros to generate the
	public implementations of major, minor, and makedev.
	* misc/tst-makedev.c: New test.
	* include/sys/sysmacros.h: New wrapper.

	* misc/Makefile (headers): Add sys/sysmacros.h, bits/sysmacros.h.
	(routines): Add makedev.
	(tests): Add tst-makedev.
	* misc/Versions [GLIBC_2.25]: Add gnu_dev_major, gnu_dev_minor,
	gnu_dev_makedev.
	* posix/Makefile (headers): Remove sys/sysmacros.h.
	* sysdeps/unix/sysv/linux/Makefile (sysdep_routines): Remove makedev.

	* sysdeps/arm/nacl/libc.abilist: Add GLIBC_2.25,
	gnu_dev_major, gnu_dev_makedev, gnu_dev_minor.
	* sysdeps/unix/sysv/linux/aarch64/libc.abilist
	* sysdeps/unix/sysv/linux/alpha/libc.abilist
	* sysdeps/unix/sysv/linux/arm/libc.abilist
	* sysdeps/unix/sysv/linux/hppa/libc.abilist
	* sysdeps/unix/sysv/linux/i386/libc.abilist
	* sysdeps/unix/sysv/linux/ia64/libc.abilist
	* sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist
	* sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist
	* sysdeps/unix/sysv/linux/microblaze/libc.abilist
	* sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist
	* sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist
	* sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist
	* sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist
	* sysdeps/unix/sysv/linux/nios2/libc.abilist
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist
	* sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist
	* sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist
	* sysdeps/unix/sysv/linux/sh/libc.abilist
	* sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist
	* sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist
	* sysdeps/unix/sysv/linux/tile/tilegx/tilegx32/libc.abilist
	* sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/libc.abilist
	* sysdeps/unix/sysv/linux/tile/tilepro/libc.abilist
	* sysdeps/unix/sysv/linux/x86_64/64/libc.abilist
	* sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist:
	Add GLIBC_2.25.
2016-08-03 15:23:04 -04:00
Adhemerval Zanella 9ff72da471 posix: New Linux posix_spawn{p} implementation
This patch implements a new posix_spawn{p} implementation for Linux.  The main
difference is it uses the clone syscall directly with CLONE_VM and CLONE_VFORK
flags and a direct allocated stack.  The new stack and start function solves
most the vfork limitation (possible parent clobber due stack spilling).  The
remaning issue are related to signal handling:

  1. That no signal handlers must run in child context, to avoid corrupt
     parent's state.
  2. Child must synchronize with parent to enforce stack deallocation and
     to possible return execv issues.

The first one is solved by blocking all signals in child, even NPTL-internal
ones (SIGCANCEL and SIGSETXID).  The second issue is done by a stack allocation
in parent and a synchronization with using a pipe or waitpid (in case or error).
The pipe has the advantage of allowing the child signal an exec error (checked
with new tst-spawn2 test).

There is an inherent race condition in pipe2 usage for architectures that do not
support the syscall directly.  In such cases the a pipe plus fctnl is used
instead and it may lead to file descriptor leak in parent (as decribed by fcntl
documentation).

The child process stack is allocate with a mmap with MAP_STACK flag using
default architecture stack size.  Although it is slower than use a stack buffer
from parent, it allows some slack for the compatibility code to run scripts
with no shebang (which may use a buffer with size depending of argument list
count).

Performance should be similar to the vfork default posix implementation and
way faster than fork path (vfork on mostly linux ports are basically
clone with CLONE_VM plus CLONE_VFORK).  The only difference is the syscalls
required for the stack allocation/deallocation.

It fixes BZ#10354, BZ#14750, and BZ#18433.

Tested on i386, x86_64, powerpc64le, and aarch64.

	[BZ #14750]
	[BZ #10354]
	[BZ #18433]
	* include/sched.h (__clone): Add hidden prototype.
	(__clone2): Likewise.
	* include/unistd.h (__dup): Likewise.
	* posix/Makefile (tests): Add tst-spawn2.
	* posix/tst-spawn2.c: New file.
	* sysdeps/posix/dup.c (__dup): Add hidden definition.
	* sysdeps/unix/sysv/linux/aarch64/clone.S (__clone): Likewise.
	* sysdeps/unix/sysv/linux/alpha/clone.S (__clone): Likewise.
	* sysdeps/unix/sysv/linux/arm/clone.S (__clone): Likewise.
	* sysdeps/unix/sysv/linux/hppa/clone.S (__clone): Likewise.
	* sysdeps/unix/sysv/linux/i386/clone.S (__clone): Likewise.
	* sysdeps/unix/sysv/linux/ia64/clone2.S (__clone): Likewise.
	* sysdeps/unix/sysv/linux/m68k/clone.S (__clone): Likewise.
	* sysdeps/unix/sysv/linux/microblaze/clone.S (__clone): Likewise.
	* sysdeps/unix/sysv/linux/mips/clone.S (__clone): Likewise.
	* sysdeps/unix/sysv/linux/nios2/clone.S (__clone): Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/clone.S (__clone):
	Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/clone.S (__clone):
	Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-32/clone.S (__clone): Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-64/clone.S (__clone): Likewise.
	* sysdeps/unix/sysv/linux/sh/clone.S (__clone): Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc32/clone.S (__clone): Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc64/clone.S (__clone): Likewise.
	* sysdeps/unix/sysv/linux/tile/clone.S (__clone): Likewise.
	* sysdeps/unix/sysv/linux/x86_64/clone.S (__clone): Likewise.
	* sysdeps/unix/sysv/linux/nptl-signals.h
	(____nptl_is_internal_signal): New function.
	* sysdeps/unix/sysv/linux/spawni.c: New file.
2016-03-07 11:53:47 +07:00
Adhemerval Zanella 1eb8930608 posix: execvpe cleanup
This patch removes all the dynamic allocation on execvpe code and
instead use direct stack allocation.  This is QoI approach to make
it possible use in scenarios where memory is shared with parent
(vfork or clone with CLONE_VM).

For default process spawn (script file without a shebang), stack
allocation is bounded by NAME_MAX plus PATH_MAX plus 1.  Large
file arguments returns an error (ENAMETOOLONG).  This differs than
current GLIBC pratice in general, but it used to limit stack
allocation for large inputs.  Also, path in PATH environment variable
larger than PATH_MAX are ignored.

The shell direct execution exeception, where execve returns ENOEXEC,
might requires a large stack allocation due large input argument list.

Tested on i686, x86_64, powerpc64le, and aarch64.

	* posix/execvpe.c (__execvpe): Remove dynamic allocation.
	* posix/Makefile (tests): Add tst-execvpe{1,2,3,4,5,6}.
	* posix/tst-execvp1.c (do_test): Use a macro to call execvp.
	* posix/tst-execvp2.c (do_test): Likewise.
	* posix/tst-execvp3.c (do_test): Likewise.
	* posix/tst-execvp4.c (do_test): Likewise.
	* posix/tst-execvpe1.c: New file.
	* posix/tst-execvpe2.c: Likewise.
	* posix/tst-execvpe3.c: Likewise.
	* posix/tst-execvpe4.c: Likewise.
	* posix/tst-execvpe5.c: Likewise.
	* posix/tst-execvpe6.c: Likewise.
2016-03-07 00:21:37 -03:00
Florian Weimer 6793dd51d8 Improve file descriptor checks for posix_spawn actions [BZ #19505] 2016-02-19 14:49:38 +01:00
Joseph Myers f7a9f785e5 Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
Joseph Myers d10a3ab273 Do not use -Wno-strict-prototypes.
Two glibc makefiles use -Wno-strict-prototypes.  I don't know if this
was needed before my recent conversion of many function definitions to
prototype style, but it's not needed now; this patch removes it.

Tested for x86_64 and x86 (testsuite, and that installed stripped
shared libraries are unchanged by the patch).

	* posix/Makefile (CFLAGS-regex.c): Remove variable.
	* resolv/Makefile (+cflags): Do not use -Wno-strict-prototypes.
2015-10-19 21:24:50 +00:00
Andreas Schwab f881f6ff62 Add dependencies on needed locales in each subdir tests (bug 18969) 2015-10-12 15:18:08 +02:00
Adhemerval Zanella d3573f61ac Fix wordsize-32 mmap offset for negative value (BZ#18877)
This patch fixes the default wordsize-32 mmap implementation offset
calculation for negative values.  Current code uses signed shift
operation to calculate the multiple size to use with syscall and
it is implementation defined.  Change it to use a division base
on mmap page size (default being as before, 4096).

Tested on armv7hf.

	[BZ #18877]
	* posix/Makefile (tests): Add tst-mmap-offset.
	* posix/tst-mmap.c: New file.
	* sysdeps/unix/sysv/linux/generic/wordsize-32/mmap.c (__mmap): Fix
	offset calculation for negative values.
2015-08-28 10:42:07 -03:00
Roland McGrath da3a1594af Move tst-getlogin to login/ subdirectory. 2015-02-06 12:29:27 -08:00
Joseph Myers b168057aaa Update copyright dates with scripts/update-copyrights. 2015-01-02 16:29:47 +00:00
Chris Metcalf e47b8d3bbc posix/Makefile: use $(objpfx) for files in before-compile.
This fixes a build failure with a separate build tree where
posix-conf-vars-def.h wasn't being built.
2014-12-29 10:58:25 -05:00
Siddhesh Poyarekar 4a6aca7bf8 Remove Wundef warnings for specification macros
This patch adds a file posix-conf-vars.list that is used to generate
macros to determine if a macro is defined as set, unset or not
defined.  gen-posix-conf-vars.awk processes this file and generates a
header (posix-conf-vars-def.h) with these macros.  A new header
posix-conf-vars.h includes this generated header and defines accessor
macros for the generated macros.

Tested on x86_64.

	* posix/Makefile (before-compile): Add posix-conf-vars-def.h.
	($(objpfx)posix-conf-vars-def.h): New target.
	* posix/posix-conf-vars.list: New file.
	* posix/posix-conf-vars.h: New file.
	* posix/confstr.c: Include posix-conf-vars.h.
	(confstr): Use CONF_IS_* macros.
	* posix/posix-envs.def: Include posix-conf-vars.h.  Use
	CONF_IS_* macros.
	* scripts/gen-posix-conf-vars.awk: New file.
2014-12-29 17:37:54 +05:30
Alexandre Oliva f3d945d5f2 BZ#16469: don't drop trailing dot in res_nquerydomain(..., name, NULL, ...)
If we drop it here, we will fail to detect a duplicate trailing dot
later on.  Retaining, OTOH, has no ill effects whatsoever, and it even
saves us the trouble of copying the domain name minus the trailing
dot, like we used to do.

for ChangeLog

	[BZ #16469]
	* NEWS: Update.
	* resolv/res_query.c (__libc_res_nquerydomain): Retain
	trailing dot.
	* posix/tst-getaddrinfo5.c: New.
	* posix/Makefile (tests): Add it.
2014-11-21 03:39:37 -02:00
Andreas Schwab 4d43ef1e74 Fix memory leak in regexp compiler (BZ #17069) 2014-06-19 19:00:03 +02:00
Andreas Schwab b3a9f56ba5 Don't read past end of pattern in fnmatch (BZ #17062) 2014-06-18 14:20:02 +02:00
Joseph Myers 8540f6d2a7 Don't require test wrappers to preserve environment variables, use more consistent environment.
One wart in the original support for test wrappers for cross testing,
as noted in
<https://sourceware.org/ml/libc-alpha/2012-10/msg00722.html>, is the
requirement for test wrappers to pass a poorly-defined set of
environment variables from the build system to the system running the
glibc under test.  Although some variables are passed explicitly via
$(test-wrapper-env), including LD_* variables that simply can't be
passed implicitly because of the side effects they'd have on the build
system's dynamic linker, others are passed implicitly, including
variables such as GCONV_PATH and LOCPATH that could potentially affect
the build system's libc (so effectively relying on any such effects
not breaking the wrappers).  In addition, the code in
cross-test-ssh.sh for preserving environment variables is fragile (it
depends on how bash formats a list of exported variables, and could
well break for multi-line variable definitions where the contents
contain things looking like other variable definitions).

This patch moves to explicitly passing environment variables via
$(test-wrapper-env).  Makefile variables that previously used
$(test-wrapper) are split up into -before-env and -after-env parts
that can be passed separately to the various .sh files used in
testing, so those files can then insert environment settings between
the two parts.

The common default environment settings in make-test-out are made into
a separate makefile variable that can also be passed to scripts,
rather than many scripts duplicating those settings (for testing an
installed glibc, it is desirable to have the GCONV_PATH setting on
just one place, so just that one place needs to support it pointing to
an installed sysroot instead of the build tree).  The default settings
are included in the variables such as $(test-program-prefix), so that
if tests do not need any non-default settings they can continue to use
single variables rather than the split-up variables.

Although this patch cleans up LC_ALL=C settings (that being part of
the common defaults), various LANG=C and LANGUAGE=C settings remain.
Those are generally unnecessary and I propose a subsequent cleanup to
remove them.  LC_ALL takes precedence over LANG, and while LANGUAGE
takes precedence over LC_ALL, it only does so for settings other than
LC_ALL=C.  So LC_ALL=C on its own is sufficient to ensure the C
locale, and anything that gets LC_ALL=C does not need the other
settings.

While preparing this patch I noticed some tests with .sh files that
appeared to do nothing beyond what the generic makefile support for
tests can do (localedata/tst-wctype.sh - the makefiles support -ENV
variables and .input files - and localedata/tst-mbswcs.sh - just runs
five tests that could be run individually from the makefile).  So I
propose another subsequent cleanup to move those to using the generic
support instead of special .sh files.

Tested x86_64 (native) and powerpc32 (cross).

	* Makeconfig (run-program-env): New variable.
	(run-program-prefix-before-env): Likewise.
	(run-program-prefix-after-env): Likewise.
	(run-program-prefix): Define in terms of new variables.
	(built-program-cmd-before-env): New variable.
	(built-program-cmd-after-env): Likewise.
	(built-program-cmd): Define in terms of new variables.
	(test-program-prefix-before-env): New variable.
	(test-program-prefix-after-env): Likewise.
	(test-program-prefix): Define in terms of new variables.
	(test-program-cmd-before-env): New variable.
	(test-program-cmd-after-env): Likewise.
	(test-program-cmd): Define in terms of new variables.
	* Rules (make-test-out): Use $(run-program-env).
	* scripts/cross-test-ssh.sh (env_blacklist): Remove variable.
	(help): Do not mention environment variables.  Mention
	--timeoutfactor option.
	(timeoutfactor): New variable.
	(blacklist_exports): Remove function.
	(exports): Remove variable.
	(command): Do not include ${exports}.
	* manual/install.texi (Configuring and compiling): Do not mention
	test wrappers preserving environment variables.  Mention that last
	assignment to a variable must take precedence.
	* INSTALL: Regenerated.
	* benchtests/Makefile (run-bench): Use $(run-program-env).
	* catgets/Makefile ($(objpfx)test1.cat): Use
	$(built-program-cmd-before-env), $(run-program-env) and
	$(built-program-cmd-after-env).
	($(objpfx)test2.cat): Do not specify environment variables
	explicitly.
	($(objpfx)de/libc.cat): Use $(built-program-cmd-before-env),
	$(run-program-env) and $(built-program-cmd-after-env).
	($(objpfx)test-gencat.out): Use $(test-program-cmd-before-env),
	$(run-program-env) and $(test-program-cmd-after-env).
	($(objpfx)sample.SJIS.cat): Do not specify environment variables
	explicitly.
	* catgets/test-gencat.sh: Use test_program_cmd_before_env,
	run_program_env and test_program_cmd_after_env arguments.
	* elf/Makefile ($(objpfx)tst-pathopt.out): Use $(run-program-env).
	* elf/tst-pathopt.sh: Use run_program_env argument.
	* iconvdata/Makefile ($(objpfx)iconv-test.out): Use
	$(test-wrapper-env) and $(run-program-env).
	* iconvdata/run-iconv-test.sh: Use test_wrapper_env and
	run_program_env arguments.
	* iconvdata/tst-table.sh: Do not set GCONV_PATH explicitly.
	* intl/Makefile ($(objpfx)tst-gettext.out): Use
	$(test-program-prefix-before-env), $(run-program-env) and
	$(test-program-prefix-after-env).
	($(objpfx)tst-gettext2.out): Likewise.
	* intl/tst-gettext.sh: Use test_program_prefix_before_env,
	run_program_env and test_program_prefix_after_env arguments.
	* intl/tst-gettext2.sh: Likewise.
	* intl/tst-gettext4.sh: Do not set environment variables
	explicitly.
	* intl/tst-gettext6.sh: Likewise.
	* intl/tst-translit.sh: Likewise.
	* malloc/Makefile ($(objpfx)tst-mtrace.out): Use
	$(test-program-prefix-before-env), $(run-program-env) and
	$(test-program-prefix-after-env).
	* malloc/tst-mtrace.sh: Use test_program_prefix_before_env,
	run_program_env and test_program_prefix_after_env arguments.
	* math/Makefile (run-regen-ulps): Use $(run-program-env).
	* nptl/Makefile ($(objpfx)tst-tls6.out): Use $(run-program-env).
	* nptl/tst-tls6.sh: Use run_program_env argument.  Set LANG=C
	explicitly with each use of ${test_wrapper_env}.
	* posix/Makefile ($(objpfx)wordexp-tst.out): Use
	$(test-program-prefix-before-env), $(run-program-env) and
	$(test-program-prefix-after-env).
	* posix/tst-getconf.sh: Do not set environment variables
	explicitly.
	* posix/wordexp-tst.sh: Use test_program_prefix_before_env,
	run_program_env and test_program_prefix_after_env arguments.
	* stdio-common/tst-printf.sh: Do not set environment variables
	explicitly.
	* stdlib/Makefile ($(objpfx)tst-fmtmsg.out): Use
	$(test-program-prefix-before-env), $(run-program-env) and
	$(test-program-prefix-after-env).
	* stdlib/tst-fmtmsg.sh: Use test_program_prefix_before_env,
	run_program_env and test_program_prefix_after_env arguments.
	Split $test calls into $test_pre and $test.
	* timezone/Makefile (build-testdata): Use
	$(built-program-cmd-before-env), $(run-program-env) and
	$(built-program-cmd-after-env).

localedata/ChangeLog:
	* Makefile ($(addprefix $(objpfx),$(CTYPE_FILES))): Use
	$(built-program-cmd-before-env), $(run-program-env) and
	$(built-program-cmd-after-env).
	($(objpfx)sort-test.out): Use $(test-program-prefix-before-env),
	$(run-program-env) and $(test-program-prefix-after-env).
	($(objpfx)tst-fmon.out): Use $(run-program-prefix-before-env),
	$(run-program-env) and $(run-program-prefix-after-env).
	($(objpfx)tst-locale.out): Use $(built-program-cmd-before-env),
	$(run-program-env) and $(built-program-cmd-after-env).
	($(objpfx)tst-trans.out): Use $(run-program-prefix-before-env),
	$(run-program-env), $(run-program-prefix-after-env),
	$(test-program-prefix-before-env) and
	$(test-program-prefix-after-env).
	($(objpfx)tst-ctype.out): Use $(test-program-cmd-before-env),
	$(run-program-env) and $(test-program-cmd-after-env).
	($(objpfx)tst-wctype.out): Likewise.
	($(objpfx)tst-langinfo.out): Likewise.
	($(objpfx)tst-langinfo-static.out): Likewise.
	* gen-locale.sh: Use localedef_before_env, run_program_env and
	localedef_after_env arguments.
	* sort-test.sh: Use test_program_prefix_before_env,
	run_program_env and test_program_prefix_after_env arguments.
	* tst-ctype.sh: Use tst_ctype_before_env, run_program_env and
	tst_ctype_after_env arguments.
	* tst-fmon.sh: Use run_program_prefix_before_env, run_program_env
	and run_program_prefix_after_env arguments.
	* tst-langinfo.sh: Use tst_langinfo_before_env, run_program_env
	and tst_langinfo_after_env arguments.
	* tst-locale.sh: Use localedef_before_env, run_program_env and
	localedef_after_env arguments.
	* tst-mbswcs.sh: Do not set environment variables explicitly.
	* tst-numeric.sh: Likewise.
	* tst-rpmatch.sh: Likewise.
	* tst-trans.sh: Use run_program_prefix_before_env,
	run_program_env, run_program_prefix_after_env,
	test_program_prefix_before_env and test_program_prefix_after_env
	arguments.
	* tst-wctype.sh: Use tst_wctype_before_env, run_program_env and
	tst_wctype_after_env arguments.
2014-06-06 22:19:27 +00:00
Joseph Myers 2bf1804182 Include LOCPATH in default test environment.
Tests run using the default $(make-test-out) automatically get
GCONV_PATH and LC_ALL set, whether or not those environment variables
are actually needed for the individual test.  However, they do not get
LOCPATH set, meaning that a large number of tests have -ENV settings
just to set LOCPATH.

This patch moves LOCPATH into the default environment used for all
tests, on the principle that like GCONV_PATH any settings needed to
use files associated with the newly built library, rather than any old
installed files, are appropriate to use by default.

A further motivation is that various tests using .sh files also set
some combination of LC_ALL, GCONV_PATH and LOCPATH.  Preferably .sh
files should also use the default environment with any additions
required for the individual test.  Now, it was suggested in
<https://sourceware.org/ml/libc-alpha/2014-05/msg00715.html> that
various Makefile variables used in testing should be derived by
composing the -before-env and -after-env variables used when explicit
environment settings are required.  With such a change, it's also
natural for those variables to include the default settings (via some
intermediate makefile variable also used in make-test-out).

Because some .sh files only set variables that correspond to the
default settings, or a subset thereof, and this applies to more of the
.sh files once LOCPATH is in the default settings, doing so reduces
the size of a revised version of
<https://sourceware.org/ml/libc-alpha/2014-05/msg00596.html>: scripts
only needing the (expanded) default settings will not need to receive
the separate -before-env and -after-env variables, only the single
variable they do at present.  So moving LOCPATH into the default
settings can reduce churn caused by subsequent patches.

Tested x86_64 and x86.

	* Rules (make-test-out): Include
	LOCPATH=$(common-objpfx)localedata in default environment.
	* debug/Makefile (tst-chk1-ENV): Remove variable.
	(tst-chk2-ENV): Likewise.
	(tst-chk3-ENV): Likewise.
	(tst-chk4-ENV): Likewise.
	(tst-chk5-ENV): Likewise.
	(tst-chk6-ENV): Likewise.
	(tst-lfschk1-ENV): Likewise.
	(tst-lfschk2-ENV): Likewise.
	(tst-lfschk3-ENV): Likewise.
	(tst-lfschk4-ENV): Likewise.
	(tst-lfschk5-ENV): Likewise.
	(tst-lfschk6-ENV): Likewise.
	* iconvdata/Makefile (bug-iconv6-ENV): Likewise.
	(tst-iconv7-ENV): Likewise.
	* intl/Makefile (LOCPATH-ENV): Likewise.
	(tst-codeset-ENV): Likewise.
	(tst-gettext3-ENV): Likewise.
	(tst-gettext5-ENV): Likewise.
	* libio/Makefile (tst-widetext-ENV): Don't set LOCPATH.
	(tst-fopenloc-ENV): Likewise.
	(tst-fgetws-ENV): Remove variable.
	(tst-ungetwc1-ENV): Likewise.
	(tst-ungetwc2-ENV): Likewise.
	(bug-ungetwc2-ENV): Likewise.
	(tst-swscanf-ENV): Likewise.
	(bug-ftell-ENV): Likewise.
	(tst-fgetwc-ENV): Likewise.
	(tst-fseek-ENV): Likewise.
	(tst-ftell-partial-wide-ENV): Likewise.
	(tst-ftell-active-handler-ENV): Likewise.
	(tst-ftell-append-ENV): Likewise.
	* posix/Makefile (tst-fnmatch-ENV): Likewise.
	(tst-regexloc-ENV): Likewise.
	(bug-regex1-ENV): Likewise.
	(tst-regex-ENV): Likewise.
	(tst-regex2-ENV): Likewise.
	(bug-regex5-ENV): Likewise.
	(bug-regex6-ENV): Likewise.
	(bug-regex17-ENV): Likewise.
	(bug-regex18-ENV): Likewise.
	(bug-regex19-ENV): Likewise.
	(bug-regex20-ENV): Likewise.
	(bug-regex22-ENV): Likewise.
	(bug-regex23-ENV): Likewise.
	(bug-regex25-ENV): Likewise.
	(bug-regex26-ENV): Likewise.
	(bug-regex30-ENV): Likewise.
	(bug-regex32-ENV): Likewise.
	(bug-regex33-ENV): Likewise.
	(bug-regex34-ENV): Likewise.
	(bug-regex35-ENV): Likewise.
	(tst-rxspencer-ENV): Likewise.
	(tst-rxspencer-no-utf8-ENV): Likewise.
	* stdio-common/Makefile (tst-sprintf-ENV): Likewise.
	(tst-sscanf-ENV): Likewise.
	(tst-swprintf-ENV): Likewise.
	(tst-swscanf-ENV): Likewise.
	(test-vfprintf-ENV): Likewise.
	(scanf13-ENV): Likewise.
	(bug14-ENV): Likewise.
	(tst-grouping-ENV): Likewise.
	* stdlib/Makefile (tst-strtod-ENV): Likewise.
	(tst-strtod3-ENV): Likewise.
	(tst-strtod4-ENV): Likewise.
	(tst-strtod5-ENV): Likewise.
	(testmb2-ENV): Likewise./
	* string/Makefile (tst-strxfrm-ENV): Likewise.
	(tst-strxfrm2-ENV): Likewise.
	(bug-strcoll1-ENV): Likewise.
	(test-strcasecmp-ENV): Likewise.
	(test-strncasecmp-ENV): Likewise.
	* time/Makefile (tst-strptime-ENV): Likewise.
	(tst-ftime_l-ENV): Likewise.
	* wcsmbs/Makefile (tst-btowc-ENV): Likewise.
	(tst-mbrtowc-ENV): Likewise.
	(tst-wcrtomb-ENV): Likewise.
	(tst-mbrtowc2-ENV): Likewise.
	(tst-c16c32-1-ENV): Likewise.
	(tst-mbsnrtowcs-ENV): Likewise.

localedata/ChangeLog:
	* Makefile (TEST_MBWC_ENV): Remove variable.
	(tst_iswalnum-ENV): Likewise.
	(tst_iswalpha-ENV): Likewise.
	(tst_iswcntrl-ENV): Likewise.
	(tst_iswctype-ENV): Likewise.
	(tst_iswdigit-ENV): Likewise.
	(tst_iswgraph-ENV): Likewise.
	(tst_iswlower-ENV): Likewise.
	(tst_iswprint-ENV): Likewise.
	(tst_iswpunct-ENV): Likewise.
	(tst_iswspace-ENV): Likewise.
	(tst_iswupper-ENV): Likewise.
	(tst_iswxdigit-ENV): Likewise.
	(tst_mblen-ENV): Likewise.
	(tst_mbrlen-ENV): Likewise.
	(tst_mbrtowc-ENV): Likewise.
	(tst_mbsrtowcs-ENV): Likewise.
	(tst_mbstowcs-ENV): Likewise.
	(tst_mbtowc-ENV): Likewise.
	(tst_strcoll-ENV): Likewise.
	(tst_strfmon-ENV): Likewise.
	(tst_strxfrm-ENV): Likewise.
	(tst_swscanf-ENV): Likewise.
	(tst_towctrans-ENV): Likewise.
	(tst_towlower-ENV): Likewise.
	(tst_towupper-ENV): Likewise.
	(tst_wcrtomb-ENV): Likewise.
	(tst_wcscat-ENV): Likewise.
	(tst_wcschr-ENV): Likewise.
	(tst_wcscmp-ENV): Likewise.
	(tst_wcscoll-ENV): Likewise.
	(tst_wcscpy-ENV): Likewise.
	(tst_wcscspn-ENV): Likewise.
	(tst_wcslen-ENV): Likewise.
	(tst_wcsncat-ENV): Likewise.
	(tst_wcsncmp-ENV): Likewise.
	(tst_wcsncpy-ENV): Likewise.
	(tst_wcspbrk-ENV): Likewise.
	(tst_wcsrtombs-ENV): Likewise.
	(tst_wcsspn-ENV): Likewise.
	(tst_wcsstr-ENV): Likewise.
	(tst_wcstod-ENV): Likewise.
	(tst_wcstok-ENV): Likewise.
	(tst_wcstombs-ENV): Likewise.
	(tst_wcswidth-ENV): Likewise.
	(tst_wcsxfrm-ENV): Likewise.
	(tst_wctob-ENV): Likewise.
	(tst_wctomb-ENV): Likewise.
	(tst_wctrans-ENV): Likewise.
	(tst_wctype-ENV): Likewise.
	(tst_wcwidth-ENV): Likewise.
	(tst-digits-ENV): Likewise.
	(tst-mbswcs6-ENV): Likewise.
	(tst-xlocale1-ENV): Likewise.
	(tst-xlocale2-ENV): Likewise.
	(tst-strfmon1-ENV): Likewise.
	(tst-strptime-ENV): Likewise.
	(tst-setlocale-ENV): Don't set LOCPATH.
	(bug-iconv-trans-ENV): Remove variable.
	(tst-sscanf-ENV): Likewise.
	(tst-leaks-ENV): Don't set LOCPATH.
	(bug-setlocale1-ENV): Remove variable.
	(bug-setlocale1-static-ENV): Likewise.
	(tst-setlocale2-ENV): Likewise.
2014-06-04 23:37:25 +00:00
Stefan Liebler 78b6eebcf1 Use += before-compile instead of a :=. 2014-03-24 16:59:01 +01:00
Joseph Myers 0b20a9e89f Make tests consistently use *.out output files.
This patch systematically renames miscellaneous tests so their outputs
use a *.out name (unless the test is just running some glibc program
with its conventional output file name, rather than a special program
at all, as in catgets tests generating *.cat).  In the case of the
iconv test test-iconvconfig, output is redirected where it wasn't
before.

In various places the "generated" variable is updated to reflect the
revised test names; in iconvdata/Makefile a typo (mmtrace-tst-loading)
is also fixed.  resolv/Makefile sets both "generate" (which appears
unused) and "generated".  Bitrot in the settings of these variables
could no doubt be fixed so that "make clean" after build and testing
leaves results the same as after configure (and indeed the
tests-special / xtests-special variables could be used to simplify
things, by removing those files automatically rather than listing them
manually in these variables), and "make distclean" leaves an empty
build directory, but right now it appears various files don't get
deleted.  I think they are liable to continue to bitrot in the absence
of routine testing that these targets actually work, given that
building in the source directory isn't supported and that was the main
use of such makefile targets.

Tested x86_64.

	* elf/Makefile (tests-special): Rename tests to end with .out.
	($(objpfx)noload-mem): Likewise.
	($(objpfx)tst-leaks1-mem): Likewise.
	($(objpfx)tst-leaks1-static-mem.out): Likewise.
	* iconv/Makefile (xtests-special): Change test-iconvconfig to
	$(objpfx)test-iconvconfig.out.
	(test-iconvconfig): Change to $(objpfx)test-iconvconfig.out.  Use
	set -e inside subshell and redirect output to file.
	* iconvdata/Makefile (generated): Rename tests to end with .out.
	Correct type.
	(tests-special): Rename tests to end with .out.
	($(objpfx)mtrace-tst-loading): Likewise.
	* intl/Makefile (generated): Likewise.
	(tests-special): Likewise.
	($(objpfx)mtrace-tst-gettext): Likewise.
	* misc/Makefile (generated): Likewise.
	(tests-special): Likewise.
	($(objpfx)tst-error1-mem): Likewise.
	* nptl/Makefile (tests-special): Likewise.
	($(objpfx)tst-stack3-mem): Likewise.
	(generated): Likewise.
	* posix/Makefile (generated): Likewise.
	(tests-special): Likewise.
	(xtests-special): Likewise.
	($(objpfx)tst-fnmatch-mem): Likewise.
	($(objpfx)bug-regex2-mem): Likewise.
	($(objpfx)bug-regex14-mem): Likewise.
	($(objpfx)bug-regex21-mem): Likewise.
	($(objpfx)bug-regex31-mem): Likewise.
	($(objpfx)tst-vfork3-mem): Likewise.
	($(objpfx)tst-rxspencer-no-utf8-mem): Likewise.
	($(objpfx)tst-pcre-mem): Likewise.
	($(objpfx)tst-boost-mem): Likewise.
	($(objpfx)bug-ga2-mem): Likewise.
	($(objpfx)bug-glob2-mem): Likewise.
	* resolv/Makefile (generate): Likewise.
	(tests-special): Likewise.
	(xtests-special): Likewise.
	(generated): Likewise.
	($(objpfx)mtrace-tst-leaks): Likewise.
	($(objpfx)mtrace-tst-leaks2): Likewise.

localedata:
	* Makefile (generated): Rename tests to end with .out.
	(tests-special): Likewise.
	($(objpfx)mtrace-tst-leaks): Likewise.
2014-03-07 03:29:23 +00:00
Joseph Myers f214606a0e Enumerate tests with special rules in tests-special variable.
This patch is a revised and updated version of
<https://sourceware.org/ml/libc-alpha/2014-01/msg00196.html>.

In order to generate overall summaries of the results of all tests in
the glibc testsuite, we need to identify and concatenate the files
with the results of individual tests.

Tomas Dohnalek's patch used $(common-objpfx)*/*.test-result for this.
However, the normal glibc approach is explicit enumeration of the
expected set of files with a given property, rather than all files
matching some pattern like that.  Furthermore, we would like to be
able to mark tests as UNRESOLVED if the file with their results is for
some reason missing, and in future we would like to be able to mark
tests as UNSUPPORTED if they are disabled for a particular
configuration (rather than simply having them missing from the list of
tests as at present).  Such handling of tests that were not run or did
not record results requires an explicit enumeration of tests.

For the tests following the default makefile rules, $(tests) (and
$(xtests)) provides such an enumeration.  Others, however, are added
directly as dependencies of the "tests" and "xtests" makefile
targets.  This patch changes the makefiles to put them in variables
tests-special and xtests-special, with appropriate dependencies on the
tests listed there then being added centrally.

Those variables are used in Rules and so need to be set before Rules
is included in a subdirectory makefile, which is often earlier in the
makefile than the dependencies were present before.  We previously
discussed the question of where to include Rules; see the question at
<https://sourceware.org/ml/libc-alpha/2012-11/msg00798.html>, and a
discussion in
<https://sourceware.org/ml/libc-alpha/2013-01/msg00337.html> of why
Rules is included early rather than late in subdirectory makefiles.

It was necessary to avoid an indirection through the check-abi target
and get the check-abi-* targets for individual libraries into the
tests-special variable.  The intl/ test $(objpfx)tst-gettext.out,
previously built only because of dependencies from other tests, was
also added to tests-special for the same reason.

The entries in tests-special are the full makefile targets, complete
with $(objpfx) and .out.  If a future change causes tests to be named
consistently with a .out suffix, this can be changed to include just
the path relative to $(objpfx), without .out.

Tested x86_64, including that the same set of files is generated in
the build directory by a build and testsuite run both before and after
the patch (except for changes to the
elf/tst-null-argv.debug.out.<number> file name), and a build with
run-built-tests=no to verify there aren't any more obvious instances
of the issue Marcus Shawcroft reported with a previous version in
<https://sourceware.org/ml/libc-alpha/2014-01/msg00462.html>.

	* Makefile (tests): Change dependencies to ....
	(tests-special): ... additions to this variable.
	(tests): Depend on $(tests-special).
	* Makerules (check-abi-list): New variable.
	(check-abi): Depend on $(check-abi-list).
	[$(subdir) = elf] (tests-special): Add
	$(objpfx)check-abi-libc.out.
	[$(build-shared) = yes && subdir] (tests-special): Add
	$(check-abi-list).
	[$(build-shared) = yes && subdir] (tests): Do not depend on
	check-abi.
	* Rules (tests): Depend on $(tests-special).
	(xtests): Depend on $(xtests-special).
	* catgets/Makefile (tests): Change dependencies to ....
	(tests-special): ... additions to this variable.
	* conform/Makefile (tests): Change dependencies to ....
	(tests-special): ... additions to this variable.
	* elf/Makefile (tests): Change dependencies to ....
	(tests-special): ... additions to this variable.
	* grp/Makefile (tests): Change dependencies to ....
	(tests-special): ... additions to this variable.
	* iconv/Makefile (xtests): Change dependencies to ....
	(xtests-special): ... additions to this variable.
	* iconvdata/Makefile (tests): Change dependencies to ....
	(tests-special): ... additions to this variable.
	* intl/Makefile (tests): Change dependencies to ....
	(tests-special): ... additions to this variable.  Also add
	$(objpfx)tst-gettext.out.
	* io/Makefile (tests): Change dependencies to ....
	(tests-special): ... additions to this variable.
	* libio/Makefile (tests): Change dependencies to ....
	(tests-special): ... additions to this variable.
	* malloc/Makefile (tests): Change dependencies to ....
	(tests-special): ... additions to this variable.
	* misc/Makefile (tests): Change dependencies to ....
	(tests-special): ... additions to this variable.
	* nptl/Makefile (tests): Change dependencies to ....
	(tests-special): ... additions to this variable.
	* nptl_db/Makefile (tests): Change dependencies to ....
	(tests-special): ... additions to this variable.
	* posix/Makefile (tests): Change dependencies to ....
	(tests-special): ... additions to this variable.
	(xtests): Change dependencies to ....
	(xtests-special): ... additions to this variable.
	* resolv/Makefile (tests): Change dependencies to ....
	(tests-special): ... additions to this variable.
	(xtests): Change dependencies to ....
	(xtests-special): ... additions to this variable.
	* stdio-common/Makefile (tests): Change dependencies to ....
	(tests-special): ... additions to this variable.
	(do-tst-unbputc): Remove target.
	(do-tst-printf): Likewise.
	* stdlib/Makefile (tests): Change dependencies to ....
	(tests-special): ... additions to this variable.
	* string/Makefile (tests): Change dependencies to ....
	(tests-special): ... additions to this variable.
	* sysdeps/x86/Makefile (tests): Change dependencies to ....
	(tests-special): ... additions to this variable.

localedata:
	* Makefile (tests): Change dependencies to ....
	(tests-special): ... additions to this variable.
2014-03-06 22:35:33 +00:00
Roland McGrath f08e9a2629 Fix fallout from Joseph's untested Makeconfig change. 2014-02-28 13:00:27 -08:00
Joseph Myers f8c17e79fa Support expected failures in .test-result files.
This patch, an updated version of
<https://sourceware.org/ml/libc-alpha/2014-01/msg00195.html>, makes it
possible for .test-result files for individual tests to contain XPASS
and XFAIL rather than PASS and FAIL in cases where failure is
expected.  This replaces the marking of two individual tests with "-"
to cause them to be expected at makefile level to fail;
evaluate-test.sh will ensure it exits with status 0 for an expected
failure.

Tested x86_64.

	* scripts/evaluate-test.sh: Take new argument indicating whether
	failure is expected.
	* Makeconfig (evaluate-test): Pass argument to evaluate-test.sh
	indicating whether failure is expected.
	* conform/Makefile (test-xfail-run-conformtest): New variable.
	($(objpfx)run-conformtest.out): Don't expect to fail at makefile
	level.
	* posix/Makefile (test-xfail-annexc): New variable.
	($(objpfx)annexc.out): Don't expect to fail at makefile level.
2014-02-27 03:25:27 +00:00
Joseph Myers a5f891ac8d Consistently include Makeconfig after defining subdir.
In <https://sourceware.org/ml/libc-alpha/2014-01/msg00196.html> I
noted it was necessary to add includes of Makeconfig early in various
subdirectory makefiles for the tests-special variable settings added
by that patch to be conditional on configuration information.  No-one
commented on the general question there of whether Makeconfig should
always be included immediately after the definition of subdir.

This patch implements that early inclusion of Makeconfig in each
directory (which is a lot easier than consistent placement of includes
of Rules).  Includes are added if needed, or moved up if already
present.  Subdirectory "all:" targets are removed, since Makeconfig
provides one.

There is potential for further cleanups I haven't done.  Rules and
Makerules have code such as

ifneq   "$(findstring env,$(origin headers))" ""
headers :=
endif

to override to empty any value of various variables that came from the
environment.  I think there is a case for Makeconfig setting all the
subdirectory variables (other than subdir) to empty to ensure no
outside value is going to take effect if a subdirectory fails to
define a variable.  (A list of such variables, possibly out of date
and incomplete, is in manual/maint.texi.)  Rules and Makerules would
give errors if Makeconfig hadn't already been included, instead of
including it themselves.  The special code to override values coming
from the environment would then be obsolete and could be removed.

Tested x86_64, including that installed binaries are identical before
and after the patch.

	* argp/Makefile: Include Makeconfig immediately after defining
	subdir.
	* assert/Makefile: Likewise.
	* benchtests/Makefile: Likewise.
	* catgets/Makefile: Likewise.
	* conform/Makefile: Likewise.
	* crypt/Makefile: Likewise.
	* csu/Makefile: Likewise.
	(all): Remove target.
	* ctype/Makefile: Include Makeconfig immediately after defining
	subdir.
	* debug/Makefile: Likewise.
	* dirent/Makefile: Likewise.
	* dlfcn/Makefile: Likewise.
	* gmon/Makefile: Likewise.
	* gnulib/Makefile: Likewise.
	* grp/Makefile: Likewise.
	* gshadow/Makefile: Likewise.
	* hesiod/Makefile: Likewise.
	* hurd/Makefile: Likewise.
	(all): Remove target.
	* iconvdata/Makefile: Include Makeconfig immediately after
	defining subdir.
	* inet/Makefile: Likewise.
	* intl/Makefile: Likewise.
	* io/Makefile: Likewise.
	* libio/Makefile: Likewise.
	(all): Remove target.
	* locale/Makefile: Include Makeconfig immediately after defining
	subdir.
	* login/Makefile: Likewise.
	* mach/Makefile: Likewise.
	(all): Remove target.
	* malloc/Makefile: Include Makeconfig immediately after defining
	subdir.
	(all): Remove target.
	* manual/Makefile: Include Makeconfig immediately after defining
	subdir.
	* math/Makefile: Likewise.
	* misc/Makefile: Likewise.
	* nis/Makefile: Likewise.
	* nss/Makefile: Likewise.
	* po/Makefile: Likewise.
	(all): Remove target.
	* posix/Makefile: Include Makeconfig immediately after defining
	subdir.
	* pwd/Makefile: Likewise.
	* resolv/Makefile: Likewise.
	* resource/Makefile: Likewise.
	* rt/Makefile: Likewise.
	* setjmp/Makefile: Likewise.
	* shadow/Makefile: Likewise.
	* signal/Makefile: Likewise.
	* socket/Makefile: Likewise.
	* soft-fp/Makefile: Likewise.
	* stdio-common/Makefile: Likewise.
	* stdlib/Makefile: Likewise.
	* streams/Makefile: Likewise.
	* string/Makefile: Likewise.
	* sunrpc/Makefile: Likewise.
	(all): Remove target.
	* sysvipc/Makefile: Include Makeconfig immediately after defining
	subdir.
	* termios/Makefile: Likewise.
	* time/Makefile: Likewise.
	* timezone/Makefile: Likewise.
	(all): Remove target.
	* wcsmbs/Makefile: Include Makeconfig immediately after defining
	subdir.
	* wctype/Makefile: Likewise.

libidn/ChangeLog:
	* Makefile: Include Makeconfig immediately after defining subdir.

localedata/ChangeLog:
	* Makefile: Include Makeconfig immediately after defining subdir.
	(all): Remove target.

nptl/ChangeLog:
	* Makefile: Include Makeconfig immediately after defining subdir.

nptl_db/ChangeLog:
	* Makefile: Include Makeconfig immediately after defining subdir.
2014-02-26 23:12:03 +00:00
Joseph Myers f0881698bf Generate .test-result files for tests with special rules.
This patch, an updated version of
<https://sourceware.org/ml/libc-alpha/2014-01/msg00194.html> now
proposed for inclusion in glibc, extends the generation of PASS and
FAIL status in .test-result files for individual tests to cover tests
with their own custom makefile rules.  This is just adding
$(evaluate-test) calls to all such rules, since tests with multiple
commands were previously split into separate tests.

Note that the tests the makefiles expect to fail (posix/annexc and
conformtest) currently get FAIL listed in the .test-result file,
rather than XFAIL; a subsequent patch will introduce a better XFAIL
mechanism.

Tested x86_64.

	* Makefile ($(objpfx)c++-types-check.out): Use $(evaluate-test).
	($(objpfx)check-local-headers.out): Likewise.
	($(objpfx)begin-end-check.out): Likewise.
	* Makerules (check-abi-%.out): Likewise.
	* catgets/Makefile ($(objpfx)test1.cat): Likewise.
	($(objpfx)test2.cat): Likewise.
	($(objpfx)de/libc.cat): Likewise.
	($(objpfx)test-gencat.out): Likewise.
	* conform/Makefile ($(objpfx)run-conformtest.out): Likewise.
	* elf/Makefile ($(objpfx)order-cmp.out): Likewise.
	($(objpfx)noload-mem): Likewise.
	($(objpfx)tst-pathopt.out): Likewise.
	($(objpfx)tst-rtld-load-self.out): Likewise.
	($(objpfx)tst-array1-cmp.out): Likewise.
	($(objpfx)tst-array1-static-cmp.out): Likewise.
	($(objpfx)tst-array2-cmp.out): Likewise.
	($(objpfx)tst-array3-cmp.out): Likewise.
	($(objpfx)tst-array4-cmp.out): Likewise.
	($(objpfx)tst-array5-cmp.out): Likewise.
	($(objpfx)tst-array5-static-cmp.out): Likewise.
	($(objpfx)check-textrel.out): Likewise.
	($(objpfx)check-execstack.out): Likewise.
	($(objpfx)check-localplt.out): Likewise.
	($(objpfx)order2-cmp.out): Likewise.
	($(objpfx)tst-leaks1-mem): Likewise.
	($(objpfx)tst-leaks1-static-mem): Likewise.
	($(objpfx)tst-initorder-cmp.out): Likewise.
	($(objpfx)tst-initorder2-cmp.out): Likewise.
	($(objpfx)tst-unused-dep.out): Likewise.
	($(objpfx)tst-unused-dep-cmp.out): Likewise.
	* grp/Makefile ($(objpfx)tst_fgetgrent.out): Likewise.
	* iconv/Makefile (test-iconvconfig): Likewise.
	* iconvdata/Makefile ($(objpfx)mtrace-tst-loading): Likewise.
	($(objpfx)iconv-test.out): Likewise.
	($(objpfx)tst-tables.out): Likewise.
	* intl/Makefile ($(objpfx)mtrace-tst-gettext): Likewise.
	($(objpfx)tst-gettext.out): Likewise.
	($(objpfx)tst-translit.out): Likewise.
	($(objpfx)tst-gettext2.out): Likewise.
	($(objpfx)tst-gettext4.out): Likewise.
	($(objpfx)tst-gettext6.out): Likewise.
	* io/Makefile ($(objpfx)ftwtest.out): Likewise.
	* libio/Makefile ($(objpfx)test-freopen.out): Likewise.
	($(objpfx)tst-fopenloc-cmp.out): Likewise.
	($(objpfx)tst-fopenloc-mem.out): Likewise.
	* malloc/Makefile ($(objpfx)tst-mtrace.out): Likewise.
	* misc/Makefile ($(objpfx)tst-error1-mem): Likewise.
	* posix/Makefile ($(objpfx)globtest.out): Likewise.
	($(objpfx)wordexp-tst.out): Likewise.
	($(objpfx)annexc.out): Likewise.
	($(objpfx)tst-fnmatch-mem): Likewise.
	($(objpfx)bug-regex2-mem): Likewise.
	($(objpfx)bug-regex14-mem): Likewise.
	($(objpfx)bug-regex21-mem): Likewise.
	($(objpfx)bug-regex31-mem): Likewise.
	($(objpfx)tst-vfork3-mem): Likewise.
	($(objpfx)tst-rxspencer-no-utf8-mem): Likewise.
	($(objpfx)tst-pcre-mem): Likewise.
	($(objpfx)tst-boost-mem): Likewise.
	($(objpfx)tst-getconf.out): Likewise.
	($(objpfx)bug-ga2-mem): Likewise.
	($(objpfx)bug-glob2-mem): Likewise.
	* resolv/Makefile ($(objpfx)mtrace-tst-leaks): Likewise.
	($(objpfx)mtrace-tst-leaks2): Likewise.
	* stdio-common/Makefile ($(objpfx)tst-unbputc.out): Likewise.
	($(objpfx)tst-printf.out): Likewise.
	($(objpfx)tst-setvbuf1.out): Likewise.
	($(objpfx)tst-setvbuf1-cmp.out): Likewise.
	* stdlib/Makefile ($(objpfx)isomac.out): Likewise.
	($(objpfx)tst-fmtmsg.out): Likewise.
	* string/Makefile ($(objpfx)tst-svc-cmp.out): Likewise.
	* sysdeps/x86/Makefile ($(objpfx)tst-xmmymm.out): Likewise.

localedata:
	* Makefile ($(objpfx)sort-test.out): Use $(evaluate-test).
	($(objpfx)tst-fmon.out): Likewise.
	($(objpfx)tst-numeric.out): Likewise.
	($(objpfx)tst-locale.out): Likewise.
	($(objpfx)tst-rpmatch.out): Likewise.
	($(objpfx)tst-trans.out): Likewise.
	($(objpfx)tst-mbswcs.out): Likewise.
	($(objpfx)tst-ctype.out): Likewise.
	($(objpfx)tst-wctype.out): Likewise.
	($(objpfx)tst-langinfo.out): Likewise.
	($(objpfx)mtrace-tst-leaks): Likewise.

nptl:
	* Makefile ($(objpfx)tst-stack3-mem): Use $(evaluate-test).
	($(objpfx)tst-tls6.out): Likewise.
	($(objpfx)tst-cleanup0.out): Likewise.
	($(objpfx)tst-cleanup0-cmp.out): Likewise.
	($(objpfx)tst-cancel-wrappers.out): Likewise.
	($(objpfx)tst-oddstacklimit.out): Likewise.

nptl_db:
	* Makefile ($(objpfx)db-symbols.out): Use
	$(evaluate-test).
2014-02-21 21:48:08 +00:00
Joseph Myers 7f98f1806a Split up rules for tests using mtrace and something else.
Most glibc tests that use mtrace to verify that there were no memory
leaks from the glibc facilities used in a given test depend on the
.out file of the previous test so that the mtrace test runs mtrace and
nothing else.

Two, however, have a single target combining mtrace with something
else.  In the case of libio/tst-fopenloc.check, the test both compares
the output with an expected baseline and runs mtrace.  In the case of
posix/tst-rxspencer-mem, the test is run (with different command line
from the main run) and then mtrace is run, from the same makefile
target.

This patch splits both of these tests up to use separate makefile
targets for each thing tested; in the tst-rxspencer case, a file
tst-rxspencer-no-utf8.c is created that just includes tst-rxspencer.c,
as is usual for tests where the same code gets tested in different
compile-time or runtime configurations.

Adding $(evaluate-test) to test commands, as in
<https://sourceware.org/ml/libc-alpha/2014-01/msg00194.html>, will no
longer need to insert && between multiple commands, as all tests will
either have just a single command or already use &&.

Tested x86_64.

	* libio/Makefile ($(objpfx)tst-fopenloc.check): Split into
	separate $(objpfx)tst-fopenloc-cmp.out and
	$(objpfx)tst-fopenloc-mem.out targets.
	(tests): Update dependencies.
	* posix/Makefile (tests variable): Add tst-rxspencer-no-utf8.
	(generated): Change tst-rxspencer-mem and tst-rxspencer.mtrace to
	tst-rxspencer-no-utf8-mem and tst-rxspencer-no-utf8.mtrace.
	(tst-rxspencer-no-utf8-ARGS): New variable.
	(tst-rxspencer-no-utf8-ENV): Likewise.
	(tests target): Depend on $(objpfx)tst-rxspencer-no-utf8-mem
	instead of $(objpfx)tst-rxspencer-mem.
	($(objpfx)tst-rxspencer-mem): Change target to
	$(objpfx)tst-rxspencer-no-utf8-mem.  Depend on
	$(objpfx)tst-rxspencer-no-utf8.out instead of running test program.
	* posix/tst-rxspencer-no-utf8.c: New file.
2014-02-14 13:45:14 +00:00
Allan McRae d4697bc93d Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
Dmitry V. Levin 47c22455d4 Test getaddrinfo return value
This helps testing for regression of BZ#15339.  Creation of network
isolated environments is a privileged operation and therefore is not
included to the test.
2013-05-21 17:21:05 +00:00
Roland McGrath 8fb16a04e6 Move getlogin, getlogin_r, setlogin to login/ subdir. 2013-05-06 15:10:09 -07:00
Paul Pluzhnikov 3e6bd4b198 Set LC_ALL=C before sed. 2013-03-08 20:31:23 -08:00
Siddhesh Poyarekar adbb8027be Remove PIPE_BUF Linux-specific code
Fixes BZ #12723

The variable pipe buffer size does nothing to the value of PIPE_BUF,
since the number of bytes that are atomically written is still
PIPE_BUF on Linux.
2013-03-07 12:15:08 +05:30
Andreas Schwab a445af0bc7 Fix buffer overrun in regexp matcher 2013-02-12 09:30:34 +01:00
Andreas Schwab 7e2f0d2d77 Fix handling of collating symbols in regexps 2013-02-12 09:25:34 +01:00
H.J. Lu 740b3dbee8 Add --enable-hardcoded-path-in-tests configure option 2013-01-11 07:14:18 -08:00
H.J. Lu 4cf8f2098f Support run tst-exec and tst-spawn directly 2013-01-10 14:14:55 -08:00
Roland McGrath ad98e30c90 Force getconf.speclist to be generated in the others pass. 2013-01-09 16:05:32 -08:00
Joseph Myers 568035b787 Update copyright notices with scripts/update-copyrights. 2013-01-02 19:05:09 +00:00
Joseph Myers 531f1ae0a7 Generate /usr/libexec/getconf files when cross-compiling. 2012-11-17 01:49:19 +00:00
Marcus Shawcroft c485e4d2cc Adding missing -fexception CFLAGS 2012-11-14 12:35:10 +00:00
Joseph Myers cc1290d07e Support cross-testing. 2012-10-24 21:59:01 +00:00
Roland McGrath 6e6249d0b4 BZ#14743: Move clock_* symbols from librt to libc. 2012-10-24 14:50:46 -07:00
Joseph Myers 03ac099f6b Define and use $(run-built-tests). 2012-10-24 00:08:46 +00:00
Joseph Myers ebfd1bbd04 Use $(run-program-prefix) in posix/globtest.sh. 2012-10-23 23:32:14 +00:00
Jim Blandy 166bca2480 Add and use $(host-built-program-cmd). 2012-10-23 22:49:59 +00:00