[Piglit] [PATCH 02/12] Add support to load multiple test profiles

Dylan Baker baker.dylan.c at gmail.com
Mon Dec 23 16:51:39 PST 2013


This patch gives piglit run the ability to take one or more test
proflies as arguments rather than just one. It loads the profiles,
merging them from left to right, overwriting conflicting results. This
will allow the oglconform and es3conform loaders to be taken out of
all.tests.

Signed-off-by: Dylan Baker <baker.dylan.c at gmail.com>
---
 framework/core.py | 32 ++++++++++++++++++++++++++++++++
 piglit-resume.py  |  4 ++--
 piglit-run.py     |  5 +++--
 3 files changed, 37 insertions(+), 4 deletions(-)

diff --git a/framework/core.py b/framework/core.py
index c8dc4bc..28a1ded 100644
--- a/framework/core.py
+++ b/framework/core.py
@@ -605,6 +605,22 @@ class TestProfile:
             group = group[group_name]
         del group[l[-1]]
 
+    def update(self, *profiles):
+        """ Updates the contents of this TestProfile instance with another
+
+        This method overwrites key:value pairs in self with those in the
+        provided profiles argument. This allows multiple TestProfiles to be
+        called in the same run; which could be used to run piglit and external
+        suites at the same time.
+
+        Arguments:
+        profiles -- one or more TestProfile-like objects to be merged.
+
+        """
+        for profile in profiles:
+            self.tests.update(profile.tests)
+            self.test_list.update(profile.test_list)
+
 
 def loadTestProfile(filename):
     ns = {'__file__': filename}
@@ -616,6 +632,22 @@ def loadTestProfile(filename):
     return ns['profile']
 
 
+def merge_test_profiles(profiles):
+    """ Helper for loading and merging TestProfile instances
+
+    Takes paths to test profiles as arguments and returns a single merged
+    TestPRofile instance.
+
+    Arguments:
+    profiles -- a list of one or more paths to profile files.
+
+    """
+    profile = loadTestProfile(profiles.pop())
+    for p in profiles:
+        profile.update(loadTestProfile(p))
+    return profile
+
+
 def load_results(filename):
     """ Loader function for TestrunResult class
     
diff --git a/piglit-resume.py b/piglit-resume.py
index ae5de9b..df65ab6 100755
--- a/piglit-resume.py
+++ b/piglit-resume.py
@@ -68,7 +68,7 @@ def main():
         env.exclude_tests.add(key)
     json_writer.close_dict()
     
-    profile = core.loadTestProfile(results.options['profile'])
+    profile = core.merge_test_profiles(results.options['profile'])
     # This is resumed, don't bother with time since it wont be accurate anyway
     profile.run(env, json_writer)
     
@@ -81,4 +81,4 @@ def main():
           "Results have ben wrriten to {0}".format(results_path))
     
 if __name__ == "__main__":
-    main()
\ No newline at end of file
+    main()
diff --git a/piglit-run.py b/piglit-run.py
index c4bed93..3ea4217 100755
--- a/piglit-run.py
+++ b/piglit-run.py
@@ -80,7 +80,8 @@ def main():
                         help="Capture a difference in dmesg before and "
                              "after each test")
     parser.add_argument("test_profile",
-                        metavar="<Path to test profile>",
+                        metavar="<Path to one or more test profile(s)>",
+                        nargs='+',
                         help="Path to testfile to run")
     parser.add_argument("results_path",
                         type=path.realpath,
@@ -131,7 +132,7 @@ def main():
     for (key, value) in env.collectData().items():
         json_writer.write_dict_item(key, value)
 
-    profile = core.loadTestProfile(args.test_profile)
+    profile = core.merge_test_profiles(args.test_profile)
 
     json_writer.write_dict_key('tests')
     json_writer.open_dict()
-- 
1.8.5.2



More information about the Piglit mailing list