llvm-project/lldb/test/persistent_variables/TestPersistentVariables.py
Johnny Chen 1a9f4dd5a0 Provided a mechanism for the test class to cleanup after itself once it's done.
This will remove the confusion experienced when previous test runs left some
files (both intermediate or by-product as a result of the test).

lldbtest.TestBase defines a classmethod tearDownClass(cls) which invokes the
platform-specific cleanup() function as defined by the plugin; after that, it
invokes a subclass-specific function classCleanup(cls) if defined; and, finally,
it restores the old working directory.

An example of classCleanup(cls) is in settings/TestSettings.py:

    @classmethod
    def classCleanup(cls):
        system(["/bin/sh", "-c", "rm output.txt"])

where it deletes the by-product "output.txt" as a result of running a.out.

llvm-svn: 114058
2010-09-16 01:53:04 +00:00

46 lines
1.0 KiB
Python

"""
Test that lldb persistent variables works correctly.
"""
import os, time
import unittest2
import lldb
from lldbtest import *
class PersistentVariablesTestCase(TestBase):
mydir = "persistent_variables"
def test_persistent_variables(self):
"""Test that lldb persistent variables works correctly."""
self.buildDefault()
self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
self.runCmd("breakpoint set --name main")
self.runCmd("run", RUN_SUCCEEDED)
self.expect("expr int $i = 5; $i + 1",
startstr = "$0 = (int) 6")
# $0 = (int) 6
self.expect("expr $i + 3",
startstr = "$1 = (int) 8")
# $1 = (int) 8
self.expect("expr $1 + $0",
startstr = "$2 = (int) 14")
# $2 = (int) 14
self.expect("expr $2",
startstr = "$3 = (int) 14")
# $3 = (int) 14
if __name__ == '__main__':
import atexit
lldb.SBDebugger.Initialize()
atexit.register(lambda: lldb.SBDebugger.Terminate())
unittest2.main()