forked from u-boot/u-boot
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
At present the tests run one after the other using a single CPU. This is not very efficient. Bring in the concurrencytest module and run the tests concurrently, using one process for each CPU by default. A -P option allows this to be overridden, which is necessary for code-coverage to function correctly. This requires fixing a few tests which are currently not fully independent. At some point we might consider doing this across all pytests in U-Boot. There is a pytest version that supports specifying the number of processes to use, but it did not work for me. Signed-off-by: Simon Glass <[email protected]>
- Loading branch information
Showing
12 changed files
with
274 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*.pyc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
concurrencytest | ||
=============== | ||
|
||
![testing goats](https://raw.github.com/cgoldberg/concurrencytest/master/testing-goats.png "testing goats") | ||
|
||
Python testtools extension for running unittest suites concurrently. | ||
|
||
---- | ||
|
||
Install from PyPI: | ||
``` | ||
pip install concurrencytest | ||
``` | ||
|
||
---- | ||
|
||
Requires: | ||
|
||
* [testtools](https://pypi.python.org/pypi/testtools) : `pip install testtools` | ||
* [python-subunit](https://pypi.python.org/pypi/python-subunit) : `pip install python-subunit` | ||
|
||
---- | ||
|
||
Example: | ||
|
||
```python | ||
import time | ||
import unittest | ||
|
||
from concurrencytest import ConcurrentTestSuite, fork_for_tests | ||
|
||
|
||
class SampleTestCase(unittest.TestCase): | ||
"""Dummy tests that sleep for demo.""" | ||
|
||
def test_me_1(self): | ||
time.sleep(0.5) | ||
|
||
def test_me_2(self): | ||
time.sleep(0.5) | ||
|
||
def test_me_3(self): | ||
time.sleep(0.5) | ||
|
||
def test_me_4(self): | ||
time.sleep(0.5) | ||
|
||
|
||
# Load tests from SampleTestCase defined above | ||
suite = unittest.TestLoader().loadTestsFromTestCase(SampleTestCase) | ||
runner = unittest.TextTestRunner() | ||
|
||
# Run tests sequentially | ||
runner.run(suite) | ||
|
||
# Run same tests across 4 processes | ||
suite = unittest.TestLoader().loadTestsFromTestCase(SampleTestCase) | ||
concurrent_suite = ConcurrentTestSuite(suite, fork_for_tests(4)) | ||
runner.run(concurrent_suite) | ||
``` | ||
Output: | ||
|
||
``` | ||
.... | ||
---------------------------------------------------------------------- | ||
Ran 4 tests in 2.003s | ||
OK | ||
.... | ||
---------------------------------------------------------------------- | ||
Ran 4 tests in 0.504s | ||
OK | ||
``` |
Oops, something went wrong.