Skip to content

Commit 07e22ed

Browse files
Merge pull request #50 from bridadan/greentea_legacy_package
Add Greentea legacy package
2 parents 3630d0d + e58064a commit 07e22ed

40 files changed

+4577
-0
lines changed

.circleci/config.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ commands:
2626
- run_tests:
2727
working_directory: .
2828
- install_mbed_os_tools
29+
- run_tests:
30+
working_directory: legacy/mbed-greentea
2931
- run_tests:
3032
working_directory: legacy/mbed-ls
3133
enforce_style:

legacy/mbed-greentea/.coveragerc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[run]
2+
source =
3+
mbed_greentea

legacy/mbed-greentea/MANIFEST.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
include README.md LICENSE CONTRIBUTING.md
2+
include .coveragerc

legacy/mbed-greentea/README.md

Lines changed: 229 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,229 @@
1+
# Development moved
2+
3+
The development of Greentea has been moved into the [mbed-os-tools](../../src/mbed_os_tools) package. You can continue to use this module for legacy reasons, however all further development should be continued in the new package.
4+
5+
-------------
6+
7+
[![Circle CI](https://circleci.com/gh/ARMmbed/greentea.svg?style=svg)](https://circleci.com/gh/ARMmbed/greentea)
8+
[![Coverage Status](https://coveralls.io/repos/github/ARMmbed/greentea/badge.svg?branch=master)](https://coveralls.io/github/ARMmbed/greentea?branch=master)
9+
[![PyPI version](https://badge.fury.io/py/mbed-greentea.svg)](https://badge.fury.io/py/mbed-greentea)
10+
11+
# Greentea - test automation for mbed
12+
_**G**eneric **re**gression **en**vironment for **te**st **a**utomation_
13+
14+
## Introduction
15+
16+
Greentea is the automated testing tool for mbed OS development. It automates the process of flashing mbed boards, driving the test and accumulating test results into test reports. Developers use it for local development as well as for automation in a Continuous Integration environment.
17+
18+
This document should help you start using Greentea. Please see the [htrun documentation](https://github.com/ARMmbed/htrun), the tool Greentea uses to drive tests, for the technical details of the interactions between the platform and the host machine.
19+
20+
Because Greentea is an open source project, we accept contributions! Please see our [contributing document](CONTRIBUTING.md) for more information.
21+
22+
### Prerequistes
23+
24+
Greentea requires [Python version 2.7](https://www.python.org/downloads/). It supports the following OSes:
25+
26+
- Windows
27+
- Linux (Ubuntu preferred)
28+
- OS X (experimental)
29+
30+
### Installing
31+
32+
Tools that depend on Greentea usually install it. Determine if Greentea is already installed by running:
33+
```
34+
$ mbedgt --version
35+
1.2.5
36+
```
37+
38+
You can also install it manually via pip.
39+
40+
```
41+
pip install mbed-greentea
42+
```
43+
44+
## Test specification JSON format
45+
46+
The Greentea test specification format decouples the tool from your build system. It provides important data, such as test names, paths to test binaries and the platform on which the binaries should run.
47+
48+
Greentea automatically looks for files called `test_spec.json` in your working directory. You can also use the `--test-spec` argument to direct Greentea to a specific test specification file.
49+
50+
When you use the `-t` / `--target` argument with the `--test-spec` argument, you can select which "build" should be used. In the example below, you could provide the arguments `--test-spec test_spec.json -t K64F-ARM` to only run that build's tests.
51+
52+
### Example of test specification file
53+
54+
In the below example, there are two defined builds:
55+
* Build `K64F-ARM` for NXP `K64F` platform compiled with `ARMCC` compiler.
56+
* Build `K64F-GCC` for NXP `K64F` platform compiled with `GCC ARM` compiler.
57+
58+
```json
59+
{
60+
"builds": {
61+
"K64F-ARM": {
62+
"platform": "K64F",
63+
"toolchain": "ARM",
64+
"base_path": "./BUILD/K64F/ARM",
65+
"baud_rate": 9600,
66+
"tests": {
67+
"tests-mbedmicro-rtos-mbed-mail": {
68+
"binaries": [
69+
{
70+
"binary_type": "bootable",
71+
"path": "./BUILD/K64F/ARM/tests-mbedmicro-rtos-mbed-mail.bin"
72+
}
73+
]
74+
},
75+
"tests-mbed_drivers-c_strings": {
76+
"binaries": [
77+
{
78+
"binary_type": "bootable",
79+
"path": "./BUILD/K64F/ARM/tests-mbed_drivers-c_strings.bin"
80+
}
81+
]
82+
}
83+
}
84+
},
85+
"K64F-GCC": {
86+
"platform": "K64F",
87+
"toolchain": "GCC_ARM",
88+
"base_path": "./BUILD/K64F/GCC_ARM",
89+
"baud_rate": 9600,
90+
"tests": {
91+
"tests-mbedmicro-rtos-mbed-mail": {
92+
"binaries": [
93+
{
94+
"binary_type": "bootable",
95+
"path": "./BUILD/K64F/GCC_ARM/tests-mbedmicro-rtos-mbed-mail.bin"
96+
}
97+
]
98+
}
99+
}
100+
}
101+
}
102+
}
103+
```
104+
105+
The examples below use the above test specification file.
106+
107+
## Command-line usage
108+
This section highlights a few of the capabilities of the Greentea command-line interface. For a full list of the available options, please run `mbedgt --help`.
109+
110+
Assume for the examples below that the above `test_spec.json` file is in the current directory.
111+
112+
### Listing all tests
113+
You can use the `-l` argument to list all available tests:
114+
115+
```
116+
$ mbedgt -l
117+
mbedgt: greentea test automation tool ver. 1.2.5
118+
mbedgt: using multiple test specifications from current directory!
119+
using 'BUILD\tests\K64F\ARM\test_spec.json'
120+
using 'BUILD\tests\K64F\GCC_ARM\test_spec.json'
121+
mbedgt: available tests for built 'K64F-GCC_ARM', location 'BUILD/tests/K64F/GCC_ARM'
122+
test 'tests-mbedmicro-rtos-mbed-mail'
123+
mbedgt: available tests for built 'K64F-ARM', location 'BUILD/tests/K64F/ARM'
124+
test 'tests-mbed_drivers-c_strings'
125+
test 'tests-mbedmicro-rtos-mbed-mail'
126+
```
127+
128+
### Executing all tests
129+
The default action of Greentea using `mbedgt` is to execute all tests that are found in `test_spec.json` files. You can also add `-V` to make the output more verbose.
130+
131+
132+
### Limiting tests
133+
You can select test cases by name using the `-n` argument. This command executes all tests named `tests-mbedmicro-rtos-mbed-mail` from all builds in the test specification:
134+
```
135+
$ mbedgt -n tests-mbedmicro-rtos-mbed-mail
136+
```
137+
138+
When using the `-n` argument, you can use the `*` character at the end of a test name to match all tests that share a prefix. This command executes all tests that start with `tests*`:
139+
140+
```
141+
$ mbedgt -n tests*
142+
```
143+
144+
You can use the `-t` argument to select which build to use when finding tests. This command executes the test `tests-mbedmicro-rtos-mbed-mail` for the `K64F-ARM` build in the test specification:
145+
```
146+
$ mbedgt -n tests-mbedmicro-rtos-mbed-mail -t K64F-ARM
147+
```
148+
149+
You can use a comma (`,`) to separate test names (argument `-n`) and build names (argument `-t`). This command executes the tests `tests-mbedmicro-rtos-mbed-mail` and `tests-mbed_drivers-c_strings` for the `K64F-ARM` and `K64F-GCC_ARM` builds in the test specification:
150+
```
151+
$ mbedgt -n tests-mbedmicro-rtos-mbed-mail,tests-mbed_drivers-c_strings -t K64F-ARM,K64F-GCC_ARM
152+
```
153+
154+
### Selecting platforms
155+
You can limit which boards Greentea uses for testing by using the `--use-tids` argument.
156+
157+
```
158+
$ mbedgt --use-tids 02400203C3423E603EBEC3D8,024002031E031E6AE3FFE3D2
159+
```
160+
161+
Where ```02400203C3423E603EBEC3D8``` and ```024002031E031E6AE3FFE3D2``` are the target IDs of platforms attached to your system.
162+
163+
You can view target IDs using the [mbed-ls](https://github.com/ARMmbed/mbed-ls) tool (installed with Greentea).
164+
165+
```
166+
$ mbedls
167+
+--------------+---------------------+------------+------------+-------------------------+
168+
|platform_name |platform_name_unique |mount_point |serial_port |target_id |
169+
+--------------+---------------------+------------+------------+-------------------------+
170+
|K64F |K64F[0] |E: |COM160 |024002031E031E6AE3FFE3D2 |
171+
|K64F |K64F[1] |F: |COM162 |02400203C3423E603EBEC3D8 |
172+
|LPC1768 |LPC1768[0] |G: |COM5 |1010ac87cfc4f23c4c57438d |
173+
+--------------+---------------------+------------+------------+-------------------------+
174+
```
175+
In this case, you won't test one target, the LPC1768.
176+
177+
### Testing on Fast Model FVPs
178+
179+
Fast Models FVPs are software models for Arm reference design platfrom
180+
181+
Greentea supports running test on Fast Models. And [mbed-fastmodel-agent](https://github.com/ARMmbed/mbed-fastmodel-agent) module is required for this purpose.
182+
183+
The "--fm" option only available when the `mbed-fastmodel-agent` module is installed :
184+
185+
You can run tests for FVP_MPS2_Cortex-M3 models, by '--fm' option:
186+
```
187+
$ mbedgt --fm FVP_MPS2_M3:DEFAULT
188+
```
189+
190+
Where ```FVP_MPS2_M3``` is the platfrom name for the ```FVP_MPS2_Cortex-M3``` models in mbed OS.
191+
192+
And ```DEFAULT``` is the config to the Fast Model, you can find out using ```mbedfm``` command
193+
194+
### Creating reports
195+
Greentea supports a number of report formats.
196+
197+
#### HTML
198+
This creates an interactive HTML page with test results and logs.
199+
```
200+
mbedgt --report-html html_report.html
201+
```
202+
203+
#### JUnit
204+
This creates an XML JUnit report, which you can use with popular Continuous Integration software, such as [Jenkins](https://jenkins.io/index.html).
205+
```
206+
mbedgt --report-junit junit_report.xml
207+
```
208+
209+
#### JSON
210+
This creates a general JSON report.
211+
```
212+
mbedgt --report-json json_report.json
213+
```
214+
215+
#### Plain text
216+
This creates a human-friendly text summary of the test run.
217+
```
218+
mbedgt --report-text text_report.text
219+
```
220+
221+
## Host test detection
222+
When developing with mbed OS, Greentea detects host tests automatically if you place them in the correct location. All tests in mbed OS are placed under a `TESTS` directory. You may place custom host test scripts in a folder named `host_tests` in this folder. For more information about the mbed OS test directory structure, please see the [mbed CLI documentation](https://docs.mbed.com/docs/mbed-os-handbook/en/latest/dev_tools/cli/#test-directory-structure).
223+
224+
## Common issues
225+
226+
### `IOERR_SERIAL` errors
227+
Possible causes:
228+
- Another program is using the serial port. Be sure all terminals and other instances of Greentea are closed before trying again.
229+
- The mbed interface firmware is out of date. Please see the platform's page on [developer.mbed.org](https://developer.mbed.org/) for details about how to update it.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
"""
2+
mbed SDK
3+
Copyright (c) 2011-2015 ARM Limited
4+
5+
Licensed under the Apache License, Version 2.0 (the "License");
6+
you may not use this file except in compliance with the License.
7+
You may obtain a copy of the License at
8+
9+
http://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
See the License for the specific language governing permissions and
15+
limitations under the License.
16+
17+
Author: Przemyslaw Wirkus <[email protected]>
18+
"""
19+
20+
from .mbed_greentea_cli import main
21+
22+
"""! @package mbed-greentea
23+
24+
This is a test suite used by mbed project. If you have yotta package with tests you can run them on supported hardware
25+
This test suite supports:
26+
* mbed-ls - mbed-enabled device auto detection module
27+
* mbed-host-test - mbed-enabled device test framework (flash, reset and make host tests)
28+
29+
"""
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
from mbed_greentea.mbed_greentea_cli import main
2+
main()
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
"""
2+
mbed SDK
3+
Copyright (c) 2011-2016 ARM Limited
4+
5+
Licensed under the Apache License, Version 2.0 (the "License");
6+
you may not use this file except in compliance with the License.
7+
You may obtain a copy of the License at
8+
9+
http://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
See the License for the specific language governing permissions and
15+
limitations under the License.
16+
17+
Author: Przemyslaw Wirkus <[email protected]>
18+
"""
19+
20+
from mbed_os_tools.test.cmake_handlers import (
21+
load_ctest_testsuite,
22+
parse_ctesttestfile_line,
23+
list_binaries_for_targets,
24+
list_binaries_for_builds,
25+
)
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
"""
2+
mbed SDK
3+
Copyright (c) 2011-2016 ARM Limited
4+
5+
Licensed under the Apache License, Version 2.0 (the "License");
6+
you may not use this file except in compliance with the License.
7+
You may obtain a copy of the License at
8+
9+
http://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
See the License for the specific language governing permissions and
15+
limitations under the License.
16+
17+
Author: Przemyslaw Wirkus <[email protected]>
18+
"""
19+
20+
from mbed_os_tools.test.mbed_common_api import (
21+
run_cli_command,
22+
run_cli_process,
23+
)
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
"""
2+
mbed SDK
3+
Copyright (c) 2011-2016 ARM Limited
4+
5+
Licensed under the Apache License, Version 2.0 (the "License");
6+
you may not use this file except in compliance with the License.
7+
You may obtain a copy of the License at
8+
9+
http://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
See the License for the specific language governing permissions and
15+
limitations under the License.
16+
17+
Author: Przemyslaw Wirkus <[email protected]>
18+
"""
19+
20+
from mbed_os_tools.test.mbed_coverage_api import *

0 commit comments

Comments
 (0)