teak-llvm/lldb/packages/Python/lldbsuite/test/api/multithreaded/TestMultithreaded.py
Adrian Prantl 5ec76fe720 Compile the LLDB tests out-of-tree.
This patch is the result of a discussion on lldb-dev, see
http://lists.llvm.org/pipermail/lldb-dev/2018-January/013111.html for
background.

For each test (should be eventually: each test configuration) a
separate build directory is created and we execute

  make VPATH=$srcdir/path/to/test -C $builddir/path/to/test -f $srcdir/path/to/test/Makefile -I $srcdir/path/to/test

In order to make this work all LLDB tests need to be updated to find
the executable in the test build directory, since CWD still points at
the test's source directory, which is a requirement for unittest2.

Although we have done extensive testing, I'm expecting that this first
attempt will break a few bots. Please DO NOT HESITATE TO REVERT this
patch in order to get the bots green again. We will likely have to
iterate on this some more.

Differential Revision: https://reviews.llvm.org/D42281

llvm-svn: 323803
2018-01-30 18:29:16 +00:00

113 lines
4.0 KiB
Python

"""Test the lldb public C++ api breakpoint callbacks."""
from __future__ import print_function
# __package__ = "lldbsuite.test"
import os
import re
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil
import subprocess
class SBBreakpointCallbackCase(TestBase):
NO_DEBUG_INFO_TESTCASE = True
def setUp(self):
TestBase.setUp(self)
self.generateSource('driver.cpp')
self.generateSource('listener_test.cpp')
self.generateSource('test_breakpoint_callback.cpp')
self.generateSource('test_listener_event_description.cpp')
self.generateSource('test_listener_event_process_state.cpp')
self.generateSource('test_listener_resume.cpp')
mydir = TestBase.compute_mydir(__file__)
@skipIfRemote
@skipIfNoSBHeaders
# clang-cl does not support throw or catch (llvm.org/pr24538)
@skipIfWindows
def test_breakpoint_callback(self):
"""Test the that SBBreakpoint callback is invoked when a breakpoint is hit. """
self.build_and_test('driver.cpp test_breakpoint_callback.cpp',
'test_breakpoint_callback')
@skipIfRemote
@skipIfNoSBHeaders
# clang-cl does not support throw or catch (llvm.org/pr24538)
@skipIfWindows
@expectedFlakeyFreeBSD
def test_sb_api_listener_event_description(self):
""" Test the description of an SBListener breakpoint event is valid."""
self.build_and_test(
'driver.cpp listener_test.cpp test_listener_event_description.cpp',
'test_listener_event_description')
pass
@skipIfRemote
@skipIfNoSBHeaders
# clang-cl does not support throw or catch (llvm.org/pr24538)
@skipIfWindows
@expectedFlakeyFreeBSD
def test_sb_api_listener_event_process_state(self):
""" Test that a registered SBListener receives events when a process
changes state.
"""
self.build_and_test(
'driver.cpp listener_test.cpp test_listener_event_process_state.cpp',
'test_listener_event_process_state')
pass
@skipIfRemote
@skipIfNoSBHeaders
# clang-cl does not support throw or catch (llvm.org/pr24538)
@skipIfWindows
@expectedFlakeyFreeBSD
@expectedFailureAll(oslist=["linux"])
def test_sb_api_listener_resume(self):
""" Test that a process can be resumed from a non-main thread. """
self.build_and_test(
'driver.cpp listener_test.cpp test_listener_resume.cpp',
'test_listener_resume')
pass
def build_and_test(self, sources, test_name, args=None):
""" Build LLDB test from sources, and run expecting 0 exit code """
# These tests link against host lldb API.
# Compiler's target triple must match liblldb triple
# because remote is disabled, we can assume that the os is the same
# still need to check architecture
if self.getLldbArchitecture() != self.getArchitecture():
self.skipTest(
"This test is only run if the target arch is the same as the lldb binary arch")
self.inferior = 'inferior_program'
self.buildProgram('inferior.cpp', self.inferior)
self.addTearDownHook(lambda:
os.remove(self.getBuildArtifact(self.inferior)))
self.buildDriver(sources, test_name)
self.addTearDownHook(lambda:
os.remove(self.getBuildArtifact(test_name)))
test_exe = self.getBuildArtifact(test_name)
self.signBinary(test_exe)
exe = [test_exe, self.getBuildArtifact(self.inferior)]
env = {self.dylibPath: self.getLLDBLibraryEnvVal()}
if self.TraceOn():
print("Running test %s" % " ".join(exe))
check_call(exe, env=env)
else:
with open(os.devnull, 'w') as fnull:
check_call(exe, env=env, stdout=fnull, stderr=fnull)
def build_program(self, sources, program):
return self.buildDriver(sources, program)