26f1972257bdd28429b2331ec9bb1c00dfb4c1c6
[openbsd] /
1 """
2 Test lldb data formatter subsystem.
3 """
4
5
6
7 import lldb
8 from lldbsuite.test.decorators import *
9 from lldbsuite.test.lldbtest import *
10 from lldbsuite.test import lldbutil
11
12
13 class TestDataFormatterLibcxxBitset(TestBase):
14
15     mydir = TestBase.compute_mydir(__file__)
16
17     def setUp(self):
18         TestBase.setUp(self)
19
20         primes = [1]*300
21         primes[0] = primes[1] = 0
22         for i in range(2, len(primes)):
23             for j in range(2*i, len(primes), i):
24                 primes[j] = 0
25         self.primes = primes
26
27     def check(self, name, size):
28         var = self.frame().FindVariable(name)
29         self.assertTrue(var.IsValid())
30         self.assertEqual(var.GetNumChildren(), size)
31         for i in range(size):
32             child = var.GetChildAtIndex(i)
33             self.assertEqual(child.GetValueAsUnsigned(), self.primes[i],
34                     "variable: %s, index: %d"%(name, size))
35
36     @add_test_categories(["libc++"])
37     def test_value(self):
38         """Test that std::bitset is displayed correctly"""
39         self.build()
40         lldbutil.run_to_source_breakpoint(self, '// break here',
41                 lldb.SBFileSpec("main.cpp", False))
42
43         self.check("empty", 0)
44         self.check("small", 13)
45         self.check("large", 200)
46
47     @add_test_categories(["libc++"])
48     def test_ptr_and_ref(self):
49         """Test that ref and ptr to std::bitset is displayed correctly"""
50         self.build()
51         (_, process, _, bkpt) = lldbutil.run_to_source_breakpoint(self,
52                 'Check ref and ptr',
53                 lldb.SBFileSpec("main.cpp", False))
54
55         self.check("ref", 13)
56         self.check("ptr", 13)
57
58         lldbutil.continue_to_breakpoint(process, bkpt)
59
60         self.check("ref", 200)
61         self.check("ptr", 200)