[Lldb-commits] [lldb] r111811 - in /lldb/trunk/test: dotest.py lldbtest.py stl/TestSTL.py
Johnny Chen
johnny.chen at apple.com
Mon Aug 23 10:10:45 PDT 2010
Author: johnny
Date: Mon Aug 23 12:10:44 2010
New Revision: 111811
URL: http://llvm.org/viewvc/llvm-project?rev=111811&view=rev
Log:
Changed the keyword argument for runCmd()/expect() from 'verbose' to 'trace',
which, defaults to False, and if set to True, will trace lldb command execution
and result.
Added "-t" command option to the test driver dotest.py which sets the
LLDB_COMMAND_TRACE environment variable to "YES" and as a result always turns on
command tracing regardless of the 'trace' keyword argument to runCmd()/expect().
Modified:
lldb/trunk/test/dotest.py
lldb/trunk/test/lldbtest.py
lldb/trunk/test/stl/TestSTL.py
Modified: lldb/trunk/test/dotest.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/dotest.py?rev=111811&r1=111810&r2=111811&view=diff
==============================================================================
--- lldb/trunk/test/dotest.py (original)
+++ lldb/trunk/test/dotest.py Mon Aug 23 12:10:44 2010
@@ -59,6 +59,7 @@
Usage: dotest.py [option] [args]
where options:
-h : print this help message and exit (also --help)
+-t : trace lldb command execution and result
-v : do verbose mode of unittest framework
and:
@@ -118,11 +119,15 @@
usage()
sys.exit(0)
else:
- # Process possible verbose flag.
+ # Process possible trace and/or verbose flag.
index = 1
- if sys.argv[1].find('-v') != -1:
- verbose = 2
- index += 1
+ for i in range(1, len(sys.argv) - 1):
+ if sys.argv[index].startswith('-t'):
+ os.environ["LLDB_COMMAND_TRACE"] = "YES"
+ index += 1
+ if sys.argv[index].startswith('-v'):
+ verbose = 2
+ index += 1
# Gather all the dirs passed on the command line.
if len(sys.argv) > index:
Modified: lldb/trunk/test/lldbtest.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbtest.py?rev=111811&r1=111810&r2=111811&view=diff
==============================================================================
--- lldb/trunk/test/lldbtest.py (original)
+++ lldb/trunk/test/lldbtest.py Mon Aug 23 12:10:44 2010
@@ -24,6 +24,84 @@
Ran 1 test in 0.363s
OK
+$ LLDB_COMMAND_TRACE=YES python array_types/TestArrayTypes.py
+LLDB_COMMAND_TRACE=YES python array_types/TestArrayTypes.py
+runCmd: file /Volumes/data/lldb/svn/trunk/test/array_types/a.out
+output: Current executable set to '/Volumes/data/lldb/svn/trunk/test/array_types/a.out' (x86_64).
+
+runCmd: breakpoint set -f main.c -l 42
+output: Breakpoint created: 1: file ='main.c', line = 42, locations = 1
+
+runCmd: run
+output: Launching '/Volumes/data/lldb/svn/trunk/test/array_types/a.out' (x86_64)
+
+runCmd: thread list
+output: Process 24987 state is Stopped
+ thread #1: tid = 0x2e03, pc = 0x0000000100000df4, where = a.out`main + 612 at /Volumes/data/lldb/svn/trunk/test/array_types/main.c:45, stop reason = breakpoint 1.1, queue = com.apple.main-thread
+
+runCmd: breakpoint list
+output: Current breakpoints:
+1: file ='main.c', line = 42, locations = 1, resolved = 1
+ 1.1: where = a.out`main + 612 at /Volumes/data/lldb/svn/trunk/test/array_types/main.c:45, address = 0x0000000100000df4, resolved, hit count = 1
+
+
+runCmd: variable list strings
+output: (char *[4]) strings = {
+ (char *) strings[0] = 0x0000000100000f0c "Hello",
+ (char *) strings[1] = 0x0000000100000f12 "Hola",
+ (char *) strings[2] = 0x0000000100000f17 "Bonjour",
+ (char *) strings[3] = 0x0000000100000f1f "Guten Tag"
+}
+
+runCmd: variable list char_16
+output: (char [16]) char_16 = {
+ (char) char_16[0] = 'H',
+ (char) char_16[1] = 'e',
+ (char) char_16[2] = 'l',
+ (char) char_16[3] = 'l',
+ (char) char_16[4] = 'o',
+ (char) char_16[5] = ' ',
+ (char) char_16[6] = 'W',
+ (char) char_16[7] = 'o',
+ (char) char_16[8] = 'r',
+ (char) char_16[9] = 'l',
+ (char) char_16[10] = 'd',
+ (char) char_16[11] = '\n',
+ (char) char_16[12] = '\0',
+ (char) char_16[13] = '\0',
+ (char) char_16[14] = '\0',
+ (char) char_16[15] = '\0'
+}
+
+runCmd: variable list ushort_matrix
+output: (unsigned short [2][3]) ushort_matrix = {
+ (unsigned short [3]) ushort_matrix[0] = {
+ (unsigned short) ushort_matrix[0][0] = 0x0001,
+ (unsigned short) ushort_matrix[0][1] = 0x0002,
+ (unsigned short) ushort_matrix[0][2] = 0x0003
+ },
+ (unsigned short [3]) ushort_matrix[1] = {
+ (unsigned short) ushort_matrix[1][0] = 0x000b,
+ (unsigned short) ushort_matrix[1][1] = 0x0016,
+ (unsigned short) ushort_matrix[1][2] = 0x0021
+ }
+}
+
+runCmd: variable list long_6
+output: (long [6]) long_6 = {
+ (long) long_6[0] = 1,
+ (long) long_6[1] = 2,
+ (long) long_6[2] = 3,
+ (long) long_6[3] = 4,
+ (long) long_6[4] = 5,
+ (long) long_6[5] = 6
+}
+
+.
+----------------------------------------------------------------------
+Ran 1 test in 0.349s
+
+OK
$
"""
@@ -70,6 +148,9 @@
# State pertaining to the inferior process, if any.
runStarted = False
+ # os.environ["LLDB_COMMAND_TRACE"], if set to "YES", will turn on this flag.
+ traceAlways = False;
+
def setUp(self):
#import traceback
#traceback.print_stack()
@@ -85,6 +166,10 @@
if ("LLDB_TEST" in os.environ):
os.chdir(os.path.join(os.environ["LLDB_TEST"], self.mydir));
+ if ("LLDB_COMMAND_TRACE" in os.environ and
+ os.environ["LLDB_COMMAND_TRACE"] == "YES"):
+ self.traceAlways = True
+
# Create the debugger instance if necessary.
try:
self.dbg = lldb.DBG
@@ -115,7 +200,7 @@
# Restore old working directory.
os.chdir(self.oldcwd)
- def runCmd(self, cmd, msg=None, check=True, verbose=False):
+ def runCmd(self, cmd, msg=None, check=True, trace=False):
"""
Ask the command interpreter to handle the command and then check its
return status.
@@ -124,7 +209,9 @@
if not cmd or len(cmd) == 0:
raise Exception("Bad 'cmd' parameter encountered")
- if verbose:
+ trace = (True if self.traceAlways else trace)
+
+ if trace:
print >> sys.stderr, "runCmd:", cmd
self.ci.HandleCommand(cmd, self.res)
@@ -132,7 +219,7 @@
if cmd.startswith("run"):
self.runStarted = True
- if verbose:
+ if trace:
if self.res.Succeeded():
print >> sys.stderr, "output:", self.res.GetOutput()
else:
@@ -142,7 +229,7 @@
self.assertTrue(self.res.Succeeded(),
msg if msg else CMD_MSG(cmd))
- def expect(self, cmd, msg=None, startstr=None, substrs=None, verbose=False):
+ def expect(self, cmd, msg=None, startstr=None, substrs=None, trace=False):
"""
Similar to runCmd; with additional expect style output matching ability.
@@ -152,21 +239,23 @@
'startstr' and matches the substrings contained in 'substrs'.
"""
+ trace = (True if self.traceAlways else trace)
+
# First run the command.
- self.runCmd(cmd, verbose = (True if verbose else False))
+ self.runCmd(cmd, trace = (True if trace else False))
# Then compare the output against expected strings.
output = self.res.GetOutput()
matched = output.startswith(startstr) if startstr else True
- if not matched and startstr and verbose:
+ if not matched and startstr and trace:
print >> sys.stderr, "Startstr not matched:", startstr
if substrs:
for str in substrs:
matched = output.find(str) > 0
if not matched:
- if verbose:
+ if trace:
print >> sys.stderr, "Substring not matched:", str
break
Modified: lldb/trunk/test/stl/TestSTL.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/stl/TestSTL.py?rev=111811&r1=111810&r2=111811&view=diff
==============================================================================
--- lldb/trunk/test/stl/TestSTL.py (original)
+++ lldb/trunk/test/stl/TestSTL.py Mon Aug 23 12:10:44 2010
@@ -42,7 +42,7 @@
# This assertion currently always fails.
# This might be related: rdar://problem/8247112.
#
- #self.runCmd("thread step-in", verbose=True)
+ #self.runCmd("thread step-in", trace=True)
self.runCmd("thread step-in")
self.expect("thread backtrace", "We have stepped in STL",
More information about the lldb-commits
mailing list