gn_files = subprocess.check_output(
['git', 'ls-files', '*BUILD.gn']).splitlines()
- # Matches e.g. | "foo.cpp",|.
+ # Matches e.g. | "foo.cpp",|, captures |foo| in group 1.
gn_cpp_re = re.compile(r'^\s*"([^"]+\.(?:cpp|h))",$', re.MULTILINE)
- # Matches e.g. | "foo.cpp"|.
+ # Matches e.g. | foo.cpp|, captures |foo| in group 1.
cmake_cpp_re = re.compile(r'^\s*([A-Za-z_0-9/-]+\.(?:cpp|h))$',
re.MULTILINE)
def sync_unittests():
+ # Matches e.g. |add_llvm_unittest_with_input_files|.
+ unittest_re = re.compile(r'^add_\S+_unittest', re.MULTILINE)
+
+ # FIXME: Add 'llvm' here once it's complete.
checked = [ 'clang', 'lld' ]
for c in checked:
for root, _, _ in os.walk(os.path.join(c, 'unittests')):
cmake_file = os.path.join(root, 'CMakeLists.txt')
if not os.path.exists(cmake_file):
continue
+ if not unittest_re.search(open(cmake_file).read()):
+ continue # Skip CMake files that just add subdirectories.
gn_file = os.path.join('llvm/utils/gn/secondary', root, 'BUILD.gn')
if not os.path.exists(gn_file):
print('missing GN file %s for unittest CMake file %s' %
"//llvm/tools/sanstats",
"//llvm/tools/verify-uselistorder",
"//llvm/tools/yaml2obj",
+ "//llvm/unittests",
"//llvm/utils/FileCheck",
"//llvm/utils/TableGen:llvm-tblgen",
"//llvm/utils/count",
]
}
- # FIXME: dep on "//llvm/unittests" once it exists
# FIXME: llvm_build_examples
testonly = true
}
--- /dev/null
+import("//llvm/utils/unittest/unittest.gni")
+
+unittest("ADTTests") {
+ # ADT is a headers-only library so there's no //llvm/lib/ADT to depend on.
+ # Also see note in //llvm/lib/Support/BUILD.gn.
+ deps = [
+ # Some tests include files from IR, but there's no library dependency.
+ "//llvm/include/llvm/IR:public_tablegen",
+ "//llvm/lib/Support",
+ ]
+ sources = [
+ "APFloatTest.cpp",
+ "APIntTest.cpp",
+ "APSIntTest.cpp",
+ "AnyTest.cpp",
+ "ArrayRefTest.cpp",
+ "BitVectorTest.cpp",
+ "BitmaskEnumTest.cpp",
+ "BreadthFirstIteratorTest.cpp",
+ "BumpPtrListTest.cpp",
+ "DAGDeltaAlgorithmTest.cpp",
+ "DeltaAlgorithmTest.cpp",
+ "DenseMapTest.cpp",
+ "DenseSetTest.cpp",
+ "DepthFirstIteratorTest.cpp",
+ "EquivalenceClassesTest.cpp",
+ "FoldingSet.cpp",
+ "FunctionExtrasTest.cpp",
+ "FunctionRefTest.cpp",
+ "HashingTest.cpp",
+ "IListBaseTest.cpp",
+ "IListIteratorTest.cpp",
+ "IListNodeBaseTest.cpp",
+ "IListNodeTest.cpp",
+ "IListSentinelTest.cpp",
+ "IListTest.cpp",
+ "ImmutableListTest.cpp",
+ "ImmutableMapTest.cpp",
+ "ImmutableSetTest.cpp",
+ "IntEqClassesTest.cpp",
+ "IntervalMapTest.cpp",
+ "IntrusiveRefCntPtrTest.cpp",
+ "IteratorTest.cpp",
+ "MakeUniqueTest.cpp",
+ "MapVectorTest.cpp",
+ "MappedIteratorTest.cpp",
+ "OptionalTest.cpp",
+ "PackedVectorTest.cpp",
+ "PointerEmbeddedIntTest.cpp",
+ "PointerIntPairTest.cpp",
+ "PointerSumTypeTest.cpp",
+ "PointerUnionTest.cpp",
+ "PostOrderIteratorTest.cpp",
+ "PriorityWorklistTest.cpp",
+ "RangeAdapterTest.cpp",
+ "SCCIteratorTest.cpp",
+ "STLExtrasTest.cpp",
+ "ScopeExitTest.cpp",
+ "SequenceTest.cpp",
+ "SetVectorTest.cpp",
+ "SimpleIListTest.cpp",
+ "SmallPtrSetTest.cpp",
+ "SmallSetTest.cpp",
+ "SmallStringTest.cpp",
+ "SmallVectorTest.cpp",
+ "SparseBitVectorTest.cpp",
+ "SparseMultiSetTest.cpp",
+ "SparseSetTest.cpp",
+ "StatisticTest.cpp",
+ "StringExtrasTest.cpp",
+ "StringMapTest.cpp",
+ "StringRefTest.cpp",
+ "StringSwitchTest.cpp",
+ "TinyPtrVectorTest.cpp",
+ "TripleTest.cpp",
+ "TwineTest.cpp",
+ "VariadicFunctionTest.cpp",
+ ]
+}
--- /dev/null
+import("//llvm/utils/unittest/unittest.gni")
+
+unittest("AnalysisTests") {
+ deps = [
+ "//llvm/lib/Analysis",
+ "//llvm/lib/AsmParser",
+ "//llvm/lib/IR",
+ "//llvm/lib/Support",
+ ]
+ sources = [
+ "AliasAnalysisTest.cpp",
+ "AliasSetTrackerTest.cpp",
+ "BasicAliasAnalysisTest.cpp",
+ "BlockFrequencyInfoTest.cpp",
+ "BranchProbabilityInfoTest.cpp",
+ "CFGTest.cpp",
+ "CGSCCPassManagerTest.cpp",
+ "CallGraphTest.cpp",
+ "DivergenceAnalysisTest.cpp",
+ "GlobalsModRefTest.cpp",
+ "LazyCallGraphTest.cpp",
+ "LoopInfoTest.cpp",
+ "MemoryBuiltinsTest.cpp",
+ "MemorySSATest.cpp",
+ "OrderedBasicBlockTest.cpp",
+ "OrderedInstructionsTest.cpp",
+ "PhiValuesTest.cpp",
+ "ProfileSummaryInfoTest.cpp",
+ "ScalarEvolutionTest.cpp",
+ "SparsePropagation.cpp",
+ "TBAATest.cpp",
+ "TargetLibraryInfoTest.cpp",
+ "UnrollAnalyzerTest.cpp",
+ "ValueLatticeTest.cpp",
+ "ValueTrackingTest.cpp",
+ ]
+}
--- /dev/null
+import("//llvm/utils/unittest/unittest.gni")
+
+unittest("AsmParserTests") {
+ deps = [
+ "//llvm/lib/AsmParser",
+ "//llvm/lib/IR",
+ "//llvm/lib/Support",
+ ]
+ sources = [
+ "AsmParserTest.cpp",
+ ]
+}
--- /dev/null
+import("//llvm/lib/Target/targets.gni")
+
+group("unittests") {
+ deps = [
+ "ADT:ADTTests",
+ "Analysis:AnalysisTests",
+ "AsmParser:AsmParserTests",
+ "BinaryFormat:BinaryFormatTests",
+ "Bitcode:BitcodeTests",
+ "CodeGen:CodeGenTests",
+
+ # FIXME: Add.
+ #"CodeGen/GlobalISel:GlobalISelTests",
+ "DebugInfo/CodeView:DebugInfoCodeViewTests",
+ "DebugInfo/DWARF:DebugInfoDWARFTests",
+ "DebugInfo/MSF:DebugInfoMSFTests",
+
+ # FIXME: Add.
+ #"DebugInfo/PDB:DebugInfoPDBTests",
+ "Demangle:DemangleTests",
+
+ # FIXME: Add more:
+ #"ExecutionEngine:ExecutionEngineTests",
+ #"ExecutionEngine/MCJIT:MCJITTests",
+ #"ExecutionEngine/Orc:OrcJITTests",
+ #"FuzzMutate:FuzzMutateTests",
+ #"IR:IRTests",
+ #"LineEditor:LineEditorTests",
+ #"MC:MCTests",
+ #"MI:MITests",
+ #"Object:ObjectTests",
+ #"ObjectYAML:ObjectYAMLTests",
+ #"Option:OptionTests",
+ #"Passes:PluginsTests",
+ #"ProfileData:ProfileDataTests",
+ #"Support:SupportTests",
+ #"Support/DynamicLibrary:DynamicLibraryTests",
+ #"Transforms/IPO:IPOTests",
+ #"Transforms/Scalar:ScalarTests",
+ #"Transforms/Utils:UtilsTests",
+ #"XRay:XRayTests",
+ #"tools/llvm-cfi-verify:CFIVerifyTests",
+ #"tools/llvm-exegesis:LLVMExegesisTests",
+ ]
+
+ # Target-dependend 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.
+ # FIXME: Add AArch64, ARM these once the Targets exist.
+ #if (llvm_build_AArch64) {
+ #deps += [
+ #"Target/AArch64:AArch64Tests",
+ #"tools/llvm-exegesis/AArch64:LLVMExegesisAArch64Tests",
+ #]
+ #}
+ #if (llvm_build_ARM) {
+ #deps += [ "tools/llvm-exegesis/ARM:LLVMExegesisARMTests" ]
+ #}
+ if (llvm_build_X86) {
+ # FIXME: Add:
+ #deps += [ "tools/llvm-exegesis/X86:LLVMExegesisX86Tests" ]
+ }
+
+ testonly = true
+}
--- /dev/null
+import("//llvm/utils/unittest/unittest.gni")
+
+unittest("BinaryFormatTests") {
+ deps = [
+ "//llvm/lib/BinaryFormat",
+ ]
+ sources = [
+ "DwarfTest.cpp",
+ "MachOTest.cpp",
+ "MsgPackReaderTest.cpp",
+ "MsgPackTypesTest.cpp",
+ "MsgPackWriterTest.cpp",
+ "TestFileMagic.cpp",
+ ]
+}
--- /dev/null
+import("//llvm/utils/unittest/unittest.gni")
+
+unittest("BitcodeTests") {
+ deps = [
+ "//llvm/lib/AsmParser",
+ "//llvm/lib/Bitcode/Reader",
+ "//llvm/lib/Bitcode/Writer",
+ "//llvm/lib/IR",
+ "//llvm/lib/Support",
+ ]
+ sources = [
+ "BitReaderTest.cpp",
+ "BitstreamReaderTest.cpp",
+ "BitstreamWriterTest.cpp",
+ ]
+}
--- /dev/null
+import("//llvm/utils/unittest/unittest.gni")
+
+unittest("CodeGenTests") {
+ deps = [
+ "//llvm/lib/Analysis",
+ "//llvm/lib/AsmParser",
+ "//llvm/lib/CodeGen",
+ "//llvm/lib/CodeGen/AsmPrinter",
+ "//llvm/lib/CodeGen/SelectionDAG",
+ "//llvm/lib/IR",
+ "//llvm/lib/MC",
+ "//llvm/lib/Support",
+ "//llvm/lib/Target",
+ "//llvm/lib/Target:TargetsToBuild",
+ ]
+ sources = [
+ "AArch64SelectionDAGTest.cpp",
+ "DIEHashTest.cpp",
+ "LowLevelTypeTest.cpp",
+ "MachineInstrBundleIteratorTest.cpp",
+ "MachineInstrTest.cpp",
+ "MachineOperandTest.cpp",
+ "ScalableVectorMVTsTest.cpp",
+ ]
+}
--- /dev/null
+import("//llvm/utils/unittest/unittest.gni")
+
+unittest("DebugInfoCodeViewTests") {
+ deps = [
+ "//llvm/lib/DebugInfo/CodeView",
+ "//llvm/lib/Testing/Support",
+ ]
+ sources = [
+ "RandomAccessVisitorTest.cpp",
+ "TypeHashingTest.cpp",
+ "TypeIndexDiscoveryTest.cpp",
+ ]
+}
--- /dev/null
+import("//llvm/utils/unittest/unittest.gni")
+
+unittest("DebugInfoDWARFTests") {
+ deps = [
+ "//llvm/lib/CodeGen/AsmPrinter",
+ "//llvm/lib/DebugInfo/DWARF",
+ "//llvm/lib/MC",
+ "//llvm/lib/Object",
+ "//llvm/lib/ObjectYAML",
+ "//llvm/lib/Support",
+ "//llvm/lib/Target:TargetsToBuild",
+ "//llvm/lib/Testing/Support",
+ ]
+ sources = [
+ "DWARFDebugInfoTest.cpp",
+ "DWARFDebugLineTest.cpp",
+ "DWARFFormValueTest.cpp",
+ "DwarfGenerator.cpp",
+ "DwarfUtils.cpp",
+ ]
+}
--- /dev/null
+import("//llvm/utils/unittest/unittest.gni")
+
+unittest("DebugInfoMSFTests") {
+ deps = [
+ "//llvm/lib/DebugInfo/MSF",
+ "//llvm/lib/Testing/Support",
+ ]
+ sources = [
+ "MSFBuilderTest.cpp",
+ "MSFCommonTest.cpp",
+ "MappedBlockStreamTest.cpp",
+ ]
+}
--- /dev/null
+import("//llvm/utils/unittest/unittest.gni")
+
+unittest("DemangleTests") {
+ deps = [
+ "//llvm/lib/Demangle",
+ ]
+ sources = [
+ "ItaniumDemangleTest.cpp",
+ "PartialDemangleTest.cpp",
+ ]
+}