2
from lldbsuite.test.decorators import *
3
from lldbsuite.test.lldbtest import *
4
from lldbsuite.test import lldbutil
6
class StaticInitializers(TestBase):
8
mydir = TestBase.compute_mydir(__file__)
11
""" Test a static initializer. """
14
lldbutil.run_to_source_breakpoint(self, '// break here',
15
lldb.SBFileSpec("main.cpp", False))
17
# We use counter to observe if the initializer was called.
18
self.expect("expr counter", substrs=["(int) $", " = 0"])
19
self.expect("expr -p -- struct Foo { Foo() { inc_counter(); } }; Foo f;")
20
self.expect("expr counter", substrs=["(int) $", " = 1"])
22
def test_failing_init(self):
23
""" Test a static initializer that fails to execute. """
26
lldbutil.run_to_source_breakpoint(self, '// break here',
27
lldb.SBFileSpec("main.cpp", False))
29
# FIXME: This error message is not even remotely helpful.
30
self.expect("expr -p -- struct Foo2 { Foo2() { do_abort(); } }; Foo2 f;", error=True,
31
substrs=["error: couldn't run static initializers: couldn't run static initializer:"])