Build and run unit tests

In this section of the guide, we build and run the unit tests that are provided in our example. First, we compile the tests for both the Arch Pro hardware and MPS2+ FVP. These steps take some time. This is because Mbed OS compiles the entire library to run the unit tests properly on target.

Follow these steps:

  1. Plug in your Arch Pro development board over USB.
  2. Run the following commands for the Arch Pro:

    cd mbed-os
    mbed test -t ARM -m ARCH_PRO --compile
    mbedls will verify that you have an Mbed-enabled board connected to your computer. The mbed test command compiles all tests with the Arm Compiler.
  3. Now we are ready to run the unit test suite on both hardware and virtual platforms to contrast the results. Certain tests run on one platform, and not another, because of differences in the internal hardware. For example, the Arch Pro cannot run some real-time operating system tests and driver tests that it does not support with its hardware. To ensure that the Arch Pro and MPS2+ FVP are running the same test suite, the -n switch is added to enumerate the tests to run. Wildcards (*) are used to include all of a certain class of test, and commas separate the tests. You must be in the mbed-os directory to perform these tests.
  4. Run tests on the Arch Pro, using this command:

    mbedgt -m ARCH_PRO -n features-device_key*,features-frameworks*,features-storage*,tests-integration*,tests-mbed_platform*
  5. Run tests on the MPS2+ FVP Cortex-M3, using this command:

    mbedgt --fm FVP_MPS2_M3:DEFAULT -n features-device_key*,features-frameworks*,features-storage*,tests-integration*,tests-mbed_platform*
    All test suites should pass, and a total time is displayed after completing all tests. The total test time for both the Arch Pro board and the MPS2+ FVP will vary, depending on the host computer bandwidth and performance. The test commands above run 33 test suites with a total of 124 tests on each platform. Different MBed OS versions contain different test modules. This means that you will run more tests, or fewer tests, depending on which version you have. Here are the times to complete all 124 tests for each platform on my machine – you may get different depending on your machine performance:
    • Arch Pro: 488 seconds
    • MPS2+ FVP: 259 seconds
Previous Next