Commit Graph

137 Commits

Author SHA1 Message Date
Martin Storsjö 61ddd976fe Revert "test: crt-test: Skip a test for cos(-NAN) == -NAN when optimizing"
This reverts commit 1d8c107d49.

After 49e14021be, when using F(-NAN)
instead of -F(NAN) to hide the negation, this test passes correctly.
I hadn't realized that GCC and Clang optimized cos(-x) = cos(x), when
I made 1d8c107d49 (and at the time, the
F() macro didn't work properly with -NAN on all toolchains).
2026-04-24 15:39:58 +03:00
Martin Storsjö 49e14021be test: crt-test: Prefer F(-NAN) instead of -F(NAN)
In the former form, the negation of NAN is hidden inside the
optimization blocking macro/wrapper. After
9be66e9d22, F(-NAN) works just as
well as -F(NAN).

This avoids test issues with recent optimizations in LLVM.
https://github.com/llvm/llvm-project/pull/193586 seems to make
the compiler consider known symmetry for hyperbolic math functions,
exploiting the fact that cosh(-x) is equal to cosh(x) (for values
other than NANs). By hiding the negation inside the F() wrapper,
the compiler can't reason about is existence.
2026-04-24 14:39:15 +03:00
Martin Storsjö e604eb6f1f test: crt-test: Remove a comment which no longer is accurate
Since 9be66e9d22, the F() macro
no longer uses strtod(), so the details about what strtod("NAN")
and strtod("-NAN") returns are no longer relevant.
2026-04-24 14:38:26 +03:00
Martin Storsjö b68aefdbb5 test: crt-test: Remove unused variables 2026-04-24 14:34:20 +03:00
Martin Storsjö dc9837d908 test: Add the original test case for atomic loads of varying sizes
This covers the original testcase from
https://github.com/mstorsjo/llvm-mingw/issues/538.
2026-02-25 12:13:08 +02:00
Martin Storsjö 49afca5984 test: Add a test for atomic load/store of large integers
Test atomically loading/storing 128 bit integers on 64 bit, and
64 bit integers on 32 bit.

This test case covers the root cause of
https://github.com/mstorsjo/llvm-mingw/issues/538.
2026-02-25 12:13:08 +02:00
Martin Storsjö 98a14ed36f test: Support mingw32-make running with a proper sh.exe 2026-01-08 11:34:24 +02:00
Martin Storsjö e6cbbe9a35 test: Add a test for catching pointers by reference
This test should make sure that
https://github.com/mstorsjo/llvm-mingw/issues/522 doesn't
regress again.
2025-10-21 22:20:19 +03:00
Martin Storsjö a57c32023b test: Waive frexp failures on msvcrt.dll on arm64ec, similar to on aarch64
Building crt-test for arm64ec msvcrt.dll doesn't work currently,
but if mingw-w64 is tweaked so that it works, this test does
need to be waived.
2025-09-02 16:01:52 +03:00
Martin Storsjö 4700b4f7bb test: Skip building the ubsan and openmp tests for arm64ec
Also unset RUN for arm64ec, instead of accidentally inheriting the
earlier value.
2025-07-17 22:49:10 +03:00
Martin Storsjö a453b3c9b3 test: Skip inline x86_64 assembly on arm64ec 2025-05-18 22:30:20 +03:00
Martin Storsjö 9f59c26011 test: Fix the test-scan-deps test for arm64ec
Add a separate arm64ec arch case, skip the x86_64 one.
2025-05-18 22:29:52 +03:00
Martin Storsjö e633b48b63 test: Add a comment about a test that fails when run emulated on arm
The test is specific to building for x86, for a msvcrt.dll target,
and running that binary on arm.
2025-05-02 13:56:51 +03:00
Martin Storsjö 19b4d2a434 test: Add tests for tchar.h routines 2025-04-02 20:38:48 +03:00
Martin Storsjö 7e7e506bbc test: Add testing of swprintf/_swprintf/_snwprintf and related functions 2025-03-20 18:22:29 +02:00
Martin Storsjö 4f0ec7f8f8 test: Add testing of various variants of strtok/wcstok 2025-03-20 17:28:57 +02:00
Martin Storsjö 8dabd61494 test: Rename HAVE_SANITIZERS to HAVE_ASAN
Always run the ubsan tests; those should work on any architecture
now.
2025-02-11 10:02:57 +02:00
Martin Storsjö c412f4ac74 test: Add missing cases of CPPFLAGS/CFLAGS/CXXFLAGS
Normally neither of these variables are set, but by applying them
consistently, it allows testing building with extra flags set.
2025-02-10 13:57:53 +02:00
Martin Storsjö f730b67e8e test: Correctly use CXXFLAGS for one case of .cpp file compilation 2025-02-10 13:57:50 +02:00
Martin Storsjö 8e6bbb7b83 test: Waive issues in frexp* functions in msvcrt.dll on ARM
These issues appear when testing with the real msvcrt.dll on ARM;
if testing in Wine, these functions behave as expected.
2024-12-04 12:34:40 +02:00
Martin Storsjö ccfa1317a5 test: Test building crt-test.c as C++ 2024-11-12 11:31:44 +02:00
Martin Storsjö 2b80cf0efd test: Fix crt-test.c to be buildable in C++ mode
Make it work with both GCC on Linux, llvm-mingw, and MSVC.
2024-11-12 11:31:44 +02:00
Martin Storsjö e457f40bd9 test: Explicitly test with -D__USE_MINGW_ANSI_STDIO=0 as well 2024-11-12 11:31:44 +02:00
Martin Storsjö da1e61f7e5 test: Waive issues in crt-test.c if running with msvcrt.dll and -D__USE_MINGW_ANSI_STDIO=0 2024-11-12 11:31:43 +02:00
Martin Storsjö 8eec3b91b3 test: Fix code style in crt-test.c 2024-11-12 11:31:43 +02:00
Martin Storsjö 6c748d21dd test: Test the clang-scan-deps wrapper 2024-05-02 20:03:56 +03:00
Martin Storsjö 85c0ef1a21 test: Don't build asan/ubsan tests with PDB debug info
The DWARF debug info should work just as well.

Since 8c03f400a837dc9333e54ab371e7904aa2bec43c in llvm-project,
llvm-symbolizer prefers DWARF over PDB if there is a DWARF section
in the inspected executable. Thus, in order to use PDB, one would
have to strip out any remnants of DWARF debug info from the executable,
like in run-lldb-tests.sh (e.g. by -Wl,-s).

For the purposes of this test, simplifying the setup to use DWARF
works just as well.
2024-03-18 09:41:13 +00:00
Martin Storsjö 9c48a7d92c test: Print the reason for failing in test output inspections 2024-03-18 09:38:04 +00:00
Martin Storsjö 8a7c59dc94 test: Avoid the compiler optimizing out the cfguard check call
When calling make_indirect_call with a parameter which is known,
Clang, since the 18.x release, can end up producing a specialized
version of the function which omits the cfguard check call (as the
target is known) and calls the known target directly.

The function is marked with a noinline attribute, to avoid
the compiler optimizing out the cfguard check call when the
target is known, but even with a noinline function, the compiler
apparently can make a separate specialized version of it.

To avoid the compiler doing such optimizations, reference the
target function via a global variable - the compiler can't assume
anything about the contents of them (they could be altered between
initialization and reading them later).

This fixes the cfguard invalid_icall test with Clang 18.x, when
compiled with optimizations enabled.
2024-03-14 23:11:45 +02:00
Martin Storsjö 8a6b022f88 test: Test building another executable in UWP mode
Test building a file that includes windows.h, to catch issues with
e.g. the definition of WINAPI_FAMILY.
2024-03-13 18:19:42 +02:00
Martin Storsjö ac3c8bfe35 test: Add a testcase for atomic helpers 2024-01-24 09:11:40 +02:00
Martin Storsjö a815d6557a test: Add a smoke test for resource files and windres 2023-12-12 16:10:37 +02:00
Martin Storsjö c1dfe42094 test: Remove an exception for a glibc test failure in crt-test
I no longer can reproduce the issue that this works around; neither
on current environments or when testing building with older
distributions.
2023-10-27 10:32:10 +03:00
Martin Storsjö e4534c56fa test: Split the math tests in crt-test into many smaller functions
This speeds up compilation a bit further.
2023-10-27 10:31:55 +03:00
Martin Storsjö 5e45947c20 test: Split the main function in crt-test to a couple smaller functions
This speeds up compilation with LLVM a little bit.
2023-10-26 12:01:17 +03:00
Martin Storsjö 0f79bd9460 test: Reset the iret variable inbetween tests of frexp 2023-10-26 12:01:17 +03:00
Martin Storsjö b592dd734e tests: Consistently use <triple>-gcc instead of <triple>-clang for cross compilation
While <triple>-clang is more specific, using <triple>-gcc allows
testing GCC based toolchains (somewhat) with the same scripts/makefiles
too.
2023-03-11 23:59:19 +02:00
Martin Storsjö dfd4c31f2e test: Simplify handling of OpenMP
It is available on all architectures by default now. Keep the
HAVE_OPENMP conditional within the test makefile to allow custom
testing without having it available.
2023-01-29 01:09:17 +02:00
Martin Storsjö 4ba7adbb90 run-tests: Check for the error messages from ssp routines
Since using the ssp routines from mingw-w64 instead of those from
GCC's libssp, these messages are included in the piped output of
the process, so we can check for the right messages.
2023-01-29 01:09:17 +02:00
Martin Storsjö abc36e1f7c run-tests: Stop trying to copy libssp-0.dll
We no longer build that DLL.
2023-01-29 01:09:17 +02:00
Martin Storsjö ef9806fc0a run-tests: Stop explicitly linking against -lssp for the fortification test
Since libmingwex.a provides these routines now, we don't need to
specify -lssp manually.
2023-01-29 01:09:17 +02:00
Martin Storsjö 241a1cd148 test: Prepare the test scripts for testing native Windows tools via WSL
Use the TOOLEXT variable in run-tests.sh in the same way as in the
Makefile. The Makefile sets this variable automatically if invoked
by mingw32-make, but if running run-tests.sh in WSL with native
Windows compilers, then we need to set TOOLEXT manually when calling
run-tests.sh.

Allow skipping the cfguard failure tests when run in such a
configuration, since Linux make in WSL can't easily run cmd.exe
like in MSYS2.
2023-01-21 23:48:24 +02:00
Martin Storsjö 04c623fe8b crt-test: Improve the check for testing the >64 bit range for strtold
The previous condition failed to identify that macOS on aarch64
also has long double equal to regular double.
2022-12-01 12:13:20 +02:00
Martin Storsjö 21c279aab5 crt-test: Skip the NAN preservation tests on platforms other than mingw
This part of the tests does pass on glibc on x86_64 and on MSVC,
but fails on macOS (for some functions) and on glibc on aarch64
(for one function).

This is a somewhat overly pedantic test, but is useful for checking
the NAN preservation behaviour when modifying implementations.

Also print the sign bit explicitly - not all printf implementations
distinguish between NAN and -NAN when printed.
2022-12-01 12:07:32 +02:00
Martin Storsjö e934cba58e test: Include the runtime DLLs even if not running tests
This makes the produced binaries ready for running separately
afterwards, which was regressed in
e16ba0772f.
2022-11-02 10:37:58 +02:00
Martin Storsjö e16ba0772f run-tests: Split out building and running of tests into a Makefile
This allows building and running the tests in parallel.
2022-10-29 23:22:56 +03:00
Martin Storsjö 71b3bcb278 crt-test: Wrap parameters to tested string functions to avoid optimizing them
When some of the parameters to standard C functions are known
constants, the compiler can optimize out the call to the actual
function.

When built with fortification enabled, the compiler previously
didn't actually end up calling the __<func>_chk functions in
most cases, as it could optimize out much of the calls. Now all
tested function calls should end up emitted as intended, making
this actually do functional testing of the __<func>_chk function
implementations.
2022-10-14 14:34:02 +03:00
Martin Storsjö c81a93e86c crt-test: Fix tests with MSVC after changing the F() macro
The literal NAN in MSVC is a negative NAN, while it is a positive one
in other environments. (strtod("NAN", NULL) did return a positive NAN
though.) In most tests where we test that NANs are preserved, the exact
sign doesn't matter much as long as it matches, but for some tests, it
does matter. Change to using variables with known representation
in the tests where it matters.

Also add a LL suffix to make a tricky constant more correct.
In MSVC, the variable initialization
    long long i = -2147483648;
actually sets the variable to the positive value 2147483648 (both
in MSVC 2019 and 2022).
2022-10-14 14:33:57 +03:00
Martin Storsjö 9be66e9d22 crt-test: Fix the macros for avoiding compiler optimizations
The macros F() and L() etc were meant for providing constants for
the tests, without the compiler seeing them as constants, to
avoid optimizing out the entire functions that are to be tested.

However in practice, the compiler is also able to optimize out
e.g. a call to strtol("42", NULL, 0), so this didn't have the
intended effect.

Instead make the macros wrap through a no-op function, but which
is indirected via a global function pointer. The compiler can't
reason about global variables keeping their values (they could be
modified by e.g. a constructor in a different object file, before
running the main function). This avoids needing to pass all values
through strtod/strtol etc.

Change some constants like 123456789012345, which are seen by
the compiler as integer constants (which aren't exactly representable
in floating point form) into 123456789012345.0, which the compiler
won't complain about being inexact.
2022-10-14 14:33:51 +03:00
Martin Storsjö 04edd84e9d test: Return 0 if cfguard-test is executed without arguments
This simplifies bare-bones testing of just executing all built
executables without an argument.
2022-10-04 11:51:12 +03:00