[llvm] r354912 - [lit] Allow setting parallelism groups to None
Julian Lettner via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 26 11:03:26 PST 2019
Author: yln
Date: Tue Feb 26 11:03:26 2019
New Revision: 354912
URL: http://llvm.org/viewvc/llvm-project?rev=354912&view=rev
Log:
[lit] Allow setting parallelism groups to None
Check that we do not crash if a parallelism group is explicitly set to
None. Permits usage of the following pattern.
[lit.common.cfg]
lit_config.parallelism_groups['my_group'] = None
if <condition>:
lit_config.parallelism_groups['my_group'] = 3
[project/lit.cfg]
config.parallelism_group = 'my_group'
Reviewers: rnk
Differential Revision: https://reviews.llvm.org/D58305
Added:
llvm/trunk/utils/lit/tests/Inputs/parallelism-groups/
llvm/trunk/utils/lit/tests/Inputs/parallelism-groups/lit.cfg
llvm/trunk/utils/lit/tests/Inputs/parallelism-groups/test1.txt
llvm/trunk/utils/lit/tests/Inputs/parallelism-groups/test2.txt
llvm/trunk/utils/lit/tests/parallelism-groups.py
Modified:
llvm/trunk/utils/lit/lit/TestingConfig.py
llvm/trunk/utils/lit/lit/run.py
Modified: llvm/trunk/utils/lit/lit/TestingConfig.py
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/lit/TestingConfig.py?rev=354912&r1=354911&r2=354912&view=diff
==============================================================================
--- llvm/trunk/utils/lit/lit/TestingConfig.py (original)
+++ llvm/trunk/utils/lit/lit/TestingConfig.py Tue Feb 26 11:03:26 2019
@@ -106,7 +106,7 @@ class TestingConfig:
environment, substitutions, unsupported,
test_exec_root, test_source_root, excludes,
available_features, pipefail, limit_to_features = [],
- is_early = False, parallelism_group = ""):
+ is_early = False, parallelism_group = None):
self.parent = parent
self.name = str(name)
self.suffixes = set(suffixes)
Modified: llvm/trunk/utils/lit/lit/run.py
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/lit/run.py?rev=354912&r1=354911&r2=354912&view=diff
==============================================================================
--- llvm/trunk/utils/lit/lit/run.py (original)
+++ llvm/trunk/utils/lit/lit/run.py Tue Feb 26 11:03:26 2019
@@ -17,6 +17,12 @@ class _Display(object):
if self.failedCount == self.maxFailures:
self.provider.cancel()
+# No-operation semaphore for supporting `None` for parallelism_groups.
+# lit_config.parallelism_groups['my_group'] = None
+class NopSemaphore(object):
+ def acquire(self): pass
+ def release(self): pass
+
class Run(object):
"""
This class represents a concrete, configured testing run.
@@ -26,11 +32,10 @@ class Run(object):
self.lit_config = lit_config
self.tests = tests
# Set up semaphores to limit parallelism of certain classes of tests.
- # For example, some ASan tests require lots of virtual memory and run
- # faster with less parallelism on OS X.
- self.parallelism_semaphores = \
- {k: multiprocessing.BoundedSemaphore(v) for k, v in
- self.lit_config.parallelism_groups.items()}
+ self.parallelism_semaphores = {
+ k : NopSemaphore() if v is None else
+ multiprocessing.BoundedSemaphore(v)
+ for k, v in lit_config.parallelism_groups.items()}
def execute_tests_in_pool(self, jobs, max_time):
# We need to issue many wait calls, so compute the final deadline and
Added: llvm/trunk/utils/lit/tests/Inputs/parallelism-groups/lit.cfg
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/tests/Inputs/parallelism-groups/lit.cfg?rev=354912&view=auto
==============================================================================
--- llvm/trunk/utils/lit/tests/Inputs/parallelism-groups/lit.cfg (added)
+++ llvm/trunk/utils/lit/tests/Inputs/parallelism-groups/lit.cfg Tue Feb 26 11:03:26 2019
@@ -0,0 +1,11 @@
+import lit.formats
+config.name = 'parallelism-groups'
+config.suffixes = ['.txt']
+config.test_format = lit.formats.ShTest()
+config.test_source_root = None
+config.test_exec_root = None
+
+# Should not crash
+lit_config.parallelism_groups['my_group'] = None
+
+config.parallelism_group = 'my_group'
Added: llvm/trunk/utils/lit/tests/Inputs/parallelism-groups/test1.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/tests/Inputs/parallelism-groups/test1.txt?rev=354912&view=auto
==============================================================================
--- llvm/trunk/utils/lit/tests/Inputs/parallelism-groups/test1.txt (added)
+++ llvm/trunk/utils/lit/tests/Inputs/parallelism-groups/test1.txt Tue Feb 26 11:03:26 2019
@@ -0,0 +1 @@
+# RUN: true
Added: llvm/trunk/utils/lit/tests/Inputs/parallelism-groups/test2.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/tests/Inputs/parallelism-groups/test2.txt?rev=354912&view=auto
==============================================================================
--- llvm/trunk/utils/lit/tests/Inputs/parallelism-groups/test2.txt (added)
+++ llvm/trunk/utils/lit/tests/Inputs/parallelism-groups/test2.txt Tue Feb 26 11:03:26 2019
@@ -0,0 +1 @@
+# RUN: true
Added: llvm/trunk/utils/lit/tests/parallelism-groups.py
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/tests/parallelism-groups.py?rev=354912&view=auto
==============================================================================
--- llvm/trunk/utils/lit/tests/parallelism-groups.py (added)
+++ llvm/trunk/utils/lit/tests/parallelism-groups.py Tue Feb 26 11:03:26 2019
@@ -0,0 +1,21 @@
+# Check that we do not crash if a parallelism group is set to None. Permits
+# usage of the following pattern.
+#
+# [lit.common.cfg]
+# lit_config.parallelism_groups['my_group'] = None
+# if <condition>:
+# lit_config.parallelism_groups['my_group'] = 3
+#
+# [project/lit.cfg]
+# config.parallelism_group = 'my_group'
+#
+# Note: We need at least 2 tests to prevent lit from using "single process
+# mode", which ignores parallelism groups.
+#
+
+# RUN: %{lit} -j2 %{inputs}/parallelism-groups | FileCheck %s
+
+# CHECK: -- Testing: 2 tests, 2 threads --
+# CHECK-DAG: PASS: parallelism-groups :: test1.txt
+# CHECK-DAG: PASS: parallelism-groups :: test2.txt
+# CHECK: Expected Passes : 2
More information about the llvm-commits
mailing list