labath created this revision.
labath added reviewers: aprantl, jingham.
Herald added subscribers: JDevlieghere, eraman.
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.
https://reviews.llvm.org/D42836
Files:
packages/Python/lldbsuite/test/decorators.py
packages/Python/lldbsuite/test/functionalities/exec/TestExec.py
packages/Python/lldbsuite/test/lldbinline.py
packages/Python/lldbsuite/test/lldbtest.py
packages/Python/lldbsuite/test/logging/TestLogging.py
Index: packages/Python/lldbsuite/test/logging/TestLogging.py
===================================================================
--- packages/Python/lldbsuite/test/logging/TestLogging.py
+++ packages/Python/lldbsuite/test/logging/TestLogging.py
@@ -19,6 +19,7 @@
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 @@
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 @@
"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 @@
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)
Index: packages/Python/lldbsuite/test/lldbtest.py
===================================================================
--- packages/Python/lldbsuite/test/lldbtest.py
+++ packages/Python/lldbsuite/test/lldbtest.py
@@ -850,9 +850,6 @@
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
@@ -1520,7 +1517,7 @@
"""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 +1536,7 @@
"""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 +1555,7 @@
"""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 +1574,7 @@
"""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 +1593,7 @@
"""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 +1778,40 @@
@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:
@@ -2308,6 +2305,10 @@
print(str(method) + ":", result, file=sbuf)
return result
+ def getDebugInfo(self):
+ method = getattr(self, self.testMethodName)
+ return getattr(method, "debug_info", None)
+
def build(
self,
architecture=None,
@@ -2319,23 +2320,23 @@
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()
Index: packages/Python/lldbsuite/test/lldbinline.py
===================================================================
--- packages/Python/lldbsuite/test/lldbinline.py
+++ packages/Python/lldbsuite/test/lldbinline.py
@@ -139,34 +139,34 @@
@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())
Index: packages/Python/lldbsuite/test/functionalities/exec/TestExec.py
===================================================================
--- packages/Python/lldbsuite/test/functionalities/exec/TestExec.py
+++ packages/Python/lldbsuite/test/functionalities/exec/TestExec.py
@@ -52,7 +52,7 @@
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:
Index: packages/Python/lldbsuite/test/decorators.py
===================================================================
--- packages/Python/lldbsuite/test/decorators.py
+++ packages/Python/lldbsuite/test/decorators.py
@@ -170,7 +170,7 @@
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 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)
_______________________________________________
lldb-commits mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits