[Lldb-commits] [lldb] r110611 - in /lldb/trunk/test: array_types/TestArrayTypes.py lldbtest.py
Johnny Chen
johnny.chen at apple.com
Mon Aug 9 15:01:17 PDT 2010
Author: johnny
Date: Mon Aug 9 17:01:17 2010
New Revision: 110611
URL: http://llvm.org/viewvc/llvm-project?rev=110611&view=rev
Log:
Added some commonly used assert messages to the lldbtest.py module which houses
the TestBase. Modified TestArrayTypes.py to use the assert messages. Other
files to follow.
Modified:
lldb/trunk/test/array_types/TestArrayTypes.py
lldb/trunk/test/lldbtest.py
Modified: lldb/trunk/test/array_types/TestArrayTypes.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/array_types/TestArrayTypes.py?rev=110611&r1=110610&r2=110611&view=diff
==============================================================================
--- lldb/trunk/test/array_types/TestArrayTypes.py (original)
+++ lldb/trunk/test/array_types/TestArrayTypes.py Mon Aug 9 17:01:17 2010
@@ -3,9 +3,9 @@
import os, time
import unittest2
import lldb
-import lldbtest
+from lldbtest import *
-class TestArrayTypes(lldbtest.TestBase):
+class TestArrayTypes(TestBase):
mydir = "array_types"
@@ -14,29 +14,31 @@
res = self.res
exe = os.path.join(os.getcwd(), "a.out")
self.ci.HandleCommand("file " + exe, res)
- self.assertTrue(res.Succeeded())
+ self.assertTrue(res.Succeeded(), CURRENT_EXECUTABLE_SET)
# Break on line 42 inside main().
self.ci.HandleCommand("breakpoint set -f main.c -l 42", res)
self.assertTrue(res.Succeeded())
self.assertTrue(res.GetOutput().startswith(
- "Breakpoint created: 1: file ='main.c', line = 42, locations = 1"))
+ "Breakpoint created: 1: file ='main.c', line = 42, locations = 1"),
+ BREAK_POINT_CREATED)
self.ci.HandleCommand("run", res)
- time.sleep(0.1)
+ time.sleep(1)
self.assertTrue(res.Succeeded())
# The stop reason of the thread should be breakpoint.
self.ci.HandleCommand("thread list", res)
- print "thread list ->", res.GetOutput()
self.assertTrue(res.Succeeded())
self.assertTrue(res.GetOutput().find('state is Stopped') > 0 and
- res.GetOutput().find('stop reason = breakpoint') > 0)
+ res.GetOutput().find('stop reason = breakpoint') > 0,
+ STOPPED_DUE_TO_BREAKPOINT)
# The breakpoint should have a hit count of 1.
self.ci.HandleCommand("breakpoint list", res)
self.assertTrue(res.Succeeded())
- self.assertTrue(res.GetOutput().find('resolved, hit count = 1') > 0)
+ self.assertTrue(res.GetOutput().find('resolved, hit count = 1') > 0,
+ BREAK_POINT_HIT_ONCE)
# Issue 'variable list' command on several array-type variables.
@@ -51,20 +53,24 @@
output.find('Hello') > 0 and
output.find('Hola') > 0 and
output.find('Bonjour') > 0 and
- output.find('Guten Tag') > 0)
+ output.find('Guten Tag') > 0,
+ VARIABLES_DISPLAYED_CORRECTLY)
self.ci.HandleCommand("variable list char_16", res);
self.assertTrue(res.Succeeded())
self.assertTrue(res.GetOutput().find('(char) char_16[0]') > 0 and
- res.GetOutput().find('(char) char_16[15]') > 0)
+ res.GetOutput().find('(char) char_16[15]') > 0,
+ VARIABLES_DISPLAYED_CORRECTLY)
self.ci.HandleCommand("variable list ushort_matrix", res);
self.assertTrue(res.Succeeded())
- self.assertTrue(res.GetOutput().startswith('(unsigned short [2][3])'))
+ self.assertTrue(res.GetOutput().startswith('(unsigned short [2][3])'),
+ VARIABLES_DISPLAYED_CORRECTLY)
self.ci.HandleCommand("variable list long_6", res);
self.assertTrue(res.Succeeded())
- self.assertTrue(res.GetOutput().startswith('(long [6])'))
+ self.assertTrue(res.GetOutput().startswith('(long [6])'),
+ VARIABLES_DISPLAYED_CORRECTLY)
self.ci.HandleCommand("continue", res)
self.assertTrue(res.Succeeded())
Modified: lldb/trunk/test/lldbtest.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbtest.py?rev=110611&r1=110610&r2=110611&view=diff
==============================================================================
--- lldb/trunk/test/lldbtest.py (original)
+++ lldb/trunk/test/lldbtest.py Mon Aug 9 17:01:17 2010
@@ -31,6 +31,24 @@
import unittest2
import lldb
+#
+# Some commonly used assert messages.
+#
+
+CURRENT_EXECUTABLE_SET = "Current executable set successfully"
+
+COMMAND_HANDLED = "Command handled successfully"
+
+BREAK_POINT_CREATED = "Breakpoint created successfully"
+
+BREAK_POINT_HIT_ONCE = "Breakpoint resolved with hit cout = 1"
+
+STOPPED_DUE_TO_BREAKPOINT = "Process state is stopped due to breakpoint"
+
+STOPPED_DUE_TO_STEP_IN = "Process state is stopped due to step in"
+
+VARIABLES_DISPLAYED_CORRECTLY = "Show specified variable(s) correctly"
+
class TestBase(unittest2.TestCase):
"""This LLDB abstract base class is meant to be subclassed."""
More information about the lldb-commits
mailing list