blob: 8e7af009c6a5ec1cd3c2b82cad4fa811001fee2a [file] [log] [blame]
Johnny Chenf2888032010-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
Johnny Chencbb4be02010-09-01 19:59:58 +000010class PersistentVariablesTestCase(TestBase):
Johnny Chenf2888032010-08-13 20:12:05 +000011
Greg Clayton4570d3e2013-12-10 23:19:29 +000012 mydir = TestBase.compute_mydir(__file__)
Johnny Chenf2888032010-08-13 20:12:05 +000013
14 def test_persistent_variables(self):
15 """Test that lldb persistent variables works correctly."""
Johnny Chen1a9f4dd2010-09-16 01:53:04 +000016 self.buildDefault()
17
18 self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
Johnny Chenf2888032010-08-13 20:12:05 +000019
Sean Callananfbf5c682013-05-22 22:49:06 +000020 self.runCmd("breakpoint set --source-pattern-regexp break")
Johnny Chenf2888032010-08-13 20:12:05 +000021
Sean Callanan05834cd2015-07-01 23:56:30 +000022 self.runCmd("run", RUN_SUCCEEDED)
Johnny Chenf2888032010-08-13 20:12:05 +000023
Sean Callananfbf5c682013-05-22 22:49:06 +000024 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 Chenf2888032010-08-13 20:12:05 +000031
Johnny Chena8807f92010-10-19 00:52:07 +000032 self.expect("expression $i + 3",
Sean Callananfbf5c682013-05-22 22:49:06 +000033 startstr = "(int) $2 = 8")
Johnny Chenf2888032010-08-13 20:12:05 +000034
Sean Callananfbf5c682013-05-22 22:49:06 +000035 self.expect("expression $2 + $1",
36 startstr = "(int) $3 = 14")
Johnny Chenf2888032010-08-13 20:12:05 +000037
Sean Callananfbf5c682013-05-22 22:49:06 +000038 self.expect("expression $3",
39 startstr = "(int) $3 = 14")
Johnny Chen6b4896f2010-12-14 17:48:26 +000040
Sean Callananfbf5c682013-05-22 22:49:06 +000041 self.expect("expression $2",
42 startstr = "(int) $2 = 8")
Johnny Chenf2888032010-08-13 20:12:05 +000043
Sean Callanan0b342b62013-05-24 20:36:56 +000044 self.expect("expression (int)-2",
45 startstr = "(int) $4 = -2")
46
47 self.expect("expression $4 > (int)31",
48 startstr = "(bool) $5 = false")
Johnny Chenf2888032010-08-13 20:12:05 +000049
Sean Callanan415422c2013-06-05 22:07:06 +000050 self.expect("expression (long)$4",
51 startstr = "(long) $6 = -2")
52
Johnny Chenf2888032010-08-13 20:12:05 +000053if __name__ == '__main__':
54 import atexit
55 lldb.SBDebugger.Initialize()
56 atexit.register(lambda: lldb.SBDebugger.Terminate())
57 unittest2.main()