]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - packages/Python/lldbsuite/test/python_api/rdar-12481949/Test-rdar-12481949.py
Vendor import of lldb trunk r290819:
[FreeBSD/FreeBSD.git] / packages / Python / lldbsuite / test / python_api / rdar-12481949 / Test-rdar-12481949.py
1 """
2 Check that SBValue.GetValueAsSigned() does the right thing for a 32-bit -1.
3 """
4
5 from __future__ import print_function
6
7
8 import os
9 import time
10 import lldb
11 from lldbsuite.test.lldbtest import *
12 import lldbsuite.test.lldbutil as lldbutil
13
14
15 class Radar12481949DataFormatterTestCase(TestBase):
16
17     # test for rdar://problem/12481949
18     mydir = TestBase.compute_mydir(__file__)
19
20     def setUp(self):
21         # Call super's setUp().
22         TestBase.setUp(self)
23         # Find the line number to break at.
24         self.line = line_number('main.cpp', '// Set break point at this line.')
25
26     def test_with_run_command(self):
27         """Check that SBValue.GetValueAsSigned() does the right thing for a 32-bit -1."""
28         self.build()
29         self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
30
31         lldbutil.run_break_set_by_file_and_line(
32             self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True)
33
34         self.runCmd("run", RUN_SUCCEEDED)
35
36         # The stop reason of the thread should be breakpoint.
37         self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
38                     substrs=['stopped',
39                              'stop reason = breakpoint'])
40
41         # This is the function to remove the custom formats in order to have a
42         # clean slate for the next test case.
43         def cleanup():
44             self.runCmd('type format delete hex', check=False)
45             self.runCmd('type summary clear', check=False)
46
47         # Execute the cleanup function during test case tear down.
48         self.addTearDownHook(cleanup)
49
50         self.assertTrue(
51             self.frame().FindVariable("myvar").GetValueAsSigned() == -1,
52             "GetValueAsSigned() says -1")
53         self.assertTrue(
54             self.frame().FindVariable("myvar").GetValueAsSigned() != 0xFFFFFFFF,
55             "GetValueAsSigned() does not say 0xFFFFFFFF")
56         self.assertTrue(
57             self.frame().FindVariable("myvar").GetValueAsSigned() != 0xFFFFFFFFFFFFFFFF,
58             "GetValueAsSigned() does not say 0xFFFFFFFFFFFFFFFF")
59
60         self.assertTrue(
61             self.frame().FindVariable("myvar").GetValueAsUnsigned() != -1,
62             "GetValueAsUnsigned() does not say -1")
63         self.assertTrue(
64             self.frame().FindVariable("myvar").GetValueAsUnsigned() == 0xFFFFFFFF,
65             "GetValueAsUnsigned() says 0xFFFFFFFF")
66         self.assertTrue(
67             self.frame().FindVariable("myvar").GetValueAsUnsigned() != 0xFFFFFFFFFFFFFFFF,
68             "GetValueAsUnsigned() does not says 0xFFFFFFFFFFFFFFFF")