aboutsummaryrefslogtreecommitdiff
path: root/lib/libc/tests
Commit message (Collapse)AuthorAgeFilesLines
* libc/test: fix typoRobert Clausecker5 days1-1/+1
| | | | | | | I misapplied ngie's recommended correction. Fixes: 123c086200491819595abc271d360e605288fd18 Differential Revision: https://reviews.freebsd.org/D54169
* libc/tests/string: improve stpncpy() "bounds" unit testRobert Clausecker5 days1-16/+39
| | | | | | | | | | | | | | | | The test is extended the same way I previously extended the memccpy() test to fix what is probably the same kind of bug. PR: 291359 Reported by: Collin Funk <collin.funk1@gmail.com> Reviewed by: ngie Approved by: markj (mentor) Fixes: 6fa9e7d8737548ef93c573387ce62402c368d486 (D42519) See also: 61ed5748e4e9c7397fcb2638b442f46ac5c9e7c5 (D46051) MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D54169 lib/libc/tests/string/stpncpy_test.c: apply ngie's fixes
* libc/limits_test: add no-op testcase to satisfy kyuaSiva Mahadevan14 days1-1/+4
| | | | | | | | | | | | | This test suite is purely tested with compile-time assertions, so it needs a dummy runtime test to ensure that kyua reports the file as passing. Pull Request: https://github.com/freebsd/freebsd-src/pull/1915 Sponsored by: The FreeBSD Foundation Reviewed by: fuz Approved by: markj (mentor) MFC after: 1 month Signed-off-by: Siva Mahadevan <me@svmhdvn.name>
* libc: Fix TESTSDIR for new stdbit testsJessica Clarke2025-12-011-0/+2
| | | | | | | | | | Otherwise the directory created by etc/mtree/BSD.tests.dist, which is where these belong, and referred to by the generated Kyuafile for /usr/tests/lib/libc (via stdbit's existence in TESTS_SUBDIRS), ends up empty with no Kyuafile, which is an error for kyua. Reported by: kp Fixes: 2fb8cbc6ef1b ("libc/tests: add stdbit test framework and unit tests")
* libc/tests: add stdbit test framework and unit testsRobert Clausecker2025-11-3018-0/+511
| | | | | | | | | | | | This adds unit tests for all 70 functions in <stdbit.h>. I'm sorry for the test framework, but it makes it so I don't have to write 70 unit tests by hand. Reviewed by: adrian, des Approved by: markj (mentor) MFC after: 1 month Differential Revision: https://reviews.freebsd.org/D53660
* libc/tests: add test for *_MAX, *_MIN, and *_WIDTHRobert Clausecker2025-11-302-0/+102
| | | | | | | | | | This file checks the correctness of the various _MAX, _MIN, and _WIDTH macros defined for the libc types. It assumes that none of the types have padding bits. Approved by: markj (mentor) MFC after: 1 month Differential Revision: https://reviews.freebsd.org/D53831
* strfmon: Fix negative sign handling for C localeJose Luis Duran2025-11-261-3/+3
| | | | | | | | | | | | | | | | | | | If the locale's positive_sign and negative_sign values would both be returned by localeconv() as empty strings, strfmon() shall behave as if the negative_sign value was the string "-". This occurs with the C locale. The implementation previously assigned "0" to sign_posn (parentheses around the entire string); now it assigns it to "1" (sign before the string) when it is undefined (CHAR_MAX). Austin Group Defect 1199[1] is applied, changing the requirements for the '+' and '(' flags. [1]: https://www.austingroupbugs.net/view.php?id=1199 Reviewed by: kib MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D53913
* strfmon: EINVAL if the '+' flag and both signs are emptyJose Luis Duran2025-11-261-4/+4
| | | | | | | | | | | | | | | | According to the Open Group Base Specifications Issue 8[1], strfmon(3) should return EINVAL when the '+' flag was included in a conversion specification and the locale's positive_sign and negative_sign values would both be returned by localeconv(3) as empty strings. Austin Group Defect 1199[2] is applied, adding the [EINVAL] error. [1]: https://pubs.opengroup.org/onlinepubs/9799919799/functions/strfmon.html [2]: https://www.austingroupbugs.net/view.php?id=1199 Reviewed by: kib MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D53912
* strfmon: Add tests for Austin Group Defect 1199Jose Luis Duran2025-11-261-23/+57
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Add tests for The Open Group Base Specifications Issue 8[1], Austin Group Defect 1199[2]. Items marked with XXX represent an invalid output. These items will be fixed in subsequent commits. Notice that an existing test is now considered invalid. Our locale definitions do not include int_p_sep_by_space nor int_n_sep_by_space[3]. Those will be addressed in a subsequent commit. However, the CLDR project defines them as "0", which causes the output to appear as "USD123.45". If our locale definitions were to set the international {n,p}_sep_by_space to "1", the output would display as the expected "USD 123.45". While here, use the SPDX license identifier and add my name to the file. [1]: https://pubs.opengroup.org/onlinepubs/9799919799/functions/strfmon.html [2]: https://www.austingroupbugs.net/view.php?id=1199 [3]: https://unicode-org.atlassian.net/browse/CLDR-237 Reviewed by: kib MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D53911
* libc: report _SC_NPROCESSORS_ONLN more accurately in cpu-limited jailsKyle Evans2025-10-291-3/+137
| | | | | | | | | | | | | | | | | | | | | We don't support CPU hotplug, but we do support cpuset(8) restrictions on jails (including prison0, which uses cpuset 1). The process cannot widen its cpuset beyond its root set, so it makes sense to instead report the number of cpus enabled there rather than the total number in the system. This change is effectively a nop for the majority of systems and jails in the wild, though it does reduce the performance of this query now that we can't take advantage of AT_NCPUS being provided in the auxinfo. The implementation here is notably different than Linux, which would not take cgroups into account. They do, however, take CPU hotplug into account, so the possibility for it to diverge from (and be lower than) the # configured count to reflect what the process can actually be scheduled on doesn't really diverge in semantics. Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D52295
* inet_net_test: Compare pointers against nullptrJohn Baldwin2025-10-201-6/+6
| | | | | | | | | | | | | | | | | | | | GCC does not like passing NULL (__null) to std::ostringstream::operator<< inside of ATF_REQUIRE_EQ: lib/libc/tests/net/inet_net_test.cc: In member function 'virtual void {anonymous}::atfu_tc_inet_net_ntop_invalid::body() const': lib/libc/tests/net/inet_net_test.cc:306:9: error: passing NULL to non-pointer argument 1 of 'std::__1::basic_ostream<_CharT, _Traits>& std::__1::basic_ostream<_CharT, _Traits>::operator<<(long int) [with _CharT = char; _Traits = std::__1::char_traits<char>]' [-Werror=conversion-null] 306 | ATF_REQUIRE_EQ(ret, NULL); | ^~~~~~~~~~~~~~ In file included from /usr/obj/.../amd64.amd64/tmp/usr/include/c++/v1/sstream:317, from /usr/obj/.../amd64.amd64/tmp/usr/include/atf-c++/macros.hpp:29, from /usr/obj/.../amd64.amd64/tmp/usr/include/atf-c++.hpp:29, from lib/libc/tests/net/inet_net_test.cc:33: /usr/obj/.../amd64.amd64/tmp/usr/include/c++/v1/__ostream/basic_ostream.h:338:81: note: declared here 338 | basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(long __n) { | ~~~~~^~~ ... Fixes: 8f4a0d2f7b96 ("libc: Import OpenBSD's inet_net_{ntop,pton}")
* inet_net_test: Use int to hold expected return values from inet_net_ptonJohn Baldwin2025-10-201-2/+2
| | | | | | | | | | | | | | | GCC warns about the sign mismatch in comparisons: lib/libc/tests/net/inet_net_test.cc: In member function 'virtual void {anonymous}::atfu_tc_inet_net_inet4::body() const': lib/libc/tests/net/inet_net_test.cc:86:17: error: comparison of integer expressions of different signedness: 'int' and 'const unsigned int' [-Werror=sign-compare] 86 | ATF_REQUIRE_EQ(bits, addr.bits); | ^~~~~~~~~~~~~~ lib/libc/tests/net/inet_net_test.cc: In member function 'virtual void {anonymous}::atfu_tc_inet_net_inet6::body() const': lib/libc/tests/net/inet_net_test.cc:205:17: error: comparison of integer expressions of different signedness: 'int' and 'const unsigned int' [-Werror=sign-compare] 205 | ATF_REQUIRE_EQ(bits, addr.bits); | ^~~~~~~~~~~~~~ Fixes: 8f4a0d2f7b96 ("libc: Import OpenBSD's inet_net_{ntop,pton}")
* libc: Import OpenBSD's inet_net_{ntop,pton}Lexi Winter2025-10-182-0/+335
| | | | | | | | | | | | | | | | | Our versions of these functions (originally taken from BIND) simply don't work correctly for AF_INET6. These were removed from BIND itself quite a while ago, but OpenBSD has made several fixes in the mean time, so import their code. Add tests for both functions. PR: 289198 Reported by: Nico Sonack <nsonack@herrhotzenplotz.de> MFC after: 1 week Reviewed by: des Obtained from: OpenBSD (lib/libc/net) Sponsored by: https://www.patreon.com/bsdivy Differential Revision: https://reviews.freebsd.org/D52629
* realpath: Report correct path on failureDag-Erling Smørgrav2025-10-131-9/+2
| | | | | | | | | | | If lstat() fails with EACCES or ENOTDIR, the path we need to return in the caller-provided buffer is that of the parent directory (which is either unreadable or not a directory; the latter can only happen in the case of a race) rather than that of the child we attempted to stat. Sponsored by: Klara, Inc. Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D53025
* realpath: Additional test casesDag-Erling Smørgrav2025-10-131-12/+101
| | | | | | | | | | | | * Passing NULL should result in EINVAL * Passing an empty path should result in ENOENT * Failure with a non-null buffer should leave a partial result. As pointed out in a comment in the test case, this reveals a discrepancy between the documentation and reality. Sponsored by: Klara, Inc. Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D53024
* tzcode: Test escape from TZDIRDag-Erling Smørgrav2025-09-291-13/+26
| | | | | | | Test a value of TZ that temporarily escapes from TZDIR (which is not permitted when setugid) then reenters it. MFC after: 3 days
* tzcode: Fix issues when TZ is an absolute pathDag-Erling Smørgrav2025-09-272-8/+83
| | | | | | | | | | | | | | | | | | | | | | * If TZ starts with TZDIR, strip any additional slashes so relname does not end up looking like an absolute path. For instance, TZ=/usr/share/zoneinfo//UTC should result in UTC, not /UTC. * In the setugid case, we were incorrectly passing name rather than relname to fstatat(). * Modify the tz_env and tz_env_setugid test cases to exercise both of these scenarios. * Also add test cases for invalid values of TZ, which I wrote earlier but forgot to include in a5f14e4f9069. Reported by: Paul Eggert <eggert@cs.ucla.edu> MFC after: 3 days Fixes: 967a49a21a27 ("Update tzcode to 2025b") Fixes: a5f14e4f9069 ("tzcode: Use -00 only for invalid time zones") Reviewed by: philip Differential Revision: https://reviews.freebsd.org/D52753
* packages: Remove the tests-dev packageLexi Winter2025-09-182-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We don't want a tests-dev package, because this means set-devel depends on tests-dev, which transitively depends on tests, which means you can't install set-devel without also getting tests. The only real "dev" files in tests-dev are from ATF (libprivateatf), so move that to its own package and add a dependency from tests. Also move Kyua to its own package, since this might be useful for running tests even when the user doesn't want the whole set of base tests installed. Add a dependency from -tests to both -atf and -kyua, and a dependency on -set-base, since the tests won't work without the full base system installed. The remaining "dev" files in tests are actually test artifacts, not real development libraries. Add a new NO_DEV_PACKAGE option to bsd.lib.mk, which causes dev files to be installed in the base package instead of creating a -dev package, and set this option for everything that installs test libraries. While here, add a slightly more informative description for the tests package. MFC after: 3 seconds Reviewed by: bapt, emaste Differential Revision: https://reviews.freebsd.org/D52597
* Fix floaing point test. (again)Warner Losh2025-09-141-1/+1
| | | | Fixes: 9dd78db9c30a
* Fix floaing point test.Warner Losh2025-09-141-1/+1
| | | | | | | | | I botched a style fix to a pull request, and didn't catch it on amd64, but it broke almost everything else. It's a false positive to the style program and spaces cannot be inserted here. It's not math, but a funky notation. Fixes: 9dd78db9c30a
* libc: prevent incorrect %a/%La rounding at full precisionOsamu Sho2025-09-141-0/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In __hdtoa() and __hldtoa(), rounding is incorrectly applied when the requested precision exactly matches the number of significant hexadecimal digits. In this case, the redux adjustment can trigger an unintended exponent increment and shift the rounding position left by one bit. This causes the least significant digit to be rounded incorrectly. The fix adds a new condition based on MAX_HEX_DIGITS (derived from MANT_DIG) so that rounding is performed only when precision is strictly less than the number of significant digits. This avoids the unintended shift while preserving correct rounding for other cases. A new regression test (printfloat_test:hexadecimal_rounding_offset_eq_exp) covers both the binary64 (%.13a) and binary128 (%.28La on arm64) cases that previously fail, ensuring the bug does not regress. Note: MAX_HEX_DIGITS represents the maximum number of hexadecimal digits needed to express the mantissa. It is computed by subtracting the implicit integer bit from [L]DBL_MANT_DIG, dividing the remaining mantissa bits by 4 (with +3 to round up any remainder), and finally adding +1 for the leading integer digit. This makes its meaning explicit and distinct from SIGFIGS, which serves a different purpose. Fixes: 76303a9735ee ("Make several changes to the way printf handles hex floating point (%a):") Signed-off-by: Osamu Sho <osamusho@gmail.com> Reviewed by: imp,jlduran Pull Request: https://github.com/freebsd/freebsd-src/pull/1837
* libc: Have memcmp test what the standard requiresEd Maste2025-09-131-6/+6
| | | | | | | | | | | | | | | | libc's C memcmp currently returns the difference in byte values rather than just -1/0/1 as the AArch64 assembly implementation, many non- FreeBSD implementations, and compiler built-in optimizations do. It is a bug for a user to expect memcmp to return the difference in the byte values as the compiler is free to inline memcmp() with an implementation that does not do this. Change the test to validate only what the standard requires. PR: 289084 Reviewed by: markj, fuz Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D52502
* tzcode: Add a test case for plain issetugid caseDag-Erling Smørgrav2025-09-011-17/+43
| | | | | | | | | | | | This catches a bug in tzcode which incorrectly considers TZDEFAULT as unsafe as if it came from the environment. Also deduplicate some repeated code, and fix a missing mode in an open(2) call with O_CREAT set. Event: Oslo Hackathon 202508 Reviewed by: philip Differential Revision: https://reviews.freebsd.org/D52241
* tzcode: Add a test case for thin jailsDag-Erling Smørgrav2025-08-271-7/+36
| | | | | | | Add a test case for a typical thin jail scenario where TZDIR does not exist and we get our information from /etc/localtime. This is technically already covered by the detect_tz_changes test case, but this new test case is independent of the DETECT_TZ_CHANGES option.
* tzcode: Add test case for setugid programsDag-Erling Smørgrav2025-08-252-12/+45
| | | | | Fixes: a6b19979bf13 ("tzcode: Fix TZ for non-setugid programs") Differential Revision: https://reviews.freebsd.org/D52124
* tzcode: Fix TZ for non-setugid programsDag-Erling Smørgrav2025-08-221-19/+42
| | | | | | | | | | | The previous commit had the desired effect for setugid programs, but broke TZ for everyone else. I didn't notice because my test cases swap out /etc/localtime instead of setting TZ, so add a test case that sets TZ. Fixes: b6ea2513f776 ("tzcode: Limit TZ for setugid programs") Reviewed by: cy Differential Revision: https://reviews.freebsd.org/D52108
* libc: Drop incorrect qsort optimizationDag-Erling Smørgrav2025-08-152-0/+114
| | | | | | | | | | | | | | | | As pointed out in the PR and the article linked below, the switch to insertion sort in the BSD qsort code is based on a misunderstanding of Knuth's TAOCP and is actually a pessimization. As demonstrated by the added test, it is trivially easy to construct pathological input which results in quadratic runtime. Without that misguided optimization, the same input runs in nearly linearithmic time. https://www.raygard.net/2022/02/26/Re-engineering-a-qsort-part-3 PR: 287089 MFC after: 1 week Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D51907
* stdio: Fix bug in integer-parsing FSMDag-Erling Smørgrav2025-08-082-0/+50
| | | | | | | | | | | If we encounter a zero in the havezero state, we should assume octal, just like we would if we encountered any other digit below 8. MFC after: 1 week PR: 288440 Fixes: d9dc1603d6e4 ("libc: Implement N2630.") Reviewed by: mandree Differential Revision: https://reviews.freebsd.org/D51832
* libc: Fix style nits in flushlbuf regression testDag-Erling Smørgrav2025-08-071-5/+5
| | | | Sponsored by: Klara, Inc.
* libc: gen: refactor execvPe() for readabilityKyle Evans2025-08-031-0/+50
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The current incarnation of execvPe() is a bit messy, and it can be rather difficult to reason about whether we're actually doing the right thing with our errors. We have two cases in which we may enter the loop: 1.) We have a name that has no slashes in it, and we enter the loop normally through our strsep() logic to process $PATH 2.) We have a name with at least one slash, in which case we jump into the middle of the loop then bail after precisely the one iteration if we failed Both paths will exit the loop if we failed, either via jumping to the `done` label to preserve an errno or into the path that clobbers errno. Clobbering errno for case #2 above would seem to be wrong, as we did not actually search -- this would seem to be what POSIX expects, as well, based on expectations of the conformance test suite. Simplify reasoning about the two paths by splitting out an execvPe_prog that does the execve(2) call specifically, and returns based on whether the error would be fatal in a PATH search or not. For the relative/absolute case, we can just ignore the return value and keep errno intact. The search case gets simplified to return early if we hit a fatal error, or continue until the end and clobber errno if we did not find a suitable candidate. Another posix_spawnp() test is added to confirm that we didn't break our EACCES behavior in the process. Reviewed by: des, markj Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D51629
* dbm_nextkey: Always return an error if we've reached the end of the databaseBojan Novković2025-07-312-0/+54
| | | | | | | | | | | | | POSIX.1 states that `dbm_nextkey` must return an invalid key (i.e., `key.dptr == NULL`) after the end of the database was reached. The current implementation of `hash_seq` will incorrectly restart the key sequence after the end of the database is reached. Fix this by checking the "current bucket" index when R_NEXT is passed. Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D51635 Reviewed by: markj
* db/hash.c: Allow O_WRONLY in dbm_openBojan Novković2025-07-303-7/+115
| | | | | | | | | | | | | | The dbm(3) manpage explicitly states that O_WRONLY is not allowed in dbm_open, but a more recent comment in ` __hash_open` suggests otherwise. Furthermore, POSIX.1 allows O_WRONLY in dbm_open and states that the underlying file must be opened for both reading and writing. Fix this by correcting the O_WRONLY check and moving it further into the function to make sure that the original flags are stored in hashp. Sponsored by: Klara, Inc. Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D51514
* dbm: Add tests for dbm_openBojan Novković2025-07-252-0/+45
| | | | | | Sponsored by: Klara, Inc. Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D51492
* libc: Test time zone change detection.Dag-Erling Smørgrav2025-07-182-1/+285
| | | | | | | | | While here, clean the detection code up a bit. Sponsored by: Klara, Inc. Sponsored by: NetApp, Inc. Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D51343
* libc/powerpc64: Fix swapcontext(3)Timothy Pearson2025-07-132-2/+65
| | | | | | | | | | | | | | | | | | | | | On PowerPC platforms a valid link to the Table of Contents (TOC) is required for PLT lookups to function. This TOC pointer is stored in a dedicated register, and is used along with the stack pointer by both C prologue and PLT lookup code. When calling swapcontext() with uc_link != NULL, a PLT lookup to setcontext(3) is attempted from within the _ctx_done context. The exiting process has usually trashed both r1 and r2 at this point, leading to a crash within the PLT lookup before setcontext(2) is reached to restore the linked context. Save and restore r2 as in a regular function. This ensures the subsequent PLT lookup to setcontext(3) succeeds. Signed-off-by: Timothy Pearson <tpearson@raptorengineering.com> MFC after: 1 week Pull Request: https://github.com/freebsd/freebsd-src/pull/1759
* readdir: Fix error check.Dag-Erling Smørgrav2025-07-112-7/+6
| | | | | | | | | | | | | Now that dd_size is unsigned, we need to check if the return value from getdirentries() was negative before assigning it to dd_size. While here, simplify the scandir_error test case slightly, and verify that calling readdir() again after EOF still returns NULL. Fixes: 42e613018da5 Sponsored by: Klara, Inc. Reviewed by: kevans Differential Revision: https://reviews.freebsd.org/D51266
* wordexp(3): Handle ECHILD from waitpidKenny Levinsen2025-07-081-0/+26
| | | | | | | | | | | | | | If the calling process has used SIG_IGN as handler or set the SA_NOCLDWAIT flag for SIGCHLD, processes will be automatically reaped on exit and calls to waitpid(3) will therefore fail with ECHILD. We waitpid primarily to reap our child so that the caller does not have to worry about it. ECHILD indicates that there is no child to reap, so we can just treat that as a success and move on. Signed-off-by: Kenny Levinsen <kl@kl.wtf> Tested by: Jan Beich Pull Request: https://github.com/freebsd/freebsd-src/pull/1675
* opendir, fdopendir: Add tests, clean up.Dag-Erling Smørgrav2025-07-082-0/+145
| | | | | | | | | | | | * Add test cases for opendir() and fdopendir(). * Drop O_NONBLOCK from opendir(); it was added a long time ago to avoid blocking if given a closed named pipe, but now we use O_DIRECTORY, which ensures that we get ENOTDIR in that case. * While here, remove unused #includes left over from the split. Sponsored by: Klara, Inc. Reviewed by: kevans, markj Differential Revision: https://reviews.freebsd.org/D51126
* fts: Add test cases for unreadable directories.Dag-Erling Smørgrav2025-07-024-72/+180
| | | | | | Sponsored by: Klara, Inc. Reviewed by: kevans Differential Revision: https://reviews.freebsd.org/D51098
* scandir: Propagate errors from readdir().Dag-Erling Smørgrav2025-06-261-0/+63
| | | | | | | | | | | | | | Currently, if `readdir()` fails, `scandir()` simply returns a partial result (or a null result if it fails before any entries were selected). There is no way within the current API design to return both a partial result and an error indicator, so err on the side of caution: if an error occurs, discard any partial result and return the error instead. MFC after: 1 week Reported by: Maxim Suhanov <dfirblog@gmail.com> Sponsored by: Klara, Inc. Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D51046
* libc: Rename fscandir{,_b}() to fdscandir{,_b}().Dag-Erling Smørgrav2025-06-232-12/+12
| | | | | | | | | | | | | This seems to fit the pattern better (e.g. fdopendir()). I've added weak references to ease the transition, but since it's only been a few days, we can remove them (and the ObsoleteFiles entries for the manual pages) before we branch stable/15. Fixes: deeebfdecab5 Sponsored by: Klara, Inc. Reviewed by: kevans Differential Revision: https://reviews.freebsd.org/D50980
* glob: Improve callback tests.Dag-Erling Smørgrav2025-06-232-35/+63
| | | | | | | | | | | Most importantly, they need to run without privileges, since root is allowed to read a directory regardless of its permission bits. PR: 287694 Fixes: 4d7c31bca252 Sponsored by: Klara, Inc. Reviewed by: bnovkov Differential Revision: https://reviews.freebsd.org/D50965
* scandir: Fix behavior when no entries match.Dag-Erling Smørgrav2025-06-201-0/+22
| | | | | | | | | | | | In the previous commit, I removed the initial initialization of the `names` array, not realizing that `scandir()` is expected to return a non-null (but empty) array of entries if no entries matched. Restore the historical behavior, document it, and add a test. Fixes: deeebfdecab5 Sponsored by: Klara, Inc. Reviewed by: kevans, allanjude, markj Differential Revision: https://reviews.freebsd.org/D50949
* libc: Add fscandir(), fscandir_b(), scandirat_b().Dag-Erling Smørgrav2025-06-203-1/+235
| | | | | | | | | While here, clean up scandir() a bit and improve the documentation. MFC after: never Sponsored by: Klara, Inc. Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D50935
* include: ssp: fortify <signal.h>Ricardo Branco2025-06-113-0/+329
| | | | | | | | sig2str(3) Reviewed by: imp, kib, des, jilles Pull Request: https://github.com/freebsd/freebsd-src/pull/1696 Closes: https://github.com/freebsd/freebsd-src/pull/1696
* Add tests for sig2str() / str2sig()Ricardo Branco2025-06-112-0/+214
| | | | | Reviewed by: imp, kib, des, jilles Pull Request: https://github.com/freebsd/freebsd-src/pull/1696
* glob2_test: Add tests for error callback functions and blocksBojan Novković2025-06-023-2/+112
| | | | | | | | | This change adds tests that check basic callback functionality for blocks and function pointers. The tests also make sure that GLOB_ERR overrides the callback's return value. Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D50486
* Revert "Mark several getaddrinfo tests as XFAIL"Enji Cooper2025-05-281-6/+0
| | | | | | This change was unreviewed and should not have been committed to :main. This reverts commit 9b37d84c87e69dabc69d818aa4d2fea718bd8b74.
* Mark several getaddrinfo tests as XFAILEnji Cooper2025-05-281-0/+6
| | | | | | | | | | | | | | | | | These tests were recently enabled on main and have failed consistently since they were enabled. - lib.libc.net.getaddrinfo.getaddrinfo.basic - lib.libc.net.getaddrinfo.getaddrinfo.nofamily - lib.libc.net.getaddrinfo.getaddrinfo_test.basic - lib.libc.net.getaddrinfo.getaddrinfo_test.empty_servname - lib.libc.net.getaddrinfo.getaddrinfo_test.sock_raw Mark them as expected failures so they no longer count as failures in Jenkins CI. PR: 285826 MFC with: 5313457780, 0b773a94ab
* libc: Improve scanfloat test.Dag-Erling Smørgrav2025-05-161-68/+68
|