[Lldb-commits] [lldb] r324226 - [dotest] make debug info variant accessible in setUp()

Pavel Labath via lldb-commits lldb-commits at lists.llvm.org
Mon Feb 5 03:30:46 PST 2018


Author: labath
Date: Mon Feb  5 03:30:46 2018
New Revision: 324226

URL: http://llvm.org/viewvc/llvm-project?rev=324226&view=rev
Log:
[dotest] make debug info variant accessible in setUp()

Summary:
This changes the way we store the debug info variant to make it
available earlier in the test bringup: instead of it being set by the
test wrapper method, it is set as a *property* of the wrapper method.

This way, we can inspect it as soon as self.testMethodName is
initialized. The retrieval is implemented by a new function
TestBase.getDebugInfo(), and all that's necessary to make it work is to
change self.debug_info into self.getDebugInfo().

While searching for debug_info occurences i noticed that TestLogging is
being replicated for no good reason, so I removed the replication there.

Reviewers: aprantl, jingham

Subscribers: eraman, JDevlieghere, lldb-commits

Differential Revision: https://reviews.llvm.org/D42836

Modified:
    lldb/trunk/packages/Python/lldbsuite/test/decorators.py
    lldb/trunk/packages/Python/lldbsuite/test/functionalities/exec/TestExec.py
    lldb/trunk/packages/Python/lldbsuite/test/lldbinline.py
    lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py
    lldb/trunk/packages/Python/lldbsuite/test/logging/TestLogging.py

Modified: lldb/trunk/packages/Python/lldbsuite/test/decorators.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/decorators.py?rev=324226&r1=324225&r2=324226&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/decorators.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/decorators.py Mon Feb  5 03:30:46 2018
@@ -170,7 +170,7 @@ def _decorateTest(mode,
         skip_for_arch = _match_decorator_property(
             archs, self.getArchitecture())
         skip_for_debug_info = _match_decorator_property(
-            debug_info, self.debug_info)
+            debug_info, self.getDebugInfo())
         skip_for_triple = _match_decorator_property(
             triple, lldb.DBG.GetSelectedPlatform().GetTriple())
         skip_for_remote = _match_decorator_property(
@@ -430,13 +430,13 @@ def expectedFlakey(expected_fn, bugnumbe
 
 def expectedFlakeyDwarf(bugnumber=None):
     def fn(self):
-        return self.debug_info == "dwarf"
+        return self.getDebugInfo() == "dwarf"
     return expectedFlakey(fn, bugnumber)
 
 
 def expectedFlakeyDsym(bugnumber=None):
     def fn(self):
-        return self.debug_info == "dwarf"
+        return self.getDebugInfo() == "dwarf"
     return expectedFlakey(fn, bugnumber)
 
 

Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/exec/TestExec.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/exec/TestExec.py?rev=324226&r1=324225&r2=324226&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/exec/TestExec.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/exec/TestExec.py Mon Feb  5 03:30:46 2018
@@ -52,7 +52,7 @@ class ExecTestCase(TestBase):
             execute_command(
                 "'%s' -g -O0 -arch i386 -arch x86_64 '%s' -o '%s'" %
                 (os.environ["CC"], o_file, exe))
-            if self.debug_info != "dsym":
+            if self.getDebugInfo() != "dsym":
                 dsym_path = self.getBuildArtifact("a.out.dSYM")
                 execute_command("rm -rf '%s'" % (dsym_path))
         else:

Modified: lldb/trunk/packages/Python/lldbsuite/test/lldbinline.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lldbinline.py?rev=324226&r1=324225&r2=324226&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/lldbinline.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/lldbinline.py Mon Feb  5 03:30:46 2018
@@ -139,34 +139,34 @@ class InlineTest(TestBase):
     @add_test_categories(["dsym"])
     def __test_with_dsym(self):
         self.using_dsym = True
-        self.debug_info = "dsym"
         self.BuildMakefile()
         self.build()
         self.do_test()
+    __test_with_dsym.debug_info = "dsym"
 
     @add_test_categories(["dwarf"])
     def __test_with_dwarf(self):
         self.using_dsym = False
-        self.debug_info = "dwarf"
         self.BuildMakefile()
         self.build()
         self.do_test()
+    __test_with_dwarf.debug_info = "dwarf"
 
     @add_test_categories(["dwo"])
     def __test_with_dwo(self):
         self.using_dsym = False
-        self.debug_info = "dwo"
         self.BuildMakefile()
         self.build()
         self.do_test()
+    __test_with_dwo.debug_info = "dwo"
 
     @add_test_categories(["gmodules"])
     def __test_with_gmodules(self):
         self.using_dsym = False
-        self.debug_info = "gmodules"
         self.BuildMakefile()
         self.build()
         self.do_test()
+    __test_with_gmodules.debug_info = "gmodules"
 
     def execute_user_command(self, __command):
         exec(__command, globals(), locals())

Modified: lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py?rev=324226&r1=324225&r2=324226&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py Mon Feb  5 03:30:46 2018
@@ -850,9 +850,6 @@ class Base(unittest2.TestCase):
         self.setPlatformWorkingDir()
         self.enableLogChannelsForCurrentTest()
 
-        # Initialize debug_info
-        self.debug_info = None
-
         lib_dir = os.environ["LLDB_LIB_DIR"]
         self.dsym = None
         self.framework_dir = None
@@ -1404,6 +1401,10 @@ class Base(unittest2.TestCase):
             option_str += " -C " + comp
         return option_str
 
+    def getDebugInfo(self):
+        method = getattr(self, self.testMethodName)
+        return getattr(method, "debug_info", None)
+
     # ==================================================
     # Build methods supported through a plugin interface
     # ==================================================
@@ -1520,7 +1521,7 @@ class Base(unittest2.TestCase):
         """Platform specific way to build the default binaries."""
         if not testdir:
             testdir = self.mydir
-        if self.debug_info:
+        if self.getDebugInfo():
             raise Exception("buildDefault tests must set NO_DEBUG_INFO_TESTCASE")
         module = builder_module()
         self.makeBuildDir()
@@ -1539,7 +1540,7 @@ class Base(unittest2.TestCase):
         """Platform specific way to build binaries with dsym info."""
         if not testdir:
             testdir = self.mydir
-        if self.debug_info <> "dsym":
+        if self.getDebugInfo() != "dsym":
             raise Exception("NO_DEBUG_INFO_TESTCASE must build with buildDefault")
 
         module = builder_module()
@@ -1558,7 +1559,7 @@ class Base(unittest2.TestCase):
         """Platform specific way to build binaries with dwarf maps."""
         if not testdir:
             testdir = self.mydir
-        if self.debug_info <> "dwarf":
+        if self.getDebugInfo() != "dwarf":
             raise Exception("NO_DEBUG_INFO_TESTCASE must build with buildDefault")
 
         module = builder_module()
@@ -1577,7 +1578,7 @@ class Base(unittest2.TestCase):
         """Platform specific way to build binaries with dwarf maps."""
         if not testdir:
             testdir = self.mydir
-        if self.debug_info <> "dwo":
+        if self.getDebugInfo() != "dwo":
             raise Exception("NO_DEBUG_INFO_TESTCASE must build with buildDefault")
 
         module = builder_module()
@@ -1596,7 +1597,7 @@ class Base(unittest2.TestCase):
         """Platform specific way to build binaries with gmodules info."""
         if not testdir:
             testdir = self.mydir
-        if self.debug_info <> "gmodules":
+        if self.getDebugInfo() != "gmodules":
             raise Exception("NO_DEBUG_INFO_TESTCASE must build with buildDefault")
 
         module = builder_module()
@@ -1781,40 +1782,40 @@ class LLDBTestCaseFactory(type):
                     @decorators.add_test_categories(["dsym"])
                     @wraps(attrvalue)
                     def dsym_test_method(self, attrvalue=attrvalue):
-                        self.debug_info = "dsym"
                         return attrvalue(self)
                     dsym_method_name = attrname + "_dsym"
                     dsym_test_method.__name__ = dsym_method_name
+                    dsym_test_method.debug_info = "dsym"
                     newattrs[dsym_method_name] = dsym_test_method
 
                 if "dwarf" in supported_categories:
                     @decorators.add_test_categories(["dwarf"])
                     @wraps(attrvalue)
                     def dwarf_test_method(self, attrvalue=attrvalue):
-                        self.debug_info = "dwarf"
                         return attrvalue(self)
                     dwarf_method_name = attrname + "_dwarf"
                     dwarf_test_method.__name__ = dwarf_method_name
+                    dwarf_test_method.debug_info = "dwarf"
                     newattrs[dwarf_method_name] = dwarf_test_method
 
                 if "dwo" in supported_categories:
                     @decorators.add_test_categories(["dwo"])
                     @wraps(attrvalue)
                     def dwo_test_method(self, attrvalue=attrvalue):
-                        self.debug_info = "dwo"
                         return attrvalue(self)
                     dwo_method_name = attrname + "_dwo"
                     dwo_test_method.__name__ = dwo_method_name
+                    dwo_test_method.debug_info = "dwo"
                     newattrs[dwo_method_name] = dwo_test_method
 
                 if "gmodules" in supported_categories:
                     @decorators.add_test_categories(["gmodules"])
                     @wraps(attrvalue)
                     def gmodules_test_method(self, attrvalue=attrvalue):
-                        self.debug_info = "gmodules"
                         return attrvalue(self)
                     gmodules_method_name = attrname + "_gmodules"
                     gmodules_test_method.__name__ = gmodules_method_name
+                    gmodules_test_method.debug_info = "gmodules"
                     newattrs[gmodules_method_name] = gmodules_test_method
 
             else:
@@ -2319,23 +2320,23 @@ class TestBase(Base):
         self.makeBuildDir()
 
         dictionary = lldbplatformutil.finalize_build_dictionary(dictionary)
-        if self.debug_info is None:
+        if self.getDebugInfo() is None:
             return self.buildDefault(architecture, compiler, dictionary,
                                      clean, self.mydir)
-        elif self.debug_info == "dsym":
+        elif self.getDebugInfo() == "dsym":
             return self.buildDsym(architecture, compiler, dictionary,
                                   clean, self.mydir)
-        elif self.debug_info == "dwarf":
+        elif self.getDebugInfo() == "dwarf":
             return self.buildDwarf(architecture, compiler, dictionary,
                                    clean, self.mydir)
-        elif self.debug_info == "dwo":
+        elif self.getDebugInfo() == "dwo":
             return self.buildDwo(architecture, compiler, dictionary,
                                  clean, self.mydir)
-        elif self.debug_info == "gmodules":
+        elif self.getDebugInfo() == "gmodules":
             return self.buildGModules(architecture, compiler, dictionary,
                                       clean, self.mydir)
         else:
-            self.fail("Can't build for debug info: %s" % self.debug_info)
+            self.fail("Can't build for debug info: %s" % self.getDebugInfo())
 
     def run_platform_command(self, cmd):
         platform = self.dbg.GetSelectedPlatform()

Modified: lldb/trunk/packages/Python/lldbsuite/test/logging/TestLogging.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/logging/TestLogging.py?rev=324226&r1=324225&r2=324226&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/logging/TestLogging.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/logging/TestLogging.py Mon Feb  5 03:30:46 2018
@@ -19,6 +19,7 @@ class LogTestCase(TestBase):
     mydir = TestBase.compute_mydir(__file__)
     append_log_file = "lldb-commands-log-append.txt"
     truncate_log_file = "lldb-commands-log-truncate.txt"
+    NO_DEBUG_INFO_TESTCASE = True
 
     @classmethod
     def classCleanup(cls):
@@ -28,23 +29,11 @@ class LogTestCase(TestBase):
 
     def test(self):
         self.build()
-        if self.debug_info == "dsym":
-            self.command_log_tests("dsym")
-        else:
-            self.command_log_tests("dwarf")
-
-    def command_log_tests(self, type):
         exe = self.getBuildArtifact("a.out")
         self.expect("file " + exe,
                     patterns=["Current executable set to .*a.out"])
 
-        log_file = os.path.join(
-            self.getBuildDir(),
-            "lldb-commands-log-%s-%s-%s.txt" %
-            (type,
-             os.path.basename(
-                 self.getCompiler()),
-                self.getArchitecture()))
+        log_file = os.path.join(self.getBuildDir(), "lldb-commands-log.txt")
 
         if (os.path.exists(log_file)):
             os.remove(log_file)
@@ -75,7 +64,6 @@ class LogTestCase(TestBase):
             "Something was written to the log file.")
 
     # Check that lldb truncates its log files
-    @no_debug_info_test
     def test_log_truncate(self):
         if (os.path.exists(self.truncate_log_file)):
             os.remove(self.truncate_log_file)
@@ -99,7 +87,6 @@ class LogTestCase(TestBase):
         self.assertEquals(contents.find("bacon"), -1)
 
     # Check that lldb can append to a log file
-    @no_debug_info_test
     def test_log_append(self):
         if (os.path.exists(self.append_log_file)):
             os.remove(self.append_log_file)




More information about the lldb-commits mailing list