Dynamic host test loader (from directory location) #32
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This feature allows
mbedhtrun
to load and register additional host test scripts from given directory.In many cases users will add host tests to their yotta modules preferably under
/test/host_tests/
module directory.Host tests script files are enumerated and registered so they can be used with local module test cases.
Rationale
Not all host tests can be stored with
mbedhtrun
package. Some of them may and will be only used locally, for prototyping. Some host tests may just be very module dependent and should not be stored with `mbedhtrun``.Switch -e (enumerate host tests from directory)
New CLI switch
-e
/--enum-host-tests
defines (yotta module) directory in which we will store local host tests. You can also pointmbedhtrun
to different directory with pool of host tests.Note: Directory ytmodule
/test/host_tests
will be default local host test location used by test tools such asgreentea
.Example
In this example we have simple test
basic
located under/test/basic
(C++ code) and corresponding host test under/test/host_tests
,In this example we will add to yotta module
./test
directory sub directoryhost_tests
and put simple host testbasic.py
.Test
/test/basic
is connected with host test by namembed_drivers_basic
defined both in test case C++ source code (see listing below) and as name of host test.Directory structure with local host test(s):
We can now point
mbedhtrun
(switch--enum-host-tests .\test\host_tests\
) to new location within yotta module and use--list
switch to just registered host tests:New locally defined host test was registered as
mbed_drivers_basic
(modulebasic
, classbasic.Basic()
.Where:
mbed_drivers_basic
is host test name loaded fromBaseHostTest.Basic.name
basic
name is Python file name (no extension)basic.Basic()
name is composed from module and class (inherited fromBaseHostTest
) name inside host test fileExample test (+ new host test) execution command
Note: Add switch
-v
to increase-e
switch's verboseness.basic.cpp listing
Note:
MBED_HOSTTEST_SELECT(mbed_drivers_basic);
macro usage.basic.py listing
Note:
name = 'mbed_drivers_basic'
host test name definition.