aboutsummaryrefslogtreecommitdiff
path: root/support
AgeCommit message (Collapse)AuthorFilesLines
12 hourssupport: Add support_accept_oom to heuristically support OOM errorsFlorian Weimer6-1/+183
Some tests may trigger the kernel OOM handler under conditions which are difficult to predict (depending on available RAM and swap space). If we can determine specific regions which might do this and this does not contradict the test object, the functions support_accept_oom (true) and support_accept_oom (false) can be called at the start and end, and the test driver will ignore SIGKILL signals. Reviewed-by: Carlos O'Donell <carlos@redhat.com>
41 hourssupport: fix build failure due to lack of stdbool.hYury Khrustalev2-0/+4
On some targets using bool in support/check_mem_access.h resulted in build error due to stdbool.h not being included, fix this. See 9be489d77867dd2444ecc044a5f3049d1751ee85 for details. Reported-by: Joseph Myers <josmyers@redhat.com> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 dayssupport: add check_mem_access functionYury Khrustalev3-0/+98
Add check_mem_access(addr) function to check if memory at addr can be written or read returning false if memory is not accessible. This function changes signal handler for SIGSEGV and SIGBUS signals when it is called first, and it is not thread-safe. Co-authored-by: Adhemerval Zanella Netto <adhemerval.zanella@linaro.org> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
14 dayssupport: Implement 'xfmemopen' for seamless 'fmemopen' useMaciej W. Rozycki3-0/+33
Add 'xfmemopen' wrapper for seamless 'fmemopen' use in tests, following 'xfopen', 'xfclose', etc., and providing a standardized error reporting facility. Reviewed-by: Florian Weimer <fweimer@redhat.com>
2025-09-01Tests: Create files with mode 0666, not 0777 (bug 33171)Florian Weimer2-5/+5
Mode 0777 should be used for directories only because it results in executable entries (after typical umasks are applied). Reviewed-by: Arjun Shankar <arjun@redhat.com>
2025-08-27elf: early conversion of elf p_flags to mprotect flagsCupertino Miranda1-5/+4
This patch replaces _dl_stack_flags global variable by _dl_stack_prot_flags. The advantage is that any convertion from p_flags to final used mprotect flags occurs at loading of p_flags. It avoids repeated spurious convertions of _dl_stack_flags, for example in allocate_thread_stack. This modification was suggested in: https://sourceware.org/pipermail/libc-alpha/2025-March/165537.html Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2025-08-19support: Handle FUSE_GETXATTR during FUSE FS mountArjun Shankar1-1/+5
When testing with some kernel versions, support FUSE infrastructure encounters a FUSE_GETXATTR request, leading to FUSE tests hanging until timed out. Therefore, pass FUSE_GETXATTR requests from support_fuse_handle_mountpoint to support_fuse_handle_directory, and adjust support_fuse_handle_directory to return ENOSYS so that tests can proceed. Reviewed-by: Florian Weimer <fweimer@redhat.com>
2025-08-04Delete temporary files in support_subprocessH.J. Lu1-0/+3
Call support_delete_temp_files to delete temporary files before exit in support_subprocess. This partially fixes BZ #33182. Signed-off-by: H.J. Lu <hjl.tools@gmail.com> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2025-08-03hurd: support: Fix running SGID testsSamuel Thibault1-0/+21
Secure mode is enabled only if SGID actually provides a new privilege, so we have to drop it before gaining it again. Fixes commit 3a3fb2ed83f79100c116c824454095ecfb335ad7 ("Fix error reporting (false negatives) in SGID tests")
2025-08-03support: Handle COPY_FILE_RANGE events with FUSEFlorian Weimer1-0/+1
2025-07-09support: Always run ldconfig in containered testsAndreas K. Hüttel1-1/+1
This is required so the generated ld.so.conf files take effect. Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2025-05-22Fix error reporting (false negatives) in SGID testsFlorian Weimer2-87/+29
And simplify the interface of support_capture_subprogram_self_sgid. Use the existing framework for temporary directories (now with mode 0700) and directory/file deletion. Handle all execution errors within support_capture_subprogram_self_sgid. In particular, this includes test failures because the invoked program did not exit with exit status zero. Existing tests that expect exit status 42 are adjusted to use zero instead. In addition, fix callers not to call exit (0) with test failures pending (which may mask them, especially when running with --direct). Fixes commit 35fc356fa3b4f485bd3ba3114c9f774e5df7d3c2 ("elf: Fix subprocess status handling for tst-dlopen-sgid (bug 32987)"). Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2025-05-21support: Pick group in support_capture_subprogram_self_sgid if UID == 0Florian Weimer1-4/+54
When running as root, it is likely that we can run under any group. Pick a harmless group from /etc/group in this case. Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2025-05-20support: Use const char * argument in support_capture_subprogram_self_sgidFlorian Weimer2-5/+4
The function does not modify the passed-in string, so make this clear via the prototype. Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2025-04-01add ptmx support to test-containerDJ Delorie4-0/+67
2025-03-26support: Use unwinder in links-dso-program-c only with libgcc_sFlorian Weimer1-1/+1
Do not build links-dso-program-c with exception (unwinding) support if libgcc_s is not available. In this case, the unwinder may be part of libgcc.a or libgcc_eh.a, depending on how GCC was built. If the unwinder is in libgcc_eh.a only, linking links-dso-program-c failed before this change. After this change, the exception handling landing pad is only generated if libgcc_s available, avoiding an undefined _Unwind_Resume (or equivalent) symbol reference in the non-libgcc_s case. Fixes commit ffd36cc27407003a6f9efcb9c16370e3435c5b1d ("support: Use unwinder in links-dso-program-c only with libgcc_s") and commit 5dfbc3c43ecc1bcfc760a032c91bb002660051bc ("support: Link links-dso-program-c with libgcc_s only if available").
2025-03-21support: Link links-dso-program-c with libgcc_s only if availableFlorian Weimer1-1/+4
Add a configure check to detect bootstrapping builds that do not have libgcc_s. Fixes commit 3e2be87832781a29ed67f38f87c1ce3dd4c1b866 ("support: Link links-dso-program-c against libgcc_s"). Reviewed-by: Sam James <sam@gentoo.org>
2025-03-21support: Link links-dso-program-c against libgcc_sFlorian Weimer2-0/+22
If C++ support is not available, links-dso-program-c is used instead of the C++ version. The C version was not linked against libgcc_s, which meant that thread cancellation and the backtrace function did not work in containers tests in that situation. Reviewed-by: Sam James <sam@gentoo.org>
2025-02-24support: Add support_next_to_fault_before support functionFrédéric Bérat2-10/+39
Refactor the support_next_to_fault and add the support_next_to_fault_before method returns a buffer with a protected page before it, to be able to test buffer underflow accesses. Reviewed-by: Tulio Magno Quites Machado Filho <tuliom@redhat.com>
2025-02-13nss: Improve network number parsers (bz 32573, 32575)Tobias Stoeckmann2-0/+4
Make sure that numbers never overflow uint32_t in inet_network to properly validate octets encountered in IPv4 addresses. Avoid malloca in NSS networks file code because /etc/networks lines can be arbitrarily long. Instead of handcrafting the input for inet_network by adding ".0" octets if they are missing, just left shift the result. Also, do not accept invalid entries, but ignore the line instead. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org> Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2025-01-07tst-xdirent: Fix allocating dirent for readdir_r callSamuel Thibault1-4/+8
As documented in the glibc manual, “Some systems don’t define the d_name element sufficiently long”, and it provides an example of using a union to properly allocate the storage under the dirent.
2025-01-01Fix license typo induced by update-copyrighytPaul Eggert1-1/+1
2025-01-01Update copyright dates with scripts/update-copyrightsPaul Eggert269-269/+269
2024-12-23support: Add support_record_failure_barrierFlorian Weimer2-0/+13
This can be used to stop execution after a TEST_COMPARE_BLOB failure, for example.
2024-12-18tst-timespec.c: Explicitly cast TIME_T_MAX to doubleH.J. Lu1-1/+1
Explicitly cast TIME_T_MAX to double in tst-timespec.c to silence Clang error: tst-timespec.c:290:19: error: implicit conversion from 'time_t' (aka 'long') to 'double' changes value from 9223372036854775807 to 9223372036854775808 [-Werror,-Wimplicit-const-int-float-conversion] 287 | {.expected = {.tv_sec = 0, .tv_nsec = 1}, | ~ 288 | .observed = {.tv_sec = TIME_T_MAX / TIMESPEC_HZ, 289 | .tv_nsec = TIMESPEC_HZ - 1}, 290 | .upper_bound = TIME_T_MAX, .lower_bound = 1, .result = 1, | ^~~~~~~~~~ Signed-off-by: H.J. Lu <hjl.tools@gmail.com> Reviewed-by: Sam James <sam@gentoo.org>
2024-12-10malloc: add indirection for malloc(-like) functions in tests [BZ #32366]Sam James1-1/+1
GCC 15 introduces allocation dead code removal (DCE) for PR117370 in r15-5255-g7828dc070510f8. This breaks various glibc tests which want to assert various properties of the allocator without doing anything obviously useful with the allocated memory. Alexander Monakov rightly pointed out that we can and should do better than passing -fno-malloc-dce to paper over the problem. Not least because GCC 14 already does such DCE where there's no testing of malloc's return value against NULL, and LLVM has such optimisations too. Handle this by providing malloc (and friends) wrappers with a volatile function pointer to obscure that we're calling malloc (et. al) from the compiler. Reviewed-by: Paul Eggert <eggert@cs.ucla.edu>
2024-11-25Silence most -Wzero-as-null-pointer-constant diagnosticsAlejandro Colomar7-14/+14
Replace 0 by NULL and {0} by {}. Omit a few cases that aren't so trivial to fix. Link: <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117059> Link: <https://software.codidact.com/posts/292718/292759#answer-292759> Signed-off-by: Alejandro Colomar <alx@kernel.org>
2024-11-12support: Add xdupSiddhesh Poyarekar3-0/+32
Add xdup as the error-checking version of dup for test cases. Signed-off-by: Siddhesh Poyarekar <siddhesh@sourceware.org> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2024-10-16support: Make support_process_state_wait return the found stateAdhemerval Zanella3-8/+24
So caller can check which state was found if multiple ones are asked. Checked on x86_64-linux-gnu. Reviewed-by: Florian Weimer <fweimer@redhat.com>
2024-09-21support: Add valgrind instructions to <support/fuse.h>Florian Weimer1-2/+4
Replacing an outdated comment (namespace setup is now handled by support_fuse_init).
2024-09-21support: Fix memory leaks in FUSE testsFlorian Weimer2-0/+2
The internal read buffer (used by all FUSE tests) was not freed. The support/tst-support_fuse test missed a deallocation.
2024-09-12support: Fix Hurd build of tst-support_readdirFlorian Weimer1-4/+7
Check for the availability of the d_off member at compile time, not run time. Fixes commit 1251e9ea49fba9f53bbf4f290f3db90c01931fa7 ("support: Add <support/readdir.h>").
2024-09-12support: Add <support/readdir.h>Florian Weimer4-0/+475
It allows to read directories using the six readdir variants without writing type-specific code or using skeleton files that are compiled four times. The readdir_r subtest for support_readdir_expect_error revealed bug 32124. Reviewed-by: DJ Delorie <dj@redhat.com>
2024-09-05support: Add FUSE-based file system test framework to support/Florian Weimer4-0/+1270
This allows to monitor the exact file system operations performed by glibc and inject errors. Hurd does not have <sys/mount.h>. To get the sources to compile at least, the same approach as in support/test-container.c is used. Reviewed-by: DJ Delorie <dj@redhat.com>
2024-09-05support: Add <support/xdirent.h>Florian Weimer8-0/+321
Use static functions for readdir/readdir_r, so that -D_FILE_OFFSET_BITS=64 does not improperly redirect calls to the wrong implementation. Reviewed-by: DJ Delorie <dj@redhat.com>
2024-09-05Bundle <linux/fuse.h> userspace header from Linux 6.10Florian Weimer5-0/+1597
And include the required licensing information. The only change is a removed trailing empty line in LICENSES/exceptions/Linux-syscall-note. Bundling <linux/fuse.h> is the recommended way to deal with the evolution of the FUSE userspace interface because structs change sizes over time. The kernel maintains compatibility, but source-level compatibility on recompilation may require additional code that is aware of older struct sizes. Signed-off-by: Florian Weimer <fweimer@redhat.com> Reviewed-by: DJ Delorie <dj@redhat.com>
2024-09-03Add support/ code for checking file contentsJoseph Myers6-0/+202
For use in freopen tests, add various support/ helper interfaces for use in checking file contents. Tested for x86_64.
2024-08-26support: Report errno constants in TEST_COMPARE failuresFlorian Weimer1-1/+10
If the expression is errno, decode it as an errno constant using strerrorname_np. Reviewed-by: Arjun Shankar <arjun@redhat.com>
2024-08-16support: Use macros for *stat wrappersFlorian Weimer8-159/+25
Macros will automatically use the correct types, without having to fiddle with internal glibc macros. It's also impossible to get the types wrong due to aliasing because support_check_stat_fd and support_check_stat_path do not depend on the struct stat* types. The changes reveal some inconsistencies in tests. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2024-08-16support: Add the xstatx functionFlorian Weimer3-0/+35
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2024-08-16support: Include <string.h> for strcmp in support_format_addrinfo.cFlorian Weimer1-0/+1
This is currently implied by the internal headers, but it makes sense not to rely on this. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2024-08-16support: Remove #include <config.h>Florian Weimer2-2/+0
This is not needed: include/intprops.h has its own detection logic. It makes building these files outside of glibc easer. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2024-08-09support: Add options list terminator to the test driverFlorian Weimer1-0/+1
This avoids crashes if a test is passed unknown options. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2024-07-26support: Add FAIL test failure helperMaciej W. Rozycki1-0/+5
Add a FAIL test failure helper analogous to FAIL_RET, that does not cause the current function to return, providing a standardized way to report a test failure with a message supplied while permitting the caller to continue executing, for further reporting, cleaning up, etc. Update existing test cases that provide a conflicting definition of FAIL by removing the local FAIL definition and then as follows: - tst-fortify-syslog: provide a meaningful message in addition to the file name already added by <support/check.h>; 'support_record_failure' is already called by 'support_print_failure_impl' invoked by the new FAIL test failure helper. - tst-ctype: no update to FAIL calls required, with the name of the file and the line number within of the failure site additionally included by the new FAIL test failure helper, and error counting plus count reporting upon test program termination also already provided by 'support_record_failure' and 'support_report_failure' respectively, called by 'support_print_failure_impl' and 'adjust_exit_status' also respectively. However in a number of places 'printf' is called and the error count adjusted by hand, so update these places to make use of FAIL instead. And last but not least adjust the final summary just to report completion, with any error count following as reported by the test driver. - test-tgmath2: no update to FAIL calls required, with the name of the file of the failure site additionally included by the new FAIL test failure helper. Also there is no need to track the return status by hand as any call to FAIL will eventually cause the test case to return an unsuccesful exit status regardless of the return status from the test function, via a call to 'adjust_exit_status' made by the test driver. Reviewed-by: DJ Delorie <dj@redhat.com>
2024-06-17support: Include <limits.h> for NAME_MAX use in temp_file.cFlorian Weimer1-0/+1
2024-06-17support: Include <stdlib.h> for atoi use in support_wait_for_thread_exitFlorian Weimer1-0/+1
2024-06-05support: Fix typo in xgetsockname error messageAvinal Kumar1-1/+2
The error message in xgetsockname was incorrectly referring to a different function. This commit fixes that. Suggested-by: Arjun Shankar <arjun@redhat.com> Signed-off-by: Avinal Kumar <avinal.xlvii@gmail.com> Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2024-05-07support: Add envp argument to support_capture_subprogramAdhemerval Zanella5-12/+16
So tests can specify a list of environment variables. Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
2024-04-10libsupport: Add xgetpeernameSergey Kolosov3-0/+32
The patch adds redirections for getpeername. Reviewed-by: Arjun Shankar <arjun@redhat.com>
2024-04-02Always define __USE_TIME_BITS64 when 64 bit time_t is usedAdhemerval Zanella3-3/+3
It was raised on libc-help [1] that some Linux kernel interfaces expect the libc to define __USE_TIME_BITS64 to indicate the time_t size for the kABI. Different than defined by the initial y2038 design document [2], the __USE_TIME_BITS64 is only defined for ABIs that support more than one time_t size (by defining the _TIME_BITS for each module). The 64 bit time_t redirects are now enabled using a different internal define (__USE_TIME64_REDIRECTS). There is no expected change in semantic or code generation. Checked on x86_64-linux-gnu, i686-linux-gnu, aarch64-linux-gnu, and arm-linux-gnueabi [1] https://sourceware.org/pipermail/libc-help/2024-January/006557.html [2] https://sourceware.org/glibc/wiki/Y2038ProofnessDesign Reviewed-by: DJ Delorie <dj@redhat.com>