[all-commits] [llvm/llvm-project] 7ea6d4: [libc] Add a C unit test framework wrapper and con...
Pavel Labath via All-commits
all-commits at lists.llvm.org
Mon Aug 3 23:11:43 PDT 2026
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 7ea6d45feaed43266ece53df274aaf6b53340238
https://github.com/llvm/llvm-project/commit/7ea6d45feaed43266ece53df274aaf6b53340238
Author: Pavel Labath <pavel at labath.sk>
Date: 2026-08-04 (Tue, 04 Aug 2026)
Changed paths:
M libc/cmake/modules/LLVMLibCTestRules.cmake
M libc/test/UnitTest/CMakeLists.txt
A libc/test/UnitTest/LibcCTest.cpp
A libc/test/UnitTest/LibcCTest.h
M libc/test/include/fpclassify_test.c
M libc/test/include/isfinite_test.c
M libc/test/include/isinf_test.c
M libc/test/include/isnan_test.c
M libc/test/include/isnormal_test.c
M libc/test/include/issubnormal_test.c
M libc/test/include/iszero_test.c
M libc/test/include/math_constants_test.c
M libc/test/include/signbit_test.c
M libc/test/include/stdbit_test.c
M utils/bazel/llvm-project-overlay/libc/test/UnitTest/BUILD.bazel
M utils/bazel/llvm-project-overlay/libc/test/include/BUILD.bazel
M utils/bazel/llvm-project-overlay/libc/test/libc_test_rules.bzl
Log Message:
-----------
[libc] Add a C unit test framework wrapper and convert existing tests (#213657)
This removes the dependency on the host C library (hermetic tests),
makes sure the tests actually do something in release builds (where
assert() is a noop), and makes better and more consistent failure
messages.
This is just a thin wrapper over the existing framework which repackages
the C++ interface into something consumable by C code. I tried to keep
the interface consistent, but of course, many of the framework features
are C++ only. Registering more than one test function was tricky, so the
framework currently supports only one.
The main trick here was getting the static library linker to extract
LibcCTest.cpp.o from libLibcTest.unit.a. Since C test cases don't
instantiate static CTest objects in their own translation unit like C++
tests do (they cannot do that portably), nothing in the object file
referenced LibcCTest.cpp. I made this work by introducing
libc_c_test_anchor() and calling it explicitly inside the generated
libc_c_test_run() function.
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list