aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-12-24 21:27:38 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-12-24 21:27:38 +0000
commite868669d42868f9ebdffb38894237229b3df059c (patch)
tree3d6ee9d3bc0d8026df97c3b044a9d158d3ee8264
parenta1736c0c750d4514a5d8fda36670addf1e4de54a (diff)
Sketch a simple new C++Tests suite for checking that llvm-gcc and clang generate
the same visible symbols, useful for finding ABI/Mangler/vtable/etc. issues. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92147 91177308-0d34-0410-b5e6-96231b3b80d8
-rwxr-xr-xutils/C++Tests/LLVM-Code-Symbols/check-symbols42
-rw-r--r--utils/C++Tests/LLVM-Code-Symbols/lit.local.cfg56
-rw-r--r--utils/C++Tests/lit.cfg1
3 files changed, 99 insertions, 0 deletions
diff --git a/utils/C++Tests/LLVM-Code-Symbols/check-symbols b/utils/C++Tests/LLVM-Code-Symbols/check-symbols
new file mode 100755
index 0000000000..f8ff734c72
--- /dev/null
+++ b/utils/C++Tests/LLVM-Code-Symbols/check-symbols
@@ -0,0 +1,42 @@
+#!/usr/bin/env python
+
+import subprocess
+import difflib
+
+def capture_2(args0, args1):
+ import subprocess
+ print ' '.join(args0)
+ print ' '.join(args1)
+ p0 = subprocess.Popen(args0, stdin=None, stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE)
+ p1 = subprocess.Popen(args1, stdin=p0.stdout, stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE)
+ out,_ = p1.communicate()
+ return out
+
+def main():
+ import sys
+ clang = sys.argv[1]
+ flags = sys.argv[2:]
+
+ llvmgcc_nm = capture_2(["llvm-gcc"] + flags + ["-emit-llvm","-c","-o","-"],
+ ["llvm-nm", "-extern-only"])
+ clang_nm = capture_2([clang] + flags + ["-emit-llvm","-c","-o","-"],
+ ["llvm-nm", "-extern-only"])
+
+ llvmgcc_nm = llvmgcc_nm.split('\n')
+ clang_nm = clang_nm.split('\n')
+ llvmgcc_nm.sort()
+ clang_nm.sort()
+
+ if llvmgcc_nm == clang_nm:
+ sys.exit(0)
+
+ for line in difflib.unified_diff(llvmgcc_nm, clang_nm,
+ fromfile="llvm-gcc symbols",
+ tofile="clang symbols"):
+ print line
+ sys.exit(1)
+
+if __name__ == '__main__':
+ main()
diff --git a/utils/C++Tests/LLVM-Code-Symbols/lit.local.cfg b/utils/C++Tests/LLVM-Code-Symbols/lit.local.cfg
new file mode 100644
index 0000000000..c328a25127
--- /dev/null
+++ b/utils/C++Tests/LLVM-Code-Symbols/lit.local.cfg
@@ -0,0 +1,56 @@
+# -*- Python -*-
+
+# Configuration file for the 'lit' test runner.
+
+def getRoot(config):
+ if not config.parent:
+ return config
+ return getRoot(config.parent)
+
+root = getRoot(config)
+
+# testFormat: The test format to use to interpret tests.
+target_obj_root = root.llvm_obj_root
+cxxflags = ['-D__STDC_LIMIT_MACROS',
+ '-D__STDC_CONSTANT_MACROS',
+ '-Wno-sign-compare',
+ '-I%s/include' % root.llvm_src_root,
+ '-I%s/include' % root.llvm_obj_root,
+ '-I%s/lib/Target/Alpha' % root.llvm_src_root,
+ '-I%s/lib/Target/ARM' % root.llvm_src_root,
+ '-I%s/lib/Target/Blackfin' % root.llvm_src_root,
+ '-I%s/lib/Target/CBackend' % root.llvm_src_root,
+ '-I%s/lib/Target/CellSPU' % root.llvm_src_root,
+ '-I%s/lib/Target/CppBackend' % root.llvm_src_root,
+ '-I%s/lib/Target/Mips' % root.llvm_src_root,
+ '-I%s/lib/Target/MSIL' % root.llvm_src_root,
+ '-I%s/lib/Target/MSP430' % root.llvm_src_root,
+ '-I%s/lib/Target/PIC16' % root.llvm_src_root,
+ '-I%s/lib/Target/PowerPC' % root.llvm_src_root,
+ '-I%s/lib/Target/Sparc' % root.llvm_src_root,
+ '-I%s/lib/Target/SystemZ' % root.llvm_src_root,
+ '-I%s/lib/Target/X86' % root.llvm_src_root,
+ '-I%s/lib/Target/XCore' % root.llvm_src_root,
+ '-I%s/lib/Target/Alpha' % target_obj_root,
+ '-I%s/lib/Target/ARM' % target_obj_root,
+ '-I%s/lib/Target/Blackfin' % target_obj_root,
+ '-I%s/lib/Target/CBackend' % target_obj_root,
+ '-I%s/lib/Target/CellSPU' % target_obj_root,
+ '-I%s/lib/Target/CppBackend' % target_obj_root,
+ '-I%s/lib/Target/Mips' % target_obj_root,
+ '-I%s/lib/Target/MSIL' % target_obj_root,
+ '-I%s/lib/Target/MSP430' % target_obj_root,
+ '-I%s/lib/Target/PIC16' % target_obj_root,
+ '-I%s/lib/Target/PowerPC' % target_obj_root,
+ '-I%s/lib/Target/Sparc' % target_obj_root,
+ '-I%s/lib/Target/SystemZ' % target_obj_root,
+ '-I%s/lib/Target/X86' % target_obj_root,
+ '-I%s/lib/Target/XCore' % target_obj_root];
+
+kScript = os.path.join(os.path.dirname(__file__), "check-symbols")
+config.test_format = \
+ lit.formats.OneCommandPerFileTest(command=[kScript, root.clang] + cxxflags,
+ dir='%s/lib' % root.llvm_src_root,
+ recursive=True,
+ pattern='^(.*\\.cpp)$')
+
diff --git a/utils/C++Tests/lit.cfg b/utils/C++Tests/lit.cfg
index e61502b62e..274ca103f4 100644
--- a/utils/C++Tests/lit.cfg
+++ b/utils/C++Tests/lit.cfg
@@ -24,3 +24,4 @@ if not lit.params.get('run_clang_all'):
config.excludes.append('Clang-Code-Compile')
config.excludes.append('LLVM-Code-Syntax')
config.excludes.append('LLVM-Code-Compile')
+ config.excludes.append('LLVM-Code-Symbols')