Commit Graph

6682 Commits

Author SHA1 Message Date
rillig e572db3830 snprintb: error out on unknown new-style formatting directive 2024-03-04 21:35:28 +00:00
rillig 5926386128 lint: clean up string parsing and snprintb check 2024-03-03 16:09:01 +00:00
rillig 3d5fc26390 lint: warn about escaped snprintb directive
Repurpose message 362, as the previous version was redundant since null
bytes in old-style formats are already covered by message 371 (bit
position out of range) and 377 (redundant '\0' at the end).
2024-03-03 13:09:22 +00:00
rillig a8d07ea3d1 lint: fix warning about "empty" single-letter snprintb descriptions 2024-03-03 10:27:18 +00:00
rillig c9de07fbb0 lint: check for unreachable bits and fields in snprintb formats
While here, clean up a few existing checks.
2024-03-03 00:50:41 +00:00
rillig 1ec17c714c lint: check snprintb formats for overlapping bits and fields 2024-03-02 11:56:37 +00:00
rillig 38c0bdf232 lint: test format strings from snprintb calls
The functions snprintb and snprintb_m are specific to NetBSD, and their
format strings are tricky to get correct.  Provide some assistance in
catching the most common mistakes.
2024-03-01 19:39:28 +00:00
rillig 9e211f3599 tests/lint: remove redundant documentation 2024-03-01 17:22:55 +00:00
rillig d13846be6a tests/snprintb: clean up tests
Always write the value to be formatted in hexadecimal, to make it easily
distinguishable from the buffer size and maximum line length.

Use consistent wording in the comments of the test cases. Be stricter
about mistakes in a format.

Fix some wrong numbers in the snprintb_m tests for limited line length.
2024-02-24 13:00:00 +00:00
rillig e7ed3a67af snprintb: allow non-ASCII descriptions on all platforms
Previously, these descriptions were only allowed on platforms where
plain 'char' is unsigned. On platforms where plain 'char' is signed,
they invoked undefined behavior or terminated the output early.
2024-02-24 12:40:00 +00:00
rillig 69c5b3b0c1 snprintb: always null-terminate output
Always null-terminate the output in the buffer, even in error cases. The
wording in the manual page has been promising this since 2008. For
snprintb_m, ensure that the output is terminated with two null
characters, to gracefully handle situations in which the caller does not
check whether snprintb returned an error.

If the buffer size is zero, allow the buffer to be a null pointer,
analogous to snprintf.

Fix an out-of-bounds memory read if the bitfmt ends with a '*' directive
(since today).

In the tests, merge the helper functions for snprintb, snprintb_m, as
they were similar enough.

Fix a few 'line_max exceeded' tests, ensuring that they output a '#'
marker, and that the 'complete' tests don't.
2024-02-22 21:04:23 +00:00
rillig d101133e9b snprintb: error out on out-of-bounds bit shifts
Previously, these invoked undefined behavior, now they lead to an early
return. An example of out-of-bounds bit number is in SCZ_PCICTRL_BITS.
Bit fields that extend beyond the msb are still allowed.

Allow 'f' and 'F' to have fields that are 64 bits wide. This only makes
sense when the field starts at bit 0.

Remove the unused 'val_len', it was only needed before snprintb.c 1.20.
2024-02-22 18:26:15 +00:00
rillig c235936e8d tests/snprintb: test '=' and '*' directives that can never match 2024-02-20 21:45:36 +00:00
rillig 12034681d8 snprintb_m: limit length of generated strings
The manual page promises that the 'max' argument limits the length of
the generated strings, so don't generate any strings that are longer
than that limit. Mark incomplete strings with a trailing '#' to make
them easily recognizable.
2024-02-20 20:31:56 +00:00
rillig c38e738e50 tests/snprintb: fix out-of-bounds memory read (since 2024-02-16)
Before t_snprintb.c 1.20, the buffer size was required to be greater
than zero. Allowing the buffer size to be zero led to buf[-1] being
checked. On amd64, that byte happened to be 0, on i386 it didn't.

Fixes PR lib/57951.
2024-02-20 19:49:10 +00:00
riastradh fa59e25364 fenv(3): Fix fetestexcept to avoid side effects on trap state.
PR port-amd64/57949
2024-02-20 03:53:48 +00:00
rillig 8f391120f6 snprintb: fix how named bit-fields are split into multiple lines 2024-02-19 23:30:56 +00:00
rillig db5059c208 tests/snprintb: add more tests, especially for snprintb_m 2024-02-19 23:22:03 +00:00
riastradh 37dc27dad0 fenv(3): Add test for PR port-amd64/57949. 2024-02-19 23:19:10 +00:00
riastradh 3dfc28084a longjmp(3) t_sigstack: Fix fencepost error.
Extremely unlikely to cause trouble, but let's just turn that into
`never' to keep it easier for readers.

PR lib/57946
2024-02-19 19:43:27 +00:00
riastradh 9ba2d744e7 longjmp(3) t_sigstack: Use a sigaltstack per handler entry.
longjmp evidently doesn't reset the state of whether the process is
executing on the alternate signal stack.  So when we re-enter the
signal handler, the alternate stack appears to be still in use, and
the system chooses the original stack for the second call to the
signal handler -- which trips our assertion asking to verify that the
signal handler is always using an alternate stack.

Not strictly necessary for the signal handler to use an alternate
stack on re-entry, but this makes it clearer that the signal handler
itself is always using the alternate stack so we can verify that the
interrupted code is _not_ in the signal handler.

With this change, the test now passes on aarch64.

PR lib/57946
2024-02-19 13:34:48 +00:00
riastradh 81899325cc longjmp(3) t_sigstack: Note aarch64 seems to DTRT.
But only by code inspection; it appears to have another problem: on
re-entry, the signal handler is called on the normal stack, not on
the alternate signal stack.

PR lib/57946
2024-02-19 12:41:27 +00:00
riastradh 2bb6194384 longjmp(3) t_sigstack: Print which entry failed.
PR lib/57946
2024-02-19 12:41:19 +00:00
riastradh 3026ea4883 longjmp(3): Test signal mask vs stack restore with siglongjmp too.
PR lib/57946
2024-02-19 12:29:48 +00:00
riastradh 6514aab6b2 longjmp(3): Paranoia: more error checking in PR lib/57946 test. 2024-02-19 04:33:21 +00:00
riastradh a7b033762e longjmp(3): Add test for PR lib/57946. 2024-02-19 04:30:38 +00:00
rillig 0b94bf4814 snprintb: eliminate two local variables, allow zero-size buffer
Like snprintf, the buffer size may be zero. Unlike snprintf, the buffer
must not be NULL.
2024-02-16 19:53:40 +00:00
rillig c277ab1882 snprintb: fix integer overflow when writing past a small buffer
Previously, snprintb returned -1 in this case, assuming that the
snprintf used in FMTSTR validates against an overly large buffer size.
2024-02-16 19:20:38 +00:00
rillig 9ec1abff9d tests/snprintb: fix test for 8-bit field value
The previous version tested the behavior on a platform with signed
'char' before the portability fix.
2024-02-16 18:13:47 +00:00
rillig 889b1738f6 snprintb: fix '=' and ':' for 8-bit values on platforms with signed char
Previously, '=' and ':' worked only on platforms where plain 'char' is
unsigned. On platforms where plain 'char' is signed, only 7-bit values
worked.
2024-02-16 18:09:15 +00:00
rillig 935bb26983 tests/snprintb: clean up existing tests, add more tests
Due to the check that any bytes beyond the expected output must be
unmodified, there's no need anymore to explicitly write the "ZZZ" at the
end of the expected output. While here, remove the redundant trailing
"\0".

Add more tests to cover possible situations where an out-of-bounds write
may have occurred. In some cases, the line length specified in
snprintb_m is exceeded.
2024-02-16 01:19:53 +00:00
rillig 26844513e8 snprintb: fix string termination (since today)
In the previous commit, I had accidentally only run the tests for
snprintb_m but not those for snprintb, thereby missing a newly
introduced bug that would not null-terminate the resulting strings.

Add more tests to cover similar situations in which the buffer is too
small to contain the complete output.
2024-02-15 23:48:51 +00:00
rillig 795d5f45da snprintb: fix out-of-bounds write 2024-02-15 22:37:10 +00:00
rillig 1fb4457e9f tests/libutil/snprintb_m: add tests for small line length 2024-02-14 20:51:17 +00:00
andvar 1cd43426d5 Fix various typos in comments, log messages and documentation. 2024-02-10 18:43:51 +00:00
andvar 100a3398b8 fix spelling mistakes, mainly in comments and log messages. 2024-02-09 22:08:30 +00:00
rillig d06187ed85 tests/lint: sync test for integer constant type on ILP32 platforms
The test was broken since lex.c 1.214 from today.
2024-02-07 22:59:28 +00:00
rillig 26428579ad lint: unify rules for determining the type of an integer constant
Previously, in traditional C mode, large decimal numbers were treated as
unsigned, which disagreed with the book from 1978.
2024-02-07 07:42:50 +00:00
rillig 139c6401cd lint: warn about short octal escape followed by '8' or '9'
These mistakes is typically found in snprintb format directives but is
probably a typo everywhere else as well.
2024-02-03 20:10:10 +00:00
rillig 2b097c752f tests/lint: extend tests for hexadecimal character escapes 2024-02-03 19:18:36 +00:00
rillig 29354841ac lint: allow hexadecimal character escapes up to UINT_MAX
Previously, any value larger than INT_MAX was regarded as negative and
thus terminated the loop around get_escaped_char.
2024-02-03 18:58:05 +00:00
rillig 661078afe6 lint: remove unused code for converting multibyte character sequences 2024-02-03 10:56:18 +00:00
rillig c1862de9dd lint: allow larger numbers in escapes for wide characters and strings 2024-02-03 10:01:58 +00:00
rillig bc5123edee tests/lint: test octal escapes in character and wide strings 2024-02-03 09:36:14 +00:00
rillig 03951da31e lint: use the locale for interpreting wide character strings 2024-02-02 23:36:01 +00:00
rillig 3454588e0f tests/lint: test UTF-8 mode 2024-02-02 23:30:38 +00:00
rillig 708a1296c5 tests/lint: add UTF-8 test for string literals 2024-02-02 22:45:48 +00:00
andvar 34908c4889 fix various typos in comments. 2024-02-02 22:39:09 +00:00
andvar 82befdcba0 s/shold/should/ 2024-02-02 21:52:22 +00:00
rillig 183f84fe87 tests/lint: test lexing of characters and strings 2024-02-02 19:07:57 +00:00
rillig 8016349204 lint: fix debug output for strings, reduce code size
The debug output contained too many newlines.

The buffer functions were built into lint2 even though they weren't
used.

Enable the query for invisible characters in string literals, to make
sure that a newline in a string literal does not trigger that query.
2024-02-02 16:25:58 +00:00
rillig 402b4579b3 lint: make newline in a string literal an error in C90 and later 2024-02-02 16:05:37 +00:00
martin e9be82c8ac Skip the dtb set if the /boot partition is not mounted. 2024-01-30 16:57:32 +00:00
riastradh f17b3abd13 tests/usr.bin/mtree: Fixed the set lists, no more xfail.
PR misc/57877
2024-01-28 19:08:06 +00:00
rillig 7caac60117 tests/lint: enforce diagnostics to be listed in chronologic order
While here, fix the tests on uchar platforms.
2024-01-28 08:54:27 +00:00
rillig ea7127375b tests/lint: sort diagnostics in ilp32 tests chronologically 2024-01-28 08:26:07 +00:00
rillig d2c16d5796 tests/lint: sort multiple diagnostics per line chronologically
For now, the chronologic order is not enforced but has to be established
manually, for example by removing all 'expect' comment lines and
regenerating them with 'accept.sh -u'.

While here, clean up a few instances that came up when regenerating the
'expect' comments, such as wrong indentation or needless deviation from
the 'expect+1' form.
2024-01-28 08:17:27 +00:00
rillig 5357c932ab tests/lint: fix tests for integer constants on ILP32 platforms
The comment in msg_218 was both off-topic and wrong, so remove it.
2024-01-28 06:57:41 +00:00
rillig fc60683a64 tests/libutil/snprintb: remove redundant integer constant suffixes
I added these because lint told me so. Lint was wrong though, as it had
not implemented the C99 rules for integer constants.
2024-01-27 21:42:29 +00:00
rillig 8c7fbc585c lint: fix type of large integer constants 2024-01-27 20:03:14 +00:00
rillig a4d99aada1 tests/lint: test integer constants in different language levels 2024-01-27 15:10:56 +00:00
rillig 59290883cd tests/libutil/snprintb: fix test for 32-bit platforms 2024-01-27 10:32:03 +00:00
rillig c7aa2e0520 tests/libutil/snprintb: add more tests
Test all number bases (octal, decimal, hexadecimal), in both old-style
and new-style formats, as well as small buffer sizes.

Document working edge cases such as empty descriptions or descriptions
containing spaces, as well as situations that invoke undefined behavior.

Add comments to the individual test cases, as reading the actual format
strings takes more time.
2024-01-27 08:54:15 +00:00
riastradh e8c974429a tests/usr.bin/mtree: xfail PR 57877; omit needless debug print. 2024-01-26 00:32:46 +00:00
rillig efceecc2b3 tests/libutil/snprintb: clean up and extend tests
In case of a failure, print the details of the test case, including file
and line number of the actual test data. Do not write the format strings
directly to the output, as they contain non-printable bytes and embedded
null bytes.

After a failed test case, continue with the others.

Lay out the format strings according to their structure, to make them
more readable. Remove redundant "\0" at the end of the new-style format
strings.

Fix an off-by-one error in the test data: 0xf is FIFTEEN, not SIXTEEN.

Add a test for performing a restricted subset of rot13 in the format
string, to explore the limits of snprintb formatting.

What's still missing are tests for edge cases and error cases.
2024-01-25 18:13:14 +00:00
riastradh 00b317fce9 mtree(8): Test the installed sets.
Except etc and xetc, which likely won't match for reasons that aren't
great, like etc including empty log files which in an installed
system have probably changed.

This test will probably fail, but we should make sure it doesn't!

PR misc/57877
2024-01-25 00:30:57 +00:00
rillig 09702fc7eb lint: rename symt_t to symbol_kind
It was confusing to have two kinds of "symbol type" (s_type and s_symt),
so rename all related identifiers to be more distinctive.

No functional change.
2024-01-23 19:44:28 +00:00
christos 16b546eeb6 Add range tests with trailing characters. 2024-01-20 16:52:41 +00:00
rillig 45efdafbcc lint: add query for const automatic variables 2024-01-20 10:02:31 +00:00
rillig 6f23d4df44 lint: allow '\e' only in GCC mode 2024-01-19 19:23:34 +00:00
andvar b433853d68 s/rouding/rounding/ in test description. 2024-01-14 12:44:09 +00:00
rillig e1fc9df408 lint: warn about integer overflow when folding constant INT_MIN / -1 2024-01-11 20:25:04 +00:00
rillig 4b7b10e320 lint: allow complex offsetof(type, member-designator)
Both GCC 11 and Clang 8 accept member-designators that are not
identifiers but designator sequences, such as in 'offsetof(struct stat,
st_atim.tv_sec)', so make lint accept them as well.
2024-01-09 23:46:54 +00:00
rillig 059939593e tests/lint: fix overflow test for 32-bit platforms (since yesterday)
Plain integer constants without suffix are first tried to fit into
'int', then 'long', but not 'long long'.  This means that numbers larger
than 32 bits must be written with the LL suffix.
2024-01-08 17:11:32 +00:00
rillig cc3c7d5b6a tests/lint: test operators, integer overflow, conversions 2024-01-07 21:19:42 +00:00
rillig 74d7189882 lint: allow querying for invisible characters in literals and constants 2024-01-07 18:42:37 +00:00
rillig 7762dd1cfb lint: fix crash for invalid __func__ (since 2023-01-29) 2024-01-07 12:43:16 +00:00
rillig 08e0319cf4 lint: remove redundant parentheses, braces and comments
Rename the functions for folding constant expressions, to make the
comments redundant.
2024-01-06 15:05:24 +00:00
rillig 648e87c8ee tests/lint: add spaces to expected files, for better readability 2023-12-30 22:44:22 +00:00
rillig 588350fc12 tests/lint: sync comments in test for strict bool mode with reality 2023-12-30 17:09:42 +00:00
rillig dd2389327b lint: in strict bool mode, allow 'a & b' in controlling expressions
Previously, the expression 'a & b' was only treated as bool if 'a' had
enum type.  This didn't cover cases in which bit masks were implemented
using integer types instead of enum sets.
2023-12-30 15:37:27 +00:00
rillig 7252c1d112 tests/lint: test '&' for non-enum types in strict bool mode 2023-12-30 15:18:57 +00:00
martin 21ef827d2a PR 57803: fix typo in test title. 2023-12-30 13:09:24 +00:00
andvar 79548a514e s/synax/syntax/ in test description. 2023-12-28 20:04:10 +00:00
rillig b4747d0de9 tests/indent: don't create an unneeded file 2023-12-17 10:02:09 +00:00
mlelstv d233f49979 mmap() fails for size == 0 with EINVAL unless the mapping is anonymous. 2023-12-11 09:26:08 +00:00
rillig 35fd37d4b4 tests/libcurses: require 3 digits in octal character escapes
Previously, the string literal "\0" had been interpreted as "0", which
would have made the backslash redundant.  The tests don't use this form.
2023-12-10 18:04:55 +00:00
rillig 97817c96ae indent: be strict about options from profile files
Previously, the "option" 'xdi0' was treated the same as '-xdi0'.
2023-12-10 17:45:35 +00:00
rillig 08fd84594d tests/libcurses: constify 2023-12-10 15:51:13 +00:00
rillig 2209bb4284 tests/libcurses: fix typo in comment 2023-12-10 15:42:29 +00:00
rillig d7c2af39e9 tests/indent: fix name of test case 2023-12-10 15:39:25 +00:00
rillig 960c22026a lint: allow querying for 'static' followed by non-'static' declaration 2023-12-10 15:29:38 +00:00
rillig de4a7516ed lint: clean up comments
No functional change.
2023-12-10 14:59:47 +00:00
riastradh 29fd213712 t_setrlimit: Narrow the scope of stack-protector warning suppression. 2023-12-07 16:54:44 +00:00
rillig 0fde876303 tests/indent: test compound expressions 2023-12-03 14:26:10 +00:00
rillig 9cb5ea81fb tests/libcurses: sync documentation with reality
Unknown escape sequences in string literals trigger an error, since
testlang_conf.l 1.22 from 2021-02-25.

The '\b' is recognized since testlang_conf.l 1.26 from 2021-11-15.
2023-12-03 09:42:36 +00:00
rillig 8a47554360 tests/lint: add more test cases for nonportable character comparison 2023-12-02 23:54:49 +00:00
christos 20b493dddb remove dup copy. 2023-12-02 16:18:17 +00:00
christos 6a63b824ad PR/57735: Jose Louis Duran: mtree -f file1 -f file2 does not consider type
changes.
(FreeBSD https://github.com/freebsd/freebsd-src/commit/\
    4f4b548b1d21ae16955b09f9b717524167a7d97e)
2023-12-02 13:23:59 +00:00
riastradh 20941a42e9 pthread: Don't adjust user-allocated stack addresses by guardsize.
PR lib/57721

XXX pullup-10
XXX pullup-9
XXX pullup-8
2023-11-28 02:54:33 +00:00
riastradh a76ca770cc libpthread/t_stack: Fix format string for size_t.
Tested this on i386 since that had been crashing before, but i386
doesn't see %zu for unsigned int as a problem.

PR lib/57721

XXX pullup-10
XXX pullup-9
XXX pullup-8
2023-11-28 00:27:05 +00:00
riastradh 2852ab885f libpthread/t_stack: Appease gcc12 maybe-uninitialized warning.
The jmp_buf is not, in fact, uninitialized at the point of use, but
it doesn't hurt to narrow the scope a bit to between when the jmp_buf
is initialized by setjmp, and when the signal handler might be called
after sigaction.

Noted by prlw1.

PR lib/57721

XXX pullup-10
XXX pullup-9
XXX pullup-8
2023-11-27 22:18:29 +00:00
riastradh 1ce2050a8e libpthread/t_stack: Omit needless cast in previous.
Arose from an earlier draft of the change.

PR lib/57721

XXX pullup-10
XXX pullup-9
XXX pullup-8
2023-11-27 22:17:41 +00:00
riastradh 73a871b293 libpthread/t_stack: Make this more robust to the guard size bug.
Make sure to allocate enough space for the thread's stack for a guard
even though there shouldn't be one, so that when we run the thread,
it doesn't start with the stack pointer pointing into someone else's
allocation (like malloc) causing stack frames to trash another data
structure -- or causing the user of that data structure to trash the
stack frames.

PR lib/57721

XXX pullup-10
XXX pullup-9
XXX pullup-8
2023-11-27 22:15:08 +00:00
christos ecbffb52ab Don't use fmtcheck for strfmon format strings. It does not work. Fix a broken
test.
2023-11-27 19:45:36 +00:00
riastradh c73729f0bb t_dlinfo, t_rtld_r_debug: Audit ATF_REQUIRE/CHECK, sprinkle messages.
Make sure to use ATF_REQUIRE when the subsequent code doesn't work if
the check fails.
2023-11-24 17:40:20 +00:00
riastradh e441ef5517 rtld tests: Don't use RZ for dlinfo.
Use

	ATF_REQUIRE_EQ_MSG(dlinfo(...), 0, "dlinfo: %s", dlerror())

instead, in order to accurately report the error on failure.  RZ is
only for functions like pthread_create(3) that return zero on success
and errno(3) code on failure, but dlinfo returns -1 on failure and
sets dlerror() to report the nature of the error.
2023-11-24 17:40:09 +00:00
riastradh ef23f679e4 tests: Audit RZ abuse.
RZ succeeds if x is zero, and fails if x is nonzero, treating a
nonzero value as a error number as in errno(3) to print the message.

The following library routines instead return -1 on failure and set
errno to the error code:

fuse_opt_add_arg
fuse_opt_add_opt
fuse_opt_add_opt_escaped
fuse_opt_insert_arg
lseek
system

So use RL instead for those -- succeeds if x is zero, and fails if x
is -1.

This shouldn't make any tests newly fail or newly succeed -- the
functions in question only ever return 0 or -1 -- but if the tests
were already failing anywhere, they will now fail with meaningful
messages.

TBD: dlinfo, which isn't fit for RL or RZ since it reports errors via
dlerror() rather than errno.
2023-11-24 17:31:03 +00:00
christos e757b4ce33 t_setrlimit uses alloca now 2023-11-24 17:19:55 +00:00
riastradh 8f4b2a189f t_rnd: Nix trailing whitespace.
No functional change intended.
2023-11-24 16:36:23 +00:00
riastradh 290ca0f2a9 t_rnd: Fix misuse of RZ.
Not likely to matter, but in the unlikely event that rump_sys_close
fails, it will return -1 and set errno as RL expects, not return the
error code as RZ expects.
2023-11-24 16:35:51 +00:00
riastradh 5b36b4ea47 pthread: Add tests for pthread user stack allocation.
PR lib/57721

XXX pullup-10
XXX pullup-9
XXX pullup-8
2023-11-24 16:21:17 +00:00
riastradh 6cfac959ea t_setrlimit: Fix typos in comments and messages.
No substantive change intended.  Suggested by rillig@.

PR kern/57711

XXX pullup-10
XXX pullup-9
XXX pullup-8
2023-11-22 02:20:34 +00:00
riastradh bf53af405a exec: Map noaccess part of stack with prot=NONE, maxprot=READ|WRITE.
This way, setrlimit(RLIMT_STACK) can grant READ|WRITE access when
increasing the stack size.

PR kern/57711

XXX pullup-10
XXX pullup-9
XXX pullup-8
2023-11-21 00:09:18 +00:00
riastradh 2fb69068d1 t_setrlimit: Verify changing RLIMIT_STACK affects access to stack.
PR kern/57711

XXX pullup-10
XXX pullup-9
XXX pullup-8
2023-11-20 13:05:17 +00:00
riastradh 8328a6ed14 t_fdrestart: Mark some tests no longer xfail.
Backing out ad's changes last month seemed to fix the symptoms
(although I'm pretty sure this logic is still broken, more to come).

PR kern/57659
2023-11-18 19:46:55 +00:00
christos 8cbc788f24 PR/57689: RVP: getcwd() not overridable with -D_FORTIFY_SOURCE 2023-11-10 23:03:25 +00:00
riastradh 1eb7667c84 t_fenv: Factor checks out of switch in checkrounding.
No functional change intended, just tidies up a bit.

PR port-mips/57680

XXX pullup-10
2023-11-06 13:48:12 +00:00
riastradh 519833e0d7 t_fenv: Use volatile intermediate to force rounding to double.
See comment for details about why this is necessary.

Should fix these tests on i386 (and perhaps m68k too).

PR port-mips/57680

XXX pullup-10
2023-11-06 13:48:00 +00:00
riastradh 8fde1c3f4c t_fenv: Improve diagnostics when rounding mode tests fail.
Print the correct input, and print the rounding mode for clarity so
you don't have to cross-reference it by line number.

PR port-mips/57680

XXX pullup-10
2023-11-05 21:13:06 +00:00
riastradh 40e521dfc3 t_fenv: Add #pragma STDC FENV_ACCESS ON and verify FLT_RADIX is 2.
Except gcc doesn't implement this pragma, so make it conditional.

And clang only supports it on some architectures, so just leave it
out for now with a comment about why.

PR port-mips/57680

XXX pullup-10
2023-11-05 16:28:05 +00:00
riastradh f6d88030b5 t_fenv: Verify rounding mode takes effect.
At least for addition operations, anyway.

Somewhat redundant with the test t_fe_round added by maya@ but this
gives two minimal pairs to easily diagnose exactly what the rounding
mode is when the wrong one was selected.

PR port-mips/57680

XXX pullup-10
2023-11-05 16:06:27 +00:00
riastradh f7171b7a20 t_fenv: Check FLT_ROUNDS whenever we touch the rounding mode.
PR port-mips/57680

XXX pullup-10
2023-11-05 15:28:17 +00:00
riastradh 1865a6485e t_fenv: Print wrong values if tests fail.
XXX pullup-10
2023-11-05 15:27:40 +00:00
yamaguchi 63162a40fe Added the test for vlan over l2tp 2023-11-02 09:50:50 +00:00
rillig 49e867d6b1 tests/lint: test GCC attributes after abstract function type 2023-10-22 21:30:32 +00:00
rillig 0fce8157b2 tests/indent: clean up comments 2023-10-22 21:03:08 +00:00
rin fa6a6a38f1 ifconfig/t_capabilities: s/if_capabilities/if_capenable/ in message 2023-10-18 08:52:46 +00:00
rin e782b7c6e7 ifconfig/t_capabilities: Skip unless run_unsafe is configured to yes
The test modifies if_capabilities for all available interfaces.
This is not a behavior we expect for normal ATF runs.

Similar tests modifying living network configurations are already
skipped by default. This is the last one remained for ifconfig(8).

Also, I'm not sure whether this is a test for ifconfig(8).

XXX
Pullup to netbsd-10 ASAP. No other branches are affected.
2023-10-18 08:25:14 +00:00
yamaguchi e8037d3f57 Update the test case for MTU of lag to adapt new behavior 2023-10-18 06:41:00 +00:00
rjs 1b17496e10 The t_fdrestart test requires rump. 2023-10-17 13:51:52 +00:00
yamaguchi ca0a5f7dd4 Make the lagg interface up before change its MTU
This change is related to PR kern/57650
2023-10-16 07:57:40 +00:00
riastradh 349eda5c97 t_fdrestart: Rework this to be a little more robust.
For the write test, need to make sure the pipe's buffer is full first
before the write that blocks, so that it doesn't return partial
progress rather than ERESTART if woken.
2023-10-15 15:18:17 +00:00
riastradh d37c22e105 t_fdrestart: Verify rump_sys_write failed second time around.
PR kern/57659
2023-10-15 14:30:51 +00:00
riastradh 5ba0017fa5 t_fdrestart: New test of closing fd with another thread in I/O on it.
Adapted from regress/sys/kern/dislodgefd.

PR kern/57659
2023-10-15 13:22:52 +00:00
christos 9a3e6516d0 PR/57633: Jose Luis Duran: Add strfmon tests from FreeBSD 2023-10-14 20:19:31 +00:00
blymn fc8a227a5a Update check files affected by a fix to addbyte.c in libcurses. 2023-10-05 06:15:58 +00:00
christos 0630eb1ffb Add testing for pad resetting (Jose Luis Duran) 2023-09-28 13:31:11 +00:00
knakahara 4743d3462c Update for sys/net/if_ipsec.c:r1.35 2023-09-27 08:48:01 +00:00
kre 5ae58755a4 Perform quoting of variable expansions, etc correctly. That includes
(some) removing of quotes from where they're useless (superstition).

This should be NFC for these tests, as the data being quoted doesn't
happen to require it, but depending upon the data not altering, or the
code not being copied to a different environment is unwise, when it is
so easy to simply do it correctly.

A few line wrapping and white space changes as well.

Nothing changed here is intended to alter the way that the tests run,
or results generated.
2023-09-26 12:15:44 +00:00
gson d9ed1423c3 Don't expect the net/carp/t_basic/carp_handover_ipv6_halt_nocarpdevip
and carp_handover_ipv6_ifdown_nocarpdevip test cases to fail.  At
least on the TNF i386 and amd64 testbeds, they pass more often than
not since the commit of src/sys/netinet/ip_carp.c 1.119 by mlelstv on
2023.04.07.06.44.08.
2023-09-19 11:55:14 +00:00
rillig 4f890ce92c lint: fix wording of diagnostics about 'C99 extension'
The term 'extension' means an extension to a C standard.  C99 by itself
is not an extension but a revision of the C standard.
2023-09-14 21:53:02 +00:00
rillig a479246e62 lint: mark unreachable function call arguments as used as well
Previously, in a '?:' expression with a constant condition, the branch
that is not taken was skipped but any identifiers in there were intended
to be marked as used.  In function call expressions, this only worked
for the last argument, as the PUSH operator is not a binary operator
(see ops.def).  Cover this case as well.
2023-09-12 22:01:05 +00:00
rillig f88aa15bf2 lint: mark symbols that are only used in untaken '?:' branch as used 2023-09-12 07:23:27 +00:00
rillig 41bc0f7db1 tests/lint: show that '?:' skips untaken branches early
This is probably done to avoid wrong warnings from branches that are
only taken on other platforms, but it also generates a wrong 'unused'
warning.
2023-09-12 06:51:02 +00:00
rillig 855fdcf693 tests/lint: allow lint libraries to be installed 2023-09-07 06:24:31 +00:00
rillig a5de335bf3 tests/lint: test case labels with out-of-bounds values 2023-09-07 06:17:35 +00:00
mrg 27c7635cf1 apply previous to just GCC. 2023-09-05 22:14:08 +00:00
riastradh d946f6431e certctl(8): Fix permissions on ca-certificates.crt bundle: 0644.
While here, write it atomically: write to .tmp first, then rename
when done; this way applications never see a partially-written bundle
at /etc/openssl/certs/ca-certificates.crt.
2023-09-05 12:32:30 +00:00
riastradh aa907e4708 certctl(8): Test permissions of ca-certificates.crt.
Inadvertently created 0600 instead of 0644 due to copying file
created by mktemp(1) with cp(1).
2023-09-05 12:31:33 +00:00
mrg bd4c4b4eb0 apply -Wno-maybe-uninitialized to chacha_sse2.c.
there's a clearly initialised memory region that is claimed as
being maybe uninitialised, and this test-build version of it
triggers it while the normal build doesn't.
2023-09-05 04:22:44 +00:00
riastradh f76ba7ffef certctl(8): Fix quoting and whitespace style in evilpath test.
No functional change intended.
2023-09-02 17:42:01 +00:00
riastradh 2572d76403 certctl(8): Fix some bugs with evil pathnames. 2023-09-02 17:41:43 +00:00
riastradh 4e4b90f7ff certctl(8): Test more evil pathnames. 2023-09-02 17:41:33 +00:00
riastradh 1cac5d57e4 certctl(8): Avoid clobbering prepopulated /etc/openssl/certs.
Also avoid clobbering some other edge cases like symlinks or
non-directories there.

This way, we have the following transitions on system updates:

- If /etc/openssl/certs is empty (as in default NetBSD<10 installs):
  quietly populated on rehash.

- If /etc/openssl/certs is nonempty (you've added things to it,
  e.g. by hand or with mozilla-rootcerts) and has never been managed
  by certctl(8): left alone on rehash, with an error message to
  explain what you need to do.

- If /etc/openssl/certs has been managed by certctl(8): quietly
  updated on rehash.

Note: This means current installations made since certctl(8) was
added will be treated like /etc/openssl/certs is nonempty and has
never been managed by certctl(8).  To work around this, you can just
delete /etc/openssl/certs and rerun `certctl rehash'.
2023-08-28 22:25:49 +00:00
riastradh 9189de7638 certctl(8): Test prepopulated /etc/openssl/certs.
This is the scenario when you have previously populated
/etc/openssl/certs manually, or with a package like mozilla-rootcerts
or mozilla-rootcerts-openssl, and you update to a version of NetBSD
with certctl(8).  In this case, certctl(8) should avoid destroying
your work.

While here, also test some related but less likely edge cases:

- nonexistent
- symlink
- regular file
2023-08-28 22:25:41 +00:00
riastradh 3d4f065740 certctl(8): Exit nonzero on missing certs.conf. 2023-08-28 22:25:32 +00:00
riastradh e1aab3dc32 certctl(8): Add xfail test for missing certs.conf.
Command should fail, i.e., exit with nonzero status, but it exits
with zero instead.
2023-08-28 22:25:21 +00:00
rillig dcb32fd76a lint: make diagnostics about ANSI C more international 2023-08-26 10:43:53 +00:00
rillig 92925e854e tests/usr.bin/error: add basic tests for several error message styles 2023-08-26 10:06:16 +00:00
riastradh 50a8b41245 certctl(8): New tool for managing OpenSSL CA certificates.
Same command-line syntax as FreeBSD, clearer semantics about which
parts are config and which parts are cache.
2023-08-26 05:27:13 +00:00
rin 1330871fbe t_ptrace_core_wait.h: Increment PC after trap, also for riscv
Fix *:core_dump_procinfo tests for riscv64.
2023-08-24 05:55:25 +00:00
rin d1f3632e87 riscv: tests/lib/csu: Fix typo in check_stack_alignment()
Now, all tests in tests/lib/csu successfully pass for riscv64.
2023-08-24 05:51:55 +00:00
rillig eb08e01b67 tests/compat/linux: fix typo in comment 2023-08-23 20:05:05 +00:00
christos a7f1bde315 Remove PROGDPLIBSSTATIC from ec and threads; dh still needs it because it
references internal symbols in libcrypto like ossl_dh_compute_key which
have been made static by the linker script (they are still visible in the
archive version).
2023-08-22 17:27:48 +00:00
rin 9b45ffed94 t_ipsec_{gif,l2tp}: Adjust for tcpdump 4.99.4
It does not longer output redundant `` (ipip-proto-4)'':
cba9b77a98

Now, these tests become passing again.

Thanks mlelstv@ for finding out upstream commit.
OK ozaki-r@
2023-08-22 05:40:50 +00:00
christos b7a2c5757f Tests for the compat_linux inotify framework from GSoC 2023 (Theodore Preduta) 2023-08-19 22:56:43 +00:00
christos 3a3e6e6861 Update link. We should also update the data... 2023-08-15 19:05:41 +00:00
riastradh 8a22324f3b vis(3): Fix one more buffer overrun in an edge case.
PR lib/57573

XXX pullup-10
XXX pullup-9
XXX pullup-8
2023-08-12 12:48:52 +00:00
riastradh 6d340e9776 vis(3): Fix main part of PR lib/57573.
From Kyle Evans <kevans@FreeBSD.org>.

XXX pullup-10
XXX pullup-9
XXX pullup-8
2023-08-12 12:48:37 +00:00
riastradh ad713b59f2 vis(3) tests: Test another overflow edge case.
Related to PR lib/57573.

XXX pullup-10
XXX pullup-9
XXX pullup-8
2023-08-12 12:46:16 +00:00
riastradh 4d342ca518 vis(3) tests: Expand tests and diagnostic outputs on failure.
PR lib/57573

XXX pullup-10
XXX pullup-9
XXX pullup-8
2023-08-12 12:45:03 +00:00
riastradh db2eb9a062 vis(3) tests: Add xfail test for encoding overflow.
From Kyle Evans <kevans@FreeBSD.org>.

PR lib/57573

XXX pullup-10
XXX pullup-9
XXX pullup-8
2023-08-12 12:43:26 +00:00
rillig fdd1c40690 tests/lint: test parsing of preprocessing directives 2023-08-11 04:27:49 +00:00
riastradh 78e153c0eb workqueue(9) tests: Fix mistake in rev. 1.9.
Somehow, despite manually verifying a build/install/test of every
revision in my patch series, I managed to commit the wrong version of
the file for what became rev. 1.9, so the test was just broken when
it went in and remained broken in the commit where I fixed the real
bug and removed the xfail marker on the test.

PR kern/5757

XXX pullup-10
XXX pullup-9
XXX pullup-8
2023-08-10 22:20:20 +00:00
mrg 251ecc35b2 make this build with GCC 12.
there are some odd constructs here to trigger sanitizers.
2023-08-10 20:44:37 +00:00
riastradh 53a88a4133 workqueue(9): Avoid touching running work items in workqueue_wait.
As soon as the workqueue function has called, it is forbidden to
touch the struct work passed to it -- the function might free or
reuse the data structure it is embedded in.

So workqueue_wait is forbidden to search the queue for the batch of
running work items.  Instead, use a generation number which is odd
while the thread is processing a batch of work and even when not.

There's still a small optimization available with the struct work
pointer to wait for: if we find the work item in one of the per-CPU
_pending_ queues, then after we wait for a batch of work to complete
on that CPU, we don't need to wait for work on any other CPUs.

PR kern/57574

XXX pullup-10
XXX pullup-9
XXX pullup-8
2023-08-09 08:23:13 +00:00
riastradh f8e8b7bf19 workqueue(9) tests: Add test for PR kern/57574.
XXX pullup-10
XXX pullup-9
XXX pullup-8
2023-08-09 08:23:02 +00:00
riastradh aab7c67520 workqueue(9) tests: Destroy struct work immediately on entry. 2023-08-09 08:22:53 +00:00
riastradh a8809f1847 workqueue(9) tests: Nix trailing whitespace. 2023-08-09 08:22:43 +00:00
riastradh c6ab813da9 tests/rump/rumpkern: Use PROGDPLIBS, not explicit -L/-l.
This way we relink the t_* test programs whenever changes under
tests/rump/kernspace change libkernspace.a.
2023-08-09 08:22:33 +00:00
rillig 7e8e260d9f lint: in -a mode, do not warn about integer conversions from 'int'
Since tree.c 1.552 from 2023-07-08, lint warned about integer
conversions from 'int' or 'unsigned int' to smaller integer types.  This
only affected 32-bit platforms where size_t is 'unsigned int' rather
than 'unsigned long', as on these platforms, the integer ranks of 'int'
and 'long' are the same, see INT_RANK in inittyp.c.

Discovered by lib/libkvm, which fails on i386 when lint generates any
warnings.
2023-08-08 20:15:10 +00:00
rillig 53d7accc5b tests/lint: test integer conversions on ilp32 int platforms 2023-08-08 19:57:23 +00:00
riastradh d3dc0d63ee t_cdb: No need for weird padding any more.
cdbw_output never needed it at runtime, and the declaration no longer
makes gcc angry about not having it.
2023-08-08 10:36:17 +00:00
mrg 832d47522a introduce new GCC 12 warning disables and use them in a few places
this introduces 4 new warning disable flags:

   CC_WNO_MISSING_TEMPLATE_KEYWORD
   CC_WNO_REGISTER
   CC_WNO_STRINGOP_OVERREAD
   CC_WNO_ARRAY_BOUNDS

and documents them in README.warnings.  of these, the string op
and array bounds are both problematic (real bugs) and also spurious
(not real bugs), and the other 2 are mostly temporary for older
3rd party code.

add some new uses of CC_WNO_STRINGOP_OVERFLOW.

fix m68k build for gallium and GCC 12.
2023-08-08 06:27:31 +00:00
mrg e58149cdf7 avoid uninitialised variable.
found by GCC 12.
2023-08-07 23:29:58 +00:00
rillig 26eb44f64d tests/lint: show that portable mode depends on PTRDIFF_TSPEC
Since 2023.07.08.12.45.43, lint warns in lib/libkvm on i386.
2023-08-07 22:30:38 +00:00
rin a65365b875 t_asan_global_buffer_overflow: Avoid ODR Violation for pic variants
Common symbol triggers ODR (One Definition Rule) Violation correctly,
instead of Global Buffer Overflow.

XXX
Add test for odr_violation.
2023-08-07 00:54:54 +00:00
rillig fe7ce87087 lint: since C99, a non-void function must return a value 2023-08-06 19:44:50 +00:00
rillig dca1e8c791 tests/lint: document how much of C99 lint already implements 2023-08-06 19:31:06 +00:00
riastradh cdd57aa330 tests/crypto/opencrypto: test_asymfeat requires privileges. 2023-08-05 13:29:57 +00:00
riastradh d493b3c627 tests/net/inpcb: Tests require root. 2023-08-05 13:25:26 +00:00
riastradh 5b1bee9cea tests/net/net/t_bind: IP_BINDANY and IPV6_BINDANY require root. 2023-08-05 13:22:49 +00:00
riastradh 23336793ae tests/lib/librumphijack: Avoid trying to run rpcbind as non-root.
Can probably make this work through rumphijack, but there's no sense
in even trying the test if we can't, so let's reduce the unprivileged
false alarms.
2023-08-05 13:13:37 +00:00
riastradh 1f0bb15ec8 tests/lib/libnvmm: Tests require privileges. 2023-08-05 13:05:14 +00:00
riastradh ea54f3e2ea t_nullmnt: Need privileges for mount.
(unless vfs.generic.usermount=1 but let's keep it simple)
2023-08-05 13:01:06 +00:00
riastradh 0351610f0a tests/include/t_paths: Test all paths, nonfatally.
This way a single failure doesn't suppress failure reports for all
the other paths to test.

Omit some needless blank lines while here.
2023-08-05 12:11:05 +00:00
riastradh 3f8fc68fb9 tests/include/t_paths: /dev/ksyms requires root. 2023-08-05 11:59:09 +00:00
rillig 8d2e8478af lint: implement __builtin_offsetof for the simplest cases
Cases not covered:
1. C99 allows designators in the offsetof macro.
2. For packed types, the offset is likely to be incorrect.
2023-08-05 10:13:39 +00:00
rillig 2d4c92c54f tests/lint: fix test for packed structs on 32-bit platforms 2023-08-05 10:00:59 +00:00