summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohnny Chen <johnny.chen@apple.com>2010-08-25 18:49:48 +0000
committerJohnny Chen <johnny.chen@apple.com>2010-08-25 18:49:48 +0000
commitf2b70237e657dd43a724c564d47d4c758b9d8c49 (patch)
tree87ecb09c801a751c33fd33e1485166d281e4d78f
parent0de55cecb2797335db1c479d15aca13b9e32a7cd (diff)
downloadbcm5719-llvm-f2b70237e657dd43a724c564d47d4c758b9d8c49.tar.gz
bcm5719-llvm-f2b70237e657dd43a724c564d47d4c758b9d8c49.zip
Allow command retries in case of process launch failures. This recovery
mechanism seems to work fine on my MacBook Pro in some limited test cases. The default maxLaunchCount and timeWait variables used in the scheme can be overridden by the env variables LLDB_MAX_LAUNCH_COUNT and LLDB_TIME_WAIT. llvm-svn: 112071
-rw-r--r--lldb/test/lldbtest.py37
1 files changed, 29 insertions, 8 deletions
diff --git a/lldb/test/lldbtest.py b/lldb/test/lldbtest.py
index b9e211e4237..10ecb63b25c 100644
--- a/lldb/test/lldbtest.py
+++ b/lldb/test/lldbtest.py
@@ -107,6 +107,7 @@ $
import os
import sys
+import time
import unittest2
import lldb
@@ -150,6 +151,14 @@ class TestBase(unittest2.TestCase):
# State pertaining to the inferior process, if any.
runStarted = False
+ # Maximum allowed attempts when launching the inferior process.
+ # Can be overridden by the LLDB_MAX_LAUNCH_COUNT environment variable.
+ maxLaunchCount = 3;
+
+ # Time to wait before the next launching attempt in second(s).
+ # Can be overridden by the LLDB_TIME_WAIT environment variable.
+ timeWait = 1.0;
+
# os.environ["LLDB_COMMAND_TRACE"], if set to "YES", will turn on this flag.
traceAlways = False;
@@ -168,6 +177,12 @@ class TestBase(unittest2.TestCase):
if ("LLDB_TEST" in os.environ):
os.chdir(os.path.join(os.environ["LLDB_TEST"], self.mydir));
+ if "LLDB_MAX_LAUNCH_COUNT" in os.environ:
+ self.maxLaunchCount = int(os.environ["LLDB_MAX_LAUNCH_COUNT"])
+
+ if "LLDB_TIME_WAIT" in os.environ:
+ self.timeWait = float(os.environ["LLDB_TIME_WAIT"])
+
if ("LLDB_COMMAND_TRACE" in os.environ and
os.environ["LLDB_COMMAND_TRACE"] == "YES"):
self.traceAlways = True
@@ -213,19 +228,25 @@ class TestBase(unittest2.TestCase):
trace = (True if self.traceAlways else trace)
- if trace:
- print >> sys.stderr, "runCmd:", cmd
+ self.runStarted = (cmd.startswith("run") or
+ cmd.startswith("process launch"))
- self.ci.HandleCommand(cmd, self.res)
+ for i in range(self.maxLaunchCount if self.runStarted else 1):
+ self.ci.HandleCommand(cmd, self.res)
- if cmd.startswith("run"):
- self.runStarted = True
+ if trace:
+ print >> sys.stderr, "runCmd:", cmd
+ if self.res.Succeeded():
+ print >> sys.stderr, "output:", self.res.GetOutput()
+ else:
+ print >> sys.stderr, self.res.GetError()
- if trace:
if self.res.Succeeded():
- print >> sys.stderr, "output:", self.res.GetOutput()
+ break
else:
- print >> sys.stderr, self.res.GetError()
+ if self.runStarted:
+ # Process launch failed, wait some time before the next try.
+ time.sleep(self.timeWait)
if check:
self.assertTrue(self.res.Succeeded(),
OpenPOWER on IntegriCloud