Commit Graph

1485 Commits

Author SHA1 Message Date
Alan Somers
f9fffe9e2b fsx: seed more randomly with the -S0 option
When using -S0, seed the PRNG with the current time in nanoseconds, not
seconds, so consecutive runs don't accidentally use the same seed.

Also, rename some variables for clarity.

Reviewed by:	ngie
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D20078
2019-04-28 17:27:06 +00:00
Alan Somers
6040822c4e Make timespecadd(3) and friends public
The timespecadd(3) family of macros were imported from NetBSD back in
r35029. However, they were initially guarded by #ifdef _KERNEL. In the
meantime, we have grown at least 28 syscalls that use timespecs in some
way, leading many programs both inside and outside of the base system to
redefine those macros. It's better just to make the definitions public.

Our kernel currently defines two-argument versions of timespecadd and
timespecsub.  NetBSD, OpenBSD, and FreeDesktop.org's libbsd, however, define
three-argument versions.  Solaris also defines a three-argument version, but
only in its kernel.  This revision changes our definition to match the
common three-argument version.

Bump _FreeBSD_version due to the breaking KPI change.

Discussed with:	cem, jilles, ian, bde
Differential Revision:	https://reviews.freebsd.org/D14725
2018-07-30 15:46:40 +00:00
Alan Somers
e310a67bc4 Fix the build of tools/regression/sockets/unix_cmsg
MFC after:	2 weeks
2018-07-19 00:22:18 +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
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
Pedro F. Giffuni
8a16b7a18f General further adoption of SPDX licensing ID tags.
Mainly focus on files that use BSD 3-Clause license.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.

Special thanks to Wind River for providing access to "The Duke of
Highlander" tool: an older (2014) run over FreeBSD tree was useful as a
starting point.
2017-11-20 19:49:47 +00:00
Pedro F. Giffuni
df57947f08 spdx: initial adoption of licensing ID tags.
The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.

Special thanks to Wind River for providing access to "The Duke of
Highlander" tool: an older (2014) run over FreeBSD tree was useful as a
starting point.

Initially, only tag files that use BSD 4-Clause "Original" license.

RelNotes:	yes
Differential Revision:	https://reviews.freebsd.org/D13133
2017-11-18 14:26:50 +00:00
Bryan Drewery
ea825d0274 DIRDEPS_BUILD: Update dependencies.
Sponsored by:	Dell EMC Isilon
2017-10-31 00:07:04 +00:00
Gleb Smirnoff
a4658c801e Add a test case for a connection on accept queue that is reset before
it is accepted.  In that case accept(2) shall return ECONNABORTED.
Accept filters provide help with easily replicating that case.
2017-08-24 20:52:02 +00:00
Enji Cooper
22184bfa63 Improve handling with system state
- Always unlink $cmd after exit via END block.
- The tests don't function well if kern.geom.debugflags != 0. Save debugflags,
  then restore them at the end of the test.

MFC after:	1 month
Sponsored by:	Dell EMC Isilon
2017-06-10 20:56:31 +00:00
Enji Cooper
e15b2a7854 Don't explicitly get the class to PART in gctl_test_helper.c
This will allow the tool to be used with arbitrary geom(4) classes, like GEOM.

Specify class=PART explicitly in the tester to keep existing behavior.

MFC after:	1 month
Sponsored by:	Dell EMC Isilon
2017-06-10 19:48:45 +00:00
Gleb Smirnoff
62b2dd31af Make the test to leave one connection on the incomplete queue
before exiting.  This examines some race conditions in kernel.
2017-06-08 06:13:53 +00:00
Gleb Smirnoff
f7ff0c669e Improve this unit test: make sure that the accept filter actually works.
Before this test just checked scenario of setting and removing the accept
filter at different states of the socket.  Now it also checks that accept
filter works: we connect to the server, and then check that we can't accept,
then we send 1 byte of data and check again.
2017-06-08 05:12:11 +00:00
Enji Cooper
73dcfb8ddc Use calloc instead of malloc + memset
MFC after:	3 days
Sponsored by:	Dell EMC Isilon
2017-05-27 23:57:09 +00:00
Enji Cooper
67b1f73f1e gctl_test.t: catch errors with the mdcfg directive
While here, add a note about certain testcases relying on `count=1024` in
the "create" portion.

MFC after:	5 weeks
Sponsored by:	Dell EMC Isilon
2017-04-23 02:30:06 +00:00
Enji Cooper
d1f57d5900 gctl_test.t: improve error reporting with mdcfg and mount directives
If the commands had failed previously, it would press on and result in a
series of cascading failures. Fail early and continue on to the next case
instead of executing additional commands after a previously failed series
of steps.

MFC after:      5 weeks
Sponsored by:   Dell EMC Isilon
2017-04-22 23:30:02 +00:00
Enji Cooper
9940eaaa17 gctl_test.t: more tweaks to try and update the code and get it functional (again?)
- Make the logfile for $out be built off the basename for $cmd, instead of $cmd.
  (r317292 broke this assumption).
- Rename $mntpt to $mntpt_prefix for clarity, as this variable is a prefix for
  mountpoints.
- Reindent the umount directive block while here to match the rest of the code.

MFC after:	5 weeks
Sponsored by:	Dell EMC Isilon
2017-04-22 23:27:40 +00:00
Enji Cooper
414bf3a177 Use verb=delete not verb=remove
The `remove` verb hasn't been present in geom_part*(4) for well
over a decade, if ever. I couldn't find any references to it in
^/stable/5 at least, which is around the timeframe that this test
was written.

MFC after:	5 weeks
Sponsored by:	Dell EMC Isilon
2017-04-22 23:06:53 +00:00
Enji Cooper
acca703a09 gctl_test.t: minor tweaks
- Declare $count with the `my` scope operator to permit `use strict`.
- Add `use strict`.
- Use `use warnings` instead of using `-w` in the shebang.
- Don't unlink $cmd when done (prevents unnecessary rebuilding).
- Improve the error message when running with insufficient permissions, e.g.,
  non-root.

MFC after:	5 weeks
Sponsored by:	Dell EMC Isilon
2017-04-22 22:40:39 +00:00
Enji Cooper
29924a1c12 gctl_test_helper: add diagnostic output for parse_retval(..)
This will help end-users better diagnose issues with the function.

MFC after:	5 weeks
Sponsored by:	Dell EMC Isilon
2017-04-22 22:34:45 +00:00
Enji Cooper
d55eb4ff7e The GPT class no longer exists; use the PART class instead
MFC after:	5 weeks
Sponsored by:	Dell EMC Isilon
2017-04-22 20:51:54 +00:00
Enji Cooper
cb7cf35ee9 Bump WARNS to 6 per previous commits which fixed warnings
MFC after:	5 weeks
Tested with:	clang (4.0), gcc (4.2.1, 6.3.0)
Sponsored by:	Dell EMC Isilon
2017-04-22 20:29:56 +00:00
Enji Cooper
e1915a5901 gctl_test_helper: apply polish
- Staticize variables to fix warnings.
- Sprinkle asserts around for calls that can fail
- Apply style(9) for main(..) definition.
- ANSIify usage(..) definition.

MFC after:	5 weeks
Sponsored by:	Dell EMC Isilon
2017-04-22 20:27:46 +00:00
Enji Cooper
b58910a05f gctl_test.t: use make to compile gctl_test_helper instead of calling cc directly
MFC after:	5 weeks
Sponsored by:	Dell EMC Isilon
2017-04-22 20:15:47 +00:00
Enji Cooper
e02a067a1a Rename gctl.t to gctl_test.t and test.c to gctl_test_helper.c
This is being done to reduce ambiguity and to make the tests more portable
in the future to other locations in the source tree.

MFC after:	5 weeks
Sponsored by:	Dell EMC Isilon
2017-04-22 20:06:11 +00:00
Enji Cooper
b87e84c58a Fix -Wimplicit-function-declaration compilation warning by moving libgeom.h
#include below the stdio.h #include.

gctl_dump(3) needs stdio.h, per reasoning noted in r317289.

MFC after:	5 weeks
PR:		218809
Submitted by:	Chang-Hsien Tsai <luke.tw@gmail.com>
Sponsored by:	Dell EMC Isilon
2017-04-22 20:00:52 +00:00
Warner Losh
fbbd9655e5 Renumber copyright clause 4
Renumber cluase 4 to 3, per what everybody else did when BSD granted
them permission to remove clause 3. My insistance on keeping the same
numbering for legal reasons is too pedantic, so give up on that point.

Submitted by:	Jan Schaumann <jschauma@stevens.edu>
Pull Request:	https://github.com/freebsd/freebsd/pull/96
2017-02-28 23:42:47 +00:00
Gleb Smirnoff
b748360b8a Add a regression test for putting a socket on kqueue, and then doing
listen(2) on it (see r313043).  Based on Hartmut's code.
2017-02-14 21:56:01 +00:00
Maxim Sobolev
339efd75a4 Add a new socket option SO_TS_CLOCK to pick from several different clock
sources to return timestamps when SO_TIMESTAMP is enabled. Two additional
clock sources are:

o nanosecond resolution realtime clock (equivalent of CLOCK_REALTIME);
o nanosecond resolution monotonic clock (equivalent of CLOCK_MONOTONIC).

In addition to this, this option provides unified interface to get bintime
(equivalent of using SO_BINTIME), except it also supported with IPv6 where
SO_BINTIME has never been supported. The long term plan is to depreciate
SO_BINTIME and move everything to using SO_TS_CLOCK.

Idea for this enhancement has been briefly discussed on the Net session
during dev summit in Ottawa last June and the general input was positive.

This change is believed to benefit network benchmarks/profiling as well
as other scenarios where precise time of arrival measurement is necessary.

There are two regression test cases as part of this commit: one extends unix
domain test code (unix_cmsg) to test new SCM_XXX types and another one
implementis totally new test case which exchanges UDP packets between two
processes using both conventional methods (i.e. calling clock_gettime(2)
before recv(2) and after send(2)), as well as using setsockopt()+recv() in
receive path. The resulting delays are checked for sanity for all supported
clock types.

Reviewed by:    adrian, gnn
Differential Revision:  https://reviews.freebsd.org/D9171
2017-01-16 17:46:38 +00:00
Maxim Sobolev
79847968f9 Check that SCM_XXX timestamp returned by the kernel is less 1 second
away in the past from the current time. This should be plenty for the
scheduler to do its job. It provides assurance that the timestamp
returned is actually a valid one, not just some random garbage.
2016-12-09 22:13:00 +00:00
Maxim Sobolev
0d49655f96 Auto-generate 2 test cases that differ only in structure and SCM_XXX constant
used. We can do it programmatically, but that would make code convoluted
and more complex. I have two more of those types coming for the CLOCK_REALTIME
and CLOCK_MONOTONIC. This seems like an elegant and scallable approach.
2016-12-06 18:22:25 +00:00
Maxim Sobolev
1fab62b1e1 Refactor the regression test code by splitting huge monolithic C
file into smaller pieces that are hopefully easier to understand
and extend. This is to pave the ground for adding few more
socket timestamp formats that I am working on here.

No functional changes (I hope).
2016-12-05 17:21:04 +00:00
Jung-uk Kim
fadb8b98ee Clean up and add some test cases for ALU instructions. 2016-10-21 06:56:30 +00:00
Mariusz Zaborski
d3bfc7250f Move libcasper tests from regression/capsicum/libcasper/ to
lib/libcasper/service/${service_name}/tests.

Reviewed by:	emaste, ngie
Differential Revision:	https://reviews.freebsd.org/D7759
2016-09-08 20:01:26 +00:00
Mariusz Zaborski
d7795033dd Fix Capsicum syscalls test suite. 2016-08-30 19:58:41 +00:00
Enji Cooper
d36b43fc49 Remove calls to die added for associated bugs
Panics are no longer hit with ^/head@r303573 on amd64

PR:     194586, 194587, 194589
Sponsored by:   EMC / Isilon Storage Division
2016-07-31 06:28:40 +00:00
Pedro F. Giffuni
bd0ca2385a tools: minor spelling fixes.
Mostly comments but also some user-visible strings.

MFC after:	2 weeks
2016-05-01 16:20:14 +00:00
Mariusz Zaborski
7f6a709bef Set NULL to the ai_next pointer which fix cap_getaddrinfo().
Add regression test case.

PR:		195551
Submitted by:	Mikhail <mp39590@gmail.com>
Approved by:	pjd (mentor)
2016-04-14 18:27:10 +00:00
Bryan Drewery
2472c543df Remove these broken filemon tests.
They were not very useful in their current state.  It only ran a fork bomb,
confirmed headers/footers matched, hard-coded the number of expected entries
(rather than ensuring each entry is present when expected), and was missing a
sizeof_long.c file from r251368 which makes its intent for testing 32-bit
binaries unclear.

More extensive tests should be written with ATF now.
2016-03-09 20:15:03 +00:00
Mariusz Zaborski
c501d73c7e Convert casperd(8) daemon to the libcasper.
After calling the cap_init(3) function Casper will fork from it's original
process, using pdfork(2). Forking from a process has a lot of advantages:
1. We have the same cwd as the original process.
2. The same uid, gid and groups.
3. The same MAC labels.
4. The same descriptor table.
5. The same routing table.
6. The same umask.
7. The same cpuset(1).
From now services are also in form of libraries.
We also removed libcapsicum at all and converts existing program using Casper
to new architecture.

Discussed with:		pjd, jonathan, ed, drysdale@google.com, emaste
Partially reviewed by:	drysdale@google.com, bdrewery
Approved by:		pjd (mentor)
Differential Revision:	https://reviews.freebsd.org/D4277
2016-02-25 18:23:40 +00:00
Jilles Tjoelker
f00fb5457e semget(): Check for [EEXIST] error first.
Although POSIX literally permits failing with [EINVAL] if IPC_CREAT and
IPC_EXCL were both passed, the semaphore set already exists and has fewer
semaphores than nsems, this does not allow an application to retry safely:
if the [EINVAL] is actually because of the semmsl limit, an infinite loop
would result.

PR:		206927
2016-02-07 22:12:39 +00:00
Enji Cooper
ca62bc5f7e Use different ports in the TCP/UDP testcases with the first set and
the second set (increment the original ports by 10)

This avoids issues where the first listening socket might not be torn
down by the time it makes it to the second set of testcases.

The sockets should likely only be setup once, but this keeps in the
spirit of the original testcases, so this will be easier to backport
to ^/stable/9

MFC after: 1 week
Sponsored by: EMC / Isilon Storage Division
2016-01-23 22:51:22 +00:00
Enji Cooper
0d6796ed05 Don't run the t_cmsg_len testcase on 64-bit architectures
It always fails when trying to send through the sendit(9) private KPI in the
kernel due to a size mismatch between the msghdr and data being sent [*], which
suspiciously seems like it's related to sizeof pointers instead of scalars, or
something of that ilk

MFC after: 1 week
PR: 206543, 206544 [*]
Sponsored by: EMC / Isilon Storage Division
2016-01-23 22:49:13 +00:00
Enji Cooper
78cd93ff95 - Don't return immediately in check_xucred, check_scm_creds_cmsgcred, and
check_scm_creds_sockcred after initial != NULL checks have been done for
  debugging purposes
- Use more terse names for bintime (bt), cmesgcred (cmcred),
  sockcred (sc), and timeval (tv) [*]
- Add some debug messages to better understand some of the flow of the test
  program

MFC after: 1 week
Requested by: bde [*]
Use of the word "terse" (^.^) corrected by: jhb, rpokala [*]
Sponsored by: EMC / Isilon Storage Division
2016-01-23 22:44:00 +00:00
Jilles Tjoelker
afa04e4170 sem: Don't free nameinfo that is still in list when open() fails.
This bug could be reproduced easily by calling sem_open() with O_CREAT |
O_EXCL on a semaphore that is already open in the process. The struct
sem_nameinfo would be freed while still in sem_list and later calls to
sem_open() or sem_close() could access freed memory.

PR:		206396
MFC after:	5 days
2016-01-22 14:52:31 +00:00
Enji Cooper
f4ce06a920 Fix -Wunused warning with clang/gcc
- Get rid of unused argc/argv variables in main
- Bump WARNS to 6

MFC after: 3 days
Sponsored by: EMC / Isilon Storage Division
2016-01-16 02:19:56 +00:00
Enji Cooper
cc67e311d5 Fix warnings with clang/gcc
- Get rid of unused argc/argv variables in main
- Exit on failure with a return code of 1 instead of -1 with err/errx as a
  return code of -1 is implementation dependent
- Bump WARNS to 6

MFC after: 5 days
Sponsored by: EMC / Isilon Storage Division
2016-01-16 02:18:36 +00:00
Enji Cooper
eb1c509ffd Fix warnings with gcc 5.0
reconnect.c:
- Convert the K&R prototype of main to an ANSI prototype to mute a
  warning from gcc 4.2.1
- Close s_sock2 after finishing off the last test to plug a leak and
  mute a warning from gcc 5.0 about a -Wunused-but-set variable

sendfile.c:
- Fix a -Wunused-but-set warning with gcc 5.0 with pagesize in main(..)

MFC after: 5 days
Sponsored by: EMC / Isilon Storage Division
2016-01-16 02:15:13 +00:00
Enji Cooper
c084ac2883 Test for EPROTOTYPE not EPROTONOSUPPORT
- `SOCK_RAW` is the implied supported type parameter for socket(2) per route(4)
- localsw in `sys/kern/uipc_usrreq.c` doesn't have an entry for `SOCK_RAW`, so
  the prototype is invalid (this isn't explicitly documented anywhere I could
  find)

MFC after: 1 week
Sponsored by: EMC / Isilon Storage Division
2016-01-16 02:02:50 +00:00
Enji Cooper
7c5cecc0f9 Add missing newline to message about requiring root privileges
This will help ensure that scripts/parsers don't get confused when the message
is printed out

MFC after: 3 days
Sponsored by: EMC / Isilon Storage Division
2016-01-16 01:37:17 +00:00