]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - packages/Python/lldbsuite/test/lang/cpp/unicode-literals/TestUnicodeLiterals.py
Vendor import of lldb trunk r290819:
[FreeBSD/FreeBSD.git] / packages / Python / lldbsuite / test / lang / cpp / unicode-literals / TestUnicodeLiterals.py
1 # coding=utf8
2 """
3 Test that the expression parser returns proper Unicode strings.
4 """
5
6 from __future__ import print_function
7
8
9 import os
10 import time
11 import lldb
12 from lldbsuite.test.decorators import *
13 from lldbsuite.test.lldbtest import *
14 from lldbsuite.test import lldbutil
15
16 # this test case fails because of rdar://12991846
17 # the expression parser does not deal correctly with Unicode expressions
18 # e.g.
19 #(lldb) expr L"Hello"
20 #(const wchar_t [6]) $0 = {
21 #  [0] = \0\0\0\0
22 #  [1] = \0\0\0\0
23 #  [2] = \0\0\0\0
24 #  [3] = \0\0\0\0
25 #  [4] = H\0\0\0
26 #  [5] = e\0\0\0
27 #}
28
29
30 class UnicodeLiteralsTestCase(TestBase):
31
32     mydir = TestBase.compute_mydir(__file__)
33
34     @expectedFailureAll(
35         oslist=["windows"],
36         bugnumber="llvm.org/pr24489: Name lookup not working correctly on Windows")
37     def test_expr1(self):
38         """Test that the expression parser returns proper Unicode strings."""
39         self.build()
40         self.rdar12991846(expr=1)
41
42     @expectedFailureAll(
43         oslist=["windows"],
44         bugnumber="llvm.org/pr24489: Name lookup not working correctly on Windows")
45     def test_expr2(self):
46         """Test that the expression parser returns proper Unicode strings."""
47         self.build()
48         self.rdar12991846(expr=2)
49
50     @expectedFailureAll(
51         oslist=["windows"],
52         bugnumber="llvm.org/pr24489: Name lookup not working correctly on Windows")
53     def test_expr3(self):
54         """Test that the expression parser returns proper Unicode strings."""
55         self.build()
56         self.rdar12991846(expr=3)
57
58     def setUp(self):
59         # Call super's setUp().
60         TestBase.setUp(self)
61         # Find the line number to break for main.cpp.
62         self.source = 'main.cpp'
63         self.line = line_number(
64             self.source, '// Set break point at this line.')
65
66     def rdar12991846(self, expr=None):
67         """Test that the expression parser returns proper Unicode strings."""
68         if self.getArchitecture() in ['i386']:
69             self.skipTest(
70                 "Skipping because this test is known to crash on i386")
71
72         exe = os.path.join(os.getcwd(), "a.out")
73
74         # Create a target by the debugger.
75         target = self.dbg.CreateTarget(exe)
76         self.assertTrue(target, VALID_TARGET)
77
78         # Break on the struct declration statement in main.cpp.
79         lldbutil.run_break_set_by_file_and_line(self, "main.cpp", self.line)
80
81         # Now launch the process, and do not stop at entry point.
82         process = target.LaunchSimple(
83             None, None, self.get_process_working_directory())
84
85         if not process:
86             self.fail("SBTarget.Launch() failed")
87
88         if expr == 1:
89             self.expect('expression L"hello"', substrs=['hello'])
90
91         if expr == 2:
92             self.expect('expression u"hello"', substrs=['hello'])
93
94         if expr == 3:
95             self.expect('expression U"hello"', substrs=['hello'])