1d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen""" 2d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny ChenTest that variables of integer basic types are displayed correctly. 3d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen""" 4d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen 5d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chenimport AbstractBase 6d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chenimport unittest2 7d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chenimport sys 8d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chenimport lldb 9d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chenfrom lldbtest import * 10d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen 11d047d81eefa9bb0ad1979a37fabbbd23d2cfa936Johnny Chen# rdar://problem/9649573 12d047d81eefa9bb0ad1979a37fabbbd23d2cfa936Johnny Chen# Capture the lldb and gdb-remote log files for test failures when run with no "-w" option 13d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chenclass DebugIntegerTypesFailures(AbstractBase.GenericTester): 14d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen 15d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen mydir = "types" 16d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen 17d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen def setUp(self): 18d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen # Call super's setUp(). 19d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen TestBase.setUp(self) 20cf797164b03f9cf073386e26c08b88b70a1feb30Johnny Chen # If we're lucky, test_long_type_with_dsym fails. 21d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen # Let's turn on logging just for that. 2251c3533dfbe3630107543838e6fb75b084b3972fJohnny Chen try: 2351c3533dfbe3630107543838e6fb75b084b3972fJohnny Chen if "test_long_type_with_dsym" in self.id(): 2451c3533dfbe3630107543838e6fb75b084b3972fJohnny Chen self.runCmd( 2551c3533dfbe3630107543838e6fb75b084b3972fJohnny Chen "log enable -n -f %s lldb commands event process state" % 2651c3533dfbe3630107543838e6fb75b084b3972fJohnny Chen os.environ["DEBUG_LLDB_LOG"]) 2751c3533dfbe3630107543838e6fb75b084b3972fJohnny Chen self.runCmd( 2851c3533dfbe3630107543838e6fb75b084b3972fJohnny Chen "log enable -n -f %s gdb-remote packets process" % 2951c3533dfbe3630107543838e6fb75b084b3972fJohnny Chen os.environ["DEBUG_GDB_REMOTE_LOG"]) 3051c3533dfbe3630107543838e6fb75b084b3972fJohnny Chen except: 3151c3533dfbe3630107543838e6fb75b084b3972fJohnny Chen pass 32d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen 33d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen def tearDown(self): 34d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen # Call super's tearDown(). 35d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen TestBase.tearDown(self) 36cf797164b03f9cf073386e26c08b88b70a1feb30Johnny Chen # If we're lucky, test_long_type_with_dsym fails. 37d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen # Let's turn off logging just for that. 38cf797164b03f9cf073386e26c08b88b70a1feb30Johnny Chen if "test_long_type_with_dsym" in self.id(): 39d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen self.runCmd("log disable lldb") 40d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen self.runCmd("log disable gdb-remote") 41d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen 42d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") 43d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen def test_char_type_with_dsym(self): 44d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen """Test that char-type variables are displayed correctly.""" 45d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen d = {'CXX_SOURCES': 'char.cpp'} 46d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen self.buildDsym(dictionary=d) 47d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen self.setTearDownCleanup(dictionary=d) 48d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen self.char_type() 49d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen 50d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen def test_char_type_with_dwarf(self): 51d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen """Test that char-type variables are displayed correctly.""" 52d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen d = {'CXX_SOURCES': 'char.cpp'} 53d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen self.buildDwarf(dictionary=d) 54d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen self.setTearDownCleanup(dictionary=d) 55d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen self.char_type() 56d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen 57d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") 58d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen def test_short_type_with_dsym(self): 59d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen """Test that short-type variables are displayed correctly.""" 60d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen d = {'CXX_SOURCES': 'short.cpp'} 61d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen self.buildDsym(dictionary=d) 62d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen self.setTearDownCleanup(dictionary=d) 63d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen self.short_type() 64d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen 65d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen def test_short_type_with_dwarf(self): 66d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen """Test that short-type variables are displayed correctly.""" 67d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen d = {'CXX_SOURCES': 'short.cpp'} 68d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen self.buildDwarf(dictionary=d) 69d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen self.setTearDownCleanup(dictionary=d) 70d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen self.short_type() 71d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen 72d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") 73d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen def test_int_type_with_dsym(self): 74d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen """Test that int-type variables are displayed correctly.""" 75d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen d = {'CXX_SOURCES': 'int.cpp'} 76d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen self.buildDsym(dictionary=d) 77d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen self.setTearDownCleanup(dictionary=d) 78d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen self.int_type() 79d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen 80d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen def test_int_type_with_dwarf(self): 81d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen """Test that int-type variables are displayed correctly.""" 82d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen d = {'CXX_SOURCES': 'int.cpp'} 83d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen self.buildDwarf(dictionary=d) 84d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen self.setTearDownCleanup(dictionary=d) 85d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen self.int_type() 86d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen 87d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") 88d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen def test_long_type_with_dsym(self): 89d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen """Test that long-type variables are displayed correctly.""" 90d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen d = {'CXX_SOURCES': 'long.cpp'} 91d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen print self.id() 92d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen self.buildDsym(dictionary=d) 93d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen self.setTearDownCleanup(dictionary=d) 94d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen self.long_type() 95d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen 96d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen def test_long_type_with_dwarf(self): 97d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen """Test that long-type variables are displayed correctly.""" 98d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen d = {'CXX_SOURCES': 'long.cpp'} 99d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen self.buildDwarf(dictionary=d) 100d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen self.setTearDownCleanup(dictionary=d) 101d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen self.long_type() 102d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen 103d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") 104d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen def test_long_long_type_with_dsym(self): 105d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen """Test that 'long long'-type variables are displayed correctly.""" 106d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen d = {'CXX_SOURCES': 'long_long.cpp'} 107d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen self.buildDsym(dictionary=d) 108d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen self.setTearDownCleanup(dictionary=d) 109d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen self.long_long_type() 110d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen 111d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen def test_long_long_type_with_dwarf(self): 112d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen """Test that 'long long'-type variables are displayed correctly.""" 113d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen d = {'CXX_SOURCES': 'long_long.cpp'} 114d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen self.buildDwarf(dictionary=d) 115d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen self.setTearDownCleanup(dictionary=d) 116d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen self.long_long_type() 117d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen 118d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen def char_type(self): 119d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen """Test that char-type variables are displayed correctly.""" 120d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen self.generic_type_tester(set(['char']), quotedDisplay=True) 121d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen 122d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen def int_type(self): 123d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen """Test that int-type variables are displayed correctly.""" 124d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen self.generic_type_tester(set(['int'])) 125d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen 126d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen def short_type(self): 127d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen """Test that short-type variables are displayed correctly.""" 128d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen self.generic_type_tester(set(['short'])) 129d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen 130d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen def long_type(self): 131d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen """Test that long-type variables are displayed correctly.""" 132d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen self.generic_type_tester(set(['long'])) 133d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen 134d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen def long_long_type(self): 135d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen """Test that long long-type variables are displayed correctly.""" 136d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen self.generic_type_tester(set(['long long'])) 137d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen 138d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen 139d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chenif __name__ == '__main__': 140d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen import atexit 141d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen lldb.SBDebugger.Initialize() 142d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen atexit.register(lambda: lldb.SBDebugger.Terminate()) 143d88785b7743c8f4cfa0f5025f5db56f716e6c7b4Johnny Chen unittest2.main() 144