llvm.org GIT mirror llvm / 0ffe848
[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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@354912 91177308-0d34-0410-b5e6-96231b3b80d8 Julian Lettner 5 months ago
6 changed file(s) with 45 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
105105 environment, substitutions, unsupported,
106106 test_exec_root, test_source_root, excludes,
107107 available_features, pipefail, limit_to_features = [],
108 is_early = False, parallelism_group = ""):
108 is_early = False, parallelism_group = None):
109109 self.parent = parent
110110 self.name = str(name)
111111 self.suffixes = set(suffixes)
1616 if self.failedCount == self.maxFailures:
1717 self.provider.cancel()
1818
19 # No-operation semaphore for supporting `None` for parallelism_groups.
20 # lit_config.parallelism_groups['my_group'] = None
21 class NopSemaphore(object):
22 def acquire(self): pass
23 def release(self): pass
24
1925 class Run(object):
2026 """
2127 This class represents a concrete, configured testing run.
2531 self.lit_config = lit_config
2632 self.tests = tests
2733 # Set up semaphores to limit parallelism of certain classes of tests.
28 # For example, some ASan tests require lots of virtual memory and run
29 # faster with less parallelism on OS X.
30 self.parallelism_semaphores = \
31 {k: multiprocessing.BoundedSemaphore(v) for k, v in
32 self.lit_config.parallelism_groups.items()}
34 self.parallelism_semaphores = {
35 k : NopSemaphore() if v is None else
36 multiprocessing.BoundedSemaphore(v)
37 for k, v in lit_config.parallelism_groups.items()}
3338
3439 def execute_tests_in_pool(self, jobs, max_time):
3540 # We need to issue many wait calls, so compute the final deadline and
0 import lit.formats
1 config.name = 'parallelism-groups'
2 config.suffixes = ['.txt']
3 config.test_format = lit.formats.ShTest()
4 config.test_source_root = None
5 config.test_exec_root = None
6
7 # Should not crash
8 lit_config.parallelism_groups['my_group'] = None
9
10 config.parallelism_group = 'my_group'
0 # Check that we do not crash if a parallelism group is set to None. Permits
1 # usage of the following pattern.
2 #
3 # [lit.common.cfg]
4 # lit_config.parallelism_groups['my_group'] = None
5 # if :
6 # lit_config.parallelism_groups['my_group'] = 3
7 #
8 # [project/lit.cfg]
9 # config.parallelism_group = 'my_group'
10 #
11 # Note: We need at least 2 tests to prevent lit from using "single process
12 # mode", which ignores parallelism groups.
13 #
14
15 # RUN: %{lit} -j2 %{inputs}/parallelism-groups | FileCheck %s
16
17 # CHECK: -- Testing: 2 tests, 2 threads --
18 # CHECK-DAG: PASS: parallelism-groups :: test1.txt
19 # CHECK-DAG: PASS: parallelism-groups :: test2.txt
20 # CHECK: Expected Passes : 2