Repository navigation
testing/libc/sysconf: Add a test of sysconf() - #4022
Merged
Merged
Conversation
Check that sysconf() gives a value, or -1 with errno unchanged, for each name of <unistd.h>, and -1 with EINVAL for a name that is not valid. Check that the names of a limit or an option give the value of its constant in <limits.h>, <signal.h>, <time.h> or <unistd.h>, that _SC_OPEN_MAX is the RLIMIT_NOFILE soft limit, and that the processor, page and compilation environment names give sane values. Assisted-by: Claude Code:claude-opus-5-5 Signed-off-by: Marco Casaroli <[email protected]>
xiaoxiang781216
approved these changes
Nov 12, 2026
🔗 Cross-repo PR dependenciesThe read-only Build run reported the following dependent PR(s) and fetched head SHA(s): |
casaroli
marked this pull request as draft
November 12, 2026 14:09
casaroli
marked this pull request as ready for review
November 12, 2026 14:09
🔗 Cross-repo PR dependenciesThe read-only Build run reported the following dependent PR(s) and fetched head SHA(s):
|
GUIDINGLI
approved these changes
Nov 13, 2026
casaroli
marked this pull request as draft
November 13, 2026 09:31
casaroli
marked this pull request as ready for review
November 13, 2026 09:31
🔗 Cross-repo PR dependenciesThe read-only Build run reported the following dependent PR(s) and fetched head SHA(s): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
depends-on: /pull/4033
Summary
This PR adds
testing/libc/sysconf(sysconf_test), a test ofsysconf():<unistd.h>gives a value, or -1 witherrnounchanged.INT_MINandINT_MAXgive -1 withEINVAL.<limits.h>,<signal.h>or<time.h>gives the value of the constant (ARG_MAX,HOST_NAME_MAX,IOV_MAX,LINE_MAX,PTHREAD_KEYS_MAX,NSIG,CLK_TCK, ...).<unistd.h>gives the value of the macro. A macro of 0 means "asksysconf()": the test then accepts any value._SC_OPEN_MAXis theRLIMIT_NOFILEsoft limit;_SC_PAGE_SIZEis_SC_PAGESIZEand > 0;_SC_NPROCESSORS_ONLNis from 1 to_SC_NPROCESSORS_CONF;_SC_AVPHYS_PAGESis from 0 to_SC_PHYS_PAGES; at most one C compilation environment gives 1, and_SC_V7_*,_SC_V8_*give the same as_SC_V6_*.The program prints each error and
sysconf test: <names> names, <errors> errors, and returnsEXIT_FAILUREif there is an error. The names that only apache/nuttx#21674 defines are under#ifdef, so the test also builds on older nuttx.Impact
Test only. New option
CONFIG_TESTING_SYSCONF, default n like the other tests intesting/libc.Testing
QEMU with HVF, 1 CPU. knsh: kernel build, the program from
/system/bin. nsh: flat build, the program as a builtin.qemu-armv8a:knshqemu-armv8a:nshqemu-armv8a:knshand:nshwithPRIORITY_INHERITANCE,PRIORITY_PROTECT,FS_LARGEFILE,TLS_NELEM=8,LIBC_REGEX_SC_THREAD_PRIO_INHERIT,_SC_THREAD_PRIO_PROTECT, both_SC_THREAD_ROBUST_PRIO_*and_SC_REGEXP201712,_SC_THREAD_KEYS_MAX8,_SC_V6_LP64_OFF641 (knsh)mps2-an500:knsh(protected, QEMU TCG)On master, 106 valid names and the invalid names give -1 with
ENOSYS, so the test sees an error for each of them and for each constant thatsysconf()does not give.On Linux (glibc 2.43, Fedora, gcc, the same source with
FARandnitems()defined): 132 names, 4 errors. glibc givesEINVALfor 3 valid names (_SC_SS_REPL_MAX,_SC_THREAD_ROBUST_PRIO_INHERIT,_SC_THREAD_ROBUST_PRIO_PROTECT) and has more than one compilation environment (multilib).CMake (Ninja) build of
qemu-armv8a:nshwith the test: OK, no compiler warning in the test.tools/checkpatch.sh -c -u -m -g origin/master..HEADpasses.