Skip to content

Commit 7b06ec0

Browse files
authored
[compiler-rt] Make sure memprof and ctx_profile unittests run (#89814)
They weren't run before as part of `check-compiler-rt`. Verified by adding a `EXPECT_TRUE(false)` in both and observing test failure.
1 parent 96c45a7 commit 7b06ec0

File tree

5 files changed

+94
-0
lines changed

5 files changed

+94
-0
lines changed

compiler-rt/test/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@ if(COMPILER_RT_CAN_EXECUTE_TESTS)
9292
if(COMPILER_RT_BUILD_PROFILE AND COMPILER_RT_HAS_PROFILE)
9393
compiler_rt_test_runtime(profile)
9494
endif()
95+
if(COMPILER_RT_BUILD_CTX_PROFILE)
96+
compiler_rt_test_runtime(ctx_profile)
97+
endif()
9598
if(COMPILER_RT_BUILD_MEMPROF)
9699
compiler_rt_test_runtime(memprof)
97100
endif()
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
set(CTX_PROFILE_LIT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
2+
3+
set(CTX_PROFILE_TESTSUITES)
4+
5+
# Add unit tests.
6+
if(COMPILER_RT_INCLUDE_TESTS)
7+
foreach(arch ${CTX_PROFILE_SUPPORTED_ARCH})
8+
string(TOUPPER ${arch} ARCH_UPPER_CASE)
9+
set(CONFIG_NAME ${ARCH_UPPER_CASE}${OS_NAME}Config)
10+
configure_lit_site_cfg(
11+
${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.site.cfg.py.in
12+
${CMAKE_CURRENT_BINARY_DIR}/Unit/${CONFIG_NAME}/lit.site.cfg.py)
13+
list(APPEND CTX_PROFILE_TEST_DEPS CtxProfileUnitTests)
14+
list(APPEND CTX_PROFILE_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/Unit/${CONFIG_NAME})
15+
endforeach()
16+
endif()
17+
18+
add_lit_testsuite(check-ctx_profile "Running the Contextual Profiler tests"
19+
${CTX_PROFILE_TESTSUITES}
20+
DEPENDS ${CTX_PROFILE_TEST_DEPS})
21+
set_target_properties(check-ctx_profile PROPERTIES FOLDER "Compiler-RT Misc")
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
@LIT_SITE_CFG_IN_HEADER@
2+
3+
import os
4+
import platform
5+
import re
6+
import shlex
7+
8+
# Load common config for all compiler-rt unit tests.
9+
lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/unittests/lit.common.unit.configured")
10+
11+
# Setup config name.
12+
config.name = 'CtxProfile-Unit'
13+
config.target_arch = "@arch@"
14+
assert config.target_arch == 'x86_64'
15+
16+
config.test_exec_root = os.path.join("@COMPILER_RT_BINARY_DIR@",
17+
"lib", "ctx_profile", "tests")
18+
19+
config.test_source_root = config.test_exec_root
20+
21+
# When LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=on, the initial value of
22+
# config.compiler_rt_libdir (COMPILER_RT_RESOLVED_LIBRARY_OUTPUT_DIR) has the
23+
# host triple as the trailing path component. The value is incorrect for i386
24+
# tests on x86_64 hosts and vice versa. But, since only x86_64 is enabled as
25+
# target, and we don't support different environments for building and,
26+
# respectivelly, running tests, we shouldn't see this case.
27+
assert not config.enable_per_target_runtime_dir or config.target_arch == config.host_arch

compiler-rt/test/memprof/CMakeLists.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,19 @@ foreach(arch ${MEMPROF_TEST_ARCH})
4343
${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME})
4444
endforeach()
4545

46+
# Add unit tests.
47+
if(COMPILER_RT_INCLUDE_TESTS)
48+
foreach(arch ${MEMPROF_TEST_ARCH})
49+
string(TOUPPER ${arch} ARCH_UPPER_CASE)
50+
set(CONFIG_NAME ${ARCH_UPPER_CASE}${OS_NAME}Config)
51+
configure_lit_site_cfg(
52+
${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.site.cfg.py.in
53+
${CMAKE_CURRENT_BINARY_DIR}/Unit/${CONFIG_NAME}/lit.site.cfg.py)
54+
list(APPEND MEMPROF_TEST_DEPS MemProfUnitTests)
55+
list(APPEND MEMPROF_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/Unit/${CONFIG_NAME})
56+
endforeach()
57+
endif()
58+
4659
add_lit_testsuite(check-memprof "Running the MemProfiler tests"
4760
${MEMPROF_TESTSUITES}
4861
DEPENDS ${MEMPROF_TEST_DEPS})
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
@LIT_SITE_CFG_IN_HEADER@
2+
3+
import os
4+
import platform
5+
import re
6+
import shlex
7+
8+
# Load common config for all compiler-rt unit tests.
9+
lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/unittests/lit.common.unit.configured")
10+
11+
# Setup config name.
12+
config.name = 'MemProfiler-Unit'
13+
config.target_arch = "@arch@"
14+
assert config.target_arch == 'x86_64'
15+
16+
config.test_exec_root = os.path.join("@COMPILER_RT_BINARY_DIR@",
17+
"lib", "memprof", "tests")
18+
19+
config.test_source_root = config.test_exec_root
20+
21+
# When LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=on, the initial value of
22+
# config.compiler_rt_libdir (COMPILER_RT_RESOLVED_LIBRARY_OUTPUT_DIR) has the
23+
# host triple as the trailing path component. The value is incorrect for i386
24+
# tests on x86_64 hosts and vice versa. But, since only x86_64 is enabled as
25+
# target, and we don't support different environments for building and,
26+
# respectivelly, running tests, we shouldn't see this case.
27+
assert not config.enable_per_target_runtime_dir or config.target_arch == config.host_arch
28+
29+
if not config.parallelism_group:
30+
config.parallelism_group = 'shadow-memory'

0 commit comments

Comments
 (0)