Changeset View
Changeset View
Standalone View
Standalone View
lldb/packages/Python/lldbsuite/test/decorators.py
Show First 20 Lines • Show All 681 Lines • ▼ Show 20 Lines | def compiler_doesnt_support_struct_attribute(self): | ||||
cmd = [self.getCompiler(), "-x", "c++", "-c", "-o", f.name, "-"] | cmd = [self.getCompiler(), "-x", "c++", "-c", "-o", f.name, "-"] | ||||
p = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True) | p = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True) | ||||
stdout, stderr = p.communicate('struct __attribute__((%s)) Test {};'%attr) | stdout, stderr = p.communicate('struct __attribute__((%s)) Test {};'%attr) | ||||
if attr in stderr: | if attr in stderr: | ||||
return "Compiler does not support attribute %s"%(attr) | return "Compiler does not support attribute %s"%(attr) | ||||
return None | return None | ||||
return skipTestIfFn(compiler_doesnt_support_struct_attribute) | return skipTestIfFn(compiler_doesnt_support_struct_attribute) | ||||
def skipUnlessHasCallSiteInfo(func): | |||||
"""Decorate the function to skip testing unless call site info from clang is available.""" | |||||
sgraenitz: Two leading `""` missing? | |||||
def is_compiler_clang_with_call_site_info(self): | |||||
compiler_path = self.getCompiler() | |||||
compiler = os.path.basename(compiler_path) | |||||
if not compiler.startswith("clang"): | |||||
return "Test requires clang as compiler" | |||||
f = tempfile.NamedTemporaryFile() | |||||
cmd = "echo 'int main() {}' | " \ | |||||
"%s -g -glldb -O1 -S -emit-llvm -x c -o %s -" % (compiler_path, f.name) | |||||
if os.popen(cmd).close() is not None: | |||||
return "Compiler can't compile with call site info enabled" | |||||
with open(f.name, 'r') as ir_output_file: | |||||
buf = ir_output_file.read() | |||||
if 'DIFlagAllCallsDescribed' not in buf: | |||||
return "Compiler did not introduce DIFlagAllCallsDescribed IR flag" | |||||
return None | |||||
return skipTestIfFn(is_compiler_clang_with_call_site_info)(func) | |||||
def skipUnlessThreadSanitizer(func): | def skipUnlessThreadSanitizer(func): | ||||
"""Decorate the item to skip test unless Clang -fsanitize=thread is supported.""" | """Decorate the item to skip test unless Clang -fsanitize=thread is supported.""" | ||||
def is_compiler_clang_with_thread_sanitizer(self): | def is_compiler_clang_with_thread_sanitizer(self): | ||||
compiler_path = self.getCompiler() | compiler_path = self.getCompiler() | ||||
compiler = os.path.basename(compiler_path) | compiler = os.path.basename(compiler_path) | ||||
if not compiler.startswith("clang"): | if not compiler.startswith("clang"): | ||||
return "Test requires clang as compiler" | return "Test requires clang as compiler" | ||||
▲ Show 20 Lines • Show All 115 Lines • Show Last 20 Lines |
Two leading "" missing?