61107077f9cffc78bdc91d5ef343a815ca28ded6
[openbsd] /
1 import lldb
2 from lldbsuite.test.decorators import *
3 from lldbsuite.test.lldbtest import *
4 from lldbsuite.test import lldbutil
5
6 class StaticInitializers(TestBase):
7
8     mydir = TestBase.compute_mydir(__file__)
9
10     @expectedFailureAll(archs="aarch64", oslist="linux",
11                         bugnumber="https://bugs.llvm.org/show_bug.cgi?id=44053")
12     def test(self):
13         """ Test a static initializer. """
14         self.build()
15
16         lldbutil.run_to_source_breakpoint(self, '// break here',
17                 lldb.SBFileSpec("main.cpp", False))
18
19         # We use counter to observe if the initializer was called.
20         self.expect("expr counter", substrs=["(int) $", " = 0"])
21         self.expect("expr -p -- struct Foo { Foo() { inc_counter(); } }; Foo f;")
22         self.expect("expr counter", substrs=["(int) $", " = 1"])
23
24     def test_failing_init(self):
25         """ Test a static initializer that fails to execute. """
26         self.build()
27
28         lldbutil.run_to_source_breakpoint(self, '// break here',
29                 lldb.SBFileSpec("main.cpp", False))
30
31         # FIXME: This error message is not even remotely helpful.
32         self.expect("expr -p -- struct Foo2 { Foo2() { do_abort(); } }; Foo2 f;", error=True,
33                     substrs=["error: couldn't run static initializers: couldn't run static initializer:"])