]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - packages/Python/lldbsuite/test/expression_command/char/TestExprsChar.py
Vendor import of lldb trunk r290819:
[FreeBSD/FreeBSD.git] / packages / Python / lldbsuite / test / expression_command / char / TestExprsChar.py
1 from __future__ import print_function
2
3
4 import lldb
5 from lldbsuite.test.decorators import *
6 from lldbsuite.test.lldbtest import *
7 from lldbsuite.test import lldbutil
8
9
10 class ExprCharTestCase(TestBase):
11
12     mydir = TestBase.compute_mydir(__file__)
13
14     def setUp(self):
15         # Call super's setUp().
16         TestBase.setUp(self)
17
18         self.main_source = "main.cpp"
19         self.main_source_spec = lldb.SBFileSpec(self.main_source)
20         self.exe = os.path.join(os.getcwd(), "a.out")
21
22     def do_test(self, dictionary=None):
23         """These basic expression commands should work as expected."""
24         self.build(dictionary=dictionary)
25
26         target = self.dbg.CreateTarget(self.exe)
27         self.assertTrue(target)
28
29         breakpoint = target.BreakpointCreateBySourceRegex(
30             '// Break here', self.main_source_spec)
31         self.assertTrue(breakpoint)
32
33         # Launch the process, and do not stop at the entry point.
34         process = target.LaunchSimple(
35             None, None, self.get_process_working_directory())
36         self.assertTrue(process)
37
38         threads = lldbutil.get_threads_stopped_at_breakpoint(
39             process, breakpoint)
40         self.assertEqual(len(threads), 1)
41
42         frame = threads[0].GetFrameAtIndex(0)
43
44         value = frame.EvaluateExpression("foo(c)")
45         self.assertTrue(value.IsValid())
46         self.assertTrue(value.GetError().Success())
47         self.assertEqual(value.GetValueAsSigned(0), 1)
48
49         value = frame.EvaluateExpression("foo(sc)")
50         self.assertTrue(value.IsValid())
51         self.assertTrue(value.GetError().Success())
52         self.assertEqual(value.GetValueAsSigned(0), 2)
53
54         value = frame.EvaluateExpression("foo(uc)")
55         self.assertTrue(value.IsValid())
56         self.assertTrue(value.GetError().Success())
57         self.assertEqual(value.GetValueAsSigned(0), 3)
58
59     @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr21765")
60     def test_default_char(self):
61         self.do_test()
62
63     @expectedFailureAll(
64         archs=[
65             "arm",
66             "aarch64",
67             "s390x"],
68         bugnumber="llvm.org/pr23069")
69     @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr21765")
70     def test_signed_char(self):
71         self.do_test(dictionary={'CFLAGS_EXTRAS': '-fsigned-char'})
72
73     @expectedFailureAll(
74         archs=[
75             "i[3-6]86",
76             "x86_64"],
77         bugnumber="llvm.org/pr23069, <rdar://problem/28721938>")
78     @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr21765")
79     @expectedFailureAll(triple='mips*', bugnumber="llvm.org/pr23069")
80     def test_unsigned_char(self):
81         self.do_test(dictionary={'CFLAGS_EXTRAS': '-funsigned-char'})