[libc-commits] [libc] [libc] Replace check-libc with lit-based test execution (PR #184163)
Jeff Bailey via libc-commits
libc-commits at lists.llvm.org
Mon Mar 9 06:06:24 PDT 2026
https://github.com/kaladron updated https://github.com/llvm/llvm-project/pull/184163
>From 52c4202bbf3597c3832fdb5f2d1d78a0e12fb54e Mon Sep 17 00:00:00 2001
From: Jeff Bailey <jeffbailey at google.com>
Date: Mon, 2 Mar 2026 16:14:10 +0000
Subject: [PATCH 1/3] [libc] Replace check-libc with lit-based test execution
Now that check-libc-lit has been validated alongside check-libc,
make lit the default test runner by renaming check-libc-lit to
check-libc. Remove the old CMake-driven check-libc custom target.
---
libc/test/CMakeLists.txt | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/libc/test/CMakeLists.txt b/libc/test/CMakeLists.txt
index beea3ad38466a..d7c3738a4ff95 100644
--- a/libc/test/CMakeLists.txt
+++ b/libc/test/CMakeLists.txt
@@ -1,7 +1,5 @@
-add_custom_target(check-libc)
add_custom_target(libc-unit-tests)
add_custom_target(libc-hermetic-tests)
-add_dependencies(check-libc libc-unit-tests libc-hermetic-tests)
add_custom_target(exhaustive-check-libc)
add_custom_target(libc-long-running-tests)
@@ -31,7 +29,7 @@ configure_lit_site_cfg(
"LIBC_GPU_LOADER_EXECUTABLE"
)
-add_lit_testsuite(check-libc-lit
+add_lit_testsuite(check-libc
"Running libc tests via lit"
${LIBC_BUILD_DIR}/test
DEPENDS libc-unit-tests-build libc-hermetic-tests-build
>From 1c649e3fd0980aacd53918013cb976f1f071b913 Mon Sep 17 00:00:00 2001
From: Jeff Bailey <jeffbailey at google.com>
Date: Tue, 3 Mar 2026 18:01:34 +0000
Subject: [PATCH 2/3] [libc] Remove old lit targets
---
libc/test/include/CMakeLists.txt | 1 -
libc/test/integration/CMakeLists.txt | 1 -
2 files changed, 2 deletions(-)
diff --git a/libc/test/include/CMakeLists.txt b/libc/test/include/CMakeLists.txt
index c1828f51c261e..3ac5615d7e209 100644
--- a/libc/test/include/CMakeLists.txt
+++ b/libc/test/include/CMakeLists.txt
@@ -1,6 +1,5 @@
add_custom_target(libc_include_tests)
add_dependencies(check-libc libc_include_tests)
-add_dependencies(check-libc-lit libc_include_tests)
add_libc_test(
assert_test
diff --git a/libc/test/integration/CMakeLists.txt b/libc/test/integration/CMakeLists.txt
index 9a7e9a57752e6..7dbcc9544a0b9 100644
--- a/libc/test/integration/CMakeLists.txt
+++ b/libc/test/integration/CMakeLists.txt
@@ -1,6 +1,5 @@
add_custom_target(libc-integration-tests)
add_dependencies(check-libc libc-integration-tests)
-add_dependencies(check-libc-lit libc-integration-tests)
function(add_libc_integration_test_suite name)
add_custom_target(${name})
>From a4b01a07fe7bac223365400776ad75b1b417169d Mon Sep 17 00:00:00 2001
From: Jeff Bailey <jeffbailey at google.com>
Date: Mon, 9 Mar 2026 13:06:11 +0000
Subject: [PATCH 3/3] Stab in the dark at a Windows fix while I get my
environment set up.
---
libc/utils/libctest/format.py | 40 +++++++++++++++++++++++++++--------
1 file changed, 31 insertions(+), 9 deletions(-)
diff --git a/libc/utils/libctest/format.py b/libc/utils/libctest/format.py
index 6df14d069b652..c8280fd1b5561 100644
--- a/libc/utils/libctest/format.py
+++ b/libc/utils/libctest/format.py
@@ -24,12 +24,16 @@
import os
import shlex
+import sys
import lit.formats
import lit.Test
import lit.util
+kIsWindows = sys.platform in ["win32", "cygwin"]
+
+
class LibcTest(lit.formats.ExecutableTest):
"""
Test format for libc unit tests.
@@ -64,7 +68,8 @@ def _isTestExecutable(self, filename, filepath):
"""
Check if a file is a libc test executable we should run.
- Recognized patterns (all must end with .__build__):
+ Recognized patterns (all must end with .__build__, optionally followed
+ by .exe on Windows):
libc.test.src.<category>.<test_name>.__build__
libc.test.src.<category>.<test_name>.__unit__[.<opts>...].__build__
libc.test.src.<category>.<test_name>.__hermetic__[.<opts>...].__build__
@@ -72,23 +77,40 @@ def _isTestExecutable(self, filename, filepath):
libc.test.include.<test_name>.__hermetic__[.<opts>...].__build__
libc.test.integration.<category>.<test_name>.__build__
"""
- if not filename.endswith(".__build__"):
+ test_name = filename
+ if kIsWindows and filename.endswith(".exe"):
+ test_name = filename[: -len(".exe")]
+
+ if not test_name.endswith(".__build__"):
return False
- if filename.startswith("libc.test.src."):
+ if test_name.startswith("libc.test.src."):
pass # Accept all src tests ending in .__build__
- elif filename.startswith("libc.test.include."):
- if ".__unit__." not in filename and ".__hermetic__." not in filename:
+ elif test_name.startswith("libc.test.include."):
+ if ".__unit__." not in test_name and ".__hermetic__." not in test_name:
return False
- elif filename.startswith("libc.test.integration."):
+ elif test_name.startswith("libc.test.integration."):
pass # Accept all integration tests ending in .__build__
else:
return False
if not os.path.isfile(filepath):
return False
- if not os.access(filepath, os.X_OK):
+ if not kIsWindows and not os.access(filepath, os.X_OK):
return False
return True
+ def _getParamsPath(self, test_path):
+ params_path = test_path + ".params"
+ if os.path.isfile(params_path):
+ return params_path
+
+ root, ext = os.path.splitext(test_path)
+ if ext.lower() == ".exe":
+ params_path = root + ".params"
+ if os.path.isfile(params_path):
+ return params_path
+
+ return None
+
def execute(self, test, litConfig):
"""
Execute a test by running the test executable.
@@ -108,8 +130,8 @@ def execute(self, test, litConfig):
# Format: one arg per line, "---" separator, then KEY=VALUE env lines.
extra_args = []
extra_env = {}
- params_path = test_path + ".params"
- if os.path.isfile(params_path):
+ params_path = self._getParamsPath(test_path)
+ if params_path:
with open(params_path) as f:
content = f.read()
args_section, _, env_section = content.partition("---\n")
More information about the libc-commits
mailing list