[compiler-rt] [compiler-rt] Make sure `memprof` and `ctx_profile` unittests run (PR #89814)
Mircea Trofin via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 23 12:45:22 PDT 2024
https://github.com/mtrofin created https://github.com/llvm/llvm-project/pull/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.
>From 4c75b9d27cb57f34d1d9c5201fa6f88f4181f594 Mon Sep 17 00:00:00 2001
From: Mircea Trofin <mtrofin at google.com>
Date: Tue, 23 Apr 2024 12:43:28 -0700
Subject: [PATCH] [compiler-rt] Make sure `memprof` and `ctx_profile` unittests
run
They weren't run before as part of `check-compiler-rt`.
Verified by adding a `EXPECT_TRUE(false)` in both and observing test failure.
---
compiler-rt/test/CMakeLists.txt | 3 +++
compiler-rt/test/ctx_profile/CMakeLists.txt | 21 ++++++++++++++++++
.../test/ctx_profile/Unit/lit.site.cfg.py.in | 22 +++++++++++++++++++
compiler-rt/test/memprof/CMakeLists.txt | 13 +++++++++++
.../test/memprof/Unit/lit.site.cfg.py.in | 22 +++++++++++++++++++
5 files changed, 81 insertions(+)
create mode 100644 compiler-rt/test/ctx_profile/CMakeLists.txt
create mode 100644 compiler-rt/test/ctx_profile/Unit/lit.site.cfg.py.in
create mode 100644 compiler-rt/test/memprof/Unit/lit.site.cfg.py.in
diff --git a/compiler-rt/test/CMakeLists.txt b/compiler-rt/test/CMakeLists.txt
index edc007aaf477a7..8805cc8f798f18 100644
--- a/compiler-rt/test/CMakeLists.txt
+++ b/compiler-rt/test/CMakeLists.txt
@@ -92,6 +92,9 @@ if(COMPILER_RT_CAN_EXECUTE_TESTS)
if(COMPILER_RT_BUILD_PROFILE AND COMPILER_RT_HAS_PROFILE)
compiler_rt_test_runtime(profile)
endif()
+ if(COMPILER_RT_BUILD_CTX_PROFILE)
+ compiler_rt_test_runtime(ctx_profile)
+ endif()
if(COMPILER_RT_BUILD_MEMPROF)
compiler_rt_test_runtime(memprof)
endif()
diff --git a/compiler-rt/test/ctx_profile/CMakeLists.txt b/compiler-rt/test/ctx_profile/CMakeLists.txt
new file mode 100644
index 00000000000000..23c6fb16ed1f40
--- /dev/null
+++ b/compiler-rt/test/ctx_profile/CMakeLists.txt
@@ -0,0 +1,21 @@
+set(CTX_PROFILE_LIT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
+
+set(CTX_PROFILE_TESTSUITES)
+
+# Add unit tests.
+if(COMPILER_RT_INCLUDE_TESTS)
+ foreach(arch ${CTX_PROFILE_SUPPORTED_ARCH})
+ string(TOUPPER ${arch} ARCH_UPPER_CASE)
+ set(CONFIG_NAME ${ARCH_UPPER_CASE}${OS_NAME}Config)
+ configure_lit_site_cfg(
+ ${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.site.cfg.py.in
+ ${CMAKE_CURRENT_BINARY_DIR}/Unit/${CONFIG_NAME}/lit.site.cfg.py)
+ list(APPEND CTX_PROFILE_TEST_DEPS CtxProfileUnitTests)
+ list(APPEND CTX_PROFILE_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/Unit/${CONFIG_NAME})
+ endforeach()
+endif()
+
+add_lit_testsuite(check-ctx_profile "Running the Contextual Profiler tests"
+ ${CTX_PROFILE_TESTSUITES}
+ DEPENDS ${CTX_PROFILE_TEST_DEPS})
+set_target_properties(check-ctx_profile PROPERTIES FOLDER "Compiler-RT Misc")
diff --git a/compiler-rt/test/ctx_profile/Unit/lit.site.cfg.py.in b/compiler-rt/test/ctx_profile/Unit/lit.site.cfg.py.in
new file mode 100644
index 00000000000000..e43bb8d4cbbd66
--- /dev/null
+++ b/compiler-rt/test/ctx_profile/Unit/lit.site.cfg.py.in
@@ -0,0 +1,22 @@
+ at LIT_SITE_CFG_IN_HEADER@
+
+import os
+import platform
+import re
+import shlex
+
+# Load common config for all compiler-rt unit tests.
+lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/unittests/lit.common.unit.configured")
+
+# Setup config name.
+config.name = 'CtxProfile-Unit'
+config.target_arch = "@arch@"
+assert config.target_arch == 'x86_64'
+
+config.test_exec_root = os.path.join("@COMPILER_RT_BINARY_DIR@",
+ "lib", "ctx_profile", "tests")
+
+config.test_source_root = config.test_exec_root
+
+if config.enable_per_target_runtime_dir and config.target_arch != config.host_arch:
+ config.compiler_rt_libdir = re.sub(r'/i386(?=-[^/]+$)', '/x86_64', config.compiler_rt_libdir)
diff --git a/compiler-rt/test/memprof/CMakeLists.txt b/compiler-rt/test/memprof/CMakeLists.txt
index 3f0ba3812485d2..fa6a4cd5f0b76a 100644
--- a/compiler-rt/test/memprof/CMakeLists.txt
+++ b/compiler-rt/test/memprof/CMakeLists.txt
@@ -43,6 +43,19 @@ foreach(arch ${MEMPROF_TEST_ARCH})
${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME})
endforeach()
+# Add unit tests.
+if(COMPILER_RT_INCLUDE_TESTS)
+ foreach(arch ${MEMPROF_TEST_ARCH})
+ string(TOUPPER ${arch} ARCH_UPPER_CASE)
+ set(CONFIG_NAME ${ARCH_UPPER_CASE}${OS_NAME}Config)
+ configure_lit_site_cfg(
+ ${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.site.cfg.py.in
+ ${CMAKE_CURRENT_BINARY_DIR}/Unit/${CONFIG_NAME}/lit.site.cfg.py)
+ list(APPEND MEMPROF_TEST_DEPS MemProfUnitTests)
+ list(APPEND MEMPROF_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/Unit/${CONFIG_NAME})
+ endforeach()
+endif()
+
add_lit_testsuite(check-memprof "Running the MemProfiler tests"
${MEMPROF_TESTSUITES}
DEPENDS ${MEMPROF_TEST_DEPS})
diff --git a/compiler-rt/test/memprof/Unit/lit.site.cfg.py.in b/compiler-rt/test/memprof/Unit/lit.site.cfg.py.in
new file mode 100644
index 00000000000000..ab8494809c6e1f
--- /dev/null
+++ b/compiler-rt/test/memprof/Unit/lit.site.cfg.py.in
@@ -0,0 +1,22 @@
+ at LIT_SITE_CFG_IN_HEADER@
+
+import os
+import platform
+import re
+import shlex
+
+# Load common config for all compiler-rt unit tests.
+lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/unittests/lit.common.unit.configured")
+
+# Setup config name.
+config.name = 'MemProfiler-Unit'
+config.target_arch = "@arch@"
+assert config.target_arch == 'x86_64'
+
+config.test_exec_root = os.path.join("@COMPILER_RT_BINARY_DIR@",
+ "lib", "memprof", "tests")
+
+config.test_source_root = config.test_exec_root
+
+if config.enable_per_target_runtime_dir and config.target_arch != config.host_arch:
+ config.compiler_rt_libdir = re.sub(r'/i386(?=-[^/]+$)', '/x86_64', config.compiler_rt_libdir)
More information about the llvm-commits
mailing list