]> granicus.if.org Git - llvm/commitdiff
[gn build] Add build file for DebugInfoPDBTests
authorNico Weber <nicolasweber@gmx.de>
Sat, 5 Jan 2019 00:14:37 +0000 (00:14 +0000)
committerNico Weber <nicolasweber@gmx.de>
Sat, 5 Jan 2019 00:14:37 +0000 (00:14 +0000)
I'm pretty unhappy this patch: DebugInfoPDBTests uses an API that requires some
magic txt file to be next to the unit test executable that stores the absolute
path to the LLVM source root.

The choices here are:

1. Don't use the unittest() template for DebugInfoPDBTests and set output_dir
   for unit tests in two places (the gni file for every test but this one, and the
   BUILD.gn file for this specific test).

2. Add another unittest_foo() template variation for this one test.

I went with the former, and added a comment to the template to look out for
this.

(The CMake build has the same issue.)

Differential Revision: https://reviews.llvm.org/D56324

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@350447 91177308-0d34-0410-b5e6-96231b3b80d8

utils/gn/secondary/llvm/unittests/BUILD.gn
utils/gn/secondary/llvm/unittests/DebugInfo/PDB/BUILD.gn [new file with mode: 0644]
utils/gn/secondary/llvm/utils/unittest/unittest.gni

index 9073478fd25cd7b34a87f5d0f4e255e062e6d95e..abdcbd37b91df7efbeb13b6bca65471479f89c1a 100644 (file)
@@ -14,9 +14,7 @@ group("unittests") {
     "DebugInfo/CodeView:DebugInfoCodeViewTests",
     "DebugInfo/DWARF:DebugInfoDWARFTests",
     "DebugInfo/MSF:DebugInfoMSFTests",
-
-    # FIXME: Add.
-    #"DebugInfo/PDB:DebugInfoPDBTests",
+    "DebugInfo/PDB:DebugInfoPDBTests",
     "Demangle:DemangleTests",
 
     # FIXME: Add.
@@ -55,7 +53,7 @@ group("unittests") {
     "tools/llvm-exegesis:LLVMExegesisTests",
   ]
 
-  # Target-dependend unit tests.
+  # Target-dependent unit tests.
   # FIXME: This matches how they are set up in the cmake build,
   # but if we disable an arch after building with it on, this
   # setup leaves behind stale executables.
diff --git a/utils/gn/secondary/llvm/unittests/DebugInfo/PDB/BUILD.gn b/utils/gn/secondary/llvm/unittests/DebugInfo/PDB/BUILD.gn
new file mode 100644 (file)
index 0000000..cfb92c6
--- /dev/null
@@ -0,0 +1,32 @@
+import("//llvm/utils/unittest/unittest.gni")
+
+unittest("DebugInfoPDBTests") {
+  deps = [
+    "//llvm/lib/DebugInfo/CodeView",
+    "//llvm/lib/DebugInfo/MSF",
+    "//llvm/lib/DebugInfo/PDB",
+    "//llvm/lib/Testing/Support",
+  ]
+  sources = [
+    "HashTableTest.cpp",
+    "NativeSymbolReuseTest.cpp",
+    "PDBApiTest.cpp",
+    "StringTableBuilderTest.cpp",
+  ]
+
+  # DebugInfoPDBTests uses llvm::getInputFileDirectory(), which expects
+  # a file called llvm.srcdir.txt next to the test executable that contains
+  # the path of the source directory (which contains this file).
+  # lit doesn't change the cwd while running googletests, so the cwd isn't
+  # well-defined. This means this has to be an absolute path.
+  # FIXME: This doesn't work with swarming. This should really be a data
+  # dependency, and the cwd while tests requiring input files run should
+  # be required to be some fixed directory.
+  # FIXME: Also, the GN way is to write this file at build time. But since
+  # there's only one use of this, and since this is a pattern that hopefully
+  # will disappear again, and since it doesn't have any measurable performance
+  # hit, write the file at GN time.
+  # Note: This line here implicitly depends on unittest() setting output_dir to
+  # target_out_dir.
+  write_file("$target_out_dir/llvm.srcdir.txt", rebase_path("."))
+}
index d2a6e37fdd4911d17abe269c4ca172930b45d66a..10f4ad3ff339af888259699bec2c92f96d416e0c 100644 (file)
@@ -33,6 +33,9 @@ template("unittest") {
     # run the unit test binary if necessary. Using target_out_dir here
     # means that //clang/unittests/Format gets its binary in
     # out/gn/obj/clang/unittests/Format/FormatTests, which seems fine.
+    #
+    # If you change output_dir here, look through
+    # `git grep target_out_dir '*/unittests/*'` and update those too.
     output_dir = target_out_dir
     deps += [ "//llvm/utils/unittest/UnitTestMain" ]
     testonly = true