Commit Graph

409 Commits

Author SHA1 Message Date
Eric van Gyzen
dc26651a96 Update pthread_cond_timedwait() test to current NetBSD
NetBSD adapted and committed our r350620.  Update to their version 1.8.

Reviewed by:	ngie
Obtained from:	NetBSD
MFC after:	1 week
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D21279
2019-08-16 13:10:08 +00:00
Eric van Gyzen
e48c002fa4 Relax time constraint in pthread_cond_timedwait unit test
pthread_cond_timedwait() should wait _at least_ until the timeout,
but it might appear to wait longer due to system activity and
scheduling.  The test ignored fractional seconds when comparing the
actual and expected timeouts, so it allowed anywhere between zero
and one extra second of wait time.  Zero is a bit unreasonable.
Compare fractional seconds so we always allow up to one extra second.

Reviewed by:	ngie
MFC after:	1 week
Sponsored by:	Dell EMC Isilon
2019-08-05 22:59:35 +00:00
Li-Wen Hsu
7e37c475fa Temporarily skip lib.libc.regex.exhaust_test.regcomp_too_big and
lib.libregex.exhaust_test.regcomp_too_big on i386 as they are flakey on it

PR:		237450
Sponsored by:	The FreeBSD Foundation
2019-07-22 18:42:55 +00:00
Brooks Davis
1575a795cb Add missing mode in open(2) calls with O_CREAT.
When O_CREAT is specified, the third, variadic argument is
required as the permission. If on is not passed, then depending
on the ABI, either the contents of the third argument register
or some arbitrary stuff on the stack will be used as the permission.

This has been merged to NetBSD.

Reviewed by:	asomers, ngie
Obtained from:	CheriBSD
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D20972
2019-07-16 22:27:49 +00:00
Mark Johnston
54a3a11421 Provide separate accounting for user-wired pages.
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
2019-05-13 16:38:48 +00:00
Kyle Evans
79483833d0 MFV r345515: netbsd-tests: import memory bump for libc/regex/t_exhaust
MFC after:	3 days
2019-03-26 02:21:09 +00:00
Mark Johnston
b16150ea90 Have pthread_cond_destroy() return EBUSY if the condvar has waiters.
This is not required of a compliant implementation, but it's easy to
check for and helps improve compatibility with other common
implementations.  Moreover, it's consistent with our
pthread_mutex_destroy().

PR:		234805
Reviewed by:	jhb, kib, ngie
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D19496
2019-03-08 21:07:08 +00:00
Dimitry Andric
bc8fc00705 Amend r343442, by only expecting the lib.msun.cbrt_test.cbrtl_powl and
trig_test.reduction test cases to fail, if the fixes from r343916 have
not yet been applied to the base compiler.

Reported by:    lwhsu
PR:		234040
Upstream PR:	https://bugs.llvm.org/show_bug.cgi?id=40206
MFC after:	1 week
2019-02-08 18:31:54 +00:00
Li-Wen Hsu
24df7b15fa Temporarily mark lib.msun.{cbrt_test.cbrtl_powl,trig_test.reduction}
expected failure after clang700-import merge

PR:		234040
Reviewed by:	ngie, markj
Approved by:	markj (mentor)
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D18938
2019-01-25 18:48:20 +00:00
Konstantin Belousov
ea7e7006db Implement shmat(2) flag SHM_REMAP.
Based on the description in Linux man page.

Reviewed by:	markj, ngie (previous version)
Sponsored by:	Mellanox Technologies
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D18837
2019-01-16 05:15:57 +00:00
Konstantin Belousov
b87850b96e Trim spaces at the end of lines.
Reviewed by:	markj, ngie
Sponsored by:	Mellanox Technologies
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D18837
2019-01-16 05:09:29 +00:00
Yuri Pankov
adeebb8308 Make mbstowcs_basic test pass, now that we have more ctype definitions.
Reported by:	jenkins
Approved by:	kib (mentor, implicit)
2018-11-17 12:59:59 +00:00
Yuri Pankov
9eb7d595e1 Reset persistent mbstates when rune locale encoding changes.
This was shown to be a problem by side effect of now-enabled test case,
which was going through C, en_US.UTF-8, ja_JP.SJIS, and ja_JP.eucJP,
and failing eventually as data in mbrtowc's mbstate, that was
perfectly correct for en_US.UTF-8 was treated as incorrect for
ja_JP.SJIS, failing the entire test case.

This makes the persistent mbstates to be per ctype-component,
and not per-locale so we could easily reset the mbstates when
only LC_CTYPE is changed.

Reviewed by:	bapt, pfg
Approved by:	kib (mentor, implicit)
Differential Revision:	https://reviews.freebsd.org/D17796
2018-11-09 03:32:53 +00:00
Yuri Pankov
32a8ec8bdd strptime: make %k and %l specifiers match their description in
strftime(3), and allow them to process space-padded input.

PR:		230720
Submitted by:	rlittle@inetco.com (original version)
Approved by:	kib (mentor, implicit)
Differential Revision:	https://reviews.freebsd.org/D17761
2018-11-03 23:37:13 +00:00
Yuri Pankov
281c29899f Connect libc/tests/time to the build, adding test cases for strptime()
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
2018-10-30 02:37:23 +00:00
Ruslan Bukin
7db2360401 Increase timeout for timedmutex_test:mutex2, timedmutex_test:mutex3
tests.

Default value is 300. It takes ~310s to complete each of these tests
in QEMU/RISC-V.

Sponsored by:	DARPA, AFRL
2018-08-06 15:55:58 +00:00
Ruslan Bukin
380122186e Replace __riscv__ with __riscv.
__riscv__ is not pre-defined anymore by latest version of GNU compiler.

Sponsored by:	DARPA, AFRL
2018-08-03 12:47:54 +00:00
Alan Somers
46e1f0715d Fix tmpfs detection in the sys/fs/tmpfs tests
This code was originally written for NetBSD.  r306031 tried to adapt it to
FreeBSD, but didn't correctly handle the case that tmpfs was available, but
not already loaded.  Fix the logic to load the module if necessary.  The
tmpfs tests shouldn't be skipped anymore.

Also, fix a comment that was dislocated by r306031.

Reported by:	Jenkins
MFC after:	2 weeks
2018-07-21 23:54:40 +00:00
Andrew Turner
acfbf59013 Stop writing past the end of the buffer in the msgget_limit test. The value
in i is already correct to write to the last item in the buf array.

Obtained from:	CheriBSD
Sponsored by:	DARPA, AFRL
2018-07-19 17:13:46 +00:00
Kyle Evans
52cf896593 netbsd-tests: bsdgrep(1): Add a test for -m, too 2018-06-07 18:53:39 +00:00
Kyle Evans
ce024bdc0c netbsd-tests: grep(1): Add test for -c flag
Someone might be inclined to accidentally break this. someone might have
written said test because they broke it locally.
2018-06-07 18:06:01 +00:00
Brooks Davis
75c1df31cf Fix build post r330299 2018-03-02 23:31:55 +00:00
Bryan Drewery
70c144dc78 nanosleep(2): Fix bogus incrementing of rmtp by tc_tick_sbt on [EINTR].
sbt is the time in the future that the tsleep_sbt() is expected to be completed
at.  sbtt is the current time.  Depending on the precision with sysctl
kern.timecounter.alloweddeviation the start time may be incremented by
tc_tick_sbt.  The same increment is needed for the current time of sbtt before
calculating the difference.  The impact of missing this increment is that rmtp
may increase by one tc_tick_sbt on every early [EINTR] return.  If the same
struct is passed in for rqtp as rmtp this can result in rqtp effectively
incrementing by tc_tick_sbt and sleeping longer than originally intended.

This problem was introduced in r247797.

Reviewed by:	kib, markj, vangyzen (all on an older version of the test)
MFC after:	2 weeks
Sponsored by:	Dell EMC
Differential Revision:	https://reviews.freebsd.org/D14362
2018-02-14 18:43:50 +00:00
Alan Somers
fa82818f1d Fix Coverity CIDs in the sys/kern/sysv_test tests
CID 979810: strcpy => strlcpy
CID 1193367: don't leak a file descriptor
CID 1299856: Check the return value of read(2)

Reported by:	Coverity
Coverity CID:	978910 1193367 1299856
MFC after:	3 weeks
X-MFC-With:	328896
Sponsored by:	Spectra Logic Corp
2018-02-13 19:17:33 +00:00
Alan Somers
dc4e221c3a Convert tools/regression/sockets/socketpair to ATF
Reviewed by:	cem
MFC after:	3 weeks
Differential Revision:	https://reviews.freebsd.org/D14305
2018-02-10 19:43:52 +00:00
Brooks Davis
5e1e3ea237 Fix and enable SysV IPC tests.
Don't declare some types that FreeBSD incorrectly declares.

Fix an incorrect call to open() (missing mode).

ANSIfy prototypes.

Enable SysV message queue, semaphore, and shared memory tests.

With exception of the workaround for union semun, these fixes have been
committed to NetBSD.

Reviewed by:	asomers
Approved by:	CheriBSD
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D13471
2018-02-05 18:48:00 +00:00
John Baldwin
68e709cb29 Update limits on makecontext() arguments in the setcontext_link test.
sparc64 and riscv do not support 10 arguments, but MIPS now does.
While here, combine clauses for architectures that support the same
number of arguments to reduce duplication.

Sponsored by:	DARPA / AFRL
2018-01-31 18:03:40 +00:00
Kyle Evans
acfa114e53 Remove t_grep:mmap_eof_not_eol test
The test was marked as an expected failure in r320414 after r319971's import
of a newer jemalloc removed an essential feature (opt.redzone) for
reproducing the behavior it was testing. Since then, no way has been found
or demonstrated to reliably test the behavior, so remove the test.

PR:		220309
2018-01-29 18:50:45 +00:00
Alan Somers
76f9d2759b mlock(2): correct documentation for error conditions.
The man page is years out of date regarding errors. Our implementation _does_
allow unaligned addresses, and it _does_not_ check for negative lengths,
because the length is unsigned. It checks for overflow instead.

Update the tests accordingly.

Reviewed by:	bcr
MFC after:	3 weeks
Differential Revision:	https://reviews.freebsd.org/D13826
2018-01-22 21:45:54 +00:00
Kyle Evans
c552f48b6f bsdgrep: add some additional tests for fgrep
Previously added tests only check that fgrep is somewhat sane and works. Add
some more tests that check that the implementation is basically functional
and not producing incorrect results with various flags.

Reviewed by:	cem, emaste, ngie
Approved by:	emaste (mentor)
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D12056
2017-08-24 01:20:52 +00:00
Kyle Evans
a4a801688c regex(3): Handle invalid {} constructs consistently and adjust tests
Currently, regex(3) exhibits the following wrong behavior as demonstrated
with sed:

 - echo "a{1,2,3}b" | sed -r "s/{/_/"     (1)
 - echo "a{1,2,3}b" | sed "s/\}/_/"       (2)
 - echo "a{1,2,3}b" | sed -r "s/{}/_/"    (3)

Cases (1) and (3) should throw errors but they actually succeed, and (2)
throws an error when it should match the literal '}'. The correct behavior
was decided by comparing to the behavior with the equivalent BRE (1)(3) or
ERE (2) and consulting POSIX, along with some reasonable evaluation.

Tests were also adjusted/added accordingly.

PR:		166861
Reviewed by:	emaste, ngie, pfg
Approved by:	emaste (mentor)
MFC after:	never
Differential Revision:	https://reviews.freebsd.org/D10315
2017-08-08 04:10:46 +00:00
Ruslan Bukin
ca20f8ec29 o Replace __riscv__ with __riscv
o Replace __riscv64 with (__riscv && __riscv_xlen == 64)

This is required to support new GCC 7.1 compiler.
This is compatible with current GCC 6.1 compiler.

RISC-V is extensible ISA and the idea here is to have built-in define
per each extension, so together with __riscv we will have some subset
of these as well (depending on -march string passed to compiler):

__riscv_compressed
__riscv_atomic
__riscv_mul
__riscv_div
__riscv_muldiv
__riscv_fdiv
__riscv_fsqrt
__riscv_float_abi_soft
__riscv_float_abi_single
__riscv_float_abi_double
__riscv_cmodel_medlow
__riscv_cmodel_medany
__riscv_cmodel_pic
__riscv_xlen

Reviewed by:	ngie
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D11901
2017-08-07 14:09:57 +00:00
Kyle Evans
0e95794283 bsdgrep(1): Don't exit before processing every file
Given an empty pattern (i.e. grep "" A B), bsdgrep(1) would previously exit()
with the appropriate exit code upon encountering an empty file. Likely intended
as an optimization, but this behavior is technically incorrect since an empty
pattern should match every line.

PR:		220924
Reviewed by:	emaste, cem (earlier version), ngie
Approved by:	emaste (mentor)
Differential Revision:	https://reviews.freebsd.org/D11698
2017-07-25 01:50:37 +00:00
Kyle Evans
c043764469 Add regression test for recent regex(3) breakage
BREs recently became prematurely sensitive to the branching operator, which
outright broke expressions that used it instead of failing silently. Test
that \| is matching a literal | for the time being.

Reviewed by:	cem, emaste, ngie
Approved by:	emaste (mentor)
Differential Revision:	https://reviews.freebsd.org/D11577
2017-07-21 01:35:55 +00:00
Alan Somers
97ae05e314 Remove an extraneous strlen from t_setdomainname.c
Reported by:	Coverity
CID:		1377568
MFC after:	15 days
X-MFC-With:	320737
Sponsored by:	Spectra Logic Corp
2017-07-12 14:51:32 +00:00
Alan Somers
eaca103d94 Fix cleanup in lib/libc/gen/setdomainname_test
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
2017-07-06 14:47:59 +00:00
Enji Cooper
1c227d0049 :snprintf_float: don't blindly set RLIMIT_DATA and RLIMIT_AS to 1 MB -- raise
the limit to 32MB instead.

Require user=root and memory=64MB+ first so one can be reasonably sure that
the test will function appropriately.

MFC after:	1 month
MFC with:	r320726
PR:	220502
2017-07-06 07:59:00 +00:00
Enji Cooper
1f73e6d888 Expect :snprintf_float to segfault
This issue started occurring within the past month or so.

PR:	220502
Reported by:	Jenkins (amd64-head job)
2017-07-06 07:45:20 +00:00
Enji Cooper
69a3d9e7dc Expect :mmap_eof_not_eol to fail
It relies on a jemalloc feature (opt.redzone) no longer available after
r319971.

MFC with:	r318908, r319971
PR:		220309
2017-06-27 17:22:03 +00:00
Konstantin Belousov
2b34e84335 Add abstime kqueue(2) timers and expand struct kevent members.
This change implements NOTE_ABSTIME flag for EVFILT_TIMER, which
specifies that the data field contains absolute time to fire the
event.

To make this useful, data member of the struct kevent must be extended
to 64bit.  Using the opportunity, I also added ext members.  This
changes struct kevent almost to Apple struct kevent64, except I did
not changed type of ident and udata, the later would cause serious API
incompatibilities.

The type of ident was kept uintptr_t since EVFILT_AIO returns a
pointer in this field, and e.g. CHERI is sensitive to the type
(discussed with brooks, jhb).

Unlike Apple kevent64, symbol versioning allows us to claim ABI
compatibility and still name the new syscall kevent(2).  Compat shims
are provided for both host native and compat32.

Requested by:	bapt
Reviewed by:	bapt, brooks, ngie (previous version)
Sponsored by:	The FreeBSD Foundation
Differential revision:	https://reviews.freebsd.org/D11025
2017-06-17 00:57:26 +00:00
Enji Cooper
7c91b65f54 Add testcases for cat -b
MFC after:	1 month
Sponsored by:	Dell EMC Isilon
2017-06-06 21:50:00 +00:00
Enji Cooper
9086e0e068 Add additional testcases for cat(1)
Verify the following additional cases:
- -s (in isolation, in addition to the -se testcase obtained via the
      NetBSD test).
- -vt

Submitted by:	shivansh
Reviewed by:	asomers (earlier diff), ngie
MFC after:	1 month
Sponsored by:	Google, Inc (GSoC 2017)
Differential Revision:	D11020
2017-06-06 21:03:43 +00:00
Ed Maste
d7b654747f bsdgrep: add --mmap tests
Basic sanity tests as well as coverage for the bug fixed in r318565.

Submitted by:	Kyle Evans <kevans91@ksu.edu>
Reviewed by:	bapt, ngie
Differential Revision:	https://reviews.freebsd.org/D10827
2017-05-26 00:19:50 +00:00
Ed Maste
6d635d3b32 bsdgrep: Correct per-line line metadata printing
Metadata printing with -b, -H, or -n flags suffered from a few flaws:

1) -b/offset printing was broken when used in conjunction with -o

2) With -o, bsdgrep did not print metadata for every match/line, just
   the first match of a line

3) There were no tests for this

Address these issues by outputting this data per-match if the -o flag is
specified, and prior to outputting any matches if -o but not --color,
since --color alone will not generate a new line of output for every
iteration over the matches.

To correct -b output, fudge the line offset as we're printing matches.

While here, make sure we're using grep_printline in -A context.  Context
printing should *never* look at the parsing context, just the line.

The tests included do not pass with gnugrep in base due to it exhibiting
similar quirky behavior that bsdgrep previously exhibited.

Submitted by:	Kyle Evans <kevans91@ksu.edu>
Reviewed by:	cem
Differential Revision:	https://reviews.freebsd.org/D10580
2017-05-20 11:20:03 +00:00
Ed Maste
fe8c9d5bf1 bsdgrep: emit more than MAX_LINE_MATCHES per line
We should not set an arbitrary cap on the number of matches on a line,
and in any case MAX_LINE_MATCHES of 32 is much too low.  Instead, if we
match more than MAX_LINE_MATCHES, keep processing and matching from the
last match until all are found.

For the regression test, we produce 4096 matches (larger than we expect
we'll ever set MAX_LINE_MATCHES) and make sure we actually get 4096
lines of output with the -o flag.

We'll also make sure that every distinct line is getting its own line
number to detect line metadata not being printed as appropriate along
the way.

PR:		218811
Submitted by:	Kyle Evans <kevans91@ksu.edu>
Reported by:	jbeich
Reviewed by:	cem
Differential Revision:	https://reviews.freebsd.org/D10577
2017-05-20 03:51:31 +00:00
Enji Cooper
99429157e8 sys/fs/tmpfs/vnd_test: make md(4) allocation dynamic
The previous logic was flawed in the sense that it assumed that /dev/md3
was always available. This was a caveat I noted in r306038, that I hadn't
gotten around to solving before now.

Cache the device for the mountpoint after executing mdmfs, then use the
cached value in basic_cleanup(..) when unmounting/disconnecting the md(4)
device.

Apply sed expressions to use reuse logic in the NetBSD code that could
also be applied to FreeBSD, just with different tools.

Differential Revision:	D10766
MFC after:	1 week
Reviewed by:	bdrewery
Sponsored by:	Dell EMC Isilon
2017-05-19 17:14:29 +00:00
John Baldwin
6dfb9460ca Skip tests depending on coredumps if coredumps are disabled via kern.coredump.
The kern.coredump sysctl can be set to 0 to disable coredumps.  Skip the
'status_coredump' and 'wait6_coredumped' tests if this sysctl is set to 0
rather than reporting a failure.

Submitted by:	brooks
Reviewed by:	ngie
Obtained from:	CheriBSD
Sponsored by:	DARPA / AFRL
Differential Revision:	https://reviews.freebsd.org/D10665
2017-05-16 18:42:44 +00:00
Ed Maste
f701bdc59e bsdgrep: add more tests for different binary flags
The existing 'binary' test in netbsd-tests/ does a basic check of the
default treatment for binary behavior, but not much more than that.
Given some opportunity for breakage recently that did not trigger any
failures, add some tests to cover the three different binary file
behaviors (a, -I, -U) and their --binary-files= equivalent values.

Submitted by:	Kyle Evans <kevans91@ksu.edu>
Reviewed by:	cem, ngie
Differential Revision:	https://reviews.freebsd.org/D10620
2017-05-15 20:41:29 +00:00
Enji Cooper
33cbbff80f lib/libc/gen/realpath_test: make check result from getcwd(3)
This is being done to avoid dereferencing a NULL pointer via strlcat,
obscuring the underlying issue with the getcwd(3) call.

MFC after:	2 weeks
Sponsored by:	Dell EMC Isilon
2017-05-15 19:58:01 +00:00
Ed Maste
b5fc583c27 bsdgrep: don't allow negative -A / -B / -C
Previously, when given a negative -A/-B/-C argument bsdgrep would
overflow the respective context flag(s) and exhibited surprising
behavior.

Fix this by removing unsignedness of Aflag/Bflag and erroring out if
we're given a value < 0.  Also adjust the type used to track 'tail'
context in procfile() so that it accurately reflects the Aflag value
rather than overflowing and losing trailing context.

This also fixes an inconsistency previously existing between -n and
-C "n" behavior.  They are now both limited to LLONG_MAX, to be
consistent.

Add some test cases to make sure grep errors out properly for both
negative context values as well as non-numeric context values rather
than giving bogus matches.

Submitted by:	Kyle Evans <kevans91@ksu.edu>
Reviewed by:	cem
Differential Revision:	https://reviews.freebsd.org/D10675
2017-05-15 17:51:01 +00:00
Enji Cooper
a229b00539 Fix up previous commit
- Apply the logic to the FreeBSD block
- Fix a typo with the getconf(1) call that I would have caught, were
  it not for the fact that I got the blocks wrong.
- Consolidate the hardcoded buffer sizes to the NetBSD block.

This would have been discovered had I run the test on a system where
PATH_MAX != 1024 (I don't have that at my disposal right at this moment).

MFC after:	3 weeks
MFC with:	r318210
Sponsored by:	Dell EMC Isilon
2017-05-12 05:17:49 +00:00
Enji Cooper
8fb58d8b6a ssp_test:read:: query the value of MAXPATHLEN via getconf(1)
In the event the value of PATH_MAX was changed, the assumption that
MAXPATHLEN is 1024 (and hence the buffer length required to trigger
SSP to fail for read(2)) would be invalidated. Query getconf(1) for
the actual value of MAXPATHLEN via _XOPEN_PATH_MAX instead, and
increment the value by 1 to ensure that the SSP support tests the
stack smashing support properly.

MFC after:	3 weeks
Sponsored by:	Dell EMC Isilon
2017-05-12 05:06:48 +00:00
Enji Cooper
a41afc8290 Remove expected failure that no longer fails with gnu grep in base
Reported by:	Jenkins
Submitted by:	Kyle Evans <kevans91@ksu.edu>
Sponsored by:	Dell EMC Isilon
2017-05-09 04:11:53 +00:00
Ed Maste
e2127de812 bsdgrep: don't ouptut matches with -c, -l, -L
Refactoring done in r317703 broke -c, -l, and -L flags implying
suppression of match printing.  Fortunately this is just a matter of not
doing any printing of the resulting matches and context printing was not
broken in this refactoring.

Add some regression tests since this area may still see further
refactoring, include different context flags as well even though they
were not broken in this case.

PR:		219077
Submitted by:	Kyle kevans91@ksu.edu
Reported by:	markj
Reviewed by:	cem, ngie
Differential Revision:	https://reviews.freebsd.org/D10607
2017-05-05 17:35:05 +00:00
Brooks Davis
e351474725 Remove expected failure now that it was fixed in r317660.
PR:		211804
Reviewed by:	ngie
Obtained from:	CheriBSD
MFC after:	2 weeks
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D10576
2017-05-02 22:14:55 +00:00
Ed Maste
a4f3f02be6 bsdgrep: fix -w flag matching with an empty pattern
-w flag matching with an empty pattern was generally 'broken', allowing
matches to occur on any line whether or not it actually matches -w
criteria.

This fix required a good amount of refactoring to address.  procline()
is altered to *only* process the line and return whether it was a match
or not, necessary to be able to short-circuit the whole function in case
of this matchall flag. -m flag handling is moved out as well because it
suffers from the same fate as context handling if we bypass any actual
pattern matching.

The matching context (matches, mostly) didn't previously exist outside
of procline(), so we go ahead and create context object for file
processing bits to pass around.  grep_printline() was created due to
this, for the scenarios where the matches don't actually matter and we
just want to print a line or two, a la flushing the context queue and
no -o or --color specified.

Damage from this broken behavior would have been mitigated by the fact
that it is unlikely users would invoke grep -w with an empty pattern.

This was identified while checking PR 105221 for problems it this may
cause in BSD grep, but PR 105221 is *not* a report of this behavior.

Submitted by:	Kyle Evans <kevans91 at ksu.edu>
Differential Revision:	https://reviews.freebsd.org/D10433
2017-05-02 20:39:33 +00:00
Ed Maste
befd089c0d bsdgrep: revise test case which will soon become a failure
Work in progress (D10315) is going to make egrep_empty_invalid an
actually invalid regex, to be consistent with the equivalent BRE "{"
behavior, when using regex(3).

Any non-0 exit value is acceptable, depending on how the installed grep
interprets the expression. GNU grep interprets it as non-matching, and
in the future BSD grep will interpret it is an error.

Submitted by:	Kyle Evans <kevans91 at ksu.edu>
Reviewed by:	cem, ngie
Differential Revision:	https://reviews.freebsd.org/D10572`
2017-05-02 18:37:11 +00:00
Ed Maste
945fc991b2 bsdgrep: fix -w -v matching improperly with certain patterns
-w and -v flag matching was mostly functional but had some minor
problems:

1. -w flag processing only allowed one iteration through pattern
   matching on a line. This was problematic if one pattern could match
   more than once, or if there were multiple patterns and the earliest/
   longest match was not the most ideal, and

2. Previous work "fixed" things to not further process a line if the
   first iteration through patterns produced no matches. This is clearly
   wrong if we're dealing with the more restrictive -w matching.

#2 breakage could have also occurred before recent broad rewrites, but
it would be more arbitrary based on input patterns as to whether or not
it actually affected things.

Fix both of these by forcing a retry of the patterns after advancing
just past the start of the first match if we're doing more restrictive
-w matching and we didn't get any hits to start with. Also move -v flag
processing outside of the loop so that we have a greater change to match
in the more restrictive cases. This wasn't strictly wrong, but it could
be a little more error prone.

While here, introduce some regressions tests for this behavior and fix
some excessive wrapping nearby that hindered readability. GNU grep
passes these new tests.

PR:		218467, 218811
Submitted by:	Kyle Evans <kevans91 at ksu.edu>
Reviewed by:	cem, ngie
Differential Revision:	https://reviews.freebsd.org/D10329
2017-05-02 02:32:10 +00:00
Enji Cooper
5199917cc6 Add more sanity tests for grep, egrep, and fgrep
The test suite currently lacks basic sanity checks to ensure that egrep,
fgrep, and grep are actually matching the right expression types, i.e. passing
the right flags to regcomp(3). Amend the test suite to make sure that not only
are the individual versions doing the right thing, but also that we don't have some
kind of frankenregex situation happening where egrep is accepting a BRE or
grep an ERE.

I've chosen to not expand the 'basic' test but to add the 'grep_sanity' checks
to their own test case since this is testing for more than just 'grep matches things',
but actual expression types.

Differential Revision:	D10444
Reviewed by:	emaste, ngie
Submitted by:	Kyle Evans <kevans91@ksu.edu>
Tested with:	bsdgrep, gnu grep (base, ports)
Sponsored by:	Dell EMC Isilon
2017-04-22 21:40:10 +00:00
Enji Cooper
6e5e4dbd06 Remove the expected failures for :context and :context2 with bsdgrep(1)
They're no longer needed after recent fixes made to bsdgrep(1).

Submitted by:	Kyle Evans <kevans91@ksu.edu> (via a previous diff in D10433)
Sponsored by:	Dell EMC Isilon
2017-04-22 21:26:15 +00:00
Ed Maste
e06ffa3230 bsdgrep: fix zero-length matches without the -o flag
r316477 broke zero-length matches when not using the -o flag, by
skipping over them entirely.

Add a regression test so that it doesn't break again in the future.

Submitted by:	Kyle Evans <kevans91 at ksu.edu>
Reviewed by:	cem emaste ngie
Differential Revision:	https://reviews.freebsd.org/D10333
2017-04-17 14:59:55 +00:00
Enji Cooper
9f67a48145 Fix expectations for testcases per bsdgrep vs gnu grep from base/ports
The following failures occur with various versions of grep:

BSD grep:
- :context
- :context2

GNU grep (base):
- :color
- :oflag_zerolen

GNU grep (ports):
- :recurse_symlink

Tested with:	bsdgrep (^/head@r316542), gnu grep (base/2.5.1), gnu grep (ports/2.27)
Reported by:	Jenkins (bsdgrep failures)
Sponsored by:	Dell EMC Isilon
2017-04-13 04:10:27 +00:00
Ed Maste
799c5faa8b bsdgrep: create additional tests for coverage on recent fixes
Create additional tests to cover regressions that were discovered by
PRs linked to reviews D10098, D10102, and D10104.

It is worth noting that neither bsdgrep(1) nor gnugrep(1) in the base
system currently pass all of these tests, and gnugrep(1) not quite being
up to snuff was also noted in at least one of the PRs.

PR:		175314 202022 195763 180990 197555 197531 181263 209116
Submitted by:	Kyle Evans <kevans91@ksu.edu>
Reviewed by:	cem, ngie, emaste
MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D10112
2017-04-05 18:41:44 +00:00
Enji Cooper
9532aae589 Annotate all changes made in r316178-r316180 with __FreeBSD__
Restore the stock (upstream) code under an #else block, so it's easier
for me to visualize and understand the code that needs to be upstreamed.

MFC after:	2 months
X-MFC with:	r316178, r316179, r316180
Sponsored by:	Dell EMC Isilon
2017-03-30 07:13:47 +00:00
Conrad Meyer
70aca7c8e8 t_msgctl: Fix the same msgsnd() misuse as t_msgsnd
msgsnd(2)'s msgsz argument does not describe the full structure, only the
message component.

Reported by:	Coverity
CIDs:		1368703, 1368711
Sponsored by:	Dell EMC Isilon
2017-03-29 21:31:45 +00:00
Conrad Meyer
1a663d3c00 Follow-up to r316179: More of the same
Reported by:	Coverity
CIDs:		1368705, 1368706, 1368707, 1368710
Sponsored by:	Dell EMC Isilon
2017-03-29 21:29:21 +00:00
Conrad Meyer
ebf1bc1768 t_msgsnd: Use msgsnd()'s msgsz argument correctly to avoid overflow
msgsnd's msgsz argument is the size of the message following the 'long'
message type.  Don't include the message type in the size of the message
when invoking msgsnd(2).

Reported by:	Coverity
CID:		1368712
Sponsored by:	Dell EMC Isilon
2017-03-29 21:26:13 +00:00
Enji Cooper
b49d92c2aa Remove all expected failures from lib/libc/locale/io_test for FreeBSD
This is no longer required as of r315616, as the test is no longer
built/installed.

This is being done to diff reduce with NetBSD.

Sponsored by:	Dell EMC Isilon
2017-03-20 03:52:06 +00:00
Eric van Gyzen
3f8455b090 Add clock_nanosleep()
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
2017-03-19 00:51:12 +00:00
Enji Cooper
13081ad7c6 Add additional __FreeBSD_version guards around the hsearch_r testcases
The reasoning for this is the same as r276046: to ease MFCing the tests
to ^/stable/10 .

This was accidentally missed in r313439

MFC after:	1 week
X-MFC with:	r313439
Sponsored by:	Dell EMC Isilon
2017-03-01 03:31:12 +00:00
Eric van Gyzen
b215ceaaec Add sem_clockwait_np()
This function allows the caller to specify the reference clock
and choose between absolute and relative mode.  In relative mode,
the remaining time can be returned.

The API is similar to clock_nanosleep(3).  Thanks to Ed Schouten
for that suggestion.

While I'm here, reduce the sleep time in the semaphore "child"
test to greatly reduce its runtime.  Also add a reasonable timeout.

Reviewed by:	ed (userland)
MFC after:	2 weeks
Relnotes:	yes
Sponsored by:	Dell EMC
Differential Revision:	https://reviews.freebsd.org/D9656
2017-02-23 19:36:38 +00:00
Enji Cooper
cad7148985 Oops... put the atf_tc_expect_fail in the testcase definition, not the
test suite definition
2017-02-07 19:02:59 +00:00
Enji Cooper
ce801ad813 Expect the t_precision long double checks to fail on FreeBSD/i386
There are some potential issues with the test (as brd@ has pointed out
elsewhere) with precision, etc not being set before the test, but as
always, more research is required.
2017-02-07 18:57:52 +00:00
Enji Cooper
62d02a8f74 Add #else case in run(..) to fix test on non-{amd64,arm64,mips} after
recent refactoring to the test
2017-02-07 06:34:02 +00:00
Enji Cooper
a678f77962 MFhead@r313380 2017-02-07 06:04:13 +00:00
Enji Cooper
87e886953f Expect :floatunditf to fail on FreeBSD/i386
The precision error on FreeBSD/i386 doesn't match the expected output in
long double form.

MFC after:	1 week
Sponsored by:	Dell EMC Isilon
2017-02-07 04:15:41 +00:00
Enji Cooper
7047ed6854 Expect :hsearch_r_nonexistent to fail on FreeBSD
The docs and the behavior mismatch; as noted in the bug, the behavior
for hsearch_r matches Linux, whereas the docs seem to match NetBSD
requirements wise.

PR:	216872
2017-02-07 02:57:11 +00:00
Enji Cooper
f2b9adff63 Uncomment more of the hsearch_r testcases
Call hdestroy/hdestroy_r on FreeBSD instead of hdestroy(1?)(_r).

All but hdestroy_r_nonexistent pass as-is.
2017-02-07 02:00:14 +00:00
Enji Cooper
dd66b5baa8 Merge in changes from ^/vendor/NetBSD/tests/dist@r313245
Diff reduce lib/libm/t_pow.c per upstream changes
2017-02-04 18:20:07 +00:00
Enji Cooper
4421971444 Add back #else block accidentally removed in r312145
This fixes the build with !(amd64|arm64|mips*)
2017-01-18 09:46:02 +00:00
Enji Cooper
5f761d3c88 Merge ^/vendor/NetBSD/tests/dist@r312370 2017-01-18 05:36:09 +00:00
Enji Cooper
6fa647788e Reintroduce libutil.h #include for FreeBSD only for fparseln 2017-01-16 20:46:40 +00:00
Enji Cooper
f115a1c3e0 Remove explicit pthread_np.h #include, per change in libnetbsd@r312303 2017-01-16 18:52:05 +00:00
Enji Cooper
ea498175b9 Diff reduce with upstream and prep for next set of content pushes 2017-01-16 18:44:40 +00:00
Enji Cooper
4acf8d706e Diff reduce with upstream by using macros and logic integrated in
later revisions of the test
2017-01-16 18:36:38 +00:00
Enji Cooper
39a3103b41 Use sys/param.h instead of sys/types.h to prep for upstreaming to NetBSD 2017-01-16 18:17:53 +00:00
Enji Cooper
e2a4e9c682 Remove unnecessary whitespace diff 2017-01-16 18:04:14 +00:00
Enji Cooper
183ae521e5 Use _SED instead of hacking tests rewriting mknod ... p as mkfifo
Similar to r312297
2017-01-16 17:53:58 +00:00
Enji Cooper
267f10b14c Use _SED to rewrite mknod ... p command as mkfifo instead of
adding an unnecessary diff to the test
2017-01-16 17:49:53 +00:00
Enji Cooper
3b0a9131e6 Merge ^/vendor/NetBSD/tests/dist@r312294
This includes a number of accepted upstream fixes, as well as
a reimplementation of the net/carp/... testcase (which is
currently unused).
2017-01-16 17:43:43 +00:00
Enji Cooper
89964aab17 Add GLOB_STAR #ifdef to testcases which require GLOB_STAR support 2017-01-16 07:41:39 +00:00
Enji Cooper
f467f63cbb Remove sys/param.h
It was used for nitems, but I converted it to __arraycount later, and
is already pulled in by header pollution on FreeBSD as well as NetBSD
ala sys/cdefs.h
2017-01-16 07:39:08 +00:00
Enji Cooper
5ca8558309 Drop unnecessary diff rewriting dict(..) function
This is already being properly handled via ATF config require.files call
2017-01-16 07:34:45 +00:00
Enji Cooper
6a93de28a6 Diff reduce with upstream and consolidate #ifdefs where possible 2017-01-15 22:00:59 +00:00
Enji Cooper
bfb8e4c9c4 Remove libutil.h #include on FreeBSD and instead favor stdio.h from libnetbsd 2017-01-15 21:38:19 +00:00
Enji Cooper
caeb04e465 lib/libc/gen/t_glob.c: diff reduce with NetBSD's copy 2017-01-15 10:17:15 +00:00
Enji Cooper
f40f3adc42 Pull in ^/vendor/NetBSD/tests/dist@r312219
Remove divergence with upstream where possible
2017-01-15 10:04:20 +00:00
Enji Cooper
83e891f222 Revert t_pow@r312154
This hunk hasn't been accepted yet
2017-01-14 10:10:49 +00:00
Enji Cooper
1f6a3aa8e5 Fix the build using hunks pending upstream contributions 2017-01-14 10:08:22 +00:00
Enji Cooper
e0940c61c2 Diff reduce with upstream post-accepted contributions 2017-01-14 10:05:26 +00:00