summaryrefslogtreecommitdiff
path: root/lib/libc/tests
Commit message (Collapse)AuthorAgeFilesLines
* Disable ssp raw test without ASANBrooks Davis2020-10-281-1/+1
| | | | | | | | | | | | | r366981 disabled ASAN when it might not be reliable (with an external compiler), but this test is broken without ASAN so disable it completely in that case. PR: 250706 Reviewed by: emaste, lwhsu Differential Revision: https://reviews.freebsd.org/D26982 Notes: svn path=/head/; revision=367121
* Only use ASAN when using the in-tree compilerBrooks Davis2020-10-231-1/+3
| | | | | | | | | | | | | | When building FreeBSD 11 on a FreeBSD 12 system with CROSS_TOOLCHAIN=llvm10 we end up trying to link against the packaged version of the sanitizer library. This resulted in a requirement for getentropy(3) which is not present in FreeBSD 11. Reviewed by: emaste MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D26903 Notes: svn path=/head/; revision=366981
* lib/libc/tests/iconv: raise WARNS to 6Alan Somers2020-09-242-2/+1
| | | | | | | MFC after: 2 weeks Notes: svn path=/head/; revision=366132
* lib/libc/tests/sys: raise WARNS to 6Alan Somers2020-09-241-6/+0
| | | | | | | MFC after: 2 weeks Notes: svn path=/head/; revision=366131
* build: provide a default WARNS for all in-tree buildsKyle Evans2020-09-181-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | The current default is provided in various Makefile.inc in some top-level directories and covers a good portion of the tree, but doesn't cover parts of the build a little deeper (e.g. libcasper). Provide a default in src.sys.mk and set WARNS to it in bsd.sys.mk if that variable is defined. This lets us relatively cleanly provide a default WARNS no matter where you're building in the src tree without breaking things outside of the tree. Crunchgen has been updated as a bootstrap tool to work on this change because it needs r365605 at a minimum to succeed. The cleanup necessary to successfully walk over this change on WITHOUT_CLEAN builds has been added. There is a supplemental project to this to list all of the warnings that are encountered when the environment has WARNS=6 NO_WERROR=yes: https://warns.kevans.dev -- this project will hopefully eventually go away in favor of CI doing a much better job than it. Reviewed by: emaste, brooks, ngie (all earlier version) Reviewed by: emaste, arichardson (depend-cleanup.sh change) Differential Revision: https://reviews.freebsd.org/D26455 Notes: svn path=/head/; revision=365887
* libc tests: dynthr_mod: fix some WARNS issuesKyle Evans2020-09-091-1/+3
| | | | | | | | | | | | | | This is being addressed as part of a side-patch I'm working on that builds all the things with WARNS=6, instead of relying on it being supplied in just shallow parts of the build with higher-level Makefile.inc. Provide a prototype for mod_main and annotate the thread function argument as unused. MFC after: 1 week Notes: svn path=/head/; revision=365494
* libc/resolv: attempt to fix the test under WARNS=6Kyle Evans2020-09-091-15/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | | | In a side-change that I'm working on to start defaulting src builds to WARNS=6 where WARNS isn't otherwise specified, GCC6 (and clang, to a lesser extent) pointed out a number of issues with the resolv tests: - Global method variable that gets shadowed in run_tests() - Signed/unsigned comparison between i in run_tests() and hosts->sl_cur The shadowed variable looks like it might actually be bogus as written, as we pass it to RUN_TESTS -> run_tests, but other parts use the global method instead. This change is mainly geared towards correcting that by removing the global and plumbing the method through from run_tests -> run into the new thread. For the signed/unsigned comparison, there's no compelling reason to not just switch i/nthreads/nhosts to size_t. The review also included a change to the load() function that was better addressed by jhb in r365302. Reviewed by: ngie, pstef MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D24844 Notes: svn path=/head/; revision=365493
* Various fixes to the load() function.John Baldwin2020-09-031-8/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | - Use getline() instead of fgetln(). This ensures the returned string is always null-terminated without losing the last character if the last line in a file doesn't have a newline. Also, while fgetln says the returned buffer can be modified, that doesn't actually seem safe as the current implementation means you are modifying stdio's internal buffer. - Remove a spurious if before an ATF_REQUIRE that was clearly supposed to be non-optional. - Remove a pointless compare of 'ptr' against '\0' (really NULL) that duplicated the middle condition in the for(). - Once a comment is found, skip the rest of the line, not just the current word. Reviewed by: kevans Obtained from: CheriBSD Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D26278 Notes: svn path=/head/; revision=365302
* Pass a valid mode with O_CREATE to open(2).John Baldwin2020-09-021-6/+6
| | | | | | | | | | | | | | | CheriABI is pickier about the arguments to open(2) and crashes with a fault if a mode isn't passed to an open() when O_CREATE is specified. Reported by: CHERI Reviewed by: brooks Obtained from: CheriBSD MFC after: 2 weeks Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D26281 Notes: svn path=/head/; revision=365280
* Fix a buffer overrun.John Baldwin2020-09-011-3/+3
| | | | | | | | | | | | | | getln() returns 'len' valid characters. line[len] is out of bounds. Reported by: CHERI Reviewed by: brooks Obtained from: CheriBSD MFC after: 2 weeks Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D26197 Notes: svn path=/head/; revision=365055
* Don't explicitly specify c99 or gnu99 as the default is now gnu99.Xin LI2020-08-171-2/+0
| | | | | | | MFC after: 2 weeks Notes: svn path=/head/; revision=364292
* Revert r351416 to let lib.libc.gen.getmntinfo_test.getmntinfo_test get more testLi-Wen Hsu2020-07-131-3/+0
| | | | | | | | | | This is supposed to be fixed by r363068 PR: 240049 Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=363165
* Enable long double tests on RISC-VMitchell Horne2020-06-242-6/+8
| | | | | | | | | | | | | | | | | | | | | | | | Some of the NetBSD contributed tests are gated behind the __HAVE_LONG_DOUBLE flag. This flag seems to be defined only for platforms whose long double is larger than their double. I could not find this explicitly documented anywhere, but it is implied by the definitions in NetBSD's sys/arch/${arch}/include/math.h headers, and the following assertion from the UBSAN code: #ifdef __HAVE_LONG_DOUBLE long double LD; ASSERT(sizeof(LD) > sizeof(uint64_t)); #endif RISC-V has 128-bit long doubles, so enable the tests on this platform, and update the comments to better explain the purpose of this flag. Reviewed by: ngie MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D25419 Notes: svn path=/head/; revision=362576
* Add missing shell script from r361995Kyle Evans2020-06-101-0/+4
| | | | | | | | | Pointy hat: kevans Reported by: rpokala X-MFC-With: r361995 Notes: svn path=/head/; revision=361999
* execvp: fix up the ENOEXEC fallbackKyle Evans2020-06-102-0/+48
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If execve fails with ENOEXEC, execvp is expected to rebuild the command with /bin/sh instead and try again. The previous version did this, but overlooked two details: argv[0] can conceivably be NULL, in which case memp would never get terminated. We must allocate no less than three * sizeof(char *) so we can properly terminate at all times. For the non-NULL argv standard case, we count all the non-NULL elements and actually skip the first argument, so we end up capturing the NULL terminator in our bcopy(). The second detail is that the spec is actually worded such that we should have been preserving argv[0] as passed to execvp: "[...] executed command shall be as if the process invoked the sh utility using execl() as follows: execl(<shell path>, arg0, file, arg1, ..., (char *)0); where <shell path> is an unspecified pathname for the sh utility, file is the process image file, and for execvp(), where arg0, arg1, and so on correspond to the values passed to execvp() in argv[0], argv[1], and so on." So we make this change at this time as well, while we're already touching it. We decidedly can't preserve a NULL argv[0] as this would be incredibly, incredibly fragile, so we retain our legacy behavior of using "sh" for argv[] in this specific instance. Some light tests are added to try and detect some components of handling the ENOEXEC fallback; posix_spawnp_enoexec_fallback_null_argv0 is likely not 100% reliable, but it at least won't raise false-alarms and it did result in useful failures with pre-change libc on my machine. This is a secondary change in D25038. Reported by: Andrew Gierth <andrew_tao173.riddles.org.uk> Reviewed by: jilles, kib, Andrew Gierth MFC after: 1 week Notes: svn path=/head/; revision=361995
* Avoid using non-portable dd status=none flagAlex Richardson2020-06-052-2/+10
| | | | | | | | | | | | | | | | | Copying the approach chosen in r309412. This fixes building the libc tests on a macOS host since the macOS /bin/dd binary does not support status=none. As there only seem to be two uses, this commit changes the two Makefiles. If this becomes more common, we could also add a wrapper bootstrap script that ignores status= and forwards the remaining args to the real dd. Another alternative would be to remove the status flag and pipe stderr to /dev/null, but them we lose error messages. Reviewed By: brooks Differential Revision: https://reviews.freebsd.org/D24785 Notes: svn path=/head/; revision=361829
* Provide O_SEARCHKyle Evans2020-02-021-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | O_SEARCH is defined by POSIX [0] to open a directory for searching, skipping permissions checks on the directory itself after the initial open(). This is close to the semantics we've historically applied for O_EXEC on a directory, which is UB according to POSIX. Conveniently, O_SEARCH on a file is also explicitly undefined behavior according to POSIX, so O_EXEC would be a fine choice. The spec goes on to state that O_SEARCH and O_EXEC need not be distinct values, but they're not defined to be the same value. This was pointed out as an incompatibility with other systems that had made its way into libarchive, which had assumed that O_EXEC was an alias for O_SEARCH. This defines compatibility O_SEARCH/FSEARCH (equivalent to O_EXEC and FEXEC respectively) and expands our UB for O_EXEC on a directory. O_EXEC on a directory is checked in vn_open_vnode already, so for completeness we add a NOEXECCHECK when O_SEARCH has been specified on the top-level fd and do not re-check that when descending in namei. [0] https://pubs.opengroup.org/onlinepubs/9699919799/ Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D23247 Notes: svn path=/head/; revision=357412
* Add qsort_r(3) regression test.Edward Tomasz Napierala2020-01-202-0/+93
| | | | | | | | | MFC after: 2 weeks Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D23206 Notes: svn path=/head/; revision=356910
* Add qsort_s(3). Apart from the constraints, it also makes it easierEdward Tomasz Napierala2020-01-202-0/+258
| | | | | | | | | | | | | to port software written for Linux variant of qsort_r(3). Reviewed by: kib, arichardson MFC after: 2 weeks Relnotes: yes Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D23174 Notes: svn path=/head/; revision=356909
* Add sigsetop extensions commonly found in musl libc and glibcKyle Evans2019-12-122-0/+192
| | | | | | | | | | | | | | These functions (sigandset, sigisemptyset, sigorset) are commonly available in at least musl libc and glibc; sigorset, at least, has proven quite useful in qemu-bsd-user work for tracking the current process signal mask in a more self-documenting/aesthetically pleasing manner. Reviewed by: bapt, jilles, pfg MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D22187 Notes: svn path=/head/; revision=355641
* Update Makefile.depend filesSimon J. Gerraty2019-12-111-1/+0
| | | | | | | | | | | | | Update a bunch of Makefile.depend files as a result of adding Makefile.depend.options files Reviewed by: bdrewery MFC after: 1 week Sponsored by: Juniper Networks Differential Revision: https://reviews.freebsd.org/D22494 Notes: svn path=/head/; revision=355617
* Fix various -Wpointer-compare warningsBrooks Davis2019-10-084-8/+8
| | | | | | | | | | | | | | | | | | | | This warning (comparing a pointer against a zero character literal rather than NULL) has existed since GCC 7.1.0, and was recently added to Clang trunk. Almost all of these are harmless, except for fwcontrol's str2node, which needs to both guard against dereferencing a NULL pointer (though in practice it appears none of the callers will ever pass one in), as well as ensure it doesn't parse the empty string as node 0 due to strtol's awkward interface. Submitted by: James Clarke <jtrc27@jrtc27.com> Obtained from: CheriBSD Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D21914 Notes: svn path=/head/; revision=353326
* Unskip test cases from netbsd-tests by defining __HAVE_FENVLi-Wen Hsu2019-08-311-0/+3
| | | | | | | | | | | | | | | This unskips: - lib.libc.stdlib.strtod_test.strtod_round - lib.msun.fe_round_test.t_nofe_round In lib/msun/tests/Makefile only define on fe_round_test.c because lib.msun.ilogb_test.ilogb will get wrong results and needs more examination. MFC after: 1 week Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=351648
* lib.libc.gen.getmntinfo_test.getmntinfo_test is unstable since 8/20, skip itLi-Wen Hsu2019-08-231-0/+3
| | | | | | | | | | in CI env temporarily for more offline diagnosis PR: 240049 Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=351416
* Avoid copying too much from the input string.Brooks Davis2019-07-191-1/+1
| | | | | | | | | | | | | | This avoids reading past the end of the static strings. On a system with bounds checking these tests fault. Reviewed by: asomers Obtained from: CheriBSD MFC after: 1 week Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D21004 Notes: svn path=/head/; revision=350160
* Include a mode when creating files with openat().Brooks Davis2019-07-181-2/+2
| | | | | | | | | | | Reviewed by: asomers Obtained from: CheriBSD MFC after: 1 week Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D20989 Notes: svn path=/head/; revision=350117
* Fix filename to avoid skipping lib/libc/net/servent test.Olivier Cochard2019-07-151-0/+2
| | | | | | | | | | | PR: 239177 Approved by: ngie MFC after: 1 month Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D20943 Notes: svn path=/head/; revision=350019
* Provide separate accounting for user-wired pages.Mark Johnston2019-05-131-11/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Historically we have not distinguished between kernel wirings and user wirings for accounting purposes. User wirings (via mlock(2)) were subject to a global limit on the number of wired pages, so if large swaths of physical memory were wired by the kernel, as happens with the ZFS ARC among other things, the limit could be exceeded, causing user wirings to fail. The change adds a new counter, v_user_wire_count, which counts the number of virtual pages wired by user processes via mlock(2) and mlockall(2). Only user-wired pages are subject to the system-wide limit which helps provide some safety against deadlocks. In particular, while sources of kernel wirings typically support some backpressure mechanism, there is no way to reclaim user-wired pages shorting of killing the wiring process. The limit is exported as vm.max_user_wired, renamed from vm.max_wired, and changed from u_int to u_long. The choice to count virtual user-wired pages rather than physical pages was done for simplicity. There are mechanisms that can cause user-wired mappings to be destroyed while maintaining a wiring of the backing physical page; these make it difficult to accurately track user wirings at the physical page layer. The change also closes some holes which allowed user wirings to succeed even when they would cause the system limit to be exceeded. For instance, mmap() may now fail with ENOMEM in a process that has called mlockall(MCL_FUTURE) if the new mapping would cause the user wiring limit to be exceeded. Note that bhyve -S is subject to the user wiring limit, which defaults to 1/3 of physical RAM. Users that wish to exceed the limit must tune vm.max_user_wired. Reviewed by: kib, ngie (mlock() test changes) Tested by: pho (earlier version) MFC after: 45 days Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D19908 Notes: svn path=/head/; revision=347532
* Fix `get_int_via_sysctlbyname(..)` on JenkinsEnji Cooper2019-04-221-0/+2
| | | | | | | | | | | | | | | | Initialize `oldlen` to the size of the value, instead of leaving the value unitialized. Leaving it unitialized seems to work by accident on amd64 when running 64-bit programs, but not on i386. This matches patterns in use in other programs. PR: 237458 Approved by: emaste (mentor; implicit) MFC after: 1 week Tested on: ^/head (amd64), ^/stable/11 (i386) Notes: svn path=/head/; revision=346539
* Allow users to override CSTD/CXXSTD on a per-prog basisEnji Cooper2019-03-291-2/+2
| | | | | | | | | | | | | | | | | | | | | The current logic for CSTD/CXXSTD requires homogenity as far as the supported C/C++ standards, which is a sensible default. However, when dealing with differing versions of C++, some code may compile with C++11, but not C++17 (for instance). So in order to avoid having people convert over their code to the new standard, give the users the ability to specify the standard on a per-program basis. This will allow a user to override the supporting standard for a set of programs, mixing C++11 with C++14 (for instance). Reviewed by: asomers Apprved by: emaste (mentor) MFC after: 1 month MFC with: r345708 Differential Revision: https://reviews.freebsd.org/D19738 Notes: svn path=/head/; revision=345709
* Revert r345706: the third time will be the charmEnji Cooper2019-03-291-2/+2
| | | | | | | | | | | | | | | | When a review is closed via Phabricator it updates the patch attached to the review. I downloaded the raw patch from Phabricator, applied it, and repeated my mistake from r345704 by accident mixing content from D19732 and D19738. For my own personal sanity, I will try not to mix reviews like this in the future. MFC after: 1 month MFC with: r345706 Approved by: emaste (mentor, implicit) Notes: svn path=/head/; revision=345707
* Standardize `-std=c++* as `CXXSTD`Enji Cooper2019-03-291-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | CXXSTD was added as the C++ analogue to CSTD. CXXSTD defaults to `-std=c++11` with supporting compilers; `-std=gnu++98`, otherwise for older versions of g++. This change standardizes the CXXSTD variable, originally added to googletest.test.inc.mk as part of r345203. As part of this effort, convert all `CXXFLAGS+= -std=*` calls to use `CXXSTD`. Notes: This value is not sanity checked in bsd.sys.mk, however, given the two most used C++ compilers on FreeBSD (clang++ and g++) support both modes, it is likely to work with both toolchains. This method will be refined in the future to support more variants of C++, as not all versions of clang++ and g++ (for instance) support C++14, C++17, etc. Any manual appending of `-std=*` to `CXXFLAGS` should be replaced with CXXSTD. Example: Before this commit: ``` CXXFLAGS+= -std=c++14 ``` After this commit: ``` CXXSTD= c++14 ``` Reviewed by: asomers Approved by: emaste (mentor) MFC after: 1 month MFC with: r345203, r345704, r345705 Relnotes: yes Tested with: make tinderbox Differential Revision: https://reviews.freebsd.org/D19732 Notes: svn path=/head/; revision=345706
* Revert r345704Enji Cooper2019-03-291-2/+2
| | | | | | | | | | | | I accidentally committed code from two reviews. I will reintroduce the code to bsd.progs.mk as part of a separate commit from r345704. Approved by: emaste (mentor, implicit) MFC after: 2 months MFC with: r345704 Notes: svn path=/head/; revision=345705
* CXXSTD is the C++ analogue to CSTD.Enji Cooper2019-03-291-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | CXXSTD defaults to `-std=c++11` with supporting compilers; `-std=gnu++98`, otherwise for older versions of g++. This change standardizes the CXXSTD variable, originally added to googletest.test.inc.mk as part of r345203. As part of this effort, convert all `CXXFLAGS+= -std=*` calls to use `CXXSTD`. Notes: This value is not sanity checked in bsd.sys.mk, however, given the two most used C++ compilers on FreeBSD (clang++ and g++) support both modes, it is likely to work with both toolchains. This method will be refined in the future to support more variants of C++, as not all versions of clang++ and g++ (for instance) support C++14, C++17, etc. Any manual appending of `-std=*` to `CXXFLAGS` should be replaced with CXXSTD. Example: Before this commit: ``` CXXFLAGS+= -std=c++14 ``` After this commit: ``` CXXSTD= c++14 ``` Reviewed by: asomers Approved by: emaste (mentor) MFC after: 1 month Relnotes: yes Differential Revision: https://reviews.freebsd.org/D19732 Notes: svn path=/head/; revision=345704
* Drop "All rights reserved" from my copyright statements.John Baldwin2019-03-061-1/+0
| | | | | | | | | Reviewed by: rgrimes MFC after: 1 month Differential Revision: https://reviews.freebsd.org/D19485 Notes: svn path=/head/; revision=344855
* Make `server_cat(..)` handle short receivesEnji Cooper2019-02-191-27/+27
| | | | | | | | | | | | | | | | | | | | | | | In short, the prior code was far too simplistic when it came to calling recv(2) and failed intermittently (or in the case of Jenkins, deterministically). Handle short recv(2)s by checking the return code and incrementing the window into the buffer by the number of received bytes. If the number of received bytes <= 0, then bail out of the loop, and test the total number of received bytes vs the expected number of bytes sent for equality, and base whether or not the test passes/fails on that fact. Remove the expected failure, now that the hdtr testcases deterministically pass on my host after this change [1]. PR: 234809 [1], 235200 Reviewed by: asomers Approved by: emaste (mentor) MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D19188 Notes: svn path=/head/; revision=344310
* Avoid the DNS lookup for "localhost"Enji Cooper2019-02-041-4/+13
| | | | | | | | | | | | | | | | ci.FreeBSD.org does not have access to a DNS resolver/network (unlike my test VM), so in order for the test to pass on the host, it needs to avoid the DNS lookup by using the numeric host address representation. PR: 235200 Reviewed by: asomers, lwhsu Approved by: emaste (mentor) MFC after: 2 weeks MFC with: r343362, r343365, r343367-r343368, r343461 Differential Revision: https://reviews.freebsd.org/D19026 Notes: svn path=/head/; revision=343751
* libc/tests: Add test case for jemalloc/libthr bug fixed in r343566Kyle Evans2019-01-314-0/+178
| | | | | | | | | | | Submitted by: Andrew Gierth (original reproducer; kevans massaged for atf) Reviewed by: kib MFC after: 2 weeks X-MFC-with: r343566 (or after) Differential Revision: https://reviews.freebsd.org/D19027 Notes: svn path=/head/; revision=343599
* Fix reporting errors with `gai_strerror(..)`Enji Cooper2019-01-261-1/+1
| | | | | | | | | | | | | | The return value (`err`) should be checked; not the `errno` value. PR: 235200 Approved by: emaste (mentor) Reviewed by: asomers, lwhsu MFC after: 28 days MFC with: r343362, r343365, r343367-r343368 Differential Revision: https://reviews.freebsd.org/D18969 Notes: svn path=/head/; revision=343461
* Fix up r343367Enji Cooper2019-01-231-1/+1
| | | | | | | | | | | | | I should have only changed the format qualifier with the `size_t` value, `length`, not the other [`off_t`] value, `dest_file_size`. MFC after: 1 month MFC with: r343362, r343365, r343367 Approved by: emaste (mentor; implicit) Reported by: gcc 8.x Notes: svn path=/head/; revision=343368
* Unbreak the build on architectures where size_t isn't synonymous with uintmax_tEnji Cooper2019-01-231-2/+2
| | | | | | | | | | | | | | | I should have used `%zu` instead of `%ju` with `size_t` types. MFC after: 1 month MFC with: r343362, r343365 Approved by: emaste (mentor; implicit) Reviewed by: asomers Pointyhat to: ngie Submitted by: asomers Differential Revision: https://reviews.freebsd.org/D18935 Notes: svn path=/head/; revision=343367
* Unbreak the gcc build with sendfile_test after r343362Enji Cooper2019-01-231-5/+5
| | | | | | | | | | | | | | | | | | gcc 8.x is more pedantic than clang 7.x with format strings and the tests passed `void*` variables while supplying `%s` (which is technically incorrect). Make the affected `void*` variables use `char*` storage instead to address this issue, as the compiler will upcast the values to `char*`. MFC after: 1 month MFC with: r343362 Approved by: emaste (mentor; implicit) Reviewed by: asomers Differential Revision: https://reviews.freebsd.org/D18934 Notes: svn path=/head/; revision=343365
* Add [initial] functional tests for sendfile(2) as lib/libc/sys/sendfileEnji Cooper2019-01-232-0/+1147
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | These testcases exercise a number of functional requirements for sendfile(2). The testcases use IPv4 and IPv6 domain sockets with TCP, and were confirmed functional on UFS and ZFS. UDP address family sockets cannot be used per the sendfile(2) contract, thus using UDP sockets is outside the scope of testing the syscall in positive cases. As seen in `:s_negative_udp_socket_test`, UDP is used to test the sendfile(2) contract to ensure that EINVAL is returned by sendfile(2). The testcases added explicitly avoid testing out `SF_SYNC` due to the complexity of verifying that support. However, this is a good next logical item to verify. The `hdtr_positive*` testcases work to a certain degree (the header testcases pass), but the trailer testcases do not work (it is an expected failure). In particular, the value received by the mock server doesn't match the expected value, and instead looks something like the following (using python array notation): `trailer[:]message[1:]` instead of: `message[:]trailer[:]` This makes me think there's a buffer overrun issue or problem with the offset somewhere in the sendfile(2) system call, but I need to do some other testing first to verify that the code is indeed sane, and my assumptions/code isn't buggy. The `sbytes_negative` testcases that check `sbytes` being set to an invalid value resulting in `EFAULT` fails today as the other change (which checks `copyout(9)`) has not been committed [1]. Thus, it should remain an expected failure (see bug 232210 for more details on this item). Next steps for testing sendfile(2): 1. Fix the header/trailer testcases so that they pass. 2. Setup if_tap interface and test with it, instead of using "localhost", per @asomers's suggestion. 3. Handle short recv(2)'s in `server_cat(..)`. 4. Add `SF_SYNC` support. 5. Add some more negative tests outside the scope of the functional contract. MFC after: 1 month Reviewed by: asomers Approved by: emaste (mentor) PR: 232210 Sponsored by: Netflix, Inc Differential Revision: https://reviews.freebsd.org/D18625 Notes: svn path=/head/; revision=343362
* Allow multi-byte thousands separators in strfmon(3)Conrad Meyer2018-12-192-0/+72
| | | | | | | | | | PR: 234010 Reported by: Jon Tejnung <jon AT herrskogen.se> Reviewed by: yuripv Differential Revision: https://reviews.freebsd.org/D18605 Notes: svn path=/head/; revision=342260
* regcomp: reduce size of bitmap for multibyte localesYuri Pankov2018-12-121-4/+22
| | | | | | | | | | | | | | | | | | | | | | | | | This fixes the obscure endless loop seen with case-insensitive patterns containing characters in 128-255 range; originally found running GNU grep test suite. Our regex implementation being kludgy translates the characters in case-insensitive pattern to bracket expression containing both cases for the character and doesn't correctly handle the case when original character is in bitmap and the other case is not, falling into the endless loop going through in p_bracket(), ordinary(), and bothcases(). Reducing the bitmap to 0-127 range for multibyte locales solves this as none of these characters have other case mapping outside of bitmap. We are also safe in the case when the original character outside of bitmap has other case mapping in the bitmap (there are several of those in our current ctype maps having unidirectional mapping into bitmap). Reviewed by: bapt, kevans, pfg Differential revision: https://reviews.freebsd.org/D18302 Notes: svn path=/head/; revision=341838
* regexec: fix processing multibyte strings.Yuri Pankov2018-11-232-0/+38
| | | | | | | | | | | | | | | Matcher function incorrectly assumed that moffset that we get from findmust is in bytes. Fix this by introducing a stepback function, taking short path if MB_CUR_MAX is 1, and going back byte-by-byte, checking if we have a legal character sequence otherwise. PR: 153502 Reviewed by: pfg, kevans Approved by: kib (mentor, implicit) Differential revision: https://reviews.freebsd.org/D18297 Notes: svn path=/head/; revision=340835
* Connect libc/tests/time to the build, adding test cases for strptime()Yuri Pankov2018-10-301-0/+1
| | | | | | | | | | | | issues fixed recently, and disabling the failing ones (mostly due to TZ parsing differences with NetBSD). Reviewed by: ngie Approved by: kib (mentor) Differential Revision: https://reviews.freebsd.org/D17546 Notes: svn path=/head/; revision=339904
* 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