Commit Graph

6682 Commits

Author SHA1 Message Date
martin ce6107da93 Add manhtml set 2024-05-07 14:53:59 +00:00
riastradh 557aa1ae1a tests/lib/libm/t_bit: Expand and tidy.
1. Instead of calling out VAX by name, use #ifdef NAN.

2. Verify signbit works on long double on all architectures, not just
   those with __HAVE_LONG_DOUBLE which means long double is _larger_
   than double.

3. Minor formatting tidying.
2024-05-06 18:41:23 +00:00
riastradh 9da594439c tests/lib/libc/stdlib/t_strtod: Spruce up and nix needless #ifdefs. 2024-05-06 18:39:36 +00:00
riastradh 10d47f3307 tests/lib/libm/t_modf: Use isinf(INFINITY) to detect inf support.
Apparently VAX defines the INFINITY macro even though it's not
actually an infinity and isinf returns zero for it.
2024-05-06 18:35:59 +00:00
riastradh 30aeb9cc52 tests/lib/libc/gen/t_floatunditf: Nix __HAVE_LONG_DOUBLE conditional.
Conversion from uint64_t to long double should work on all ports,
including those where long double is the same as double, i.e., where
__HAVE_LONG_DOUBLE is undefined.

Instead, conditionalize the test cases on how many bits of precision
long double has in the significand, according to LDBL_MANT_DIG.  The
conditionals here should handle binary128, powerpc double-dekker
(~106-bit precision), x86 extended precision (80-bit), m68k extended
precision (80-bit), and VAX D (56-bit).
2024-05-06 17:53:43 +00:00
riastradh 49e81414d0 tests/lib/libm/t_sincos: Nix __HAVE_LONG_DOUBLE conditionals.
sincosl is supposed to be there even if long double is double, as is
the case when __HAVE_LONG_DOUBLE is undefined.
2024-05-06 15:53:46 +00:00
riastradh 742590c903 tests/lib/libm/t_scalbn: Nix __HAVE_LONG_DOUBLE conditionals.
If long double is the same as double, i.e., __HAVE_LONG_DOUBLE is
undefined, these tests should still pass, since they don't rely on
extra precision beyond double.
2024-05-06 15:49:31 +00:00
riastradh d36ac80d42 tests/lib/libm/t_precision: Nix __HAVE_LONG_DOUBLE conditionals.
long double and LDBL_EPSILON work even on architectures where long
double is the same as double, i.e., where the confusingly named
__HAVE_LONG_DOUBLE is not defined.
2024-05-06 15:46:31 +00:00
riastradh 26b22dc580 tests/lib/libm/t_cos: Fix comment about necessity of volatile. 2024-05-06 15:45:20 +00:00
riastradh 3d20dd055f tests/lib/libm/t_cos: Nix __HAVE_LONG_DOUBLE.
cosl should always be defined even on architectures where long double
is the same as double so the confusingly named __HAVE_LONG_DOUBLE is
not defined.
2024-05-06 15:44:08 +00:00
riastradh 840e85b4fd tests/lib/libm/t_cabsl: Nix __HAVE_LONG_DOUBLE conditionals.
__HAVE_LONG_DOUBLE just means long double is different from double.
This test should always pass on all ports, even if long double is the
same as double; it doesn't test any additional precision.
2024-05-06 15:40:55 +00:00
riastradh 9263853839 tests/usr.bin/mtree/t_sets.sh: atf_fail, not atf_tc_fail 2024-05-06 14:38:28 +00:00
riastradh e21ed88e62 tests/lib/libc/setjmp/t_sigstack: Add missing comment for 1.10.
PR lib/57946
2024-05-06 12:11:03 +00:00
skrll d2c36e3e86 arm has been fixed 2024-05-06 06:58:00 +00:00
riastradh 8ae9996403 tests/lib/libm/t_modf: Check sign of modf on infinities too.
Normally I don't like CHECK(A && B) and favour CHECK(A); CHECK(B)
instead, so you can see which one failed, but in this case the inputs
are displayed anyway so we don't lose anything unless the
floating-point printer is broken.
2024-05-06 02:21:39 +00:00
riastradh a2c1cc7d5e tests/lib/libm/t_modf.c: Expand modf/modff/modfl tests.
1. Exercise more edge cases around the largest exponent that can
   represent non-integers.

2. - Verify modf can handle all cases modff can.
   - Veriy modf can handle some cases modff can't.
   - Verify modfl can handle all cases modf or modff can.
   - If long double isn't just double, verify modfl can handle some
     cases modf and modff can't.

3. Check infinities and NaN.

4. Verify oddness, i.e., modf(-x) = -modf(x).

5. Display more useful diagnostics in case any of this goes wrong.
2024-05-06 00:54:02 +00:00
riastradh 2b70237da2 tests/lib/libm/t_fe_round.c: Work around likely ia64 bug in gcc. 2024-05-05 23:08:53 +00:00
riastradh b544c4974f tests/lib/libm/t_next: Fix stub on VAX.
Tested building the wrong tree, oops.
2024-05-05 14:34:58 +00:00
riastradh df931a7810 tests/lib/libm/t_next: Disable this test on VAX.
But leave a replacement xfail test that fails unconditionally, to
leave a reminder in the tests of PR 57881: vax libm is missing
various symbols.
2024-05-05 14:29:38 +00:00
riastradh b129f29edd tests/lib/libm: Test nextafter/nexttoward and variants.
The tests are fairly trivial but should work without any conditionals
about floating-point formats.
2024-05-05 02:53:01 +00:00
riastradh cd71d51811 tests/usr.bin/mtree: Fail gracefully with unknown sets.
Rather than `bogus test program', make a test fail.

PR misc/57877
2024-05-04 20:24:37 +00:00
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
rillig 134116ce30 lint: clean up 2024-03-28 21:04:48 +00:00
rillig 8910413e27 lint: clean up; extend overflow test 2024-03-27 20:09:43 +00:00
rillig e57698da95 lint: don't use 'long' in diagnostics
The size of 'long' differs between 64-bit and 32-bit platforms.
Eliminate this possible platform-dependency.
2024-03-27 19:28:20 +00:00
rillig e6155eab48 t_strptime: fix typo in test description 2024-03-26 21:52:23 +00:00
rillig 216c89c02b lint: fix warnings about loss of accuracy on bit-field operations 2024-03-25 23:39:13 +00:00
rillig 6167e0cc12 tests/lint: demonstrate wrong warnings about lossy bit field operations 2024-03-25 22:46:23 +00:00
rillig 64230f3217 lint: rename snprintb 'directives' to 'conversions'
This aligns the terminology with the snprintf function.
2024-03-25 22:37:43 +00:00
rillig b050579e9d snprintb: mark the end of the buffer if the buffer is too small
This avoids confusion in case the buffer ends with an incomplete number.
2024-03-25 20:39:26 +00:00
martin 56e0726f28 The fetestexcept_trap test case only makes sense on FPUs that implement
exceptions.
2024-03-18 16:33:54 +00:00
riastradh 086a7f840a strptime(3): Exercise some edge cases in the automatic tests.
Unfortunately, we can't quite use strptime as a black box to detect
the cases that triggered undefined behaviour, because strptime just
fails in that case anyway since the number that would go in .tm_year
is far out of the representable range.

PR lib/58041
2024-03-16 00:06:37 +00:00
riastradh f1f68b211d libcrypto: Fix buffer overrun in truncated SHA-512 functions.
Further fallout from the libc/openssl sha2 symbol collision.

PR lib/58039
2024-03-15 18:10:37 +00:00
riastradh 1e152b590b libcrypto: Add some trivial tests for truncated SHA-512 variants.
These should use more of the test vectors from

https://csrc.nist.gov/Projects/Cryptographic-Algorithm-Validation-Program/Secure-Hashing#Testing

but this will do for now to detect the buffer overrun rake we left
lying around for ourselves.

PR lib/58039
2024-03-15 15:32:07 +00:00
rillig 083828859c stat: don't allow numeric formatting flags on strings
Calling snprintf with "%+s" invokes undefined behavior.
2024-03-14 21:17:54 +00:00
rillig 897cdf26ba tests/stat: test the left-aligned and right-aligned 'S' format 2024-03-14 21:00:32 +00:00
rillig 9ca08a6937 tests/lint: ensure that lint correctly decays array parameter types 2024-03-13 06:56:24 +00:00
rillig 9ed4dea22d tests/lint: extend test for previously wrong warning about bit-fields 2024-03-12 20:35:29 +00:00
rillig 9b239cc71c lint: fix warning about loss of conversion for unsigned bit-fields
Since decl.c 1.180 from 2021-05-02.
2024-03-12 07:56:08 +00:00
rillig fc2f5e14be tests/lint: demonstrate wrong warning when comparing a bit-field
Since decl.c 1.180 from 2021-05-02, which allowed arbitrary integer
types to be used as the underlying type for bit-fields in GCC mode.
2024-03-12 07:29:39 +00:00
rillig dd848dec1a lint: add details to the message about integer overflow
Having only the operator was too unspecific to be actionable, so add the
actual numbers and the data type.
2024-03-10 19:45:14 +00:00
rillig bd9743d3db lint: saturate signed integer overflow
In array address calculations, this prevents a 'array subscript cannot
be negative' for large array subscripts.
2024-03-10 16:06:13 +00:00
rillig 08d1bd5c72 lint: fix integer overflow detection
Previously, an unsigned operation that had a negative result went
undetected in a few cases. Now, all results that are not representable
by their type are considered overflows.

The implementation of signed shift-right had been wrong for a few
commits.
2024-03-10 15:49:12 +00:00
rillig 51858eeb3e lint: detect more cases of integer overflow in constant expressions
For unsigned integers, detect when 'a + b' wraps around.
2024-03-10 14:32:30 +00:00
rillig 7d57e750b8 tests/lint: enable test for integer overflow in array index 2024-03-10 10:39:19 +00:00
rillig 25f6e58591 lint: remove wrong warning about overflow in unary '-' for unsigned 2024-03-10 10:31:29 +00:00
rillig 34885a599d lint: fix integer overflow in integer overflow check 2024-03-10 10:15:51 +00:00
rillig 16f849b643 tests/lint: test integer overflow when folding constants
The test is still incomplete, yet it has discovered several bugs that
are worth fixing.
2024-03-10 09:58:30 +00:00
rillig 3e856647d2 lint: fix excessive overflow warning after division by zero 2024-03-09 23:55:11 +00:00
rillig 2b5c0f6a77 tests/lint: demonstrate integer overflow on lp64 platforms 2024-03-09 17:34:01 +00:00
rillig d6cf182bfe tests/lint: test check for out-of-bounds array index 2024-03-09 16:47:09 +00:00