]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - packages/Python/lldbsuite/test/functionalities/data-formatter/vector-types/TestVectorTypesFormatting.py
Vendor import of lldb trunk r256945:
[FreeBSD/FreeBSD.git] / packages / Python / lldbsuite / test / functionalities / data-formatter / vector-types / TestVectorTypesFormatting.py
1 """
2 Check that vector types format properly
3 """
4
5 from __future__ import print_function
6
7
8
9 import os, time
10 import lldb
11 from lldbsuite.test.lldbtest import *
12 import lldbsuite.test.lldbutil as lldbutil
13
14 class VectorTypesFormattingTestCase(TestBase):
15
16     mydir = TestBase.compute_mydir(__file__)
17
18     def setUp(self):
19         # Call super's setUp().
20         TestBase.setUp(self)
21         # Find the line number to break at.
22         self.line = line_number('main.cpp', '// break here')
23
24     # rdar://problem/14035604
25     @skipIf(compiler='gcc') # gcc don't have ext_vector_type extension
26     def test_with_run_command(self):
27         """Check that vector types format properly"""
28         self.build()
29         self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
30
31         lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True)
32
33         self.runCmd("run", RUN_SUCCEEDED)
34
35         # The stop reason of the thread should be breakpoint.
36         self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
37             substrs = ['stopped',
38                        'stop reason = breakpoint'])
39
40         # This is the function to remove the custom formats in order to have a
41         # clean slate for the next test case.
42         def cleanup():
43             pass
44
45         # Execute the cleanup function during test case tear down.
46         self.addTearDownHook(cleanup)
47
48         pass # my code never fails
49         
50         v = self.frame().FindVariable("v")
51         v.SetPreferSyntheticValue(True)
52         v.SetFormat(lldb.eFormatVectorOfFloat32)
53         
54         if self.TraceOn(): print(v)
55         
56         self.assertTrue(v.GetNumChildren() == 4, "v as float32[] has 4 children")
57         self.assertTrue(v.GetChildAtIndex(0).GetData().float[0] == 1.25, "child 0 == 1.25")
58         self.assertTrue(v.GetChildAtIndex(1).GetData().float[0] == 1.25, "child 1 == 1.25")
59         self.assertTrue(v.GetChildAtIndex(2).GetData().float[0] == 2.50, "child 2 == 2.50")
60         self.assertTrue(v.GetChildAtIndex(3).GetData().float[0] == 2.50, "child 3 == 2.50")
61         
62         self.expect("expr -f int16_t[] -- v", substrs=['(0, 16288, 0, 16288, 0, 16416, 0, 16416)'])
63         self.expect("expr -f uint128_t[] -- v", substrs=['(85236745249553456609335044694184296448)'])
64         self.expect("expr -f float32[] -- v", substrs=['(1.25, 1.25, 2.5, 2.5)'])
65         
66         oldValue = v.GetChildAtIndex(0).GetValue()
67         v.SetFormat(lldb.eFormatHex)
68         newValue = v.GetChildAtIndex(0).GetValue()
69         self.assertFalse(oldValue == newValue, "values did not change along with format")
70         
71         v.SetFormat(lldb.eFormatVectorOfFloat32)
72         oldValueAgain = v.GetChildAtIndex(0).GetValue()
73         self.assertTrue(oldValue == oldValueAgain, "same format but different values")