[libc-commits] [libc] [libc] Implement lit-based test execution for Libc (PR #178746)
Petr Hosek via libc-commits
libc-commits at lists.llvm.org
Thu Jan 29 23:51:39 PST 2026
================
@@ -0,0 +1,85 @@
+#===============================================================================
+# Lit Test Infrastructure for LLVM libc
+#
+# This module provides functions to set up lit-based testing for libc.
+#
+# Lit discovers and runs the test executables created by the
+# add_libc_test() infrastructure. No separate build rules are needed.
+#===============================================================================
+
+# Guard against double inclusion
+if(LIBC_LIT_TEST_RULES_INCLUDED)
+ return()
+endif()
+set(LIBC_LIT_TEST_RULES_INCLUDED TRUE)
+
+# Include LLVM's lit infrastructure
+include(AddLLVM)
+
+#-------------------------------------------------------------------------------
+# configure_libc_lit_site_cfg()
+#
+# Configures the lit.site.cfg.py file from its template.
+# This should be called once from libc/test/CMakeLists.txt.
+#-------------------------------------------------------------------------------
+function(configure_libc_lit_site_cfg)
+ # Set variables for the template
+ set(LIBC_SOURCE_DIR "${LIBC_SOURCE_DIR}")
+ set(LIBC_BINARY_DIR "${LIBC_BUILD_DIR}")
+
+ # Configure the site config file
+ configure_lit_site_cfg(
+ ${LIBC_SOURCE_DIR}/test/lit.site.cfg.py.in
+ ${LIBC_BUILD_DIR}/test/lit.site.cfg.py
+ MAIN_CONFIG
+ ${LIBC_SOURCE_DIR}/test/lit.cfg.py
+ PATHS
+ "LLVM_SOURCE_DIR"
+ "LLVM_BINARY_DIR"
+ "LLVM_TOOLS_DIR"
+ "LLVM_LIBS_DIR"
+ "LIBC_SOURCE_DIR"
+ "LIBC_BINARY_DIR"
+ )
+endfunction()
----------------
petrhosek wrote:
Is there any specific reason for not inlining this logic directly in `libc/test/CMakeLists.txt`?
https://github.com/llvm/llvm-project/pull/178746
More information about the libc-commits
mailing list