blob: 8aff13ad452464fb61af862ee60365f5a8ca76d3 [file] [log] [blame]
Johnny Chen741bf6c2010-08-13 20:12:05 +00001"""
2Test that lldb persistent variables works correctly.
3"""
4
5import os, time
6import unittest2
7import lldb
8from lldbtest import *
9
10class TestPersistentVariables(TestBase):
11
12 mydir = "persistent_variables"
13
14 def test_persistent_variables(self):
15 """Test that lldb persistent variables works correctly."""
16 res = self.res
17
18 self.ci.HandleCommand("file ../array_types/a.out", res)
19 self.assertTrue(res.Succeeded(), CURRENT_EXECUTABLE_SET)
20
21 self.ci.HandleCommand("breakpoint set --name main", res)
22 self.assertTrue(res.Succeeded())
23
24 self.ci.HandleCommand("run", res)
Johnny Chenffde4fc2010-08-16 21:28:10 +000025 self.runStarted = True
Johnny Chen741bf6c2010-08-13 20:12:05 +000026 self.assertTrue(res.Succeeded(), RUN_STOPPED)
27
28 self.ci.HandleCommand("expr int $i = 5; $i + 1", res)
29 self.assertTrue(res.Succeeded(), CMD_MSG('expr int $i = 5; $i + 1'))
30 #print res.GetOutput()
31 # $0 = (int)6
32
33 self.ci.HandleCommand("expr $i + 3", res)
34 self.assertTrue(res.Succeeded(), CMD_MSG('expr $i + 3'))
35 #print res.GetOutput()
36 # $1 = (int)8
37
38 self.ci.HandleCommand("expr $1 + $0", res)
39 self.assertTrue(res.Succeeded(), CMD_MSG('expr $1 + $0'))
40 #print res.GetOutput()
41 # $2 = (int)14
42
43 self.ci.HandleCommand("expr $2", res)
44 self.assertTrue(res.Succeeded() and
45 res.GetOutput().startswith("$3 = (int) 14"),
46 CMD_MSG('expr $2'))
47 #print res.GetOutput()
48 # $3 = (int)14
49
50 self.ci.HandleCommand("continue", res)
51 self.ci.HandleCommand("quit", res)
Johnny Chenffde4fc2010-08-16 21:28:10 +000052 self.runStarted = False
Johnny Chen741bf6c2010-08-13 20:12:05 +000053
54
55if __name__ == '__main__':
56 import atexit
57 lldb.SBDebugger.Initialize()
58 atexit.register(lambda: lldb.SBDebugger.Terminate())
59 unittest2.main()