summaryrefslogtreecommitdiff
path: root/clang/utils/C++Tests/LLVM-Code-Symbols
diff options
context:
space:
mode:
Diffstat (limited to 'clang/utils/C++Tests/LLVM-Code-Symbols')
-rwxr-xr-xclang/utils/C++Tests/LLVM-Code-Symbols/check-symbols54
-rw-r--r--clang/utils/C++Tests/LLVM-Code-Symbols/lit.local.cfg48
2 files changed, 102 insertions, 0 deletions
diff --git a/clang/utils/C++Tests/LLVM-Code-Symbols/check-symbols b/clang/utils/C++Tests/LLVM-Code-Symbols/check-symbols
new file mode 100755
index 0000000..cd54eed
--- /dev/null
+++ b/clang/utils/C++Tests/LLVM-Code-Symbols/check-symbols
@@ -0,0 +1,54 @@
+#!/usr/bin/env python
+
+import subprocess
+import difflib
+
+def capture_2(args0, args1):
+ import subprocess
+ 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 normalize_nm(data):
+ lines = data.split('\n')
+ lines.sort()
+
+ # FIXME: Ignore common symbols for now.
+ lines = [ln for ln in lines
+ if not ln.startswith(' C')]
+
+ return lines
+
+def main():
+ import sys
+ clang = sys.argv[1]
+ flags = sys.argv[2:]
+
+ # FIXME: Relax to include undefined symbols.
+ nm_args = ["llvm-nm", "-extern-only", "-defined-only"]
+
+ llvmgcc_args = ["llvm-gcc"] + flags + ["-emit-llvm","-c","-o","-"]
+ clang_args = [clang] + flags + ["-emit-llvm","-c","-o","-"]
+
+ llvmgcc_nm = capture_2(llvmgcc_args, nm_args)
+ clang_nm = capture_2(clang_args, nm_args)
+
+ llvmgcc_nm = normalize_nm(llvmgcc_nm)
+ clang_nm = normalize_nm(clang_nm)
+
+ if llvmgcc_nm == clang_nm:
+ sys.exit(0)
+
+ print ' '.join(llvmgcc_args), '|', ' '.join(nm_args)
+ print ' '.join(clang_args), '|', ' '.join(nm_args)
+ 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/clang/utils/C++Tests/LLVM-Code-Symbols/lit.local.cfg b/clang/utils/C++Tests/LLVM-Code-Symbols/lit.local.cfg
new file mode 100644
index 0000000..7882813
--- /dev/null
+++ b/clang/utils/C++Tests/LLVM-Code-Symbols/lit.local.cfg
@@ -0,0 +1,48 @@
+# -*- 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/ARM' % 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/X86' % root.llvm_src_root,
+ '-I%s/lib/Target/XCore' % root.llvm_src_root,
+ '-I%s/lib/Target/ARM' % 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/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)$')
+