Commit Graph

6280 Commits

Author SHA1 Message Date
rillig db245c79a9 indent: remove blank between comment and parentheses or brackets
Finally, indent formats its own source code without messing up the
layout.
2023-05-16 08:22:11 +00:00
rillig c5b428c7c1 indent: fix handling of INDENT OFF/ON comments
Previously, the 'INDENT OFF' comments were interpreted when the newline
token from the line above the comment was processed, which was earlier
than could be reasonably expected.

The 'INDENT ON' comments were interpreted equally early, which led to
the situation that the 'INDENT OFF' comments were preserved literally
but the 'INDENT ON' comments weren't.
2023-05-16 08:04:03 +00:00
rillig 70c3f641d2 indent: fix detection of casts
A word followed by a '(' does not start a cast expression.
2023-05-15 21:51:45 +00:00
rillig 62d29170f1 indent: fix type cast in function definition 2023-05-15 20:50:37 +00:00
rillig a59ea3192b indent: fix duplicate space between comment and binary operator 2023-05-15 20:30:20 +00:00
rillig 2aaa93dadf indent: fix line wrapping of comments to the right of code 2023-05-15 19:55:51 +00:00
rillig 219ccf6233 indent: improve type guessing, fix formatting of declarations 2023-05-15 18:22:40 +00:00
rillig 3357d7dc84 tests/indent: test type detection 2023-05-15 17:51:49 +00:00
rillig 2e1f799d6b indent: remove accidental space before tab 2023-05-15 17:38:56 +00:00
rillig 3842fd14e5 indent: remove backslash line continuation outside preprocessing
The indenter did not handle these backslashes well, interpreting them as
unary operators, and they are an edge case anyway.  Line continuations
in string literals and character constants are kept.
2023-05-15 17:28:14 +00:00
rillig c3a01c7bfa tests/indent: demonstrate wrong spacing after function prototype 2023-05-15 15:04:48 +00:00
rillig 6c38484f82 indent: fix spacing between function prototype and attributes 2023-05-15 14:55:47 +00:00
rillig c74302075d indent: fix indentation of struct member names 2023-05-15 14:12:03 +00:00
rillig 415b6afa14 tests/indent: demonstrate wrong indentation of struct members 2023-05-15 13:53:32 +00:00
rillig b33d7ae266 indent: fix indentation of statements after controlling expression 2023-05-15 13:33:19 +00:00
rillig 60722870c9 tests/indent: add another test for -eei -nlp 2023-05-15 13:28:05 +00:00
rillig 8bbe0ac207 indent: fix indentation of expressions in -nlp -eei mode 2023-05-15 12:59:43 +00:00
rillig 3801fbef33 tests/indent: test extra indentation with fixed continuation indentation 2023-05-15 12:11:07 +00:00
rillig 09166ed3ac indent: fix indentation of multi-line '?:' expressions in functions 2023-05-15 10:13:40 +00:00
rillig e311e1f8e6 tests/indent: -badp should not add blank lines in initializers 2023-05-15 09:05:08 +00:00
rillig 89e0e636cf indent: fix spacing in for loop with declaration (since 2022-02-13) 2023-05-15 08:56:39 +00:00
rillig f382e6fe26 tests/indent: demonstrate wrong spacing in for loops 2023-05-15 08:22:23 +00:00
rillig 9a2185a149 indent: clean up memory and buffer management
Remove the need to explicitly initialize the buffers.  To avoid
subtracting null pointers or comparing them using '<', migrate the
buffers from the (start, end) form to the (start, len) form.  This form
also avoids inconsistencies in whether 'buf.e == buf.s' or 'buf.s ==
buf.e' is used.

Make buffer.st const, to avoid accidental modification of the buffer's
content.

Replace '*buf.e++ = ch' with buf_add_char, to avoid having to keep track
how much unwritten space is left in the buffer.  Remove all safety
margins, that is, no more unchecked access to buf.st[-1] or appending
using '*buf.e++'.

Fix line number counting in lex_word for words that contain line breaks.

No functional change.
2023-05-15 07:28:45 +00:00
rillig 506e3bec5c indent: only null-terminate the buffers if necessary
The only case where a buffer is used as a C-style string is when looking
up a keyword.

No functional change.
2023-05-14 22:26:37 +00:00
rillig 1304bdca7f indent: fix handling of multiple block comments in a line 2023-05-14 17:53:38 +00:00
rillig 217e4d847d indent: in comments, keep a leading tab
This kind of comments is used for the CVS IDs at the top of files.
2023-05-14 17:13:37 +00:00
rillig 0cd0431ee6 indent: fix vertical spacing after declarations
A comment is not supposed to change the state of the 'blank line after
declaration', but it did.  The initialization of saved_just_saw_decl was
wrong though since it tried to capture the previous value after it had
already been overwritten.
2023-05-14 16:47:06 +00:00
rillig e04d6833e7 indent: miscellaneous cleanups 2023-05-14 11:29:23 +00:00
rillig 4f2a635091 lint: add query for chained assignments 2023-05-13 20:55:44 +00:00
riastradh 1e9b358f6a openssl: More tests need -Wno-missing-field-initializers. 2023-05-13 17:46:09 +00:00
rillig c49e59f750 indent: do not add a space before a comment that starts a line 2023-05-13 16:40:18 +00:00
rillig 2261e976c8 indent: implement 'blank after declarations' 2023-05-13 15:34:22 +00:00
riastradh 61b8d55f2a openssl: libcrypto bf test needs -Wno-missing-field-initializers 2023-05-13 15:12:13 +00:00
rillig 4cae730b26 tests/indent: extend test for blank line after declaration 2023-05-13 14:19:14 +00:00
rillig 24dd152d37 indent: fix lexing of numbers that are spread over multiple lines 2023-05-13 13:31:37 +00:00
rillig 9db90c6e6b tests/indent: add test for lexing of numbers 2023-05-13 13:24:01 +00:00
rillig 842f73039b indent: clean up a condition, add comments
No functional change.
2023-05-13 09:40:47 +00:00
rillig 38caea9b89 indent: preserve indentation of preprocessor directives 2023-05-13 08:33:39 +00:00
rillig ff059387ed tests/indent: explain, clean up and add some tests 2023-05-13 06:52:48 +00:00
rillig 8ba922e8f2 tests/indent: test pushing the placeholder symbol to the parser stack 2023-05-12 22:36:15 +00:00
rillig 0cdf93c9f3 indent: remove statistics
The numbers from the statistics were wrong.
2023-05-12 10:53:33 +00:00
rillig 46afda1643 tests/indent: test interaction between preprocessing and comments 2023-05-11 21:36:31 +00:00
rillig d5678748c0 indent: don't touch comments in preprocessing lines
The indentation of multi-line comments was wrong, and the code for
handling them was too complicated.
2023-05-11 19:01:35 +00:00
rillig bacb7fc4b5 tests/indent: add more tests for preprocessing directives 2023-05-11 18:44:14 +00:00
rillig 5300eef1a9 tests/indent: test multi-line comments in preprocessing lines 2023-05-11 18:36:36 +00:00
rillig d54ae284ce indent: remove broken code for handling blank lines
This fixes several bugs where blank lines were erroneously added or
removed, treating these old bugs for new bugs in different places.
These new bugs are expected to be easier to fix, as the old bugs will
not interfere anymore.
2023-05-11 18:13:55 +00:00
rillig 3ae5a30b3c indent: add debug output for tracking comments and braces 2023-05-11 17:22:56 +00:00
christos a09aac5f84 aarch64 needs static 2023-05-11 14:34:30 +00:00
rillig 44c1f7b6a8 indent: remove unnecessary assignments to last_else
No functional change intended.
2023-05-11 10:39:25 +00:00
kre 490e17a0c9 Fix building the debugging tarball of the directory tree created for
the pathname matching tests ... this is not used in any way in a normal
test run, but if there are problems, one needs a mechanism to discover
whether the issue is with the code that creates the directory tree in the
test, or with the matching (either what the test expects to happen, or
what the shell actually does).   The couple of lines being fixed here make
that mechanism work --- I have had this in my private sources for years
now, but never got around to committing it.   It is time.  NFC for any
normal test run.
2023-05-11 10:08:34 +00:00
rillig 373317666b indent: remove buggy code for swapping tokens
It is not the job of an indenter to swap tokens, even if it's only about
placing comments elsewhere.  The code that swapped the tokens was
complicated, buggy and impossible to understand.

In -br (brace right) mode, indent no longer moves a '{' from the
beginning of a line to the end of the previous line, as that was handled
by the token swapping code as well.  This change is unintended, but it
will be easier to re-add that now that the code is simpler.
2023-05-11 09:28:53 +00:00
rillig 0510ee8e2a lint: fix type name in diagnostic for enum as controlling expression
Previously, the type was reported as 'int' instead of 'enum'.

Continue to only report the type simple for pointer types, as the exact
pointer type is irrelevant to this message.
2023-05-11 08:01:36 +00:00
gutteridge 1b3c330bb0 t_fss.sh: add missing test case head 2023-05-11 01:56:31 +00:00
gutteridge 7cb4398ae9 t_patterns.sh: fix naming of head() of filename_expansion 2023-05-11 01:50:40 +00:00
gutteridge 3d108ca492 t_cmdsub.sh: fix naming of head() of cmdsub_paren_tests 2023-05-11 00:32:48 +00:00
gutteridge 360a298dc1 t_getopt.sh: fix naming of head() of getopt_optval test case 2023-05-10 23:44:15 +00:00
rillig a48523a624 lint: track integer constraints through conditional expressions 2023-05-09 15:51:33 +00:00
rillig 872d56a969 lint: preserve integer constraints on cast 2023-05-09 15:45:06 +00:00
rillig b889b215f6 tests/lint: demonstrate wrong warning about loss of accuracy 2023-05-09 15:37:29 +00:00
rillig 815f75fc84 tests/lint: demonstrate wrong warning about losing accuracy 2023-05-09 14:46:36 +00:00
andvar e171cef674 fix the grammar in comments reported by Jim Spath in misc/57397. 2023-05-08 19:23:45 +00:00
christos 59a49c3ac2 make tests support both 1.x and 3.x.
Lot of work needed to add all the 3.x tests, but that can wait until all
is switched
2023-05-08 17:46:06 +00:00
skrll 75b842b847 RISC-V support that works on QEMU with a single hart.
Thanks for Simon Burge for plic(4).
2023-05-07 12:41:45 +00:00
gutteridge 09bc0ce2d8 t_sed.sh: add a test case for relative addressing
At one time, this didn't always work correctly, per PR bin/49109. Test
case from https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=192108
2023-05-06 02:12:11 +00:00
gutteridge f12d9a9c2d t_sed.sh: fix grammar, spelling, and formatting issues (NFC) 2023-05-06 02:07:42 +00:00
gutteridge 9e739a8449 t_trapsignal.sh: fix head() function definitions of test cases 2023-05-05 01:27:18 +00:00
gutteridge 3a6eaa3511 t_fexecve.sh: fix head() function definitions of test cases 2023-05-04 00:02:10 +00:00
gutteridge 55843ced06 t_expr.sh: fix naming of head() of lang test case 2023-05-02 00:11:27 +00:00
rillig 0878a3d7ee lint: reword message for missing declaration in header
Suggested by Christos.
2023-04-25 19:00:57 +00:00
uwe c9764f2dff tests/rump/modautoload: reorder -lrumpvfs_nofifofs
Make the way we spell "-lrumpvfs -lrumpvfs_nofifofs" hack consistent.
The order doesn't matter here because of --whole-archive.
2023-04-24 20:55:53 +00:00
uwe 1694588bdd tests: trim down the list of LIBRUMPBASE libraries
Now that cyclic dependencies are (mostly) broken, we can drop repeated
-l instances that worked around those cycles.  Links on sun2.
2023-04-24 20:35:49 +00:00
mlelstv 7d5fef3b2c Allow 24bit support. 2023-04-23 16:49:38 +00:00
rillig 951d064816 tests/lint: add rationale for not warning about alignment problems 2023-04-23 11:52:43 +00:00
rillig f0ae73e148 lint: be strict when parsing command line for excluded message IDs
Previously, lint accepted -X '1, 2, 3', while the manual page lists the
IDs without spaces.

On 32-bit platforms, lint accepted -X -4294967295, and on 64-bit
platforms, it accepted the corresponding larger numbers.

The code for parsing message IDs and query IDs conceptually does the
same, but the implementations differed for no reason.
2023-04-23 09:04:44 +00:00
rillig 1d3cf26e0d tests/lint: test command line parsing for message and query IDs
The parsing methods differ but shouldn't.
2023-04-23 08:47:27 +00:00
gutteridge 212fac277d t_open_pr_57260.c: KNF a block (spaces to tabs) 2023-04-23 00:46:46 +00:00
rillig 6b952c1471 lint: allow cast from a type to a union containing that type 2023-04-22 20:54:28 +00:00
rillig 368afe279d lint: fix wrong warning about 'extern' temporary identifier 2023-04-22 20:27:09 +00:00
rillig da9016a31f tests/lint: demonstrate wrong warning about extern temporary identifier 2023-04-22 20:21:13 +00:00
rillig a143ec617b tests/lint: test cast to union with stricter alignment 2023-04-22 19:45:04 +00:00
rillig b847195210 lint: don't warn about cast between union and one of its member types
Seen in src/sbin/newfs_udf/udf_core.c for context.anchors.
2023-04-22 17:42:29 +00:00
rillig 0e61302acd tests/lint: add test for conversions to and from a union type
Additionally, fix the line numbers in another test.
2023-04-22 17:30:35 +00:00
rillig 83d27b7d33 lint: do not warn about parenthesized assignment in controlling expr
Same as for GCC and Clang.
2023-04-22 15:14:37 +00:00
gutteridge 04d453bc9d Add new test t_open_pr_57260
New test case that reflects the fix in PR kern/57260. The majority of
work for this case itself was by riastradh@, who'd supplied the basis
for it in the ticket, and provided further guidance.
2023-04-21 21:50:04 +00:00
rillig 5fe653032c tests/lint: remove wrong comment
GCC 10 does warn about returning a temporary object, but only when
optimizations are enabled.
2023-04-15 12:59:02 +00:00
rillig db7f32c2b2 tests/lint: add more tests for returning local objects 2023-04-15 12:47:32 +00:00
rillig 408e7ca205 lint: add query for parenthesized return value 2023-04-15 11:34:45 +00:00
rillig e7d3b23c6b tests/lint: extend test for returning local address 2023-04-15 10:53:59 +00:00
kre 960493d8f0 PR misc/57343 (Jim Spath) - fixed a typo in atf_tc_skip message. 2023-04-11 18:23:42 +00:00
rillig 484ed28712 lint: don't wrongly warn about overflow in complex constants
Seen in lib/libm.
2023-04-11 00:03:42 +00:00
rillig f8bad61ed5 tests/lint: demonstrate wrong warning with complex numbers 2023-04-10 23:52:49 +00:00
rillig f92802e558 lint: fix duplicate warning when parsing big float constants 2023-04-05 20:17:30 +00:00
rillig cc35e66604 tests/lint: demonstrate duplicate warning when parsing big floats 2023-04-05 20:13:01 +00:00
he ac0941c572 Fix the test for "inf" output, also include newline in printf format... 2023-04-04 19:39:38 +00:00
christos 30cc241785 Add a test for PR/57250 from Havard Eidnes 2023-04-04 19:30:11 +00:00
gutteridge 57f997550b t_magic_symlinks.sh: fix line continuation in realpath head()
This wasn't noticed before because the name of the head() itself was
wrong, and was being ignored.
2023-04-03 21:35:59 +00:00
gutteridge f56d3fb7f1 t_magic_symlinks.sh: fix naming of head() of realpath test case
Addresses part of PR kern/57319 from Jim Spath.
2023-04-03 20:08:38 +00:00
rillig ce2e717784 lint: allow querying for octal integer constants 2023-03-31 13:03:05 +00:00
rillig d0a5c1bc3c lint: warn about 'extern' declarations inside function bodies
https://mail-index.netbsd.org/tech-userlevel/2023/03/15/msg013727.html

The previous attempt (message 351 about 'extern' declarations outside
headers) did not cover the proposal from the tech-userlevel mailing list
but instead warns about a different usage pattern of the 'extern'
keyword.
2023-03-28 20:04:51 +00:00
rillig b2baa50111 lint: warn about extern declarations outside headers
https://mail-index.netbsd.org/tech-userlevel/2023/03/15/msg013727.html
2023-03-28 14:44:34 +00:00
andvar 95f94af301 fix various typos in documentation, comments and sysctl device description.
mainly aion -> ation and inlude -> include.
2023-03-26 19:10:32 +00:00
martin 9da6df7d4c PR 57284: rewrite test to extract all temperaturs from all local sensors
and test them (instead of only one temperature from a tiny list of hard
coded possible devices).
2023-03-23 11:32:49 +00:00
hannken 86c75e95c0 Adjust pc/npc before syscall allowing EJUSTRETURN to return
to the next instruction.  Only ERESTART should return to
the same instruction.  Differences to sparc64 reduced.

Test t_ptrace_wait:syscallemu1 now passes on sparc.

Fixes PR kern/52166 "syscallemu does not work on sparc (32-bit)"

Ok: Martin Husemann
2023-03-20 11:19:29 +00:00
kre 23edd9e279 Adjust the tilde expansion test to deal with (very) recent changes
to what the shell produces for tilde expansions, when the expansion
of the tilde prefix ends with '/' and the character immediately following
is another '/' - previously /bin/sh (and most other shells, but not all)
retained both slashes, and this test expected that behaviour.

No longer, now only one of the two will appear.  Adjust the expected
test results accordingly, and add an extra loop iteration to make sure
this is thoroughly tested (one more tilde expansion value).

Also, add two new test cases that test for the new (explicit - though
it was always stated this way, but not as explicitly) that if HOME is
an empty string (not unset - that remains an unspecified case, as it
was) then the expansion of ~ must generate "", and not nothing.
The current test was unable to distinguish those two, since it
simply looked for characters in the output, so add a new test cases
explicitly to test for this particular case.   This also means (also
previously in the standard, but not as explicitly) that shells are
not permitted to decide "The ~ expansion produces an empty string, that
is weird, let's generate something else instead" which some shells were
doing.
2023-03-06 05:54:54 +00:00
nia 188cf0e1a1 delete attribution per request of contributor 2023-03-01 21:06:41 +00:00
rillig eaf30a03e7 lint: split platform-specific test for loss of accuracy
Lint distinguishes between platforms where size_t is unsigned int and
platforms where size_t is unsigned long.
2023-02-27 23:07:53 +00:00
rillig 17f65f1e9a tests/lint: sync test for nonportable character comparisons
Message 230 was changed on 2023-02-22 but only tested on signed char
platforms.
2023-02-27 21:59:14 +00:00
sjg 68f52b2486 t_make skip varname-dot-make-meta-ignore_*
The meta-ignore tests will likely not work in this environment
so skip them.
2023-02-25 19:37:33 +00:00
rillig 6adfeb9415 lint: fix confusing message about nonportable character constants 2023-02-22 22:30:40 +00:00
rillig f29e29e219 tests/lint: add platform-specific tests 2023-02-22 22:12:35 +00:00
rillig 68d13a7aa7 lint: fix null pointer dereference in invalid case expression 2023-02-21 19:47:21 +00:00
christos 36c8de9256 New optval test from des @ FreeBSD 2023-02-20 15:47:56 +00:00
rillig 4995df0909 lint: do not warn about traditional C migration in C99 mode
For large integer constants, the resulting type could differ between
traditional C and C90. In C99 mode, this difference is no longer
relevant since it is too far away from traditional C.
2023-02-19 12:00:15 +00:00
rillig a44d0c3164 tests/lint: fix and extend tests for C90 migration warning 2023-02-19 11:50:29 +00:00
rillig 8ee241b006 lint: remove compat code for lexing hex floating point literals
Hex floating literals are required by C99.
2023-02-18 14:32:32 +00:00
andvar f231fa93bb s/plyaback/playback/ in comment. 2023-02-13 22:24:06 +00:00
rillig 15a1e93882 tests/lint: sync reference to platform properties generator 2023-02-06 21:20:58 +00:00
rillig 456342a5d0 lint: eliminate unnecessary indirection
No functional change.
2023-02-06 21:01:55 +00:00
rillig f1b2140bb8 tests/lint: fix source directory for looking up the .exp-ln files 2023-02-05 17:23:01 +00:00
rillig 6d1c4d2bf4 tests/lint1: the redundantly listed files contained .exp-ln as well 2023-02-05 16:11:56 +00:00
rillig d81c1a19b2 tests/lint: fix resolving of wildcards in builds from other directories 2023-02-05 15:11:19 +00:00
rillig cd59f013cc tests/lint: merge tests for initialization 2023-02-05 13:01:28 +00:00
rillig 6730036cf8 tests/lint: remove redundancy from Makefile
The list of test files is already kept in distrib/sets/lists/tests/mi.
2023-02-05 12:36:56 +00:00
rillig 134e5c5e76 tests/lint: remove redundant tests
The names of the tests were misleading: 'recursive' should have been
'nested', and the interesting topic in the 'cast' tests was not the cast
but the pointer dereference.
2023-02-05 12:25:11 +00:00
rillig 9de3085848 tests/lint: clean up
The .exp files are no longer kept under version control, so there's no
reason anymore to forcefully trigger a warning or an error.
2023-02-05 10:57:48 +00:00
christos e20f737644 PR/57205: Dag-Erling Smørgrav: Add tests strchrnul(3), fix strchr pasto
from strlen.
2023-01-30 19:49:49 +00:00
rillig e0bb9f7cf5 lint: properly clean up when leaving a function definition 2023-01-29 18:37:20 +00:00
rillig b5b35fa5a0 lint: fix definition of __func__ 2023-01-29 18:16:48 +00:00
rillig e80194217c lint: demonstrate wrong declaration of __func__ 2023-01-29 17:36:26 +00:00
rillig 2f05763014 lint: don't warn about negative '>>' when the actual value is positive 2023-01-29 17:13:10 +00:00
rillig 6b8b6837b1 tests/lint: merge tests for '>>' 2023-01-29 17:02:09 +00:00
rillig b4db8a2cd2 tests/lint: document how compilers promote bit-fields 2023-01-28 08:36:17 +00:00
rillig 93f3a70d97 tests/lint: investigate how compilers interpret bit-fields 2023-01-28 08:30:12 +00:00
rillig f25c712f32 tests/lint: merge tests for declaration after statement 2023-01-22 17:17:24 +00:00
rillig 0ad5a70976 lint: prevent undefined behavior for signed '<<'
Found by manual code inspection, verified by MKSANITIZER=yes
USE_SANITIZER=undefined.
2023-01-22 16:05:08 +00:00
rillig a695cd72f6 lint: add test for floating constant overflow 2023-01-21 17:48:29 +00:00
rillig 798c690d94 lint: add support for C11 '_Atomic' as atomic-type-specifier
Following the C11 grammar, the keyword '_Atomic' needs to be a separate
syntactic category, to avoid further conflicts in the grammar.

The two newly added conflicts in the grammar would come into play when
mixing traditional C with C11, in a type name without an implicit 'int'.
If the type '_Atomic(int)*' were parsed as '_Atomic int(int)*', the
trailing '*' would be a syntax error.
2023-01-21 13:48:40 +00:00
rillig e104b7676c lint: add support for the C11 type qualifier '_Atomic'
That keyword can be used as a type specifier as well, support for that
will be added later.
2023-01-21 13:07:21 +00:00
rillig 149d92727c tests/lint: test _Atomic, added in C11 2023-01-21 11:57:03 +00:00
rillig 5db76b35c9 lint: fix null pointer dereference on invalid argument to __typeof__ 2023-01-21 08:04:43 +00:00
rillig d67dd6957e tests/make: rename files that are not test cases 2023-01-19 23:26:14 +00:00
rillig f523563840 tests/lint: fix typo in comment 2023-01-16 00:37:59 +00:00
rillig 66827794fe tests/lint: add basic tests for lint (not lint1 or lint2) 2023-01-15 23:18:05 +00:00
rillig 8e78cfd5a6 tests/lint: document conversion from void pointer 2023-01-15 14:00:09 +00:00
rillig 687f4c966a tests/lint: fix test for sizeof with variable-length array 2023-01-15 13:55:06 +00:00
rillig f0df5ddf92 tests/lint: add more tests for sizeof 2023-01-15 13:30:04 +00:00
rillig 7997ddce85 tests/lint: add test for parsing sizeof expressions 2023-01-15 00:53:19 +00:00
rillig a5ae950d72 tests/lint: add more tests for array/enum mismatch 2023-01-14 11:15:07 +00:00
rillig 0f2ef2d80b lint: rename lint2 functions to be more expressive 2023-01-14 08:48:18 +00:00
rillig 872114d0db lint: do not report usual arithmetic conversions for constants 2023-01-08 18:37:12 +00:00
rillig 12c5dc767e lint/tests: test query for usual arithmetic conversions 2023-01-08 18:21:00 +00:00
rillig 8c46ae662d lint: recognize enum constant named 'max' as a count of values
Seen in external/bsd/mdocml/dist/mdoc.h(50).
2023-01-08 15:22:33 +00:00
rillig e39cd4feb0 tests/lint: add more tests for enum/array mismatch 2023-01-08 15:18:02 +00:00
rillig a89fe711df tests/lint: remove obsolete comments
The handling of initializers was completely rewritten in init.c 1.228
from 2021-12-21.
2023-01-04 06:04:07 +00:00
rillig e1fea1d661 tests/lint: document where to find the test results for promotions 2023-01-04 05:47:19 +00:00
rillig ce38ef24bf tests/lint: fix typo in comment 2023-01-04 05:32:01 +00:00
rillig 7c0153f0bf tests/lint: merge tests for ':?' with null pointer constant 2023-01-04 05:25:08 +00:00
rillig 391c34354a lint: fix the result type of '?:' for void pointers
The change from 2015-07-29 was wrong since that rule only applies to
null pointer constants but not to other void pointers.
2023-01-04 05:08:22 +00:00
rillig 6173d74cda tests/lint: demonstrate wrong type for '?:' expressions 2023-01-03 22:02:20 +00:00
riastradh ddb0a7e7a7 swab(3): Rewrite this to be understandable.
And make the tests work, and exercise all lengths up to 100.

Evidently the previous definition, presumably tightly optimized for
1980s-era compilers and CPUs, was too hard to understand, because it
was incorrectly tested for two decades and broken for years.

PR lib/57141

XXX pullup-8
XXX pullup-9
XXX pullup-10
2022-12-28 15:34:19 +00:00
wiz c1acb3b3a5 adapt mbstowcs_basic test for unicode table update
reformat so it's easier to find which result data belongs to which input
2022-12-21 09:33:34 +00:00
kre 1cba94e3a4 This test makes (made) a false assumption about the way that
process scheduling works.   That a process (or in this case,
a thread) is no longer blocked at time T does not mean that it
will resume execution at time T.   The OS is free to devote
resources to other processes/threads instead - all we should
normally be able to expect is that if it is not unblocked before
time T, that it will not start running before then.

In general though, the pthread_cond_*wait() functions don't guarantee
even that - but for this test, the possibility of something else
randomly signalling the condvar isn't believable, so don't worry about
that possibility (but do fail without calling strerror(0) on the off
chance it does happen).

Once we cease testing that the process resumed running before some
particular time, we can stop dealing with qemu timekeeping issues,
it might (seem to) take qemu twice as long as was requested before
the thread resumes, but that's OK - the same thing could happen on
a loaded system for other reasons.

Beyond that, the test also has (had) a race condition.   When using
CLOCK_REALTIME though that clock needed to have advanced to T before
the ETIMEDOUT should happen, there is no guarantee that it will stay >T
(CLOCK_REALTIME is allowed to be reset backwards).   So, only test
that the current time (after ETIMEDOUT) >= T when we're using
CLOCK_MONOTONIC - for CLOCK_REALTIME the time might have stepped
back between when the ETIMEDOUT happened and when the thread
obtains the current clock reading.  For that case, all we can test
is that the ETIMEDOUT actually happens.

With much of what was there now gone, the code can be simplified,
we no longer need to do timespec arithmetic, just one comparison
(simpler to test that Tend >= Tstart+period than Tend-Tstart > period
as we need Tstart+period for the abstime value for the timeout anyway).

Note that this still tests for the issue reported in PR lib/47703
which is where the test came from in the first place.

ps: we seem to be missing pthread_cond_clockwait() which is the same
as pthread_cond_timedwait() except that the clock to use is passed
as a parameter, rather than as an attribute of the condition variable.
2022-12-11 10:02:53 +00:00
blymn c6e199d915 Update check files due to reversion of a libcurses change. 2022-12-05 21:15:07 +00:00
jschauma de630815c5 allow testing of files other than those in /etc
To test e.g., the file "/some/where/protocols" instead of "/etc/protocols",
set TEST_FILE=/some/where/protocols in your environment.

Note: this now compares the contents of the file you gave versus what
getprotoent(3)/getservent(3) uses (which still is /etc/protocols via
h_protoent.c / /etc/services or /var/db/services.cdb via h_servent.c).

When you have expected changes in the services or protocols file that
you're generating, this necessarily produces a difference.  To really
allow testing the file versus what the library function returns, you'd
have to install the file on the system running the test, but at least
with this change you can now generate the file and verify that it didn't
caused unexpected differences.
2022-12-04 02:53:17 +00:00
jschauma 76292795b2 whitespace 2022-12-04 02:42:39 +00:00
ozaki-r 9ac30c6562 tests: fix Makefile and lists for MKRUMP=no
Pointed out by Michael Scholz, thanks.
2022-12-01 04:24:37 +00:00
martin 062f53e0d1 Avoid explicitly naming the raw part device with a partition letter - use
the non-partition letter variant instead.
2022-11-30 17:49:59 +00:00
martin 8693f01d5f Unfortunately rump does not provide the same magic as MAKEDEV does
for native /dev and create an alias for disk devices w/o partition
latter pointing at the raw partition, so for rump based tests we
actually have to calculate the concrete device name.

Use an idiom suggested by kre for this which also works for ports that
have kern.rawpartition > 4.
2022-11-30 17:49:09 +00:00
ozaki-r 2c37112bef tests: restore a line removed accidentally 2022-11-30 07:48:43 +00:00
martin 2e1faf8f64 Simplify: avoid use of the explicit raw partition, MAKDEV does
all the needed magic for us already. Pointed out by kre
2022-11-30 07:20:36 +00:00
blymn 731bbb483f Update the check files due to bug fix in libcurses. 2022-11-30 06:20:17 +00:00
ozaki-r efcd8443e2 tests: build and install t_ip_reass.c 2022-11-30 06:07:51 +00:00
ozaki-r 67a880e0c1 tests: tweak t_ip_reass.c for NetBSD
The test is modified to run on rump kernels.
2022-11-30 06:06:36 +00:00
ozaki-r 34f02c31eb tests: import ip_reass_test.c from FreeBSD as t_ip_reass.c
As of:
	commit 9ed1e4ecd4e9eb3bde16f52a937a6fa86a971638
	Author: Mark Johnston <markj@FreeBSD.org>
	Date:   Tue Nov 20 18:13:18 2018 +0000

	    Plug a trivial memory leak.

	    CID:            1396911
	    MFC with:       r340485
2022-11-30 06:05:58 +00:00
martin e04aecab2f Avoid dependence on details of the MD synthesized disklabel for
the vnd after mounting the single filesystem image.
2022-11-29 20:06:24 +00:00
jschauma 0adaf508e8 whoops, we don't want an extra space here
(erroneously introduced in my previous commit)
2022-11-28 17:41:00 +00:00
jschauma a8b3b3348f whitespace 2022-11-28 17:09:52 +00:00
knakahara d432a9d987 Add ATF for unnumbered interfaces. 2022-11-25 08:43:15 +00:00
knakahara 708e59eb6f clean up 2022-11-24 02:58:28 +00:00
christos 902698381c fix vax 2022-11-23 18:18:57 +00:00
rin 867b834377 Sync style between Lua script and C source code.
Fix false positive for some tests.
2022-11-22 15:57:03 +00:00
christos ae082add65 lua libm API from Phil Rulon 2022-11-21 22:01:32 +00:00
martin f202639d6b vnconfig is used in this tests, so require user root. 2022-11-21 19:07:36 +00:00
kre c01cab9c1c Adapt to recent gpt(8) change which now issues a message when
the secondary GPT header is moved.   Do it this way rather than
just using -q to suppress the message, so the test verifies that
the appropriate action was taken.
2022-11-21 16:06:00 +00:00
ozaki-r a97d0b3002 tests: build and install added test files 2022-11-17 08:45:35 +00:00
ozaki-r 86fd57d8dd tests: add t_broadcast_bind.sh 2022-11-17 08:42:56 +00:00
ozaki-r eedb766f76 tests: tweak broadcast_bind.c for NetBSD 2022-11-17 08:42:06 +00:00
ozaki-r a86cd60e5f tests: import broadcast_bind.c from OpenBSD
As of $OpenBSD: broadcast_bind.c,v 1.2 2015/12/02 20:45:00 mpi Exp $
2022-11-17 08:41:16 +00:00
ozaki-r 3eb71caadc tests: add t_inpcb_bind.sh 2022-11-17 08:40:23 +00:00
ozaki-r ae0059cb30 tests: make inpcb_bind.c buildable 2022-11-17 08:38:58 +00:00
ozaki-r 0fca6c426e tests: import in_pcbbind/runtest.c from OpenBSD as inpcb_bind.c
As of $OpenBSD: runtest.c,v 1.7 2022/04/10 14:08:35 claudio Exp $
2022-11-17 08:38:08 +00:00
ozaki-r 87c661b6f4 tests: make t_tcp_connect_port.c run on rump kernel 2022-11-17 08:36:54 +00:00
ozaki-r ed458f0ba0 tests: import tcp_connect_port_test.c from FreeBSD as t_tcp_connect_port.c
As of:
	commit 36c52a52eecf1ed0232f9e138564009a85de76c2
	Author: Jonathan T. Looney <jtl@FreeBSD.org>
	Date:   Sat Nov 14 15:44:28 2020 +0000

	    Add a regression test for the port-selection behavior fixed in r367680.
2022-11-17 08:36:00 +00:00
ozaki-r 652168dc16 tests: make t_socket_afinet.c run on rump kernel 2022-11-17 08:34:39 +00:00
ozaki-r 7b795c7b93 tests: import socket_afinet.c from FreeBSD as t_socket_afinet.c
As of:
	commit 3aaaa2efde896e19d229ee2cf09fe7e6ab0fbf6e
	Author: Thomas Munro <tmunro@FreeBSD.org>
	Date:   Wed Apr 28 21:31:38 2021 +1200

	    poll(2): Add POLLRDHUP.
2022-11-17 08:33:27 +00:00
chs 87ba0e2a31 Restore backward compatibility of UFS2 with previous NetBSD releases by
disabling support in UFS2 for extended attributes (including ACLs).
Add a new variant of UFS2 called "UFS2ea" that does support extended attributes.
Add new	fsck_ffs operations "-c	ea" and	"-c no-ea" to convert file systems
from UFS2 to UFS2ea and	vice-versa (both of which delete all existing extended
attributes in the process).
2022-11-17 06:40:38 +00:00
blymn a90239df44 Uncomment the waddstr call that was returning ERR, this is actually
correct so make the expected return ERR then repeat the call with
scrollok set to true to validate.

Do refreshes on the window instead of stdscr so we get the window
contents reported and update the check files with the expected
output.
2022-11-10 06:13:29 +00:00
knakahara 9d1cf4af54 Add test for sys/netipsec/ipsec.c:r1.176. 2022-11-09 08:21:20 +00:00
blymn ea7ddd486e * Uncomment the slk_wset test which was previously commented out due
to incorrect output as this bug has been fixed.
* Added a check file to verify the slk_wset output.
2022-11-08 06:06:54 +00:00
msaitoh 175c89d22f Sync with if_dl.h rev. 1.31's change. 2022-11-07 08:34:30 +00:00
ozaki-r 3df6c9b812 tests: add tests for invalid extra operations on a shutdown socket
The tests cover some error paths that normally happen.
2022-11-04 08:01:42 +00:00
blymn a3f4239604 Update check files to allow for changes due to fixes to libcurses. 2022-11-04 06:17:58 +00:00
ozaki-r c3619612ae tests: add tests for TCP with nc 2022-11-02 09:37:56 +00:00
ozaki-r a18735eded tests: enable start_nc_server to have extra options for nc 2022-11-02 09:35:12 +00:00
msaitoh 838c32b638 Revert for if_dl.h's change. 2022-10-27 12:59:59 +00:00
msaitoh 5b130b9d06 Sync with if_dl.h rev. 1.29's change. 2022-10-24 13:42:55 +00:00
blymn 7adc35708b Updates to account for changes resulting from fixes to libcurses. 2022-10-19 06:10:43 +00:00
rillig ce87d2e53b tests/lint: add more examples for 'extra bits set to 0'
Seen in sys/external/bsd/compiler_rt/dist/lib/builtins/fp_lib.h:88.
2022-10-15 21:19:15 +00:00
knakahara ae6e8d4c4e Add test for sadb_x_policy->sadb_x_policy_flags. 2022-10-11 09:55:21 +00:00
ryo f5b5fa5b34 add tests for PR/57046. 2022-10-06 06:05:31 +00:00
rillig 55d487c96b lint: miscellaneous cleanup
No functional change.
2022-10-01 10:04:06 +00:00
rillig bb8d02713c lint: add hyphen to adjective 'old-style' 2022-10-01 09:42:40 +00:00
skrll d5bc748e3e toolchain/57033: usr.bin/c++/t_call_once2:call_once2_profile test case fails
Remove the -static flag I added because it doesn't fix anything and it
actually causes more problems.
2022-09-29 07:22:49 +00:00
skrll 745686120d toolchain/57033: usr.bin/c++/t_call_once2:call_once2_profile test case fails
Revive a missing space.
2022-09-28 11:09:59 +00:00
rillig 07d76dc41e tests/lint: fix test for queries on platforms where char is unsigned
error: queries.c(118): missing /* expect+1: implicit conversion
    changes sign from 'char' to 'int' [Q3] */
error: queries.c(122): missing /* expect+1: implicit conversion
    changes sign from 'char' to 'int' [Q3] */
2022-09-24 19:55:44 +00:00
knakahara 34a1a4b9aa tests: add tests for automatic route deletions on an address removal 2022-09-20 02:25:07 +00:00
rillig 0f43f630f1 tests/lint: fix test for queries on platforms where char is unsigned
These platforms reported an additional "implicit conversion changes
sign" in lines 105, 105, 118, 122.
2022-09-10 13:13:22 +00:00
rillig 6c259f3957 fix misspellings of 'available' and nearby typos 2022-09-10 12:14:17 +00:00
wiz ab1d953c71 grep: when -r is used, but no path argument provided, search the current dir
As discussed on tech-userlevel.
2022-09-09 22:14:28 +00:00
rillig 2676d01412 lint: rename dcs manipulation functions to be clearer
No functional change.
2022-08-28 08:41:06 +00:00
rillig c588212fb6 tests/lint: add more information to test for __attribute__((aligned))
Declaring an array type having a negative dimension is the simplest way
to embed an integer into a lint diagnostic, thereby revealing what size
and alignment lint has calculated for a struct.

While here, move these "compile-time assertions" closer to their
corresponding struct, to make reading easier.
2022-08-27 23:24:37 +00:00
rillig 68d3211991 tests/lint: add another test for aligned struct member
In the kernel, several structs have this attribute, and running lint on
them runs into a compile-time assertion.  Typical error messages are:

* error: illegal bit-field size: 255 [36]
* error: integral constant expression expected [55]
2022-08-27 21:59:41 +00:00
christos 5dd94c5e95 Add sincos{,f,l} from FreeBSD 2022-08-27 08:31:58 +00:00
rillig a649f3d0e9 lint: remove explicit list of known GCC attributes
Most GCC attributes consist of a single identifier.  Up to now, it was
necessary to list each of these identifiers in the grammar, even those
that only apply to a single target architecture.

Instead, parse the general form of attributes, matching the few
attributes that lint handles by name instead.  While here, rename the
grammar rules to use the GCC terms.

To avoid conflicts between the global function 'printf' and the GCC
attribute of the same name, do not add GCC attributes to the symbol
table, and don't make these symbols 'extern' either.

ok christos@.
2022-08-25 19:03:47 +00:00
mlelstv c0019d5261 requires pmap_private.h now. 2022-08-21 14:06:42 +00:00
rillig e8f3e4bdea lint: add more details to message about large bit-shifts 2022-08-19 19:40:39 +00:00
rillig a45115be53 tests/lint: demonstrate wrong warning about bit-shift 2022-08-19 19:13:04 +00:00
hannken e14a6c8694 When run from py-anita/amd64 this test fails with:
cgdconfig: getfsspecname failed: no match for `wd0e'

as the virtual machine has root on dk0, dk0 at wd0 and trying to
open wd0e fails.

This tests runs without a rump kernel and therefore should not
even try to open configured devices on the host.  Replace the
disks "wd0e" and "ld1e" with non-existant disks "dska" and "dskb".
2022-08-13 17:46:26 +00:00
isaki aa3450bc70 audiotest: Add two tests for AUDIO_SETINFO after mmap.
These tests affect only standalone test, not atf.
2022-08-13 07:22:40 +00:00
isaki 248c923741 audiotest: Fix typo in comments. 2022-08-13 07:19:15 +00:00
isaki 00cd774dfc audiotest: Separate mmap_len test by parameters.
This change affects only standalone test, not atf.
2022-08-13 07:14:40 +00:00
riastradh fdfb7cab0e membar(3): Fix t_spinlock for machines with hash-locked atomics.
Regular stores don't participate in the hash-locking scheme, so use
atomic_swap instead of a regular store here.
2022-08-12 11:21:44 +00:00
riastradh 920e28df65 cgdconfig(8): Add support for shared keys.
New clause `shared <id> algorithm <alg> subkey <info>' in a keygen
block enables `cgdconfig -C' to reuse a key between different params
files, so you can, e.g., use a single password for multiple disks.
This is better than simply caching the password itself because:

- Hashing the password is expensive, so it should only be done once.

  Suppose your budget is time t before you get bored, and you
  calibrate password hash parameters to unlock n disks before you get
  bored waiting for `cgdconfig -C'.

  . With n password hashings the adversary's cost goes up only by a
    factor of t/n.
  . With one password hashing and n subkeys the adversary's cost goes
    up by a factor of n.

  And if you ever add a disk, rehashing it will make `cgdconfig -C'
  go over budget, whereas another subkey adds negligible cost to you.

- Subkeys work for other types of keygen blocks, like shell_cmd,
  which could be used to get a key from a hardware token that needs a
  button press.

The <info> parameter must be different for each params file;
everything else in the keygen block must be the same.  With this
clause, the keygen block determines a shared key used only to derive
keys; the actual key used by cgdconfig is derived from the shared key
by the specified algorithm.

The only supported algorithm is hkdf-hmac-sha256, which uses
HKDF-Expand of RFC 5869 instantiated with SHA-256.

Example:

	algorithm aes-cbc;
	iv-method encblkno1;
	keylength 128;
	verify_method none;
	keygen pkcs5_pbkdf2/sha1 {
		iterations 39361;
		salt AAAAgMoHiYonye6KogdYJAobCHE=;
		shared "pw" algorithm hkdf-hmac-sha256
		    subkey AAAAgFlw0BMQ5gY+haYkZ6JC+yY=;
	};

The key used for this disk will be derived by

	HKDF-HMAC-SHA256_k(WXDQExDmBj6FpiRnokL7Jg==),

where k is the outcome of PBKDF2-SHA1 with the given parameters.

Note that <info> encodes a four-byte prefix giving the big-endian
length in bits of the info argument to HKDF, just like all other bit
strings in cgdconfig parameters files.

If you have multiple disks configured using the same keygen block
except for the info parameter, `cgdconfig -C' will only prompt once
for your passphrase, generate a shared key k with PBKDF2 as usual,
and then reuse it for each of the disks.
2022-08-12 10:49:17 +00:00
riastradh 732db29a3c cgdconfig(8): New -T operation prints all generated keys in cgd.conf.
For testing purposes.
2022-08-12 10:48:44 +00:00
riastradh a7c16118d0 cgdconfig(8): New -t operation just prints the derived key in base64.
For testing purposes.
2022-08-12 10:48:27 +00:00
charlotte f5524c7c97 Add a TNF copyright statement in t_mixerctl.sh 2022-08-10 00:14:22 +00:00
andvar b117086304 fix some typos and grammar in comments. 2022-08-07 10:12:19 +00:00
andvar 6478b40555 s/blity/bility/ in various words, mainly in comments. 2022-08-06 18:26:41 +00:00
kre 52acc68675 Provide _GNU_SOURCE for t_clone now that is required to make clone()
visible.
2022-08-01 15:48:39 +00:00
andvar 4fe346050d s/fucntion/function/ in comments. 2022-07-26 19:49:32 +00:00
riastradh 9f0a763c4a t_sig_backtrace: Pacify vfork clobber warning with volatile. 2022-07-25 22:43:01 +00:00
riastradh 2edbbc6f32 execinfo(3): Mark sig_backtrace_jump test as xfail.
PR lib/56940
2022-07-25 22:37:37 +00:00
riastradh d14f9f0135 execinfo: Fix mistake in previous: match `the_loop*' as prefix.
Now that there are two functions we need to catch either one.
2022-07-25 11:02:41 +00:00
riastradh 03353bf482 execinfo: Test stack traces through null pointer jump too. 2022-07-25 10:38:17 +00:00
kre fa7d65a3b6 Add ATF tests for realpath(1)
Note that realpath can act differently for root than for other users
(where an ordinary user will see EACCESS root just barrels right through).

The tests adapt themselves, when run as root, less error cases can be
tested than when run as some other user.
2022-07-21 09:52:48 +00:00
thorpej 75d451f371 Make kqueue event status for vnodes shareable, and for stacked file systems
like nullfs, make the upper vnode share that status with the lower vnode.

And, lo, NetBSD 9.99.99.

Fixes PR kern/56713.
2022-07-18 04:30:30 +00:00
rillig d39a56301d lint: add more details to message about pointer alignment
The previous message 'may cause alignment problem' was not detailed
enough to be actionable, it didn't give the necessary insight to why
lint was complaining at all.

The new message 'increases alignment from 1 to 4' or 'from 2 to 8'
describes the potentially problematic conversion, and together with the
involved type names, it allows an informed decision about whether lint's
warning is warranted or not.

In a typical NetBSD build, this warning is in the top 10.  The number of
these warnings depends on the architecture, it is typically between 800
and 1600.
2022-07-16 22:36:06 +00:00
rillig 238d676f52 lint: fix edge cases in the query for redundant cast before assignment
Casting from and to _Bool is only allowed outside strict bool mode.
Outside strict bool mode, _Bool is an integer type, therefore return
early if any of the operands has type _Bool.  In strict bool mode, even
casting from _Bool to _Bool is not allowed, as it is not needed in
practice.

Handle _Complex types before real floating-point types.  Return early
for _Complex types, as these are floating-point types as well.

For pointer casts, not only flag casts to or from 'pointer to void', but
also casts between the same types.

In debug mode, when constructing the type '_Complex float', the type
name of '_Complex' occurs in the debug log.  Outside of debug mode,
printing this type name is an error since this type keyword only occurs
internally, when constructing a type.  At that point, it is not supposed
to occur in any user-visible message.
2022-07-08 21:19:06 +00:00
rillig 9db688f9b4 lint: fix query for redundant cast before assignment
Previously, 'i = (int)dbl' was marked as redundant, even though it
performs a value conversion.
2022-07-08 20:27:36 +00:00
rillig 881bc41253 tests/lint: document why in ic_expr, '&' does not need before_conversion 2022-07-07 18:11:29 +00:00