summary refs log tree commit diff
path: root/support
Commit message (Collapse)AuthorAgeFilesLines
* test-container: return UNSUPPORTED for ENOSPC on clone()Xi Ruoyao2022-07-051-31/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | Since Linux 4.9, the kernel provides /proc/sys/user/max_{mnt,pid,user}_namespace as a limitation of number of namespaces. Some distros (for example, Slint Linux 14.2.1) set them (or only max_user_namespace) to zero as a "security policy" for disabling namespaces. The clone() call will set errno to ENOSPC under such a limitation. We didn't check ENOSPC in the code so the test will FAIL, and report: unable to unshare user/fs: No space left on device This message is, unfortunately, very unhelpful. It leads people to check the memory or disk space, instead of finding the real issue. To improve the situation, we should check for ENOSPC and return UNSUPPORTED as the test result. Also refactor check_for_unshare_hints() to emit a proper message telling people how to make the test work, if they really need to run the namespaced tests. Reported-by: Philippe Delavalade <philippe.delavalade@orange.fr> URL: https://lists.linuxfromscratch.org/sympa/arc/lfs-support/2022-06/msg00022.html Signed-off-by: Xi Ruoyao <xry111@xry111.site> Reviewed-by: DJ Delorie <dj@redhat.com>
* support: Change non-address output format of support_format_dns_packetFlorian Weimer2022-06-242-9/+17
| | | | | | | It makes sense to include the owner name (LHS) and record type in the output, so that they can be checked for correctness. Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* support: Add xmkfifoAdhemerval Zanella2022-04-153-0/+31
| | | | Wrapper support mkfifo.
* test-container: Fix "unused code" warnings on HURDDJ Delorie2022-04-121-0/+6
| | | | | | | | | Comment out bits of code that are only used when we *have* pid namespaces, to avoid "unused code" warnings. Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org> Message-Id: <xno817tnds.fsf@greed.delorie.com>
* Allow for unpriviledged nested containersDJ Delorie2022-04-044-35/+147
| | | | | | | | | | | | | | | | | If the build itself is run in a container, we may not be able to fully set up a nested container for test-container testing. Notably is the mounting of /proc, since it's critical that it be mounted from within the same PID namespace as its users, and thus cannot be bind mounted from outside the container like other mounts. This patch defaults to using the parent's PID namespace instead of creating a new one, as this is more likely to be allowed. If the test needs an isolated PID namespace, it should add the "pidns" command to its init script. Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* support: Fix support_process_state_wait path size calculationAdhemerval Zanella2022-03-231-1/+2
| | | | | | | Use INT_STRLEN_BOUND to proper get the maximum pid_t size. Also fix the wrong calculation (the 3 should multiply the sizeof (pid_t)). Checked on x86_64-linux-gnu.
* support: Remove unused extract_8 functionAdhemerval Zanella2022-03-231-11/+0
|
* support: Add support_socket_so_timestamp_time64Adhemerval Zanella2022-01-283-0/+53
| | | | | | | | Check if the socket support 64-bit network packages timestamps (SO_TIMESTAMP and SO_TIMESTAMPNS). This will be used on recvmsg and recvmmsg tests to check if the timestamp should be generated. Reviewed-by: Florian Weimer <fweimer@redhat.com>
* Avoid -Wuse-after-free in tests [BZ #26779].Martin Sebor2022-01-261-1/+2
| | | | Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* support: Add helpers to create paths longer than PATH_MAXSiddhesh Poyarekar2022-01-212-9/+159
| | | | | | | | | Add new helpers support_create_and_chdir_toolong_temp_directory and support_chdir_toolong_temp_directory to create and descend into directory trees longer than PATH_MAX. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org> Signed-off-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
* debug: Synchronize feature guards in fortified functions [BZ #28746]Siddhesh Poyarekar2022-01-121-0/+2
| | | | | | | | | | | | | | | | | | Some functions (e.g. stpcpy, pread64, etc.) had moved to POSIX in the main headers as they got incorporated into the standard, but their fortified variants remained under __USE_GNU. As a result, these functions did not get fortified when _GNU_SOURCE was not defined. Add test wrappers that check all functions tested in tst-chk0 at all levels with _GNU_SOURCE undefined and then use the failures to (1) exclude checks for _GNU_SOURCE functions in these tests and (2) Fix feature macro guards in the fortified function headers so that they're the same as the ones in the main headers. This fixes BZ #28746. Signed-off-by: Siddhesh Poyarekar <siddhesh@sourceware.org> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* Revert "support: Add support_socket_so_timestamp_time64"Adhemerval Zanella2022-01-123-61/+0
| | | | This reverts commit a4cf12360fb7a8eae4fa4923763309b7f10797c3.
* support: Add support_socket_so_timestamp_time64Adhemerval Zanella2022-01-123-0/+61
| | | | | | Check if the socket support 64-bit network packages timestamps (SO_TIMESTAMP and SO_TIMESTAMPNS). This will be used on recvmsg and recvmmsg tests to check if the timestamp should be generated.
* Update copyright dates with scripts/update-copyrightsPaul Eggert2022-01-01238-239/+239
| | | | | | | | | | | | | | | | | | | | | | | I used these shell commands: ../glibc/scripts/update-copyrights $PWD/../gnulib/build-aux/update-copyright (cd ../glibc && git commit -am"[this commit message]") and then ignored the output, which consisted lines saying "FOO: warning: copyright statement not found" for each of 7061 files FOO. I then removed trailing white space from math/tgmath.h, support/tst-support-open-dev-null-range.c, and sysdeps/x86_64/multiarch/strlen-vec.S, to work around the following obscure pre-commit check failure diagnostics from Savannah. I don't know why I run into these diagnostics whereas others evidently do not. remote: *** 912-#endif remote: *** 913: remote: *** 914- remote: *** error: lines with trailing whitespace found ... remote: *** error: sysdeps/unix/sysv/linux/statx_cp.c: trailing lines
* Add --with-timeoutfactor=NUM to specify TIMEOUTFACTORH.J. Lu2021-12-041-1/+1
| | | | | | | | | On Ice Lake and Tiger Lake laptops, some test programs timeout when there are 3 "make check -j8" runs in parallel. Add --with-timeoutfactor=NUM to specify an integer to scale the timeout of test programs, which can be overriden by TIMEOUTFACTOR environment variable. Reviewed-by: Florian Weimer <fweimer@redhat.com>
* elf: Testing infrastructure for ld.so DSO sorting (BZ #17645)Chung-Lin Tang2021-10-216-1/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is the first of a 2-part patch set that fixes slow DSO sorting behavior in the dynamic loader, as reported in BZ #17645. In order to facilitate such a large modification to the dynamic loader, this first patch implements a testing framework for validating shared object sorting behavior, to enable comparison between old/new sorting algorithms, and any later enhancements. This testing infrastructure consists of a Python script scripts/dso-ordering-test.py' which takes in a description language, consisting of strings that describe a set of link dependency relations between DSOs, and generates testcase programs and Makefile fragments to automatically test the described situation, for example: a->b->c->d # four objects linked one after another a->[bc]->d;b->c # a depends on b and c, which both depend on d, # b depends on c (b,c linked to object a in fixed order) a->b->c;{+a;%a;-a} # a, b, c serially dependent, main program uses # dlopen/dlsym/dlclose on object a a->b->c;{}!->[abc] # a, b, c serially dependent; multiple tests generated # to test all permutations of a, b, c ordering linked # to main program (Above is just a short description of what the script can do, more documentation is in the script comments.) Two files containing several new tests, elf/dso-sort-tests-[12].def are added, including test scenarios for BZ #15311 and Redhat issue #1162810 [1]. Due to the nature of dynamic loader tests, where the sorting behavior and test output occurs before/after main(), generating testcases to use support/test-driver.c does not suffice to control meaningful timeout for ld.so. Therefore a new utility program 'support/test-run-command', based on test-driver.c/support_test_main.c has been added. This does the same testcase control, but for a program specified through a command-line rather than at the source code level. This utility is used to run the dynamic loader testcases generated by dso-ordering-test.py. [1] https://bugzilla.redhat.com/show_bug.cgi?id=1162810 Signed-off-by: Chung-Lin Tang <cltang@codesourcery.com> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* Add alloc_align attribute to memalign et alJonathan Wakely2021-10-211-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | GCC 4.9.0 added the alloc_align attribute to say that a function argument specifies the alignment of the returned pointer. Clang supports the attribute too. Using the attribute can allow a compiler to generate better code if it knows the returned pointer has a minimum alignment. See https://gcc.gnu.org/PR60092 for more details. GCC implicitly knows the semantics of aligned_alloc and posix_memalign, but not the obsolete memalign. As a result, GCC generates worse code when memalign is used, compared to aligned_alloc. Clang knows about aligned_alloc and memalign, but not posix_memalign. This change adds a new __attribute_alloc_align__ macro to <sys/cdefs.h> and then uses it on memalign (where it helps GCC) and aligned_alloc (where GCC and Clang already know the semantics, but it doesn't hurt) and xposix_memalign. It can't be used on posix_memalign because that doesn't return a pointer (the allocated pointer is returned via a void** parameter instead). Unlike the alloc_size attribute, alloc_align only allows a single argument. That means the new __attribute_alloc_align__ macro doesn't really need to be used with double parentheses to protect a comma between its arguments. For consistency with __attribute_alloc_size__ this patch defines it the same way, so that double parentheses are required. Signed-off-by: Jonathan Wakely <jwakely@redhat.com> Reviewed-by: Carlos O'Donell <carlos@redhat.com> Tested-by: Carlos O'Donell <carlos@redhat.com>
* Add TEST_COMPARE_STRING_WIDE to support/check.hJoseph Myers2021-10-1211-138/+448
| | | | | | | | | | | | | | | | | | | | | | | I'd like to be able to test narrow and wide string interfaces, with the narrow string tests using TEST_COMPARE_STRING and the wide string tests using something analogous (possibly generated using macros from a common test template for both the narrow and wide string tests where appropriate). Add such a TEST_COMPARE_STRING_WIDE, along with functions support_quote_blob_wide and support_test_compare_string_wide that it builds on. Those functions are built using macros from common templates shared by the narrow and wide string implementations, though I didn't do that for the tests of test functions. In support_quote_blob_wide, I chose to use the \x{} delimited escape sequence syntax proposed for C2X in N2785, rather than e.g. trying to generate the end of a string and the start of a new string when ambiguity would result from undelimited \x (when the next character after such an escape sequence is valid hex) or forcing an escape sequence to be used for the next character in the case of such ambiguity. Tested for x86_64.
* support: Also return fd when it is 0Siddhesh Poyarekar2021-10-061-7/+7
| | | | | | | | The fd validity check in open_dev_null checks if fd > 0, which would lead to a leaked fd if it is == 0. Signed-off-by: Siddhesh Poyarekar <siddhesh@sourceware.org> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* support: Add check for TID zero in support_wait_for_thread_exitFlorian Weimer2021-10-011-1/+4
| | | | | | | | | | | | | | | | Some kernel versions (observed with kernel 5.14 and earlier) can list "0" entries in /proc/self/task. This happens when a thread exits while the task list is being constructed. Treat this entry as not present, like the proposed kernel patch does: [PATCH] procfs: Do not list TID 0 in /proc/<pid>/task <https://lore.kernel.org/all/8735pn5dx7.fsf@oldenburg.str.redhat.com/> Fixes commit 032d74eaf6179100048a5bf0ce942e97dc8b9a60 ("support: Add support_wait_for_thread_exit"). Reviewed-by: Carlos O'Donell <carlos@redhat.com> Tested-by: Carlos O'Donell <carlos@redhat.com>
* support: Add support_mutex_pi_monotonicAdhemerval Zanella2021-10-013-0/+41
| | | | Returns true if Priority Inheritance support CLOCK_MONOTONIC.
* xsysconf: Only fail on error results and errno setStafford Horne2021-09-241-1/+1
| | | | | | | | | | | | | | | | When testing nptl/tst-pthread-attr-affinity-fail fails with: error: xsysconf.c:33: sysconf (83): Cannot allocate memory error: 1 test failures This happens as xsysconf checks the errno after running sysconf. Internally the sysconf request for _SC_NPROCESSORS_CONF on linux allocates memory. But there is a problem, even though malloc succeeds errno is getting set to ENOMEM. POSIX allows successful calls to clobber errno. So xsysconf just checking errno is wrong. Fix xsysconf by only failing if we have an error result and errno is set.
* time: Fix compile error in itimer test affecting hurdStafford Horne2021-09-161-0/+12
| | | | | | | | | | | | | | | | | | | | | The recent change to use __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 to avoid doing 64-bit checks on some platforms broke the test for hurd where __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 is not defined. With error: tst-itimer.c: In function 'do_test': tst-itimer.c:103:11: error: '__KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64' undeclared (first use in this function) 103 | if (__KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ tst-itimer.c:103:11: note: each undeclared identifier is reported only once for each function it appears in Define a support helper to detect when setitimer and getitimer support 64-bit time_t. Fixes commit 6e8a0aac2f ("time: Fix overflow itimer tests on 32-bit systems"). Cc: Adhemerval Zanella <adhemerval.zanella@linaro.org> Cc: Joseph Myers <joseph@codesourcery.com>
* support: Add support_wait_for_thread_exitFlorian Weimer2021-08-303-1/+78
|
* support: Add support_open_dev_null_rangeAdhemerval Zanella2021-08-264-0/+299
| | | | | | | | | It returns a range of file descriptor referring to the '/dev/null' pathname. The function takes care of restarting the open range if a file descriptor is found within the specified range and also increases RLIMIT_NOFILE if required. Checked on x86_64-linux-gnu.
* copy_and_spawn_sgid: Avoid double calls to close()Siddhesh Poyarekar2021-08-031-0/+1
| | | | | | | If close() on infd and outfd succeeded, reset the fd numbers so that we don't attempt to close them again. Reviewed-by: Arjun Shankar <arjun@redhat.com>
* tests: use xmalloc to allocate implementation arraySiddhesh Poyarekar2021-07-281-7/+17
| | | | | | | | The benchmark and tests must fail in case of allocation failure in the implementation array. Also annotate the x* allocators in support.h so that the compiler has more information about them. Reviewed-by: Florian Weimer <fweimer@redhat.com>
* support: Replace _SC_MINSIGSTKSZ with _SC_SIGSTKSZH.J. Lu2021-07-111-2/+2
| | | | | | | | | | | Replace _SC_MINSIGSTKSZ with _SC_SIGSTKSZ since sysconf (_SC_MINSIGSTKSZ) returns the minimum number of bytes of free stack space required in order to guarantee successful, non-nested handling of a single signal whose handler is an empty function while sysconf (_SC_SIGSTKSZ) returns the suggested minimum number of bytes of stack space required for a signal stack. Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* support: Replace MINSIGSTKSZ with sysconf (_SC_MINSIGSTKSZ)H.J. Lu2021-07-091-4/+5
| | | | | | | Replace MINSIGSTKSZ with sysconf (_SC_MINSIGSTKSZ) since the constant MINSIGSTKSZ used in glibc build may be too small. Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* Define PTHREAD_STACK_MIN to sysconf(_SC_THREAD_STACK_MIN)H.J. Lu2021-07-091-0/+1
| | | | | | | | | | | | | The constant PTHREAD_STACK_MIN may be too small for some processors. Rename _SC_SIGSTKSZ_SOURCE to _DYNAMIC_STACK_SIZE_SOURCE. When _DYNAMIC_STACK_SIZE_SOURCE or _GNU_SOURCE are defined, define PTHREAD_STACK_MIN to sysconf(_SC_THREAD_STACK_MIN) which is changed to MIN (PTHREAD_STACK_MIN, sysconf(_SC_MINSIGSTKSZ)). Consolidate <bits/local_lim.h> with <bits/pthread_stack_min.h> to provide a constant target specific PTHREAD_STACK_MIN value. Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* support: Add support_stack_allocAdhemerval Zanella2021-07-084-38/+107
| | | | | | | | | | | | The code to allocate a stack from xsigstack is refactored so it can be more generic. The new support_stack_alloc() also set PROT_EXEC if DEFAULT_STACK_PERMS has PF_X. This is required on some architectures (hppa for instance) and trying to access the rtld global from testsuite will require more intrusive refactoring in the ldsodefs.h header. Checked on x86_64-linux-gnu and i686-linux-gnu. I also ran tst-xsigstack on both hppa and ia64.
* support: Fix xclone build failures on ia64 and hppaFlorian Weimer2021-06-251-4/+3
|
* support: Add xcloneAdhemerval Zanella2021-06-243-0/+85
| | | | | | It is a wrapper for Linux clone syscall, to simplify the call to the use only the most common arguments and remove architecture specific handling (such as ia64 different name and signature).
* support: Add support_create_timerAdhemerval Zanella2021-06-223-0/+81
| | | | | | | | It is a simple wrapper over timer_create, timer_settime, and sigaction. It will be used to check for large timeout to trigger an EINTR and to avoid use a large timeout (as for alarm()). Reviewed-by: Lukasz Majewski <lukma@denx.de>
* libsupport: Add 64-bit time_t support for stat functionsAdhemerval Zanella2021-06-155-0/+112
| | | | | | | | | The patch adds redirections for xstat, xlstat, and xfstat when _TIME_BITS=64 is defined. Reviewed-by: Lukasz Majewski <lukma@denx.de> Reviewed-by: Carlos O'Donell <carlos@redhat.com> Tested-by: Carlos O'Donell <carlos@redhat.com>
* libsupport: Add 64-bit time_t support for time functionsAdhemerval Zanella2021-06-1511-19/+205
| | | | | | | | | | | The patch adds redirections for xclock_gettime, xclock_settime, timespec_add, timespec_sub, test_timespec_before_impl, test_timespec_equal_or_after_impl, support_timespec_ns, support_timespec_normalize, and support_timespec_check_in_range when _TIME_BITS=64 is defined. Co-authored-by: Lukasz Majewski <lukma@denx.de> Tested-by: Carlos O'Donell <carlos@redhat.com>
* io: Fix sporadic test failures in io/tst-statFlorian Weimer2021-06-101-1/+2
| | | | | | | | support_stat_nanoseconds cannot restore the ctime time, and this may lead to sporadic test failures. Therefore, probe for nanoseconds support before the initial statx call. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* support: Do not build xpthread_attr_setaffinity_np for hurdAdhemerval Zanella2021-05-282-0/+4
| | | | It does not provide pthread_attr_setaffinity_np extension.
* support: Add xpthread_attr_setaffinity_np wrapperAdhemerval Zanella2021-05-273-0/+32
|
* support: Free gdb_script_nameSiddhesh Poyarekar2021-05-131-0/+1
| | | | Identified by static analysis.
* support: Close fds in copy_funcSiddhesh Poyarekar2021-05-131-8/+13
| | | | | copy_func may leave file descriptors open on error, so close them on function exit.
* libsupport: Add support_select_normalizes_timeoutAdhemerval Zanella2021-04-123-0/+34
| | | | It will be used on a select() test.
* libsupport: Add support_select_modifies_timeoutAdhemerval Zanella2021-04-123-0/+34
| | | | It will be used on a select() test.
* support: Add capability to fork an sgid childSiddhesh Poyarekar2021-04-124-0/+150
| | | | | | | | | | | | | | | | | | | | Add a new function support_capture_subprogram_self_sgid that spawns an sgid child of the running program with its own image and returns the exit code of the child process. This functionality is used by at least three tests in the testsuite at the moment, so it makes sense to consolidate. There is also a new function support_subprogram_wait which should provide simple system() like functionality that does not set up file actions. This is useful in cases where only the return code of the spawned subprocess is interesting. This patch also ports tst-secure-getenv to this new function. A subsequent patch will port other tests. This also brings an important change to tst-secure-getenv behaviour. Now instead of succeeding, the test fails as UNSUPPORTED if it is unable to spawn a setgid child, which is how it should have been in the first place. Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* support: Fix hurd build after bfddda2570331dAdhemerval Zanella2021-04-011-1/+1
|
* io: Check at runtime if timestamp supports nanosecondsAdhemerval Zanella2021-03-312-8/+34
| | | | | | | | Now that non-LFS stat function is implemented on to on LFS, it will use statx when available. It allows to check for nanosecond timestamp if the kernel supports __NR_statx. Checked on s390-linux-gnu with 4.12.14 kernel.
* support: Add support_path_support_time64_valueAdhemerval Zanella2021-03-292-9/+12
| | | | It allows to check for support on arbitrary timestamp values.
* S390: Don't test nanoseconds in io/tst-stat.cStefan Liebler2021-03-263-0/+35
| | | | | | | | | | | Both new tests io/tst-stat and io/tst-stat-lfs (_FILE_OFFSET_BITS=64) are comparing the nanosecond fields with the statx result. Unfortunately on s390(31bit) those fields are always zero if old KABI with non-LFS support is used. With _FILE_OFFSET_BITS=64 stat is using statx internally. As suggested by Adhemerval this patch disables the nanosecond check for s390(31bit). Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* support: Use syscall function instead of INLINE_SYSCALL_CALLAdhemerval Zanella2021-03-181-1/+1
| | | | | It fixes the build on ARM in thumb mode that requires an out of the line helper (__libc_do_syscall) to issue the syscall.
* support: Pass environ to child processSiddhesh Poyarekar2021-03-161-1/+1
| | | | | Pass environ to posix_spawn so that the child process can inherit environment of the test.