This removes the tests attribute from TestProfile, which has been deprecated for some time. The problem with tests is that it uses a nested tree structure, which has to be flattened before tests can be run. This creates a significant amount of overhead.
Signed-off-by: Dylan Baker <[email protected]> --- framework/profile.py | 53 +--------------------- framework/tests/profile_tests.py | 98 ---------------------------------------- 2 files changed, 2 insertions(+), 149 deletions(-) diff --git a/framework/profile.py b/framework/profile.py index 6c3aa41..3a30e99 100644 --- a/framework/profile.py +++ b/framework/profile.py @@ -70,9 +70,8 @@ class TestDict(dict): # pylint: disable=too-few-public-methods "Keys must be strings, but was {}".format(type(key)) # None is required to make empty assignment work: # foo = Tree['a'] - assert isinstance(value, (Tree, Test, types.NoneType)), \ - "Values must be either a Tree or a Test, but was {}".format( - type(value)) + assert isinstance(value, (Test, types.NoneType)), \ + "Values must be either a Test, but was {}".format(type(value)) super(TestDict, self).__setitem__(key.lower(), value) @@ -81,21 +80,6 @@ class TestDict(dict): # pylint: disable=too-few-public-methods return super(TestDict, self).__getitem__(key.lower()) -class Tree(TestDict): # pylint: disable=too-few-public-methods - """A tree-like object built with python dictionaries. - - When a node that doesn't exist is requested it is automatically created - with a new Tree node. - - This also enforces lowering of keys, both for getting and setting. - - """ - def __missing__(self, key): - """Automatically create new Tree nodes.""" - self[key] = Tree() - return self[key] - - class TestProfile(object): """ Class that holds a list of tests for execution @@ -115,8 +99,6 @@ class TestProfile(object): """ def __init__(self): - # Self.tests is deprecated, see above - self.tests = Tree() self.test_list = TestDict() self.filters = [] # Sets a default of a Dummy @@ -140,34 +122,6 @@ class TestProfile(object): """ self._dmesg = get_dmesg(not_dummy) - def _flatten_group_hierarchy(self): - """ Flatten nested dictionary structure - - Convert Piglit's old hierarchical Group() structure into a flat - dictionary mapping from fully qualified test names to "Test" objects. - - For example, - self.tests['spec']['glsl-1.30']['preprocessor']['compiler']['void.frag'] - would become: - self.test_list['spec/glsl-1.30/preprocessor/compiler/void.frag'] - - """ - - def f(prefix, group, test_dict): - """ Recursively flatter nested dictionary tree """ - for key, value in group.iteritems(): - fullkey = grouptools.join(prefix, key) - if isinstance(value, Tree): - f(fullkey, value, test_dict) - else: - test_dict[fullkey] = value - f('', self.tests, self.test_list) - - # Empty the nested structure. Do not use clear(), since it will - # actually remove all of the objects in the Tree, which will also - # remove them from self.test_list - self.tests = Tree() - def _prepare_test_list(self, opts): """ Prepare tests for running @@ -179,8 +133,6 @@ class TestProfile(object): opts - a core.Options instance """ - self._flatten_group_hierarchy() - def matches_any_regexp(x, re_list): return any(r.search(x) for r in re_list) @@ -316,7 +268,6 @@ class TestProfile(object): """ for profile in profiles: - self.tests.update(profile.tests) self.test_list.update(profile.test_list) @contextlib.contextmanager diff --git a/framework/tests/profile_tests.py b/framework/tests/profile_tests.py index 9723c8c..8f9dba0 100644 --- a/framework/tests/profile_tests.py +++ b/framework/tests/profile_tests.py @@ -82,54 +82,6 @@ def test_testprofile_set_dmesg_false(): assert isinstance(profile_.dmesg, dmesg.DummyDmesg) -def test_testprofile_flatten(): - """ TestProfile.flatten_group_hierarchy flattens and empties self.tests """ - test1 = utils.Test(['thing']) - test2 = utils.Test(['thing']) - test3 = utils.Test(['thing']) - - profile_ = profile.TestProfile() - profile_.tests['group1']['test1'] = test1 - profile_.tests['group1']['group2']['test2'] = test2 - profile_.tests['group1']['group2']['group3']['test3'] = test3 - - profile_._flatten_group_hierarchy() - - baseline = profile.Tree({ - 'group1/test1': test1, - 'group1/group2/test2': test2, - 'group1/group2/group3/test3': test3, - }) - - # Do not flatten until after baseline, since we want to use the same - # isntances and tests should be emptied by flattening - profile_._flatten_group_hierarchy() - - # profile_.tests should have been emptied - nt.assert_dict_equal(profile_.tests, {}) - - nt.assert_dict_equal(profile_.test_list, baseline) - - -def test_testprofile_update_tests(): - """ TestProfile.update() updates TestProfile.tests - - TestProfile.tests is deprecated, and this test should be removed eventually - - """ - profile1 = profile.TestProfile() - profile1.tests['group1']['test1'] = utils.Test(['test1']) - - profile2 = profile.TestProfile() - baseline = profile2.tests - baseline['group2']['test2'] = utils.Test(['test2']) - baseline['group1']['test1'] = utils.Test(['test3']) - - profile1.update(profile2) - - nt.assert_dict_equal(profile1.tests, baseline) - - def test_testprofile_update_test_list(): """ TestProfile.update() updates TestProfile.test_list """ profile1 = profile.TestProfile() @@ -145,56 +97,6 @@ def test_testprofile_update_test_list(): nt.assert_dict_equal(profile1.test_list, profile2.test_list) -def generate_prepare_test_list_flatten(): - """ Generate tests for TestProfile.prepare_test_list() """ - test1 = utils.Test(['thingy']) - test2 = utils.Test(['thingy']) - test3 = utils.Test(['thingy']) - - tests = profile.Tree() - tests['group1']['test1'] = test1 - tests['group1']['group3']['test2'] = test2 - tests['group3']['test5'] = test3 - - test_list = { - 'group1/test1': test1, - 'group1/group3/test2': test2, - 'group3/test5': test3, - } - - check_flatten.description = \ - "TestProfile.prepare_test_list flattens TestProfile.tests" - yield check_flatten, tests, test_list - - check_mixed_flatten.description = \ - "TestProfile flattening is correct when tess and test_list are set" - yield check_mixed_flatten, tests, test_list - - [email protected] -def check_flatten(tests, testlist): - """ TestProfile.prepare_test_list flattens TestProfile.tests """ - profile_ = profile.TestProfile() - profile_.tests = tests - profile_._flatten_group_hierarchy() - - nt.assert_dict_equal(profile_.test_list, testlist) - - [email protected] -def check_mixed_flatten(tests, testlist): - """ flattening is correct when tests and test_list are defined """ - profile_ = profile.TestProfile() - profile_.tests = tests - profile_.test_list['test8'] = utils.Test(['other']) - profile_._flatten_group_hierarchy() - - baseline = {'test8': profile_.test_list['test8']} - baseline.update(testlist) - - nt.assert_dict_equal(profile_.test_list, baseline) - - def generate_prepare_test_list_test_test_matches(): """ Generate tests for TestProfile.perpare_test_list filtering """ data = {'group1/test1': 'thingy', 'group1/group3/test2': 'thing', -- 2.2.2 _______________________________________________ Piglit mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/piglit
