| Johnny Chen | 741bf6c | 2010-08-13 20:12:05 +0000 | [diff] [blame^] | 1 | """ |
| 2 | Test that lldb persistent variables works correctly. |
| 3 | """ |
| 4 | |
| 5 | import os, time |
| 6 | import unittest2 |
| 7 | import lldb |
| 8 | from lldbtest import * |
| 9 | |
| 10 | class 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) |
| 25 | self.assertTrue(res.Succeeded(), RUN_STOPPED) |
| 26 | |
| 27 | self.ci.HandleCommand("expr int $i = 5; $i + 1", res) |
| 28 | self.assertTrue(res.Succeeded(), CMD_MSG('expr int $i = 5; $i + 1')) |
| 29 | #print res.GetOutput() |
| 30 | # $0 = (int)6 |
| 31 | |
| 32 | self.ci.HandleCommand("expr $i + 3", res) |
| 33 | self.assertTrue(res.Succeeded(), CMD_MSG('expr $i + 3')) |
| 34 | #print res.GetOutput() |
| 35 | # $1 = (int)8 |
| 36 | |
| 37 | self.ci.HandleCommand("expr $1 + $0", res) |
| 38 | self.assertTrue(res.Succeeded(), CMD_MSG('expr $1 + $0')) |
| 39 | #print res.GetOutput() |
| 40 | # $2 = (int)14 |
| 41 | |
| 42 | self.ci.HandleCommand("expr $2", res) |
| 43 | self.assertTrue(res.Succeeded() and |
| 44 | res.GetOutput().startswith("$3 = (int) 14"), |
| 45 | CMD_MSG('expr $2')) |
| 46 | #print res.GetOutput() |
| 47 | # $3 = (int)14 |
| 48 | |
| 49 | self.ci.HandleCommand("continue", res) |
| 50 | self.ci.HandleCommand("quit", res) |
| 51 | |
| 52 | |
| 53 | if __name__ == '__main__': |
| 54 | import atexit |
| 55 | lldb.SBDebugger.Initialize() |
| 56 | atexit.register(lambda: lldb.SBDebugger.Terminate()) |
| 57 | unittest2.main() |