| Johnny Chen | f288803 | 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 | |
| Johnny Chen | cbb4be0 | 2010-09-01 19:59:58 +0000 | [diff] [blame] | 10 | class PersistentVariablesTestCase(TestBase): |
| Johnny Chen | f288803 | 2010-08-13 20:12:05 +0000 | [diff] [blame] | 11 | |
| Greg Clayton | 4570d3e | 2013-12-10 23:19:29 +0000 | [diff] [blame] | 12 | mydir = TestBase.compute_mydir(__file__) |
| Johnny Chen | f288803 | 2010-08-13 20:12:05 +0000 | [diff] [blame] | 13 | |
| 14 | def test_persistent_variables(self): |
| 15 | """Test that lldb persistent variables works correctly.""" |
| Johnny Chen | 1a9f4dd | 2010-09-16 01:53:04 +0000 | [diff] [blame] | 16 | self.buildDefault() |
| 17 | |
| 18 | self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) |
| Johnny Chen | f288803 | 2010-08-13 20:12:05 +0000 | [diff] [blame] | 19 | |
| Sean Callanan | fbf5c68 | 2013-05-22 22:49:06 +0000 | [diff] [blame] | 20 | self.runCmd("breakpoint set --source-pattern-regexp break") |
| Johnny Chen | f288803 | 2010-08-13 20:12:05 +0000 | [diff] [blame] | 21 | |
| Sean Callanan | 05834cd | 2015-07-01 23:56:30 +0000 | [diff] [blame^] | 22 | self.runCmd("run", RUN_SUCCEEDED) |
| Johnny Chen | f288803 | 2010-08-13 20:12:05 +0000 | [diff] [blame] | 23 | |
| Sean Callanan | fbf5c68 | 2013-05-22 22:49:06 +0000 | [diff] [blame] | 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") |
| Johnny Chen | f288803 | 2010-08-13 20:12:05 +0000 | [diff] [blame] | 31 | |
| Johnny Chen | a8807f9 | 2010-10-19 00:52:07 +0000 | [diff] [blame] | 32 | self.expect("expression $i + 3", |
| Sean Callanan | fbf5c68 | 2013-05-22 22:49:06 +0000 | [diff] [blame] | 33 | startstr = "(int) $2 = 8") |
| Johnny Chen | f288803 | 2010-08-13 20:12:05 +0000 | [diff] [blame] | 34 | |
| Sean Callanan | fbf5c68 | 2013-05-22 22:49:06 +0000 | [diff] [blame] | 35 | self.expect("expression $2 + $1", |
| 36 | startstr = "(int) $3 = 14") |
| Johnny Chen | f288803 | 2010-08-13 20:12:05 +0000 | [diff] [blame] | 37 | |
| Sean Callanan | fbf5c68 | 2013-05-22 22:49:06 +0000 | [diff] [blame] | 38 | self.expect("expression $3", |
| 39 | startstr = "(int) $3 = 14") |
| Johnny Chen | 6b4896f | 2010-12-14 17:48:26 +0000 | [diff] [blame] | 40 | |
| Sean Callanan | fbf5c68 | 2013-05-22 22:49:06 +0000 | [diff] [blame] | 41 | self.expect("expression $2", |
| 42 | startstr = "(int) $2 = 8") |
| Johnny Chen | f288803 | 2010-08-13 20:12:05 +0000 | [diff] [blame] | 43 | |
| Sean Callanan | 0b342b6 | 2013-05-24 20:36:56 +0000 | [diff] [blame] | 44 | self.expect("expression (int)-2", |
| 45 | startstr = "(int) $4 = -2") |
| 46 | |
| 47 | self.expect("expression $4 > (int)31", |
| 48 | startstr = "(bool) $5 = false") |
| Johnny Chen | f288803 | 2010-08-13 20:12:05 +0000 | [diff] [blame] | 49 | |
| Sean Callanan | 415422c | 2013-06-05 22:07:06 +0000 | [diff] [blame] | 50 | self.expect("expression (long)$4", |
| 51 | startstr = "(long) $6 = -2") |
| 52 | |
| Johnny Chen | f288803 | 2010-08-13 20:12:05 +0000 | [diff] [blame] | 53 | if __name__ == '__main__': |
| 54 | import atexit |
| 55 | lldb.SBDebugger.Initialize() |
| 56 | atexit.register(lambda: lldb.SBDebugger.Terminate()) |
| 57 | unittest2.main() |