1""" 2Test that lldb persistent variables works correctly. 3""" 4 5import os, time 6import unittest2 7import lldb 8from lldbtest import * 9 10class PersistentVariablesTestCase(TestBase): 11 12 mydir = os.path.join("expression_command", "persistent_variables") 13 14 def test_persistent_variables(self): 15 """Test that lldb persistent variables works correctly.""" 16 self.buildDefault() 17 18 self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) 19 20 self.runCmd("breakpoint set --source-pattern-regexp break") 21 22 self.runCmd("run", RUN_SUCCEEDED) 23 24 self.runCmd("expression int $i = i") 25 26 self.expect("expression $i == i", 27 startstr = "(bool) $0 = true") 28 29 self.expect("expression $i + 1", 30 startstr = "(int) $1 = 6") 31 32 self.expect("expression $i + 3", 33 startstr = "(int) $2 = 8") 34 35 self.expect("expression $2 + $1", 36 startstr = "(int) $3 = 14") 37 38 self.expect("expression $3", 39 startstr = "(int) $3 = 14") 40 41 self.expect("expression $2", 42 startstr = "(int) $2 = 8") 43 44 self.expect("expression (int)-2", 45 startstr = "(int) $4 = -2") 46 47 self.expect("expression $4 > (int)31", 48 startstr = "(bool) $5 = false") 49 50 self.expect("expression (long)$4", 51 startstr = "(long) $6 = -2") 52 53if __name__ == '__main__': 54 import atexit 55 lldb.SBDebugger.Initialize() 56 atexit.register(lambda: lldb.SBDebugger.Terminate()) 57 unittest2.main() 58