2020-12-12 06:55:15 +08:00
|
|
|
# Twister Testing
|
2020-03-20 06:27:27 +08:00
|
|
|
|
|
|
|
Running the tests require the environment variable ZEPHYR_BASE to be set.
|
|
|
|
|
2020-12-12 06:55:15 +08:00
|
|
|
Twister Testsuite are located in $ZEPHYR_BASE/scripts/tests directory with all the data files in $ZEPHYR_BASE/scripts/test_data directory.
|
2020-03-20 06:27:27 +08:00
|
|
|
|
|
|
|
## Dependencies
|
|
|
|
|
|
|
|
Install all the dependencies using
|
|
|
|
|
|
|
|
```
|
2020-07-30 19:34:28 +08:00
|
|
|
pip install -r $ZEPHYR_BASE/scripts/requirements-build-test.txt
|
2020-03-20 06:27:27 +08:00
|
|
|
```
|
|
|
|
|
|
|
|
## Executing testsuite
|
|
|
|
|
|
|
|
The testcases can be executed from the root directory using
|
|
|
|
|
|
|
|
```
|
2020-12-08 01:29:36 +08:00
|
|
|
pytest $ZEPHYR_BASE/scripts/tests/twister
|
2020-03-20 06:27:27 +08:00
|
|
|
```
|
|
|
|
|
2020-12-12 06:55:15 +08:00
|
|
|
## Twister Coverage
|
2020-03-20 06:27:27 +08:00
|
|
|
|
|
|
|
The coverage for all the tests can be run using the command below. This will collect all the tests available.
|
|
|
|
|
|
|
|
```bash
|
2020-12-08 01:29:36 +08:00
|
|
|
coverage run -m pytest $ZEPHYR_BASE/scripts/tests/twister/
|
2020-03-20 06:27:27 +08:00
|
|
|
```
|
|
|
|
|
2020-12-08 01:29:36 +08:00
|
|
|
Then we can generate the coverage report for just twister script using
|
2020-07-10 17:30:33 +08:00
|
|
|
|
|
|
|
```bash
|
2020-12-08 01:29:36 +08:00
|
|
|
coverage report -m $ZEPHYR_BASE/scripts/pylib/twister/twisterlib.py
|
2020-07-10 17:30:33 +08:00
|
|
|
```
|
|
|
|
|
2020-12-08 01:29:36 +08:00
|
|
|
To generate the coverage report for twister script use below command
|
2020-03-20 06:27:27 +08:00
|
|
|
|
|
|
|
```bash
|
2020-12-08 01:29:36 +08:00
|
|
|
coverage report -m $ZEPHYR_BASE/scripts/twister
|
2020-03-20 06:27:27 +08:00
|
|
|
```
|
|
|
|
|
2020-12-08 01:29:36 +08:00
|
|
|
The html coverage report for twister can be generated using
|
2020-03-20 06:27:27 +08:00
|
|
|
|
|
|
|
```bash
|
2020-12-08 01:29:36 +08:00
|
|
|
coverage html twister
|
2020-03-20 06:27:27 +08:00
|
|
|
```
|
|
|
|
|
|
|
|
If needed,the full coverage html report can be generated in every run of "pytest" in the tests directory using configuration file (setup.cfg).
|
|
|
|
|
|
|
|
## Organization of tests
|
|
|
|
|
2020-12-08 01:29:36 +08:00
|
|
|
- conftest.py: Contains common fixtures for use in testing the twister tool.
|
|
|
|
- test_twister.py : Contains basic testcases for environment variables, verifying testcase & platform schema's.
|
|
|
|
- test_testsuite_class.py : Contains testcases for Testsuite class (except reporting functionality) in twisterlib.py.
|
2020-07-10 17:30:33 +08:00
|
|
|
- test_testinstance.py : Contains testcases for Testinstance and Testcase class.
|
2020-12-08 01:29:36 +08:00
|
|
|
- test_reporting_testsuite.py : Contains testcases for reporting fucntionality of Testsuite class of twister.
|