llvm-project/lldb/test/persistent_variables/TestPersistentVariables.py
Johnny Chen 6ca006c7c1 Factored the "continue" command execution of the inferior process as part of the
cleanup before finish into the test fixture in lldbtest.TestBase.tearDown().

Derivatives of TestBase is responsible for setting self.runStarted to True if an
inferior process has been started.

llvm-svn: 111188
2010-08-16 21:28:10 +00:00

60 lines
1.7 KiB
Python

"""
Test that lldb persistent variables works correctly.
"""
import os, time
import unittest2
import lldb
from lldbtest import *
class TestPersistentVariables(TestBase):
mydir = "persistent_variables"
def test_persistent_variables(self):
"""Test that lldb persistent variables works correctly."""
res = self.res
self.ci.HandleCommand("file ../array_types/a.out", res)
self.assertTrue(res.Succeeded(), CURRENT_EXECUTABLE_SET)
self.ci.HandleCommand("breakpoint set --name main", res)
self.assertTrue(res.Succeeded())
self.ci.HandleCommand("run", res)
self.runStarted = True
self.assertTrue(res.Succeeded(), RUN_STOPPED)
self.ci.HandleCommand("expr int $i = 5; $i + 1", res)
self.assertTrue(res.Succeeded(), CMD_MSG('expr int $i = 5; $i + 1'))
#print res.GetOutput()
# $0 = (int)6
self.ci.HandleCommand("expr $i + 3", res)
self.assertTrue(res.Succeeded(), CMD_MSG('expr $i + 3'))
#print res.GetOutput()
# $1 = (int)8
self.ci.HandleCommand("expr $1 + $0", res)
self.assertTrue(res.Succeeded(), CMD_MSG('expr $1 + $0'))
#print res.GetOutput()
# $2 = (int)14
self.ci.HandleCommand("expr $2", res)
self.assertTrue(res.Succeeded() and
res.GetOutput().startswith("$3 = (int) 14"),
CMD_MSG('expr $2'))
#print res.GetOutput()
# $3 = (int)14
self.ci.HandleCommand("continue", res)
self.ci.HandleCommand("quit", res)
self.runStarted = False
if __name__ == '__main__':
import atexit
lldb.SBDebugger.Initialize()
atexit.register(lambda: lldb.SBDebugger.Terminate())
unittest2.main()