Commit graph

441 commits

Author SHA1 Message Date
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
Enji Cooper 81e7d81dc3 One more sys/types.h kevent clarification missed in r312151 2017-01-14 09:47:06 +00:00
Enji Cooper ecab856bc9 Clarify why sys/types.h #include is needed on FreeBSD 2017-01-14 09:45:46 +00:00
Enji Cooper c8300756f2 Use cleanup routines to remove POSIX semaphores instead of just blindly
unlinking them at the beginning of the testcase

This is a lot more intelligent in cleaning up the semaphores if the testcase
fails before sem_unlink is called.

Contributed back as bin/51872 upstream.
2017-01-14 09:42:06 +00:00
Enji Cooper 2a1440c618 Diff reduce with upstream by taking diff hunks that were contributed back 2017-01-14 09:38:40 +00:00
Enji Cooper 9f30f6b7c3 Readd the CMSG_DATA for assigning the kqueue... this testcase isn't officially
correct yet, but it's getting closer.
2017-01-14 09:25:09 +00:00
Enji Cooper 25785590d5 Remove extra EVSET I added in r312146 by accident 2017-01-14 09:21:36 +00:00
Enji Cooper a41b7cf58e Diff reduce with upstream
Use CMSG_FIRSTHDR macro to properly link the kqueue to the socket to
get it to now return -1/EBADF with sendmsg per the testcase expectations
2017-01-14 09:20:54 +00:00
Enji Cooper 7bb9bc9cc2 Try to consolidate the #ifdef soup into FreeBSD vs non-FreeBSD blocks better 2017-01-14 08:47:00 +00:00
Enji Cooper 0e6a2253dc Diff reduce with upstream 2017-01-14 08:39:53 +00:00
Enji Cooper 6e515978dd Remove comment no longer true since the test no longer bombs out earlier on 2017-01-14 08:38:21 +00:00
Enji Cooper 04f40d86db Diff reduce with upstream 2017-01-14 08:36:43 +00:00
Enji Cooper 50e474a4f6 :strtold_nan: remove unnecessary strcmp check
It gets checked again later on in the testcase
2017-01-14 08:35:29 +00:00
Enji Cooper 1081817ad5 Diff reduce with upstream 2017-01-14 08:12:57 +00:00
Enji Cooper 154be35857 Use copy of sha2.h from libnetbsd 2017-01-14 08:11:17 +00:00
Enji Cooper 0e3f47800f Restore deleted line 2017-01-14 07:59:33 +00:00
Enji Cooper 1cb4521644 Diff reduce with upstream using lib/libnetbsd's updated copy of sha1.h 2017-01-14 07:58:40 +00:00
Enji Cooper 9a62e988b3 r312133 should have used the non-FreeBSD block 2017-01-14 07:50:29 +00:00
Enji Cooper 4e9c68081e Diff reduce with upstream by using util.h from libnetbsd instead of libutil.h 2017-01-14 07:48:22 +00:00
Enji Cooper 3b85282333 Diff reduce with upstream 2017-01-14 07:39:07 +00:00
Enji Cooper 88dd6cd01d Copy ^/vendor/NetBSD/tests/dist/lib/libc/hash/t_hmac.c to
contrib/netbsd-tests/lib/libc/hash/t_hmac.c

This was missed in r303980
2017-01-14 07:16:15 +00:00
Enji Cooper 8eace6ac0f Try again with a better commit message 2017-01-14 07:15:14 +00:00
Enji Cooper 519b4f22b0 Copy ^/vendor/NetBSD/tests/dist to contrib/netbsd-tests
This was missed in r303980
2017-01-14 07:14:25 +00:00
Enji Cooper 63d1fd5970 Merge content currently under test from ^/vendor/NetBSD/tests/dist/@r312123
Sponsored by:	Dell EMC Isilon
2017-01-14 06:49:17 +00:00
Enji Cooper 792bbaba98 Remove contrib/netbsd-tests/fs/nfs/nfsservice/rpcbind
This should have been pruned in r305358

MFC after:	3 days
Sponsored by:	Dell EMC Isilon
2017-01-14 06:16:57 +00:00
Enji Cooper 36b9e15c66 Delete trailing whitespace and use __arraycount instead of nitems in contrib code
MFC after:	1 week
2017-01-14 03:54:23 +00:00
Enji Cooper a5deb9babb Note that sys/types.h is required on FreeBSD for kqueue(2), unlike NetBSD
MFC after:	12 days
X-MFC with:	r305358
Sponsored by:	Dell EMC Isilon
2017-01-14 01:01:02 +00:00
Enji Cooper cdebaff820 Upgrade NetBSD tests to 01.11.2017_23.20 snapshot
This contains some new testcases in /usr/tests/...:

- .../lib/libc
- .../lib/libthr
- .../lib/msun
- .../sys/kern

Tested on:	amd64, i386
MFC after:	1 month
2017-01-13 03:33:57 +00:00
Enji Cooper 9527fa4f66 Remove __HAVE_LONG_DOUBLE #define from t_strtod.c and place it in Makefile
This is to enable support in other testcases

Inspired by lib/msun/tests/Makefile .

MFC after:	1 week
2017-01-12 08:40:52 +00:00
Enji Cooper 35cfc322f1 Fix lib/libc/sys/access_test after r311925
sys/param.h needs to be #included in order for __FreeBSD_version to be checked

MFC after:	13 days
2017-01-12 08:31:42 +00:00
Enji Cooper bccef7f6d9 Consolidate __NetBSD__ #ifdef
MFC after:	3 days
2017-01-11 10:20:35 +00:00
Enji Cooper ddba0402f4 Import testcase updates with code contributed back to NetBSD
This also (inadvertently) contains an update to
contrib/netbsd-tests/lib/libc/sys/t_wait.c (new testcases).

MFC after:		2 weeks
In collaboration with:	christos@NetBSD.org
2017-01-11 09:51:34 +00:00
Enji Cooper d1a6b5fb2f Fix whitespace in comment
MFC after:	3 days
2017-01-11 09:34:42 +00:00
Enji Cooper 0e0dd02306 Partially revert r311236
There's no sense in trying to close a file descriptor from the negative cases
with unlink_test; it's best to ignore these cases.

The mkfifo case does make sense to keep though.

MFC after:	3 days
2017-01-11 07:22:21 +00:00
Enji Cooper 19f27f3c34 Fix up r311227
Check for creat returning a value != -1, not a non-zero value

MFC after:	3 days
Pointyhat to:	ngie
Reported by:	Coverity
CID:		1368366
2017-01-11 07:17:03 +00:00
Enji Cooper 7931520d40 Diff reduce with upstream by removing signal.h #include
MFC after:	3 days
2017-01-10 10:27:09 +00:00
Enji Cooper b6a72c5dbe Merge ^/vendor/NetBSD/tests/dist@r311868
This is the vendor accepted version of ^/head@r311245

MFC after:	3 days
2017-01-10 10:16:59 +00:00
Enji Cooper 2bbc0fe246 Merge the grammar fix for lib/libc/gen/raise_test:raise_stress
MFC after:	3 days
2017-01-10 10:12:36 +00:00
Enji Cooper 20a4ce8bf2 Redo fix for CID 979581
The previous change was flawed in terms of how it calculated the
buffer length for the sockaddr_un object. Use SUN_LEN where
appropriate and mute the Coverity complaint by using memset(.., 0, ..)
to zero out the entire structure instead of setting .sun_len to a bogus
value and strlcpy'ing in the contents of argv[1].

SUN_LEN is now being passed to bind(2) as well. For some odd reason
this wasn't flagged as a bug with Coverity.

Reported by:	jilles, jmallett
MFC after:	2 days
X-MFC with:	r311233
2017-01-05 07:46:57 +00:00
Enji Cooper d6766132c2 run: ensure pthread_condattr_{init,setclock} is successful
MFC after:	1 week
Reported by:	Coverity
CID:		1268631, 1268633
2017-01-04 09:06:49 +00:00
Enji Cooper dca7cc9815 setrlimit_basic: don't leak buf; free it on completion
MFC after:	3 days
Reported by:	Coverity
CID:		978311
2017-01-04 09:00:16 +00:00
Enji Cooper fcc9604d43 revoke_perm: don't leak fd at the end of the test; close it
This code is unused on FreeBSD, but it mutes a valid Coverity warning
which would be true on NetBSD

MFC after:	3 days
Reported by:	Coverity
CID:		978311
2017-01-04 08:59:06 +00:00
Enji Cooper 621b0f13af stat_symlink: don't leak fd; close the file descriptor when done
MFC after:	3 days
Reported by:	Coverity
CID:		978314
2017-01-04 08:49:07 +00:00
Enji Cooper c0b11b8e04 pipe_restart: free f on function exit to quell complaint from Coverity
MFC after:	3 days
Reported by:	Coverity
CID:		978307
2017-01-04 08:43:27 +00:00
Enji Cooper 64af3fbaba swapcontext1: test for getcontext(3) and swapcontext(3) success properly
The beforementioned libcalls both succeed if the return codes aren't -1

MFC after:	3 days
Reported by:	Coverity
CID:		976790, 976791
2017-01-04 08:35:46 +00:00
Enji Cooper 7251167f52 Clarify lifetime of child(..) function
Ensure child exits when complete as it's always run in a forked
process.

Add a missing break statement in :pselect_sigmask when calling
child(..) for clarity and to avoid weird domino effects if the
child process somehow does something it's not supposed to do
with the logfiles, file descriptors, etc

MFC after:	1 week
Reported by:	Coverity
CID:		1223369, 1223370, 1300301
2017-01-04 08:25:31 +00:00
Enji Cooper 17a0c1eb75 fpu: ensure calls to pthread_create succeed and test sched_yield to make
sure it returns 0

sched_yield tests for values returning 0 of type int and sched_yield is
of type long, so the test is a mismatch

MFC after:	1 week
Reported by:	Coverity
CID:		1254953, 1254954, 1254965, 1254966
2017-01-04 08:07:48 +00:00
Enji Cooper b5bbd2a17c mincore_resid: free buf after use
MFC after:	3 days
Reported by:	Coverity
CID:		978304
2017-01-04 04:55:33 +00:00
Enji Cooper 83e8b13f15 {strchr,strlen}_basic: don't leak the dlopen'ed handle; close after use
MFC after:	3 days
Reported by:	Coverity
CID:		978299, 978300
2017-01-04 04:50:03 +00:00
Enji Cooper 5d37d9cc25 mknodat_fd: close dfd after use to avoid leaking it
MFC after:	3 days
Reported by:	Coverity
CID:		978287
2017-01-04 04:32:00 +00:00
Enji Cooper f4cbf11049 mkfifoat_fd: close dfd after use to avoid leaking it
MFC after:	3 days
Reported by:	Coverity
CID:		978286
2017-01-04 04:29:53 +00:00
Enji Cooper 5641f109c1 fexecve: don't leak fd on fexecve(2) failure; close before calling err
MFC after:	3 days
Reported by:	Coverity
CID:		978285
2017-01-04 04:27:13 +00:00
Enji Cooper 3b33767589 tty: don't leak s after opening it with openpty
MFC after:	3 days
Reported by:	Coverity
CID:		978321
2017-01-04 04:19:05 +00:00
Enji Cooper 57f5b7d843 mmap_prot_3, mmap_truncate, mmap_truncate_signal: don't leak fd and map
Reported by:	Coverity
CID:		978306, 1251406, 1288196, 1300541
2017-01-04 04:10:36 +00:00
Enji Cooper 619898777b listen_low_port: check for errors from socket(2) before continuing
MFC after:	3 days
Reported by:	Coverity
CID:		976778
2017-01-04 03:59:50 +00:00
Enji Cooper 2020383ffd kqueue_desc_passing: initialize m.msg_flags to 0
This mutes an uninitialized scalar warning from Coverity

MFC after:	3 days
Reported by:	Coverity
CID:		979620
2017-01-04 03:54:54 +00:00
Enji Cooper ab25ecadbf umask_open: don't leak fd on success
MFC after:	3 days
Reported by:	Coverity
CID:		978315
2017-01-04 03:41:16 +00:00
Enji Cooper 3c917d6fa3 unlink_fifo: don't leak the file descriptors opened with mkfifo and open
MFC fater:	3 days
Reported by:	Coverity
CID:		978316, 978317
2017-01-04 03:35:23 +00:00
Enji Cooper 6a64e31600 ttyname_err: close fd if it was opened successfully
MFC after:	3 days
Reported by:	Coverity
CID:		978292
2017-01-04 02:52:39 +00:00
Enji Cooper cc34906655 Fix Coverity issues
- Initialize .sun_len before passing it to strlcpy and bind.
- Close fd on error

MFC after:	3 days
Reported by:	Coverity
CID:		978283, 979581
2017-01-04 02:46:36 +00:00
Enji Cooper 251d8e776e humanize_number_basic: don't leak buf
MFC after:	3 days
Reported by:	Coverity
CID:		1251407
2017-01-04 02:38:14 +00:00
Enji Cooper 06cd8428bc ftok_link: don't leak fd
MFC after:	3 days
Reported by:	Coverity
CID:		978291
2017-01-04 02:34:30 +00:00
Enji Cooper 05aee7d5b0 seekdir_basic: fix various Coverity issues
Address..
- .. resource leaks of file descriptors and memory
- .. unchecked return values from creat(2), mkdir(2), and telldir(3)
- .. potential NULL derefs after calling readdir(3)

MFC after:	1 week
Reported by:	Coverity
CID:		975255, 975256, 976989, 978989, 978990
2017-01-04 02:31:05 +00:00
Enji Cooper cc7734cbac Change the process limits for RLIMIT_MEMLOCK to RLIM_INFINITY when
executing :mincore_resid

The default process limits in FreeBSD is 64kB for unprivileged users,
which empirically is too low to run the :mincore_resid testcase.

Process limits are inherited, so even though the default limit for
root users is RLIM_INFINITY, the inherited limit with "sudo" with the
default login.conf will be 64kB.

Use setrlimit to set rlim_max for RLIMIT_MEMLOCK to RLIM_INFINITY to
avoid ENOMEM issues when calling mlock to wire the mmap'ed address
space.

setrlimit requires root access to increase rlim_max, so require root
privileges when running the test

Discovered when executing the tests with sudo, e.g.
"sudo kyua test -k /usr/tests/lib/libc/sys/Kyuafile mincore_test"

MFC after:	2 weeks
2016-12-10 22:08:33 +00:00
Enji Cooper 5eabf0ffea Use _test_unmount instead of test_unmount in cleanup to avoid
false positives with atf_check when tmpfs is not loaded, etc

MFC after:	1 week
2016-12-09 23:44:25 +00:00
Enji Cooper 60fbebc327 - Ignore errors from umount
- Use _test_unmount instead of test_unmount in cleanup

MFC after:	1 week
2016-12-09 23:43:33 +00:00
Enji Cooper 5be335bb11 Make test_unmount usable in cleanup subroutines
- Duplicate test_unmount to _test_unmount
- Remove atf_check calls
- Call _test_unmount from test_unmount, checking the exit code
  at the end, and returning it to maintain the test_unmount
  "contract"

MFC after:	1 week
2016-12-09 23:42:04 +00:00
Enji Cooper 7f9dff23d3 Only run mdconfig -d -u 3 if /dev/md3 exists on the system
This will prevent "cleanup failures" (exit code != 0 returned) when
tmpfs is not loaded

MFC after:	1 week
2016-12-09 22:50:43 +00:00
Bryan Drewery b4af531e83 Remove unneeded hack fixed by r309626.
strvis(3) being tainted by our mbtowc(3) calls was causing
spurious failures here.

MFC after:	2 weeks
Sponsored by:	Dell EMC Isilon
2016-12-06 17:06:14 +00:00