Skip to content

Commit 8b6ef88

Browse files
author
Zachary Turner
committed
Resubmit "Refactor debuginfo-tests" again.
This was reverted due to the tests being run twice on some build bots. Each run had a slightly different configuration due to the way in which it was being invoked. This fixes the problem (albeit in a somewhat hacky way). Hopefully in the future we can get rid of the workflow of running debuginfo-tests as part of clang, and then this hack can go away. llvm-svn: 318697
1 parent 5c774b9 commit 8b6ef88

28 files changed

+174
-29
lines changed

clang/test/CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,14 @@ set(CLANG_TEST_PARAMS
8888
clang_site_config=${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
8989
)
9090

91+
if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/debuginfo-tests/CMakeLists.txt")
92+
# This is a hack to keep existing build build infrastructure working while we
93+
# can migrate to the new standard workflow of checking out debuginfo-tests into
94+
# llvm/projects or using it in a mono-repo
95+
set(DEBUGINFO_TESTS_EXCLUDE_FROM_ALL ON)
96+
add_subdirectory(debuginfo-tests)
97+
endif()
98+
9199
if( NOT CLANG_BUILT_STANDALONE )
92100
list(APPEND CLANG_TEST_DEPS
93101
llvm-config

clang/test/lit.cfg.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,6 @@
5858

5959
tools = [
6060
'c-index-test', 'clang-check', 'clang-diff', 'clang-format', 'opt',
61-
ToolSubst('%test_debuginfo', command=os.path.join(
62-
config.llvm_src_root, 'utils', 'test_debuginfo.pl')),
6361
ToolSubst('%clang_func_map', command=FindTool(
6462
'clang-func-mapping'), unresolved='ignore'),
6563
]

debuginfo-tests/CMakeLists.txt

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Debug Info tests. These tests invoke clang to generate programs with
2+
# various types of debug info, and then run those programs under a debugger
3+
# such as GDB or LLDB to verify the results.
4+
5+
if (DEBUGINFO_TESTS_EXCLUDE_FROM_ALL)
6+
# When run from inside of the clang tree, lit will pick up two different
7+
# test suites. It will pick up debuginfo-tests as a standalone test
8+
# suite since it has a lit.cfg, but it will also run because it will
9+
# be identified as a subsuite of clang during discovery. We rely on
10+
# clang to set this so that this configuration only gets picked up
11+
# once.
12+
set(EXCLUDE_FROM_ALL ON)
13+
endif()
14+
15+
set(DEBUGINFO_TESTS_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
16+
set(DEBUGINFO_TESTS_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
17+
18+
set(DEBUGINFO_TEST_DEPS
19+
clang
20+
llvm-config
21+
FileCheck
22+
count
23+
not
24+
)
25+
26+
get_target_property(CLANG_SOURCE_DIR clang SOURCE_DIR)
27+
28+
if (TARGET lld)
29+
set(DEBUGINFO_TESTS_HAS_LLD 1)
30+
list(APPEND DEBUGINFO_TEST_DEPS lld)
31+
get_target_property(LLD_SOURCE_DIR lld SOURCE_DIR)
32+
endif()
33+
34+
configure_lit_site_cfg(
35+
${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in
36+
${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg.py
37+
MAIN_CONFIG
38+
${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py
39+
)
40+
41+
add_lit_testsuite(check-debuginfo "Running debug info integration tests"
42+
${CMAKE_CURRENT_BINARY_DIR}
43+
DEPENDS ${DEBUGINFO_TEST_DEPS}
44+
)
45+
46+
set_target_properties(check-debuginfo PROPERTIES FOLDER "Debug info tests")

debuginfo-tests/lit.cfg.py

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# -*- Python -*-
2+
3+
import os
4+
import platform
5+
import re
6+
import subprocess
7+
import tempfile
8+
9+
import lit.formats
10+
import lit.util
11+
12+
from lit.llvm import llvm_config
13+
from lit.llvm.subst import ToolSubst
14+
from lit.llvm.subst import FindTool
15+
16+
# Configuration file for the 'lit' test runner.
17+
18+
# name: The name of this test suite.
19+
config.name = 'debuginfo-tests'
20+
21+
# testFormat: The test format to use to interpret tests.
22+
#
23+
# For now we require '&&' between commands, until they get globally killed and
24+
# the test runner updated.
25+
config.test_format = lit.formats.ShTest(not llvm_config.use_lit_shell)
26+
27+
# suffixes: A list of file extensions to treat as test files.
28+
config.suffixes = ['.c', '.cpp', '.m']
29+
30+
# excludes: A list of directories to exclude from the testsuite. The 'Inputs'
31+
# subdirectories contain auxiliary inputs for various tests in their parent
32+
# directories.
33+
config.excludes = ['Inputs']
34+
35+
# test_source_root: The root path where tests are located.
36+
config.test_source_root = os.path.join(config.debuginfo_tests_src_root, 'tests')
37+
38+
# test_exec_root: The root path where tests should be run.
39+
config.test_exec_root = config.debuginfo_tests_obj_root
40+
41+
llvm_config.use_default_substitutions()
42+
43+
llvm_config.use_clang()
44+
45+
if config.llvm_use_sanitizer:
46+
# Propagate path to symbolizer for ASan/MSan.
47+
llvm_config.with_system_environment(
48+
['ASAN_SYMBOLIZER_PATH', 'MSAN_SYMBOLIZER_PATH'])
49+
50+
tool_dirs = [config.llvm_tools_dir]
51+
52+
tools = [
53+
ToolSubst('%test_debuginfo', command=os.path.join(
54+
config.llvm_src_root, 'utils', 'test_debuginfo.pl')),
55+
]
56+
57+
llvm_config.add_tool_substitutions(tools, tool_dirs)
58+
59+
lit.util.usePlatformSdkOnDarwin(config, lit_config)

debuginfo-tests/lit.site.cfg.py.in

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
@LIT_SITE_CFG_IN_HEADER@
2+
3+
import lit.util
4+
5+
config.test_exec_root = "@CMAKE_BINARY_DIR@"
6+
7+
config.llvm_src_root = "@LLVM_SOURCE_DIR@"
8+
config.llvm_obj_root = "@LLVM_BINARY_DIR@"
9+
config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
10+
config.llvm_libs_dir = "@LLVM_LIBS_DIR@"
11+
config.llvm_shlib_dir = "@SHLIBDIR@"
12+
config.llvm_plugin_ext = "@LLVM_PLUGIN_EXT@"
13+
config.debuginfo_tests_obj_root = "@DEBUGINFO_TESTS_BINARY_DIR@"
14+
config.debuginfo_tests_src_root = "@DEBUGINFO_TESTS_SOURCE_DIR@"
15+
config.has_lld = lit.util.pythonize_bool("@DEBUGINFO_TESTS_HAS_LLD@")
16+
config.host_triple = "@LLVM_HOST_TRIPLE@"
17+
config.target_triple = "@TARGET_TRIPLE@"
18+
config.host_arch = "@HOST_ARCH@"
19+
20+
config.llvm_use_sanitizer = "@LLVM_USE_SANITIZER@"
21+
22+
@LIT_SITE_CFG_IN_FOOTER@
23+
24+
# Let the main config do the real work.
25+
lit_config.load_config(config, "@DEBUGINFO_TESTS_SOURCE_DIR@/lit.cfg.py")

debuginfo-tests/aggregate-indirect-arg.cpp renamed to debuginfo-tests/tests/aggregate-indirect-arg.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// RUN: %clangxx %target_itanium_abi_host_triple -O0 -g %s -c -o %t.o
22
// RUN: %clangxx %target_itanium_abi_host_triple %t.o -o %t.out
3-
// RUN: %test_debuginfo %s %t.out
3+
// RUN: %test_debuginfo %s %t.out
44
// Radar 8945514
55
// DEBUGGER: break 22
66
// DEBUGGER: r
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// RUN: %clang %target_itanium_abi_host_triple -O0 -g %s -c -o %t.o
22
// RUN: %clang %target_itanium_abi_host_triple %t.o -o %t.out -framework Foundation
3-
// RUN: %test_debuginfo %s %t.out
3+
// RUN: %test_debuginfo %s %t.out
44

55
// REQUIRES: system-darwin
66

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// RUN: %clang %target_itanium_abi_host_triple -O0 -g %s -c -o %t.o
22
// RUN: %clang %target_itanium_abi_host_triple %t.o -o %t.out -framework Foundation
3-
// RUN: %test_debuginfo %s %t.out
3+
// RUN: %test_debuginfo %s %t.out
44

55
// REQUIRES: system-darwin
66
// Radar 9279956
@@ -24,9 +24,9 @@ - (void) helper {
2424
int master = 0;
2525
__block int m2 = 0;
2626
__block int dbTransaction = 0;
27-
int (^x)(void) = ^(void) { (void) self;
28-
(void) master;
29-
(void) dbTransaction;
27+
int (^x)(void) = ^(void) { (void) self;
28+
(void) master;
29+
(void) dbTransaction;
3030
m2++;
3131
return m2;
3232
};

0 commit comments

Comments
 (0)