-
Notifications
You must be signed in to change notification settings - Fork 178
Rework the Greentea docs #927
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rework the Greentea docs #927
Conversation
…amples, move everything into a single document
cfbd5ed
to
45f7c9d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please prefer to use Mbed CLI over the tools shipped with dependent packages.
|
||
#### Writing tests | ||
 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should promote working with Mbed CLI within it's own documentation where possible. Either this is titled incorrectly, or it should be removed (I can't see the image content)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I think I copied something wrong there. The description just shows the tree structure, nothing to do with make. My bad :-)
|
||
Where `02400203C3423E603EBEC3D8` and `024002031E031E6AE3FFE3D` are the target IDs of platforms attached to your system. | ||
|
||
You can view target IDs using the [`mbed-ls`](https://github.com/ARMmbed/mbed-os-tools/tree/master/packages/mbed-ls) tool (installed with Greentea). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use mbed detect
instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated. Copied it from old content but missed this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really like the format you've put forward here, I think it's definitely an improvement.
The CLI for mbed test
is at best described as "finicky", I'm actively working to make it better. I've commented on some of the commands below and some issues I foresee.
|
||
The Greentea tool handles the actual testing process. To read more about this tool, please visit its [GitHub repository](https://github.com/ARMmbed/mbed-os-tools/tree/master/packages/mbed-greentea). | ||
As specified above, there is a convention where all tests live in the `TESTS/` directory. In the `first-greentea-test` folder create a folder `TESTS/tests/simple-test/`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd suggest the following example folder structure since the example kind of looks like a duplication (double "tests" folders):
As specified above, there is a convention where all tests live in the `TESTS/` directory. In the `first-greentea-test` folder create a folder `TESTS/tests/simple-test/`. | |
As specified above, there is a convention where all tests live in the `TESTS/` directory. In the `first-greentea-test` folder create a folder `TESTS/test-group/simple-test/`. |
|
||
#### Writing tests | ||
 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we usually host these on s3? Perhaps just using an text representation of the structure would be easier. Ex:
project/
TESTS/
test-group/
simple-test/
main.cpp
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, the image is in this pr, but not uploaded to s3 yet. @bridadan Good suggestion, I'll update it to use that.
void test_success() { | ||
TEST_ASSERT(true); | ||
} | ||
// this is how a test looks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: differentiate between "test" with "test case"
// this is how a test looks | |
// this is how a test case looks |
GREENTEA_SETUP(40, "default_auto"); | ||
return verbose_test_setup_handler(number_of_cases); | ||
utest::v1::status_t greentea_setup(const size_t number_of_cases) { | ||
// here we specify the timeout (60s) and the host runner (the name of our Python file) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: default_auto
is currently provided by htrun
, not by a python file within mbed-os.
// here we specify the timeout (60s) and the host runner (the name of our Python file) | |
// here we specify the timeout (60s) and the host test (a built-in host test or the name of our Python file) |
return verbose_test_setup_handler(number_of_cases); | ||
utest::v1::status_t greentea_setup(const size_t number_of_cases) { | ||
// here we specify the timeout (60s) and the host runner (the name of our Python file) | ||
GREENTEA_SETUP(1*60, "default_auto"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Ok to drop the multiplication here?
GREENTEA_SETUP(1*60, "default_auto"); | |
GREENTEA_SETUP(60, "default_auto"); |
$ mbed test -n tests-mbedmicro-rtos-mbed-mail | ||
``` | ||
|
||
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-mbedmicro-rtos`: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will now use "globbing" rules, so you can actually sprinkle the *
characters any where you like.
You can limit which boards Greentea uses for testing by using the `--use-tids` argument. | ||
|
||
``` | ||
$ mbed test --use-tids 02400203C3423E603EBEC3D8,024002031E031E6AE3FFE3D2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will currently error unless you add --run
.
|K64F |K64F[0] |E: |COM160 |024002031E031E6AE3FFE3D2 | | ||
|K64F |K64F[1] |F: |COM162 |02400203C3423E603EBEC3D8 | | ||
|LPC1768 |LPC1768[0] |G: |COM5 |1010ac87cfc4f23c4c57438d | | ||
+--------------+---------------------+------------+------------+-------------------------+ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If your current working directly is within an Mbed OS project, the output of mbed detect
looks like this:
mbed detect
[mbed] Working path "C:\Users\bridan01\onedrive_arm\Documents\dev\mbed-os" (program)
[mbed] Detected K64F, port COM79, mounted F:, interface version 0250:
[mbed] Supported toolchains for K64F
| Target | mbed OS 2 | mbed OS 5 | uARM | IAR | ARM | GCC_ARM |
|---------------|-----------|-----------|------|-----------|-----------|-----------|
| K64F | Supported | Supported | - | Supported | Supported | Supported |
| RAPIDIOT_K64F | Supported | Supported | - | Supported | Supported | Supported |
Supported targets: 2
[mbed] Detected K64F, port COM78, mounted D:, interface version 0251:
[mbed] Supported toolchains for K64F
| Target | mbed OS 2 | mbed OS 5 | uARM | IAR | ARM | GCC_ARM |
|---------------|-----------|-----------|------|-----------|-----------|-----------|
| K64F | Supported | Supported | - | Supported | Supported | Supported |
| RAPIDIOT_K64F | Supported | Supported | - | Supported | Supported | Supported |
Supported targets: 2
Which unfortunately does not list the target id. mbedls
will but I know we want to direct folks to use Mbed CLI commands. In this case I don't think we have many options here, any ideas @theotherjimmy?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, huh. Not only does mbed detect
omit the information, it also neglects to use unique names. I suppose we'll have to use mbedls
until we fix this in mbed detect
.
This creates a human-friendly text summary of the test run. | ||
|
||
``` | ||
mbed test --report-text text_report.text |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All of these report commands would need the --run
command added first, otherwise it would throw an exception:
$ mbed test -n tests-mbed_functional-callback -v --report-json report.json
[mbed] Working path "C:\Users\bridan01\onedrive_arm\Documents\dev\mbed-os" (program)
[mbed] Exec "c:\python27\python.exe -u C:\Users\bridan01\onedrive_arm\Documents\dev\mbed-os\tools\test.py -t GCC_ARM -m K64F --source . --build .\BUILD\tests\K64F\GCC_ARM --test-spec .\BUILD\tests\K64F\GCC_ARM\test_spec.json --build-data .\BUILD\tests\K64F\GCC_ARM\build_data.json -n tests-mbed_functional-callback -v --greentea --report-json report.json" in "C:\Users\bridan01\onedrive_arm\Documents\dev\mbed-os"
usage: test.py [-h] [-m MCU] [--custom-targets CUSTOM_TARGETS_DIRECTORY]
[-t TOOLCHAIN] [--color] [--cflags CFLAGS]
[--asmflags ASMFLAGS] [--ldflags LDFLAGS] [-c]
[--profile PROFILE] [--app-config APP_CONFIG] [-D MACROS]
[-j JOBS] [--source SOURCE_DIR] [--build BUILD_DIR] [-l]
[-p PATHS] [-f FORMAT] [--continue-on-build-fail] [-n NAMES]
[--test-config TEST_CONFIG] [--test-spec TEST_SPEC]
[--build-report-junit BUILD_REPORT_JUNIT]
[--build-data BUILD_DATA] [-v] [--stats-depth STATS_DEPTH]
[--ignore IGNORE] [--icetea] [--greentea]
test.py: error: unrecognized arguments: --report-json report.json
[mbed] ERROR: "c:\python27\python.exe" returned error.
Code: 2
Path: "C:\Users\bridan01\onedrive_arm\Documents\dev\mbed-os"
Command: "c:\python27\python.exe -u C:\Users\bridan01\onedrive_arm\Documents\dev\mbed-os\tools\test.py -t GCC_ARM -m K64F --source . --build .\BUILD\tests\K64F\GCC_ARM --test-spec .\BUILD\tests\K64F\GCC_ARM\test_spec.json --build-data .\BUILD\tests\K64F\GCC_ARM\build_data.json -n tests-mbed_functional-callback -v --greentea --report-json report.json"
Tip: You could retry the last command with "-v" flag for verbose output
---
} | ||
``` | ||
|
||
If you now run `mbed test -l` this will now list only these tests: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You want to use the --run-list
option here as well.
If you now run `mbed test -l` this will now list only these tests: | |
If you now run `mbed test --run-list` this will now list only these tests: |
|
||
#### Writing tests | ||
 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -1,6 +1,10 @@ | |||
## Greentea testing applications | |||
|
|||
The way tests are run and compiled in Arm Mbed OS 5 is substantially different from previous versions of Mbed. | |||
Greentea is the automated testing tool for Arm Mbed OS development. It's a test runner that automates the process of flashing development boards, starting tests, and accumulating test results into test reports. Developers use it for local development as well as for automation in a Continuous Integration environment. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there some reason to use capital first letters for "Continous Integration"?
} | ||
|
||
// Test cases | ||
// list of all cases |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is listing test cases which are contained in this file and there are multiple files. "all" sounds me a bit more than one file tests
@bridadan @OPpuolitaival @ARMmbed/mbed-docs Updated based on feedback. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Definitely looking really good, thanks for making those changes. Just a few more comments below.
This creates a human-friendly text summary of the test run. | ||
|
||
``` | ||
mbed test --report-text text_report.text --run |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thinking about this more, none of the report arguments are currently part of the help options in Mbed CLI. This only works because Mbed CLI passes along arguments to the underlying scripts when it doesn't recognize it. How do you feel about removing this reporting section altogether?
You can limit which boards Greentea uses for testing by using the `--use-tids` argument. | ||
|
||
``` | ||
$ mbed test --use-tids 02400203C3423E603EBEC3D8,024002031E031E6AE3FFE3D2 --run |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same thing that I mentioned below about the reporting section, this isn't in the mbed test --help
text. How do you feel about removing this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, isn't it great that our docs are more complete than our CLI?
|
||
utest::v1::status_t greentea_setup(const size_t number_of_cases) { | ||
// here we specify the timeout (60s) and the host runner (the name of our Python file) | ||
GREENTEA_SETUP(1*60, "hello_world_tests"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One other 1*60
that can be removed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good
@bridadan @ARMmbed/mbed-docs Is this good to go now? |
@ARMmbed/mbed-docs Ping. |
Edit file, mostly for consistent person and voice across docs.
$ mbed test -t GCC_ARM -m auto -v -n tests-test-group-simple-test | ||
``` | ||
|
||
This yields (on a K64F): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we please use a different board for our examples?
@AnotherButler Fixed |
…-5-docs into greentea-test-update
@theotherjimmy Have your concerns been addressed? |
@theotherjimmy @ARMmbed/mbed-docs ping again. |
@AnotherButler @ARMmbed/mbed-docs Who can merge this? |
@theotherjimmy I'm going to merge this today or tomorrow. If you have any further concerns, please create a new PR. |
@AnotherButler @ARMmbed/mbed-docs When will this be available? |
5.12 at the end of the month |
Apply changes from PR #927 to 5.11.
Apply changes from PR #927 to 5.11.
I just applied your changes to 5.11. Let me know if they haven't built by tomorrow. |
@AnotherButler Awesome, thanks. |
@iriark01 @ARMmbed/mbed-docs As per our discussion on e-mail.
This PR:
mbed test
instead of thembedgt
command.