Commit Graph

498 Commits

Author SHA1 Message Date
Andriy Gapon
72891bc15d re-enable zfs_copies_006_pos test after a fix in r330977
The test was disabled in r329408.

PR:		225960
2018-03-15 09:28:10 +00:00
Andriy Gapon
3c9d418b7e re-enable zpool_upgrade_007_pos test after the fix in r330974
The test was disabled in r329248.

PR:		225877
2018-03-15 08:52:49 +00:00
Alan Somers
4b40bdbd1f Add tests for lagg(4) and other cloned network interfaces
Unfortunately, most of the tests are disabled because they fairly frequently
trigger panics.

MFC after:	3 weeks
Sponsored by:	Spectra Logic Corp
2018-02-23 18:18:42 +00:00
Alan Somers
2fae26bd8b Add the ZFS test suite
It was originally written by Sun as part of the STF (Solaris test framework).
They open sourced it in OpenSolaris, then HighCloud partially ported it to
FreeBSD, and Spectra Logic finished the port.  We also added many testcases,
fixed many broken ones, and converted them all to the ATF framework.  We've had
help along the way from avg, araujo, smh, and brd.

By default most of the tests are disabled.  Set the disks Kyua variable to
enable them.

Submitted by:	asomers, will, justing, ken, brd, avg, araujo, smh
Sponsored by:	Spectra Logic Corp, HighCloud
2018-02-23 16:31:00 +00:00
Alan Somers
834063202a gpart: append partition name to the underlying provider's physical path
If the underlying provider's physical path is null, then the gpart device's
physical path will be, too. Otherwise, it will append the partition name,
such as "/p1" or "/s1/a". This will make gpart work better with zfsd(8).

PR:		224965
MFC after:	3 weeks
Differential Revision:	https://reviews.freebsd.org/D14010
2018-02-14 20:26:09 +00:00
Alan Somers
0bab7fa8a7 geli: append "/eli" to the underlying provider's physical path
If the underlying provider's physical path is null, then the geli device's
physical path will be, too. Otherwise, it will append "/eli".  This will make
geli work better with zfsd(8).

PR:		224962
MFC after:	3 weeks
Differential Revision:	https://reviews.freebsd.org/D13979
2018-02-14 20:15:32 +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
e0a40f3045 Mark the unused argument to continue_thread() as such.
clang in HEAD and 11 does not warn about this, but clang in 10 does.
2018-01-24 17:46:20 +00:00
Conrad Meyer
844d9543dc Add ccp(4): experimental driver for AMD Crypto Co-Processor
* Registers TRNG source for random(4)
* Finds available queues, LSBs; allocates static objects
* Allocates a shared MSI-X for all queues.  The hardware does not have
  separate interrupts per queue.  Working interrupt mode driver.
* Computes SHA hashes, HMAC.  Passes cryptotest.py, cryptocheck tests.
* Does AES-CBC, CTR mode, and XTS.  cryptotest.py and cryptocheck pass.
* Support for "authenc" (AES + HMAC).  (SHA1 seems to result in
  "unaligned" cleartext inputs from cryptocheck -- which the engine
  cannot handle.  SHA2 seems to work fine.)
* GCM passes for block-multiple AAD, input lengths

Largely based on ccr(4), part of cxgbe(4).

Rough performance averages on AMD Ryzen 1950X (4kB buffer):
aesni:      SHA1: ~8300 Mb/s    SHA256: ~8000 Mb/s
ccp:               ~630 Mb/s    SHA256:  ~660 Mb/s  SHA512:  ~700 Mb/s
cryptosoft:       ~1800 Mb/s    SHA256: ~1800 Mb/s  SHA512: ~2700 Mb/s

As you can see, performance is poor in comparison to aesni(4) and even
cryptosoft (due to high setup cost).  At a larger buffer size (128kB),
throughput is a little better (but still worse than aesni(4)):

aesni:      SHA1:~10400 Mb/s    SHA256: ~9950 Mb/s
ccp:              ~2200 Mb/s    SHA256: ~2600 Mb/s  SHA512: ~3800 Mb/s
cryptosoft:       ~1750 Mb/s    SHA256: ~1800 Mb/s  SHA512: ~2700 Mb/s

AES performance has a similar story:

aesni:      4kB: ~11250 Mb/s    128kB: ~11250 Mb/s
ccp:               ~350 Mb/s    128kB:  ~4600 Mb/s
cryptosoft:       ~1750 Mb/s    128kB:  ~1700 Mb/s

This driver is EXPERIMENTAL.  You should verify cryptographic results on
typical and corner case inputs from your application against a known- good
implementation.

Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D12723
2018-01-18 22:01:30 +00:00
Alan Somers
6f7f85e0e1 gnop(8): add the ability to set a nop provider's physical path
While I'm here, expand the existing tests a bit.

MFC after:	3 weeks
Differential Revision:	https://reviews.freebsd.org/D13579
2018-01-18 05:57:10 +00:00
Mark Johnston
a19e742901 Add regression tests for r327779.
MFC after:	2 weeks
Sponsored by:	Dell EMC Isilon
2018-01-10 19:41:05 +00:00
Mark Johnston
00da6aa72b Remove the executable bit from some recently added test scripts. 2018-01-10 15:55:07 +00:00
Kristof Provost
a60f45a0d5 pf tests: Fix pft_ping.py to work with scapy 2.3.3
Scapy requires the Raw payload to be a string, which was not the case. This
caused the pft_ping.py script to fail, which in turn caused the test to fail.
2018-01-09 19:02:42 +00:00
Alan Somers
1d23aa6ec7 geli: optimize tests
Reduce the geli tests' runtime by about a third:

* In integrity_test:copy, use a file-backed md(4) device instead of a
  malloc'd one.  That way we can corrupt the underlying storage without
  needing to detach and reattach the geli device.

* In integrity_test:{copy, hmac, data} and onetime_test:{onetime,
  onetime_a}, move reads of /dev/random out of the loop.

MFC after:	2 weeks
2018-01-08 00:10:45 +00:00
Alan Somers
565a0a2c65 geli: convert remaining TAP tests to ATF
MFC after:	2 weeks
2018-01-07 22:21:07 +00:00
Alan Somers
48c29f849e Fix typo from r327666
MFC after:	13 days
X-MFC-With:	327666
2018-01-07 21:57:52 +00:00
Alan Somers
5dce212d67 geli: fix parallel execution of tests
The trick is not to destroy an md(4) device during a test.  That can create
a "double-free" situation, because we also destroy md devices during test
cleanup.

MFC after:	2 weeks
2018-01-07 02:30:08 +00:00
Alan Somers
f397a004de geli: convert most tests from TAP to ATF
I'm leaving readonly_test and nokey_test alone for now. In a future commit
they should be broken up into several smaller test cases and distributed
between multiple files.

Reviewed by:	ngie
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D13717
2018-01-07 00:44:22 +00:00
Alan Somers
3a8d2bd4a1 geli: fix the resize test on arm64
The resize test used bsdlabel(8), which is not available on all
architectures.  Change it to use gpart(8) instead, which should be available
everywhere.

PR:		221763
Reported by:	andrew
MFC after:	2 weeks
2017-12-29 18:42:55 +00:00
Alan Somers
610b95a173 Fix a harmless typo from r310786
I copy/pasted a reference to an undefined shell variable.

MFC after:	2 weeks
2017-12-29 18:09:06 +00:00
Alan Somers
2e23c41122 geli: factor out some common code in the geli tests
No functional change.

MFC after:	2 weeks
Sponsored by:	Spectra Logic Corp
2017-12-29 16:13:06 +00:00
Alan Somers
041999e3d0 Fix potential TOCTTOU bug in the geli tests
This change mostly reverts r293436, which introduced the bug due to a belief
that geli(8) would allocate md(4) devices by itself. However, that belief is
incorrect. Instead of using linear probing to find available md(4) numbers,
it's best to use the existing attach_md function.

Reviewed by:	ngie
MFC after:	2 weeks
Sponsored by:	Spectra Logic Corp
Differential Revision:	https://reviews.freebsd.org/D13666
2017-12-29 16:06:10 +00:00
Eitan Adler
9914452050 other: Fix several typos and minor errors
- duplicate words
- typos
- references to old versions of FreeBSD

Reviewed by:	imp, benno
2017-12-27 03:23:58 +00:00
John Baldwin
3a014c56c1 Catch up to r325719 which makes the kern.proc.pid sysctl "work" for zombies.
Some of the ptrace tests need to wait for a child process to become a
zombie before preceding.  The parent process polls the child process
via the kern.proc.pid sysctl to wait for it to become a zombie.
Previously the code polled until the sysctl failed with ESRCH.  Now it
will poll until either the sysctl fails with ESRCH (for compatiblity
with older kernels) or returns a kinfo_proc structure with the ki_stat
field set to SZOMB.

Reported by:	Jenkins
Tested by:	markj
Discussed with:	mjg
MFC after:	1 week
2017-12-18 23:35:14 +00:00
Mark Johnston
37a13f5792 Skip gnop tests if the corresponding kernel module isn't available.
Reviewed by:	asomers
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D13500
2017-12-15 17:10:51 +00:00
Mark Johnston
21274cad33 Belatedly add syncwait.
X-MFC with:	r326861
2017-12-14 22:15:46 +00:00
Mark Johnston
504eda2021 Make indentation consistent with other tests, and use syncwait.
MFC after:	2 weeks
Sponsored by:	Dell EMC Isilon
2017-12-14 22:14:07 +00:00
Mark Johnston
ca623e07ce Add some basic tests for gmirror read and write error handling.
MFC after:	2 weeks
Sponsored by:	Dell EMC Isilon
2017-12-14 22:11:35 +00:00
Kristof Provost
02d92cc609 tests: ipsec: Don't load/unload aesni.ko in the test header
We can't kldunload in the test head as Kyua interprets any output from
them. This would lead to syntax errors and skipping the entire file.

Move the kld commands into the test case bodies.

Pointed out by: asomers@
2017-12-03 18:35:07 +00:00
Kristof Provost
4fbebc7472 Add IPSec tests in tunnel mode
Some IPSec in tunnel mode allowing to test multiple IPSec
configurations.  These tests are reusing the jail/vnet scripts from pf
tests for generating complex network.

Submitted by:	olivier@
Differential Revision:	https://reviews.freebsd.org/D13017
2017-12-03 13:52:35 +00:00
Conrad Meyer
38d84d683e vfs_lookup: Allow PATH_MAX-1 symlinks
Previously, symlinks in FreeBSD were artificially limited to PATH_MAX-2.

Add a short test case to verify the change.

Submitted by:	Gaurav Gangalwar <ggangalwar AT isilon.com>
Reviewed by:	kib
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D12589
2017-11-17 19:25:39 +00:00
Alan Somers
c4708ce80c Fix build on arm after r325817
Reported by:	rpokala
MFC after:	3 weeks
X-MFC-With:	325817
Sponsored by:	Spectra Logic Corp
2017-11-14 21:11:55 +00:00
Alan Somers
c52ef9bbff AIO tests: increase limits
tests/sys/aio/aio_kqueue_test.c
	Instead of using a hard-coded queue depth, use
	vfs.aio.max_aio_queue_per_proc

tests/sys/aio/lio_kqueue_test.c
	The old, small limit on lio_listio's operation count was lifted by
	change 324941.  Raise the operation count as high as possible without
	exceeding the process's operation limit.

MFC after:	3 weeks
Sponsored by:	Spectra Logic Corp
2017-11-14 17:46:37 +00:00
Bryan Drewery
ea825d0274 DIRDEPS_BUILD: Update dependencies.
Sponsored by:	Dell EMC Isilon
2017-10-31 00:07:04 +00:00
Bryan Drewery
3806950135 DIRDEPS_BUILD: Connect new directories.
Sponsored by:	Dell EMC Isilon
2017-10-31 00:04:07 +00:00
John Baldwin
e012fe34cb Discard the correct thread event reported for a ptrace stop.
When multiple threads wish to report a tracing event to a debugger,
both threads call ptracestop() and one thread will win the race to be
the reporting thread (p->p_xthread).  The debugger uses PT_LWPINFO
with the process ID to determine which thread / LWP is reporting an
event and the details of that event.  This event is cleared as a side
effect of the subsequent ptrace event that resumed the process
(PT_CONTINUE, PT_STEP, etc.).  However, ptrace() was clearing the
event identified by the LWP ID passed to the resume request even if
that wasn't the 'p_xthread'.  This could result in clearing an event
that had not yet been observed by the debugger and leaving the
existing event for 'p_thread' pending so that it was reported a second
time.

Specifically, if the debugger stopped due to a software breakpoint in
one thread, but then switched to another thread that was used to
resume (e.g. if the user switched to a different thread and issued a
step), the resume request (PT_STEP) cleared a pending event (if any)
for the thread being stepped.  However, the process immediately
stopped and the first thread reported it's breakpoint event a second
time.  The debugger decremented the PC for "both" breakpoint events
which resulted in the PC now pointing into the middle of an
instruction (on x86) and a SIGILL fault when the process was resumed a
second time.

To fix, always clear the pending event for 'p_xthread' when resuming a
process.  ptrace() still honors the requested LWP ID when enabling
single-stepping (PT_STEP) or setting a different PC (PT_CONTINUE).

Reported by:	GDB testsuite (gdb.threads/continue-pending-status.exp)
Reviewed by:	kib
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D12794
2017-10-27 03:16:19 +00:00
Kristof Provost
96b90524d1 pf tests: Remove temporary files
Remove the created_jails.lst and created_interfaces.lst files in the
cleanup code.
2017-10-26 20:55:33 +00:00
Kristof Provost
57d465298a pf tests: Fragmentation (v6) test
Test fragmentation handling (i.e. scrub fragment reassemble) code for
IPv6.

Two simple tests: Ping a host (jail) and test forwarding of fragmented
packets.
2017-10-26 20:54:52 +00:00
Kristof Provost
da86443874 pf tests: destroy jails before destroying interfaces
When cleaning up we must destroy the jails before we destroy the interfaces.
Otherwise we might try to destroy interfaces that belong to a jail, which won't
work and fail to completely clean up.
2017-10-26 20:53:56 +00:00
John Baldwin
54cfb29e3a Add a test for sending a signal while stepping a thread via PT_STEP.
MFC after:	1 week
2017-10-25 17:23:33 +00:00
Bryan Drewery
753e292217 Add a test for r324671 along with some other masked tests.
MFC after:	1 week
Sponsored by:	Dell EMC Isilon
2017-10-17 19:01:01 +00:00
Bryan Drewery
fc1e29dc35 This child is expected to exit on SIGTRAP, don't leave a core behind.
MFC after:	1 week
Sponsored by:	Dell EMC Isilon
2017-10-16 20:06:24 +00:00
Kristof Provost
f038a398da pf tests: Use pft_set_rules everywhere
We now have a utility function to set pf rules in the jail. Use it
whenever we need to set the pf rules in the test jail.
2017-10-16 15:05:32 +00:00
Kristof Provost
ba22aeacf1 pf tests: Basic IPv6 forwarding tests
Pass/block packets in the forwarding path with pf.

Introduce the pft_set_rules() helper function, because we need to
remember to flush states between individual tests. If not we can get
packets passing despite rules blocking them because they match states
created in a previous test.

Extend pft_ping.py to be able to send IPv6 echo requests.
2017-10-16 15:03:45 +00:00
Kristof Provost
67f4baf8b0 pf: test set-tos
Introduce tests for the set-tos feature of pf. Teach pft_ping.py to send
and verify ToS flags.
2017-10-16 15:01:49 +00:00
Bryan Drewery
9643739121 Fix shadowed variable hidden by WARNS changing to 3 in r313006.
Sponsored by:	Dell EMC Isilon
MFC after:	1 week
2017-10-12 19:58:21 +00:00
Enji Cooper
5b347b28cd Check the exit code from fsck_ffs instead of relying on MODIFIED being in the output
^/head@r323923 changed when MODIFIED is printed at exit. It's better to follow the
documented way of determining whether or not a filesystem is clean per fsck_ffs, i.e.,
ensure that the exit code is either 0 or 7.

The pass/fail determination is brittle prior to this commit, and ^/head@r323923 made
the issue apparent -- thus this needs to be fixed independent of ^/head@r323923.

PR:		222780
MFC after:	1 week
MFC with:	r323923
Reported by:	Jenkins
2017-10-10 05:58:33 +00:00
Kristof Provost
c0b63519b0 pf: Very basic forwarding test
This test illustrates the use of scapy to test pf.

Differential Revision:	https://reviews.freebsd.org/D12581
2017-10-06 20:51:32 +00:00
Kristof Provost
1d6f5f214a pf: Basic automated test using VIMAGE
If VIMAGE is present we can start jails with their own pf instance. This
makes it fairly easy to run tests.
For example, this basic test verifies that drop/pass and icmp
classification works. It's a basic sanity test for pf, and hopefully an
example on how to write more pf tests.

The tests are skipped if VIMAGE is not enabled.

This work is inspired by the GSoC work of Panagiotes Mousikides.

Differential Revision:	https://reviews.freebsd.org/D12580
2017-10-06 20:43:14 +00:00
Conrad Meyer
fe182ba1d0 aesni(4): Add support for x86 SHA intrinsics
Some x86 class CPUs have accelerated intrinsics for SHA1 and SHA256.
Provide this functionality on CPUs that support it.

This implements CRYPTO_SHA1, CRYPTO_SHA1_HMAC, and CRYPTO_SHA2_256_HMAC.

Correctness: The cryptotest.py suite in tests/sys/opencrypto has been
enhanced to verify SHA1 and SHA256 HMAC using standard NIST test vectors.
The test passes on this driver.  Additionally, jhb's cryptocheck tool has
been used to compare various random inputs against OpenSSL.  This test also
passes.

Rough performance averages on AMD Ryzen 1950X (4kB buffer):
aesni:      SHA1: ~8300 Mb/s    SHA256: ~8000 Mb/s
cryptosoft:       ~1800 Mb/s    SHA256: ~1800 Mb/s

So ~4.4-4.6x speedup depending on algorithm choice.  This is consistent with
the results the Linux folks saw for 4kB buffers.

The driver borrows SHA update code from sys/crypto sha1 and sha256.  The
intrinsic step function comes from Intel under a 3-clause BSDL.[0]  The
intel_sha_extensions_sha<foo>_intrinsic.c files were renamed and lightly
modified (added const, resolved a warning or two; included the sha_sse
header to declare the functions).

[0]: https://software.intel.com/en-us/articles/intel-sha-extensions-implementations

Reviewed by:	jhb
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D12452
2017-09-26 23:12:32 +00:00
Conrad Meyer
a317fb03c2 crypto(9): Use a more specific error code when a capable driver is not found
When crypto_newsession() is given a request for an unsupported capability,
raise a more specific error than EINVAL.

This allows cryptotest.py to skip some HMAC tests that a driver does not
support.

Reviewed by:	jhb, rlibby
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D12451
2017-09-26 01:31:49 +00:00
Enji Cooper
d86680b073 Convert some idioms over to py3k-compatible idioms
- Import print_function from __future__ and use print(..) instead of `print ..`.
- Use repr instead of backticks when the object needs to be dumped, unless
  print(..) can do it lazily. Use str instead of backticks as appropriate
  for simplification reasons.

This doesn't fully convert these modules over py3k. It just gets over some of
the trivial compatibility hurdles.
2017-09-24 00:14:48 +00:00
Conrad Meyer
67e4d800ec cryptotest.py: Like r323869, skip SHA HMAC tests on non-SHA drivers
Sponsored by:	Dell EMC Isilon
2017-09-22 04:41:48 +00:00
Conrad Meyer
e720124622 cryptotest.py: Fix whitespace style errors
I accidentally introduced different whitespace style in r323878.  I'm not
used to using tabs for indentation in Python scripts.

Whitespace only; no functional change.

Sponsored by:	Dell EMC Isilon
2017-09-22 04:25:44 +00:00
Conrad Meyer
005fdbbc69 cryptotest.py: Actually use NIST-KAT HMAC test vectors and test the right hashes
Previously, this test was entirely a no-op as no vector in the NIST-KAT file
has a precisely 20-byte key.

Additionally, not every vector in the file is SHA1.  The length field
determines the hash under test, and is now decoded correctly.

Finally, due to a limitation I didn't feel like fixing in cryptodev.py, MACs
are truncated to 16 bytes in this test.

With this change and the uncommitted D12437 (to allow key sizes other than
those used in IPSec), the SHA tests in cryptotest.py actually test something
and e.g. at least cryptosoft passes the test.

Sponsored by:	Dell EMC Isilon
2017-09-21 21:07:21 +00:00
Conrad Meyer
b3eaa68045 cryptotest.py: Do not run AES-CBC or AES-GCM tests on non-AES crypto(4) drivers
For some reason, we only skipped AES-XTS tests if a driver was not in the
aesmodules list.  Skip other AES modes as well to prevent spurious failures
in non-AES drivers.

Sponsored by:	Dell EMC Isilon
2017-09-21 18:06:21 +00:00
Conrad Meyer
7abea82d17 cryptotest.py: Add a seatbelt that we're actually testing anything
Without nist-kat installed, cryptotest.py is a no-op.  Showing 'success' in
that case is unhelpful.

Sponsored by:	Dell EMC Isilon
2017-09-21 05:46:28 +00:00
Enji Cooper
188e46ab03 Add supporting changes for Add limited sandbox capability to "make check"
Non-tests/... changes:
- Add HAS_TESTS= to Makefiles with libraries and programs to enable iteration
  and propagate the appropriate environment down to *.test.mk.

tests/... changes:
- Add appropriate support Makefile.inc's to set HAS_TESTS in a minimal manner,
  since tests/... is a special subdirectory tree compared to the others.

MFC after:	2 months
MFC with:	r322511
Reviewed by:	arch (silence), testing (silence)
Differential Revision:	D12014
2017-08-14 19:21:37 +00:00
Alan Somers
4312aa67e3 tests/sys/netinet/fibs_test: skip selected tests when firewalls are enabled
Some tests send packets over epair(4) interfaces. Firewalls can cause
spurious failures.

Reviewed by:	ngie
MFC after:	3 weeks
Sponsored by:	Spectra Logic Corp
Differential Revision:	https://reviews.freebsd.org/D11917
2017-08-08 15:37:21 +00:00
Enji Cooper
d2ba5111c1 Make test scripts under tests/... non-executable
Executable bits should be set at install time instead of in the repo.
Setting executable bits on files triggers false positives with Phabricator.

MFC after:	2 months
2017-08-08 04:59:16 +00:00
Enji Cooper
a9be721ce5 MFhead@r321967 2017-08-03 03:45:48 +00:00
Enji Cooper
acc33f3de9 Chase r321920 and r321930 (dev_t being widened)
The layout of st_rdev has changed after this commit, and assumptions made
in the NetBSD tests are no longer valid. Change the hardcoded assumed
values to account for the fact that major/minor are now represented by
64 bits as opposed to the less precise legacy precision of 16 bits.

PR:	221048
Relnotes: st_rdev layout changed; warning about impact of r321920 to
	  downstream consumers
2017-08-03 03:43:41 +00:00
Enji Cooper
341d6b3579 Use bsd.opts.mk, not src.opts.mk 2017-08-03 00:35:35 +00:00
Enji Cooper
86cc58dc96 MFhead@r321960 2017-08-02 22:28:12 +00:00
Enji Cooper
47606b869e Use MK_CHECK_USE_SANDBOX in tests/..., to deal with the fact that
tests/... is a special snowflake directory and using HAS_TESTS would
result in a nasty layering violation between bsd.tests.mk and
bsd.prog.mk.

Add reachover Makefile.inc's which get the default value from
Makefile.inc0 (inspired by gnu/usr.bin/binutils/Makefile.inc0).
2017-08-02 22:24:08 +00:00
Enji Cooper
3cf56bb43a Annotate tests that require root privileges appropriately
This unbreaks running the tests with unprivileged users.

MFC after:	1 week
2017-08-02 22:19:45 +00:00
Enji Cooper
67b82daf3e Fix cosmetic issue with error message
Add missing space in error message related to PR noted.

MFC after:	2 weeks
PR:		220398
2017-08-02 09:49:41 +00:00
Bryan Drewery
63ab7bb3c8 Allow changing the test PORT at compile-time.
Sponsored by:	Dell EMC Isilon
2017-07-31 22:00:27 +00:00
Enji Cooper
2941d2d603 Remove superfluous exit 0 added in r321702
atf_skip triggers equivalent functionality, which means the `exit 0`
is unreachable code.

PR:		220164
MFC after:	1 month
MFC with:	r321702
2017-07-29 22:03:21 +00:00
Enji Cooper
b8891d7c10 Load geom_gate(4) if necessary before running tests; skip if it can't be loaded
The test code prior to r311893 loaded geom_gate at test start if necessary and
skipped the tests if it couldn't be loaded.

The ATF-ifcation of this test done in r311893 unfortunately dropped this
functionality.

This change restores the geom_gate module load and skips the test(s) if unavailable
in an ATF-like way.

MFC after:	1 month
PR:		220164
Reported by:	gjb
2017-07-29 22:01:17 +00:00
Alan Somers
18ddf67c64 Implement SIGEV_THREAD notifications for lio_listio(2)
Our man pages have always indicated that this was supported, but in fact the
feature was never implemented for lio_listio(2).

Reviewed by:	jhb, kib (earlier version)
MFC after:	20 days
Sponsored by:	Spectra Logic Corp
Differential Revision:	https://reviews.freebsd.org/D11680
2017-07-21 15:09:24 +00:00
Enji Cooper
83f5e032b4 Clean up :coredump_phnum
- Use "atf_check -x 'cmd1 | cmd2'" instead of "cmd1 | atf_check cmd2". The
  two forms are idiomatically similar, but subtly different in the sense of
  what program invokes the other, and there could be unwanted side effects
  of the latter idiom dealing with forking, pipes, etc.
- Remove chmod and instead source coredump_phnum_restore_state.sh directly.
  This avoids the need to check the result of the chmod call.
- Fix indentation in an if-block (4 column space indentation -> hard tab).
2017-07-19 16:23:02 +00:00
Enji Cooper
fa562aca7a Remove expected failure for :coredump_phnum
The testcase no longer fails on ^/head because readelf has established parity
with binutils' copy of readelf.

This issue is not seen on Jenkins because
`test_suites.FreeBSD.allow_sysctl_side_effects` isn't set in kyua.conf on
the CI host, i.e., the test is skipped.

PR:	215019
Tested with:	binutils (amd64-binutils-2.28,1); elftoolchain (r3561M)
2017-07-19 16:08:08 +00:00
Alan Somers
0eafa7078f Remove dead code that was killed by r320975
Reported by:	Coverity
CID:		1377977
MFC after:	15 days
X-MFC-With:	320975
Sponsored by:	Spectra Logic Corp
2017-07-19 15:22:10 +00:00
Alan Somers
7e3db62753 Add regression tests for bugs 220459 and 220398
Bug 220398 - lio_listio(2) never sends asynchronous notification if nent==0
Bug 220459 - lio_listio(2) doesn't support SIGEV_THREAD

PR:		220459
PR:		220398
Reviewed by:	cem, jhb
MFC after:	3 weeks
Sponsored by:	Spectra Logic Corp
Differential Revision:	https://reviews.freebsd.org/D11470
2017-07-17 18:33:30 +00:00
Alan Somers
a4ea52aab6 Fix the build with GCC after r320975
Reported by:	pfg
MFC after:	20 days
X-MFC-With:	320975
Sponsored by:	Spectra Logic Corp
2017-07-14 21:50:04 +00:00
Alan Somers
314b447f66 Add tests for aio(4) completion notification via signals and threads
Reviewed by:	jhb
MFC after:	3 weeks
Sponsored by:	Spectra Logic Corp
Differential Revision:	https://reviews.freebsd.org/D11468
2017-07-13 22:53:13 +00:00
Alan Somers
d600f474c6 Use ATF cleanup routines in aio_test.c
Remove aio_test's legacy timeout handling and cleanup routines.  Instead,
use ATF's builtin capabilities.  ATF automatically cleans up newly created
files, too, so we don't have to explicitly unlink them.  The only tests than
need a cleanup routine are the md(4) tests, which must destroy their md
device.

Reviewed by:	jhb
MFC after:	3 weeks
Sponsored by:	Spectra Logic Corp
Differential Revision:	https://reviews.freebsd.org/D11468
2017-07-13 22:49:55 +00:00
Enji Cooper
3416500aef Pull down pjdfstest 0.1
The summary of changes is as follows..

Generic changes::
- Added configure support [2].
- Check for lchmod filesystem support with create_file(..); for
  testcases that require lchmod, skip the testcase -- otherwise
  use chmod directly [1].
- Added Travis CI integration [2].
- Added utimensat testcases [1].

Linux support::
- Fixed Linux support to pass on later supported versions of
  Fedora/Ubuntu [2].
- Conditionally enable posix_fallocate(2) support [2].

OSX support::
- Fixed compilation on OSX [2].
- Added partial OSX support (the test run isn't fully green yet)
  [2].

MFC after:	2 months
Obtained from:	https://github.com/pjd/pjdfstest/tree/0.1
Relnotes:	yes
Submitted by:	asomers [1], ngie [2]
Tested with:	UFS, ZFS
2017-06-28 09:22:45 +00:00
Enji Cooper
a5b450a49b Pull down pjdfstest 0.1
The summary of changes is as follows..

Generic changes::
- Added configure support [2].
- Check for lchmod filesystem support with create_file(..); for
  testcases that require lchmod, skip the testcase -- otherwise
  use chmod directly [1].
- Added Travis CI integration [2].
- Added utimensat testcases [1].

Linux support::
- Fixed Linux support to pass on later supported versions of
  Fedora/Ubuntu [2].
- Conditionally enable posix_fallocate(2) support [2].

OSX support::
- Fixed compilation on OSX [2].
- Added partial OSX support (the test run isn't fully green yet)
  [2].

Obtained from:	https://github.com/pjd/pjdfstest/tree/0.1
Submitted by:	asomers [1], ngie [2]
2017-06-28 08:48:09 +00:00
Enji Cooper
f35f0a756f trailing_slash is a TAP-compliant testcase; mark it as such, instead
of calling is a plain testcase.

MFC after:	1 month
2017-06-28 08:29:20 +00:00
Enji Cooper
2b808adfb3 Don't hardcode path to file in /tmp; this violates the kyua sandbox
MFC after:	1 month
2017-06-28 08:28:07 +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
John Baldwin
6720b89045 Add the ccr0 device to the opencrypto tests against the NIST KAT tests.
The ccr0 device supports both AES and SHA tests.

Sponsored by:	Chelsio Communications
2017-06-08 21:34:54 +00:00
Jilles Tjoelker
9086b30bc4 tests/sys/aio: Add missing mode to open() calls with O_CREAT. 2017-06-04 21:39:37 +00:00
Enji Cooper
a0fc6fa93f tests/sys/opencrypto/runtests: apply minor polish to test script
- Refactor kld loading/unloading logic:
-- Use a loop instead of an unrolled one.
-- Check for the module being loaded before trying to load it, to reduce
   noise when loading modules that are already loaded.
-- Don't mute stderr from kldload -- it could be potentially useful to
   the tester.
-- In the event that the test script was terminated early, it would leave
   the modules still attached to the system (which is undesirable).
   Always unload the modules at test end with EXIT/SIGINT/SIGTERM so the
   system is returned to its former operating state as best possible.
   Unload the modules in reverse order, in part for consistency and/or
   dependency reasons.

MFC after:	2 weeks
Sponsored by:	Dell EMC Isilon
2017-06-01 19:58:40 +00:00
Enji Cooper
1de3fb0425 Fix up TEST_METADATA
- `TEST_METADATA.foo` should be `TEST_METADATA.run_tests`: this will unbreak
  trying to run the tests on a system without python installed in $PATH.
- The tests require root because they load aesni(4) and/or cryptodev(4) if
  not already loaded.

MFC after:	2 weeks
Sponsored by:	Dell EMC Isilon
2017-06-01 19:46:48 +00:00
John Baldwin
78dd739ff3 Honor the requested crid when running a test.
Otherwise, the kernel is free to choose an aribtrary crypto device
rather than the requested device subverting tests that force the use
of a specific device.

MFC after:	1 week
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D10762
2017-06-01 19:27:38 +00:00
Enji Cooper
71784da9b1 Tweak r319058 slightly
- Specify an explicit mode when using O_CREAT per open(2).
- Fix the error message (add missing enclosing parentheses).

Submitted by:	jilles
MFC after:	3 days
MFC with:	r319058
Sponsored by:	Dell EMC Isilon
2017-05-28 17:50:29 +00:00
Enji Cooper
fa5e5f53c2 Send all of data, not just a portion of it
It was sending only a long's worth (4 or 8 bytes) of data previously
(instead of the entire buffer) via send(2).

MFC after:	1 week
Reported by:	Coverity
CID:		1229966, 1229967, 1230004, 1230005
Sponsored by:	Dell EMC Isilon
2017-05-28 09:21:28 +00:00
Enji Cooper
e5853fc53c Initial srv before using it in bind(2)
MFC after:	3 days
Reported by:	Coverity
CID:		1357526
Sponsored by:	Dell EMC Isilon
2017-05-28 09:08:30 +00:00
Enji Cooper
15f9aa4370 Don't leak accept_fd on thread completion
MFC after:	3 days
Reported by:	Coverity
CID:		1296068
Sponsored by:	Dell EMC Isilon
2017-05-28 09:01:58 +00:00
Enji Cooper
7deab5004c Use main(void) instead of main(argc __unused, argv __unused)
MFC after:	3 days
Sponsored by:	Dell EMC Isilon
2017-05-28 08:57:08 +00:00
Enji Cooper
25bd867ef1 Use an exit code of 1 instead of -1 for reasons noted in r319056
MFC after:	3 days
Sponsored by:	Dell EMC Isilon
2017-05-28 08:55:32 +00:00
Enji Cooper
fa15d1eafb Create a deterministic file in the kyua sandbox, instead of a
temporary file outside the kyua sandbox

This helps ensure that the file is removed at test exit, and as
a side effect, cures a warning about umasks with Coverity.

MFC after:	3 days
Sponsored by:	Dell EMC Isilon
2017-05-28 08:52:12 +00:00
Enji Cooper
b71f6e8c05 tests/sys/file/ftruncate_test: use an exit code of 1 instead
of -1 with err*(3).

An exit code of -1 is implementation defined -- it's best to stick
with something well-defined (1).

MFC after:	3 days
Sponsored by:	Dell EMC Isilon
2017-05-28 08:46:41 +00:00
Alan Somers
95c91f3b1d Fix build of AIO tests with -DDEBUG
Also, redefine some constants for clarity.  No functional change.

MFC after:	1 week
2017-05-21 15:37:08 +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
Mark Johnston
d74da94ce4 Add a regression test for r318191.
Reviewed by:	badger
MFC after:	1 week
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D10684
2017-05-12 18:02:57 +00:00
Enji Cooper
20a438f31a Mark all md tests as requiring unsafe AIO in order to function
These tests have been flapping (failing<->passing) on Jenkins for months.
It passes reliably for me if unsafe AIO is permitted, but it doesn't
pass on Jenkins reliably if unsafe AIO is disabled (the current default).

Mark the tests as requiring unsafe AIO to mitigate the intermittent
failures when unsafe AIO isn't permitted. If the kernel code is changed
to reliably function with md(4) devices using unsafe AIO, this commit can
be reverted.

MFC after:	2 months
PR:		217261
Reported by:	Jenkins
Sponsored by:	Dell EMC Isilon
2017-05-11 08:06:46 +00:00
Enji Cooper
8e9450bb5a Remove unused constant (PATH_TEMPLATE)
It was made unnecessary in r312913.

MFC after:	3 weeks
MFC with:	r312913
Sponsored by:	Dell EMC Isilon
2017-05-09 20:26:43 +00:00
Enji Cooper
e9b7132b30 style(9): move function definition curly braces to column 0
MFC after:	3 weeks
Sponsored by:	Dell EMC Isilon
2017-05-09 19:23:14 +00:00
Enji Cooper
175e856fa2 Print out when unsafe AIO is enabled to debugging purposes
MFC after:	3 weeks
Sponsored by:	Dell EMC Isilon
2017-05-09 19:20:02 +00:00
Enji Cooper
5fec77f1d6 Refactor ATF_REQUIRE_UNSAFE_AIO and PLAIN_REQUIRE_UNSAFE_AIO
This is being done to reduce duplication between the two macros.

MFC after:	3 weeks
Sponsored by:	Dell EMC Isilon
2017-05-09 19:16:18 +00:00
Enji Cooper
da880f61ca style(9): clean up trailing whitespace
MFC after:	3 weeks
Sponsored by:	Dell EMC Isilon
2017-05-09 18:54:35 +00:00
Mark Johnston
f55b9be8d9 Add regression tests for r317712 and r306743.
MFC after:	2 weeks
Sponsored by:	Dell EMC Isilon
2017-05-02 23:31:39 +00:00
Brooks Davis
ea703329bf Don't pass size_t arguments to setsockopt(SO_SNDBUF/SO_RCVBUF).
These command take an int. The tests work by accident on little-endian,
64-bit systems.

PR:		218919
Tested with:	qemu-cheri and CheriBSD built for mips64
Reviewed by:	asomers, ngie
Obtained from:	CheriBSD
MFC after:	1 week
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D10518
2017-04-28 17:58:15 +00:00
Michael Tuexen
d7f27102b5 armv8 has support for optional CRC32C instructions. This patch checks if they are
available and if that is true make use of them.
Thank you very much to Andrew Turner for providing help and review the patch!
Reviewed by:		andrew
MFC after:		1 week
Differential Revision:	https://reviews.freebsd.org/D10499
2017-04-27 17:53:05 +00:00
Bruce Evans
5be56374b6 Remove the unportable -msse4 here too after fixing crc32_sse42.c to not
depend on it.  This should have been part of r315983.
2017-04-02 09:24:58 +00:00
Alan Somers
5a33a2afb3 Fix back-to-back runs of sys/netinet/fibs_test;slaac_on_nondefault_fib6
This test was failing if run twice because rtadvd takes too long to die.
The rtadvd process from the first run was still running when the
second run created its interfaces.  The solution is to use SIGKILL during
the cleanup instead of SIGTERM so rtadvd will die faster.

While I'm here, randomize the addresses used for the test, which makes bugs
like this easier to spot, and fix the cleanup order to be the opposite of
the setup order

PR:		217871
MFC after:	18 days
X-MFC-With:	315458
Sponsored by:	Spectra Logic Corp
2017-03-20 23:07:34 +00:00
Eric Badger
bc2be1d35b ptrace_test: eliminate assumption about thread scheduling
A couple of the ptrace tests make assumptions about which thread in a
multithreaded process will run after a halt. This makes the tests less
portable across branches, and susceptible to future breakage. Instead,
twiddle thread scheduling and priorities to match the tests'
expectation.

X-MFC with:	r313992
Sponsored by:	Dell EMC
2017-03-18 15:25:51 +00:00
Alan Somers
559b42968c Constrain IPv6 routes to single FIBs when net.add_addr_allfibs=0
sys/netinet6/icmp6.c
	Use the interface's FIB for source address selection in ICMPv6 error
	responses.

sys/netinet6/in6.c
	In in6_newaddrmsg, announce arrival of local addresses on the
	interface's FIB only.  In in6_lltable_rtcheck, use a per-fib ND6
	cache instead of a single cache.

sys/netinet6/in6_src.c
	In in6_selectsrc, use the caller's fib instead of the default fib.
	In in6_selectsrc_socket, remove a superfluous check.

sys/netinet6/nd6.c
	In nd6_lle_event, use the interface's fib for routing socket
	messages.  In nd6_is_new_addr_neighbor, check all FIBs when trying
	to determine whether an address is a neighbor.  Also, simplify the
	code for point to point interfaces.

sys/netinet6/nd6.h
sys/netinet6/nd6.c
sys/netinet6/nd6_rtr.c
	Make defrouter_select fib-aware, and make all of its callers pass in
	the interface fib.

sys/netinet6/nd6_nbr.c
	When inputting a Neighbor Solicitation packet, consider the
	interface fib instead of the default fib for DAD.  Output NS and
	Neighbor Advertisement packets on the correct fib.

sys/netinet6/nd6_rtr.c
	Allow installing the same host route on different interfaces in
	different FIBs.  If rt_add_addr_allfibs=0, only install or delete
	the prefix route on the interface fib.

tests/sys/netinet/fibs_test.sh
	Clear some expected failures, but add a skip for the newly revealed
	BUG217871.

PR:		196361
Submitted by:	Erick Turnquist <jhujhiti@adjectivism.org>
Reported by:	Jason Healy <jhealy@logn.net>
Reviewed by:	asomers
MFC after:	3 weeks
Sponsored by:	Spectra Logic Corp
Differential Revision:	https://reviews.freebsd.org/D9451
2017-03-17 16:50:37 +00:00
Eric Badger
b4d3325975 Don't clear p_ptevents on normal SIGKILL delivery
The ptrace() user has the option of discarding the signal. In such a
case, p_ptevents should not be modified. If the ptrace() user decides to
send a SIGKILL, ptevents will be cleared in ptracestop(). procfs events
do not have the capability to discard the signal, so continue to clear
the mask in that case.

Reviewed by:	jhb (initial revision)
MFC after:	1 week
Sponsored by:	Dell EMC
Differential Revision:	https://reviews.freebsd.org/D9939
2017-03-16 13:03:31 +00:00
Gleb Smirnoff
1c0b5002f5 Fix buildworld broken in r315230 when /sys doesn't point into a right
source tree.  Usage of SYSDIR is apparently wrong here.

Discussed with:	allanjude
2017-03-15 05:31:02 +00:00
Enji Cooper
e22ad7bca1 Move .../sys/geom/eli/pbkdf2... to .../sys/geom/class/eli/...
This change moves the tests added in r313962 to an existing directory
structure used by the geli TAP tests. It also, renames the test from
pbkdf2 to pbkdf2_test .

The changes to ObsoleteFiles.inc are being committed separately as they
aren't needed for the MFC to ^/stable/11, etc, if the MFC for the tests
is done all in one commit.

MFC after:	2 weeks
X-MFC with:	r313962, r313972-r313973
Reviewed by:	allanjude
Sponsored by:	Dell EMC Isilon
Differential Revision:	D9985
2017-03-14 07:00:22 +00:00
Eric Badger
b38bd91f4f don't stop in issignal() if P_SINGLE_EXIT is set
Suppose a traced process is stopped in ptracestop() due to receipt of a
SIGSTOP signal, and is awaiting orders from the tracing process on how
to handle the signal. Before sending any such orders, the tracing
process exits. This should kill the traced process. But suppose a second
thread handles the SIGKILL and proceeds to exit1(), calling
thread_single(). The first thread will now awaken and will have a chance
to check once more if it should go to sleep due to the SIGSTOP.  It must
not sleep after P_SINGLE_EXIT has been set; this would prevent the
SIGKILL from taking effect, leaving a stopped orphan behind after the
tracing process dies.

Also add new tests for this condition.

Reviewed by:	kib
MFC after:	2 weeks
Sponsored by:	Dell EMC
Differential Revision:	https://reviews.freebsd.org/D9890
2017-03-07 13:41:01 +00:00
Alan Somers
4b6c378be3 Add an ATF test for IPv6 SLAAC with multiple fibs
Tests that an interface can get a SLAAC address and that it inserts its
routes into the correct fib. Does not test anything to do with NDP.

PR:		196361
Reviewed by:	Erick Turnquist <jhujhiti@adjectivism.org>
MFC after:	3 weeks
Sponsored by:	Spectra Logic Corp
Differential Revision:	https://reviews.freebsd.org/D9776
2017-03-01 00:28:04 +00:00
Eric Badger
e2ebfbbf38 Actually fix buildworlds other than i386/amd64/sparc64 after r313992
Disable offending test for platforms without a userspace visible
breakpoint().

Reported by:	rpokala
Approved by:	vangyzen (mentor)
2017-02-23 04:26:17 +00:00
Alan Somers
56a1ced0d5 Remove tests/sys/netinet/fibs_tests's dependency on net/socat
Instead of bridging two tap interfaces with socat, just use an epair pair.

MFC after:	3 weeks
Sponsored by:	Spectra Logic Corp
2017-02-22 23:57:22 +00:00
Eric Badger
9e0d115989 Fix world build for archs where __builtin_debugtrap() does not work.
The offending code was introduced in r313992.

Reported by:	rpokala
Approved by:	kib (mentor)
2017-02-22 04:35:07 +00:00
Alan Somers
1d06be4ab3 Improve pjdfstest run instructions
In the Kyua era, it's no longer necessary to set PJDFSTEST_TEST_PATH.  Just
use TMPDIR instead.

Reviewed by:	ngie
MFC after:	3 weeks
Relnotes:	yes
Sponsored by:	Spectra Logic Corp
Differential Revision:	https://reviews.freebsd.org/D9340
2017-02-21 21:01:01 +00:00
Eric Badger
82a4538f31 Defer ptracestop() signals that cannot be delivered immediately
When a thread is stopped in ptracestop(), the ptrace(2) user may request
a signal be delivered upon resumption of the thread. Heretofore, those signals
were discarded unless ptracestop()'s caller was issignal(). Fix this by
modifying ptracestop() to queue up signals requested by the ptrace user that
will be delivered when possible. Take special care when the signal is SIGKILL
(usually generated from a PT_KILL request); no new stop events should be
triggered after a PT_KILL.

Add a number of tests for the new functionality. Several tests were authored
by jhb.

PR:		212607
Reviewed by:	kib
Approved by:	kib (mentor)
MFC after:	2 weeks
Sponsored by:	Dell EMC
In collaboration with:	jhb
Differential Revision:	https://reviews.freebsd.org/D9260
2017-02-20 15:53:16 +00:00
Enji Cooper
d893c36a35 A forced commit to note other portion of the Makefile change accidentally
committed in r313972

The code committed in r313962 implicitly relies on python 2.x to generate
testvect.h . There are a handful of issues with this approach:

- python is not an explicit build dependency for FreeBSD
- python 2.x is deprecated and will be removed sometime in the future
  (potentially before 11.x's EOL), and the script does not function with
  python 3.5 (it uses deprecated idioms and incompatible function calls).
- python(1) (by default) lives in /usr/local/bin (${LOCALBASE}/bin) and
  gentestvect.py is a dependency of testvect.h (prior to r313972) which
  means that if the mtime of the generator script was newer than the
  mtime of the test vector, it could cause a spurious build failure in
  build time or at install time.

A better solution using C/C++ should be devised.

Discussed with:	allanjude
MFC after:	2 weeks
X-MFC with:	r313962, r313972
Sponsored by:	Dell EMC Isilon
2017-02-19 22:00:11 +00:00
Enji Cooper
bc030e5c3f Unbreak the build when "make obj" is executed beforehand
Using relative paths imply working directory (in this case .OBJDIR), whereas the
sources live in the .CURDIR-relative path.

MFC after:	2 weeks
X-MFC with:	r313962
Pointyhat to:	allanjude
Sponsored by:	Dell EMC Isilon
2017-02-19 21:19:44 +00:00
Allan Jude
85c15ab853 improve PBKDF2 performance
The PBKDF2 in sys/geom/eli/pkcs5v2.c is around half the speed it could be

GELI's PBKDF2 uses a simple benchmark to determine a number of iterations
that will takes approximately 2 seconds. The security provided is actually
half what is expected, because an attacker could use the optimized
algorithm to brute force the key in half the expected time.

With this change, all newly generated GELI keys will be approximately 2x
as strong. Previously generated keys will talk half as long to calculate,
resulting in faster mounting of encrypted volumes. Users may choose to
rekey, to generate a new key with the larger default number of iterations
using the geli(8) setkey command.

Security of existing data is not compromised, as ~1 second per brute force
attempt is still a very high threshold.

PR:		202365
Original Research:	https://jbp.io/2015/08/11/pbkdf2-performance-matters/
Submitted by:	Joe Pixton <jpixton@gmail.com> (Original Version), jmg (Later Version)
Reviewed by:	ed, pjd, delphij
Approved by:	secteam, pjd (maintainer)
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D8236
2017-02-19 19:30:31 +00:00
Enji Cooper
374d7f62e0 Revert r313565 -- :mmap__bad_arguments passes again after r313655
PR:		216976
Sponsored by:	Dell EMC Isilon
2017-02-11 20:31:57 +00:00
Enji Cooper
28e5919804 Expect :mmap__bad_arguments to fail
Some recent changes to vm related to mmap(2) have broken the prot checks that
would result with an EINVAL with this case

I suspect r313352 is the root-cause the issue

PR:		216976
Sponsored by:	Dell EMC Isilon
2017-02-10 19:31:09 +00:00
Enji Cooper
4a2dbde724 MFhead@r313398 2017-02-07 18:47:16 +00:00
Alan Somers
9d6c66cb9f Add fibs_test:udp_dontroute6, another IPv6 multi-FIB test
PR:		196361
MFC after:	3 weeks
Sponsored by:	Spectra Logic Corp
2017-02-07 17:40:59 +00:00
Enji Cooper
9b3ece1c2e MFhead@r313243 2017-02-04 18:06:09 +00:00
Enji Cooper
b42fffb4ef Replace for/retry loops with "wait_for_ggate_device" calls and check
results of commands

As noted in r313008, the underlying issue was that geom_gate device
creation wasn't created at ggatel command completion, but some short
time after. ggatec(8) employs similar logic when creating geom_gate(4)
devices.

Switch from retry loops (after the ggatec/dd write calls) to
wait_for_ggate_device function calls after calling ggatec(8) instead
to detect the presence of the /dev/ggate* device, as this function is
sufficient for determining whether or not the character device is ready
for testing

While here, use atf_check consistently with all dd calls to ensure that
data output is as expected.

MFC after:	1 week
Reviewed by:	asomers
Differential Revision:	D9409
Sponsored by:	Dell EMC Isilon
2017-02-02 03:54:43 +00:00
Alan Somers
c7f3d08d40 Add tests for multi-fib IPv6 routing
PR:		196361
Submitted by:	jhujhiti@adjectivism.org
Reported by:	Jason Healy <jhealy@logn.net>
MFC after:	4 weeks
Sponsored by:	Spectra Logic Corp
2017-01-31 20:13:50 +00:00
Enji Cooper
15b69ab272 Wait for /dev/ggate* to appear after calling ggatel create in :ggatel_{file,md}
The test assumed that `ggatel create` created a device on completion, but that's
incorrect. This squashes the race by waiting for the device to appear, as
`ggatel create` daemonizes before issuing an ioctl to geom_gate(4) if not called
with `-v`.

Discussed with:	asomers
MFC after:	1 week
PR:		204616
Sponsored by:	Dell EMC Isilon
2017-01-31 06:12:51 +00:00
Conrad Meyer
6be2ff7d3e calculate_crc32c: Add SSE4.2 implementation on x86
Derived from an implementation by Mark Adler.

The fast loop performs three simultaneous CRCs over subsets of the data
before composing them.  This takes advantage of certain properties of
the CRC32 implementation in Intel hardware.  (The CRC instruction takes 1
cycle but has 2-3 cycles of latency.)

The CRC32 instruction does not manipulate FPU state.

i386 does not have the crc32q instruction, so avoid it there.  Otherwise
the implementation is identical to amd64.

Add basic userland tests to verify correctness on a variety of inputs.

PR:		216467
Reported by:	Ben RUBSON <ben.rubson at gmail.com>
Reviewed by:	kib@, markj@ (earlier version)
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D9342
2017-01-31 03:26:32 +00:00
Robert Watson
55e0d88afd Fix build of aio_test on MIPS, where the compiler warns about the local
variable 'err' shadowing the global function err(3).  Which it does.

Sponsored by:	DARPA, AFRL
2017-01-28 12:26:22 +00:00
Alan Somers
740a9bfadd Improve the aio tests
* Add tests for aio_suspend(2).
* Add tests for polled completion notification.
* Test the full matrix of file descriptor types and completion notification
  mechanisms.
* Don't bother with mkstemp, because ATF runs every test in its own temp dir.
* Fix some typos.
* Remove extraneous ATF_REQUIRE_KERNEL_MODULE calls.

Reviewed by:	jhb
MFC after:	4 weeks
Differential Revision:	https://reviews.freebsd.org/D9045
2017-01-28 04:33:51 +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
9b6d988185 Fix typo in r312216
I meant to replace "exp" with "exponent", not "expected"

MFC after:	13 days
Pointyhat to:	ngie
Submitted by:	bde
2017-01-15 10:29:53 +00:00
Enji Cooper
d75a788085 Revert r312119 and reword the intent to fix -Wshadow issues
between exp(3) and `exp` var.

The approach taken previously was not ideal for multiple
functional and stylistic reasons.

Add to existing sed call in Makefile to replace `exp` with
`exponent` instead.

MFC after:	13 days
Requested by:	bde
2017-01-15 09:25:33 +00:00
Enji Cooper
437999a767 Mark testcases which use cap_enter as expected failures until the
PR is resolved so those of us that run the tests don't have the
bogus failures counted against our overall results

PR:	215690
2017-01-15 09:13:41 +00:00
Enji Cooper
15dbd418f6 Add include Makefiles for tests/sys/{fs,kern,kqueue,mac}/...
The primary goal for doing this is to leverage the work done in r312114
for enabling WARNS to address trivial code quality issues with new tests

MFC after:	6 days
Tested with:	make tinderbox
Sponsored by:	Dell EMC Isilon
2017-01-14 20:29:26 +00:00
Enji Cooper
4944940b4e Add include Makefiles for tests/sys/{fs,kern,kqueue,mac}/...
The primary goal for doing this is to leverage the work done in r312114
for enabling WARNS to address trivial code quality issues with new tests

MFC after:	6 days
Tested with:	make tinderbox
Sponsored by:	Dell EMC Isilon
2017-01-14 20:21:21 +00:00
Enji Cooper
00ea8a5fc9 Fix -Wformat issue
Use %zu for printing out results from nitems, as it's size_t based

MFC after:	1 week
X-MFC with:	r312120
Reported by:	gcc (mips:mipsel tinderbox)
Sponsored by:	Dell EMC Isilon
2017-01-14 10:38:39 +00:00
Enji Cooper
dcdb30d8f8 Follow up to r312118
State that execve failed instead of just printing out the program name
and strerror(errno) via err(3).

MFC after:	3 days
X-MFC with:	r312118
Sponsored by:	Dell EMC Isilon
2017-01-14 05:24:35 +00:00
Enji Cooper
f614ceaf4a Fix warnings
- Staticize test_num
- Promote i to size_t to deal with -Wsign-compare issues

Tested with:	clang, gcc, gcc49
MFC after:	1 week
Sponsored by:	Dell EMC Isilon
2017-01-14 05:18:18 +00:00
Enji Cooper
dfa7f3a543 Fix -Wformat issue with zero-length format string passed to err(3)
MFC after:	3 days
Tested with:	clang, gcc 4.2.1, gcc 4.9
Sponsored by:	Dell EMC Isilon
2017-01-14 05:02:53 +00:00
Enji Cooper
bf8f6d7c8d Remove WARNS set globally by ../Makefile.inc now
Sponsored by:	Dell EMC Isilon
2017-01-14 04:20:42 +00:00
Enji Cooper
de81acbd15 Enable WARNS?= 6 across all of tests/sys
MFC after:	1 week
Sponsored by:	Dell EMC Isilon
2017-01-14 04:20:06 +00:00
Enji Cooper
54ff563fb9 Remove unused vars to fix -Wunused issues
MFC after:	3 days
Sponsored by:	Dell EMC Isilon
2017-01-14 04:10:04 +00:00
Enji Cooper
5fea45956e Fix -Wsign-compare warnings
The loop index (i) doesn't need to be size_t as its comparison is signed

MFC after:	1 week
Sponsored by:	Dell EMC Isilon
2017-01-14 04:09:01 +00:00
Enji Cooper
02820e5e4e Bump WARNS up to 6 again
Has not been tested (can't be after r312103 without cem's hacks
to atf/kyua)!
2017-01-14 04:00:26 +00:00
Conrad Meyer
5c9ce2504a Follow-up to r312103:
Revert r310995 as well.
2017-01-14 02:29:25 +00:00
Conrad Meyer
47f2efe4fb Revert r310994
Don't implement some terrible hack on a test by test basis.  The
framework fix is straightforward and can be chased up in the original
bug.

Reviewed by:	ngie ("be my guest")
2017-01-14 01:03:20 +00:00
Alan Somers
9a1fe327ae ATFify the geom gate tests.
This ensures their cleanup routines will be run even if they should timeout.

tests/sys/geom/class/gate/ggate_test.sh
tests/sys/geom/class/gate/Makefile
	Add an ATF test with three testcases, one for each TAP test. Use
	ATF-style cleanup functions, and convert sleeps to polling loops.

ObsoleteFiles.inc
tests/sys/geom/class/gate/conf.sh
tests/sys/geom/class/gate/1_test.sh
tests/sys/geom/class/gate/2_test.sh
tests/sys/geom/class/gate/3_test.sh
	Delete TAP test files

Reviewed by:	ngie
MFC after:	4 weeks
Sponsored by:	Spectra Logic Corp
Differential Revision:	https://reviews.freebsd.org/D8891
2017-01-10 20:35:09 +00:00
Konstantin Belousov
1c32456953 Use type-independent formats for printing nlink_t and ino_t.
Extracted from:	ino64 work by gleb, mckusick
Discussed with:	mckusick
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2017-01-06 16:59:33 +00:00
Enji Cooper
e4162b7955 Bump WARNS to 6 to catch simple QA issues like some of the ones I squashed
in r310994
2017-01-01 04:02:06 +00:00
Enji Cooper
7f9785e873 Make sys/vfs/lookup_cap_dotdot actually work with "kyua test"
The tests don't work when reading/writing to file descriptors in the
sandbox after entering capability mode (and wouldn't have, regardless
of the framework), so adjust the tests so they function within the
framework.

For tests that enter capability mode over the course of the test, the
following is now done:

  1. Fork child process for capability mode test.
  2. In child...
     i.   Enter capability mode.
     ii.  Test invariants.
     iii. Exit after calling test function.
  3. Collect status for child and determine whether or not it completed
     successfully.

In order to test the invariants in the child process, they now use assert(3)
instead of ATF_REQUIRE*, as the atf-c-api functions right to results files
in the directories in order to determine where and how tests fail.

While in the area, fix several -Wshadow and -Wunused warnings found when I
bumped WARNS up to 6, and fix some minor style(9) issues with indentation
and type alignment.

PR:	215690
2017-01-01 04:01:27 +00:00
Alan Somers
162ea6dc66 ATFify the gnop tests
Also, add test cases for the -p, -P, and -s options to gnop create

Reviewed by:	ngie
MFC after:	4 weeks
Differential Revision:	https://reviews.freebsd.org/D8892
2016-12-30 02:22:38 +00:00
Alan Somers
f92ce0224a Reduce the runtime of the GELI tests
There is no reduction in test coverage.  On my system runtime is reduced
from 38m32s to 6m24s.

tests/sys/geom/class/eli/conf.sh
tests/sys/geom/class/eli/init_a_test.sh
tests/sys/geom/class/eli/init_test.sh
tests/sys/geom/class/eli/integrity_copy_test.sh
tests/sys/geom/class/eli/integrity_data_test.sh
tests/sys/geom/class/eli/integrity_hmac_test.sh
tests/sys/geom/class/eli/onetime_a_test.sh
tests/sys/geom/class/eli/onetime_test.sh
	Move the looping code into common functions in conf.sh, and remove
	alias ciphers from the list.

tests/sys/geom/class/eli/init_a_test.sh
tests/sys/geom/class/eli/init_test.sh
tests/sys/geom/class/eli/integrity_copy_test.sh
tests/sys/geom/class/eli/integrity_data_test.sh
tests/sys/geom/class/eli/integrity_hmac_test.sh
tests/sys/geom/class/eli/onetime_a_test.sh
	Move a few commands that don't need to be in the inner loop out.

tests/sys/geom/class/eli/init_test.sh
tests/sys/geom/class/eli/onetime_a_test.sh
	Reduce the sector count

tests/sys/geom/class/eli/Makefile
tests/sys/geom/class/eli/init_alias_test.sh
	Add a test for initializing a GELI device using one of the cipher
	aliases, and check that the alias is correctly interpreted.

MFC after:	4 weeks
Sponsored by:	Spectra Logic Corp
Differential Revision:	https://reviews.freebsd.org/D8814
2016-12-29 20:28:50 +00:00
Jilles Tjoelker
b9a6fb9343 reaper: Make REAPER_KILL_SUBTREE actually work.
MFC after:	2 weeks
2016-12-14 22:49:20 +00:00
Jilles Tjoelker
fe56b17710 Add tests for reaper receiving SIGCHLD (r309886).
PR:		213928
MFC after:	2 weeks
2016-12-12 22:51:29 +00:00
Conrad Meyer
9f0136cb26 Add basic ATF tests for Capability mode .. lookups
A follow-up to r309887.

Several tests copied verbatim from
https://github.com/emaste/snippets/blob/master/test_openat.c .

Reviewed by:	kib@, ngie@ (earlier version)
X-MFC-With:	r309887
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D8748
2016-12-12 17:23:09 +00:00
Jilles Tjoelker
b1dd83d1d0 Add some tests for reaper functionality (in procctl()).
MFC after:	1 week
2016-12-10 22:05:24 +00:00
Conrad Meyer
695349e306 coredump_phnum_test: Make expected pheader count more flexible
Note: this test still requires binutils readelf (from ports) to pass, until a
few issues are resolved in elftoolchain.

PR:		215019
Reported by:	ngie@
Sponsored by:	Dell EMC Isilon
2016-12-04 03:50:57 +00:00
Enji Cooper
3d77b88dff Expect 01:main to fail
Changes were made to ZFS in the past year with respect to how ACLs
are handled, causing failures in this test. Mark it TODO so (hopefully)
someone more knowledgeable (like mav or trasz) will fix the code or the
test.

PR:	212323
2016-12-03 02:24:15 +00:00
Enji Cooper
c68f00edd6 Expect :coredump_phnum to fail
The number of program headers on my system (GENERIC-NODEBUG) don't match the
expected (hardcoded) number in the test

PR:	215019
2016-12-03 02:17:50 +00:00
Enji Cooper
cebf0ec58a Fix test coredump_phnum_test:coredump_phnum require.config specification
The requirement is set via `atf_set "require.config" "allow_sysctl_side_effects"',
not `atf_set "require.config" "allow_sysctl_side_effects"'

X-MFC with: r308177
Pointyhat to: cmeyer
2016-12-03 02:09:23 +00:00
Conrad Meyer
e8e39fc29e Add test case for >65535 segment coredumps
A long-belated follow-up to r303099.

With feedback from:	jmmv, ngie
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D7264
2016-11-01 19:18:16 +00:00
Ruslan Bukin
0a33140d06 Change fs image name so it will not be regenerated (we
have both big and little-endian images in tree).
Also we don't known the endianness of the platform the
image was generated on.

Sponsored by:	DARPA, AFRL
Sponsored by:	HEIF5
2016-10-25 18:43:36 +00:00
Enji Cooper
669c253531 Integrate contrib/netbsd-tests/fs/tmpfs into the FreeBSD test suite
as tests/sys/fs

These testcases exercise tmpfs support

MFC after:	2 weeks
Sponsored by:	Dell EMC Isilon
2016-10-21 05:24:08 +00:00
Ruslan Bukin
db636d72e3 Add big-endian uzip file system and choose right file system
to proceed tests with.

Reviewed by:	jmmv, ngie
Sponsored by:	DARPA, AFRL
Sponsored by:	HEIF5
Differential Revision:	https://reviews.freebsd.org/D8073
2016-10-19 10:01:04 +00:00
Ruslan Bukin
05533a6f19 Fix comment. We have different VM layout on MIPS, so test is skipped.
Requested by:	kib
Sponsored by:	DARPA, AFRL
Sponsored by:	HEIF5
2016-10-18 10:20:58 +00:00
Ruslan Bukin
470d063a87 Skip test on MIPS as we don't have shared page implemented yet.
Sponsored by:	DARPA, AFRL
Sponsored by:	HEIF5
2016-10-10 14:21:40 +00:00
Ruslan Bukin
21a4258d89 Ensure data in pipe is available to read.
Useful for latest (5th, direct mode) test only.

Sponsored by:	DARPA, AFRL
Sponsored by:	HEIF5
2016-10-10 13:40:05 +00:00
Konstantin Belousov
ddce1c3ddb Export the mq_getfd_np() symbol from librt.so, which allows to get
file descriptor for the given posix mqueue.  Export the
timer_oshandle_np() symbol to get ktimer id for the given posix timer.

Requested by:	Lewis Donzis <lew@perftech.com>
Reviewed by:	jilles
Discussed with:	kan
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2016-10-02 17:02:59 +00:00
Ruslan Bukin
090aa8d18b Increase timeouts for geli tests. It takes 2-3x more time to proceed the
tests on MIPS64EB in QEMU.

Sponsored by:	DARPA, AFRL
Sponsored by:	HEIF5
2016-09-28 08:11:00 +00:00
Ruslan Bukin
3a970562d7 Check if IPv6 supported before running the test, skip otherwise.
Sponsored by:	DARPA, AFRL
Sponsored by:	HEIF5
2016-09-23 07:51:01 +00:00
Ruslan Bukin
d29c555195 Use bsdlabel as we don't have hardlink disklabel -> bsdlabel
on some platforms.

Reviewed by:	ngie
Sponsored by:	DARPA, AFRL
Sponsored by:	HEIF5
Differential Revision:	https://reviews.freebsd.org/D7968
2016-09-22 12:53:11 +00:00
Enji Cooper
bddfc749fa Remove change accidentally committed via r305963 for upcoming tests/sys/fs/...
work

MFC after:	3 days
Sponsored by:	Dell EMC Isilon
2016-09-19 09:15:12 +00:00
Enji Cooper
34ccb11831 Reindent TESTSDIR definition for consistency/readability
MFC after:		3 days
Sponsored by:		Dell EMC Isilon
2016-09-19 07:07:55 +00:00
Enji Cooper
a85d4fc7e4 Only chmod $TMPDIR if it's not /tmp
This is a safety belt to ensure that the /tmp sticky bit stuff doesn't
get whacked by accident if someone runs the script outright

MFC after:	1 week
X-MFC with:	r305916
Sponsored by:	Dell EMC Isilon
2016-09-18 05:10:15 +00:00
Enji Cooper
9cd2207265 Make sure $TMPDIR is created with 0755 permissions
This is required to ensure that the temporary script can be executed,
as the default mode is apparently too restrictive

MFC after:	3 days
Sponsored by:	Dell EMC Isilon
2016-09-18 05:06:15 +00:00
Jilles Tjoelker
d30e66e53a wait: Do not copyout uninitialized status/rusage/wrusage.
If wait4() or wait6() return 0 because of WNOHANG, the status, rusage and
wrusage information should not be returned.

PR:		212048
Reported by:	Casey Lucas
MFC after:	2 weeks
2016-09-09 21:58:48 +00:00
Enji Cooper
8f2b5a5469 Port contrib/netbsd-tests/kernel/kqueue/... as tests/sys/kqueue/...
proc2_test must be skipped because the invariant tested
(`ke.fflags & NOTE_TRACKERR`) doesn't pass.

MFC after:	58 days
Submitted by:	kib (earlier form)
Sponsored by:	EMC / Isilon Storage Division
Differential Revision:	https://reviews.freebsd.org/D6172
2016-09-06 08:50:21 +00:00
Enji Cooper
cb5fe245b1 Move tests/sys/kqueue/... to tests/sys/kqueue/libkqueue/...
This is being done to clearly distinguish the libkqueue tests
from the (soon to be imported) NetBSD tests.

MFC after:	58 days
Sponsored by:	EMC / Isilon Storage Division
2016-09-06 08:45:29 +00:00
Enji Cooper
3919472360 Skip testcases 9/10 if jail(8) isn't installed
These testcases require jail support

MFC after:	1 week
Sponsored by:	EMC / Isilon Storage Division
2016-09-03 17:59:46 +00:00
Enji Cooper
46f4fe1eb8 Add a missing "Bail out!" if zpool create fails
This will make the exit info more meaningful if/when zpool create fails,
and establishes parity with the other 2 zfs acl testcases (01, 03).

MFC after:	3 days
Sponsored by:	EMC / Isilon Storage Division
2016-09-03 17:31:13 +00:00
Bryan Drewery
1eb4ec9c62 DIRDEPS_BUILD: Add some missing dirctories to the build.
Sponsored by:	EMC / Isilon Storage Division
2016-08-31 19:30:59 +00:00
Julio Merino
f2ee07cfdc Make use of Kyua's work directories.
Change the vnode tests to use the current directory when creating temporary
files, which we can assume is a volatile work directory, and then make the
kqueue_test.sh driver _not_ abandon the directory created by Kyua.

This makes the various kqueue tests independent of each other, and ensures
the temporary file is cleaned up on failure.

Problem spotted by asomers@ when reviewing D4254.
2016-08-25 10:28:47 +00:00
Enji Cooper
ef5c8d5460 Only expect :encode_tv_random_million to fail on 64-bit platforms
It passes on i386

MFC after:	1 week
Sponsored by:	EMC / Isilon Storage Division
2016-08-16 20:32:08 +00:00
Enji Cooper
708cc995e3 Redirect the output of the testcases to stderr instead of
redirecting it to /dev/null

This will aid in debugging failures

MFC after:	1 week
Sponsored by:	EMC / Isilon Storage Division
2016-08-13 06:26:33 +00:00
John Baldwin
005ce8e4e6 Fix locking issues with aio_fsync().
- Use correct lock in aio_cancel_sync when dequeueing job.
- Add _locked variants of aio_set/clear_cancel_function and use those
  to avoid lock recursion when adding and removing fsync jobs to the
  per-process sync queue.
- While here, add a basic test for aio_fsync().

PR:		211390
Reported by:	Randy Westlund <rwestlun@gmail.com>
MFC after:	1 week
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D7339
2016-07-29 18:26:15 +00:00
John Baldwin
fc4f075a1a Add PTRACE_VFORK to trace vfork events.
First, PL_FLAG_FORKED events now also set a PL_FLAG_VFORKED flag when
the new child was created via vfork() rather than fork().  Second, a
new PL_FLAG_VFORK_DONE event can now be enabled via the PTRACE_VFORK
event mask.  This new stop is reported after the vfork parent resumes
due to the child calling exit or exec.  Debuggers can use this stop to
reinsert breakpoints in the vfork parent process before it resumes.

Reviewed by:	kib
MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D7045
2016-07-18 14:53:55 +00:00
John Baldwin
8d570f64aa Add a mask of optional ptrace() events.
ptrace() now stores a mask of optional events in p_ptevents.  Currently
this mask is a single integer, but it can be expanded into an array of
integers in the future.

Two new ptrace requests can be used to manipulate the event mask:
PT_GET_EVENT_MASK fetches the current event mask and PT_SET_EVENT_MASK
sets the current event mask.

The current set of events include:
- PTRACE_EXEC: trace calls to execve().
- PTRACE_SCE: trace system call entries.
- PTRACE_SCX: trace syscam call exits.
- PTRACE_FORK: trace forks and auto-attach to new child processes.
- PTRACE_LWP: trace LWP events.

The S_PT_SCX and S_PT_SCE events in the procfs p_stops flags have
been replaced by PTRACE_SCE and PTRACE_SCX.  PTRACE_FORK replaces
P_FOLLOW_FORK and PTRACE_LWP replaces P2_LWP_EVENTS.

The PT_FOLLOW_FORK and PT_LWP_EVENTS ptrace requests remain for
compatibility but now simply toggle corresponding flags in the
event mask.

While here, document that PT_SYSCALL, PT_TO_SCE, and PT_TO_SCX both
modify the event mask and continue the traced process.

Reviewed by:	kib
MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D7044
2016-07-15 15:32:09 +00:00
John Baldwin
3340c45b96 Add a test for user signal delivery.
This test verifies we get the correct ptrace event details when a signal
is posted to a traced process from userland.

Reviewed by:	kib (part of D7044)
2016-07-15 15:28:33 +00:00
George V. Neville-Neil
15dbc1605b On FreeBSD there is a setsockopt option SO_USER_COOKIE which allows
setting a 32 bit value on each socket. This can be used by applications
and DTrace as a rendezvous point so that an applicaton's data can
more easily be captured at run time. Expose the user cookie via
DTrace by updating the translator in tcp.d and add a quick test
program, a TCP server, that sets the cookie on each connection
accepted.

Reviewed by:	hiren
MFC after:	1 week
Sponsored by:	Limelight Networks
Differential Revision:	https://reviews.freebsd.org/D7152
2016-07-08 23:44:09 +00:00
Alan Somers
39ba705baf Fix bitstring allocation on 32-bit platforms
sys/sys/bitstring.h
	Fix a rounding calculation that could undersize a bitstring on
	32-bit platforms.

tests/sys/sys/bitstring_test.h
	Add a test for bitstr_size

PR:		210260
Reported by:	Mark Millard
Reviewed by:	gibbs
Approved by:	re (marius)
Sponsored by:	Spectra Logic Corp
Differential Revision:	https://reviews.freebsd.org/D6848
2016-06-24 21:44:46 +00:00
John Baldwin
b1012d8036 Account for AIO socket operations in thread/process resource usage.
File and disk-backed I/O requests store counts of read/written disk
blocks in each AIO job so that they can be charged to the thread that
completes an AIO request via aio_return() or aio_waitcomplete().  This
change extends AIO jobs to store counts of received/sent messages and
updates socket backends to set these counts accordingly.  Note that
the socket backends are careful to only charge a single messages for
each AIO request even though a single request on a blocking socket might
invoke sosend or soreceive multiple times.  This is to mimic the
resource accounting of synchronous read/write.

Adjust the UNIX socketpair AIO test to verify that the message resource
usage counts update accordingly for aio_read and aio_write.

Approved by:	re (hrs)
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D6911
2016-06-21 22:19:06 +00:00
Alan Somers
1fe8c3077f Skip sys/acl tests on systems lacking perl
tests/sys/acl/Makefile
	add perl to the required_programs for all tests in this directory

Reviewed by:	ngie
Approved by:	re (gjb)
MFC after:	4 weeks
Sponsored by:	Spectra Logic Corp
Differential Revision:	https://reviews.freebsd.org/D6870
2016-06-20 23:17:00 +00:00