[Lldb-commits] [lldb] r109545 - /lldb/trunk/test/unsigned_types/TestUnsignedTypes.py

Johnny Chen johnny.chen at apple.com
Tue Jul 27 14:49:20 PDT 2010


Author: johnny
Date: Tue Jul 27 16:49:20 2010
New Revision: 109545

URL: http://llvm.org/viewvc/llvm-project?rev=109545&view=rev
Log:
Added a test case for showing variables of unsigned types.

Added:
    lldb/trunk/test/unsigned_types/TestUnsignedTypes.py

Added: lldb/trunk/test/unsigned_types/TestUnsignedTypes.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/unsigned_types/TestUnsignedTypes.py?rev=109545&view=auto
==============================================================================
--- lldb/trunk/test/unsigned_types/TestUnsignedTypes.py (added)
+++ lldb/trunk/test/unsigned_types/TestUnsignedTypes.py Tue Jul 27 16:49:20 2010
@@ -0,0 +1,72 @@
+"""
+Test that variables with unsigned types display correctly.
+"""
+
+import os, time
+import re
+import unittest
+import lldb
+import lldbtest
+
+class TestUnsignedTypes(lldbtest.TestBase):
+
+    mydir = "unsigned_types"
+
+    def test_unsigned_types(self):
+        """Test that variables with unsigned types display correctly."""
+        res = self.res
+        exe = os.path.join(os.getcwd(), "a.out")
+        self.ci.HandleCommand("file " + exe, res)
+        self.assertTrue(res.Succeeded())
+
+        # Break on line 19 in main() aftre the variables are assigned values.
+        self.ci.HandleCommand("breakpoint set -f main.cpp -l 19", res)
+        self.assertTrue(res.Succeeded())
+        self.assertTrue(res.GetOutput().startswith(
+            "Breakpoint created: 1: file ='main.cpp', line = 19, locations = 1")
+                        )
+
+        self.ci.HandleCommand("run", res)
+        time.sleep(0.1)
+        self.assertTrue(res.Succeeded())
+
+        # The stop reason of the thread should be breakpoint.
+        self.ci.HandleCommand("thread list", res)
+        self.assertTrue(res.Succeeded())
+        self.assertTrue(res.GetOutput().find('state is Stopped') > 0 and
+                        res.GetOutput().find('stop reason = breakpoint') > 0)
+
+        # 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)
+
+        # Test that unsigned types display correctly.
+        self.ci.HandleCommand("variable list -a", res)
+        print "variable list -a ->", res.GetOutput()
+        self.assertTrue(res.Succeeded())
+        output = res.GetOutput()
+        self.assertTrue(
+            output.startswith("the_unsigned_char = (unsigned char) 'c'")
+            and
+            output.find("the_unsigned_short = (short unsigned int) 0x0063") > 0
+            and
+            output.find("the_unsigned_int = (unsigned int) 0x00000063") > 0
+            and
+            output.find("the_unsigned_long = (long unsigned int) "
+                        "0x0000000000000063") > 0
+            and
+            output.find("the_unsigned_long_long = (long long unsigned int)"
+                        " 0x0000000000000063") > 0
+            and
+            output.find("the_uint32 = (uint32_t) 0x00000063")
+            )
+        
+        self.ci.HandleCommand("continue", res)
+        self.assertTrue(res.Succeeded())
+
+
+if __name__ == '__main__':
+    lldb.SBDebugger.Initialize()
+    unittest.main()
+    lldb.SBDebugger.Terminate()





More information about the lldb-commits mailing list