Commit Graph

4832 Commits

Author SHA1 Message Date
rillig
f48ee0a965 tests/libcurses: use ASCII only in terminfo description 2021-02-13 16:43:12 +00:00
rillig
c12d26a726 tests/libcurses: split terminfo entry over more lines
This provides space to see each capability on its own, instead of having
to search them in the blob of text.
2021-02-13 16:38:02 +00:00
rillig
609d11bc47 libcurses: fix wrong tab width for addch
In sysinst, the installation screen is indented with tabs.  Sysinst uses
msgc, which brings its own text layout engine.  This engine does not use
addbytes but addch.  In addch, the x position for each tab was advanced
twice as much as needed.  The menu items were thus not indented by 8
spaces but by 16, which caused an ugly line break in the German
translation.

This bug largely went unnoticed because most other applications use
addbytes instead, which worked fine all the time.  It had been
introduced somewhere between NetBSD 8.0 and NetBSD 9.0.

The code around this bug used aliased variables for win->curx and
win->cury a lot.  Getting this right is difficult and needs a thorough
test suite.  Even though libcurses has 201 tests, that is not nearly
enough to cover all the relations between the various functions in
libcurses that call each other, crossing API boundaries from internal
to external, doing character conversions on the way and juggling around
4 different types of characters (char, wchar_t, chtype, cchar_t).

The simplest fix was to remove all this aliasing, while keeping the
API the same.  If _cursesi_waddbytes is not considered part of the API,
it would be possible to replace px with win->curx in all places, same
for py and win->cury.

The complicated code with the aliasing may have been meant for
performance reasons, but it's hard to see any advantage if both points
of truth need to be synchronized all the time.

Libcurses can be built in 2 modes: with wide character support or
without (-DDISABLE_WCHAR).  The test suite only covers the variant with
wide characters.  The single-byte variant has to be tested manually.
Running sysinst with the single-byte libcurses produces the correct
layout.
2021-02-13 14:30:37 +00:00
rillig
86536876fb tests/libcurses: extract read_command_argument from process_commands
Having code indented so far to the right that each word gets its own
line is ridiculous.  Fix that.

While here, remove the cargo-cult realloc pattern, which is not needed
if the process exits immediately on error.

While here, reduce the indentation of the code by returning early.

No functional change.
2021-02-13 10:03:49 +00:00
rillig
78dd027b59 tests/libcurses: fix reading from the parent process
In case of a short read, processing the incomplete data invoked
undefined behavior.
2021-02-13 09:28:27 +00:00
rillig
2eec569208 tests/libcurses: fix child process handling
The child process needs to be properly controlled by the parent process.
Otherwise it is not possible to get code coverage data from it using
gcov since that requires the child process to exit normally.  Previously
the child process had been killed because its parent had exited.
2021-02-13 09:18:12 +00:00
rillig
2d435e1f5f tests/libcurses: fix error messages 2021-02-13 08:43:03 +00:00
rillig
c671531bee tests/libcurses: "fix" test mvwin
The test mvwin previously expected an endless stream of bytes, by
comparing the actual output with /dev/zero.  This didn't make sense as
the curses output does not contain '\0' in any of the test cases.

Compare with /dev/null instead.  This is as wrong as before, but the
curses test framework currently ignores this situation, as for many
other test cases.  See the numerous "Excess" messages in atf-run.log.
2021-02-13 08:37:21 +00:00
rillig
08813b709b tests/libcurses: remove undocumented, unused command line option
The option -T has the same effect as the removed option -p.
2021-02-13 08:26:12 +00:00
rillig
dcdcb866a3 tests/libcurses: remove include path from usage message
The option has been removed a few minutes ago.
2021-02-13 08:22:34 +00:00
rillig
177fdb97a1 tests/libcurses: clean up remaining include guard, comments
No functional change.
2021-02-13 08:17:15 +00:00
rillig
cf012ad48f tests/libcurses: clean up inclusion guards, function declarations
No functional change.
2021-02-13 08:14:46 +00:00
rillig
dfef510f35 tests/libcurses: remove include path handling
All include commands in the current test suite use relative paths.
Instead of a fixed include path, interpret the included filename
relative to the including file.
2021-02-13 08:00:07 +00:00
rillig
8e1e8b7233 tests/libcurses: align comments 2021-02-13 07:32:19 +00:00
rillig
c8713e3dc5 tests/libcurses: fix misleading usage documentation
The check-files are not config files.
2021-02-13 07:31:07 +00:00
rillig
1b4c237756 tests/libcurses: fix pipe handling in the parent process
The parent process, like the child process, needs only 2 of the 4 pipe
ends.

In verbose mode (now at testlang_parse.y:1151 and :1154), both ends of the
pipe_from_slave were examined.  This looked like a typo and has been fixed
to those pipe ends that are relevant to the parent process.
2021-02-13 07:08:45 +00:00
rillig
26ce28a5a0 tests/libcurses: fix pipe handling in child process
The child process only ever needs 2 ends of the pipes: one for reading
the commands, one for writing back the results.
2021-02-13 06:45:42 +00:00
rillig
ff6217c297 tests/libcurses: add test for addbytes 2021-02-13 06:29:45 +00:00
rillig
2f4dbca7fd tests/libcurses: fix warnings for missing environment variables 2021-02-13 05:38:16 +00:00
rillig
ef1df6f9cf tests/libcurses: format misleading do-while loop 2021-02-12 21:29:54 +00:00
rillig
18799db59b tests/libcurses: remove wrong comments 2021-02-12 21:29:03 +00:00
rillig
ca234efa6a tests/libcurses: remove excess empty lines 2021-02-12 20:45:00 +00:00
rillig
450da2d661 tests/libcurses: query function arguments in consistent order 2021-02-12 20:41:37 +00:00
rillig
25ddeb49df tests/libcurses: don't access args directly
By providing declarative syntax for accessing the arguments, the
unnecessarily detailed boilerplate code is hidden.  This allows easy
inspection by tools and humans, to check for typos and other mistakes.
2021-02-12 18:20:05 +00:00
rillig
5326ff7afe tests/libcurses: replace ARG_CHTYPE_STRING with ARG_CHTYPE
All uses of the previous macro did not treat the argument as a string or
array of chtype, but as a single chtype.  It's strange that the previous
code arbitrarily split the access to the argument by first storing it as
a pointer and then dereferencing it.

No functional change.
2021-02-12 16:59:32 +00:00
rillig
a346ecb379 tests/libcurses: add shortcut macros for SCREEN and unsigned int 2021-02-12 16:49:18 +00:00
rillig
c7ac460c19 tests/libcurses: remove redundant comments
There is nothing surprising about call2, call3 or call4.
2021-02-12 14:05:57 +00:00
rillig
1fe7fa71d8 tests/libcurses: reduce boilerplate in function dispatcher
No functional change.  The generated code for GCC 9.3 on NetBSD 9.99.80
x86_64 is exactly the same as before.
2021-02-12 12:58:52 +00:00
rillig
b1b4392b00 tests/libcurses: reduce boilerplate in function dispatcher
This makes the code more declarative and easier to reason about.

The generated code stays exactly the same.
2021-02-12 08:55:32 +00:00
rillig
518cbcb21b tests/libcurses: add missing space after control flow keywords 2021-02-09 20:42:31 +00:00
rillig
6938509815 tests/libcurses: replace remaining strcasecmp with strcmp
There is no reason to write special functions in a different case than
the canonical one, just like for the regular curses functions.
2021-02-09 20:39:20 +00:00
rillig
e91849a6b1 tests/libcurses: fix spelling of the special call to DRAIN 2021-02-09 20:31:02 +00:00
rillig
82a08c1a4a tests/libcurses: compare function names case-sensitive
There is absolutely no reason to write function names in upper case or
mixed case.
2021-02-09 20:24:02 +00:00
rillig
74a9e3d2cc tests/libcurses: fix scanf parameter for unsigned int 2021-02-09 20:22:11 +00:00
rillig
03f821dbf2 tests/libcurses: fix off-by-one error in line numbers in diagnostics
I had broken this in testlang_parse.y 1.22 from 2021-02-07, when I
extracted the common 'eol' from the statements.  Extracting 'eol' had
the effect that the action for the statement was run before the line
number increased.

Now the line numbers in the diagnostics are the same again as before.

For lines that end with a backslash, the reported line number is the one
from the last of these lines, not the first one, also as before.  This
feature is not used by any of the current tests though.
2021-02-08 23:54:03 +00:00
joerg
cfe420e9b1 Don't define a label twice. 2021-02-08 23:50:25 +00:00
rillig
facc9c9e92 tests/libcurses: use consistent indentation for grammar rules 2021-02-08 20:55:42 +00:00
rillig
91cc09774d tests/libcurses: extract functions 'input' and 'noinput' from grammar 2021-02-08 20:39:33 +00:00
rillig
9e7915b0b6 tests/libcurses: indent grammar functions consistently 2021-02-08 20:26:46 +00:00
rillig
66374bbd09 tests/libcurses: declare %type in grammar
It looks as if the original author just didn't know how to declare the
type of non-terminals.  The explicit types in the '$' expressions were
all consistent.

No functional change.
2021-02-08 20:09:45 +00:00
rillig
9dc059c978 tests/libcurses: extract function 'delay_millis' from the grammar 2021-02-08 19:35:21 +00:00
rillig
b798190935 tests/libcurses: move function 'check' out of the grammar section
This removes the inconsistent indentation.
2021-02-08 19:28:08 +00:00
rillig
09f966d145 tests/libcurses: fix typo in license text 2021-02-08 19:15:20 +00:00
rillig
057f5777ce tests/libcurses: remove unused token DRAIN
There is a special function named 'DRAIN', but not a statement.  The
function name does not need its own token.
2021-02-08 19:09:59 +00:00
rillig
12fb37738f tests/libcurses: fix sentinel for execl
For systems where NULL is defined as a simple 0 or 0L.
2021-02-08 19:04:37 +00:00
rillig
dc127031c2 tests/libcurses: on errors, print nonprintable characters as well 2021-02-08 19:00:22 +00:00
rillig
7879077738 tests/libcurses: fix undefined behavior in test addch
The libcurses framework is not strictly typed and thus provides plenty
of ways to shoot yourself in the foot.  It's a waste of time debugging
things that a proper programming language can easily prevent.

The function addch expects an argument of type 'chtype'.  Passing a
"double-quoted" string does not match this, as 'chtype' is completely
different from a plain 'char'.  Instead, functions taking a 'chtype'
must be passed a `backtick-quoted` string.
2021-02-07 23:30:33 +00:00
rillig
1f48f93d43 tests/libcurses: use a single message style for diagnostics
Previously, there were several concurring styles:

	$msg in line %zu of file %s
	$msg line %zu of file %s
	%s, %zu: $msg

All these are now replaced with "%s:%zu: $msg".
2021-02-07 21:33:27 +00:00
rillig
9b3211a8fb tests/libcurses: make grammar for test cases conflict-free
No functional change.
2021-02-07 20:48:07 +00:00
rillig
9903d631af tests/libcurses: fix grammar for arrays
Previously, commas were completely ignored by the grammar.  Erroring out
on invalid characters made some of the tests fail since the comma was
not recognized anymore.  Add it back, but only for defining arrays.  It
would have been possible to leave out the commas or make them optional,
but since the current tests do not make use of that, keep the grammar as
strict as possible.

Fix an unclosed string literal in a test.  This had been wrongly
accepted before by the grammar.
2021-02-07 20:40:05 +00:00
rillig
925203b1c3 tests/libcurses: do not allow control characters in paths 2021-02-07 20:32:25 +00:00
rillig
c2ad8acebe tests/libcurses: error out on trying to parse /dev/zero
Be strict when parsing the tests.  Any unknown character is an error.
This avoids an endless loop when running "./director /dev/zero".  There
is no point in silently ignoring other invalid characters as well, as
this would only leave potential test writers in an unclear state,
without any benefit.
2021-02-07 20:27:40 +00:00
rillig
b30645eb36 tests/libcurses: fix documentation of call[234]
The function getyx is not a function but a macro.  It does not return
int, but void.  Since these changes destroy the simplicity of the
example, combining a regular return value and pass-by-reference return
values, I rewrote the whole section and added more examples.
2021-02-07 20:20:06 +00:00
rillig
ccd1df52a9 tests/libcurses: require keywords to be lowercase, except for OK and ERR
There is no need to write the keywords in upper case or mixed case.  The
only case where a keyword did not have the canonical form yet was a
single lowercase 'ok' in the test case 'innstr'.
2021-02-07 19:49:32 +00:00
rillig
183d5aec4d tests/libcurses: add missing semicolon in grammar 2021-02-07 19:44:34 +00:00
rillig
6989eb7749 tests/libcurses: fix typo in comment 2021-02-07 19:28:07 +00:00
rillig
1134970fd4 tests/libcurses: fix expected test output
The test framework doesn't check the files strictly, it only checks
whether the expected output is a prefix of the actual output, or vice
versa.  This allows several deviations to pass unnoticed, which is
wrong.
2021-02-07 18:56:37 +00:00
rillig
cfcf82e703 tests/libcurses: add const to some function parameters 2021-02-07 18:32:20 +00:00
rillig
58e6134faa tests/libcurses: simplify code for writing to the .exp file
If a write(2) returns less than 1, it must be an error.
2021-02-07 18:14:43 +00:00
rillig
bdb9e6b7f3 tests/libcurses: actually compare the stream to an absolute path
Up to now, the test command "compare /dev/null" was a no-op since the
command was only parsed but not run at all.  Now run it.

This makes the test mvwin fail.  That test will have to be fixed.

Comparing to /dev/null is certainly possible and may make sense,
comparing to /dev/zero is nonsense since the actual stream can never be
endless.  Some tests do that nevertheless, for whatever reason.

In order to have the expected test output closer to the curses commands
that cause it, it may be a good idea to add another command
'compare_str' that would work independently of an external file and at
the same time allow the expected output to be commented and explained.
This is not possible right now since the .chk files are read exactly
as-is.
2021-02-07 17:50:16 +00:00
rillig
1398f05953 tests/libcurses: use more common abbreviations for tokens 2021-02-07 17:32:55 +00:00
rillig
d3b5ee28db tests/libcurses: use standard indentation for grammar rule 'arg' 2021-02-07 17:26:15 +00:00
rillig
126b3d158a tests/libcurses: extract grammar rule 'arg' 2021-02-07 17:23:29 +00:00
rillig
aaac17ccef tests/libcurses: error out if called with too many arguments
This helps against users who try to add more options after the first
non-option argument and wonder why these options are silently ignored.
2021-02-07 13:56:23 +00:00
rillig
c1b0da3370 tests/libcurses: document another bug in the test director 2021-02-07 13:44:22 +00:00
rillig
fb153a60d3 tests/libcurses: fix usage of director 2021-02-07 13:22:23 +00:00
rillig
2eb448fe3b tests/libcurses: demonstrate more bugs in addch 2021-02-07 13:06:02 +00:00
rillig
4e30fe2ad3 tests/libcurses: fail on syntax errors in test files
Previously, a syntax error in a test file made the test pass, which was
outright dangerous.
2021-02-07 12:56:53 +00:00
rillig
d51c9371c9 tests/libcurses: use a single indentation style in the test grammar
The grammar rule 'args' has been left as-is since it needs to be split
into 'args' and 'arg' first, to avoid the redundancy.

The braces in "if (create_check_file)" were misleading.  It's strange that
GCC didn't reject this.
2021-02-07 12:48:34 +00:00
rillig
8de39c39e7 tests/libcurses: clean up test case grammar for statements
Previously, each statement ended with 'eol'.  This was unnecessarily
verbose since the 'eol' is not really part of the statement, it's part
of a line.

No functional change.
2021-02-07 12:24:18 +00:00
rillig
df2132f7f3 tests/libcurses: fix name of grammar rule
A list of assignments is not a statement, it's several statements.

No functional change.
2021-02-07 12:16:26 +00:00
rillig
a13a3f7e27 tests/libcurses: unary minus doesn't make sense on bool expressions
No functional change since -1 is as non-zero as 1.
2021-02-07 12:08:42 +00:00
rillig
4cf90fec0d tests/libcurses: allow end-of-line comments in data lines as well
This makes it possible to write small remarks directly in the affected
line, which not only makes for a clean visual appearance but also shows
up prominently in "cvs annotate" or "git blame", showing when such a
remark has been modified.
2021-02-07 12:05:36 +00:00
rillig
77df4d33b5 tests/libcurses: indent lexer code consistently
Several of the braces were misaligned.  For the simple keywords, there
is no need to write these braces at all, they only made the code look
more complicated than it really is.

I stumbled upon this because syntax errors in the test cases currently
let the test case succeed instead of fail, which is another ingredient
for unreliable tests, besides the loose output matching.
2021-02-07 11:52:43 +00:00
rillig
25d40489d1 libcurses: demonstrate bug in addch that doubles tab indentation
When adding "\t" via addch, win.curx advances by twice the spaces as
intended.  This bug was introduced somewhere between NetBSD 8.0 and 9.0.

Adding "\t" via addstr does not have this bug.

This bug causes the installation menu of sysinst to be have its menu
items indented by 16 characters instead of only 8.  This in turn
produces an ugly line break in the German translation.

The test framework for libcurses is not well integrated into ATF.
Whenever the expected output is longer than the actual output, or vice
versa, the test passes nevertheless.  This makes it necessary to
constantly look into atf-run.log to see whether the actual output is
indeed equal to the expected output, which is crucial, especially for
telling the difference between addstr and addnstr.

Reusing the .chk files for several tests is not a good idea either.  For
example, addstr and waddstr are supposed to produce the same result for
ASCII-only text, so it was tempting to use the same file.  But waddstr
seems to have a bug (maybe undefined behavior), at least waddstr returns
ERR in one case where it shouldn't.  This means that currently the
expected output (acknowledging the bug) must be different.

The "expected" test output in waddstr.chk looks completely broken, but
that's exactly what the test produces right now.
2021-02-07 01:53:54 +00:00
rillig
74e4499250 libcurses: fix typos in introduction to the curses test framework 2021-02-06 20:09:43 +00:00
martin
a9fe9302e9 Run all make tests as unprileged user - makes checking permission issues
a lot easier.
2021-02-06 19:00:25 +00:00
rillig
b9684d0f53 lint: update message text for 259 in test
That's the one place that is not checked for matching the actual message
by my usual pre-commit checks.
2021-02-04 07:39:39 +00:00
rillig
deb631d74d lint: add back "due to prototype" to message 259
That message is only supposed to warn about compatibility to traditional
C, in case the function should ever be compiled without its prototype
being in effect.  All other type checks are supposed to be in another
function, as documented, but that type check misses to report a few
error-prone type combinations (long to char, long to int).

30 years after the introduction of prototypes with C90, almost all
existing code uses prototypes.  The warning has thus lost most of its
usefulness and can rather be confusing since a conversion from 'char' to
'long' is not problematic with prototypes in action, and the probability
of the code being backported to a pre-C90 compiler is diminishingly
small.

The words "due to prototype" now serve as a hint again.  The proper fix
could be to suppress this warning in C99 mode since that's far enough
from traditional C.
2021-02-04 06:54:59 +00:00
rillig
1c1bd1bbee lint: document that message 108 doesn't abort anymore 2021-01-31 16:00:05 +00:00
rillig
70a1a91e7b lint: format tests in a common style
The lint tests do not focus on the whitespace since that is the most
boring part of code style.  Therefore, format the tests to be readable
by following share/misc/style as close as possible.
2021-01-31 14:57:28 +00:00
rillig
aadcb6a6f1 lint: add common header for all tests
For those tests that didn't use GCC-style line markers such as "# 2",
the line numbers of the diagnostics stay the same.  This is purely
conincidental.  Before, the 3 lines came from lint's built-in
definitions (see 'builtins' in main1.c), and line number counting
continued as if nothing had happened, making the first line of the
actual file line 4.  These 3 built-in lines are now replaced with 3
lines of file header.
2021-01-31 14:39:31 +00:00
rillig
9e66939b96 lint: reword message 259 about function argument conversion
The words "due to prototype" are an anachronism from the 1990s.
Nowadays every function is defined using a prototype, which makes these
words redundant.
2021-01-31 14:05:00 +00:00
rillig
43f40912b1 lint: make warning about function argument conversion more detailed
For every conversion it is useful to know both the source and the target
type since these are not always obvious from the code.

The only surprise is the warning in d_gcc_extension.  The conversion
there is from 'double' to 'long double', which is a lossless conversion.
This may be a bug in lint.
2021-01-31 13:56:14 +00:00
rillig
0b12920818 lint: demonstrate wrong and misleading warnings about reachability 2021-01-31 13:33:10 +00:00
rillig
eaade8c9b9 lint: add test for lossy assignments to bit-fields (164, 166) 2021-01-31 13:11:08 +00:00
rillig
2c260a3f3b lint: don't warn about constant condition in 'do { } while (0)' 2021-01-31 12:44:34 +00:00
rillig
7986832010 lint: add expectations to test for message 161 2021-01-31 12:30:53 +00:00
rillig
bed82d19b3 lint: add tests for 'constant in conditional context'
One of these tests explains why 'do { } while (0)' is so usual that
there is no reason to warn about it.  That warning will not survive for
long.
2021-01-31 12:29:16 +00:00
rillig
c4973480d0 lint: fix strange message about nested '==' operators
If one of the nested subexpressions is parenthesized, the author
probably knew how these expressions are evaluated.  Therefore don't warn
in such a situation.

Maybe the original author once made a typo and tried to initialize
variables but instead compared them, like this:

	int a, b, c;

	a == b == c;

This would explain the text of the message, which still sounds strange.
At least it doesn't show up as often anymore.
2021-01-31 12:20:00 +00:00
rillig
9ff24546ee lint: add more test cases for strange '==' warning 160 2021-01-31 11:59:56 +00:00
rillig
73fb62d3c1 lint: mention the operator in messages about bit shifts 2021-01-31 11:44:48 +00:00
rillig
6712cb633d lint: add quotes to messages 1 and 19 2021-01-31 11:23:01 +00:00
rillig
e9aa93027d lint: add expections to tests
msg_098: fix suffix for floating point constant
msg_127: remove prototype
msg_146: fix return type
2021-01-31 11:12:07 +00:00
rillig
d61a087385 lint: test messages 019 and 021 2021-01-31 09:48:47 +00:00
rillig
cfd7827cf3 lint: be more precise in message 003 "tag in argument list" 2021-01-31 09:26:27 +00:00
rillig
3cef4b4f94 lint: add a few more tests 2021-01-31 09:21:24 +00:00
rillig
c96543cdff lint: fix wrong 'expression has null effect' 2021-01-30 23:05:08 +00:00
rillig
d1d4e41c20 lint: add test for 129, possibly demonstrating a bug in lint 2021-01-30 22:38:54 +00:00
rillig
0872823424 lint: add test for message 259 about implicit conversions 2021-01-30 22:07:31 +00:00
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