Skip to content

Commit dd64c82

Browse files
authored
[unittest] Allow LLVM unit test to run under a wrapper program. (llvm#66821)
This patch add CMake option "LLVM_GTEST_RUN_UNDER" to LLVM unittest configuration. When specified, LLVM unittest will be run under the wrapper program specified by this option. This feature can simplify the setup to run LLVM unittest on a target platform that is different than host.
1 parent b337237 commit dd64c82

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

llvm/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1219,6 +1219,9 @@ if( LLVM_INCLUDE_EXAMPLES )
12191219
endif()
12201220

12211221
if( LLVM_INCLUDE_TESTS )
1222+
set(LLVM_GTEST_RUN_UNDER
1223+
"" CACHE STRING
1224+
"Define the wrapper program that LLVM unit tests should be run under.")
12221225
if(EXISTS ${LLVM_MAIN_SRC_DIR}/projects/test-suite AND TARGET clang)
12231226
include(LLVMExternalProjectUtils)
12241227
llvm_ExternalProject_Add(test-suite ${LLVM_MAIN_SRC_DIR}/projects/test-suite

llvm/test/Unit/lit.cfg.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@
1919
config.test_source_root = config.test_exec_root
2020

2121
# testFormat: The test format to use to interpret tests.
22-
config.test_format = lit.formats.GoogleTest(config.llvm_build_mode, "Tests")
22+
config.test_format = lit.formats.GoogleTest(
23+
config.llvm_build_mode,
24+
"Tests",
25+
run_under=config.gtest_run_under,
26+
)
2327

2428
# Propagate the temp directory. Windows requires this because it uses \Windows\
2529
# if none of these are present.

llvm/test/Unit/lit.site.cfg.py.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ config.llvm_obj_root = path(r"@LLVM_BINARY_DIR@")
77
config.llvm_tools_dir = lit_config.substitute(path(r"@LLVM_TOOLS_DIR@"))
88
config.llvm_build_mode = lit_config.substitute("@LLVM_BUILD_MODE@")
99
config.shlibdir = lit_config.substitute(path(r"@SHLIBDIR@"))
10+
config.gtest_run_under = lit_config.substitute(r"@LLVM_GTEST_RUN_UNDER@")
1011

1112
# Let the main config do the real work.
1213
lit_config.load_config(

0 commit comments

Comments
 (0)