Files
clang-p2996/lldb/test/functionalities/thread/TestNumThreads.py
Greg Clayton 4570d3eba0 Massive test suite cleanup to stop everyone from manually having to compute "mydir" inside each test case.
This has led to many test suite failures because of copy and paste where new test cases were based off of other test cases and the "mydir" variable wasn't updated.

Now you can call your superclasses "compute_mydir()" function with "__file__" as the sole argument and the relative path will be computed for you. 

llvm-svn: 196985
2013-12-10 23:19:29 +00:00

68 lines
2.1 KiB
Python

"""
Test number of threads.
"""
import os, time
import unittest2
import lldb
from lldbtest import *
import lldbutil
class NumberOfThreadsTestCase(TestBase):
mydir = TestBase.compute_mydir(__file__)
@unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
@dsym_test
def test_with_dsym(self):
"""Test number of threads."""
self.buildDsym()
self.number_of_threads_test()
@expectedFailureFreeBSD("llvm.org/pr18061") # test relies on undefined behaviour
@dwarf_test
def test_with_dwarf(self):
"""Test number of threads."""
self.buildDwarf()
self.number_of_threads_test()
def setUp(self):
# Call super's setUp().
TestBase.setUp(self)
# Find the line number to break inside main().
self.line = line_number('main.c', '// Set break point at this line.')
def number_of_threads_test(self):
"""Test number of threads."""
exe = os.path.join(os.getcwd(), "a.out")
self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
# This should create a breakpoint with 1 location.
lldbutil.run_break_set_by_file_and_line (self, "main.c", self.line, num_expected_locations=1)
# The breakpoint list should show 3 locations.
self.expect("breakpoint list -f", "Breakpoint location shown correctly",
substrs = ["1: file = 'main.c', line = %d, locations = 1" % self.line])
# Run the program.
self.runCmd("run", RUN_SUCCEEDED)
# Stopped once.
self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
substrs = ["stop reason = breakpoint 1."])
# Get the target process
target = self.dbg.GetSelectedTarget()
process = target.GetProcess()
# Get the number of threads
num_threads = process.GetNumThreads()
self.assertTrue(num_threads == 4, 'Number of expected threads and actual threads do not match.')
if __name__ == '__main__':
import atexit
lldb.SBDebugger.Initialize()
atexit.register(lambda: lldb.SBDebugger.Terminate())
unittest2.main()