summaryrefslogtreecommitdiff
path: root/lib/libc/tests
Commit message (Collapse)AuthorAgeFilesLines
* Rework check for libclang_rt to see if the needed library exists.Bryan Drewery2018-06-271-18/+9
| | | | | | | | | | | | | | | | Currently libclang_rt is not provided for cross-building and as such is not connected to cross-tools. For building clang once in universe it is likely that libclang_rt won't exist for the universe toolchain but even if it did it would not support anything but the native arch. So explicitly check for support before enabling h_raw. MFC after: 1 week Reviewed by: dim Sponsored by: Dell EMC Differential Revision: https://reviews.freebsd.org/D16012 Notes: svn path=/head/; revision=335704
* Don't build brk_test on platforms that don't support brk().Mark Johnston2018-06-051-0/+2
| | | | | | | X-MFC with: r334626 Notes: svn path=/head/; revision=334653
* Reimplement brk() and sbrk() to avoid the use of _end.Mark Johnston2018-06-042-0/+150
| | | | | | | | | | | | | | | | | | | | | | | | | Previously, libc.so would initialize its notion of the break address using _end, a special symbol emitted by the static linker following the bss section. Compatibility issues between lld and ld.bfd could cause the wrong definition of _end (libc.so's definition rather than that of the executable) to be used, breaking the brk()/sbrk() interface. Avoid this problem and future interoperability issues by simply not relying on _end. Instead, modify the break() system call to return the kernel's view of the current break address, and have libc initialize its state using an extra syscall upon the first use of the interface. As a side effect, this appears to fix brk()/sbrk() usage in executables run with rtld direct exec, since the kernel and libc.so no longer maintain separate views of the process' break address. PR: 228574 Reviewed by: kib (previous version) MFC after: 2 months Differential Revision: https://reviews.freebsd.org/D15663 Notes: svn path=/head/; revision=334626
* Conform to Berne Convention.Cy Schubert2018-05-221-1/+1
| | | | | | | MFC after: 3 days Notes: svn path=/head/; revision=334022
* Remove 'All rights reserved' from my filesEric van Gyzen2018-05-091-1/+0
| | | | | | | | | | See r333391 for the rationale. Approved by: emaste (for the Foundation copyright) Sponsored by: Dell EMC Notes: svn path=/head/; revision=333430
* Add new gets_s(3) stdio function.Cy Schubert2018-04-032-0/+146
| | | | | | | | | | | | | | This implements the gets_s(3) function as documented at http://en.cppreference.com/w/c/io/gets. It facilitates the optional removal of gets(3). Reviewed by: ed MFC after: 2 weeks Relnotes: yes Differential Revision: https://reviews.freebsd.org/D12785 Notes: svn path=/head/; revision=331936
* getentropy(3): Fallback to kern.arandom sysctl on older kernelsConrad Meyer2018-03-211-0/+3
| | | | | | | | | | | | | | | | | | | On older kernels, when userspace program disables SIGSYS, catch ENOSYS and emulate getrandom(2) syscall with the kern.arandom sysctl (via existing arc4_sysctl wrapper). Special care is taken to faithfully emulate EFAULT on NULL pointers, because sysctl(3) as used by kern.arandom ignores NULL oldp. (This was caught by getentropy(3) ATF tests.) Reported by: kib Reviewed by: kib Discussed with: delphij Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D14785 Notes: svn path=/head/; revision=331334
* Implement getrandom(2) and getentropy(3)Conrad Meyer2018-03-212-0/+87
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The general idea here is to provide userspace programs with well-defined sources of entropy, in a fashion that doesn't require opening a new file descriptor (ulimits) or accessing paths (/dev/urandom may be restricted by chroot or capsicum). getrandom(2) is the more general API, and comes from the Linux world. Since our urandom and random devices are identical, the GRND_RANDOM flag is ignored. getentropy(3) is added as a compatibility shim for the OpenBSD API. truss(1) support is included. Tests for both system calls are provided. Coverage is believed to be at least as comprehensive as LTP getrandom(2) test coverage. Additionally, instructions for running the LTP tests directly against FreeBSD are provided in the "Test Plan" section of the Differential revision linked below. (They pass, of course.) PR: 194204 Reported by: David CARLIER <david.carlier AT hardenedbsd.org> Discussed with: cperciva, delphij, jhb, markj Relnotes: maybe Differential Revision: https://reviews.freebsd.org/D14500 Notes: svn path=/head/; revision=331279
* Add a new set of simple tests for makecontext().John Baldwin2018-01-312-0/+190
| | | | | | | | | | | | In contrast to the existing NetBSD setcontext_link test, these tests verify that passing from 1 to 6 arguments through to the callback function work correctly which can be useful for testing ABIs which split arguments between registers and the stack. Sponsored by: DARPA / AFRL Notes: svn path=/head/; revision=328633
* Add libregex, connect it to the buildKyle Evans2018-01-222-58/+59
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | libregex is a regex(3) implementation intended to feature GNU extensions and any other non-POSIX compliant extensions that are deemed worthy. These extensions are separated out into a separate library for the sake of not cluttering up libc further with them as well as not deteriorating the speed (or lack thereof) of the libc implementation. libregex is implemented as a build of the libc implementation with LIBREGEX defined to distinguish this from a libc build. The reasons for implementation like this are two-fold: 1.) Maintenance- This reduces the overhead induced by adding yet another regex implementation to base. 2.) Ease of use- Flipping on GNU extensions will be as simple as linking against libregex, and POSIX-compliant compilations can be guaranteed with a REG_POSIX cflag that should be ignored by libc/regex and disables extensions in libregex. It is also easier to keep REG_POSIX sane and POSIX pure when implemented in this fashion. Tests are added for future functionality, but left disconnected for the time being while other testing is done. Reviewed by: cem (previous version) Differential Revision: https://reviews.freebsd.org/D12934 Notes: svn path=/head/; revision=328240
* Optimize telldir(3)Alan Somers2017-12-062-2/+192
| | | | | | | | | | | | | | | | | | | | | | | | | Currently each call to telldir() requires a malloc and adds an entry to a linked list which must be traversed on future telldir(), seekdir(), closedir(), and readdir() calls. Applications that call telldir() for every directory entry incur O(n^2) behavior in readdir() and O(n) in telldir() and closedir(). This optimization eliminates the malloc() and linked list in most cases by packing the relevant information into a single long. On 64-bit architectures msdosfs, NFS, tmpfs, UFS, and ZFS can all use the packed representation. On 32-bit architectures msdosfs, NFS, and UFS can use the packed representation, but ZFS and tmpfs can only use it for about the first 128 files per directory. Memory savings is about 50 bytes per telldir(3) call. Speedup for telldir()-heavy directory traversals is about 20-30x for one million files per directory. Reviewed by: kib, mav, mckusick MFC after: 3 weeks Sponsored by: Spectra Logic Corp Differential Revision: https://reviews.freebsd.org/D13385 Notes: svn path=/head/; revision=326640
* DIRDEPS_BUILD: Update dependencies.Bryan Drewery2017-10-3124-24/+3
| | | | | | | Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=325188
* DIRDEPS_BUILD: Connect new directories.Bryan Drewery2017-10-312-0/+36
| | | | | | | Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=325187
* getmntinfo(3): Scale faster, and return soonerConrad Meyer2017-08-252-0/+87
| | | | | | | | | | | | | | | | | | | | | | | | | | | | getmntinfo(3) is designed around a relatively static or slow growing set of current mounts. It tried to detect a race with somewhat concurrent mount and re-call getfsstat(2) in that case, looping indefinitely. It also allocated space for a single extra mount as slop. In the case where the user has a large number of mounts and is adding them at a rapid pace, it fell over. This patch makes two functional changes: 1. Allocate even more slop. Double whatever the last getfsstat(2) returned. 2. Abort and return some known results after looping a few times (arbitrarily, 3). If the list is constantly changing, we can't guarantee we return a full result to the user at any point anyways. While here, add very basic functional tests for getmntinfo(3) to the libc suite. PR: 221743 Submitted by: Peter Eriksson <peter AT ifm.liu.se> (earlier version) Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=322895
* Improve standard compliance for memset_s() and abort_handler_s().Konstantin Belousov2017-08-121-2/+7
| | | | | | | | | | | | | | | | | | | | abort_handler_s() currently simply calls abort(), though the standard specifies more: "Writes an implementation-defined message to stderr which must include the string pointed to by msg and calls abort()." memset_s() is missing error condition "n > smax", and does not invoke the constraint handler after filling the buffer: "following errors are detected at runtime and call the currently installed constraint handler function after storing ch in every location of the destination range [dest, dest+destsz) if dest and destsz are themselves valid", one of the errors is "n > smax" itself. Submitted by: Yuri Pankov <yuripv@gmx.com> MFC after: 1 week Differential revision: https://reviews.freebsd.org/D11991 Notes: svn path=/head/; revision=322427
* fnmatch(3): Update testcase for r322368.Pedro F. Giffuni2017-08-101-1/+1
| | | | Notes: svn path=/head/; revision=322371
* Properly set userid for truncate_test.Bryan Drewery2017-07-211-1/+1
| | | | | | | | MFC after: 1 week Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=321333
* Fix cleanup in lib/libc/gen/setdomainname_testAlan Somers2017-07-061-0/+1
| | | | | | | | | | | | | | | | | ATF cleanup routines run in separate processes from the tests themselves, so they can't share global variables. Also, setdomainname_test needs to be is_exclusive because the test cases access a global resource. PR: 219967 Reviewed by: ngie MFC after: 3 weeks Sponsored by: Spectra Logic Corp Differential Revision: https://reviews.freebsd.org/D11188 Notes: svn path=/head/; revision=320737
* tsearch_test: Test twalk & add some determinism.Will Andrews2017-06-061-1/+29
| | | | Notes: svn path=/head/; revision=319613
* hostent_test_getaddrinfo_eq(..): call freeaddrinfo on `ai` when doneEnji Cooper2017-05-281-8/+10
| | | | | | | | | | | | This plugs a leak of memory allocated via getaddrinfo. MFC after: 1 week Reported by: Coverity CID: 1346866 Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=319054
* hostent_test_getnameinfo_eq(..): initialize found_a_host to falseEnji Cooper2017-05-281-1/+1
| | | | | | | | | | MFC after: 1 week Reported by: Coverity CID: 1368943 Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=319051
* Bump WARNS from 1 to 3 after recent commits to fix warnings in theEnji Cooper2017-05-281-1/+1
| | | | | | | | | | | directory. Tested with: clang 4.0, gcc 4.2.1, gcc 6.3.0 MFC after: 1 week Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=319049
* Push `snapshot_file` copying down into run_tests function, and mark ↵Enji Cooper2017-05-282-25/+32
| | | | | | | | | | | | | | | snapshot_file const char *. This fixes a bogus set of errors from gcc about strdup not being allowed a NULL argument. MFC after: 1 week Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=319048
* Fix a -Wunused-but-set-variable warning reported by gcc 6.3.0Enji Cooper2017-05-281-2/+1
| | | | | | | | MFC after: 3 days Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=319046
* Fix -Wunused and -Wshadow warningsEnji Cooper2017-05-281-8/+6
| | | | | | | | MFC after: 3 days Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=319045
* getgr_test: fix -Wunused warningsEnji Cooper2017-05-281-2/+2
| | | | | | | | MFC after: 3 days Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=319044
* getpw_test: fix -Wunused warningsEnji Cooper2017-05-281-3/+7
| | | | | | | | | | | - Mark unused parameters __unused. - Put dump_passwd under DEBUG as it's only used in that case. MFC after: 3 days Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=319043
* gethostby_test: fix multiple warning typesEnji Cooper2017-05-281-27/+29
| | | | | | | | | | | | | | | - Fix -Wmissing-declaration warning by staticizing run_tests. - Fix -Wsign-compare warnings by casting size_t types to int for comparisons. Reindent some of the code in sdump_hostent(..) to accomodate the overall changes. MFC after: 3 days Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=319042
* getproto_test: fix -Wunused warningsEnji Cooper2017-05-281-2/+2
| | | | | | | | | | Mark unused parameters __unused in functions. MFC after: 3 days Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=319041
* getrpc_test: fix -Wunused warningsEnji Cooper2017-05-281-4/+2
| | | | | | | | | | | - Mark unused function parameters unused. - Remove an unused function prototype. MFC after: 3 days Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=319040
* getserv_test: mark unused parameters __unused to fix correspondingEnji Cooper2017-05-281-2/+2
| | | | | | | | | | warnings MFC after: 3 days Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=319039
* getusershell_test: mark mdata parameter in compare_usershell __unusedEnji Cooper2017-05-281-1/+2
| | | | | | | | MFC after: 3 days Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=319038
* getaddrinfo_test: mark unused function parameters __unused to fix -WunusedEnji Cooper2017-05-281-3/+4
| | | | | | | | | | warnings MFC after: 3 days Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=319037
* getproto_test: fix -Wmissing-prototypes and -Wsign-compare warningsEnji Cooper2017-05-281-4/+4
| | | | | | | | MFC after: 3 days Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=319036
* getrpc_test: fix -Wmissing-prototypes and -Wsign-compare warningsEnji Cooper2017-05-281-4/+4
| | | | | | | | MFC after: 3 days Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=319035
* getaddrinfo_test: fix -Wsign-compare warningsEnji Cooper2017-05-281-7/+7
| | | | | | | | MFC after: 3 days Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=319034
* getserv_test: fix -Wsign-compare and -Wmissing-prototypes warningsEnji Cooper2017-05-281-4/+4
| | | | | | | | MFC after: 3 days Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=319033
* getusershell_test: staticize run_tests(..) to fix warningsEnji Cooper2017-05-281-1/+1
| | | | | | | | MFC after: 3 days Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=319031
* Fix -Wsign-compare warningsEnji Cooper2017-05-281-2/+2
| | | | | | | | MFC after: 3 days Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=319030
* Staticize functions and remove unused variables to aid with bumping WARNSEnji Cooper2017-05-284-8/+2
| | | | | | | | MFC after: 3 days Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=319029
* Sort make variables to suit style.Makefile(5)Enji Cooper2017-05-281-7/+8
| | | | | | | | | | This is being done prior to functional changes. MFC after: 3 days Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=319028
* lib/libc/tests/nss: use calloc appropriatelyEnji Cooper2017-05-285-7/+6
| | | | | | | | | | | The pattern used prior to this commit was `calloc(1, n * sizeof(type))`; the pattern that should be used however is `calloc(n, sizeof(type))`. MFC after: 3 days Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=319027
* Add tests for some cases in r318298.Konstantin Belousov2017-05-182-0/+103
| | | | | | | | | | | | | | | | The first test triggers the out of bounds read of the 'left' array. It only fails when realpath.c is compiled with '-fsanitize=address'. The other test checks for ENOENT when running into an empty symlink. This matches NetBSD's realpath(3) semantics. Previously, empty symlinks were treated like ".". Submitted by: Jan Kokemц╪ller <jan.kokemueller@gmail.com> PR: 219154 MFC after: 2 weeks Notes: svn path=/head/; revision=318450
* libc glob: Avoid pathological exponential behaviorConrad Meyer2017-05-032-0/+115
| | | | | | | | | | | | | | | Adapt glob's match() routine to use a greedy algorithm that avoids exponential runtime in byzantine inputs. While here, add a testcase for the byzantine input. Prompted by: https://research.swtch.com/glob Authored by: Yves Orton <demerphq at gmail.com> Obtained from: Perl (33252c318625f3c6c89b816ee88481940e3e6f95) Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=317749
* Fix strcoll_l disagreeing with strxfrm by reworking the forward order case inBaptiste Daroussin2017-04-161-0/+93
| | | | | | | | | | | | | | | | | | | | wcscoll_l(). Illumos fixed this while grabbing back our patches: https://www.illumos.org/rb/r/402/ This does not 100% fix what postgresql folks reported as there is still a remaining issue: https://www.illumos.org/issues/7962, it improves the situation The initial issue was reported in postgresql mailing lists: https://www.postgresql.org/message-id/flat/111D0E27-A8F3-4A84-A4E0-B0FB703863DF@s24.com#111D0E27-A8F3-4A84-A4E0-B0FB703863DF@s24.com Submitted by: Yuri Pankov <yuri.pankov@nexenta.com> Obtained from: Illumos MFC after: 2 weeks Notes: svn path=/head/; revision=317034
* Implement the memset_s(3) function as specified by the C11 ISO/IECKonstantin Belousov2017-03-304-0/+260
| | | | | | | | | | | | | | | | | 9899:2011 Appendix K 3.7.4.1. Other needed supporting types, defines and constraint_handler infrastructure is added as specified in the C11 spec. Submitted by: Tom Rix <trix@juniper.net> Sponsored by: Juniper Networks Discussed with: ed MFC after: 3 weeks Differential revision: https://reviews.freebsd.org/D9903 Differential revision: https://reviews.freebsd.org/D10161 Notes: svn path=/head/; revision=316213
* Don't build/install lib/libc/io_test anymoreEnji Cooper2017-03-201-1/+2
| | | | | | | | | | | | | The failing test requires the zh_TW.Big5 locale, which is no longer installed as of r315568. Add a note/pointer just in case someone considers re-adding it. Reported by: Jenkins Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=315616
* Add clock_nanosleep()Eric van Gyzen2017-03-191-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | Add a clock_nanosleep() syscall, as specified by POSIX. Make nanosleep() a wrapper around it. Attach the clock_nanosleep test from NetBSD. Adjust it for the FreeBSD behavior of updating rmtp only when interrupted by a signal. I believe this to be POSIX-compliant, since POSIX mentions the rmtp parameter only in the paragraph about EINTR. This is also what Linux does. (NetBSD updates rmtp unconditionally.) Copy the whole nanosleep.2 man page from NetBSD because it is complete and closely resembles the POSIX description. Edit, polish, and reword it a bit, being sure to keep any relevant text from the FreeBSD page. Reviewed by: kib, ngie, jilles MFC after: 3 weeks Relnotes: yes Sponsored by: Dell EMC Differential Revision: https://reviews.freebsd.org/D10020 Notes: svn path=/head/; revision=315526
* Increase WARNS for nss testsAlan Somers2017-03-111-0/+1
| | | | | | | | | | | | ATF tests have a default WARNS of 0, unlike other usermode programs. Reviewed by: ngie MFC after: 3 weeks Sponsored by: Spectra Logic Corporation Differential Revision: https://reviews.freebsd.org/D9933 Notes: svn path=/head/; revision=315033
* Increase WARNS for iconv testsAlan Somers2017-03-111-0/+1
| | | | | | | | | | | | ATF tests have a default WARNS of 0, unlike other usermode programs. Reviewed by: ngie MFC after: 3 weeks Sponsored by: Spectra Logic Corporation Differential Revision: https://reviews.freebsd.org/D9933 Notes: svn path=/head/; revision=315032