Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
OpenGEODE
Commits
0bbbc723
Commit
0bbbc723
authored
Apr 21, 2016
by
Maxime Perrotin
Browse files
Use multiprocessing to determine the number of CPUs
parent
a87a0a87
Changes
1
Hide whitespace changes
Inline
Side-by-side
tests/regression/test.py
View file @
0bbbc723
...
...
@@ -4,14 +4,10 @@ import sys
import
time
import
os
from
functools
import
partial
from
multiprocessing
import
cpu_count
from
concurrent
import
futures
def
getProcessors
():
cmd
=
"cat /proc/cpuinfo |grep ^processor | wc -l"
return
int
(
os
.
popen
(
cmd
).
readlines
()[
0
])
def
colorMe
(
result
,
msg
):
if
sys
.
stdout
.
isatty
():
code
=
"1"
if
result
else
"2"
...
...
@@ -19,13 +15,13 @@ def colorMe(result, msg):
return
msg
def
main
():
totalCPUs
=
getProcessors
()
''' Run the test cases in parallel on all available CPUs '''
start
=
time
.
time
()
results
=
[]
rule
=
sys
.
argv
[
1
]
paths
=
sys
.
argv
[
2
:]
with
futures
.
ProcessPoolExecutor
(
max_workers
=
totalCPUs
)
as
executor
:
with
futures
.
ProcessPoolExecutor
(
max_workers
=
cpu_count
()
)
as
executor
:
for
result
in
executor
.
map
(
partial
(
make
,
rule
),
paths
):
print
(
"%40s: %s"
%
(
result
[
3
],
colorMe
(
result
[
0
],
'[OK]'
if
result
[
0
]
==
0
else
'[FAILED]'
)))
...
...
@@ -38,6 +34,7 @@ def main():
def
make
(
rule
,
path
):
''' Call a Makefile with the required rule (e.g. test-ada or clean) '''
proc
=
subprocess
.
Popen
(
[
'make'
,
'-C'
,
path
,
rule
],
stdout
=
subprocess
.
PIPE
,
...
...
@@ -49,6 +46,7 @@ def make(rule, path):
def
summarize
(
results
,
elapsed
):
''' At the end display the errors of project that failed '''
failed
=
0
for
errcode
,
stdout
,
stderr
,
path
,
rule
in
results
:
if
errcode
==
0
:
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment