[Piglit] [PATCH] core: show progress percentage indicator

Ilia Mirkin imirkin at alum.mit.edu
Wed Jan 15 05:45:19 PST 2014


This will show X% instead of 'running' in the status, that way it's
easy to see how far along a particular run is.

Signed-off-by: Ilia Mirkin <imirkin at alum.mit.edu>
---

Written while waiting for a piglit run to complete...

 framework/core.py | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/framework/core.py b/framework/core.py
index 7231938..14b07fb 100644
--- a/framework/core.py
+++ b/framework/core.py
@@ -464,7 +464,7 @@ class Test:
     def run(self):
         raise NotImplementedError
 
-    def execute(self, env, path, json_writer):
+    def execute(self, env, run_msg, path, json_writer):
         '''
         Run the test.
 
@@ -478,7 +478,7 @@ class Test:
         # Run the test
         if env.execute:
             try:
-                status("running")
+                status(run_msg)
                 time_start = time.time()
                 result = self.run(env)
                 time_end = time.time()
@@ -508,7 +508,7 @@ class Test:
             else:
                 json_writer.write_dict_item(path, result)
         else:
-            status("dry-run")
+            status("dry-run %s" % run_msg)
 
 
 class Group(dict):
@@ -565,6 +565,9 @@ class TestProfile:
         '''
 
         self.prepare_test_list(env)
+        total = len(self.test_list)
+        count = [0]
+        lock = multiprocessing.dummy.Lock()
 
         def test(pair):
             """ Function to call test.execute from .map
@@ -573,7 +576,10 @@ class TestProfile:
 
             """
             name, test = pair
-            test.execute(env, name, json_writer)
+            with lock:
+                count[0] = count[0] + 1
+                pct = 100. * count[0] / total
+            test.execute(env, "%.0f%%" % pct, name, json_writer)
 
         # Multiprocessing.dummy is a wrapper around Threading that provides a
         # multiprocessing compatible API
-- 
1.8.3.2



More information about the Piglit mailing list