Commit Graph

6611 Commits

Author SHA1 Message Date
rillig 1772ff8ac7 lint: increase debug logging for declarations
All changes to the global variable 'dcs' are tracked now, to help
identify the cause of the failing tests in expr_sizeof and
gcc_attribute_aligned.

While here, test more invalid type combinations in typedefs.
2024-05-04 06:52:16 +00:00
riastradh af8e7fd7d9 tests/lib/libm/t_fe_round.c: Expand nearbyint/rint tests.
PR lib/58054
2024-05-03 21:40:51 +00:00
rillig cbe2532061 tests/lint: fix supposedly platform-independent type definitions
No idea where I got the previous type definitions from.  The typedef
names looked just too convincing to actually check the underlying types.
2024-05-03 19:16:13 +00:00
rillig 0b487d0915 tests/lint: skip test for sizeof struct on 32-bit platforms
Even though the test only uses fixed-size types, lint's computed size of
the resulting struct differs between i386 (80) and x86_64 (112).  Both
are wrong, probably due to the unrelated struct declaration above, as
already mentioned in the comments.
2024-05-03 15:32:37 +00:00
rillig 2e8fec16de tests/lint: demonstrate wrong struct size calculation 2024-05-02 20:03:33 +00:00
riastradh 9fbbf75c78 tests/lib/libm/t_fe_round: Fix a missed cast.
Need long long or intmax_t, not long, on LP32.

PR lib/58054
2024-05-02 16:52:08 +00:00
riastradh 2bd651d959 tests/lib/libm/t_fe_round: Tidy up nearbyintl, sync nearbyint test.
PR lib/58054
2024-05-02 16:51:55 +00:00
riastradh 38aebf98e7 tests/lib/libm/t_fe_round.c: Simplify previous.
There is never any need to write casts to type T in integer constant
initializers for type T.

PR lib/58054
2024-05-02 11:55:49 +00:00
kre 483439ec0a Use intmax_t instead of long int when trying to represent very large
integers (10^50 or so), so we don't exceed the capacity of systems where
long int is only 32 bits.

Hopefully will unbreak the i386 build, perhaps others.
2024-05-02 03:30:07 +00:00
riastradh 247fbbb163 tests/lib/libm/t_fe_round: Test nearbyintl.
This uses inputs that can't be distinguished with only 53 bits of
precision, so it should work in essentially all long double formats
to detect when nearbyintl is incorrectly implemented in terms of
nearbyint.

PR lib/58054
2024-05-02 00:01:48 +00:00
riastradh 02e4b613e1 tests/lib/libm/t_fe_round: Tidy up nearbyint test.
Prompted by PR lib/58054.
2024-05-02 00:00:47 +00:00
rillig 571b49008c lint: make 'offsetof(t, array-member)' a constant expression
The macro 'offsetof(t, m)' already expanded to a constant expression for
scalar members but not for arrays.  This was because the macro expanded
to '(size_t)(((t *)0)->m)', which lint internally represents as
'addr(indir(ptr(0) + offset(m)))', and build_address simplifies
'addr(indir(x))' to 'x' if the types match.  The types only match for
scalar types though, but not for arrays.

When build_address happens, the type information is incomplete,
therefore 'offsetof(t, array)' has to be simplified at a later point.
2024-05-01 17:42:57 +00:00
rillig b636d70fb7 tests/lint: test large enum constants and offsetof with array members 2024-05-01 12:36:56 +00:00
gson 0462042f3b Increase the estimate of disk space required for the test, as the old
estimate recently proved too optimistic on the amd64 testbed on b4.
2024-05-01 11:40:25 +00:00
rillig d69057212d lint: fix size of struct with large alignment
Lint now successfully passes all compile-time assertions in the amd64
kernel that deal with struct sizes.
2024-05-01 10:30:56 +00:00
rillig 313458bc0b lint: support _Alignas and __attribute__((__aligned(4))) 2024-05-01 07:40:11 +00:00
rillig de44edfce0 lint: fix warning about out-of-bounds bit-field value 2024-05-01 05:49:33 +00:00
rillig ce8bf3c377 lint: demonstrate wrong warning about out-of-range bit-field 2024-05-01 05:38:11 +00:00
rillig de973ec253 tests/cd9660: replace compressed blob with readable hexdump
This test is skipped in most circumstances because it creates a file
whose apparent size is 4.5 GB.  It's an ISO 9660 image though,
containing mostly null bytes.  Nevertheless, tmpfs doesn't allow such a
big file to be created, so this test is skipped in settings where /tmp
is on a tmpfs.

If the test is run, the ISO image is uncompressed, which takes several
minutes.  Replace bzip2 with direct file creation from a hex dump of
that disk image, which is easier to inspect manually and also faster by
about 3 magnitudes.
2024-04-28 14:39:22 +00:00
riastradh 07d71e6b54 tests/lib/Makefile: Hook up libstdc++. 2024-04-28 12:49:08 +00:00
rillig d8f5b04c09 tests: replace deprecated '-s eq:...' with '-s exit:...' 2024-04-28 07:27:40 +00:00
riastradh 2a7fd23976 libstdc++: Add test for PR lib/58206, sync_with_stdio busted. 2024-04-28 01:21:26 +00:00
rillig fc7f5da782 lint: converting a null pointer to another pointer type is not narrowing 2024-04-27 12:46:37 +00:00
rillig 96381692fe lint: add query for conversion from void pointer to other pointer 2024-04-27 10:08:54 +00:00
rillig c4e31442c4 tests/cp: clean up
Replace the deprecated "eq:0" with "exit:0", remove redundant "-o empty"
and "-e empty".
2024-04-26 01:33:23 +00:00
rillig 4ce8b53a58 tests/cat: clean up
Multiple arguments to atf_set are joined by spaces, there's no need for
an extra space.

The exit status on success must be 0, so don't ignore it.

Remove the unnecessary shell wrapper, as no redirection is going on.
2024-04-26 00:57:15 +00:00
pho 76248f073a Add a test for kern/58149
aarch64: Cannot return from a signal handler if SP was misaligned when the signal arrived
2024-04-22 07:24:22 +00:00
rillig 6e59c25695 tests/lint: show how to trigger message 207 2024-04-19 20:59:18 +00:00
rillig 4ce516c154 tests/fmtcheck: show that fmtcheck does not support "%2$s" 2024-04-13 14:02:51 +00:00
gson 7809b23883 Require at least 64 MB RAM to run the getrusage_maxrss test case as it
allocates 40 MB and we should leave some for the system, too.
2024-04-12 07:16:50 +00:00
rillig dae6022bba lint: in snprintb, warn about all escaped characters in descriptions 2024-04-12 05:17:48 +00:00
rillig 4ed1e5f144 snprintb.3: provide examples for hexadecimal character escapes
Suggested by uwe@, in reaction to the previous commit, which preferred
octal in the examples. Hexadecimal escapes are more familiar to most
programmers, and the chance of mistaking \x14 for decimal 14 is less
than the chance of mistaking octal \014 for decimal 14.
2024-04-08 21:28:35 +00:00
rillig b5be0901e3 snprintb: reject empty bit descriptions and wrongly placed defaults 2024-04-07 15:20:16 +00:00
rillig 442f4c6c59 snprintb: reject combinations of 'f' with ':' as well as 'F' with '='
These combinations would lead to garbled output.
2024-04-07 12:05:23 +00:00
rillig 864a50a39a snprintb: reject empty descriptions
In cases where the snprintb output is garbled, it is not trustworthy, so
make sure the mistakes in the bitfmt are fixed early.
2024-04-07 10:10:54 +00:00
yamaguchi 6aa7c5ec4b lagg(4) test: Fix typo and old comment 2024-04-05 07:04:17 +00:00
riastradh 561072c7c1 Temporarily make PR t_sp:sigsafe noisier.
This is an attempt to diagnose why it's flaky in the releng testbeds
but not when I run it.  This change will be backed out once we get
new testbed output.
2024-04-04 21:19:25 +00:00
riastradh e5e887ba96 rumpkern/t_sp: Save stdout and stderr to report on failure.
This is not very tidy at the moment, but it's an experiment using the
approach in PR bin/58112, to diagnose why t_sp:sigsafe keeps failing
intermittently.  If this works, perhaps can tidy it up and apply it
to all the other tests that run rump_servers.
2024-04-04 17:27:32 +00:00
christos 0bef817c68 Better output handling (des at FreeBSD) 2024-04-04 16:58:35 +00:00
christos 8fc8182a2b make this work again 2024-04-04 16:57:45 +00:00
riastradh 3e7604f627 i386 longjmp: Restore stack first, then signal mask.
Otherwise, a pending signal may be delivered on the wrong stack when
we restore the signal mask.

While here:

- Tidy the code a little bit.
- Sprinkle comments to explain what's going on.
- Use forward branches for statically predicted not-taken.
  => val==0 is unlikely in longjmp

PR lib/57946
2024-04-04 00:46:41 +00:00
riastradh df443a3d17 amd64 longjmp: Restore stack first, then signal mask.
Otherwise, a pending signal may be delivered on the wrong stack when
we restore the signal mask.

While here:

- Tidy the code a little bit.
- Sprinkle comments to explain what's going on.
- Use `xorl %eXX,%eXX' instead of `xorq %rXX,%rXX'.
  => Same effect, one byte shorter, breaks dep chain on more uarches.
- Use forward branches for statically predicted not-taken.
  => val==0 is unlikely in longjmp

PR lib/57946
2024-04-04 00:46:30 +00:00
christos fb834229e7 fix the cbrtl/powl test 2024-04-03 01:52:28 +00:00
riastradh ad49149131 elftoolchain: Be consistent about which ELF header files we use.
1. For tools that use elftoolchain: always use elftoolchain's
   elfdefinitions.h.  Don't even think about looking at the host's
   sys/exec_elf.h, which makes no sense and should never happen.

   (ELF tools that don't use elftoolchain, like m68k-elf2coff,
   continue to use nbincludes/sys/exec_elf.h.  But no more nbincludes
   hacks in elftoolchain.)

2. For kernel components (solaris, zfs, dtrace): always use
   sys/exec_elf.h, even in Solaris components via sys/elf.h.
   elfdefinitions.h is not wired up in the kernel build at all.

3. For most userland components that involve libelf: use
   elfdefinitions.h via libelf header files (libelf.h, gelf.h).

   libdtrace in particular requires _all_ R_* reloc type definitions,
   but sys/exec_elf.h brings in only the _current machine's_ R_*
   reloc type definitions.  (While here: Use uintptr_t instead of
   Elf_Addr for pointer-to-integer cast, since Elf_Addr is MD and
   provided only by sys/exec_elf.h, not by elfdefinitions.h.)

   And most userland components using libelf don't rely on any
   properties of the current machine from sys/exec_elf.h, so they can
   use libelf's elfdefinition.h.

   Exceptions:

   - dtrace drti.c relies on link.h -> link_elf.h -> sys/exec_elf.h,
     but it also relies on sys/dtrace.h -> sys/elf.h ->
     elfdefinitions.h like other userland components using sys/elf.h.

   - kdump-ioctl.c uses sys/exec_elf.h directly and sys/dtrace.h ->
     sys/elf.h -> elfdefinitions like other userland components using
     sys/elf.h.

   - t_ptrace_wait.c (via t_ptrace_core_wait.h) uses libelf to parse
     core files, but relies on sys/exec_elf.h for struct
     netbsd_elfcore_procinfo.

   None of these exceptions needs all R_* reloc type definitions, so
   as a workaround, we can just suppress libelf's elfdefinitions.h by
   defining _SYS_ELFDEFINITIONS_H_ and use sys/exec_elf.h in these
   exceptions.

And undo the whole BUILTIN_ELF_HEADERS mistake.  This was:

- half bogus workarounds for missing build_install dependencies in
  tools/Makefile, which are no longer missing now, and
- half futile attempt to use src/sys/sys/exec_elf.h via nbincludes in
  tools involving libelf instead of libelf's elfdefinitions.h, which
  collides.

Longer-term, we may wish to unify sys/exec_elf.h and libelf's
elfdefinitions.h, so we don't have to play these games.

But at least now the games are limited to three .c files (one of
which is generated by Makefile.ioctl-c), rather than haphazardly
applied tree-wide by monstrous kludges in widely used .h files with
broken hackarounds to get the tools build lurching to completion.
2024-04-01 18:33:22 +00:00
rillig 99770e084d tests/snprintb_m: test null-terminated output in error case
While here, clean up the buffer handling for the visualized array
content in case of a failed test.
2024-04-01 09:15:51 +00:00
rillig 0382e641fc lint: in the query about implicit conversions, ignore casts 2024-03-30 19:12:37 +00:00
rillig 370056d3b9 lint: add query for implicit integer-to-floating conversion 2024-03-30 17:23:13 +00:00
rillig def8e1797a lint: do not convert array subscripts from size_t to ptrdiff_t
The C standards do not specify a fixed type for an array subscript, it
just has to be an integer type.  Previously, query 4 fired for the
ubiquitous expression 'ptr[sz]' when sz had type 'size_t'.

The test platform_ilp32_long is unaffected by this change, as the
integer constant 0x80000000 has type 'unsigned int', while size_t is
'unsigned long' on those platforms, and even though the types 'unsigned
int' and 'unsigned long' have the same value space, there's still a
conversion, at least for now.
2024-03-30 17:12:26 +00:00
rillig c6466ed0f7 lint: reword messages about array subscripts to sound more natural 2024-03-30 16:47:44 +00:00
rillig 55398a9a51 lint: fix wording of warning about bit-field initializer 2024-03-29 07:35:45 +00:00