diff options
author | Pavel Labath <labath@google.com> | 2017-11-02 22:13:09 +0000 |
---|---|---|
committer | Pavel Labath <labath@google.com> | 2017-11-02 22:13:09 +0000 |
commit | 64b6e5af136231c23ef2613af11e23e44bc6c158 (patch) | |
tree | e52c157225f5e40c0a066d1f867d81698c2b3096 /lldb/packages/Python/lldbsuite/test | |
parent | 03304427a97715dbda2069a111e482b71b3dd7d1 (diff) | |
download | bcm5719-llvm-64b6e5af136231c23ef2613af11e23e44bc6c158.tar.gz bcm5719-llvm-64b6e5af136231c23ef2613af11e23e44bc6c158.zip |
Remove getCategories mechanism of specifying test categories
Summary:
This mechanism was mostly redundant with the file-based .categories
mechanism, and it was interfering with it, as any test which implemented
a getCategories method would not inherit the filesystem categories.
This patch removes it. The existing categories are preserved either by
adding a .categories file, or using the @add_test_categories decorator.
Reviewers: jingham, clayborg, zturner
Subscribers: lldb-commits
Differential Revision: https://reviews.llvm.org/D39515
llvm-svn: 317277
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test')
16 files changed, 36 insertions, 57 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/example/TestSequenceFunctions.py b/lldb/packages/Python/lldbsuite/test/example/TestSequenceFunctions.py index 8c5fedf58ab..eb3b0bbf885 100644 --- a/lldb/packages/Python/lldbsuite/test/example/TestSequenceFunctions.py +++ b/lldb/packages/Python/lldbsuite/test/example/TestSequenceFunctions.py @@ -30,8 +30,5 @@ class SequenceFunctionsTestCase(unittest.TestCase): for element in random.sample(self.seq, 5): self.assertTrue(element in self.seq) - def getCategories(self): - return [] - if __name__ == '__main__': unittest.main() diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/expr-doesnt-deadlock/TestExprDoesntBlock.py b/lldb/packages/Python/lldbsuite/test/functionalities/expr-doesnt-deadlock/TestExprDoesntBlock.py index 21d4357a6ff..719f3f71993 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/expr-doesnt-deadlock/TestExprDoesntBlock.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/expr-doesnt-deadlock/TestExprDoesntBlock.py @@ -16,15 +16,13 @@ from lldbsuite.test import lldbutil class ExprDoesntDeadlockTestCase(TestBase): - def getCategories(self): - return ['basic_process'] - mydir = TestBase.compute_mydir(__file__) @expectedFailureAll(oslist=['freebsd'], bugnumber='llvm.org/pr17946') @expectedFailureAll( oslist=["windows"], bugnumber="Windows doesn't have pthreads, test needs to be ported") + @add_test_categories(["basic_process"]) def test_with_run_command(self): """Test that expr will time out and allow other threads to run if it blocks.""" self.build() diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/load_unload/.categories b/lldb/packages/Python/lldbsuite/test/functionalities/load_unload/.categories new file mode 100644 index 00000000000..c00c25822e4 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/functionalities/load_unload/.categories @@ -0,0 +1 @@ +basic_process diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/load_unload/TestLoadUnload.py b/lldb/packages/Python/lldbsuite/test/functionalities/load_unload/TestLoadUnload.py index 8e548e11658..98b0c9ca197 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/load_unload/TestLoadUnload.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/load_unload/TestLoadUnload.py @@ -17,9 +17,6 @@ from lldbsuite.test import lldbutil @skipIfWindows # Windows doesn't have dlopen and friends, dynamic libraries work differently class LoadUnloadTestCase(TestBase): - def getCategories(self): - return ['basic_process'] - mydir = TestBase.compute_mydir(__file__) def setUp(self): diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/thread/step_until/.categories b/lldb/packages/Python/lldbsuite/test/functionalities/thread/step_until/.categories new file mode 100644 index 00000000000..c00c25822e4 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/functionalities/thread/step_until/.categories @@ -0,0 +1 @@ +basic_process diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/thread/step_until/TestStepUntil.py b/lldb/packages/Python/lldbsuite/test/functionalities/thread/step_until/TestStepUntil.py index ec34c9985d3..d63d5c55bc8 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/thread/step_until/TestStepUntil.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/thread/step_until/TestStepUntil.py @@ -15,9 +15,6 @@ class TestCStepping(TestBase): mydir = TestBase.compute_mydir(__file__) - def getCategories(self): - return ['basic_process'] - def setUp(self): # Call super's setUp(). TestBase.setUp(self) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/hello_watchpoint/TestMyFirstWatchpoint.py b/lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/hello_watchpoint/TestMyFirstWatchpoint.py index 36fc113aa3d..2cfba398bac 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/hello_watchpoint/TestMyFirstWatchpoint.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/hello_watchpoint/TestMyFirstWatchpoint.py @@ -15,9 +15,6 @@ from lldbsuite.test import lldbutil class HelloWatchpointTestCase(TestBase): - def getCategories(self): - return ['basic_process'] - mydir = TestBase.compute_mydir(__file__) def setUp(self): @@ -37,6 +34,7 @@ class HelloWatchpointTestCase(TestBase): @expectedFailureAll( oslist=["windows"], bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows") + @add_test_categories(["basic_process"]) def test_hello_watchpoint_using_watchpoint_set(self): """Test a simple sequence of watchpoint creation and watchpoint hit.""" self.build(dictionary=self.d) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/step_over_watchpoint/TestStepOverWatchpoint.py b/lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/step_over_watchpoint/TestStepOverWatchpoint.py index d99bbb85ebc..71686a5f5c4 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/step_over_watchpoint/TestStepOverWatchpoint.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/step_over_watchpoint/TestStepOverWatchpoint.py @@ -13,9 +13,6 @@ class TestStepOverWatchpoint(TestBase): mydir = TestBase.compute_mydir(__file__) - def getCategories(self): - return ['basic_process'] - @expectedFailureAll( oslist=["linux"], archs=[ @@ -28,6 +25,7 @@ class TestStepOverWatchpoint(TestBase): # Read-write watchpoints not supported on SystemZ @expectedFailureAll(archs=['s390x']) @expectedFailureAll(oslist=["ios", "watchos", "tvos", "bridgeos"], bugnumber="<rdar://problem/34027183>") # watchpoint tests aren't working on arm64 + @add_test_categories(["basic_process"]) def test(self): """Test stepping over watchpoints.""" self.build() diff --git a/lldb/packages/Python/lldbsuite/test/lang/c/step-target/.categories b/lldb/packages/Python/lldbsuite/test/lang/c/step-target/.categories new file mode 100644 index 00000000000..c00c25822e4 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/lang/c/step-target/.categories @@ -0,0 +1 @@ +basic_process diff --git a/lldb/packages/Python/lldbsuite/test/lang/c/step-target/TestStepTarget.py b/lldb/packages/Python/lldbsuite/test/lang/c/step-target/TestStepTarget.py index b1aa98c50ba..90f07860afa 100644 --- a/lldb/packages/Python/lldbsuite/test/lang/c/step-target/TestStepTarget.py +++ b/lldb/packages/Python/lldbsuite/test/lang/c/step-target/TestStepTarget.py @@ -14,9 +14,6 @@ class TestStepTarget(TestBase): mydir = TestBase.compute_mydir(__file__) - def getCategories(self): - return ['basic_process'] - def setUp(self): # Call super's setUp(). TestBase.setUp(self) diff --git a/lldb/packages/Python/lldbsuite/test/lang/c/stepping/TestStepAndBreakpoints.py b/lldb/packages/Python/lldbsuite/test/lang/c/stepping/TestStepAndBreakpoints.py index d693e1dada5..e1916a550a1 100644 --- a/lldb/packages/Python/lldbsuite/test/lang/c/stepping/TestStepAndBreakpoints.py +++ b/lldb/packages/Python/lldbsuite/test/lang/c/stepping/TestStepAndBreakpoints.py @@ -15,16 +15,13 @@ class TestCStepping(TestBase): mydir = TestBase.compute_mydir(__file__) - def getCategories(self): - return ['basic_process'] - def setUp(self): # Call super's setUp(). TestBase.setUp(self) # Find the line numbers that we will step to in main: self.main_source = "main.c" - @add_test_categories(['pyapi']) + @add_test_categories(['pyapi', 'basic_process']) @expectedFailureAll(oslist=['freebsd'], bugnumber='llvm.org/pr17932') @expectedFailureAll(oslist=["linux"], bugnumber="llvm.org/pr14437") @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24777") diff --git a/lldb/packages/Python/lldbsuite/test/lang/objc/objc-stepping/TestObjCStepping.py b/lldb/packages/Python/lldbsuite/test/lang/objc/objc-stepping/TestObjCStepping.py index 5c403f301ec..95eb6e5a212 100644 --- a/lldb/packages/Python/lldbsuite/test/lang/objc/objc-stepping/TestObjCStepping.py +++ b/lldb/packages/Python/lldbsuite/test/lang/objc/objc-stepping/TestObjCStepping.py @@ -13,9 +13,6 @@ from lldbsuite.test import lldbutil class TestObjCStepping(TestBase): - def getCategories(self): - return ['basic_process'] - mydir = TestBase.compute_mydir(__file__) def setUp(self): @@ -35,7 +32,7 @@ class TestObjCStepping(TestBase): self.main_source, '// Step over nil should stop here.') @skipUnlessDarwin - @add_test_categories(['pyapi']) + @add_test_categories(['pyapi', 'basic_process']) def test_with_python_api(self): """Test stepping through ObjC method dispatch in various forms.""" self.build() diff --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py b/lldb/packages/Python/lldbsuite/test/lldbtest.py index 9f28cc0d39c..ecc38f35543 100644 --- a/lldb/packages/Python/lldbsuite/test/lldbtest.py +++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py @@ -1834,30 +1834,6 @@ class TestBase(Base): # Can be overridden by the LLDB_TIME_WAIT_NEXT_LAUNCH environment variable. timeWaitNextLaunch = 1.0 - # Returns the list of categories to which this test case belongs - # by default, look for a ".categories" file, and read its contents - # if no such file exists, traverse the hierarchy - we guarantee - # a .categories to exist at the top level directory so we do not end up - # looping endlessly - subclasses are free to define their own categories - # in whatever way makes sense to them - def getCategories(self): - import inspect - import os.path - folder = inspect.getfile(self.__class__) - folder = os.path.dirname(folder) - while folder != '/': - categories_file_name = os.path.join(folder, ".categories") - if os.path.exists(categories_file_name): - categories_file = open(categories_file_name, 'r') - categories = categories_file.readline() - categories_file.close() - categories = str.replace(categories, '\n', '') - categories = str.replace(categories, '\r', '') - return categories.split(',') - else: - folder = os.path.dirname(folder) - continue - def generateSource(self, source): template = source + '.template' temp = os.path.join(os.getcwd(), template) diff --git a/lldb/packages/Python/lldbsuite/test/test_result.py b/lldb/packages/Python/lldbsuite/test/test_result.py index 7bfe9708386..3f5e556040b 100644 --- a/lldb/packages/Python/lldbsuite/test/test_result.py +++ b/lldb/packages/Python/lldbsuite/test/test_result.py @@ -105,6 +105,32 @@ class LLDBTestResult(unittest2.TextTestResult): else: return str(test) + @staticmethod + def _getFileBasedCategories(test): + """ + Returns the list of categories to which this test case belongs by + looking for a ".categories" file. We start at the folder the test is in + an traverse the hierarchy upwards - we guarantee a .categories to exist + at the top level directory so we do not end up looping endlessly. + """ + import inspect + import os.path + folder = inspect.getfile(test.__class__) + folder = os.path.dirname(folder) + while folder != '/': + categories_file_name = os.path.join(folder, ".categories") + if os.path.exists(categories_file_name): + categories_file = open(categories_file_name, 'r') + categories = categories_file.readline() + categories_file.close() + categories = str.replace(categories, '\n', '') + categories = str.replace(categories, '\r', '') + return categories.split(',') + else: + folder = os.path.dirname(folder) + continue + + def getCategoriesForTest(self, test): """ Gets all the categories for the currently running test method in test case @@ -114,7 +140,7 @@ class LLDBTestResult(unittest2.TextTestResult): if test_method is not None and hasattr(test_method, "categories"): test_categories.extend(test_method.categories) - test_categories.extend(test.getCategories()) + test_categories.extend(self._getFileBasedCategories(test)) return test_categories diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-mi/.categories b/lldb/packages/Python/lldbsuite/test/tools/lldb-mi/.categories new file mode 100644 index 00000000000..8b5f00ce15a --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-mi/.categories @@ -0,0 +1 @@ +lldb-mi diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-mi/lldbmi_testcase.py b/lldb/packages/Python/lldbsuite/test/tools/lldb-mi/lldbmi_testcase.py index a862609d697..2226395dcf2 100644 --- a/lldb/packages/Python/lldbsuite/test/tools/lldb-mi/lldbmi_testcase.py +++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-mi/lldbmi_testcase.py @@ -14,9 +14,6 @@ class MiTestCaseBase(Base): myexe = "a.out" mylog = "child.log" - def getCategories(self): - return ['lldb-mi'] - @classmethod def classCleanup(cls): TestBase.RemoveTempFile(cls.myexe) |