Resubmit "Refactor debuginfo-tests" again.
authorZachary Turner <zturner@google.com>
Mon, 20 Nov 2017 21:41:36 +0000 (21:41 +0000)
committerZachary Turner <zturner@google.com>
Mon, 20 Nov 2017 21:41:36 +0000 (21:41 +0000)
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

28 files changed:
clang/test/CMakeLists.txt
clang/test/lit.cfg.py
debuginfo-tests/CMakeLists.txt [new file with mode: 0644]
debuginfo-tests/lit.cfg.py [new file with mode: 0644]
debuginfo-tests/lit.site.cfg.py.in [new file with mode: 0644]
debuginfo-tests/tests/aggregate-indirect-arg.cpp [moved from debuginfo-tests/aggregate-indirect-arg.cpp with 93% similarity]
debuginfo-tests/tests/asan-blocks.c [moved from debuginfo-tests/asan-blocks.c with 100% similarity]
debuginfo-tests/tests/asan.c [moved from debuginfo-tests/asan.c with 100% similarity]
debuginfo-tests/tests/block_var.m [moved from debuginfo-tests/block_var.m with 93% similarity]
debuginfo-tests/tests/blocks.m [moved from debuginfo-tests/blocks.m with 85% similarity]
debuginfo-tests/tests/ctor.cpp [moved from debuginfo-tests/ctor.cpp with 78% similarity]
debuginfo-tests/tests/dbg-arg.c [moved from debuginfo-tests/dbg-arg.c with 100% similarity]
debuginfo-tests/tests/foreach.m [moved from debuginfo-tests/foreach.m with 94% similarity]
debuginfo-tests/tests/forward-declare-class.cpp [moved from debuginfo-tests/forward-declare-class.cpp with 100% similarity]
debuginfo-tests/tests/lit.local.cfg [moved from debuginfo-tests/lit.local.cfg with 100% similarity]
debuginfo-tests/tests/llgdb.py [moved from debuginfo-tests/llgdb.py with 100% similarity]
debuginfo-tests/tests/nested-struct.cpp [moved from debuginfo-tests/nested-struct.cpp with 100% similarity]
debuginfo-tests/tests/nrvo-string.cpp [moved from debuginfo-tests/nrvo-string.cpp with 100% similarity]
debuginfo-tests/tests/safestack.c [moved from debuginfo-tests/safestack.c with 100% similarity]
debuginfo-tests/tests/sret.cpp [moved from debuginfo-tests/sret.cpp with 93% similarity]
debuginfo-tests/tests/stack-var.c [moved from debuginfo-tests/stack-var.c with 100% similarity]
debuginfo-tests/tests/static-member-2.cpp [moved from debuginfo-tests/static-member-2.cpp with 100% similarity]
debuginfo-tests/tests/static-member.cpp [moved from debuginfo-tests/static-member.cpp with 100% similarity]
debuginfo-tests/tests/vla.c [moved from debuginfo-tests/vla.c with 93% similarity]
llvm/CMakeLists.txt
llvm/projects/CMakeLists.txt
llvm/utils/lit/lit/llvm/config.py
llvm/utils/test_debuginfo.pl

index c1ac9e4..3bf69bf 100644 (file)
@@ -88,6 +88,14 @@ set(CLANG_TEST_PARAMS
   clang_site_config=${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
   )
 
+if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/debuginfo-tests/CMakeLists.txt")
+  # This is a hack to keep existing build build infrastructure working while we
+  # can migrate to the new standard workflow of checking out debuginfo-tests into
+  # llvm/projects or using it in a mono-repo
+  set(DEBUGINFO_TESTS_EXCLUDE_FROM_ALL ON)
+  add_subdirectory(debuginfo-tests)
+endif()
+
 if( NOT CLANG_BUILT_STANDALONE )
   list(APPEND CLANG_TEST_DEPS
     llvm-config
index 39bdf36..d2f0491 100644 (file)
@@ -58,8 +58,6 @@ tool_dirs = [config.clang_tools_dir, config.llvm_tools_dir]
 
 tools = [
     'c-index-test', 'clang-check', 'clang-diff', 'clang-format', 'opt',
-    ToolSubst('%test_debuginfo', command=os.path.join(
-        config.llvm_src_root, 'utils', 'test_debuginfo.pl')),
     ToolSubst('%clang_func_map', command=FindTool(
         'clang-func-mapping'), unresolved='ignore'),
 ]
diff --git a/debuginfo-tests/CMakeLists.txt b/debuginfo-tests/CMakeLists.txt
new file mode 100644 (file)
index 0000000..5c4b170
--- /dev/null
@@ -0,0 +1,46 @@
+# Debug Info tests.  These tests invoke clang to generate programs with
+# various types of debug info, and then run those programs under a debugger
+# such as GDB or LLDB to verify the results.
+
+if (DEBUGINFO_TESTS_EXCLUDE_FROM_ALL)
+  # When run from inside of the clang tree, lit will pick up two different
+  # test suites.  It will pick up debuginfo-tests as a standalone test
+  # suite since it has a lit.cfg, but it will also run because it will
+  # be identified as a subsuite of clang during discovery.  We rely on
+  # clang to set this so that this configuration only gets picked up
+  # once.
+  set(EXCLUDE_FROM_ALL ON)
+endif()
+
+set(DEBUGINFO_TESTS_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
+set(DEBUGINFO_TESTS_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
+
+set(DEBUGINFO_TEST_DEPS
+  clang
+  llvm-config
+  FileCheck
+  count
+  not
+  )
+
+get_target_property(CLANG_SOURCE_DIR clang SOURCE_DIR)
+
+if (TARGET lld)
+  set(DEBUGINFO_TESTS_HAS_LLD 1)
+  list(APPEND DEBUGINFO_TEST_DEPS lld)
+  get_target_property(LLD_SOURCE_DIR lld SOURCE_DIR)
+endif()
+
+configure_lit_site_cfg(
+  ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in
+  ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg.py
+  MAIN_CONFIG
+  ${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py
+  )
+
+add_lit_testsuite(check-debuginfo "Running debug info integration tests"
+  ${CMAKE_CURRENT_BINARY_DIR}
+  DEPENDS ${DEBUGINFO_TEST_DEPS}
+  )
+
+set_target_properties(check-debuginfo PROPERTIES FOLDER "Debug info tests")
\ No newline at end of file
diff --git a/debuginfo-tests/lit.cfg.py b/debuginfo-tests/lit.cfg.py
new file mode 100644 (file)
index 0000000..f754cef
--- /dev/null
@@ -0,0 +1,59 @@
+# -*- Python -*-
+
+import os
+import platform
+import re
+import subprocess
+import tempfile
+
+import lit.formats
+import lit.util
+
+from lit.llvm import llvm_config
+from lit.llvm.subst import ToolSubst
+from lit.llvm.subst import FindTool
+
+# Configuration file for the 'lit' test runner.
+
+# name: The name of this test suite.
+config.name = 'debuginfo-tests'
+
+# testFormat: The test format to use to interpret tests.
+#
+# For now we require '&&' between commands, until they get globally killed and
+# the test runner updated.
+config.test_format = lit.formats.ShTest(not llvm_config.use_lit_shell)
+
+# suffixes: A list of file extensions to treat as test files.
+config.suffixes = ['.c', '.cpp', '.m']
+
+# excludes: A list of directories to exclude from the testsuite. The 'Inputs'
+# subdirectories contain auxiliary inputs for various tests in their parent
+# directories.
+config.excludes = ['Inputs']
+
+# test_source_root: The root path where tests are located.
+config.test_source_root = os.path.join(config.debuginfo_tests_src_root, 'tests')
+
+# test_exec_root: The root path where tests should be run.
+config.test_exec_root = config.debuginfo_tests_obj_root
+
+llvm_config.use_default_substitutions()
+
+llvm_config.use_clang()
+
+if config.llvm_use_sanitizer:
+    # Propagate path to symbolizer for ASan/MSan.
+    llvm_config.with_system_environment(
+        ['ASAN_SYMBOLIZER_PATH', 'MSAN_SYMBOLIZER_PATH'])
+
+tool_dirs = [config.llvm_tools_dir]
+
+tools = [
+    ToolSubst('%test_debuginfo', command=os.path.join(
+        config.llvm_src_root, 'utils', 'test_debuginfo.pl')),
+]
+
+llvm_config.add_tool_substitutions(tools, tool_dirs)
+
+lit.util.usePlatformSdkOnDarwin(config, lit_config)
diff --git a/debuginfo-tests/lit.site.cfg.py.in b/debuginfo-tests/lit.site.cfg.py.in
new file mode 100644 (file)
index 0000000..8c4481a
--- /dev/null
@@ -0,0 +1,25 @@
+@LIT_SITE_CFG_IN_HEADER@
+
+import lit.util
+
+config.test_exec_root = "@CMAKE_BINARY_DIR@"
+
+config.llvm_src_root = "@LLVM_SOURCE_DIR@"
+config.llvm_obj_root = "@LLVM_BINARY_DIR@"
+config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
+config.llvm_libs_dir = "@LLVM_LIBS_DIR@"
+config.llvm_shlib_dir = "@SHLIBDIR@"
+config.llvm_plugin_ext = "@LLVM_PLUGIN_EXT@"
+config.debuginfo_tests_obj_root = "@DEBUGINFO_TESTS_BINARY_DIR@"
+config.debuginfo_tests_src_root = "@DEBUGINFO_TESTS_SOURCE_DIR@"
+config.has_lld = lit.util.pythonize_bool("@DEBUGINFO_TESTS_HAS_LLD@")
+config.host_triple = "@LLVM_HOST_TRIPLE@"
+config.target_triple = "@TARGET_TRIPLE@"
+config.host_arch = "@HOST_ARCH@"
+
+config.llvm_use_sanitizer = "@LLVM_USE_SANITIZER@"
+
+@LIT_SITE_CFG_IN_FOOTER@
+
+# Let the main config do the real work.
+lit_config.load_config(config, "@DEBUGINFO_TESTS_SOURCE_DIR@/lit.cfg.py")
@@ -1,6 +1,6 @@
 // RUN: %clangxx %target_itanium_abi_host_triple -O0 -g %s -c -o %t.o
 // RUN: %clangxx %target_itanium_abi_host_triple %t.o -o %t.out
-// RUN: %test_debuginfo %s %t.out 
+// RUN: %test_debuginfo %s %t.out
 // Radar 8945514
 // DEBUGGER: break 22
 // DEBUGGER: r
similarity index 93%
rename from debuginfo-tests/block_var.m
rename to debuginfo-tests/tests/block_var.m
index 7ec786f..3286217 100644 (file)
@@ -1,6 +1,6 @@
 // RUN: %clang %target_itanium_abi_host_triple -O0 -g %s -c -o %t.o
 // RUN: %clang %target_itanium_abi_host_triple %t.o -o %t.out -framework Foundation
-// RUN: %test_debuginfo %s %t.out 
+// RUN: %test_debuginfo %s %t.out
 
 // REQUIRES: system-darwin
 
similarity index 85%
rename from debuginfo-tests/blocks.m
rename to debuginfo-tests/tests/blocks.m
index 8e5a212..12c9977 100644 (file)
@@ -1,6 +1,6 @@
 // RUN: %clang %target_itanium_abi_host_triple -O0 -g %s -c -o %t.o
 // RUN: %clang %target_itanium_abi_host_triple %t.o -o %t.out -framework Foundation
-// RUN: %test_debuginfo %s %t.out 
+// RUN: %test_debuginfo %s %t.out
 
 // REQUIRES: system-darwin
 // Radar 9279956
@@ -24,9 +24,9 @@ extern void foo(void(^)(void));
  int master = 0;
  __block int m2 = 0;
  __block int dbTransaction = 0;
- int (^x)(void) = ^(void) { (void) self; 
-       (void) master; 
-       (void) dbTransaction; 
+ int (^x)(void) = ^(void) { (void) self;
+       (void) master;
+       (void) dbTransaction;
        m2++;
        return m2;
        };
similarity index 78%
rename from debuginfo-tests/ctor.cpp
rename to debuginfo-tests/tests/ctor.cpp
index 92cdbcd..364401a 100644 (file)
@@ -1,12 +1,12 @@
 // RUN: %clangxx %target_itanium_abi_host_triple -O0 -g %s -c -o %t.o
 // RUN: %clangxx %target_itanium_abi_host_triple %t.o -o %t.out
-// RUN: %test_debuginfo %s %t.out 
+// RUN: %test_debuginfo %s %t.out
 
 
 // DEBUGGER: break 14
 // DEBUGGER: r
 // DEBUGGER: p *this
-// CHECK-NEXT-NOT: Cannot access memory at address 
+// CHECK-NEXT-NOT: Cannot access memory at address
 
 class A {
 public:
similarity index 94%
rename from debuginfo-tests/foreach.m
rename to debuginfo-tests/tests/foreach.m
index 2e3c312..ccdc282 100644 (file)
@@ -1,6 +1,6 @@
 // RUN: %clang %target_itanium_abi_host_triple -O0 -g %s -c -o %t.o
 // RUN: %clang %target_itanium_abi_host_triple %t.o -o %t.out -framework Foundation
-// RUN: %test_debuginfo %s %t.out 
+// RUN: %test_debuginfo %s %t.out
 //
 // REQUIRES: system-darwin
 // Radar 8757124
@@ -19,7 +19,7 @@ int main (int argc, const char * argv[]) {
     for (NSString *thing in things) {
         NSLog (@"%@", thing);
     }
-    
+
     things = [NSArray arrayWithObjects:@"aaa", @"bbb", @"ccc" , nil];
     for (NSString *thing in things) {
         NSLog (@"%@", thing);
similarity index 93%
rename from debuginfo-tests/sret.cpp
rename to debuginfo-tests/tests/sret.cpp
index 3c304e2..640015f 100644 (file)
@@ -1,6 +1,6 @@
 // RUN: %clangxx %target_itanium_abi_host_triple -O0 -g %s -c -o %t.o
 // RUN: %clangxx %target_itanium_abi_host_triple %t.o -o %t.out
-// RUN: %test_debuginfo %s %t.out 
+// RUN: %test_debuginfo %s %t.out
 // Radar 8775834
 // DEBUGGER: break 62
 // DEBUGGER: r
@@ -24,7 +24,7 @@ protected:
     int m_int;
 };
 
-A::A (int i) : 
+A::A (int i) :
     m_int(i)
 {
 }
@@ -50,11 +50,11 @@ class B
 {
 public:
     B () {}
-    
+
     A AInstance();
 };
 
-A 
+A
 B::AInstance()
 {
     A a(12);
@@ -65,7 +65,7 @@ int main (int argc, char const *argv[])
 {
     B b;
     int return_val = b.AInstance().get_int();
-    
+
     A a(b.AInstance());
     return return_val;
 }
similarity index 93%
rename from debuginfo-tests/vla.c
rename to debuginfo-tests/tests/vla.c
index 9c8e277..e6ea1ef 100644 (file)
@@ -1,7 +1,7 @@
 // This test case verifies the debug location for variable-length arrays.
 // RUN: %clang %target_itanium_abi_host_triple -O0 -g %s -c -o %t.o
 // RUN: %clang %target_itanium_abi_host_triple %t.o -o %t.out
-// RUN: %test_debuginfo %s %t.out 
+// RUN: %test_debuginfo %s %t.out
 //
 // DEBUGGER: break 18
 // DEBUGGER: r
index 8cd9d05..5f5b138 100644 (file)
@@ -110,7 +110,7 @@ endif()
 # LLVM_EXTERNAL_${project}_SOURCE_DIR using LLVM_ALL_PROJECTS
 # This allows an easy way of setting up a build directory for llvm and another
 # one for llvm+clang+... using the same sources.
-set(LLVM_ALL_PROJECTS "clang;libcxx;libcxxabi;lldb;compiler-rt;lld;polly")
+set(LLVM_ALL_PROJECTS "clang;libcxx;libcxxabi;lldb;compiler-rt;debuginfo-tests;lld;polly")
 set(LLVM_ENABLE_PROJECTS "" CACHE STRING
        "Semicolon-separated list of projects to build (${LLVM_ALL_PROJECTS}), or \"all\".")
 if( LLVM_ENABLE_PROJECTS STREQUAL "all" )
@@ -885,13 +885,18 @@ if( LLVM_INCLUDE_EXAMPLES )
 endif()
 
 if( LLVM_INCLUDE_TESTS )
-  if(EXISTS ${LLVM_MAIN_SRC_DIR}/projects/test-suite AND TARGET clang)
+  if(TARGET clang)
     include(LLVMExternalProjectUtils)
-    llvm_ExternalProject_Add(test-suite ${LLVM_MAIN_SRC_DIR}/projects/test-suite
-      USE_TOOLCHAIN
-      EXCLUDE_FROM_ALL
-      NO_INSTALL
-      ALWAYS_CLEAN)
+    if (EXISTS ${LLVM_MAIN_SRC_DIR}/projects/test-suite)
+      llvm_ExternalProject_Add(test-suite ${LLVM_MAIN_SRC_DIR}/projects/test-suite
+        USE_TOOLCHAIN
+        TOOLCHAIN_TOOLS clang lld clang-cl
+        EXCLUDE_FROM_ALL
+        NO_INSTALL
+        ALWAYS_CLEAN)
+    endif()
+
+    add_llvm_external_project(debuginfo-tests projects/debuginfo-tests)
   endif()
   add_subdirectory(utils/lit)
   add_subdirectory(test)
index 9102efb..11835fa 100644 (file)
@@ -10,6 +10,7 @@ foreach(entry ${entries})
        (NOT ${entry} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR}/libcxxabi) AND
        (NOT ${entry} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR}/libunwind) AND
        (NOT ${entry} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR}/test-suite) AND
+       (NOT ${entry} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR}/debuginfo-tests) AND
        (NOT ${entry} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR}/parallel-libs) AND
        (NOT ${entry} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR}/openmp))
       add_subdirectory(${entry})
index c631f8b..261f1b3 100644 (file)
@@ -27,8 +27,9 @@ class LLVMConfig(object):
             # For tests that require Windows to run.
             features.add('system-windows')
 
+            lit_tools_dir = getattr(config, 'lit_tools_dir', None)
             # Seek sane tools in directories and set to $PATH.
-            path = self.lit_config.getToolsPath(config.lit_tools_dir,
+            path = self.lit_config.getToolsPath(lit_tools_dir,
                                                 config.environment['PATH'],
                                                 ['cmp.exe', 'grep.exe', 'sed.exe'])
             if path is not None:
@@ -413,8 +414,10 @@ class LLVMConfig(object):
             self.config.substitutions.append(
                 ('%target_itanium_abi_host_triple', ''))
 
-        self.config.substitutions.append(
-            ('%src_include_dir', self.config.clang_src_dir + '/include'))
+        clang_src_dir = getattr(self.config, 'clang_src_dir', None)
+        if clang_src_dir:
+            self.config.substitutions.append(
+                ('%src_include_dir', os.path.join(clang_src_dir, 'include')))
 
         # FIXME: Find nicer way to prohibit this.
         self.config.substitutions.append(
index aaf90d9..d9613d7 100755 (executable)
@@ -56,7 +56,7 @@ my $my_debugger = $ENV{'DEBUGGER'};
 if (!$my_debugger) {
     if ($use_lldb) {
         my $path = dirname(Cwd::abs_path($0));
-        $my_debugger = "/usr/bin/env python $path/../tools/clang/test/debuginfo-tests/llgdb.py";
+        $my_debugger = "/usr/bin/env python $path/../tools/clang/test/debuginfo-tests/tests/llgdb.py";
     } else {
         $my_debugger = "gdb";
     }