[Lldb-commits] [lldb] d1326a3 - [lldb] Fix broken skipUnlessUndefinedBehaviorSanitizer decorator
Jonas Devlieghere via lldb-commits
lldb-commits at lists.llvm.org
Tue Nov 30 13:03:39 PST 2021
Author: Jonas Devlieghere
Date: 2021-11-30T13:03:33-08:00
New Revision: d1326a3b10054dd89be46f51f857d009cf8ae14f
URL: https://github.com/llvm/llvm-project/commit/d1326a3b10054dd89be46f51f857d009cf8ae14f
DIFF: https://github.com/llvm/llvm-project/commit/d1326a3b10054dd89be46f51f857d009cf8ae14f.diff
LOG: [lldb] Fix broken skipUnlessUndefinedBehaviorSanitizer decorator
727bd89b605b broke the UBSan decorator. The decorator compiles a custom
source code snippet that exposes UB and verifies the presence of a UBSan
symbol in the generated binary. The aforementioned commit broke both by
compiling a snippet without UB and discarding the result.
Added:
Modified:
lldb/packages/Python/lldbsuite/test/decorators.py
Removed:
################################################################################
diff --git a/lldb/packages/Python/lldbsuite/test/decorators.py b/lldb/packages/Python/lldbsuite/test/decorators.py
index 972a98a13079..b6ef3f08df22 100644
--- a/lldb/packages/Python/lldbsuite/test/decorators.py
+++ b/lldb/packages/Python/lldbsuite/test/decorators.py
@@ -87,13 +87,16 @@ def _match_decorator_property(expected, actual):
return expected == actual
-def _compiler_supports(compiler, flag):
+def _compiler_supports(compiler,
+ flag,
+ source='int main() {}',
+ output_file=tempfile.NamedTemporaryFile()):
"""Test whether the compiler supports the given flag."""
if platform.system() == 'Darwin':
compiler = "xcrun " + compiler
- f = tempfile.NamedTemporaryFile()
try:
- cmd = "echo 'int main() {}' | %s %s -x c -o %s -" % (compiler, flag, f.name)
+ cmd = "echo '%s' | %s %s -x c -o %s -" % (source, compiler, flag,
+ output_file.name)
subprocess.check_call(cmd, shell=True)
except subprocess.CalledProcessError:
return False
@@ -755,16 +758,13 @@ def is_compiler_clang_with_ubsan(self):
if is_running_under_asan():
return "Undefined behavior sanitizer tests are disabled when runing under ASAN"
- # Write out a temp file which exhibits UB.
- inputf = tempfile.NamedTemporaryFile(suffix='.c', mode='w')
- inputf.write('int main() { int x = 0; return x / x; }\n')
- inputf.flush()
-
# We need to write out the object into a named temp file for inspection.
outputf = tempfile.NamedTemporaryFile()
# Try to compile with ubsan turned on.
- if not _compiler_supports(self.getCompiler(), '-fsanitize=undefined'):
+ if not _compiler_supports(self.getCompiler(), '-fsanitize=undefined',
+ 'int main() { int x = 0; return x / x; }',
+ outputf):
return "Compiler cannot compile with -fsanitize=undefined"
# Check that we actually see ubsan instrumentation in the binary.
More information about the lldb-commits
mailing list