forked from OSchip/llvm-project
Minor test runner improvemenst
- rework the way SBDebugger.SetAsync() is used to avoid side effects (reset original value at TearDownHook) - refactor expectedFailureClang (and add expectedFailureGcc decorator) - mark TestChangeValueAPI.py as expectedFailureGcc due to PR-15039 llvm-svn: 175523
This commit is contained in:
parent
a9b732a32a
commit
249287afde
|
@ -44,6 +44,9 @@ class CmdPythonTestCase(TestBase):
|
||||||
# Execute the cleanup function during test case tear down.
|
# Execute the cleanup function during test case tear down.
|
||||||
self.addTearDownHook(cleanup)
|
self.addTearDownHook(cleanup)
|
||||||
|
|
||||||
|
# Interact with debugger in synchronous mode
|
||||||
|
self.setAsync(False)
|
||||||
|
|
||||||
# We don't want to display the stdout if not in TraceOn() mode.
|
# We don't want to display the stdout if not in TraceOn() mode.
|
||||||
if not self.TraceOn():
|
if not self.TraceOn():
|
||||||
self.HideStdout()
|
self.HideStdout()
|
||||||
|
@ -106,7 +109,7 @@ class CmdPythonTestCase(TestBase):
|
||||||
self.expect("tell_async",
|
self.expect("tell_async",
|
||||||
substrs = ['running async'])
|
substrs = ['running async'])
|
||||||
self.expect("tell_curr",
|
self.expect("tell_curr",
|
||||||
substrs = ['I am running','sync'])
|
substrs = ['I am running sync'])
|
||||||
|
|
||||||
|
|
||||||
self.runCmd("command script clear")
|
self.runCmd("command script clear")
|
||||||
|
|
|
@ -368,27 +368,40 @@ def dwarf_test(func):
|
||||||
wrapper.__dwarf_test__ = True
|
wrapper.__dwarf_test__ = True
|
||||||
return wrapper
|
return wrapper
|
||||||
|
|
||||||
def expectedFailureClang(func):
|
def expectedFailureCompiler(func, compiler):
|
||||||
"""Decorate the item as a Clang only expectedFailure."""
|
"""Decorate the item as an expectedFailure if the test compiler matches parameter compiler."""
|
||||||
if isinstance(func, type) and issubclass(func, unittest2.TestCase):
|
if isinstance(func, type) and issubclass(func, unittest2.TestCase):
|
||||||
raise Exception("@expectedFailureClang can only be used to decorate a test method")
|
raise Exception("@expectedFailureClang can only be used to decorate a test method")
|
||||||
@wraps(func)
|
@wraps(func)
|
||||||
def wrapper(*args, **kwargs):
|
def wrapper(*args, **kwargs):
|
||||||
from unittest2 import case
|
from unittest2 import case
|
||||||
self = args[0]
|
self = args[0]
|
||||||
compiler = self.getCompiler()
|
test_compiler = self.getCompiler()
|
||||||
try:
|
try:
|
||||||
func(*args, **kwargs)
|
func(*args, **kwargs)
|
||||||
except Exception:
|
except Exception:
|
||||||
if "clang" in compiler:
|
if compiler in test_compiler:
|
||||||
raise case._ExpectedFailure(sys.exc_info())
|
raise case._ExpectedFailure(sys.exc_info())
|
||||||
else:
|
else:
|
||||||
raise
|
raise
|
||||||
|
|
||||||
if "clang" in compiler:
|
if compiler in test_compiler:
|
||||||
raise case._UnexpectedSuccess
|
raise case._UnexpectedSuccess
|
||||||
return wrapper
|
return wrapper
|
||||||
|
|
||||||
|
|
||||||
|
def expectedFailureGcc(func):
|
||||||
|
"""Decorate the item as a GCC only expectedFailure."""
|
||||||
|
if isinstance(func, type) and issubclass(func, unittest2.TestCase):
|
||||||
|
raise Exception("@expectedFailureClang can only be used to decorate a test method")
|
||||||
|
return expectedFailureCompiler(func, "gcc")
|
||||||
|
|
||||||
|
def expectedFailureClang(func):
|
||||||
|
"""Decorate the item as a Clang only expectedFailure."""
|
||||||
|
if isinstance(func, type) and issubclass(func, unittest2.TestCase):
|
||||||
|
raise Exception("@expectedFailureClang can only be used to decorate a test method")
|
||||||
|
return expectedFailureCompiler(func, "clang")
|
||||||
|
|
||||||
def expectedFailurei386(func):
|
def expectedFailurei386(func):
|
||||||
"""Decorate the item as an i386 only expectedFailure."""
|
"""Decorate the item as an i386 only expectedFailure."""
|
||||||
if isinstance(func, type) and issubclass(func, unittest2.TestCase):
|
if isinstance(func, type) and issubclass(func, unittest2.TestCase):
|
||||||
|
@ -670,6 +683,12 @@ class Base(unittest2.TestCase):
|
||||||
child.sendline(hook)
|
child.sendline(hook)
|
||||||
child.expect_exact(child_prompt)
|
child.expect_exact(child_prompt)
|
||||||
|
|
||||||
|
def setAsync(self, value):
|
||||||
|
""" Sets async mode to True/False and ensures it is reset after the testcase completes."""
|
||||||
|
old_async = self.dbg.GetAsync()
|
||||||
|
self.dbg.SetAsync(value)
|
||||||
|
self.addTearDownHook(lambda: self.dbg.SetAsync(old_async))
|
||||||
|
|
||||||
def cleanupSubprocesses(self):
|
def cleanupSubprocesses(self):
|
||||||
# Ensure any subprocesses are cleaned up
|
# Ensure any subprocesses are cleaned up
|
||||||
for p in self.subprocesses:
|
for p in self.subprocesses:
|
||||||
|
|
|
@ -35,7 +35,9 @@ class ProcessIOTestCase(TestBase):
|
||||||
|
|
||||||
target = self.dbg.CreateTarget(self.exe)
|
target = self.dbg.CreateTarget(self.exe)
|
||||||
|
|
||||||
self.dbg.SetAsync(True)
|
# Perform synchronous interaction with the debugger.
|
||||||
|
self.setAsync(True)
|
||||||
|
|
||||||
process = target.LaunchSimple(None, None, os.getcwd())
|
process = target.LaunchSimple(None, None, os.getcwd())
|
||||||
if self.TraceOn():
|
if self.TraceOn():
|
||||||
print "process launched."
|
print "process launched."
|
||||||
|
|
|
@ -40,6 +40,7 @@ class ChangeValueAPITestCase(TestBase):
|
||||||
self.line = line_number('main.c', '// Stop here and set values')
|
self.line = line_number('main.c', '// Stop here and set values')
|
||||||
self.end_line = line_number ('main.c', '// Set a breakpoint here at the end')
|
self.end_line = line_number ('main.c', '// Set a breakpoint here at the end')
|
||||||
|
|
||||||
|
@expectedFailureGcc # PR-15039: If GCC is the test compiler, stdout is not available via lldb.SBProcess.GetSTDOUT()
|
||||||
def change_value_api(self, exe_name):
|
def change_value_api(self, exe_name):
|
||||||
"""Exercise some SBValue APIs."""
|
"""Exercise some SBValue APIs."""
|
||||||
exe = os.path.join(os.getcwd(), exe_name)
|
exe = os.path.join(os.getcwd(), exe_name)
|
||||||
|
|
Loading…
Reference in New Issue