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__)
10 @expectedFailureAll(archs="aarch64", oslist="linux",
11 bugnumber="https://bugs.llvm.org/show_bug.cgi?id=44053")
13 """ Test a static initializer. """
16 lldbutil.run_to_source_breakpoint(self, '// break here',
17 lldb.SBFileSpec("main.cpp", False))
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"])
24 def test_failing_init(self):
25 """ Test a static initializer that fails to execute. """
28 lldbutil.run_to_source_breakpoint(self, '// break here',
29 lldb.SBFileSpec("main.cpp", False))
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:"])