about summary refs log tree commit diff
path: root/support
Commit message (Collapse)AuthorAgeFilesLines
* support: Add xdlvsym functionFlorian Weimer2019-06-282-0/+21
|
* support: Invent verbose_printf macroMike Crowe2019-06-211-0/+8
| | | | | | | Make it easier for tests to emit progress messages only when --verbose is specified. * support/test-driver.h: Add verbose_printf macro.
* support: Add xclock_now helper function.Mike Crowe2019-06-211-0/+10
| | | | | | | | | | | | | It's easier to read and write tests with: const struct timespec ts = xclock_now(CLOCK_REALTIME); than struct timespec ts; xclock_gettime(CLOCK_REALTIME, &ts); * support/xtime.h: Add xclock_now() helper function.
* support: Expose sbindir as support_sbindir_prefixFlorian Weimer2019-05-203-0/+10
|
* support: Add missing EOL terminators on timespecMike Crowe2019-05-201-2/+2
| | | | | | | | | | | | | The original implementations of test_timespec_before_impl and test_timespec_equal_or_after in 519839965197291924895a3988804e325035beee were missing the backslash required for a newline. Checked on x86_64-linux-gnu. * support/timespec.c: Add backslash to correct newline in failure message. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* support: Correct confusing commentMike Crowe2019-05-201-2/+2
| | | | | | * support/timespec.h: Correct confusing comment. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* support: Report NULL blobs explicitly in TEST_COMPAREFlorian Weimer2019-05-161-1/+3
| | | | | | | Provide an explicit diagnostic if the length is positive, and do not just crash with a null pointer dereference. Null pointers are only valid if the length is zero, so this can only happen with a faulty test.
* support: Add support_install_rootsbindirAlexandra Hájková2019-05-153-1/+11
| | | | Reviewed by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* support: Export bindir path on support_pathAdhemerval Zanella2019-05-143-1/+11
| | | | | | | | | | Checked on x86_64-linux-gnu. * support/Makefile (CFLAGS-support_paths.c): Add -DBINDIR_PATH. * support/support.h (support_bindir_prefix): New variable. * support/support_paths.c [BINDIR_PATH] (support_bindir_prefix): Reviewed-by: DJ Delorie <dj@redhat.com>
* support: Fix timespec printfAdhemerval Zanella2019-05-101-10/+11
| | | | | | | | | | | | | | | | | The patch print timespec members as intmax_t instead of long int. It avoid the -Werror=format= build issue on x32: timespec.c: In function 'test_timespec_before_impl': timespec.c:32:23: error: format '%ld' expects argument of type 'long int', but argument 4 has type '__time_t' {aka 'const long long int'} [-Werror=format=] Checked on x86_64-linux-gnu-x32, x86_64-linux-gnu, and i686-linux-gnu. * support/timespec.c (test_timespec_before_impl, test_timespec_equal_or_after_impl): print timespec member as intmax_t insted of long int. Reviewed-by: Florian Weimer <fweimer@redhat.com>
* support: Add timespec.hMike Crowe2019-05-096-0/+287
| | | | | | | | | | | | | | | | | | It adds useful functions for tests that use struct timespec. Checked on x86_64-linux-gnu and i686-linux-gnu. * support/timespec.h: New file. Provide timespec helper functions along with macros in the style of those in check.h. * support/timespec.c: New file. Implement check functions declared in support/timespec.h. * support/timespec-add.c: New file from gnulib containing timespec_add implementation that handles overflow. * support/timespec-sub.c: New file from gnulib containing timespec_sub implementation that handles overflow. * support/README: Mention timespec.h. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* support: Add xclock_gettimeMike Crowe2019-05-084-0/+66
| | | | | | | | | | | | * support/xclock_gettime.c (xclock_gettime): New file. Provide clock_gettime wrapper for use in tests that fails the test rather than returning failure. * support/xtime.h: New file to declare xclock_gettime. * support/Makefile: Add xclock_gettime.c. * support/README: Mention xtime.h.
* support: Add support_capture_subprogramAdhemerval Zanella2019-04-1710-50/+551
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Its API is similar to support_capture_subprocess, but rather creates a new process based on the input path and arguments. Under the hoods it uses posix_spawn to create the new process. It also allows the use of other support_capture_* functions to check for expected results and free the resources. Checked on x86_64-linux-gnu. * support/Makefile (libsupport-routines): Add support_subprocess, xposix_spawn, xposix_spawn_file_actions_addclose, and xposix_spawn_file_actions_adddup2. (tst-support_capture_subprocess-ARGS): New rule. * support/capture_subprocess.h (support_capture_subprogram): New prototype. * support/support_capture_subprocess.c (support_capture_subprocess): Refactor to use support_subprocess and support_capture_poll. (support_capture_subprogram): New function. * support/tst-support_capture_subprocess.c (write_mode_to_str, str_to_write_mode, test_common, parse_int, handle_restart, do_subprocess, do_subprogram, do_multiple_tests): New functions. (do_test): Add support_capture_subprogram tests. * support/subprocess.h: New file. * support/support_subprocess.c: Likewise. * support/xposix_spawn.c: Likewise. * support/xposix_spawn_file_actions_addclose.c: Likewise. * support/xposix_spawn_file_actions_adddup2.c: Likewise. * support/xspawn.h: Likewise. Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* Avoid fall-through in test-container if execlp fails.Joseph Myers2019-02-131-0/+1
| | | | | | | | | | | | | One of the implicit-fallthrough warnings from compiling glibc with -Wextra appears to indicate an actual bug: the test-container code could fall through inappropriately if execlp returns (which only occurs on error). This patch adds appropriate error handling in this case to avoid that fall-through. Tested for x86_64. * support/test-container.c (recursive_remove): Use FAIL_EXIT1 if execlp returns.
* support: Implement xdlmopenFlorian Weimer2019-02-073-1/+33
| | | | | Put xdlmopen into its own file, to avoid disturbing static linking tests (where dlmopen pulls in additional code).
* support: Use dlerror to detect NULL symbols in xdlsymFlorian Weimer2019-02-061-10/+10
|
* Fix alignment of TLS variables for tls variant TLS_TCB_AT_TP [BZ #23403]Stefan Liebler2019-02-065-0/+66
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The alignment of TLS variables is wrong if accessed from within a thread for architectures with tls variant TLS_TCB_AT_TP. For the main thread the static tls data is properly aligned. For other threads the alignment depends on the alignment of the thread pointer as the static tls data is located relative to this pointer. This patch adds this alignment for TLS_TCB_AT_TP variants in the same way as it is already done for TLS_DTV_AT_TP. The thread pointer is also already properly aligned if the user provides its own stack for the new thread. This patch extends the testcase nptl/tst-tls1.c in order to check the alignment of the tls variables and it adds a pthread_create invocation with a user provided stack. The test itself is migrated from test-skeleton.c to test-driver.c and the missing support functions xpthread_attr_setstack and xposix_memalign are added. ChangeLog: [BZ #23403] * nptl/allocatestack.c (allocate_stack): Align pointer pd for TLS_TCB_AT_TP tls variant. * nptl/tst-tls1.c: Migrate to support/test-driver.c. Add alignment checks. * support/Makefile (libsupport-routines): Add xposix_memalign and xpthread_setstack. * support/support.h: Add xposix_memalign. * support/xthread.h: Add xpthread_attr_setstack. * support/xposix_memalign.c: New File. * support/xpthread_attr_setstack.c: Likewise.
* support: Correct error message for TEST_COMPARE_STRINGFlorian Weimer2019-02-012-7/+7
| | | | It should say "string", not "blob".
* support: Handle AF_LOCAL, AF_UNSPEC in support_format_address_familyFlorian Weimer2019-02-011-0/+4
|
* nptl: Fix pthread_rwlock_try*lock stalls (Bug 23844)Carlos O'Donell2019-01-313-0/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For a full analysis of both the pthread_rwlock_tryrdlock() stall and the pthread_rwlock_trywrlock() stall see: https://sourceware.org/bugzilla/show_bug.cgi?id=23844#c14 In the pthread_rwlock_trydlock() function we fail to inspect for PTHREAD_RWLOCK_FUTEX_USED in __wrphase_futex and wake the waiting readers. In the pthread_rwlock_trywrlock() function we write 1 to __wrphase_futex and loose the setting of the PTHREAD_RWLOCK_FUTEX_USED bit, again failing to wake waiting readers during unlock. The fix in the case of pthread_rwlock_trydlock() is to check for PTHREAD_RWLOCK_FUTEX_USED and wake the readers. The fix in the case of pthread_rwlock_trywrlock() is to only write 1 to __wrphase_futex if we installed the write phase, since all other readers would be spinning waiting for this step. We add two new tests, one exercises the stall for pthread_rwlock_trywrlock() which is easy to exercise, and one exercises the stall for pthread_rwlock_trydlock() which is harder to exercise. The pthread_rwlock_trywrlock() test fails consistently without the fix, and passes after. The pthread_rwlock_tryrdlock() test fails roughly 5-10% of the time without the fix, and passes all the time after. Signed-off-by: Carlos O'Donell <carlos@redhat.com> Signed-off-by: Torvald Riegel <triegel@redhat.com> Signed-off-by: Rik Prohaska <prohaska7@gmail.com> Co-authored-by: Torvald Riegel <triegel@redhat.com> Co-authored-by: Rik Prohaska <prohaska7@gmail.com>
* nss_files: Fix /etc/aliases null pointer dereference [BZ #24059]Florian Weimer2019-01-312-0/+4
| | | | | | | | If /etc/aliases ends with a continuation line (a line that starts with whitespace) which does not have a trailing newline character, the file parser would crash due to a null pointer dereference. Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* hurd: Fix libsupport xsigstack buildAdhemerval Zanella2019-01-241-0/+7
| | | | | | | | | Hurd does not support MAP_NORESERVE and MAP_STACK. Checked on i686-gnu build. * support/xsigstack.c (MAP_NORESERVE, MAP_STACK): Define if they are not defined.
* Tests for minimal signal handler functionality in MINSIGSTKSZ space.Zack Weinberg2019-01-164-0/+190
| | | | | | | | | | | | | | | | | | | | | | | There is general agreement that the very short list of things that ISO C says you can do in an async signal handler should all work when the handler is running on an alternate signal stack with only MINSIGSTKSZ space. This patch adds tests to make sure those things do work. To facilitate this, there is a new set of test support routines for setting up alternate signal stacks; see support/xsignal.h for the API. * support/xsignal.h (xalloc_sigstack, xfree_sigstack) (xget_sigstack_location): New test support functions. * support/xsigstack.c: New file, implementing them. * support/tst-xsigstack.c: New test for them. * support/Makefile: Update. * signal/tst-minsigstksz-1.c * signal/tst-minsigstksz-2.c * signal/tst-minsigstksz-3.c * signal/tst-minsigstksz-3a.c * signal/tst-minsigstksz-4.c: New tests. * signal/Makefile: Run them.
* Update copyright dates with scripts/update-copyrights.Joseph Myers2019-01-01169-169/+169
| | | | | | | * All files with FSF copyright notices: Update copyright dates using scripts/update-copyrights. * locale/programs/charmap-kw.h: Regenerated. * locale/programs/locfile-kw.h: Likewise.
* Replace check_mul_overflow_size_t with __builtin_mul_overflowAdhemerval Zanella2018-12-281-23/+3
| | | | | | | | | | | | | | | Checked on x86_64-linux-gnu and i686-linux-gnu. * malloc/alloc_buffer_alloc_array.c (__libc_alloc_buffer_alloc_array): Use __builtin_mul_overflow in place of check_mul_overflow_size_t. * malloc/dynarray_emplace_enlarge.c (__libc_dynarray_emplace_enlarge): Likewise. * malloc/dynarray_resize.c (__libc_dynarray_resize): Likewise. * malloc/reallocarray.c (__libc_reallocarray): Likewise. * malloc/malloc-internal.h (check_mul_overflow_size_t): Remove function. * support/blob_repeat.c (check_mul_overflow_size_t, (minimum_stride_size, support_blob_repeat_allocate): Likewise.
* support: Do not require overflow builtin in support/blob_repeat.cFlorian Weimer2018-12-151-3/+23
| | | | | | It is only available in GCC 5 and later. Tested-by: Romain Naour <romain.naour@gmail.com>
* test-container: move postclean outside of namespace changesDJ Delorie2018-12-101-8/+37
| | | | | | | | | | | | | | | | | | | | During postclean.req testing it was found that the fork in the parent process (after the unshare syscall) would fail with ENOMEM (see recursive_remove() in test-container.c). While failing with ENOMEM is certainly unexpected, it is simply easier to refactor the design and have the parent remain outside of the namespace. This change moves the postclean.req processing to a distinct process (the parent) that then forks the test process (which will have to fork once more to complete uid/gid transitions). When the test process exists the cleanup process will ensure all files are deleted when a post clean is requested. Signed-off-by: DJ Delorie <dj@redhat.com> Reviewed-by: Carlos O'Donell <carlos@redhat.com> [BZ #23948] * support/test-container.c: Move postclean step to before we change namespaces.
* support: Implement <support/descriptors.h> to track file descriptorsFlorian Weimer2018-12-066-0/+533
|
* test-container: add "su" command to run test as root, add unshare hintsDJ Delorie2018-12-041-4/+64
| | | | | | * support/test-container.c (check_for_unshare_hints): New. (main): Call it if unshare fails. Add support for "su" scriptlet command.
* support: Close original descriptors in support_capture_subprocessFlorian Weimer2018-12-011-0/+6
|
* support: Add signal support to support_capture_subprocess_checkFlorian Weimer2018-11-283-11/+59
| | | | | | | | Signal zero does not terminate a process, so it is safe to use negative values for signal numbers. Adjust libio/tst-vtables-common.c to use this new functionality, instead of determining the termination status for a signal indirectly.
* support_quote_string: Do not use str parameter nameFlorian Weimer2018-11-281-2/+2
| | | | | This avoids a build failure if this identifier is used as a macro in a test.
* support: Implement support_quote_stringFlorian Weimer2018-11-274-0/+93
| | | | Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
* support: Print timestamps in timeout handlerFlorian Weimer2018-11-191-0/+28
| | | | | | This is sometimes useful to determine if a test truly got stuck, or if it was making progress (logging information to standard output) and was merely slow to finish.
* support: Fix printf format for TEST_COMPARE_STRINGAdhemerval Zanella2018-11-071-1/+1
| | | | | | | | | | | | | | | | Fix the following on 32 bits targets: support_test_compare_string.c: In function ‘support_test_compare_string’: support_test_compare_string.c:80:37: error: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 2 has type ‘size_t’ {aka ‘unsigned int’} [-Werror=format=] printf (" string length: %lu bytes\n", left_length); ~~^ ~~~~~~~~~~~ %u Checked on arm-linux-gnueabihf. * support/support_test_compare_string.c (support_test_compare_string): Fix printf format.
* support: Implement TEST_COMPARE_STRINGFlorian Weimer2018-11-074-0/+213
|
* support/shell-container.c: Use support_copy_file_rangeFlorian Weimer2018-11-021-1/+1
| | | | Reviewed-by: DJ Delorie <dj@redhat.com>
* support/test-container.c: Include <libc-pointer-arith.h>Florian Weimer2018-11-021-0/+1
| | | | Reviewed-by: DJ Delorie <dj@redhat.com>
* support_blob_repeat: Call mkstemp directory for the backing fileFlorian Weimer2018-10-301-5/+9
| | | | This avoids a warning during post-test cleanup.
* stdlib/test-bz22786: Avoid spurious test failures using alias mappingsFlorian Weimer2018-10-304-0/+409
| | | | | | | | On systems without enough random-access memory, stdlib/test-bz22786 will go deeply into swap and time out, even with a substantial TIMEOUTFACTOR. This commit adds a facility to construct repeating strings with alias mappings, so that the requirement for physical memory, and uses it in stdlib/test-bz22786.
* Adjust name of ld.so in test-container.c.Stefan Liebler2018-10-044-2/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | The test-container.c file assumes that ld.so is always named something like /elf/ld-linux-*. But e.g. on s390x it is named ld64.so.1 or ld.so.1 on s390. There are other architectures like power or mips with similar names. This patch introduces the new global variable support_objdir_elf_ldso which contains the absolute path to the runtime linker used by the testsuite, e.g. OBJDIR_PATH/elf/ld-linux-x86-64.so.2. The check in test-container.c is now comparing against this path. Without this patch, test-container.c is searching invalid files / directories and fails to find glibc/nss/tst-nss-test3.root/tst-nss-test3.script. Then the test tst-nss-test3 fails! Reviewed-by: Carlos O'Donell <carlos@redhat.com> ChangeLog: * support/support.h (support_objdir_elf_ldso): New variable. * support/support_paths.c (support_objdir_elf_ldso): Likewise. * support/Makefile (CFLAGS-support_paths.c): Add definition for OBJDIR_ELF_LDSO_PATH. * support/test-container.c (main): Search for the ld.so which is also used by the testsuite.
* test-container: Use xcopy_file_range for cross-device copy [BZ #23597]H.J. Lu2018-08-316-2/+186
| | | | | | | | | | | | | | | | | | | | copy_file_range can't be used to copy a file from glibc source directory to glibc build directory since they may be on different filesystems. This patch adds xcopy_file_range for cross-device copy. Reviewed-by: Carlos O'Donell <carlos@redhat.com> [BZ #23597] * support/Makefile (libsupport-routines): Add support_copy_file_range and xcopy_file_range. * support/support.h: Include <sys/types.h>. (support_copy_file_range): New prototype. * support/support_copy_file_range.c: New file. Copied and modified from io/copy_file_range-compat.c. * support/test-container.c (copy_one_file): Call xcopy_file_rang instead of copy_file_range. * support/xcopy_file_range.c: New file. * support/xunistd.h (xcopy_file_range): New prototype.
* test-container: EPERM from unshare is UNSUPPORTEDFlorian Weimer2018-08-281-2/+3
| | | | | For example, the security policy on the Fedora build daemons results in this EPERM error.
* links-dso-program: Fix build-programs=no build case.DJ Delorie2018-08-271-10/+0
| | | | | * support/Makefile (others): Don't list programs explicitly as a dependency of "others".
* Fix IA64 links-dso-program link.DJ Delorie2018-08-241-1/+1
| | | | | * support/Makefile (LDLIBS-links-dso-program): Add -lgcc and $(libunwind).
* Add test-in-container infrastructure.DJ Delorie2018-08-2212-0/+1667
| | | | | | | | | | | | | | | | | | | | | | | | | * Makefile (testroot.pristine): New rules to initialize the test-in-container "testroot". * Makerules (all-testsuite): Add tests-container. * Rules (tests-expected): Add tests-container. (binaries-all-tests): Likewise. (tests-container): New, run these tests in the testroot container. * support/Makefile (others): Add *-container, support_paths.c, xmkdirp, and links-dso-program. * support/links-dso-program-c.c: New. * support/links-dso-program.cc: New. * support/test-container.c: New. * support/shell-container.c: New. * support/echo-container.c: New. * support/true-container.c: New. * support/xmkdirp.c: New. * support/xsymlink.c: New. * support/support_paths.c: New. * support/support.h: Add support paths prototypes. * support/xunistd.h: Add xmkdirp () and xsymlink (). * nss/tst-nss-test3.c: Convert to test-in-container. * nss/tst-nss-test3.root/: New.
* Avoid running some tests if the file system does not support holesFlorian Weimer2018-08-213-0/+94
| | | | | Otherwise, these tests fills up the entire disk (or just run very slowly and eventually time out).
* support: Add TEST_NO_SETVBUFFlorian Weimer2018-06-263-1/+7
| | | | | This is sometimes needed for testing stdio streams, where the setvbuf call in the test driver could interfere with the test.
* support: Add wrappers for pthread_barrierattr_tFlorian Weimer2018-05-295-0/+84
|
* Switch IDNA implementation to libidn2 [BZ #19728] [BZ #19729] [BZ #22247]Florian Weimer2018-05-231-2/+0
| | | | | This provides an implementation of the IDNA2008 standard and fixes CVE-2016-6261, CVE-2016-6263, CVE-2017-14062.