1f74aaca6SMichael Buch""" 2f74aaca6SMichael BuchTests that frame variable and expr work for 3f74aaca6SMichael BuchC++ unions and their static data members. 4f74aaca6SMichael Buch""" 5f74aaca6SMichael Buchimport lldb 6f74aaca6SMichael Buchfrom lldbsuite.test.lldbtest import * 7f74aaca6SMichael Buchfrom lldbsuite.test.decorators import * 8f74aaca6SMichael Buchimport lldbsuite.test.lldbutil as lldbutil 9f74aaca6SMichael Buch 10*096c530aSJonas Devlieghere 11f74aaca6SMichael Buchclass CppUnionStaticMembersTestCase(TestBase): 12d579a1a2SMichael Buch def test_print_union(self): 13f74aaca6SMichael Buch """Tests that frame variable and expr work 14d579a1a2SMichael Buch for union with static data members""" 15f74aaca6SMichael Buch self.build() 16f74aaca6SMichael Buch 17f74aaca6SMichael Buch (target, process, main_thread, _) = lldbutil.run_to_source_breakpoint( 18f74aaca6SMichael Buch self, "return 0", lldb.SBFileSpec("main.cpp") 19f74aaca6SMichael Buch ) 20f74aaca6SMichael Buch 21f74aaca6SMichael Buch self.expect("frame variable foo", substrs=["val = 42"]) 22f74aaca6SMichael Buch self.expect("frame variable bar", substrs=["val = 137"]) 23f74aaca6SMichael Buch 24*096c530aSJonas Devlieghere self.expect_expr( 25*096c530aSJonas Devlieghere "foo", 26*096c530aSJonas Devlieghere result_type="Foo", 27*096c530aSJonas Devlieghere result_children=[ValueCheck(name="val", value="42")], 28*096c530aSJonas Devlieghere ) 29*096c530aSJonas Devlieghere self.expect_expr( 30*096c530aSJonas Devlieghere "bar", 31*096c530aSJonas Devlieghere result_type="Bar", 32*096c530aSJonas Devlieghere result_children=[ValueCheck(name="val", value="137")], 33*096c530aSJonas Devlieghere ) 34f74aaca6SMichael Buch 35d579a1a2SMichael Buch @expectedFailureWindows 36d579a1a2SMichael Buch def test_expr_union_static_members(self): 37d579a1a2SMichael Buch """Tests that frame variable and expr work 38d579a1a2SMichael Buch for union static data members""" 39d579a1a2SMichael Buch self.build() 40d579a1a2SMichael Buch 41d579a1a2SMichael Buch (target, process, main_thread, _) = lldbutil.run_to_source_breakpoint( 42d579a1a2SMichael Buch self, "return 0", lldb.SBFileSpec("main.cpp") 43d579a1a2SMichael Buch ) 44d579a1a2SMichael Buch 45f74aaca6SMichael Buch self.expect_expr("Foo::sVal1", result_type="const int", result_value="-42") 46*096c530aSJonas Devlieghere self.expect_expr( 47*096c530aSJonas Devlieghere "Foo::sVal2", 48*096c530aSJonas Devlieghere result_type="Foo", 49*096c530aSJonas Devlieghere result_children=[ValueCheck(name="val", value="42")], 50*096c530aSJonas Devlieghere ) 51f74aaca6SMichael Buch 52dcbf1e4eSGreg Clayton @expectedFailureWindows 53f74aaca6SMichael Buch def test_union_in_anon_namespace(self): 54f74aaca6SMichael Buch """Tests that frame variable and expr work 55f74aaca6SMichael Buch for union static data members in anonymous 56f74aaca6SMichael Buch namespaces""" 57d579a1a2SMichael Buch self.build() 58d579a1a2SMichael Buch 59d579a1a2SMichael Buch (target, process, main_thread, _) = lldbutil.run_to_source_breakpoint( 60d579a1a2SMichael Buch self, "return 0", lldb.SBFileSpec("main.cpp") 61d579a1a2SMichael Buch ) 62d579a1a2SMichael Buch 63f74aaca6SMichael Buch self.expect_expr("Bar::sVal1", result_type="const int", result_value="-137") 64*096c530aSJonas Devlieghere self.expect_expr( 65*096c530aSJonas Devlieghere "Bar::sVal2", 66*096c530aSJonas Devlieghere result_type="Bar", 67*096c530aSJonas Devlieghere result_children=[ValueCheck(name="val", value="137")], 68*096c530aSJonas Devlieghere ) 69