summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2018-05-08 10:25:20 -0700
committerDylan Baker <dylan@pnwbakers.com>2018-05-09 09:52:26 -0700
commit597e48441883ad0d1cd8b09ab53e77bf7d7243b2 (patch)
tree0cdc4c0f7def5508fa7bd591166e65099fbaccde
parent1e60f1499e5b71b6d5a747189d7c28f57359a87f (diff)
framework: fix running with mixed concurrency (neither -c or -1)
test_list is an iterator, you can't walk an iterator more than once. To solve this we use itertools.tee, which creates a shared buffer for the iterators to draw from. This fixes errors like: [000/480] Traceback (most recent call last): File "./piglit", line 178, in <module> main() File "./piglit", line 174, in main sys.exit(runner(args)) File "/home/user/piglit/framework/exceptions.py", line 51, in _inner func(*args, **kwargs) File "/home/user/piglit/framework/programs/run.py", line 370, in run backend.finalize({'time_elapsed': time_elapsed.to_json()}) File "/home/user/piglit/framework/backends/json.py", line 163, in finalize assert data['tests'] AssertionError Thanks Tomi for figuring out what was wrong with the original patch! CC: Tomi Sarvela <tomi.p.sarvela@intel.com> Tested-by: Michel Dänzer <michel.daenzer@amd.com> Reviewed-by: Juan A. Suarez <jasuarez@igalia.com>
-rw-r--r--framework/profile.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/framework/profile.py b/framework/profile.py
index 1c75025b3..5161f6e4c 100644
--- a/framework/profile.py
+++ b/framework/profile.py
@@ -596,13 +596,16 @@ def run(profiles, logger, backend, concurrency):
run_threads(single, profile, test_list)
else:
assert concurrency == "some"
+ # test_list is an iterator, we need to copy it to run it twice.
+ test_list = itertools.tee(test_list, 2)
+
# Filter and return only thread safe tests to the threaded pool
- run_threads(multi, profile, test_list,
+ run_threads(multi, profile, test_list[0],
lambda x: x[1].run_concurrent)
# Filter and return the non thread safe tests to the single
# pool
- run_threads(single, profile, test_list,
+ run_threads(single, profile, test_list[1],
lambda x: not x[1].run_concurrent)
profile.teardown()