File: TestMultithreaded.py

package info (click to toggle)
llvm-toolchain-4.0 1%3A4.0.1-10~deb9u2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 493,332 kB
  • sloc: cpp: 2,698,100; ansic: 552,773; asm: 128,821; python: 121,589; objc: 105,054; sh: 21,174; lisp: 6,758; ml: 5,532; perl: 5,311; pascal: 5,245; makefile: 2,083; cs: 1,868; xml: 686; php: 212; csh: 117
file content (108 lines) | stat: -rw-r--r-- 3,932 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
"""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):

    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.inferior))

        self.buildDriver(sources, test_name)
        self.addTearDownHook(lambda: os.remove(test_name))

        test_exe = os.path.join(os.getcwd(), test_name)
        self.signBinary(test_exe)
        exe = [test_exe, 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)