You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
*`-m <MCU>` to select a target for the compilation. At the moment, the only supported value for `mcu` is `K64F` (for the FRDM_K64F board).
392
-
*`-t <TOOLCHAIN>` to select a toolchain, where `toolchain` can be either ARM (armcc compiler) or GCC_ARM (GNU ARM Embedded).
393
-
*`--source <SOURCE>` to select the source directory. Default is `.` (the current dir). You can specify multiple source locations, even outside the program tree.
394
-
*`--build <BUILD>` to select the build directory. Default: `.build/ inside your program
395
+
*`-m <MCU>` to select a target
396
+
*`-t <TOOLCHAIN>` to select a toolchain, where `toolchain` can be either `ARM` (armcc compiler), `GCC_ARM` (GNU ARM Embedded), or `IAR` (IAR Embedded Workbench for ARM)
397
+
*`--source <SOURCE>` to select the source directory. Default is `.` (the current dir). You can specify multiple source locations, even outside the program tree
398
+
*`--build <BUILD>` to select the build directory. Default: `.build/` inside your program
395
399
*`--library` to compile the code as a [static .a/.ar library](#compiling-static-libraries)
396
400
*`--config` to inspect the run-time compile configuration (see below)
397
401
*`-S` or `--supported` shows supported matrix of targets and toolchains
@@ -504,31 +508,119 @@ A ``.uvproj`` file is created in the projectfiles/uvision folder. You can open t
504
508
505
509
### Testing
506
510
507
-
mbed OS comes with a comprehensive set of test tools (see blah.blah.com), and you can use *mbed CLI*to manage and execute tests for you. Use `mbed test --list-compile` to list the tests available:
511
+
Use the `test` command to compile and run tests:
508
512
509
-
#### Listing and compiling tests
513
+
```
514
+
$ mbed test -m K64F -t GCC_ARM
515
+
Building library mbed-build (K64F, GCC_ARM)
516
+
Building project GCC_ARM to TESTS-unit-myclass (K64F, GCC_ARM)
*`-m <MCU>` to select a target for the compilation.
556
+
*`-t <TOOLCHAIN>` to select a toolchain, where `toolchain` can be either `ARM` (armcc compiler), `GCC_ARM` (GNU ARM Embedded), or `IAR` (IAR Embedded Workbench for ARM)
557
+
*`--compile-list` to list all the tests that can be built
558
+
*`--run-list` to list all the tests that can be ran (they must be built first)
559
+
*`--compile` to only compile the tests
560
+
*`--run` to only run the tests
561
+
*`-n <TESTS_BY_NAME>` to limit the tests built or ran to a comma separated list (ex. test1,test2,test3)
562
+
*`--source <SOURCE>` to select the source directory. Default is `.` (the current dir). You can specify multiple source locations, even outside the program tree.
563
+
*`--build <BUILD>` to select the build directory. Default: `.build/ inside your program
564
+
*`-c or --clean` to clean the build directory before compiling
565
+
*`--test-spec <TEST_SPEC>` to set the path for the test spec file used when building and running tests (the default path is the build directory)
566
+
*`-v` or `--verbose` for verbose diagnostic output
567
+
*`-vv` or `--very_verbose` for very verbose diagnostic output
568
+
569
+
The compiled binaries and test artifacts can be found in the `.build/tests/<TARGET>/<TOOLCHAIN>` directory of your program.
570
+
571
+
#### Finding available tests
510
572
573
+
You can find the tests that are available for **building** by using the `--compile-list` option:
Tests are compiled by adding the argument ```--compile``` in the above compile command:
588
+
You can find the tests that are available for **running**by using the `--run-list` option:
527
589
528
590
```
529
-
$ mbed test --compile -t ARM -m K64F
591
+
$ mbed test --run-list
592
+
mbedgt: test specification file '.\.build/tests\K64F\ARM\test_spec.json' (specified with --test-spec option)
593
+
mbedgt: using '.\.build/tests\K64F\ARM\test_spec.json' from current directory!
594
+
mbedgt: available tests for built 'K64F-ARM', location '.\.build/tests\K64F\ARM'
595
+
test 'TESTS-functional-test1'
596
+
test 'TESTS-functional-test2'
597
+
test 'TESTS-functional-test3'
530
598
```
531
599
600
+
#### Change the test action
601
+
602
+
You can specify to only **build** the tests by using the `--compile` option:
603
+
604
+
```
605
+
$ mbed test -m K64F -t GCC_ARM --compile
606
+
```
607
+
608
+
You can specify to only **run** the tests by using the `--run` option:
609
+
610
+
```
611
+
$ mbed test -m K64F -t GCC_ARM --run
612
+
```
613
+
614
+
#### Limiting the test scope
615
+
616
+
You can limit the scope of the tests built and ran by using the `-n` option. This takes a comma separated list of test names as an argument:
617
+
618
+
```
619
+
$ mbed test -m K64F -t GCC_ARM -n TESTS-functional-test1,TESTS-functional-test2
620
+
```
621
+
622
+
#### Test directory structure
623
+
532
624
Test code exists in the following directory structure:
533
625
534
626
```
@@ -558,13 +650,9 @@ mbed-os-program
558
650
| ....
559
651
```
560
652
561
-
As shown above, tests exist inside ```TESTS\testgroup\testcase\``` directories. Please note that `TESTS` is a special upper case directory that is excluded from module sources while compiling. Any testing libraries can be put inside the ```frameworks``` directory. This is currently just a good convention, but in the future tests might be able to limit which libraries should and should not be included when compiling them.
562
-
563
-
Compiled test binaries are created in ```.build/<TARGET>/<TOOLCHAIN>/TestCase1.bin```
564
-
565
-
<spanclass="notes">**Note:** This feature does not work in application modules that contain ```main()```. This issue is being worked on in parallel. However, currently we don't have any module with ```main()``` and ```TESTS``` together. Hence it does not break any existing module.</span>
653
+
As shown above, tests exist inside ```TESTS\testgroup\testcase\``` directories. Please note that `TESTS` is a special upper case directory that is excluded from module sources while compiling.
566
654
567
-
#### Listing and compiling tests
655
+
<spanclass="notes">**Note:** This feature does not work in applications that contain a ```main``` function that is outside of a `TESTS` directory.</span>
dict(name=['-c', '--clean'], action='store_true', help='Clean the build directory before compiling'),
1941
-
dict(name='--test-spec', dest="test_spec", help="Destination path for the test spec file used when running tests (only override if a test spec file that can be used by the Greentea automated test tool. The default is placed in the build directory"),
1941
+
dict(name='--test-spec', dest="test_spec", help="Path used for the test spec file used when building and running tests (the default path is the build directory)"),
1942
1942
help='Find, build and run tests',
1943
1943
description=("Find, build, and run tests in a program and libraries"))
0 commit comments