casaroli opened a new pull request, #4022: URL: https://github.com/apache/nuttx-apps/pull/4022
depends-on: apache/nuttx/pull/21674 ## Summary This PR adds `testing/libc/sysconf` (`sysconf_test`), a test of `sysconf()`: - Each name of `<unistd.h>` gives a value, or -1 with `errno` unchanged. - -1, `INT_MIN` and `INT_MAX` give -1 with `EINVAL`. - Each limit with a constant in `<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`, ...). - Each option with a macro in `<unistd.h>` gives the value of the macro. A macro of 0 means "ask `sysconf()`": the test then accepts any value. - `_SC_OPEN_MAX` is the `RLIMIT_NOFILE` soft limit; `_SC_PAGE_SIZE` is `_SC_PAGESIZE` and > 0; `_SC_NPROCESSORS_ONLN` is from 1 to `_SC_NPROCESSORS_CONF`; `_SC_AVPHYS_PAGES` is 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 returns `EXIT_FAILURE` if 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 in `testing/libc`. ## Testing QEMU with HVF, 1 CPU. knsh: kernel build, the program from `/system/bin`. nsh: flat build, the program as a builtin. | Configuration | nuttx master 03aea786390 | nuttx with apache/nuttx#21674 | |---|---|---| | `qemu-armv8a:knsh` | 126 names, 144 errors | 139 names, 0 errors | | `qemu-armv8a:nsh` | 126 names, 143 errors | 139 names, 0 errors | | `qemu-armv8a:knsh` and `:nsh` with `PRIORITY_INHERITANCE`, `PRIORITY_PROTECT`, `FS_LARGEFILE`, `TLS_NELEM=8`, `LIBC_REGEX` | | 139 names, 0 errors; `_SC_THREAD_PRIO_INHERIT`, `_SC_THREAD_PRIO_PROTECT`, both `_SC_THREAD_ROBUST_PRIO_*` and `_SC_REGEXP` 201712, `_SC_THREAD_KEYS_MAX` 8, `_SC_V6_LP64_OFF64` 1 (knsh) | | `mps2-an500:knsh` (protected, QEMU TCG) | | 139 names, 0 errors | 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 that `sysconf()` does not give. On Linux (glibc 2.43, Fedora, gcc, the same source with `FAR` and `nitems()` defined): 132 names, 4 errors. glibc gives `EINVAL` for 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:nsh` with the test: OK, no compiler warning in the test. `tools/checkpatch.sh -c -u -m -g origin/master..HEAD` passes. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
