Fix type_lookup test to make buildbots happy
authorEugene Zemtsov <ezemtsov@google.com>
Tue, 1 May 2018 03:06:05 +0000 (03:06 +0000)
committerEugene Zemtsov <ezemtsov@google.com>
Tue, 1 May 2018 03:06:05 +0000 (03:06 +0000)
llvm-svn: 331242

lldb/packages/Python/lldbsuite/test/lang/cpp/type_lookup/Makefile
lldb/packages/Python/lldbsuite/test/lang/cpp/type_lookup/TestCppTypeLookup.py [new file with mode: 0644]
lldb/packages/Python/lldbsuite/test/lang/cpp/type_lookup/TestTypeLookup.py [deleted file]
lldb/packages/Python/lldbsuite/test/lang/cpp/type_lookup/main.cpp

index cd9ca5c86d84cb0a49855184f87872de00799bb3..99bfa7e03b479d88aa0a51a450b8462612e82b0a 100644 (file)
@@ -1,3 +1,3 @@
 LEVEL = ../../../make
-C_SOURCES := main.c
+CXX_SOURCES := main.cpp
 include $(LEVEL)/Makefile.rules
diff --git a/lldb/packages/Python/lldbsuite/test/lang/cpp/type_lookup/TestCppTypeLookup.py b/lldb/packages/Python/lldbsuite/test/lang/cpp/type_lookup/TestCppTypeLookup.py
new file mode 100644 (file)
index 0000000..8fb003b
--- /dev/null
@@ -0,0 +1,89 @@
+"""
+Test that we can lookup types correctly in the expression parser
+"""
+
+from __future__ import print_function
+
+
+import lldb
+import lldbsuite.test.lldbutil as lldbutil
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import decorators
+
+class TestCppTypeLookup(TestBase):
+
+    mydir = TestBase.compute_mydir(__file__)
+
+    def check_value(self, value, ivar_name, ivar_value):
+        self.assertTrue(value.GetError().Success(),
+                        "Invalid valobj: %s" % (
+                                value.GetError().GetCString()))
+        ivar = value.GetChildMemberWithName(ivar_name)
+        self.assertTrue(ivar.GetError().Success(),
+                        "Failed to fetch ivar named '%s'" % (ivar_name))
+        self.assertEqual(ivar_value,
+                         ivar.GetValueAsSigned(),
+                         "Got the right value for ivar")
+
+    def test_namespace_only(self):
+        """
+            Test that we fail to lookup a struct type that exists only in a
+            namespace.
+        """
+        self.build()
+        self.main_source_file = lldb.SBFileSpec("main.cpp")
+        (target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(
+            self, "Set a breakpoint here", self.main_source_file)
+
+        # Get frame for current thread
+        frame = thread.GetSelectedFrame()
+
+        # Make sure we don't accidentally accept structures that exist only
+        # in namespaces when evaluating expressions with top level types.
+        # Prior to the revision that added this test, we would accidentally
+        # accept types from namespaces, so this will ensure we don't regress
+        # to that behavior again
+        expr_result = frame.EvaluateExpression("*((namespace_only *)&i)")
+        self.assertTrue(expr_result.GetError().Fail(),
+                        "'namespace_only' exists in namespace only")
+
+        # Make sure we can find the correct type in a namespace "a"
+        expr_result = frame.EvaluateExpression("*((a::namespace_only *)&i)")
+        self.check_value(expr_result, "a", 123)
+        # Make sure we can find the correct type in a namespace "b"
+        expr_result = frame.EvaluateExpression("*((b::namespace_only *)&i)")
+        self.check_value(expr_result, "b", 123)
+
+        # Make sure we can find the correct type in the root namespace
+        expr_result = frame.EvaluateExpression("*((namespace_and_file *)&i)")
+        self.check_value(expr_result, "ff", 123)
+        # Make sure we can find the correct type in a namespace "a"
+        expr_result = frame.EvaluateExpression(
+                "*((a::namespace_and_file *)&i)")
+        self.check_value(expr_result, "aa", 123)
+        # Make sure we can find the correct type in a namespace "b"
+        expr_result = frame.EvaluateExpression(
+                "*((b::namespace_and_file *)&i)")
+        self.check_value(expr_result, "bb", 123)
+
+        # Make sure we don't accidentally accept structures that exist only
+        # in namespaces when evaluating expressions with top level types.
+        # Prior to the revision that added this test, we would accidentally
+        # accept types from namespaces, so this will ensure we don't regress
+        # to that behavior again
+        expr_result = frame.EvaluateExpression("*((in_contains_type *)&i)")
+        self.assertTrue(expr_result.GetError().Fail(),
+                        "'in_contains_type' exists in struct only")
+
+        # Make sure we can find the correct type in the root namespace
+        expr_result = frame.EvaluateExpression(
+                "*((contains_type::in_contains_type *)&i)")
+        self.check_value(expr_result, "fff", 123)
+        # Make sure we can find the correct type in a namespace "a"
+        expr_result = frame.EvaluateExpression(
+                "*((a::contains_type::in_contains_type *)&i)")
+        self.check_value(expr_result, "aaa", 123)
+        # Make sure we can find the correct type in a namespace "b"
+        expr_result = frame.EvaluateExpression(
+                "*((b::contains_type::in_contains_type *)&i)")
+        self.check_value(expr_result, "bbb", 123)
diff --git a/lldb/packages/Python/lldbsuite/test/lang/cpp/type_lookup/TestTypeLookup.py b/lldb/packages/Python/lldbsuite/test/lang/cpp/type_lookup/TestTypeLookup.py
deleted file mode 100644 (file)
index 490c03b..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
-"""
-Test that we can lookup types correctly in the expression parser
-"""
-
-from __future__ import print_function
-
-
-import lldb
-import lldbsuite.test.lldbutil as lldbutil
-from lldbsuite.test.lldbtest import *
-from lldbsuite.test import decorators
-
-class TestTypeLookup(TestBase):
-
-    mydir = TestBase.compute_mydir(__file__)
-
-    def check_value(self, value, ivar_name, ivar_value):
-        self.assertTrue(value.GetError().Success(),
-                        "Invalid valobj: %s" % (
-                                value.GetError().GetCString()))
-        ivar = value.GetChildMemberWithName(ivar_name)
-        self.assertTrue(ivar.GetError().Success(),
-                        "Failed to fetch ivar named '%s'" % (ivar_name))
-        self.assertEqual(ivar_value,
-                         ivar.GetValueAsSigned(),
-                         "Got the right value for ivar")
-
-    def test_namespace_only(self):
-        """
-            Test that we fail to lookup a struct type that exists only in a
-            namespace.
-        """
-        self.build()
-        self.main_source_file = lldb.SBFileSpec("main.cpp")
-        (target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(
-            self, "Set a breakpoint here", self.main_source_file)
-
-        # Get frame for current thread
-        frame = thread.GetSelectedFrame()
-
-        # Make sure we don't accidentally accept structures that exist only
-        # in namespaces when evaluating expressions with top level types.
-        # Prior to the revision that added this test, we would accidentally
-        # accept types from namespaces, so this will ensure we don't regress
-        # to that behavior again
-        expr_result = frame.EvaluateExpression("*((namespace_only *)&i)")
-        self.assertTrue(expr_result.GetError().Fail(),
-                        "'namespace_only' exists in namespace only")
-
-        # Make sure we can find the correct type in a namespace "a"
-        expr_result = frame.EvaluateExpression("*((a::namespace_only *)&i)")
-        self.check_value(expr_result, "a", 123)
-        # Make sure we can find the correct type in a namespace "b"
-        expr_result = frame.EvaluateExpression("*((b::namespace_only *)&i)")
-        self.check_value(expr_result, "b", 123)
-
-        # Make sure we can find the correct type in the root namespace
-        expr_result = frame.EvaluateExpression("*((namespace_and_file *)&i)")
-        self.check_value(expr_result, "ff", 123)
-        # Make sure we can find the correct type in a namespace "a"
-        expr_result = frame.EvaluateExpression(
-                "*((a::namespace_and_file *)&i)")
-        self.check_value(expr_result, "aa", 123)
-        # Make sure we can find the correct type in a namespace "b"
-        expr_result = frame.EvaluateExpression(
-                "*((b::namespace_and_file *)&i)")
-        self.check_value(expr_result, "bb", 123)
-
-        # Make sure we don't accidentally accept structures that exist only
-        # in namespaces when evaluating expressions with top level types.
-        # Prior to the revision that added this test, we would accidentally
-        # accept types from namespaces, so this will ensure we don't regress
-        # to that behavior again
-        expr_result = frame.EvaluateExpression("*((in_contains_type *)&i)")
-        self.assertTrue(expr_result.GetError().Fail(),
-                        "'in_contains_type' exists in struct only")
-
-        # Make sure we can find the correct type in the root namespace
-        expr_result = frame.EvaluateExpression(
-                "*((contains_type::in_contains_type *)&i)")
-        self.check_value(expr_result, "fff", 123)
-        # Make sure we can find the correct type in a namespace "a"
-        expr_result = frame.EvaluateExpression(
-                "*((a::contains_type::in_contains_type *)&i)")
-        self.check_value(expr_result, "aaa", 123)
-        # Make sure we can find the correct type in a namespace "b"
-        expr_result = frame.EvaluateExpression(
-                "*((b::contains_type::in_contains_type *)&i)")
-        self.check_value(expr_result, "bbb", 123)
index db8d412881eb8fc4b41fa1d840a4a4727cdcb00e..b244e80962c8f097e5a5e0f76065f74533e7dbc5 100644 (file)
@@ -1,4 +1,4 @@
-//===-- main.c --------------------------------------------------*- C++ -*-===//
+//===-- main.cpp ------------------------------------------------*- C++ -*-===//
 //
 //                     The LLVM Compiler Infrastructure
 //