aboutsummaryrefslogtreecommitdiff
path: root/support
AgeCommit message (Collapse)AuthorFilesLines
2022-03-11debug: Synchronize feature guards in fortified functions [BZ #28746]Siddhesh Poyarekar1-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> (cherry picked from commit fcfc9086815bf0d277ad47a90ee3fda4c37acca8)
2022-02-01support: Add support_socket_so_timestamp_time64Adhemerval Zanella3-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> (cherry picked from 38bc0f4e78934aab455b31af05cefcbf3c22bece)
2022-01-24support: Add helpers to create paths longer than PATH_MAXSiddhesh Poyarekar2-10/+160
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> (cherry picked from commit fb7bff12e81c677a6622f724edd4d4987dd9d971)
2021-10-06support: Also return fd when it is 0Siddhesh Poyarekar1-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> (cherry picked from commit 27b6edbb090f736b101f569620d8ad0e7217ddf8)
2021-10-01support: Add check for TID zero in support_wait_for_thread_exitFlorian Weimer1-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> (cherry picked from commit 176c88f5214d8107d330971cbbfbbba5186a111f)
2021-09-21support: Add support_open_dev_null_rangeAdhemerval Zanella4-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. (cherry picked from commit e814f4b04ee413a7bb3dfa43e74c8fb4abf58359)
2021-09-13support: Add support_wait_for_thread_exitFlorian Weimer3-1/+78
(cherry picked from commit 032d74eaf6179100048a5bf0ce942e97dc8b9a60)
2021-08-04copy_and_spawn_sgid: Avoid double calls to close()Siddhesh Poyarekar1-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> (cherry picked from commit 45caed9d67a00af917d8b5b88d4b5eb1225b7aef)
2021-07-28tests: use xmalloc to allocate implementation arraySiddhesh Poyarekar1-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>
2021-07-11support: Replace _SC_MINSIGSTKSZ with _SC_SIGSTKSZH.J. Lu1-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>
2021-07-09support: Replace MINSIGSTKSZ with sysconf (_SC_MINSIGSTKSZ)H.J. Lu1-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>
2021-07-09Define PTHREAD_STACK_MIN to sysconf(_SC_THREAD_STACK_MIN)H.J. Lu1-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>
2021-07-08support: Add support_stack_allocAdhemerval Zanella4-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.
2021-06-25support: Fix xclone build failures on ia64 and hppaFlorian Weimer1-4/+3
2021-06-24support: Add xcloneAdhemerval Zanella3-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).
2021-06-22support: Add support_create_timerAdhemerval Zanella3-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>
2021-06-15libsupport: Add 64-bit time_t support for stat functionsAdhemerval Zanella5-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>
2021-06-15libsupport: Add 64-bit time_t support for time functionsAdhemerval Zanella11-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>
2021-06-10io: Fix sporadic test failures in io/tst-statFlorian Weimer1-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>
2021-05-28support: Do not build xpthread_attr_setaffinity_np for hurdAdhemerval Zanella2-0/+4
It does not provide pthread_attr_setaffinity_np extension.
2021-05-27support: Add xpthread_attr_setaffinity_np wrapperAdhemerval Zanella3-0/+32
2021-05-13support: Free gdb_script_nameSiddhesh Poyarekar1-0/+1
Identified by static analysis.
2021-05-13support: Close fds in copy_funcSiddhesh Poyarekar1-8/+13
copy_func may leave file descriptors open on error, so close them on function exit.
2021-04-12libsupport: Add support_select_normalizes_timeoutAdhemerval Zanella3-0/+34
It will be used on a select() test.
2021-04-12libsupport: Add support_select_modifies_timeoutAdhemerval Zanella3-0/+34
It will be used on a select() test.
2021-04-12support: Add capability to fork an sgid childSiddhesh Poyarekar4-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>
2021-04-01support: Fix hurd build after bfddda2570331dAdhemerval Zanella1-1/+1
2021-03-31io: Check at runtime if timestamp supports nanosecondsAdhemerval Zanella2-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.
2021-03-29support: Add support_path_support_time64_valueAdhemerval Zanella2-9/+12
It allows to check for support on arbitrary timestamp values.
2021-03-26S390: Don't test nanoseconds in io/tst-stat.cStefan Liebler3-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>
2021-03-18support: Use syscall function instead of INLINE_SYSCALL_CALLAdhemerval Zanella1-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.
2021-03-16support: Pass environ to child processSiddhesh Poyarekar1-1/+1
Pass environ to posix_spawn so that the child process can inherit environment of the test.
2021-03-15support: Typo and formatting fixesSiddhesh Poyarekar2-4/+4
- Add a newline to the end of error messages in transfer(). - Fixed the name of support_subprocess_init().
2021-03-12support: Add xpthread_killAdhemerval Zanella3-0/+29
Checked on x86_64-linux-gnu.
2021-03-12io: Return UNSUPPORTED if filesystem do not support 64 bit timestampsAdhemerval Zanella3-0/+82
Some Linux filesystems might not fully support 64 bit timestamps [1], which make some Linux specific tests to fail when they check for the functionality. This patch adds a new libsupport function, support_path_support_time64, that returns whether the target file supports or not 64 bit timestamps. The support is checked by issuing a utimensat and verifying both the last access and last modification time against a statx call. The tests that might fail are also adjusted to check the file support as well: $ dd if=/dev/zero of=loopbackfile.img bs=100M count=1 1+0 records in 1+0 records out 104857600 bytes (105 MB, 100 MiB) copied, 0,0589568 s, 1,8 GB/s $ sudo losetup -fP loopbackfile.img $ mkfs.xfs loopbackfile.img meta-data=loopbackfile.img isize=512 agcount=4, agsize=6400 blks = sectsz=512 attr=2, projid32bit=1 = crc=1 finobt=1, sparse=1, rmapbt=0 = reflink=1 data = bsize=4096 blocks=25600, imaxpct=25 = sunit=0 swidth=0 blks naming =version 2 bsize=4096 ascii-ci=0, ftype=1 log =internal log bsize=4096 blocks=1368, version=2 = sectsz=512 sunit=0 blks, lazy-count=1 realtime =none extsz=4096 blocks=0, rtextents=0 $ mkdir loopfs $ sudo mount -o loop /dev/loop0 loopfs/ $ sudo chown -R azanella:azanella loopfs $ TMPDIR=loopfs/ ./testrun.sh misc/tst-utimes error: ../sysdeps/unix/sysv/linux/tst-utimes.c:55: File loopfs//utimesfECsK1 does not support 64-bit timestamps [1] https://bugzilla.redhat.com/show_bug.cgi?id=1795576
2021-03-11test-container: Always copy test-specific support files [BZ #27537]DJ Delorie1-11/+12
There's a small chance that a fresh checkout will result in some of the test-specific container files will have the same timestamp and size, which breaks the rsync logic in test-container, resulting in tests running with the wrong support files. This patch changes the rsync logic to always copy the test-specific files, which normally would always be copied anyway. The rsync logic for the testroot itself is unchanged.
2021-03-08support: Provide xclock_settime test helper functionLukasz Majewski3-0/+40
The xclock_settime is a wrapper function on the clock_settime syscall to be used in the test code. It checks if the GLIBC_TEST_ALLOW_TIME_SETTING env variable is defined in the environment in which test is executed. If it is not - the test ends as unsupported. Otherwise, the clock-settime is executed and return value is assessed. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2021-01-29elf: Fix tests that rely on ld.so.cache for cross-compilingAdhemerval Zanella1-0/+26
For configurations with cross-compiling equal to 'maybe' or 'no', ldconfig will not run and thus the ld.so.cache will not be created on the container testroot.pristine. This lead to failures on both tst-glibc-hwcaps-prepend-cache and tst-ldconfig-ld_so_conf-update on environments where the same compiler can be used to build different ABIs (powerpc and x86 for instance). This patch addas a new test-container hook, ldconfig.run, that triggers a ldconfig execution prior the test execution. Checked on x86_64-linux-gnu and i686-linux-gnu.
2021-01-11posix: Fix return value of system if shell can not be executed [BZ #27053]Adhemerval Zanella1-0/+1
POSIX states that system returned code for failure to execute the shell shall be as if the shell had terminated using _exit(127). This behaviour was removed with 5fb7fc96350575. Checked on x86_64-linux-gnu.
2021-01-11support: Add xchmod wrapperAdhemerval Zanella2-0/+31
Checked on x86_64-linux-gnu.
2021-01-10 Add xfchmod to libsupportAlexandra Hájková3-0/+30
2021-01-09Add xchdir to libsupport.Alexandra Hájková3-0/+30
2021-01-05support: Add support_small_thread_stack_sizeAdhemerval Zanella2-3/+11
It returns the minimum stack size large enough to cover most internal glibc stack usage.
2021-01-02Update copyright dates with scripts/update-copyrightsPaul Eggert205-205/+205
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 6694 files FOO. I then removed trailing white space from benchtests/bench-pthread-locks.c and iconvdata/tst-iconv-big5-hkscs-to-2ucs4.c, to work around this diagnostic from Savannah: remote: *** pre-commit check failed ... remote: *** error: lines with trailing whitespace found remote: error: hook declined to update refs/heads/master
2020-12-28support: Make support_process_state_wait wait lessSamuel Thibault1-1/+1
Tests such as posix/tst-waitid.c make heavy use of support_process_state_wait, and thus on non-Linux where it falls back to sleeping, a 2s sleep makes such test time out, while 1s remains fine enough.
2020-12-11support: Add support_slibdir_prefix variableFlorian Weimer3-0/+10
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2020-11-26support: Add support_copy_fileFlorian Weimer3-0/+49
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2020-10-16support: Add create_temp_file_in_dirAdhemerval Zanella2-4/+15
It allows created a temporary file in a specified directory.
2020-10-14support: Provide a way to clear the RA bit in DNS server responsesFlorian Weimer2-1/+7
2020-10-14support: Provide a way to reorder responses within the DNS test serverFlorian Weimer5-28/+135