summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lldb/test/lldbtest.py42
-rw-r--r--lldb/test/persistent_variables/Makefile5
-rw-r--r--lldb/test/persistent_variables/TestPersistentVariables.py4
-rw-r--r--lldb/test/persistent_variables/main.c13
-rw-r--r--lldb/test/plugins/darwin.py8
-rw-r--r--lldb/test/settings/TestSettings.py6
6 files changed, 67 insertions, 11 deletions
diff --git a/lldb/test/lldbtest.py b/lldb/test/lldbtest.py
index b0fd59a173a..1789b57dd75 100644
--- a/lldb/test/lldbtest.py
+++ b/lldb/test/lldbtest.py
@@ -271,20 +271,47 @@ class TestBase(unittest2.TestCase):
# Can be overridden by the LLDB_TIME_WAIT environment variable.
timeWait = 1.0;
- def setUp(self):
- #import traceback
- #traceback.print_stack()
+ # Keep track of the old current working directory.
+ oldcwd = None
+ @classmethod
+ def setUpClass(cls):
# Fail fast if 'mydir' attribute is not overridden.
- if not self.mydir or len(self.mydir) == 0:
+ if not cls.mydir or len(cls.mydir) == 0:
raise Exception("Subclasses must override the 'mydir' attribute.")
# Save old working directory.
- self.oldcwd = os.getcwd()
+ cls.oldcwd = os.getcwd()
# Change current working directory if ${LLDB_TEST} is defined.
# See also dotest.py which sets up ${LLDB_TEST}.
if ("LLDB_TEST" in os.environ):
- os.chdir(os.path.join(os.environ["LLDB_TEST"], self.mydir));
+ if traceAlways:
+ print "Change dir to:", os.path.join(os.environ["LLDB_TEST"], cls.mydir)
+ os.chdir(os.path.join(os.environ["LLDB_TEST"], cls.mydir))
+
+ @classmethod
+ def tearDownClass(cls):
+ """Do class-wide cleanup."""
+
+ # First, let's do the platform-specific cleanup.
+ module = __import__(sys.platform)
+ if not module.cleanup():
+ raise Exception("Don't know how to do cleanup")
+
+ # Subclass might have specific cleanup function defined.
+ if getattr(cls, "classCleanup", None):
+ if traceAlways:
+ print "Call class-specific cleanup function for class:", cls
+ cls.classCleanup()
+
+ # Restore old working directory.
+ if traceAlways:
+ print "Restore dir to:", cls.oldcwd
+ os.chdir(cls.oldcwd)
+
+ def setUp(self):
+ #import traceback
+ #traceback.print_stack()
if "LLDB_MAX_LAUNCH_COUNT" in os.environ:
self.maxLaunchCount = int(os.environ["LLDB_MAX_LAUNCH_COUNT"])
@@ -330,9 +357,6 @@ class TestBase(unittest2.TestCase):
del self.dbg
- # Restore old working directory.
- os.chdir(self.oldcwd)
-
def runCmd(self, cmd, msg=None, check=True, trace=False, setCookie=True):
"""
Ask the command interpreter to handle the command and then check its
diff --git a/lldb/test/persistent_variables/Makefile b/lldb/test/persistent_variables/Makefile
new file mode 100644
index 00000000000..d6cd0db0506
--- /dev/null
+++ b/lldb/test/persistent_variables/Makefile
@@ -0,0 +1,5 @@
+LEVEL = ../make
+
+C_SOURCES := main.c
+
+include $(LEVEL)/Makefile.rules
diff --git a/lldb/test/persistent_variables/TestPersistentVariables.py b/lldb/test/persistent_variables/TestPersistentVariables.py
index 9f1ea77703a..b0b7170ef2b 100644
--- a/lldb/test/persistent_variables/TestPersistentVariables.py
+++ b/lldb/test/persistent_variables/TestPersistentVariables.py
@@ -13,7 +13,9 @@ class PersistentVariablesTestCase(TestBase):
def test_persistent_variables(self):
"""Test that lldb persistent variables works correctly."""
- self.runCmd("file ../array_types/a.out", CURRENT_EXECUTABLE_SET)
+ self.buildDefault()
+
+ self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
self.runCmd("breakpoint set --name main")
diff --git a/lldb/test/persistent_variables/main.c b/lldb/test/persistent_variables/main.c
new file mode 100644
index 00000000000..343eac7e554
--- /dev/null
+++ b/lldb/test/persistent_variables/main.c
@@ -0,0 +1,13 @@
+//===-- main.c --------------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main (int argc, char const *argv[])
+{
+ return 0;
+}
diff --git a/lldb/test/plugins/darwin.py b/lldb/test/plugins/darwin.py
index 821f40dd7c3..1f10d86ab95 100644
--- a/lldb/test/plugins/darwin.py
+++ b/lldb/test/plugins/darwin.py
@@ -50,3 +50,11 @@ def buildDwarf(compiler=None):
# True signifies that we can handle building dsym.
return True
+
+def cleanup():
+ """Do class-wide cleanup after the test."""
+ if os.path.isfile("Makefile"):
+ lldbtest.system(["/bin/sh", "-c", "make clean"])
+
+ # True signifies that we can handle building dsym.
+ return True
diff --git a/lldb/test/settings/TestSettings.py b/lldb/test/settings/TestSettings.py
index f18c0bc9d6e..e7dbdce2fae 100644
--- a/lldb/test/settings/TestSettings.py
+++ b/lldb/test/settings/TestSettings.py
@@ -11,6 +11,10 @@ class SettingsCommandTestCase(TestBase):
mydir = "settings"
+ @classmethod
+ def classCleanup(cls):
+ system(["/bin/sh", "-c", "rm output.txt"])
+
def test_set_prompt(self):
"""Test that 'set prompt' actually changes the prompt."""
@@ -62,7 +66,7 @@ class SettingsCommandTestCase(TestBase):
self.runCmd("run", RUN_SUCCEEDED)
# Read the output file produced by running the program.
- output = open('/tmp/output.txt', 'r').read()
+ output = open('output.txt', 'r').read()
self.assertTrue(output.startswith("argv[1] matches") and
output.find("argv[2] matches") > 0 and
OpenPOWER on IntegriCloud