Commit Graph

441 Commits

Author SHA1 Message Date
Alexander Ziaee
088cc7d221 man filesystems: fix more xrefs after move to s4
Fixes: 1a720cbec5
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1282
2024-06-27 18:32:05 -06:00
Warner Losh
d37eb51047 contrib: Remove various $FreeBSD$ tags not upstream
Sponsored by:		Netflix
2024-05-31 13:49:17 -06:00
Kyle Evans
e55512504d Prepare the system for _FORTIFY_SOURCE
Notably:
- libc needs to #undef some of the macros from ssp/* for underlying
  implementations
- ssp/* wants a __RENAME() macro (snatched more or less from NetBSD)

There's some extra hinkiness included for read(), since libc spells it
as "_read" while the rest of the world spells it "read."

Reviewed by:	imp, ngie
Sponsored by:	Stormshield
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D32307
2024-05-13 00:23:50 -05:00
Mark Johnston
8eb21b4ff0 tmpfs tests: Remove an xfail annotation
This test passes after commit 08f3d5b60c ("copy_file_range: Call
vn_rdwr() at least once").

PR:		274615
MFC after:	1 month
2024-04-04 17:04:30 -04:00
Dag-Erling Smørgrav
8311bc5f17 tmpfs: Improve file time tests.
* The empty test case no longer fails because 89f1dcb3eb causes empty
  files to bypass the bug.
* The bug still exists, so add a test case which exercises it.
* While here, tighten up some of the checks.

A similar patch has been submitted upstream.

PR:		274615
X-MFC-With:	89f1dcb3eb
Sponsored by:	Juniper Networks, Inc.
Sponsored by:	Klara, Inc.
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D44609
2024-04-04 15:40:54 +02:00
Ed Maste
63f5375513 Add expected failure for tmpfs atime test failing on FreeBSD
PR:		274615
Reviewed by:	ngie
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D42321
2023-10-22 10:58:52 -04:00
Dag-Erling Smørgrav
b9385720f3 libc: Add unit tests for N2630 and possible collateral damage.
Reviewed by:	imp, emaste
Differential Revision:	https://reviews.freebsd.org/D41512
2023-08-28 15:34:05 +00:00
Kyle Evans
79e6ffb695 netbsd-tests: libc: fix strvis(3) overflow tests
These tests weren't run on x86 until CI grabbed them.  It turns out,
there's a sign extension bug that surfaces on x86 with char being a
signed type.

NetBSD unearthed this when they took and improved the patch, so just
grab their solution until we get to merging in the latest version of
the test.

Reported by:	CI (via ngie)
Fixes:	2f489a509e ("libc: fix some overflow scenarios in vis(3)")
2023-08-20 00:36:23 -05:00
Kyle Evans
2f489a509e libc: fix some overflow scenarios in vis(3)
The previous incarnation of this would call wcrtomb() on the destination
buffer, and only check for overflow *after* it's happened.
Additionally, the conversion error / VIS_NOLOCALE path also didn't check
for overflow, and the overflow check at the end didn't account for the
fact that we still need to write a NUL terminator afterward.

Start by only doing the multibyte conversion into mbdst directly if we
have enough buffer space to guarantee it'll fit.  An additional
MB_CUR_MAX buffer has been stashed on the stack to write into if we're
cutting it close at the end of the buffer, since we don't really have a
good way to determine the length of the wchar_t without just doing the
conversion.  We'll do the conversion into the buffer that's guaranteed
to fit, then copy it over if the copy won't overflow.

The byte-for-byte overflow is a little bit easier, as we simply check
for overflow with each byte written and make sure we can still NUL
terminate after.

Tests added to exercise these edge cases.

Reviewed by:	des
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D41328
2023-08-08 12:01:52 -05:00
Dmitry Chagin
a18b956b73 libexecinfo: Enable backtrace_test.backtrace_fmt_basic on amd64 again
Due to unwind tables generation enabled after c969310c for csu.

PR:			241562, 246322, 246537
Reviewed by:		kib, ngie
Differential Revision:	https://reviews.freebsd.org/D40758
2023-06-29 19:53:07 +03:00
Mark Johnston
478de7f8e2 netbsd-tests: Remove some pointless sleeps from message queue tests
- In the msgctl tests, there is no point in sleeping after a fork().
  Just block immediately in wait().
- In non-blocking send/recv tests, just wait for the child to exit once
  it's reached a message limit.  If a bug prevents the child from
  exiting promptly, the test will time out.

MFC after:	1 week
2023-03-10 17:06:46 -05:00
Dag-Erling Smørgrav
606d0e4a9a libc: Add tests for strchrnul(3).
MFC after:	1 week
Sponsored by:	Klara, Inc.
Reviewed by:	allanjude
Differential Revision:	https://reviews.freebsd.org/D38286
2023-02-02 15:45:45 +01:00
Dag-Erling Smørgrav
d8c9f80891 libc: Update mktime(3) / timegm(3) tests.
Sponsored by:	Klara, Inc.
Reviewed by:	ngie
Differential Revision:	https://reviews.freebsd.org/D38177
2023-01-25 07:22:46 +01:00
Jessica Clarke
9fb118bebc libc: Fix longjmp/_longjmp(buf, 0) for AArch64 and RISC-V
These architectures fail to handle this special case, and will cause the
corresponding setjmp/_setjmp to return 0 rather than 1. Fix this and add
regression tests (also committed upstream).

PR:		268684
Reviewed by:	arichardson, jhb
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D29363
2023-01-09 18:34:43 +00:00
John Baldwin
d131218534 h_resolv: Fix a buffer overflow in load().
fgetln() returns a pointer to an array of characters that is 'len'
characters long, not 'len + 1'.  While here, overwriting the contents
of the buffer returned by fgetln isn't really safe, so switch to using
getline() instead.

Note that these fixes are a subset of those applied to a
near-identical copy of this function in libc's resolv_test.c in commit
2afeaad315.

Reviewed by:	ngie
Reported by:	CHERI (buffer overflow)
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D37886
2022-12-28 09:39:18 -08:00
Eric van Gyzen
20917cac7b sysv test: properly wait for children
In the msg and shm tests, if the child exited before the parent
entered sigsuspend(), the test would hang and time out.  This was
also a problem in the sem test, but the misuse of atf_tc_pass()
masked it.  Adding a short sleep before the sigsuspend() calls made
the hang 100% reliable.  With the same sleep in the new version,
the test passes reliably.

Remove calls to atf_tc_pass().  The call in the sem test broke the test
by exiting prematurely, after only one child out of five had finished.
The other two were harmless but unhelpful.

Reduce a one-second sleep to a more reasonable duration so I can quickly
run many iterations of the test.

Where feasible, assert that wait() returns the child PID.  While I'm here,
use the more succinct ATF_REQUIRE* instead of if/atf_tc_fail/else.

Flush stdout before forking to avoid double-flush.

Use errx() when errno is irrelevant.

Don't use ATF_REQUIRE* in children.  Apparently, the output doesn't
get saved.  The exit status works, so it fails correctly, but silently.

Re-enable the test in CI.

PR:		233649
Reviewed by:	markj (previous version)
MFC after:	1 week
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D35187
2022-05-13 11:38:26 -05:00
Eric van Gyzen
4e71258227 newfs_msdos: connect the ATF test from NetBSD
NetBSD has an ATF test for newfs_msdos.  Connect it to the build.
Adapt it for FreeBSD.  This would have caught the bug fixed by my
previous commit.

Reviewed by:	delphij, emaste
MFC after:	1 week
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D34116
2022-02-16 09:56:16 -06:00
Mark Johnston
95c75073d3 netbsd-tests: Fix the libc stat_socket test
The test tries to connect a socket to a closed port at 127.0.0.1.  It
sets O_NONBLOCK on the socket first and expects to get EINPROGRESS from
connect(2), but this is not guaranteed, ECONNREFUSED is possible.
Handle both cases, and re-enable the test.

PR:		240621
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2022-01-14 15:01:41 -05:00
Mark Johnston
7bd2df8c82 Revert "Disable flaky test lib.libc.sys.setrlimit_test.setrlimit_stack"
The stack gap implementation is disabled by default now, so the test
passes.

This reverts commit dad71022bd.

PR:		259969
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2022-01-14 14:58:56 -05:00
Marcin Wojtas
4b97eef0bb Revert "t_setrlimit: Adjust resource limit to 20M"
This reverts commit 4f741801d8.

As per discussion in PR: 260303 the reverted patch covered the
real issue with a fixed address of the top of the stack.
2021-12-20 18:33:06 +01:00
Dawid Gorecki
4f741801d8 t_setrlimit: Adjust resource limit to 20M
With ASLR enabled by default, RLIMIT_STACK test fails due to the fact
that default stack gap can be as big as 15M. Because of that the
resource limit of 4M results in test program receiving SIGSEGV
immediately after exiting the setrlimit syscall. Since the idea of this
test is to check if rlim_cur does not extend past rlim_max, adjusting
the resource limit to 20M should not invalidate the test results.

Obtained from:		Semihalf
Sponsored by:		Alstom Group
Differential revision:	https://reviews.freebsd.org/D33116
2021-12-20 06:28:20 +01:00
Konstantin Belousov
f16ec9c6e3 Add tests for posix_spawn_file_actions_add{chdir,fchdir}_np(3)
Reviewed by:	kevans, ngie (previous version)
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D33143
2021-11-30 03:43:54 +02:00
Konstantin Belousov
e8b6309c70 netbsd h_raw.c test: fake use of sum to avoid warning
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2021-11-29 17:39:51 +02:00
Konstantin Belousov
631607ac29 t_mlock.c: Remove null_errno, it is write-only
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2021-11-29 17:39:51 +02:00
Li-Wen Hsu
dad71022bd
Disable flaky test lib.libc.sys.setrlimit_test.setrlimit_stack
PR:		259969
Sponsored by:	The FreeBSD Foundation
2021-11-28 14:58:21 +08:00
Warner Losh
4aed5c3c9d time_t is pathological: use %j + cast to print it.
Sponsored by:		Netflix
2021-10-01 12:16:10 -06:00
Eric van Gyzen
35e4527e88 sem_clockwait_np test: fix usage of ATF API
ATF_REQUIRE_ERRNO requires the given errno iff the given expression is
true.  These test cases used it incorrectly, potentially allowing
sem_clockwait_np to succeed when it was expected to fail.  Use separate
ATF calls to require failure and the expected errno.

MFC after:	1 week
Sponsored by:	Dell EMC Isilon
2021-10-01 06:39:34 -05:00
Eric van Gyzen
2334abfd01 sem test: move sem_clockwait_np tests into individual cases
Move these tests into individual test cases for all the usual reasons.
No functional change intended.

MFC after:	1 week
Sponsored by:	Dell EMC Isilon
2021-10-01 06:39:34 -05:00
Eric van Gyzen
31466594cd sem_clockwait_np test: relax time constraint on VMs
In a guest on a busy hypervisor, the time remaining after an
interrupted sleep could be much lower than other environments.
Relax the lower bound on VMs.

MFC after:	1 week
Sponsored by:	Dell EMC Isilon
2021-10-01 06:39:30 -05:00
Jilles Tjoelker
0c47338023 libc/tests: Correctly compare si_status from wait6()
Fix erroneous = that was meant to be ==.

Revision 1.10 from NetBSD t_wait.c

Obtained from:	NetBSD
2021-07-25 22:19:18 +02:00
Warner Losh
bf26ea7755 t_getgroups: No longer expected to fail
Sponsored by:		Netflix
2021-06-02 13:24:47 -06:00
Cyril Zhang
f9e565abca sort: Make NetBSD sort tests compatible with our sort
This diff primarily adds/removes flags to make the tests compatible with
sort.  Two tests are removed.  One test is changed to expect fail due to
a bug.

Reviewed by:	markj
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D30217
2021-05-13 09:33:47 -04:00
Alex Richardson
87d65c747a lib/msun: Allow building tests with WARNS=6
The only change needed is to mark a few variables as static.
2021-03-22 11:55:07 +00:00
Alex Richardson
c88c1f23a8 Allow ssp_test:read to pass more reliably
It appears that the stackframe layout can be slightly different depending on
compiler and target architecture. For example, when using CHERI LLVM for RISC-V
we can actually overflow the buffer by up to 8 bytes without SSP detecting it.
Fix this by increasing the overflow to 15 bytes.

Reviewed By:	ngie, emaste
Differential Revision: https://reviews.freebsd.org/D28997
2021-03-01 19:56:05 +00:00
Alex Richardson
1ec3feb648 Update libm tests from NetBSD
I did this without a full vendor update since that would cause too many
conflicts. Since these files now almost match the NetBSD sources the
next git subtree merge should work just fine.

Reviewed By:	lwhsu
Differential Revision: https://reviews.freebsd.org/D28797
2021-02-22 17:41:04 +00:00
Alex Richardson
2aa3ef285a libc: Fix t_spawn_fileactions test after ATF update
Since 4581cefc1e
ATF opens the results file on startup. This fixes problems like
capsicumized tests not being able to open the file on exit.

However, this test closes all file descriptors above 3 to get a
deterministic fd table allocation for the child. Instead of using closefrom
(which will close the ATF output file FD) I've changed this test use
the lowest available fd and pass that to the helper program as a string.

We could also try to re-open the results file in ATF if we get a EBADF
error, but that will fail when running under Capsicum.

Reviewed By:	cem
Differential Revision: https://reviews.freebsd.org/D28684
2021-02-18 14:02:47 +00:00
Alex Richardson
10fc4c3218 Fix two failing tests after ATF update
Since 4581cefc1e
ATF opens the results file on startup. This fixes problems like
capsicumized tests not being able to open the file on exit.

However, this test closes all file descriptors just to check that
socketpair returns fd 3+4 and thereby also closes the ATF results file.
This then results in an EBADF when writing the result so the test is
reported as broken.

While system calls that create new file descriptors (must?) use the lowest
available file descriptor number, it does not seem useful to test this
property here. Drop the check for FD==3/4 to unbreak the testsuite.

We could also try to re-open the results file in ATF if we get a EBADF
error, but that will fail when running under Capsicum.

Reviewed By:	cem
Differential Revision: https://reviews.freebsd.org/D28683
2021-02-15 22:55:12 +00:00
Alex Richardson
90b5fc9583 lib/libc/tests/rpc: Correctly set timeout
The rpc_control() API does not accept the CLCR_SET_RPCB_TIMEOUT command,
it only accepts RPC_SVC_CONNMAXREC_GET/RPC_SVC_CONNMAXREC_SET, so it was
not doing anything.
Instead of incorrectly calling this API, use clnt_create_timed() instead.

I noticed this because the test was timing out after 120s in the CheriBSD CI.

Reviewed By:	ngie
Differential Revision: https://reviews.freebsd.org/D28478
2021-02-13 13:53:01 +00:00
Dimitry Andric
2512066228 Fix lib/msun/test builds on platforms without 80-bit long doubles
After d3338f3355, the lib/msun test case
'hypotl_near_underflow' would fail to compile on platforms where long
doubles weren't 80 bit, like on x86. Disable this particular test on
such platforms for now.

PR:		253313
MFC after:	1 week
X-MFC-With:     d3338f3355
2021-02-11 12:01:10 +01:00
Dimitry Andric
d3338f3355 Fix incorrect hypotl(3) result with subnormal numbers
This adjusts the factor used to scale the subnormal numbers, so it
becomes the right value after adjusting its exponent. Thanks to Steve
Kargl for finding the most elegant fix.

Also enable the hypot tests, and add a test case for this bug.

PR:		253313
MFC after:	1 week
2021-02-10 23:28:43 +01:00
Dimitry Andric
51af033287 Add test case for 93fc678965 (incorrect powf(3) result)
This adds the test case to contrib/netbsd-tests/lib/libm/t_pow.c, as it
is currently the only place testing pow(3) and friends.

MFC after:	1 week
2021-02-09 23:37:18 +01:00
Kyle Evans
3e2d96ac97 grep: fix -A handling in conjunction with -m match limitation
The basic issue here is that grep, when given -m 1, would stop all
line processing once it hit the match count and exit immediately.  The
problem with exiting immediately is that -A processing only happens when
subsequent lines are processed and do not match.

The fix here is relatively easy; when bsdgrep matches a line, it resets
the 'tail' of the matching context to the value supplied to -A and
dumps anything that's been queued up for -B. After the current line has
been printed and tail is reset, we check our mcount and do what's
needed. Therefore, at the time that we decide we're doing nothing, we
know that 'tail' of the context is correct and we can simply continue
on if there's still more to pick up.

With this change, we still bail out immediately if there's been no -A
flag. If -A was supplied, we signal that we should continue on. However,
subsequent lines will not even bothere to try and process the line.  We
have reached the match count, so even if the next line would match then
we must process it if it hadn't. Thus, the loop in procfile() can
short-circuit and just process the line as a non-match until
procmatches() indicates that it's safe to stop.

A test has been added to reflect both that we should be picking up the
next line and that the next line should be considered a non-match even
if it should have been.

PR:		253350
MFC-after:	3 days
2021-02-08 12:41:22 -06:00
Kyle Evans
f823c6dc73 grep: fix null pattern and empty pattern file behavior
The null pattern semantics were terrible because I tried to match gnugrep,
but I got it wrong.  Let's unwind that:

- The null pattern should match every line if neither -w nor -x.
- The null pattern should match empty lines if -x.
- The null pattern should not match any lines if -w.

The first two will stop processing (shortcut) even if additional patterns
are specified. In any other case, we will continue processing other
patterns.  If no other patterns are specified beside a null pattern, then
we match if neither -w nor -x or set and do not match if either of those
are specified.

The justification for -w is that it should match on a whole word, but the
null pattern deos not have a whole word to match on.

Empty pattern files should never match anything, and more importantly, -v
should cause everything to be written.

PR:		253209
MFC-after:	4 days
2021-02-04 20:59:42 -06:00
Alex Richardson
83ff5d5d98 Un-XFAIL two tests with Clang > 10
SVN r343917 fixed this for in-tree clang, but when building with a newer
out-of-tree clang the test was still marked as XFAIL.

Reviewed By:	dim
Differential Revision: https://reviews.freebsd.org/D28390
2021-01-28 17:24:24 +00:00
Kyle Evans
9e1281eaba libc: tests: hook CPUSET(9) test up to the build
Add shims to map NetBSD's API to CPUSET(9). Obviously the invalid input
parts of these tests are relatively useless since we're just testing the
shims that aren't used elsewhere, there's still some amount of value in
the parts testing valid inputs.

Differential Revision:	https://reviews.freebsd.org/D27307
2020-12-31 12:26:01 -06:00
Kyle Evans
4f1efa309c libc: regex: partial revert of r368358
Part of the libregex functionality leaked into the tests it shares with
the standard regex(3). Introduce a P flag to set the REG_POSIX cflag to
indicate that libc regex should effectively do nothing while libregex should
specifically run it in non-extended mode.

This unbreaks the libc/regex test run.

Reported by:	Jenkins
2020-12-05 14:38:46 +00:00
Kyle Evans
6b986646d4 libregex: implement \b and \B (word boundary, not word boundary)
This is the last of the needed GNU expressions before we can unleash bsdgrep
by default. \b is effectively an agnostic equivalent of \< and \>, while
\B will match every space that isn't making a transition from
nonchar -> char or char -> nonchar.
2020-12-05 03:16:05 +00:00
Alex Richardson
371f152c7f Significantly speed up libthr/mutex_test and make more reliable
Instead of using a simple global++ as the data race, with this change we
perform the increment by loading the global, delaying for a bit and then
storing back the incremented value. If I move the increment outside of the
mutex protected range, I can now see the data race with only 100 iterations
on amd64 in almost all cases. Before this change such a racy test almost
always passed with < 100,000 iterations and only reliably failed with the
current limit of 10 million.

I noticed this poorly written test because the mutex:mutex{2,3} and
timedmutex:mutex{2,3} tests were always timing out on our CheriBSD Jenkins.
Writing good concurrency tests is hard so I won't attempt to do so, but this
change should make the test more likely to fail if pthread_mutex_lock is not
implemented correctly while also significantly reducing the time it takes to
run these four tests. It will also reduce the time it takes for QEMU RISC-V
testsuite runs by almost 40 minutes (out of currently 7 hours).

Reviewed By:	brooks, ngie
Differential Revision: https://reviews.freebsd.org/D26473
2020-11-26 13:31:57 +00:00
Adrian Chadd
cdd9aa250e [tests] Fix itimer test warning-errors on gcc-6.4
This fixes a "suggested parens" compile warning-into-error
that shows up on gcc-6.4.

Reviewed by:	ngie
Differential Revision:	https://reviews.freebsd.org/D26789
2020-10-15 14:55:07 +00:00
Mitchell Horne
6955543a88 tmpfs tests: check for built-in tmpfs module
As of r363471, tmpfs is included in all GENERIC kernel configs. This
results in a warning being emitted for each call to kldload(8):

module_register: cannot register tmpfs from tmpfs.ko; already loaded from kernel

Check for the presence of the module via kldstat first to quiet this
warning.

Reviewed by:	asomers, arichardson
Differential Revision:	https://reviews.freebsd.org/D26632
2020-10-02 00:52:31 +00:00