Commit Graph

6611 Commits

Author SHA1 Message Date
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
rillig 222dcfd4cf tests/lint: test C99 printf conversion specifiers in lint2 2023-08-05 09:44:18 +00:00
riastradh cf9621ed16 memfd(2): Run all tests; don't stop after the first failure. 2023-08-05 08:05:16 +00:00
rin 2c57825720 t_siginfo:sigfpe_int: Adjust for GCC12
Do not use constant 1 as numerator to raise integer division by zero.
GCC >= 12 optimizes (1 / i) into (abs(i) == 1 ? i : 0), even for -O0.
2023-08-04 03:31:13 +00:00
andvar 506971ff58 fix typos in comments and one definition, mainly s/sucket/socket/. 2023-08-03 20:45:49 +00:00
rillig 0448d06008 lint: make '_Static_assert' only available in C11 or C23 mode 2023-08-03 18:48:42 +00:00
nia e6ea867424 Revert addition of epoll to libc until discussion concludes 2023-08-03 12:24:46 +00:00
rin 2fd4746018 audiotest: Appease GCC 12.3.0 -Wmisleading-indentation
It does not matter whether this statement is a part of this if-then
block or not, anyway. No binary changes.
2023-08-03 08:36:38 +00:00
rin bfa63a7066 t_etfs: Skip large_blk for system with page size > 8192
Work around kernel freeze reported as PR kern/55658 for
powerpc/ibm4xx (16K pages)
2023-08-03 03:21:56 +00:00
rin a5ca3916c3 t_getrandom: Fix false positives for short read(2)
This only affects really slooooow machines, 68030 for me :)
2023-08-03 03:18:12 +00:00
rillig 5e813441c0 lint: fix handling of unnamed function parameters 2023-08-02 21:11:35 +00:00
rillig f2bab28745 lint: fix plural form in message 150 2023-08-02 18:57:54 +00:00
rillig 039b010016 lint: distinguish between arguments and parameters 2023-08-02 18:51:25 +00:00
rillig 9192ff1d13 lint: simplify handling of old-style arguments 2023-08-02 05:44:27 +00:00
gutteridge c14f999a4e t_pollts.c: fix typo in a description string (NFC) 2023-08-01 23:41:54 +00:00
andvar 1e7139f024 fix RCSIDs. 2023-08-01 20:09:12 +00:00
rillig b525fc25f4 tests/lint: test packed and in-parameter declarations 2023-08-01 19:52:15 +00:00
mrg 1115bcb541 cdbw_output()'s 3rd argument must be a 16-byte char array, so pad the
string literals passed to it with enough nuls to make this true.

found by GCC 12.
2023-08-01 07:57:17 +00:00
rillig 322d30b80f tests/lint: test symbol lookup in unnamed bit-field member declaration 2023-07-31 20:52:26 +00:00
rillig ce02e259a4 lint: fix assertion failure after unnamed bit-field member
Since 2023-07-15.
2023-07-31 20:31:58 +00:00
christos 2c545067c7 Add EPOLL_CLOEXEC (Theodore Preduta) 2023-07-30 18:31:13 +00:00
riastradh 3b7c09b692 ld.elf_so: Add some known-answer tests for hash functions.
Make sure the testing mechanism detects the traditional overflow bug.
2023-07-30 09:22:02 +00:00
rin 123e052909 t_memfd_create: Fix printf-like format by using %zu for size_t, and
%jd for off_t with cast to intmax_t, respectively.
2023-07-29 16:24:35 +00:00
christos d3ba7ba3a2 Add tests for t_memfd_create and fix bug found by tests 2023-07-29 12:16:34 +00:00
rillig ed9a7a8560 lint: condense code for ending a function
No functional change.
2023-07-29 07:49:14 +00:00
rillig 6383202121 tests/lint: test declarations in C11 and C23 2023-07-28 22:05:44 +00:00
christos d11110f473 Add epoll(2) from Theodore Preduta as part of GSoC 2023 2023-07-28 18:18:59 +00:00
rillig cbde550f0f lint: allow 'thread_local' to be combined with 'static' 2023-07-25 16:56:35 +00:00
rillig 5008d0bca1 lint: reword message about non-constant initializer 2023-07-21 06:02:07 +00:00
rillig 6d841877fb tests/lint: document an example of a non-constant initializer 2023-07-21 05:51:12 +00:00
mrg 7ab3f5c310 provide more things needed by new subr_prf.c. 2023-07-18 06:37:55 +00:00
rillig 1e05010e5d lint: each member declarator may have attributes, not only the last one 2023-07-15 21:47:35 +00:00
rillig c147c2e884 tests/lint: test GCC attributes in member declarations 2023-07-15 21:40:03 +00:00
rillig df9c24dec3 lint: allow 'extern' and 'thread_local' to be combined 2023-07-15 16:17:37 +00:00
rillig c68209d3ed tests/lint: test 'extern thread_local' storage classes
Seen in external/mpl/bind/dist/lib/isc/pthreads/include/isc/thread.h:32.
2023-07-15 16:11:32 +00:00
rillig 914dc1bf88 lint: fix member lookup after GCC statement expression 2023-07-15 14:54:31 +00:00
rillig 9a2539b9eb lint: fix use-after-free bug in GCC statement expressions 2023-07-15 13:51:36 +00:00
rillig ef4646fea8 tests/lint: demonstrate use-after-free in GCC statement expression 2023-07-15 12:24:57 +00:00
rillig 2ab89be182 tests/lint: document how to reliably crash lint1 after a parse error 2023-07-15 09:53:46 +00:00
rillig b956127314 lint: add debug logging for memory management and the symbol table 2023-07-15 09:40:36 +00:00
rillig 95638de25a lint: clean up comments, add a test for the '?:' operator 2023-07-14 08:53:52 +00:00
rillig b81e1a9edf tests/lint: test duplicate type qualifiers in pointer types 2023-07-13 22:44:10 +00:00
riastradh 07b9e924e1 t_bitops: Show the bad results on failure. 2023-07-13 20:39:24 +00:00
rillig 78e3dd62e3 lint: in C23 mode, recognize the keyword 'thread_local' 2023-07-13 20:30:21 +00:00
rillig fe2ba0d5e5 lint: _Thread_local is a storage class, not a type qualifier 2023-07-13 19:59:08 +00:00
rillig bc10e9be9d lint: reject _Noreturn if it occurs in invalid places
C11 introduced _Noreturn as a function-specifier, not as a type
attribute.  The latter may occur in more places.
2023-07-12 18:26:04 +00:00
rillig 5e96f60f79 tests/lint: add test for _Noreturn from C11 2023-07-12 18:13:39 +00:00
rillig 032c24b4d9 lint: update wording in diagnostic for C99 2023-07-11 20:54:23 +00:00
riastradh a41503c83d t_clock_gettime: Avoid signed/unsigned comparison. 2023-07-09 19:19:40 +00:00
rillig 62071d8c64 lint: in the warning about ordered enums, mention the affected type 2023-07-09 12:04:08 +00:00
rillig ea3322651c lint: clean up wording in diagnostics
Use the term 'parameter' as defined in C99 3.15.
2023-07-09 11:18:55 +00:00
rillig a194378b9e lint: clean up the wording of a few diagnostics 2023-07-09 11:01:27 +00:00
rillig 4a29af3e7e lint: remove redundant '#' after 'argument' in diagnostics 2023-07-09 10:42:07 +00:00
riastradh 42ba7a81e2 clock_gettime(2): Fix CLOCK_PROCESS/THREAD_CPUTIME_ID.
Use same calculation as getrusage, not some ad-hoc arithmetic of
internal scheduler parameters that are periodically rewound.

PR kern/57512

XXX pullup-8
XXX pullup-9
XXX pullup-10
2023-07-08 20:02:10 +00:00
rillig 486fcaa047 lint: warn about pointer casts between different kinds of types
Pointer casts from an integer type to a floating-point type and vice
versa get a 'maybe troublesome' warning now.  The previous assumption
that all types of the same bit-size are convertible may have been valid
from a technical point of view, but still such code should get more
attention.

The rules for struct and union types could be made more fine-grained
later, if the need arises.  To suppress this warning, it's always
possible to cast to an intermediate 'void *'.
2023-07-08 16:13:00 +00:00
riastradh d60bdbc1da t_timerfd: Sprinkle slightly more diagnostics.
Might help us to see if we're off by just a little bit (maybe a tiny
jitter between the hardclock timer and the monotonic clock), or if
something is seriously amiss when the timerfd_block test fails
sporadically.
2023-07-08 15:32:58 +00:00
rillig a03d49bac0 lint: do not use portable type sizes in integer constraints
This reverts the change from tree.c 1.547 from 2023-07-03.  Back then, I
didn't know that the actual value from a type's 'portable size in bits'
was not supposed to be used.
2023-07-08 15:26:25 +00:00
riastradh 3fe2e0724d t_clock_gettime: Add test for PR kern/57512. 2023-07-08 14:05:51 +00:00
rillig 1d389f0fa4 lint: warn about conversion from 128-bit to smaller integer types 2023-07-08 12:45:43 +00:00
rillig 5bb571bbdc tests/lint: demonstrate missing warning for converting int128_t 2023-07-08 12:42:11 +00:00
rillig 1d1794a80f tests/lint: fix a few ilp32 tests 2023-07-08 11:03:00 +00:00
rillig 223ac6e8ac tests/lint: automate accepting changed test results 2023-07-08 10:01:17 +00:00
rillig afb87394f6 tests/lint: only overwrite .exp files if the output actually changes 2023-07-08 08:02:45 +00:00
rillig e6298b924c lint: warn about function definitions without header declaration
The existing warning was only issued for function declarations, not for
function definitions.

The interesting change in the tests is in msg_351.c.  Many other tests
use non-static functions due to their syntactic brevity.  In these
tests, the warning is disabled individually, to allow new functions to
be added without generating warning 351.
2023-07-07 19:45:22 +00:00
rillig 06b8093259 lint: only skip 'unused' warnings after errors, not other warnings
Previously, in -w mode, any warning suppressed further 'unused'
warnings, even though there was no need to do that.  This can be seen in
the test gcc_attribute_var.c, where only the last unused variable from a
function was marked as unused, the others slipped through.

Fixed by counting the errors and the warnings separately and only
combining them if actually desired.
2023-07-07 06:03:31 +00:00
rillig 62962fdef2 tests/lint: test all combinations of {func,obj}_{decl,def}
For a non-static function definition that is not declared in a header,
lint doesn't currently warn.  The previous test didn't notice this.
2023-07-07 00:25:23 +00:00
rillig a9b749ce7a tests/lint: merge duplicate tests for C11 _Atomic 2023-07-07 00:20:39 +00:00
riastradh 7d87cccbb2 t_sig_backtrace: Flush stdout before writing to STDOUT_FILENO.
Avoids confusing ordering of output.
2023-07-06 20:44:55 +00:00
rillig bff65bdad9 tests/lint: ensure consistent preprocessor filenames in tests
The deviations often happen when copying or renaming tests.
2023-07-06 07:33:36 +00:00
riastradh d2876e0fc7 tests/libexec/ld.elf_so: Fix helper library makefiles.
1. Consolidate logic into a single helper.mk to reduce duplication.
2. Set NO* variables, not MK* variables which are reserved for user.
3. Avoid eager X!= in favour of lazy ${X:sh}.
4. Mark _g.a set list entries obsolete.  Never should've been built!

PR misc/57462
2023-07-05 22:42:46 +00:00
riastradh bf2cc18785 t_posix_memalign: Simplify.
No functional change intended.
2023-07-05 12:09:39 +00:00
riastradh ec5bc5eca5 t_posix_memalign: Fix this to reflect restriction lifted in C17. 2023-07-05 11:43:05 +00:00
rillig 1603ef6585 tests/lint: spell platform identifiers for 'long double' consistently
The test file names don't have a hyphen, so the identifiers shouldn't
have one either.
2023-07-05 11:42:14 +00:00
rillig 581fbf1bfe tests/lint: add platform-specific tests for troublesome pointer casts 2023-07-05 11:36:56 +00:00
riastradh 50dbd23a19 t_posix_memalign: Expand test cases and properties.
- Test cartesian product of a sampling of sizes and a sampling of
  alignments.

- Verify all the edge cases I could find in posix_memalign and
  aligned_alloc, including failure modes.

- Test an unreasonably large (but aligned) allocation size.

- Use ATF_CHECK_* instead of ATF_REQUIRE_* so all failures will be
  reported, not just the first one.

- While here, build with -fno-builtin-aligned_alloc and with
  -fno-builtin-posix_memalign to make sure the compiler doesn't try
  any shenanigans.

XXX pullup-10
2023-07-04 15:06:36 +00:00
rillig 353545ac36 lint: consistently use portable type size in integer constraints
Since tree.c 1.546 from 2023-07-03, lint no longer warned about possible
loss of accuracy when converting from 'long' to 'int' on an ILP32
platform that uses 'unsigned long' for size_t, when run in portable mode
(-p), which is enabled by default in the NetBSD build.

The integer constraints avoid false-positive warnings by looking at the
actual values an expression can take.  The function can_represent is
guarded by a condition that uses the portable_size_in_bits, but then
internally used the opposite size_in_bits, which led to inconsistent
results.

The warning looks confusing though, as on an ILP32 platform, 'int' and
'long' have the same size and representation, therefore there cannot be
an actual loss of accuracy.  The warning may need to be reworded to
explicitly mention the portability mode, in which sizeof(int) is assumed
to be 3 instead of 4, to catch possible loss of accuracy on other
platforms.
2023-07-03 21:36:16 +00:00
rillig 2bb36c1110 tests/lint: move platform-specific query tests to separate files
This fixes the tests on 'unsigned char' platforms.

Thanks martin@ for the notification.
2023-07-03 15:29:42 +00:00
rillig e5eea854b3 tests/lint: clean up tests for C99 bool 2023-07-03 09:37:14 +00:00
rillig 10bd4ec804 lint: fix C11 mode to not allow C23 features (since yesterday) 2023-07-03 09:33:07 +00:00
rillig 4f51279e58 lint: rename uppercase QUAD to LLONG
No binary change.
2023-07-03 07:03:19 +00:00
rillig a615f06cd9 tests/lint: add C23 tests 2023-07-02 23:45:10 +00:00
rillig 29b0195f9b lint: add initial support for C23
Required by xsrc/external/mit/MesaLib.old, brw_eu_validate.c, which
initializes a struct using empty braces: 'return (struct string){};'.
2023-07-02 23:40:23 +00:00
rillig e16f398bf1 lint: allow empty statements in GCC statement expressions 2023-07-02 22:56:13 +00:00
rillig 6ab24c0b4d tests/lint: demonstrate empty statement in GCC statement expression
Seen in external/mit/xorg/lib/dri.old.
2023-07-02 22:50:18 +00:00
rillig ad4700f62b lint: rename 'quad' to 'signed int' or 'unsigned int'
No functional change.
2023-07-02 18:14:44 +00:00
rillig 600fe2a7c7 tests/lint: rework tests for type names 2023-07-01 20:57:37 +00:00
rillig c6d4ed97fd lint: clean up typos 2023-07-01 09:21:31 +00:00
rillig 130b20d8de lint: fix initialization of unnamed union member 2023-07-01 06:09:24 +00:00
rillig 91f591a176 tests/lint: test initializing an unnamed union 2023-06-30 22:27:47 +00:00
rillig c7c89cb5fa lint: clean up names related to declaration levels
The previous prefix 'DK_' (declaration level kind) had a conflict with
the 'DK_' (designator kind) in init.c, so change the prefix to 'DLK_'.
The new name for dinfo_t is decl_level, which is more expressive.

No functional change.
2023-06-30 21:39:54 +00:00
rillig e50dbdf451 lint: fix handling of unnamed struct/union members
The support for unnamed struct/union members that was added in decl.c
1.60 from 2015-10-13 was simple but wrong. It didn't cover initializers
of these structures and computed wrong sizes for structures containing
anonymous unions. At that time, the handling of initializers was broken
as well, it was fixed 6 years later in init.c 1.229 from 2021-12-22.

Real-life examples for code that lint couldn't handle are:

	* external/bsd/jemalloc/dist/src/jemalloc.c
	* external/mit/xorg/lib/dri.old/Makefile
2023-06-30 21:06:18 +00:00
rillig f6c9a3ff5c lint: clean up handling of declarations
No functional change.
2023-06-30 19:10:49 +00:00
rillig fc9c97fa4c tests/lint: extend tests for sizeof and alignof 2023-06-30 16:39:17 +00:00
rillig cb8166a1d1 lint: fix computation of bit-field width
When bit-fields in packed structs were added on 2009-10-02, lint assumed
that they would only use 'signed int' or 'unsigned int' as storage unit,
even though C99 also allows _Bool.

The cleanup commit for decl.c 1.225 from 2021-08-28 accidentally changed
the rounding mode for bit-field storage units from round-up to
round-down.
2023-06-30 15:19:09 +00:00
rillig 9ae9809bbf lint: make alignof(incomplete enum) an error 2023-06-30 09:26:03 +00:00
rillig bf86468d4c tests/lint: add more tests for sizeof, offsetof, alignof 2023-06-30 09:21:52 +00:00
rillig 082684fd88 lint: add query for assigning an integer 0 to a pointer 2023-06-30 08:45:22 +00:00
rillig 7aaf3a0593 tests/lint: extend test for sizeof and offsetof 2023-06-30 08:03:01 +00:00
rillig 10704a6fff tests/lint: demonstrate bugs in anonymous struct/union handling 2023-06-30 07:18:02 +00:00
rillig aca02333cc tests/lint: demonstrate wrong size calculation in anonymous union 2023-06-28 21:41:27 +00:00
rillig 87eefb9092 tests/lint: do not overwrite expected files that only differ in spaces 2023-06-28 20:51:31 +00:00
rillig 15b1ffda11 tests/lint: fix preprocessor line number validation
When running the tests via ATF, the filename was an absolute filename,
while the preprocessing line in the test file uses a relative filename.
These two didn't match.
2023-06-28 17:53:21 +00:00
rillig b6d101e5c9 tests/lint: demonstrate wrong handling of nested initializer
Seen in external/bsd/jemalloc/dist/src/jemalloc.c, init_lock.
2023-06-28 15:04:07 +00:00
rillig 86d9dbede8 tests/lint: use standard form of ATF tests, test removing output file 2023-06-28 09:35:42 +00:00
rillig f6c6195c8b indent: fix 'blank line above first statement in function body' 2023-06-27 04:41:23 +00:00
rillig 36e71c5abd tests/indent: test the -badp option 2023-06-27 04:28:16 +00:00
rillig 45e235d0ba indent: improve heuristics for '*' as pointer in for loops 2023-06-26 20:23:40 +00:00
rillig 0982504e1c indent: improve heuristics for '*' as a pointer type 2023-06-26 20:10:23 +00:00
rillig f73b959d75 indent: implement 'blank line above first statement in function body' 2023-06-26 20:03:09 +00:00
rillig b54a4db2fc indent: in -bad mode, don't add a blank line above a comment or '}' 2023-06-26 14:54:40 +00:00
rillig eead40953d tests/indent: strengthen requirements for test input files
Previously, 'indent run-equals-prev-output' was allowed even when there
was no 'indent run' section above. This created an ambiguity, since
'previous output' could mean either the 'indent run' section or the
'indent run-equals-input' section.
2023-06-26 12:21:18 +00:00
rillig aa3872d78f tests/indent: extend test for -badp option 2023-06-26 11:01:08 +00:00
rillig ac483ee881 indent: treat 'complex' and 'imaginary' as type modifiers, not as types 2023-06-25 19:29:57 +00:00
rillig 9745d1edfa indent: fix formatting of parenthesized name in function definition 2023-06-25 19:19:42 +00:00
rillig 6ef27db9bc lint: don't warn about comparison between char and character constant 2023-06-24 17:50:31 +00:00
rillig 271d535ea8 lint: add query for comparing 'char' with plain integers 2023-06-24 08:11:12 +00:00
rillig a127f918f7 tests/lint: allow accept.sh to override lint1 for local testing 2023-06-24 07:45:36 +00:00
rillig 4a6e788063 lint: add query for redundant 'extern' in function declaration 2023-06-24 06:55:34 +00:00
msaitoh d1b93bab8c Fix typo in comment. 2023-06-24 05:27:13 +00:00
rillig 12dc98af47 indent: fix scanning of no-wrap comments (since 2021.11.07.10.34.03)
The "refactoring" back then tried to be too clever.
2023-06-23 20:59:04 +00:00
rillig f7b95e49e6 tests/indent: fix comments 2023-06-23 20:44:51 +00:00
rillig ec19c40c90 lint: add query for comma operator 2023-06-22 13:57:44 +00:00
rillig 69d93118ce tests/lint: comma operators are not allowed in constant expressions 2023-06-19 12:33:43 +00:00
knakahara 8d5cb09c67 Repair test coverage. I revert by proxy as the committer seems too busy to even reply mail.
TODO:
Provide some way for small machines to run subset test so that they get
shorter run time at the expense of test coverage.
2023-06-19 08:28:09 +00:00
rillig c4d462617d indent: only add blank lines before actual block comments 2023-06-18 07:32:33 +00:00
rillig 62ff1c97a7 indent: test block comments and the -bbb option 2023-06-18 07:29:36 +00:00
rillig 926f8bd544 indent: remove support for backspace in code and comments
The C code in the whole tree does not contain a single literal
backspace.
2023-06-18 07:10:24 +00:00
rillig 65e3242c1e tests/indent: add miscellaneous test cases found during clean up 2023-06-17 22:09:24 +00:00
rillig abc3274d3a indent: merge lexer symbols for type in/outside parentheses 2023-06-16 23:51:31 +00:00
rillig 95820b5370 tests/indent: format stderr output as end-of-line comments
This generates fewer error markers in syntax-aware editors.
2023-06-16 23:19:01 +00:00
rillig 398514d353 indent: fix spacing between postfix operator and left parenthesis 2023-06-16 23:07:52 +00:00
rillig 2fbaf64cd1 indent: improve heuristics for cast expressions 2023-06-16 14:26:26 +00:00
rillig 12ea422e44 indent: improve heuristics for cast expressions 2023-06-16 14:12:10 +00:00
rillig 961876df93 tests/indent: add a few code snippets from usr.bin/xlint 2023-06-16 13:43:30 +00:00
rillig 44e3c9f8ad indent: improve heuristics for casts 2023-06-16 12:55:57 +00:00
rillig 7983032213 indent: fix indentation and linebreaks in typedef declarations 2023-06-16 12:30:45 +00:00
rillig 128159d42b tests/indent: demonstrate wrong tokenization after typedef
Since 2023-06-10 06:52, which fixed the indentation of C11 _Generic
expressions.
2023-06-16 11:58:33 +00:00
rillig 8535e877f0 indent: don't force a blank line between '}' and preprocessing line 2023-06-16 11:48:32 +00:00
rillig 14063fa4b7 indent: fix indentation of multi-line enum constant initializers 2023-06-15 10:34:12 +00:00
rillig 0982fd88d1 indent: miscellaneous cleanups, more tests for edge cases 2023-06-15 09:19:06 +00:00
rillig f0cb29371b indent: fix alignment of multi-line declarations 2023-06-15 08:40:20 +00:00
rillig 940b85009c indent: clean up the code, add a few tests 2023-06-14 20:46:08 +00:00
rillig cdfe968337 indent: allow more than 128 brace levels 2023-06-14 19:05:40 +00:00
rillig ca9074275c tests/indent: separate stdout from stderr
Due to buffering, there was no guarantee that the output would be
exactly in the same order as written in the tests.
2023-06-14 17:07:32 +00:00
rillig 641fe74526 indent: allow more than 20 nested parentheses or brackets 2023-06-14 14:11:28 +00:00
rillig ddbd65a192 indent: fix formatting of comment after 'switch (expr)' 2023-06-14 11:18:09 +00:00
rillig 557ed6ed5d indent: use correct preprocessing directive in error message 2023-06-14 10:29:52 +00:00
rillig d2103f1c62 indent: allow more than 5 levels of #if/#endif 2023-06-14 10:26:00 +00:00
rillig ed7b435925 indent: clean up handling of comments
One less moving part in the parser state.

No functional change.
2023-06-14 09:31:05 +00:00
rillig 61c5d6b6d0 indent: remove a redundant flag from the parser state
No functional change.
2023-06-14 08:25:15 +00:00
rillig b2fe5a24a1 indent: merge parser symbols for stmt and stmt_list
They were handled in exactly the same way.
2023-06-14 07:20:54 +00:00
rillig bae713c412 indent: fix line break between semicolon and brace 2023-06-10 18:46:42 +00:00
rillig 3d124ccbbf tests/indent: add move coverage tests 2023-06-10 17:56:29 +00:00
rillig 8bcc07836b indent: fix stack overflow, add more tests
For several parser symbols, 2 symbols are pushed in a row, which led to
an out-of-bounds write.
2023-06-10 17:35:40 +00:00
rillig b3bf029a38 indent: miscellaneous cleanups 2023-06-10 16:43:55 +00:00
rillig f6ead5d9af indent: fix indentation of continuation lines in initializers 2023-06-10 08:17:04 +00:00
rillig 334e4e757d indent: explain right-aligned code 2023-06-10 07:05:18 +00:00
rillig f74eb54815 indent: fix token classification in declarations
As a side effect, indent handles _Generic from C11 properly now, at
least in -nlp mode.
2023-06-10 06:52:35 +00:00
rillig 338e471fd4 indent: rename and sort variables in parser state
No functional change.
2023-06-10 06:38:20 +00:00
rillig d3be4ec43d indent: trim trailing blank lines 2023-06-09 22:01:26 +00:00
rillig 1fc3c56ecf indent: support C99 compound literals 2023-06-09 11:22:31 +00:00
rillig ae40ebbc6b indent: don't treat function call expressions as cast expressions 2023-06-09 10:24:55 +00:00
rillig 1f304706fb indent: improve heuristics for function declaration vs. definition 2023-06-09 09:49:07 +00:00
rillig 1cc572504b tests/indent: add real-life test cases from make(1) and lint(1) 2023-06-09 09:45:55 +00:00
rillig eace873087 indent: when an indentation is ambiguous, indent one level further
The '-eei' mode now applies whenever the indentation from a multi-line
expression could be confused with a following statement.
2023-06-09 08:10:58 +00:00
rillig 2a0d16ddf2 tests/indent: test extra indentation in expressions 2023-06-09 07:54:05 +00:00
rillig 0fcafc89fc indent: preserve block comments with delimiters 2023-06-09 07:18:52 +00:00
rillig 5187119b0e indent: indent multi-line expressions according to parentheses
This reverts the FreeBSD change from 2004-02-12 that had been imported
on 2019-04-04.
2023-06-09 06:36:57 +00:00
rillig 7171fe25bf indent: remove fragile heuristic for detecting cast expressions
The assumption that in an expression of the form '(a * anything)', the
'*' marks a pointer type was too simple-minded.

For now, fix the obvious cases and leave the others for later.  If
needed, they can be worked around using the '-T' option.
2023-06-08 21:18:54 +00:00
rillig 5df2816aac indent: fix indentation of initializer lists with designators 2023-06-08 20:55:22 +00:00
rillig cfb043929d tests/indent: add more tests, from indent's own code 2023-06-08 20:49:04 +00:00
rillig 6b78dc3375 indent: fix indentation in multi-line else-if conditions 2023-06-08 20:36:35 +00:00