Commit Graph

4832 Commits

Author SHA1 Message Date
rillig
4916b997a5 lint: remove message 189, add tests for a few other messages
Message 189 would have applied to traditional C and was supposed to
detect assignments between struct and union types.  The corresponding
check had never been implemented though.

Traditional C has been superseded for 30 years now, therefore there is no
point in adding this check retroactively.
2021-01-30 17:56:29 +00:00
rillig
3029566535 lint: add tests that trigger a few more messages 2021-01-30 17:02:58 +00:00
rillig
37de14639f lint: add test for message 325, undefined static function 2021-01-24 17:55:41 +00:00
rillig
e8cbbabf42 lint: add test for message 329, union cast with incompatible type 2021-01-24 17:44:37 +00:00
rillig
fe3677c509 lint: add tests for a few messages 2021-01-24 16:12:45 +00:00
rillig
1f640a49f4 lint: fix wrong warning about null pointer comparison 2021-01-24 11:21:58 +00:00
rillig
7b8d5df0f6 lint: demonstrate wrong 124 for flipped == as well
Since the fix in the next commit changes two places in the code, there
must be two wrong error messages that disappear then.
2021-01-24 11:17:44 +00:00
rillig
fc1964e307 lint: demonstrate wrong 124 due to bug in is_typeok_eq 2021-01-24 11:13:22 +00:00
rillig
adda8a3bab lint: document bug in typeok_eq
Since rt is an alias for rn->tn_type->t_tspec, it cannot be PTR and VOID
at the same time.  This makes the condition unsatisfiable.  Removing
that part of the code didn't show any change in behavior, as expected.

It may even be that fixing this obvious bug doesn't show any change in
behavior since that function is only used in a single place and
check_pointer_comparison performs its own checks before issuing any
warning.

At least the test cases added to msg_124.c all run as expected.
2021-01-24 10:50:42 +00:00
rillig
f2a08f3e9b lint: improve introduction of test d_c99_bool_strict_syshdr 2021-01-24 09:18:42 +00:00
rillig
378eb7af09 lint: explain why !finite(x) is not allowed in strict bool mode 2021-01-24 07:58:48 +00:00
rillig
4e7742bb74 lint: apply strict bool mode to lex.c
There are 2 remaining expressions:

In line 244, !(kw->kw_deco & deco) is a bitwise and.  This is already
allowed for enums, it needs to be allowed for arbitrary integer
expressions as well.  This covers the many places where plain integers
are used for bit fields, together with #define.  This pattern is not as
typesafe as using enums, still it is common practice.

In line 769, the expression !finite(f) is a legitimate use of a function
that has return type int for traditional reasons.  It's the same as for
ferror.

There are several other functions like unlink, open or strcmp that have
return type int as well, but with a different meaning.  It is not yet
clear what the best way is to handle these different meanings.  Having
to write finite(f) == 0 in strict bool mode doesn't look idiomatic, on
the other hand, !strcmp(s1, s2) is exactly the pattern that strict bool
mode wants to avoid.
2021-01-23 23:11:40 +00:00
rillig
9cd64a121c lint: fix error message for relaxed bool operations in system headers
In strict mode, allowing 1 as bool constant expression is probably not
needed in practice since most comparisons are != 0 instead of == 0.

Furthermore, in the expression (flags & 0x0002) == true, comparing with
true is misleading since the '==' operator can never evaluate to true in
this case.
2021-01-23 22:34:01 +00:00
rillig
4e2fcabaa8 lint: fix two wrong error messages in strict bool mode
The strict bool mode gets complicated because for system headers the
rules need to be relaxed since they cannot be changed easily, often not at all.

Still, if lint validates a program in strict bool mode, that program
must run with equal behavior regarding boolean expressions even on a
pre-C99 platform.
2021-01-23 22:20:17 +00:00
rillig
afdff4f65d lint: extend test for strict bool mode and system headers 2021-01-23 19:03:55 +00:00
chs
6ab81237dc for the busypage test, replace atf_tc_expect_fail() with atf_tc_skip()
because atf apparently has no way to expect a test program to crash.
fixes PR 55945.
2021-01-22 22:03:01 +00:00
simonb
14893fad26 Use .set noreorder and use reg names.
atf- lib/libc/sys/t_mprotect mprotect_mremap_exec is a bit happier now.
2021-01-21 00:56:41 +00:00
rillig
f7ed7c6314 lint: clean up code (mostly comments) 2021-01-18 20:02:34 +00:00
rillig
17f1c77b1c lint: fix assertion failure for restrict and _Thread_local 2021-01-18 17:43:43 +00:00
rillig
8981d6d027 lint: add more test cases for duplicate type qualifiers 2021-01-18 17:41:04 +00:00
simonb
b64a04d2b4 Check for MAP_FAILED instead of NULL when looking for an error from mmap(2). 2021-01-18 05:44:20 +00:00
rillig
8274970958 lint: allow system headers to use int as bool, even in strict bool mode 2021-01-17 23:04:09 +00:00
rillig
fb08819de8 lint: add more tests for system headers in strict bool mode 2021-01-17 23:00:41 +00:00
rillig
d5ff218b54 lint: add test for macro from system header in strict bool mode
Seen in usr.bin/make/meta.c:1670: FD_ZERO(&readfds).  These macros
cannot be fixed since system headers must not include <stdbool.h>.
Therefore INT constants should be accepted as controlling expressions as
well.
2021-01-17 21:19:06 +00:00
rillig
bf9c8d819d lint: add type information to message 126 2021-01-17 17:14:34 +00:00
rillig
8e597c87a3 lint: add test for incrementing const variable 2021-01-17 16:19:54 +00:00
rillig
2ba3ae8c78 lint: add test for rvalue ++ after cast 2021-01-17 16:16:09 +00:00
rillig
3bfc030e8c lint: add test for ordered comparison between incompatible types 2021-01-17 16:00:16 +00:00
rillig
129dd59395 lint: rename build_ampersand to build_address
At that stage of analysis, the ampersand is no longer ambiguous, it has
already been resolved as the address-of operator, instead of the
bitwise-and operator.
2021-01-17 14:45:21 +00:00
rillig
29d26eb8ed lint: in strict bool mode, don't treat bool as arithmetic type 2021-01-17 13:50:32 +00:00
rillig
4567bafeac lint: explain failing test case in strict bool mode 2021-01-17 13:15:03 +00:00
rillig
8974cec54a lint: demonstrate wrong error message in strict bool mode 2021-01-17 11:32:06 +00:00
rillig
8e0049026c lint: simplify typeok_strict_bool_compatible 2021-01-16 18:58:21 +00:00
rillig
bc43daba66 lint: add missing warning for bool() == int 2021-01-16 18:48:52 +00:00
rillig
68c2df6f3a lint: remove redundant calls to before_conversion 2021-01-16 17:54:22 +00:00
rillig
6caf229b90 lint: add test for missing check in strict bool mode 2021-01-16 16:58:39 +00:00
rillig
9f199e7ddf lint: in strict bool mode, integer constants do not have type bool
Previously, lint1 allowed integer constants such as 0 and 1 to be used
as bool constants.  This was only half-baked since after fixing all
error messages from that strict mode, there may still be integer
literals in the code that should be replaced with true or false.  This
would stop a migration from int to bool in the middle, leaving
inconsistent code around.

To find the remaining type inconsistencies, treat integers and bool as
completely incompatible, even for compile time constants.
2021-01-16 16:03:46 +00:00
rillig
2b74a6f1fa lint: prepare to make strict bool mode even stricter
Currently, strict bool mode still allows integer constant expressions to
be converted implicitly to bool.  This is something that other languages
such as Go, Java, C#, Pascal don't allow.

By providing a custom implementation of <stdbool.h> that defines false
and true to custom bool constant identifiers, lint will cover these
cases as well.

To prepare for this, reword the rules and restructure the tests in
d_c99_bool_strict.c.
2021-01-16 15:02:11 +00:00
rillig
a04184dc1f lint: normalize whitespace in tests 2021-01-16 12:57:37 +00:00
rillig
7425412f34 lint: add test for bool bit fields as operands of '|' 2021-01-15 23:15:28 +00:00
rillig
1ceef75ca4 lint: in strict bool mode, allow bool as operands of the comma operator 2021-01-15 22:07:54 +00:00
rillig
5160655d66 lint: demonstrate wrong message for comma operator 2021-01-15 22:04:27 +00:00
rillig
a738d648f3 lint: add tests for newly added messages for strict bool mode 2021-01-14 22:18:13 +00:00
rillig
4a20ca39ed lint: add type details to message for enum type mismatch
Before December 2020, it was cumbersome to add type information to a
message since the caller had to explicitly allocate buffers for the type
names.  That's probably the reason why this crucial detail had been left
out of the warning.
2021-01-14 07:42:31 +00:00
simonb
f5add44d28 Unmount and unconfigure in the reverse order that they were done. Fixes
problem with leaving a dangling snapshot configured.
2021-01-14 04:30:40 +00:00
skrll
95cbb4a14b skip sigbus_adraln on MIPS 2021-01-13 06:44:55 +00:00
rillig
58ad84b7ab lint: add new check for strict bool mode
In strict bool mode, bool is considered incompatible with all other
scalar types, just as in Java, C#, Pascal.

The controlling expressions in if statements, while loops, for loops and
the '?:' operator must be of type bool.  The logical operators work on
bool instead of int, the bitwise operators accept both integer and bool.
The arithmetic operators don't accept bool.

Since <stdbool.h> implements bool using C preprocessor macros instead of
predefining the identifiers "true" and "false", the integer constants 0
and 1 may be used in all contexts that require a bool expression.
Except from these, no implicit conversion between bool and scalar types
is allowed.

See usr.bin/tests/xlint/lint1/d_c99_bool_strict.c for more details.

The command line option -T has been chosen because all obvious choices
(-b or -B for bool, -s or -S for strict) are already in use.  The -T may
stand for "types are checked strictly".

The default behavior of lint doesn't change.  The strict bool check is
purely optional.

An example program for strict bool mode is usr.bin/make, which has been
using explicit comparisons such as p != NULL, ch != '\0' or n > 0 in
most places for a long time now, even before the refactoring in 2020.
2021-01-12 20:42:00 +00:00
christos
d25fab543f Only try to create up-to NAME_MAX filenames.
XXX: this should be moved to stdio/t_mktemp.c where the rest of the tests
are and the code lives.
2021-01-11 20:31:34 +00:00
skrll
6285957ff6 PR/55715: pmax testbed panics with "assertion "asid == curcpu()->ci_pmap_asid_cur" failed"
It's GXemul that has the bug! Unfortunately, there's no way (currently) to
detect if we're running under GXemul emulation, so disable for all mips
for now.  Hopefully, GXemul will get fixed soon.
2021-01-11 07:17:49 +00:00
rillig
bf28682f65 lint: extend test for strict _Bool handling
There is no danger in allowing (flags & FLAG) as a controlling
expression, provided that it is immediately compared to zero, such as in
an if statement or as the operand of a logical operator.
2021-01-11 00:28:28 +00:00
rillig
e9d1e169d3 lint: add enum flags to the test about strict boolean mode 2021-01-10 21:45:50 +00:00
rillig
465f117622 lint: allow custom flags to be specified in all unit tests
Previously, only the tests called msg_*.c could use this feature.  Since
it is useful for other tests as well, enable it everywhere.
2021-01-10 21:26:12 +00:00
skrll
8be367b3f6 PR/55715: pmax testbed panics with "assertion "asid == curcpu()->ci_pmap_asid_cur" failed"
disable the sigbus_adraln test on qemu for now
2021-01-10 20:46:14 +00:00
rillig
556f6964e2 lint: fix assertion failure for syntax error in enum declaration 2021-01-10 18:13:42 +00:00
rillig
0ec7a3ab6a lint: add test for triggering assertion failures in lint1 2021-01-10 18:06:38 +00:00
rillig
76d2ead3e0 lint: add test for treating _Bool as non-scalar type
This strict mode is not yet implemented.  The plan is to use it for
usr.bin/make, to get rid of the many possible variants of defining the
Boolean type in make.h.  These variants did find some bugs, but not
reliably so.  Using static analysis seems more promising for this.

In an early stage of developing this test, lint1 crashed in the enum
definition in line 213, where the node for the '?:' had been NULL.  This
can happen in other situations as well, such as with syntax errors, but
these should be rare, as lint is usually only run if the compiler has
accepted the source code.  Still, there should not be any assertion
failures while running lint1.
2021-01-10 17:43:46 +00:00
rillig
60d8513049 lint: use message 232 for unused label in function
This message had been defined but not used before.
2021-01-10 13:54:13 +00:00
rillig
c7eced1ab4 lint: explain missing error for _Bool constant expressions 2021-01-10 13:17:24 +00:00
rillig
a90a871c79 lint: fix conversion of non-constant scalar to _Bool 2021-01-10 12:46:38 +00:00
rillig
f8cc76a76d lint: fix conversion of constant expressions to _Bool 2021-01-10 12:34:56 +00:00
rillig
9d90fb23fe lint: add test for converting non-constant expressions to _Bool 2021-01-10 12:29:46 +00:00
rillig
e107438c00 lint: demonstrate wrong handling of conversion to _Bool 2021-01-10 11:24:42 +00:00
rillig
6bb8504ff5 lint: add test for 116 "illegal pointer subtraction" 2021-01-09 22:55:36 +00:00
rillig
1043e742ed lint: fix crash for error 108 (invalid type of unary operator) 2021-01-09 17:21:33 +00:00
rillig
fe02f4b2ac lint: add test for message 108, which currently crashes 2021-01-09 17:02:19 +00:00
rillig
232122fb53 lint: add test for message 160 2021-01-09 15:32:06 +00:00
rillig
e3ae774eba lint: add tests for messages 117, 120, 125, 127 2021-01-09 14:37:16 +00:00
rillig
6b6b847fc8 lint: allow tests to specify additional flags
Several of the tests only need to add the -p flag.  Mentioning the
(current) default flags in each of these tests is redundant.  Therefore,
allow them to specify "lint1-extra-flags: -p" instead of the current
"lint1-flags: -g -S -w -p".
2021-01-09 14:33:53 +00:00
rillig
af03d2a051 lint: add tests for several messages 2021-01-08 21:25:03 +00:00
rillig
dbe5d068b4 lint: fix function as controlling expression (since 2020-12-31)
It's perfectly valid to directly use a function name as the controlling
expression of an if statement.  That function name is converted
implicitly to a pointer to that function, and that is a scalar value
then.

Spotted by christos in lib/libpthread/pthread.c:634.
2021-01-08 02:11:45 +00:00
rillig
91017b3441 lint: demonstrate wrong message 204 (since 2020-12-31)
In func.c 1.39 from 2020-12-31 18:51:28, the check that controlling
expressions are indeed scalar was extended from while and for loops to
if statements as well.  It just seemed to have been an oversight.

This revealed a bug in lint, which didn't accept the following valid
code snippet from lib/libpthread/pthread.c:634:

	void _malloc_thread_cleanup(void) __weak;
	...
	if (_malloc_thread_cleanup)
		_malloc_thread_cleanup();

Testing a function (instead of a function pointer) for truthiness is
probably rare since most functions are defined unconditionally.  For
weak functions it comes in handy though.

Clang-Tidy suggests to prefix the function with '&' to silence its
warning.  Doing that revealed a non-obvious behavior in build_ampersand,
which does not add the AMPER node to the expression even though it is
clearly mentioned in the code.  That is left for further research.

Once the original bug is fixed, it probably doesn't matter whether the
AMPER is discarded or retained since check_controlling_expression would
add it back.  There's probably a reason though to sometimes discard the
AMPER and sometimes retain it.
2021-01-08 01:40:03 +00:00
rillig
09a916ab1d lint: revert test for message 11
That test only produced other messages, but not message 11.
2021-01-07 19:11:58 +00:00
rillig
d8ecd506c6 lint: add tests for some messages 2021-01-07 18:37:41 +00:00
joerg
7c219dd6db Optimize nbperf
- add fudge mode which gives a slightly slower hash function, but works
  almost always in the first iteration by avoiding degenerate edges
- avoid keeping incidence lists around reducing the memory foot print by
  30%
- split edge processing from hashing as in the non-fudge case it is a
  reasonable costly part that often gets thrown away
- merge graph2 and graph3 routines now that they are mostly the same
2021-01-07 16:03:08 +00:00
rillig
7d8d33cba8 lint: add tests for messages 93, 94, 95, 96, 97, 98, 99 2021-01-07 00:38:46 +00:00
rillig
1aa2d3570d lint: fix test for message 324 on i386
i386 is an ILP32 platform (arch/i386/targparam.h).  On these platforms,
int and long have the same size, and even with the -p option for
portability checks, INT_RSIZE in inittyp.c is defined to 4, not 3.

Because of this, in check_integer_conversion, psize(nt) was not greater
than psize(ot), and the warning was not issued.

To make the test behave the same on all platforms, changed the long
variables to long long, since long long is 64-bit on all platforms, and
int is 32-bit.
2021-01-06 09:23:04 +00:00
rillig
15275571de lint: remove redundant symbolic operator names
These symbolic names for INCBEF, INCAFT, DECBEF and DECAFT were
non-standard and thus confusing.  All other operators were as expected.
Now that the operator names from ops.def are very similar, there is no
need to keep to almost identical lists around.

No change to the user-visible messages since the only place where these
operator names were used was in 324, and that message was restricted to
PLUS, MINUS, MULT and SHL.
2021-01-05 23:20:53 +00:00
rillig
b8104292aa lint: clean up symbolic operator names that are used in the messages
Including the "p" in the symbolic operator names was questionable, for
several reasons:

1.  The "p" could be taken to mean an actual variable name, which is
    confusing if the function doesn't have such a variable, or even more
    so if the line contains an unrelated variable called "p".

2.  For the binary operators, having the "p" mentioned on both sides of
    the operator (such as in "p + p") wrongly suggested that both
    operands of the expression were the same.

3.  The name "p" often stands for a pointer.  Most of the operators
    don't accept pointers, therefore the name was misleading.

For these reasons, the "p" was removed from the symbolic name of all
operators.  This makes several pairs of operators indistinguishable:

    INCBEF == INCAFT
    DECBEF == DECAFT
    UPLUS == PLUS
    UMINUS == MINUS
    STAR == MULT
    AMPER == AND

This is not expected to create any confusion since C programmers are
expected to know these double meanings.

The symbolic names for SHLASS and SHRASS were missing the '=' before.
This was added since omitting it was probably an oversight.
2021-01-05 23:07:49 +00:00
rillig
3796e6d449 lint: add test for "suggest cast" [324]
This warning is the only one that calls print_tnode, which in turn uses
the redundant operator names in str_op_t.

There is another list of operator names in ops.c, but those names
include more clutter, for example "p + p" instead of a simple "+".
Using those operator names would therefore rather be confusing. These
two lists should be merged, to remove unnecessary redundancy.
2021-01-05 22:38:51 +00:00
rillig
9a3fecd259 lint: fix bug in "precedence confusion possible [169]" 2021-01-04 23:50:46 +00:00
rillig
6c2a2c1402 lint: document and demonstrate the bug in check_precedence_confusion
It took quite a while to get to the correct interpretation of this small
piece of code and to draw the right conclusions from it.  Now the bug is
finally ready to be fixed, as already announced in the test.
2021-01-04 23:47:26 +00:00
rillig
8f3340157a lint: finish the comments in check_precedence_confusion 2021-01-04 22:41:56 +00:00
rillig
d2a5bcaf42 lint: add test for "precedence confusion possible [169]" 2021-01-04 15:52:51 +00:00
rillig
84a4b4d862 lint: add test for 265 "c89 C does not support 'long long'" 2021-01-03 20:20:01 +00:00
rillig
bd792b2822 lint: fix spelling of message 308
All other messages are lowercase as well.
2021-01-03 16:59:59 +00:00
rillig
87ac1cfc83 lint: add detailed type information for functions 2021-01-03 15:55:18 +00:00
rillig
6add3c2232 lint: add type information to message 124 "illegal pointer combination" 2021-01-03 15:51:16 +00:00
rillig
5ba1c48094 lint: add test for message 124 "illegal pointer combination"
The message may be correct, but it is not helpful in any way.  There are
just too many function pointers that may differ in a very small detail.

Before tyname.c 1.20 from 2021-01-02, the string representation of type
names was often limited to only 63 characters.  Because of this, it made
sense to omit any detail that could need more space than this.  Now that
this limitation is gone, it's reasonable to add more detail to the type
information, especially since that information is readily available.
2021-01-03 15:44:35 +00:00
rillig
8a6c8bc42b lint: add tests for some of the messages 2021-01-03 15:35:00 +00:00
rillig
e201064a7a lint: fix integration test
The body of an ATF test must never return 1 but instead report failure
via atf_fail.  Otherwise the following error message appears:

    Failed: Test case body returned a non-ok exit code, but this is
    not allowed

The test program t_integration intentionally bypasses the official ATF
API for performance reasons.  But even then, it should stick to the API
as close as possible.
2021-01-02 19:22:42 +00:00
rillig
ad4fbc2570 lint: add a few more tests
No serious bugs found this time.
2021-01-02 18:06:01 +00:00
rillig
5827a84bf2 lint: fix message 308 "Invalid type for _Complex"
Previously, lint aborted since it didn't expect tspec_name to be called
with NOTSPEC, which at that point was the only possible value of
dcs->d_cmod.
2021-01-02 17:17:00 +00:00
rillig
4b1f579b14 lint: add test for message 308 "Invalid type %s for _Complex" 2021-01-02 16:55:45 +00:00
rillig
a52e33d19b lint: allow _Bool for bit-fields 2021-01-02 16:33:39 +00:00
rillig
0eb1390092 lint: fix and document test for illegal bit-fields
The _Complex bit-field should have been commented out.
2021-01-02 16:12:39 +00:00
rillig
9a83ddef77 lint: add test for message 35: illegal bit-field type
Bug: _Bool is not accepted as a bit-field, but it should be.

Bug: lint aborts in a controlled manner with message "common/tyname.c,
190: tspec_name(0)" when it sees a declaration of a _Complex bit-field.
(Not that a _Complex bit-field would make any sense.)
2021-01-02 15:55:54 +00:00
rillig
5281bfe656 lint: demonstrate that -t mode is practically unusable
Since main1.c from 2014-04-18, running lint in -t mode produces strange
warnings in lines 1 to 3 of no file at all.

This is caused by the builtins that are parsed in main().  These
builtins are incompatible with traditional mode because they use long
double, which had not been known at that time.
2021-01-02 11:12:34 +00:00
rillig
a0a15c1464 lint: add a test for each message produced by lint1
Having a test for each message ensures that upcoming refactorings don't
break the basic functionality.  Adding the tests will also discover
previously unknown bugs in lint.

The tests ensure that every lint message can actually be triggered, and
they demonstrate how to do so.  Having a separate file for each test
leaves enough space for documenting historical anecdotes, rationale or
edge cases, keeping them away from the source code.

The interesting details of this commit are in Makefile and
t_integration.sh.  All other files are just auto-generated.

When running the tests as part of ATF, they are packed together as a
single test case.  Conceptually, it would have been better to have each
test as a separate test case, but ATF quickly becomes very slow as soon
as a test program defines too many test cases, and 50 is already too
many.  The time complexity is O(n^2), not O(n) as one would expect.
It's the same problem as in tests/usr.bin/make, which has over 300 test
cases as well.
2021-01-02 10:22:42 +00:00
rillig
c1c5b23632 lint: fix wrong warning about bitfield in C99 structure initialization
The variable namemem is supposed to be a circular list, which is
"documented" implicitly in push_member.

The implementation was buggy though.  In pop_member, the circular list
was destroyed though.  Given the list (capital, major, favorite_color,
green), removing capital made major point to itself in the forward
direction, even though it should not have been modified at all.

In the test, I had been too optimistic to quickly understand the code
around variable initialization.  I was wrong though, so I had to adjust
the comments there to reality.
2021-01-01 19:11:19 +00:00
rillig
59e2f0df9e lint: demonstrate bug in handling of nested C9X struct initializers 2021-01-01 16:50:47 +00:00
rillig
e93292def1 lint: fix segmentation fault when checking returned enum types (211) 2021-01-01 01:07:07 +00:00
rillig
ee607e0b85 lint: check that in "if (cond)", cond is scalar 2020-12-31 18:51:28 +00:00
rillig
e7d2b415e5 lint: remove a bit of redundancy from the test suite 2020-12-30 13:42:19 +00:00
rillig
dbb39b4651 lint: document purpose of the test d_struct_init_nested 2020-12-30 13:41:27 +00:00
rillig
f4b4e8b893 lint: add test for old style function arguments 2020-12-30 13:15:07 +00:00
rillig
ba07f3ab99 lint1: remove redundant description from tests 2020-12-28 17:00:37 +00:00
rillig
b435f5a0e0 lint1: add forgotten tests 2020-12-28 12:47:39 +00:00
rillig
6f82ec5c48 lint1: use tabular layout for listing the test cases 2020-12-28 12:17:23 +00:00
rillig
28f87c2d54 lint1: remove redundancy from test definitions
Whether a test is supposed to produce lint warnings is determined by the
corresponding .exp file.  There is no need to encode this information
redundantly in the test driver.
2020-12-28 12:01:24 +00:00
rillig
c64569a17c lint1: enable test cvt_constant
This test had never been enabled.  In t_integration.sh 1.3 from
2014-04-17 it was supposed to be enabled, but due to a line continuation
backslash, the words "test_case check_valid" ended up as the description
of the previous test, cvt_in_ternary.

While here, add the expected test output for d_struct_init_nested to
FILES.
2020-12-28 11:19:01 +00:00
rillig
e190c76bb9 lint1: add expected output for test d_struct_init_nested 2020-12-28 10:26:23 +00:00
rillig
69ccb624e9 lint1: add test for initializing nested structs
Discovered in var.c 1.774 from 2020-12-28.
2020-12-28 10:22:21 +00:00
rillig
05e935016b lint: for tests with output, ensure that the output matches 2020-12-28 09:58:56 +00:00
rillig
e47165949c lint: sort tests by name 2020-12-28 09:57:14 +00:00
reinoud
e6b71c1487 Implement support for trapping REP CMPS instructions in NVMM.
Qemu would abort hard when NVMM would get a memory trap on the instruction
since it didn't know it.
2020-12-27 20:56:14 +00:00
gson
2e0ec785ec Disable the lib/libossaudio/t_ossaudio:oss_dsp_trigger_read test case
on sparc until PR port-sparc/55876 gets fixed.
2020-12-26 15:28:52 +00:00
nia
a26ac9a7a3 t_ossaudio: More descriptive failure cases 2020-12-14 10:58:08 +00:00
nia
d00c08ec75 add some basic tests for libossaudio
since there are already tests for audio this is focused on making
sure the ioctls translate properly and implement the necessary OSS
compat quirks.

right now this only covers the dsp ioctls, it should also cover the
mixer ioctls, although that's significantly harder.
2020-12-11 12:29:27 +00:00
mrg
9c9331d392 apply this change to a a couple more tests:
---
date: 2020-07-27 09:57:44 -0700;  author: gson;  state: Exp;  lines: +6 -1;  commitid: m3HouRBlhyJQVJhC;
Skip the repeated_link_addr test by default as it causes the
evbarm-aarch64 testbed to hang (PR port-evbarm/55521), and will not be
safe to run by default even after that bug is fixed, for similar
reasons as t_repeated_updown.
---

t_repeated_mtu.sh changes the MTU, which may cause NFS to fail.
if you have NFS root, this is system killing.

t_repeated_scan.sh kills and restarts both hostapd and
wpa_supplicant.
2020-12-10 08:16:59 +00:00
chs
a7b9f93047 the busypage test is buggy, expect it to fail. 2020-12-08 17:52:11 +00:00
msaitoh
48b6679adf s/ we we / we / 2020-11-30 05:30:56 +00:00
christos
43d7e2f9be map enough space for both the page we write and the guard so that we make
sure we own the guard page before we set its protection to none. This fixes
random SEGVs where the page we set protection to none probably belonged to
the dynamic linker. Reported by gson@
2020-11-27 16:50:02 +00:00
gson
10c9b659e2 delete trailing whitespace 2020-11-27 15:37:06 +00:00
yamaguchi
37f4aefcd5 Use a state of IPCP and IPv6CP to wait for connection established 2020-11-25 10:35:07 +00:00
gson
b19091917e Mark t_tsan_*:*profile test cases as expected failures as discussed in
PR toolchain/55760.
2020-11-17 08:25:57 +00:00
martin
3a37f06f8b PR 55338: re-enable threxec test for more test coverage. 2020-11-08 08:54:50 +00:00
martin
5e2aeb226f Fix typo 2020-11-05 20:03:56 +00:00
christos
340d07a6bc Add unit-tests for col from FreeBSD 2020-11-01 22:28:32 +00:00
gson
086d077df3 Make the mkstemps_basic and mkostemps_basic test cases not randomly
fail when the replacement string happens to contain the letter "y".
2020-11-01 18:19:54 +00:00
christos
ffcac9dc43 Avoid hard-coding names and limits so this will not break again. 2020-10-31 14:57:02 +00:00
christos
ed75ee8266 PR/55663: Ruslan Nikolaev: Add support for EVFILT_USER in kqueue(2) 2020-10-31 01:08:31 +00:00
kre
74ce69e5d7 Update the test a little so that is possible to pass
(if date fails, because of bad or out of range input
to parsedate, it cannot be expected to output the
expected result).

Remove the atf-expect-fail now that parsedate() should
detect overflows, and fail, causing date to fail, rather
than simply producing bogus results.
2020-10-30 22:03:35 +00:00
blymn
865079658a Disable the wgetch test as it appears to be missing at the moment. 2020-10-29 00:27:50 +00:00
martin
bc61105d29 Use the relative paths in the installed version, not the (different)
source pathes.
2020-10-27 11:01:22 +00:00
mgorny
fc2fc80ae1 Add tests for AVX-512 registers (zmm0..zmm31, k0..7)
Thanks to David Seifert <soap@gentoo.org> for providing a VM
on an AVX-512 capable hardware

Reviewed by kamil
2020-10-27 08:32:36 +00:00
roy
033e3d74df Remove extra parens 2020-10-24 14:45:06 +00:00
martin
675eb1fbbe Add the new tests + check files, sort. 2020-10-24 14:21:25 +00:00
mgorny
120793c21a Issue 64-bit versions of *XSAVE* for 64-bit amd64 programs
When calling FXSAVE, XSAVE, FXRSTOR, ... for 64-bit programs on amd64
use the 64-suffixed variant in order to include the complete FIP/FDP
registers in the x87 area.

The difference between the two variants is that the FXSAVE64 (new)
variant represents FIP/FDP as 64-bit fields (union fp_addr.fa_64),
while the legacy FXSAVE variant uses split fields: 32-bit offset,
16-bit segment and 16-bit reserved field (union fp_addr.fa_32).
The latter implies that the actual addresses are truncated to 32 bits
which is insufficient in modern programs.

The change is applied only to 64-bit programs on amd64.  Plain i386
and compat32 continue using plain FXSAVE.  Similarly, NVMM is not
changed as I am not familiar with that code.

This is a potentially breaking change.  However, I don't think it likely
to actually break anything because the data provided by the old variant
were not meaningful (because of the truncated pointer).
2020-10-24 07:14:29 +00:00
blymn
ce321bb046 Merge in code from Google Summer of Code project which dramatically
increases the number of tests performed.

Thanks to Naman Jain <jnaman806@gmail.com> for his excellent work on
this GSoC project.
2020-10-24 04:46:16 +00:00
rillig
3e905e9da4 make(1): split test suffixes.mk into simpler, isolated tests
The code in suff.c is already hard to understand, and so were the tests
in suffixes.mk since several independent topics were merged into a
single test.

Splitting this test into a separate test per issue allows to document
the expected and actual behavior in more detail.  That's complicated
enough already.

PR bin/49086
2020-10-20 20:36:53 +00:00
kre
e12ce6c4ea Adapt for change to parsedate() which now follows POSIX and altered the
dividing line between 21st and 20th century conversions from 69/70 to
68/69.   Adapt the tests for this to conform.
2020-10-19 15:06:49 +00:00
roy
12f661253d wg: Fix tests by sprinkling ifconfig -w 10
So protocols have time to finish setup.
2020-10-16 16:17:23 +00:00
mgorny
fb8e91f57b Remove leftover commented out #if 0 2020-10-16 08:51:12 +00:00
rin
9b836018df Apply fix in rev 1.2 for core_dump_procinfo to aarch64 and arm:
http://cvsweb.netbsd.org/bsdweb.cgi/src/tests/lib/libc/sys/t_ptrace_core_wait.h#rev1.2

> For powerpc, program counter is not automatically incremented by trap
> instruction. We cannot increment PC in the trap handler, which breaks
> applications depending on this behavior, e.g., GDB.

This statement is true for aarch64 and arm.

Also, use PTRACE_BREAKPOINT_SIZE instead of hard-coded 4 to address
instruction next to PC.

OK ryo
2020-10-15 22:59:50 +00:00
mgorny
268edb6f45 Add tests for process_xmm_to_s87() and process_s87_to_xmm() 2020-10-15 17:44:44 +00:00
mgorny
e0a152e645 Fix s87_tw reconstruction to correctly indicate register states
Fix the code reconstructing s87_tw (full tag word) from fx_sw (abridged
tag word) to correctly represent all register states.  The previous code
only distinguished between empty/non-empty registers, and assigned
'regular value' to all non-empty registers.  The new code explicitly
distinguishes the two other tag word values: empty and special.
2020-10-15 17:43:08 +00:00
rin
be600c49a8 Argument for AUDIO_WSEEK ioctl is u_long, not int.
Fix false positive for aarch64eb (LP64BE):
AUDIO_WSEEK, failed, Line 4467: n expects 4 but 0
2020-10-13 09:00:17 +00:00
rin
d92bac2dfd Bump soft/hard limits for stack to 6MB for aarch64{,eb}, where old value
(~4MB) is too small to be accepted.
2020-10-13 06:58:57 +00:00
rin
dab17687cc For aarch64eb, no SIGBUS signal for unaligned accesses.
Convert to preprocessor directives.
2020-10-13 06:55:25 +00:00
rin
f46f81bd9a Now, profiling works for GCC9 on aarch64{,eb}.
Note that it seems to work even for GCC8, according to log data of
official test runs, e.g.,

	https://releng.netbsd.org/b5reports/evbarm-aarch64/2020/2020.09.01.15.45.20/test.log
2020-10-13 06:49:27 +00:00
christos
d32a26f01d simplify: use two arguments again, suggested by kre@ 2020-10-11 18:43:50 +00:00
christos
d4a34e5d29 Add tests for h and x flags 2020-10-11 17:17:39 +00:00
mgorny
3a2c6ec6be Add tests for x87 FPU registers
Reviewed by kamil
2020-10-09 17:43:30 +00:00
mgorny
431834add9 Rename MM_REG macro to ST_MAN, and cover fpr/xstate with it
Rename the MM_REG macro to ST_MAN, to make it clearer that it gets
mantissa of ST registers which overlaps with MM registers but can be
also used to read ST registers (to be used in the next commit).  Extend
it to cover the difference between GETFPREGS and GETXSTATE,
and therefore avoid additional condition on i386.

Reviewed by kamil.
2020-10-09 17:43:07 +00:00
rin
8674cb4654 Link librumpclient explicitly. Fix sun2, i.e., MKPIC=no build. 2020-10-01 13:49:18 +00:00
roy
d1817bc062 Be like other tests and speciy the binary name we install 2020-09-30 17:14:11 +00:00
roy
04b4419fc0 Fix prior 2020-09-30 17:05:59 +00:00
roy
856440c094 tap(4): update the test so that we can open the tap to ping across a bridge
ping with tap closed to ensure it fails
ping with tap open to ensure it works
2020-09-30 14:43:15 +00:00
roy
428927374e vether(4): Add ATF tests based on the tap(4) tests. 2020-09-29 19:41:48 +00:00
roy
fd5c758a79 Whitespace 2020-09-29 16:35:42 +00:00
roy
d76886af8e Fix build with clang. 2020-09-29 16:34:07 +00:00
yamaguchi
643fff90fa update test cases for AC-Name and Service-Name 2020-09-25 06:15:30 +00:00
yamaguchi
52817f12eb Add test cases for AC-Name and Service-Name 2020-09-25 06:07:31 +00:00
yamaguchi
3b0bfceb86 Add a limit for auth at a test for invalid account 2020-09-23 06:18:20 +00:00
yamaguchi
55cf8635ae Fix typo 2020-09-23 05:56:55 +00:00
kamil
8f03799314 Add new RTLD test file for r_debug
New tests:
 - self
 - dlopen

Both check whether the r_debug structure seems to be well-formed, without
and with a dlopen(3) call.
2020-09-22 01:09:32 +00:00
roy
65e7bf86f8 arp tests: Delete ARP entry after failed ping test
As it might hang around in WAITDELETE for a few seconds.
2020-09-18 16:33:49 +00:00
roy
fc25529d69 ndp_rtm: Only ping once
Pointless doing 3 pings.
On a slow system, it's possible that many RTM_MISS messages could
overflow into the next test.
2020-09-17 11:56:35 +00:00
roy
6a4c2721f4 arp_rtm: Only ping once
Pointless doing 10 pings.
On a slow system, it's possible that many RTM_MISS messages could
overflow into the next test.
2020-09-17 11:51:01 +00:00
roy
7a353eb78e Don't check lifetime when testing published 2020-09-15 11:19:10 +00:00
martin
af1644547e Simplify test requirements: we only build tsan for amd64 currently. 2020-09-15 09:33:12 +00:00
kamil
2062795b28 Enable TSan tests for GCC and >32bit address space environments 2020-09-14 15:17:53 +00:00
roy
caed3cda55 arp test: Use the ndp cache expiration test in place of the old one
As the logic is the same.
While here, GC some variables and comment out a redundant sleep.
2020-09-13 14:36:32 +00:00
kre
f1b3a283f6 Whitespace. NFC. 2020-09-10 17:40:34 +00:00
kre
b1ea2bb886 Replace use of tr to translate '-' in test names into '_' to satisfy ATF
requirements (correct sh variable/function name syntax).  Use a sh
loop instead, and save one fork() one vfork() and one exec of tr for
each test case (many of which don't need anything done to them at all).

This might partially mitigate PR misc/55595
2020-09-10 17:33:16 +00:00
christos
c2bd2f1f7f PR/55648: Kyle Evans: Minor warnings in compilation of libexecinfo test2 2020-09-09 20:04:10 +00:00
gson
2d97242511 Disable reverse DNS lookups in ping to avoid spurious test failures
due to unresponsive DNS servers.
2020-09-09 09:17:14 +00:00
jakllsch
3eade4a405 Acknowledge clang warning for NEON cipher code on aarch64eb
We've already made the nonportable vector initializations portable; the
code works on aarch64eb.
2020-09-08 17:35:27 +00:00
christos
ecd0250189 Add tests for IP_BINDANY, IPV6_BINDANY 2020-09-08 14:13:50 +00:00
mrg
a29667efc0 disable these tests unless ATF_SBIN_IFCONFIG_WIFI_ENABLE=yes is
in the environment.  they change wifi configuration, restart
wpa_supplicant and hostapd, and, on broken wifi chipsets, may
hang the test run.
2020-09-08 06:11:32 +00:00
mrg
c2082ece61 remove GCC_NO_ADDR_OF_PACKED_MEMBER for several subdir builds
that are now handled by lfs_accessors.h internally.
2020-09-07 03:09:53 +00:00
mrg
8820a04cbb avoid new GCC 9 warnings. 2020-09-07 00:29:14 +00:00
mrg
45092b0582 don't pass NULL to printf(), but use "<memory>" to signify this
test is operating on an in-memory only database.
2020-09-07 00:28:44 +00:00
mrg
cb93b81028 add support for new GCC 9 warnings that may be too much to fix
right now.  new address-of-packed-member and format-overflow
warnings have new GCC_NO_ADDR_OF_PACKED_MEMBER amd
GCC_NO_FORMAT_OVERFLOW variables to remove these warnings.

apply to a bunch of the tree.  mostly, these are real bugs that
should be fixed, but in many cases, only by removing the 'packed'
attribute from some structure that doesn't really need it.  (i
looked at many different ones, and while perhaps 60-80% were
already properly aligned, it wasn't clear to me that the uses
were always coming from sane data vs network alignment, so it
doesn't seem safe to remove packed without careful research for
each affect struct.)  clang already warned (and was not erroring)
for many of these cases, but gcc picked up dozens more.
2020-09-06 07:20:26 +00:00
maxv
4a2e4dc388 nvmm: update copyright headers 2020-09-05 07:22:25 +00:00
riastradh
13a2b7334d Revert "ufs: Prevent mkdir from choking on deleted directories."
This change made no sense and should not have been committed.
2020-09-05 02:55:38 +00:00
riastradh
4b73975959 ufs: Prevent mkdir from choking on deleted directories.
Fix some missing uvm_vnp_setsize in screw cases while here.
2020-09-05 02:47:48 +00:00
riastradh
44afc3b3f9 genfs_rename: Fix deadlocks in cross-directory cyclic rename.
Reproducer:

A: for (;;) { mkdir("c", 0600); mkdir("c/d", 0600); mkdir("c/d/e", 0600);
    rmdir("c/d/e"); rmdir("c/d"); }
B: for (;;) { mkdir("c", 0600); mkdir("c/d", 0600); mkdir("c/d/e", 0600);
    rename("c", "c/d/e"); }
C: for (;;) { mkdir("c", 0600); mkdir("c/d", 0600); mkdir("c/d/e", 0600);
    rename("c/d/e", "c"); }

Deadlock:

- A holds c and wants to lock d; and either
- B holds . and d and wants to lock c, or
- C holds . and d and wants to lock c.

The problem with these is that genfs_rename_enter_separate in B or C
tried lock order .->d->c->e (in A/B, fdvp->tdvp->fvp->tvp; in A/C,
tdvp->fdvp->tvp->fvp) which violates the ancestor->descendant order
.->c->d->e.

The resolution is to change B to do fdvp->fvp->tdvp->tvp and C to do
tdvp->tvp->fdvp->fvp.  But there's an edge case: tvp and fvp might be
the same (hard links), and we can't detect that until after we've
looked them both up -- and in some file systems (I'm looking at you,
ufs), there is no mere lookup operation, only lookup-and-lock, so we
can't even hold the lock on one of tvp or fvp when we look up the
other one if there's a chance they might be the same.

Fortunately the cases
(a) tvp = fvp
(b) tvp or fvp is a directory
are mutually exclusive as long as directories cannot be hard-linked.
In case (a) we can just defer locking {tvp, fvp} until the end, because
it can't possibly have {fdvp or fvp, tdvp or tvp} as descendants.  In
case (b) we can just lock them in the order fdvp->fvp->tdvp->tvp or
tdvp->tvp->fdvp->fvp if the first one of {fvp, tvp} is a directory,
because it can't possibly coincide with the second one of {fvp, tvp}.

With this change, we can now prove that the locking order is consistent
with the ancestor->descendant partial ordering.  Where two nodes are
incommensurate under that partial ordering, they are only ever locked
by rename and there is only ever one rename at a time.

Proof:

- For same-directory renames, genfs_rename_enter_common locks the
  directory first and then the children.  The order
  directory->child[i] is consistent with ancestor->descendant and
  child[0]/child[1] are incommensurate.

- For cross-directory renames:

  . While a rename is in progress and the fs-wide rename lock is held,
    directories can be created or removed but not changed, so the
    outcome of gro_genealogy -- which, given fdvp and tdvp, returns
    the node N relating fdvp/N/.../tdvp or null if there is none --
    can only transition from finding N to not finding N, if one of
    the directories is removed while any of the vnodes are unlocked.
    Merely creating directories cannot change the ancestry of tdvp,
    and concurrent renames are not possible.

    Thus, if a gro_genealogy determined the operation to have the
    form fdvp/N/.../tdvp, then it might cease to have that form, but
    only because tdvp was removed which will harmlessly cause the
    rename to fail later on.  Similarly, if gro_genealogy determined
    the operation _not_ to have the form fdvp/N/.../tdvp then it
    can't begin to have that form until after the rename has
    completed.

    The lock order is,

    => for fdvp/.../tdvp:
       1. lock fdvp
       2. lookup(/lock/unlock) fvp (consistent with fdvp->fvp)
       3. lock fvp if a directory (consistent with fdvp->fvp)
       4. lock tdvp (consistent with fdvp->tdvp and possibly fvp->tdvp)
       5. lookup(/lock/unlock) tvp (consistent with tdvp->tvp)
       6. lock fvp if a nondirectory (fvp->t* or fvp->fdvp is impossible)
       7. lock tvp if not fvp (tvp->f* is impossible unless tvp=fvp)

    => for incommensurate fdvp & tdvp, or for tdvp/.../fdvp:
       1. lock tdvp
       2. lookup(/lock/unlock) tvp (consistent with tdvp->tvp)
       3. lock tvp if a directory (consistent with tdvp->tvp)
       4. lock fdvp (either incommensurate with tdvp and/or tvp, or
          consistent with tdvp(->tvp)->fdvp)
       5. lookup(/lock/unlock) fvp (consistent with fdvp->fvp)
       6. lock tvp if a nondirectory (tvp->f* or tvp->tdvp is impossible)
       7. lock fvp if not tvp (fvp->t* is impossible unless fvp=tvp)

Deadlocks found by hannken@; resolution worked out with dholland@.

XXX I think we could improve concurrency somewhat -- with a likely
big win for applications like tar and rsync that create many files
with temporary names and then rename them to the permanent one in the
same directory -- by making vfs_renamelock a reader/writer lock: any
number of same-directory renames, or exactly one cross-directory
rename, at any one time.
2020-09-05 02:47:03 +00:00
riastradh
60f4a93e19 tests/fs/vfs/t_renamerace: Test a screw case hannken@ found. 2020-09-05 02:45:22 +00:00
gson
9c5137ef5c Format PR references consistently so that they can be automatically
turned into links in HTML reports.
2020-09-01 18:40:09 +00:00
riastradh
4131d8f567 tests/net/if_wg: Allow one second of leeway for rekey. 2020-08-31 20:32:58 +00:00
martin
fb1355a7bc Skip timeout tests, pointing to PR 55632. 2020-08-31 14:03:56 +00:00
tih
e76a1fdd82 Update the if_wg tests for the human readable 'latest-handshake'
output of wgconfig.
2020-08-29 07:22:49 +00:00
martin
f834934d77 Skip threxec test pointing at PR 55338, this kills some test beds. 2020-08-29 05:46:34 +00:00
martin
e1e4474c3c Also skip the stress_short test - it just needs way too long to timeout
and fail.
2020-08-28 19:35:07 +00:00
martin
18c37829c4 lockme_DOUBLEINIT:
The failure message differs slightly when using LOCKDEBUG, modify the
expected pattern to cover both variants.
2020-08-28 19:29:58 +00:00
martin
6cd60e7467 Skip a few tests with reference to already existing PRs as after "recent"
scheduler changes these tests now leave rump_server processes around that
eat CPU and disturb later tests.
2020-08-28 19:14:17 +00:00
christos
7865465b60 PR/55612: Martin Husemann: libarchive tests pollute /tmp w/o cleanup
Set $TMPDIR to where we are.
2020-08-28 18:46:05 +00:00
riastradh
4a9d230258 Nix trailing whitespace. 2020-08-28 14:18:29 +00:00
christos
fb880abaf0 When running the tests with atf-run the directory we are running in is
drwx------ so when we change to a different user, we can't find the socket
we created.

Make a directory and put the socket in there. Of course now atf can't
record its results as a different user, but that is not fatal.

tc-se:FATAL ERROR: Cannot create results file '/tmp/atf-run.9vOjFd/tcr': \
Permission denied
2020-08-28 13:56:29 +00:00
christos
33a3e8378d Remove unneeded sete{u,g}id pointed out by kre.
Remove dup unlink.
2020-08-28 11:46:05 +00:00
christos
52d4f80613 - when running as root, create the socket under a different uid/gid to verify
that it works properly with different users opening the socket.
- verify that linux works the same for both getpeereid() and fstat()
2020-08-27 14:00:01 +00:00
riastradh
03c60d1bc0 wg: Check mbuf chain length before m_copydata. 2020-08-27 02:52:33 +00:00
riastradh
5ec0ae9a4b Use wgconfig as intended to show diagnostics, not a usage message. 2020-08-27 02:51:49 +00:00
christos
ac4837d560 Check that fstat returns the correct socket owner 2020-08-26 22:52:58 +00:00
riastradh
25154f5f0c Clarify wg(4)'s relation to WireGuard, pending further discussion.
Still planning to replace wgconfig(8) and wg-keygen(8) by one wg(8)
tool compatible with wireguard-tools; update wg(4) for the minor
changes from the 2018-06-30 spec to the 2020-06-01 spec; &c.  This just
clarifies the current state of affairs as it exists in the development
tree for now.

Mark the man page EXPERIMENTAL for extra clarity.
2020-08-26 16:03:40 +00:00
gson
9d42296eb9 Only expect the fmod test case to fail when using qemu's TCG CPU emulation,
and not under hardware virtualization such as qemu -accel nvmm.
2020-08-25 13:39:16 +00:00
riastradh
c9aa4f445f Fix getrandom() tests.
Use sigaction() without SA_RESTART -- signal() implies SA_RESTART so
we never got the EINTR.

While here, reduce the timeout to something more reasonable so we
don't waste 20min of testbed time if anything goes wrong and the
one-second alarm doesn't fire.
2020-08-25 01:37:38 +00:00
gson
59b669221c Expect a failure to trap unaligned acesses only when running under
qemu's TCG CPU emulation, not when running under hardware virtualization
such as qemu -accel nvmm.
2020-08-24 06:55:16 +00:00
riastradh
284084a72c Nix trailing whitespace. 2020-08-23 22:34:29 +00:00
riastradh
bbfb23c92a Split getrandom tests into several cases to find out which ones hang. 2020-08-23 17:50:19 +00:00
perseant
5e1ae64c39 Expand test to cover more failure cases. Change from skipped to expect fail
in anticipation of working roll-forward code.
2020-08-23 16:03:54 +00:00
ryo
8c1c74cde8 adjust the number of spaces to match the current df(1) output.
fix NetBSD PR/55600

TODO: it should not be dependent on the number of spaces.
2020-08-23 15:51:30 +00:00
gson
bd4d304f2b Expect failure only when running under qemu's TCG CPU emulation, not
when running under hardware virtualization such as qemu -accel nvmm.
2020-08-23 11:04:58 +00:00
gson
3b030f477c Provide separate functions to check for running under qemu in general
and for running under qemu's built-in TCG CPU emulation (as opposed to
hardware virtualization via NVMM or KVM).
2020-08-23 11:00:18 +00:00
riastradh
61fd7d67f5 [ozaki-r] Add wg files 2020-08-20 21:28:00 +00:00
riastradh
a14187eca5 [ozaki-r] Changes to the kernel core for wireguard 2020-08-20 21:21:31 +00:00
riastradh
f1323c812d Nix trailing whitespace. 2020-08-20 13:58:30 +00:00
riastradh
f3d2f6ec55 clang can't handle __aligned on anonymous structure initializers. 2020-08-20 13:33:54 +00:00
gson
b134f0a332 Add cleanup of possible leftover rump processes, replacing the
non-working cleanup code just removed from ffs_common.sh.  Fixes
PR bin/48892 with respect to the t_rquotad test.
2020-08-20 07:32:40 +00:00
gson
912167fe43 Remove non-functional cleanup code from test_case() and test_case_root().
It had no effect because RUMP_SOCKETS_LIST is not set in the shell
running the cleanup phase.  Even if RUMP_SOCKETS_LIST had been set,
the code would still not have worked correctly because it ran
rump.halt via "atf_check -s exit:1", which would cause the first
successful halting of a rump processes to be treated as a failure
and abort the cleanup without halting any other rump processes still
running.
2020-08-20 07:23:20 +00:00
perseant
c7e481e284 Add skipped test for in-kernel roll-forward agent 2020-08-18 03:02:50 +00:00
riastradh
7f7b51ca34 Make the AES and ChaCha NEON tests work in softfloat userland.
(`Softfloat' here refers to the ABI, which of course may be running
on a CPU with NEON.)
2020-08-17 16:26:02 +00:00
gson
de5f9e0f37 Remove unused function rump_shutdown() 2020-08-17 06:18:39 +00:00
martin
9c197a80ad Restrict the NEON code to v7hf - the softfloat toolchain does not like
it (nor is it likely to work if there is no FPU present).
2020-08-16 15:52:14 +00:00
mlelstv
8f599c8a78 Plaintext buffers are used directly for write() operations to the raw device.
Align them to the needs of cgd(4).
2020-08-15 10:03:10 +00:00
rillig
edce479061 make(1): mark tests impsrc and phony-end as no longer failing
These tests have been adjusted to demonstrate the current behavior,
mentioning the expected behavior in comments.
2020-08-15 01:50:54 +00:00
martin
41db1294c8 Fix C++ file suffix (.cpp -> .cc) 2020-08-14 06:23:49 +00:00
martin
b220268543 Fix a few copy + pastos, simplify shell arithmetic 2020-08-14 05:22:25 +00:00
riastradh
bdad8b2721 New system call getrandom() compatible with Linux and others.
Three ways to call:

getrandom(p, n, 0)              Blocks at boot until full entropy.
                                Returns up to n bytes at p; guarantees
                                up to 256 bytes even if interrupted
                                after blocking.  getrandom(0,0,0)
                                serves as an entropy barrier: return
                                only after system has full entropy.

getrandom(p, n, GRND_INSECURE)  Never blocks.  Guarantees up to 256
                                bytes even if interrupted.  Equivalent
                                to /dev/urandom.  Safe only after
                                successful getrandom(...,0),
                                getrandom(...,GRND_RANDOM), or read
                                from /dev/random.

getrandom(p, n, GRND_RANDOM)    May block at any time.  Returns up to n
                                bytes at p, but no guarantees about how
                                many -- may return as short as 1 byte.
                                Equivalent to /dev/random.  Legacy.
                                Provided only for source compatibility
                                with Linux.

Can also use flags|GRND_NONBLOCK to fail with EWOULDBLOCK/EAGAIN
without producing any output instead of blocking.

- The combination GRND_INSECURE|GRND_NONBLOCK is the same as
  GRND_INSECURE, since GRND_INSECURE never blocks anyway.

- The combinations GRND_INSECURE|GRND_RANDOM and
  GRND_INSECURE|GRND_RANDOM|GRND_NONBLOCK are nonsensical and fail
  with EINVAL.

As proposed on tech-userlevel, tech-crypto, tech-security, and
tech-kern, and subsequently adopted by core (minus the getentropy part
of the proposal, because other operating systems and participants in
the discussion couldn't come to an agreement about getentropy and
blocking semantics):

https://mail-index.netbsd.org/tech-userlevel/2020/05/02/msg012333.html
2020-08-14 00:53:15 +00:00
knakahara
57870677c1 Fix missing "-m tranport" options. Pointed out by k-goda@IIJ.
Using any mode SA causes unepected call path, that is,
ipsec4_common_input_cb() calls ip_input() directly instead of
ipsecif4_input().
2020-08-05 01:10:50 +00:00
riastradh
7a8eb9a111 Implement 4-way vectorization of ChaCha for armv7 NEON.
cgd performance is not as good as I was hoping (~4% improvement over
chacha_ref.c) but it should improve substantially more if we let the
cgd worker thread keep fpu state so we don't have to pay the cost of
isb and zero-the-fpu on every 512-byte cgd block.
2020-07-28 20:08:48 +00:00
riastradh
dadf58c832 It's __ARM_NEON, not __ARM_NEON__, sometimes, apparently. 2020-07-27 20:59:53 +00:00
riastradh
f7b532dd9f Enable ChaCha NEON code on armv7 too.
The 4-blocks-at-a-time assembly helper is disabled for now; adapting
it to armv7 is going to be a little annoying with only 16 128-bit
vector registers.

(Should also do a fifth block in the integer registers for 320 bytes
at a time.)
2020-07-27 20:51:29 +00:00
gson
e665c975ab Skip the repeated_link_addr test by default as it causes the
evbarm-aarch64 testbed to hang (PR port-evbarm/55521), and will not be
safe to run by default even after that bug is fixed, for similar
reasons as t_repeated_updown.
2020-07-27 16:57:44 +00:00
jruoho
3f94c7658e Use the new "run_unsafe" atf_config_get() option also with a couple of other
tests that are known to be unsafe.
2020-07-27 07:36:19 +00:00
gson
7836998153 Instead of just skipping interfaces that are "up", skip the whole
repeated_updown test case unless explicitly enabled with "atf-run -v
run_unsafe=yes".  Gratuitously configuring interfaces "up" is no more
safe than gratuitously configuring them "down"; for example, it could
lead to accidentally connecting to an insecure network or diverting
traffic from the desired route.
2020-07-27 06:52:48 +00:00
riastradh
ed8eacd373 Sort includes. 2020-07-26 14:01:14 +00:00
martin
9c03d654a9 Add missing include to fix the build on architectures w/o any special
accelerated AES implementation.
2020-07-26 12:43:27 +00:00
riastradh
59613b8a1a Add kernel ChaCha test to exercise all available implementations. 2020-07-25 22:53:38 +00:00
riastradh
36d44afd5a Implement AES-CCM with ARMv8.5-AES. 2020-07-25 22:33:04 +00:00
martin
e6ac0f80fe Skip interfaces that are already UP before the test starts. We can
not change state of the test host this way, it breaks e.g. test systems
with the root filesystem on NFS.
2020-07-22 05:47:24 +00:00
maxv
d3713544b3 Compile USER_LDT by default, but, put it behind a privileged sysctl that
defaults to disabled. To enable:

	# sysctl -w machdep.user_ldt=1
2020-07-19 14:31:31 +00:00
kamil
07e8492e26 Add ppoll() a compatibility wrapper around pollts(2)
Submitted by Apurva Nandan.
2020-07-17 15:34:16 +00:00
jruoho
0a95079b4a Do not allow disabling interrupts on the primary CPU. Fixes PR kern/45117. 2020-07-13 13:16:07 +00:00
jruoho
50e485342b Sleep even more. 2020-07-11 09:55:26 +00:00
jruoho
eaede56dac Skip this test as it may cause a panic. Point to PR kern/55481. 2020-07-11 09:35:22 +00:00
christos
a314e6f743 add a test for v4 mapped addresses 2020-07-06 18:45:25 +00:00
christos
8049036801 don't open the socket twice. 2020-07-06 16:24:06 +00:00
jruoho
671da32626 Remove the expected timeout; there is something more sinister behind the
timeouts seen on the Qemu/evbarm-aarch64 runs.
2020-07-06 10:35:00 +00:00
jruoho
28b2e2ce1b Sleep more. 2020-07-06 10:32:18 +00:00
maxv
66af4cddad more 2020-07-03 16:07:52 +00:00
jruoho
7b69662fe9 Skip these also for Qemu runs as they cause panics. Point to PR kern/55451. 2020-07-03 07:03:14 +00:00
jruoho
9cb1df3cd3 Add a check for PR bin/54692. 2020-07-03 04:25:28 +00:00
jruoho
7bd1b83147 Add a check for the overflow noted in PR lib/46542. 2020-07-03 03:59:18 +00:00
jruoho
04c087f823 Verify that PR lib/55041 is no longer an issue. 2020-07-03 03:13:10 +00:00
jruoho
f62e6216a7 Expect a timeout for evbarm-aarch64, as seen in the recent Qemu runs. 2020-07-03 02:51:13 +00:00
jruoho
4704e28c3f Add basic checks for magic symlink(7)'s. These include a case for PR lib/55361,
although it seems that realpath(3) has bigger problems with these symlinks.
2020-07-01 13:49:26 +00:00
riastradh
341c574011 Pass the requisite -msse options for i386. 2020-07-01 09:58:29 +00:00
jruoho
55abcd082f Add basic checks for a64l(3), l64a(3), and l64a_r(3). 2020-07-01 07:16:37 +00:00
jruoho
7fed543511 Add basic tests for the rest of the mktemp(3) family of functions, including
a case for PR lib/55441.
2020-07-01 05:37:25 +00:00
riastradh
bd9707e06e New test sys/crypto/aes/t_aes.
Runs aes_selftest on all kernel AES implementations supported on the
current hardware, not just the preferred one.
2020-06-30 20:32:10 +00:00
jruoho
2ba250a115 After a comedy of errors, move t_mbtowc to its final resting place. 2020-06-30 16:09:40 +00:00
jruoho
8b2d29b6bf Check that DTrace's execsnoop and opensnoop work (cf. PR kern/53417). 2020-06-30 14:30:49 +00:00
jruoho
6d91546d37 Skip a few more nodes, and enable this test for Qemu runs. 2020-06-30 11:49:26 +00:00
jruoho
e643f0ea97 Add a couple of tests for sequential ifconfig(8) options, incl. PR kern/41912. 2020-06-30 11:48:20 +00:00
riastradh
64af5d547a Missed a spot -- one more 32-bit sign-compare issue. 2020-06-30 04:17:31 +00:00
riastradh
6a40410cdc Fix sign-compare issue on 32-bit systems.
Built fine on amd64, where all unsigned values are representable in
ssize_t, but I didn't try building on i386, where they're not.
2020-06-30 04:15:46 +00:00
riastradh
04a6492d1e New cgd cipher adiantum.
Adiantum is a wide-block cipher, built out of AES, XChaCha12,
Poly1305, and NH, defined in

   Paul Crowley and Eric Biggers, `Adiantum: length-preserving
   encryption for entry-level processors', IACR Transactions on
   Symmetric Cryptology 2018(4), pp. 39--61.

Adiantum provides better security than a narrow-block cipher with CBC
or XTS, because every bit of each sector affects every other bit,
whereas with CBC each block of plaintext only affects the following
blocks of ciphertext in the disk sector, and with XTS each block of
plaintext only affects its own block of ciphertext and nothing else.

Adiantum generally provides much better performance than
constant-time AES-CBC or AES-XTS software do without hardware
support, and performance comparable to or better than the
variable-time (i.e., leaky) AES-CBC and AES-XTS software we had
before.  (Note: Adiantum also uses AES as a subroutine, but only once
per disk sector.  It takes only a small fraction of the time spent by
Adiantum, so there's relatively little performance impact to using
constant-time AES software over using variable-time AES software for
it.)

Adiantum naturally scales to essentially arbitrary disk sector sizes;
sizes >=1024-bytes take the most advantage of Adiantum's design for
performance, so 4096-byte sectors would be a natural choice if we
taught cgd to change the disk sector size.  (However, it's a
different cipher for each disk sector size, so it _must_ be a cgd
parameter.)

The paper presents a similar construction HPolyC.  The salient
difference is that HPolyC uses Poly1305 directly, whereas Adiantum
uses Poly1395(NH(...)).  NH is annoying because it requires a
1072-byte key, which means the test vectors are ginormous, and
changing keys is costly; HPolyC avoids these shortcomings by using
Poly1305 directly, but HPolyC is measurably slower, costing about
1.5x what Adiantum costs on 4096-byte sectors.

For the purposes of cgd, we will reuse each key for many messages,
and there will be very few keys in total (one per cgd volume) so --
except for the annoying verbosity of test vectors -- the tradeoff
weighs in the favour of Adiantum, especially if we teach cgd to do
>>512-byte sectors.

For now, everything that Adiantum needs beyond what's already in the
kernel is gathered into a single file, including NH, Poly1305, and
XChaCha12.  We can split those out -- and reuse them, and provide MD
tuned implementations, and so on -- as needed; this is just a first
pass to get Adiantum implemented for experimentation.
2020-06-29 23:44:01 +00:00
maya
f728d212f0 Avoid copyright issues and name the listed author as the copyright holder.
In a private email, Miloslav had agreed that if they had written the
test, then it can be licensed bsd-2-clause. I am going to assume this
is true as the file names Miloslav as the author.

This test was likely sent to tcsh (not netbsd) that had changed bug
report systems since.
2020-06-29 20:53:40 +00:00
jruoho
db34f12f88 Use -Wl,--no-fatal-warnings for the mktemp(3) test. 2020-06-29 14:22:11 +00:00
jruoho
3e2e2a93b9 Ups. Fix shell parameter. 2020-06-27 14:04:17 +00:00
jruoho
7725c11dd6 Add also a test that writes random garbage to every ifconfig(8) option that
takes parameters. Based on quick testing, iwn(4) and wm(4) pass, but
urtwn(4) panics. Use at your own risk; in some cases, it may be possible
that horrors are written directly to the hardware.
2020-06-27 13:53:43 +00:00
jruoho
a4f7315844 Add the default TNF copyright (2005), cf. PR misc/55419. 2020-06-27 10:19:43 +00:00
jruoho
21c7d294a2 Start moving the remaining tests from src/regress to src/tests. 2020-06-27 10:14:10 +00:00
jruoho
f60c53b495 Move the test for mktemp(3) to the right place. 2020-06-27 09:45:57 +00:00
jruoho
313072e773 Add a simple test case that writes random garbage to (almost) every sysctl node.
This test reproduced already at least five unique panics in a few quick runs.
The test is skipped by default as it is not likely safe even without the panics.
2020-06-27 08:50:46 +00:00
jruoho
b61f0fee17 Add a basic test for enabling/disabling network interface capabilities. 2020-06-27 06:57:44 +00:00
jruoho
78bd8e59f5 Add a test case for PR kern/53767. 2020-06-27 05:20:34 +00:00
jruoho
dc018d6b62 Add test cases for different 802.11 options. These include cases for
PR kern/35045, PR kern/45745, and PR kern/55424.
2020-06-27 05:07:07 +00:00
jruoho
6232dbeb26 Use atf_pass to avoid test failure in case there are no suitable interfaces. 2020-06-27 04:15:17 +00:00
jruoho
55908713e4 Reference PRs consistently. 2020-06-26 07:50:11 +00:00
jruoho
f5fa72a2a9 Test creating thousands of bridge(4)'s. Unlike with tap(4) (PR kern/55417),
this test succeeeds. It is even possible to have the ultimate ifconfig(8)
output with more than 65,000 devices.
2020-06-25 18:30:42 +00:00
jruoho
9611465bb1 Verify that PR kern/52150 is no longer present. 2020-06-25 17:08:32 +00:00
jruoho
11d78a2165 Instead of UINT_MAX + 2, test what is claimed. 2020-06-25 16:57:00 +00:00
jruoho
04cb13a856 Actually create the tap(4) with a negative device number. Doh. 2020-06-25 16:52:49 +00:00
jruoho
02dcf11b6e Reference also PR kern/52526. 2020-06-25 16:34:49 +00:00
jruoho
2a70c17495 Add a test case for PR kern/52744, which no longer appears to be present. 2020-06-25 16:16:48 +00:00
jruoho
c6ea14b7ca Fix pastos. 2020-06-25 15:43:26 +00:00
jruoho
0f5766374a Add a test case for kern/52771. 2020-06-25 15:41:40 +00:00
jruoho
77e941ddd2 Add a test case for PR kern/53410. 2020-06-25 15:01:35 +00:00
jruoho
5c3bd061a3 Add test cases for PR kern/53546 and PR kern/55417. Both are skipped as
both reproduce panics.
2020-06-25 14:24:45 +00:00
jruoho
07a6f275d7 Reference also PR kern/53860. 2020-06-25 11:26:05 +00:00
jruoho
bf613d3342 Reference PRs consistently. 2020-06-25 11:12:03 +00:00
jruoho
b23ebd9451 Require root privileges. 2020-06-25 10:34:34 +00:00
martin
daa128b211 Add input files 2020-06-24 15:05:45 +00:00
martin
4c5da4561c Fix directories 2020-06-24 14:48:47 +00:00
thorpej
492187ea09 Fix pasto; use {,U}LLONG{MIN,MAX} correctly in the {u,}llong{min,max}
range checks.

PR lib/55414
2020-06-24 14:28:10 +00:00
jruoho
547814cf8b Also install new tests. 2020-06-24 12:31:26 +00:00
jruoho
08daf067e8 Fix references in comments. 2020-06-24 10:07:13 +00:00
jruoho
55d0ca692c Check that fstat(1) works (cf. PR kern/55407). 2020-06-24 10:05:07 +00:00
jruoho
3f1bde296f Add a few checks for stdethers(8) and stdhosts(8). 2020-06-24 09:47:17 +00:00
jruoho
d60b9b731a Add few basic tests for cpuctl(8). These cover PR kern/45117 and PR bin/54220.
Though, the former is not explicitly tested as it hangs the system.
2020-06-24 09:32:41 +00:00
jruoho
27ee1d2935 Add a test case for bin/54620. 2020-06-24 09:21:43 +00:00
jruoho
6ecb6de692 Add a test case for PR bin/55389. 2020-06-24 09:11:26 +00:00
rin
f01e01eb6a errno is irrelevant here. 2020-06-24 07:02:57 +00:00
rin
bc51181201 Fix random failures for pty_queue test.
Setting queue size by TIOCSQSIZE ioctl does not guarantee that data of
that size can be read by single shot of read(2).

Remove assertion based on this assertion, while total amount of data
read from child process is still checked appropriately.
2020-06-24 06:15:40 +00:00
rin
5e62095eac Turn err() into atf_tc_fail_errno() for parent process, so that
atf can catch failures correctly.
2020-06-24 05:59:18 +00:00
rin
f340ec0453 Fix core_dump_procinfo tests for powerpc, for which child process was
stalled indefinitely in trap instruction even after PT_CONTINUE.

For powerpc, program counter is not automatically incremented by trap
instruction. We cannot increment PC in the trap handler, which breaks
applications depending on this behavior, e.g., GDB.

Therefore, we need to pass (PC + 4) instead of (void *)1 (== PC) to
PT_CONTINUE when child process traps itself.
2020-06-24 04:47:10 +00:00
rin
c3c8ab8893 Work around QEMU bug #1668041 differently, by which floating-point
division by zero is not correctly trapped for i386 and amd64:

https://bugs.launchpad.net/qemu/+bug/1668041

Make trigger_fpe() cause integer division by zero for x86, and
floating-point one for other architectures. Also, assertions for
si_code in *_crash_fpe tests are commented out for now. They
should be cleaned up after the bug is fixed.

Now, *_crash_fpe tests are working also on powerpc.

Suggested by kamil.
2020-06-22 12:21:02 +00:00
rin
27ca840a21 Turn trigger_fpe() back to integer division by zero for a while
until QEMU bug #1668041 is fixed:

https://bugs.launchpad.net/qemu/+bug/1668041

by which floating-point division by zero is not trapped correctly
both on amd64 and i386.

Skip *_crash_fpe tests on powerpc, where integer division by zero
is never trapped.
2020-06-22 02:51:06 +00:00
lukem
a11399dd2d fix build of h_thread_local_dtor.cpp 2020-06-21 07:06:05 +00:00
lukem
a41884d4ca fix build of t_cabsl from t_cabsl.cxx
t_cabsl source is in t_cabsl.cxx not t_cabsl.cc - the latter
is what bsd.tests.mk defaults to.

This only broke after my commit of share/mk/bsd.dep.mk rev 1.85
but I don't know why it didn't cause a problem previously.
2020-06-21 06:58:16 +00:00
rin
669f5e8178 Fix false positive for mvscanw tests on big endian machines.
When conversion specifier is not a derivative form of "%s", retrieve
input as 32bit integer, and then convert to string literal. Then we
can avoid interpretation from ASCII code to integer, which is
apparently byte-order depended.
2020-06-20 07:50:16 +00:00
rin
4562851ebb Skip sigbus_adraln for powerpc.
SIGBUS for unaligned accesses is not mandatory for powerpc;
most processors (not all, e.g., 403) can deal with that.
2020-06-20 07:30:09 +00:00
rin
81e0508055 Fix build for vax; Compile t_ptrace_sigchld.c with -D__TEST_FENV. 2020-06-17 22:07:21 +00:00
rin
f68301ec40 Let trigger_fpe() cause floating-point divide by zero exception, instead of
integer one, which is not trapped for powerpc and aarch64.

Note that it is checked in lib/libc/gen/t_siginfo whether integer divide by
zero is interpreted as SIGFPE or not.

Now, all *_crash_fpe tests pass for powerpc, and nothing changes for amd64
at least.
2020-06-17 08:42:16 +00:00
rin
2d089d6a31 Regardless of __HAVE_FENV, include <fenv.h>, which itself defines __HAVE_FENV. 2020-06-17 08:23:18 +00:00
kamil
aa97815be0 Include explicitly <rump/rump_syscallshotgun.h> for previous indirect users
via <rump/rump.h>.
2020-06-17 00:16:21 +00:00
sevan
5996c744ca Improve sentence 2020-06-16 09:47:11 +00:00
martin
ac717ccabf PR kern/55272: skip this test on uniprocessor machines, it is too dangerous
and can kill the host kernel if a userland watchdog is running
2020-06-16 07:59:07 +00:00
christos
1f33802f79 language sensitivity 2020-06-15 13:57:45 +00:00
roy
b05648aa26 Remove in-kernel handling of Router Advertisements
This is much better handled by a user-land tool.
Proposed on tech-net here:
https://mail-index.netbsd.org/tech-net/2020/04/22/msg007766.html

Note that the ioctl SIOCGIFINFO_IN6 no longer sets flags. That now
needs to be done using the pre-existing SIOCSIFINFO_FLAGS ioctl.

Compat is fully provided where it makes sense, but trying to turn on
RA handling will obviously throw an error as it no longer exists.

Note that if you use IPv6 temporary addresses, this now needs to be
turned on in dhcpcd.conf(5) rather than in sysctl.conf(5).
2020-06-12 11:04:44 +00:00
martin
b7244a59d8 Do not destroy mutices that failed to init - fixes a run with
PTHREAD_DIAGASSERT set to "a". Pointed out by joerg.
2020-06-11 11:40:54 +00:00
ad
a1d54d8ee2 Adjust cond_timedwait_race to take account of spurious wakeups (which are
completely legit).
2020-06-10 21:46:50 +00:00
kamil
db4bf4da47 Add fork/vfork/posix_spawn tests for processes within pgrp
New tests:
 - fork_setpgid
 - vfork_setpgid
 - posix_spawn_setpgid
 - unrelated_tracer_fork_setpgid
 - unrelated_tracer_vfork_setpgid
 - unrelated_tracer_posix_spawn_setpgid

These tests trigger a kernel assert for pg_jobc going negative.

The tests are temporarily skipped.
2020-06-09 00:28:57 +00:00
thorpej
9a0cd196e4 Ensure copy_data_create_copy() is tolerant of creating empty data objects. 2020-06-08 21:31:17 +00:00
rillig
c32d14bd2e usr.bin/make: fix test failure
The two files include-sub.mk and include-subsub.mk were never intended to
be test cases on their own.  They belong to include-main.mk.

Fixes PR bin/55360.
2020-06-08 19:50:10 +00:00
fox
bf982b61a2 tests/lib/libarchive: Suppress -Werror=stringop-truncation error
This logic correctly uses strncpy(3) to fully initialize a fixed-width field, and also ensures
NUL-termination on the next line as other users of the field expect.

Add -Werror=stringop-truncation to prevent build failure, when run with MKSANITIZER=yes.

Error was reported when build.sh was run with MKSANITIZER=yes flag.

Reviewed by: kamil@
2020-06-07 23:20:52 +00:00
thorpej
9bc38ca6a6 Don't use deprecated proplib APIs (in the old "basic" test case). 2020-06-06 21:45:07 +00:00
thorpej
a792b8435e Improvements to the problib(3) API:
==> Provide a much more complete set of setters and getters for different
    value types in the prop_array_util(3) and prop_dictionary_util(3)
    functions.

==> Overhaul the prop_data(3), prop_number(3), and prop_string(3) APIs
    to be easier to use and less awkwardly named,  Deprecate the old
    awkward names, and produce link-time warnings when they are referenced.

==> Deprecate mutable prop_data(3) and prop_string(3) objects.  The old
    APIs that support them still exist, but will now produce link-time
    warnings when used.

==> When the new prop_string(3) API is used, strings are internally
    de-duplicated as a memory footprint optimization.

==> Provide a rich set of bounds-checked gettter functions in and a
    corresponding set of convenience setters in the prop_number(3) API.

==> Add a new prop_bool_value(3) function that is equivalent to
    prop_bool_true(3), but aligned with the new "value" routines in
    prop_data(3), prop_string(3), and prop_number(3).
2020-06-06 21:25:59 +00:00
thorpej
9dd0cf5370 Add a test case to ensure that _lwp_create() fails with the
expected error code when a bad new-lwp-id pointer is passed.
2020-06-06 18:11:21 +00:00
knakahara
f26b5d9d11 Refactor a little and follow new format of "npfctl list".
Fix the below ATF failures.
    - net/if_ipsec/t_ipsec_natt:ipsecif_natt_transport_null
    - net/if_ipsec/t_ipsec_natt:ipsecif_natt_transport_rijndaelcbc
    - net/ipsec/t_ipsec_natt:ipsec_natt_transport_ipv4_null
    - net/ipsec/t_ipsec_natt:ipsec_natt_transport_ipv4_rijndaelcbc

ok'ed by ozaki-r@n.o, thanks.
2020-06-05 03:24:58 +00:00
martin
305e2e0fef Skip this test on machines where it would cause serious swapping. 2020-06-03 18:07:26 +00:00
christos
e81cd2ea14 LIBISPRIVATE=yes 2020-06-01 14:42:03 +00:00
christos
2e98ca8c7c Set LIBISPRIVATE=yes 2020-06-01 14:41:25 +00:00
martin
112112a823 Adjust to "npfctl debug" command line changes, from rmind@. 2020-06-01 11:08:57 +00:00
martin
c9e294b294 Typo in error message 2020-06-01 04:38:37 +00:00
kamil
f222e3cc8d Avoid redefining _REENTRANT under sanitizers
Switch away from -Wno-macro-redefined which was Clang specific.
2020-06-01 01:03:21 +00:00
kamil
47ead56b15 Mask NULL + 0 LLVM UBSan reports in the ATF test: t_pslist.c
Pass -fno-delete-null-pointer-checks for Clang for the
MKSANITIZER/MKLIBCSANITIZER build
2020-05-31 16:36:07 +00:00
christos
d37743e0ff Fix alpha build (relocation truncated to fit: GPREL16 against symbol ...)
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47230
2020-05-26 18:52:29 +00:00
ad
0eaaa024ea Move proc_lock into the data segment. It was dynamically allocated because
at the time we had mutex_obj_alloc() but not __cacheline_aligned.
2020-05-23 23:42:41 +00:00
christos
627b2779c6 Fix sun2 build. Still there are some duplicate symbols in the rump libraries
that make this awkward.
2020-05-17 18:52:43 +00:00
christos
ab0d77c491 put librumpvfs_nofifofs after librumpvfs for the benefit of sun2 2020-05-17 18:25:11 +00:00
kamil
2affbc81a5 Ignore interception of SIGCHLD signals in the debugger
Set SIGPASS for SIGCHLD for the traced child in the following tests:
 - unrelated_tracer_fork*
 - unrelated_tracer_vfork*
 - unrelated_tracer_posix_spawn*

There is a race that SIGCHLD might be blocked during forking and dropped.

PR/55241 by Andreas Gustafsson
2020-05-16 23:10:26 +00:00
kamil
3fadaf7f87 Fix typo in test names
Noted by <joerg>
2020-05-16 22:07:06 +00:00
kamil
985ba7a358 Ignore interception of SIGCHLD signals in the debugger
Set SIGPASS for SIGCHLD for the traced child in the following tests:

 - posix_spawn_singalmasked
 - posix_spawn_singalignored
 - fork_singalmasked
 - fork_singalignored
 - vfork_singalmasked
 - vfork_singalignored
 - vforkdone_singalmasked
 - vforkdone_singalignored

There is a race that SIGCHLD might be blocked during forking and dropped.

PR/55241 by Andreas Gustafsson
2020-05-16 19:08:20 +00:00
christos
fe491c4f65 Do the same thing with linker flags instead of directly specifying the archives. 2020-05-16 12:54:27 +00:00
christos
9df67dbe77 more nofifofs 2020-05-16 12:44:42 +00:00
christos
6d46df7548 PR/55102: Kamil Rytarowski: Duplicate fifo_vnodeop_entries,
fifo_vnodeop_opv_desc symbols.

Many filesystems ffs, lfs, ulfs, chfs, ext2fs etc. use fifofs
internally for their fifo vnops. NFS does too, but it also needs
networking anyway.  Unfortunately fifofs brings in a lot of the
networking code so that the rumpkernel is not well partition. In
addition the fifo code is rarely used.

The existing hack depended on duplicating the above symbols and
adding minimal functionality for the majority of the the tests
(except the ffs and the puffs one). In these two cases both symbols
were loaded and the symbol sizes clashed which broke the sanitizers.
While this can be fixed with weak symbols and other kinds of
indirection, it is more straight forward to select between the
minimal and the full fifofs implementation by introducing a new
shared library librumpvfs_nofifofs.
2020-05-15 23:32:27 +00:00
kamil
1cb4f56df8 Ignore interception of the SIGCHLD signals.
SIGCHLD once blocked is discarded by the kernel as it has the
SA_IGNORE property. During the fork(2) operation all signals can be
shortly blocked and missed (unless there is a registered signal
handler in the traced child). This leads to a race in this test if
there would be an intention to catch SIGCHLD.

Fixes PR lib/55241 by Andreas Gustafsson
2020-05-14 19:21:35 +00:00
msaitoh
8012ca3f0e Remove extra semicolon. 2020-05-14 08:34:17 +00:00
yhardy
dd377fc593 Fix the build for MKCOMPAT=no.
The t_user_ldt test needs the i386 compat library which is only built
when MKCOMPAT=yes.
2020-05-11 21:51:25 +00:00
kamil
907d0e8035 Fix potential race in ptrace(2) clone(2) tests
Instead of comparing old and new signal mask, just after the cloning
operation, check whether the expected signal is still masked and in
another test whether it is still ignored.

Catch up after t_ptrace_fork_wait.h r. 1.2.
2020-05-11 21:18:11 +00:00
kamil
9400a778fb Fix race in fork_singalmasked
ELF RTLD after rtld.c r. 1.204 introduced locking that wraps the fork
syscall. This locking changes signal mask of the calling process during
the forking process.

Instead of comparing old and new signal mask, just after the forking
operation, check whether the expected signal is still masked and in
another test whether it is still ignored.
2020-05-11 20:58:48 +00:00
kamil
2b6df1dd1e Simplify previous
Emit SIGKILL without a loop and without checking for exact process status
once it is collected.
2020-05-11 12:17:57 +00:00
kamil
d9604583e2 Do not fail when trying to kill a dying process
A dying process can disappear for a while. Rather than aborting, retry
sending SIGKILL to it.
2020-05-11 11:03:15 +00:00
maxv
d6eec10312 A kernel without USER_LDT returns ENOSYS, not ENOTSUP. 2020-05-09 09:08:41 +00:00
thorpej
d1852f1c12 Fix a bug in the futex_wake_highest_pri test case. Still fails as
expected.
2020-05-06 05:14:27 +00:00
skrll
bda3cfd2fc Disable attempt to use ifunc on hppa. It doesn't work and new binutils
throws a build error.
2020-05-05 20:47:14 +00:00
kamil
43b8951996 Skip traceme_raise* tests rather than failing upfront
This avoid reporting the tests as unexpected failure.
2020-05-05 18:12:20 +00:00
kamil
6b097ed22f Move misc tests out of t_ptrace_wait.c to t_ptrace_misc_wait.h
The same tests are now included with the preprocessor in t_ptrace_wait.c.

No functional change intended.
2020-05-05 02:06:08 +00:00
kamil
ac9ae533a1 Move core tests out of t_ptrace_wait.c to t_ptrace_core_wait.h
The same tests are now included with the preprocessor in t_ptrace_wait.c.

No functional change intended.
2020-05-05 01:24:29 +00:00
kamil
6ca9c4c6fc Move siginfo tests out of t_ptrace_wait.c to t_ptrace_siginfo_wait.h
The same tests are now included with the preprocessor in t_ptrace_wait.c.

No functional change intended.
2020-05-05 00:57:34 +00:00
kamil
373d242e6e Move threads tests out of t_ptrace_wait.c to t_ptrace_threads_wait.h
The same tests are now included with the preprocessor in t_ptrace_wait.c.

No functional change intended.
2020-05-05 00:50:39 +00:00
kamil
29ff229651 Move topology tests out of t_ptrace_wait.c to t_ptrace_topology_wait.h
The same tests are now included with the preprocessor in t_ptrace_wait.c.

No functional change intended.
2020-05-05 00:33:37 +00:00
kamil
6afb1960b8 Move exec() tests out of t_ptrace_wait.c to t_ptrace_exec_wait.h
The same tests are now included with the preprocessor in t_ptrace_wait.c.

No functional change intended.
2020-05-05 00:23:12 +00:00
kamil
fadd423b64 Move LWP tests out of t_ptrace_wait.c to t_ptrace_lwp_wait.h
The same tests are now included with the preprocessor in t_ptrace_wait.c.

No functional change intended.
2020-05-05 00:15:45 +00:00
kamil
f74903642d Remove the duplicate ATF_TP_ADD_TC() entries
Event mask tests are already defined in
ATF_TP_ADD_TCS_PTRACE_WAIT_EVENTMASK().
2020-05-05 00:03:49 +00:00
kamil
bb8e4b817e Move eventmask tests out of t_ptrace_wait.c to t_ptrace_eventmask_wait.h
The same tests are now included with the preprocessor in t_ptrace_wait.c.

No functional change intended.
2020-05-05 00:01:14 +00:00
kamil
8f6a1c9ed3 Remove the duplicate ATF_TP_ADD_TC() entries
Byte transfer tests are already defined in
ATF_TP_ADD_TCS_PTRACE_WAIT_BYTETRANSFER().
2020-05-04 23:53:20 +00:00
kamil
a0f774c8c6 Move signal tests out of t_ptrace_wait.c to t_ptrace_signal_wait.h
The same tests are now included with the preprocessor in t_ptrace_wait.c.

No functional change intended.
2020-05-04 23:49:31 +00:00
kamil
70aa5111f3 Move fork/vfork/posix_spawn tests out of t_ptrace_wait.c to t_ptrace_fork_wait.h
The same tests are now included with the preprocessor in t_ptrace_wait.c.

No functional change intended.
2020-05-04 22:34:22 +00:00
kamil
aab911e8f8 Bump (c) year 2020-05-04 22:24:31 +00:00
kamil
7c347f59c8 Move clone() tests out of t_ptrace_wait.c to t_ptrace_clone_wait.h
The same tests are now included with the preprocessor in t_ptrace_wait.c.

No functional change intended.
2020-05-04 22:15:23 +00:00
kamil
cacb90637f Move byte transfer tests out of t_ptrace_wait.c to t_ptrace_bytetransfer_wait.h
The same tests are now included with the preprocessor in t_ptrace_wait.c.

No functional change intended.
2020-05-04 22:05:28 +00:00
kamil
fffa14ce79 Move kill()-like tests out of t_ptrace_wait.c to t_ptrace_kill_wait.h
The same tests are now included with the preprocessor in t_ptrace_wait.c.

No functional change intended.
2020-05-04 21:55:12 +00:00
kamil
b1a00b5909 Move PT_STEP tests out of t_ptrace_wait.c to t_ptrace_step_wait.h
The same tests are now included with the preprocessor in t_ptrace_wait.c.

No functional change intended.
2020-05-04 21:33:20 +00:00
kamil
7ecec66137 Move syscall tests out of t_ptrace_wait.c to t_ptrace_syscall_wait.h
The same tests are now included with the preprocessor in t_ptrace_wait.c.

No functional change intended.
2020-05-04 21:21:30 +00:00
kamil
bc8c7c1627 Move register tests out of t_ptrace_wait.c to t_ptrace_register_wait.h
The same tests are now included with the preprocessor in t_ptrace_wait.c.

No functional change intended.
2020-05-04 20:55:48 +00:00
thorpej
862dc4c75a Add a test case for PR kern/55230. It is currently marked as expect-fail. 2020-05-04 15:09:34 +00:00
christos
ca7e4587fd KMODULEDIR is no longer absolute (${DESTDIR} is added to it by the system
makefile because we need to install the module in two places the debug part
and the regular part)
2020-05-01 22:24:18 +00:00
christos
1f20091d65 no need for alloca() (breaks SSP) 2020-05-01 21:35:30 +00:00
isaki
e1f09352b2 Fix two tests.
- kqueue_mode_{RDONLY,RDWR}_READ: Fix expected value.
  This is rest of rev1.9.
- AUDIO_SETINFO_params_simul: Fix condition.
  This happens on full-duplex, not bi-directional.
These affect only standalone test, not atf.
2020-05-01 05:45:57 +00:00
thorpej
6809e70297 Oops, accidentally #if 0'd some tests, probably while debugging
something else.  Correct this silly mistake.
2020-05-01 01:44:30 +00:00
ryo
1da5a7c800 Add a test for sigaltstack(2) and SA_ONSTACK 2020-04-30 11:03:29 +00:00
thorpej
1a07681a27 - In uvm_voaddr_acquire(), take an extra hold on the anon lock obj.
- In uvm_voaddr_release(), if the anon ref count drops to 0, call
  uvm_anfree() rather than uvm_anon_release().  Unconditionally drop
  the anon lock, and release the extra hold on the anon lock obj.

Fixes a panic that occurs if the backing store for a futex backed by
an anon memory location is unmapped while a thread is waiting in the
futex.

Add a test case that reproduced the panic to verify that it's fixed.
2020-04-30 04:18:07 +00:00
riastradh
f3c622e1ff Make FUTEX_WAIT_BITSET(bitset=0) fail with EINVAL to match Linux. 2020-04-28 17:27:03 +00:00
thorpej
276ef22378 Add a NetBSD native futex implementation, mostly written by riastradh@.
Map the COMPAT_LINUX futex calls to the native ones.
2020-04-26 18:53:31 +00:00
maxv
8d6f67019a Add a test on the maximum number of slots. 2020-04-26 12:13:10 +00:00
maxv
4cc4c6ebbe Split in sub-tests for clarity, and add a new test, marked as expected
failure for now.
2020-04-26 11:56:38 +00:00
maxv
e497fc86e6 Add tests on the x86 PTEs. We scan the MMU page tables directly and verify
certain properties.
2020-04-26 09:08:40 +00:00
kre
0bcbd6c97f ATF runs shell script tests with "sh -e" (WHY???)
Compensate for that by adding an explicit test to a command so
-e will not kill the shell when the command (expectedly) fails.

Previously this was saved by /bin/sh disabling -e in command subs.
2020-04-24 14:29:19 +00:00
kamil
bac29421d5 Reduce assumptions about LWP numbers 2020-04-24 12:17:45 +00:00
thorpej
6fd6e9aadc Update for new LWP behavior -- as of 9.99.59, the LWP ID of a single-LWP
process is the PID, not 1.
2020-04-24 03:25:20 +00:00
joerg
422dd9f190 Replace noatf global with conditional compilation 2020-04-23 00:31:51 +00:00
joerg
f75c59c79e saved_output is owned by director.c 2020-04-23 00:30:08 +00:00
thorpej
d5cd44f45c Remove unit tests for the never-exposed _lwp_gettid(2). 2020-04-22 21:28:02 +00:00
joerg
4a60ab4bb4 Provide SHLIBINSTALLDIR explicitly as it defauls to /lib otherwise and
makes ld complain about the 64bit libc.
2020-04-20 12:08:08 +00:00
kre
d36f2da068 Define TESTSDIR even when not amd64 so the Atffile will be
installed in the correct location.
2020-04-19 18:07:00 +00:00