GithubHelp home page GithubHelp logo

greentea's Introduction

PyPI version

Greentea host tests runner (htrun) command line

htrun has extensive command line. In most cases htrun will be run in background:

  • driving test binary flashing,
  • device reset and
  • test execution.

Default binary flashing method is one supported by mbed-enabled devices: binary file is copied on mbed-enabled DUT (Device Under Test) mounted drive (MSD). This procedure will automatically flash device with given binary file content.

Default DUT reset method is one supported by mbed-enabled devices: serial port (CDC) "sendBreak" command resets target MCU on mbed-enabled platform.

Test execution phase will consist of:

  • Opening connection between host computer and DUT,
  • DUT will send to host preamble with test runner information such as:
    • test environment version,
    • test timeout,
    • preferred host test script (Python script which is used to supervise/instrument test execution),
  • Host will spawn host test script and test execution will be instrumented
  • Exchange data (in most cases text) between host and DUT,

Command line overview

This chapter will present a few examples of how you can use htrun command line to execute tests. In most cases test automation tools such as Greentea will execute htrun implicitly. There are cases when we want to execute htrun independently. Mostly in situation when we want to:

  • debug our code and have binary + host test instrumentation on,
  • prototype or
  • just want to replace test runner in another OS with one compatible with mbed-enabled devices.

All htrun needs is name of the binary you want to flash and method of flashing!

Useful command line end-to-end examples

Flashing phase operations

Flash binary file /path/to/file/binary.bin using mount point D:. Use serial port COM4 to communicate with DUT:

$ htrun -f /path/to/file/binary.bin -d D: -p COM4

Flash (use shell command copy) binary file /path/to/file/binary.bin using mount point D:. Use serial port COM4 to communicate with DUT:

$ htrun -f /path/to/file/binary.bin -d D: -p COM4 -c copy

Skip flashing phase (e.g. you've already flashed this device with /path/to/file/binary.bin binary). Use serial port COM4 to communicate with DUT:

$ htrun -f /path/to/file/binary.bin -d D: -p COM4 --skip-flashing

DUT-host communication and reset phase

Flash binary file /path/to/file/binary.bin using mount point D:. Use serial port COM4 with baudrate 115200 to communicate with DUT:

$ htrun -f /path/to/file/binary.bin -d D: -p COM4:115200

As above but we will skip reset phase (not so common but in some cases can be used to suppress reset phase for some reasons):

$ htrun -f /path/to/file/binary.bin -d D: -p COM4:115200 --skip-reset

Flash binary file /path/to/file/binary.bin using mount point D:. Use serial port COM4 with default baudrate to communicate with DUT. Do not send __sync key-value protocol synchronization packet to DUT before preamble read:

$ htrun -f /path/to/file/binary.bin -d D: -p COM4 --sync=0

Note: Sync packet management allows you to manipulate the way htrun sends __sync packet(s) to DUT. With current settings we can force on htrun to send __sync packets in this manner:

  • --sync=0 - No sync packets will be sent to DUT.
  • --sync=-1- __sync packets will be sent unless we will reach timeout or proper response is sent from DUT.
  • --sync=N - Where N is integer > 0. Send up to N __sync packets to target platform. Response is sent unless we get response from target platform or timeout occurs.

Global Resource Manager connection

Flash local file /path/to/file/binary.bin to remote device resource (platform K64F) provided by remote_client GRM service available on IP address 10.2.203.31 and port: 8000. Force serial port connection to remote device 9600 with baudrate:

$ htrun -p :9600 -f /path/to/file/binary.bin -m K64F --grm remote_client:10.2.203.31:8000

Command line switch --grm has format: <module_name>:<IP_address>:<port_number>.

  • <module_name> - name of Python module to load as remote resource manager.
  • <IP_address> and <port_number> - IP address and port of remote resource manager.

Note: Switch -m <platform_name> is required to tell Global Resource Management which platform to request. Note: Command line switch --grm implicitly forces --skip-flashing and --skip-reset because both flags are used for locally available DUTs.

Fast Model connection

This option is designed for htrun to use Arm Fast Models.

The "--fm" option only available when mbed-fastmodel-agent module is installed :

Load local file /path/to/file/binary.elf to onto fastmodel FVP_MPS2_m3 simulators:

$ htrun -f /path/to/file/binary.elf -m FVP_MPS2_M3 --fm DEFAULT

Command line switch format --fm <config_name>.

  • <config_name> - either pre-defined CONFIG_NAME from mbedfm or a local config file for the Fast Models.

Note: Switch -m <platform_name> is required to tell this fastmodel connection which Fastmodel to request. Note: Command line switch --fm implicitly forces --skip-flashing and --skip-reset because both flags are used for locally available DUTs.

Miscellaneous

List available host tests names, class names and origin:

$ htrun --list

List available host tests names, class names and origin. Load additional host tests from /path/to/host_tests directory:

$ htrun --list -e /path/to/host_tests

List available reset and flashing plugins:

$ htrun --plugins

Note that some plugin could need some manual installation for extra application before.

Ex: Flash binary file /path/to/file/binary.bin using STM32CubeProgrammer tool. Use serial port COM4 with baudrate 115200 to communicate with DUT:

htrun -c stprog -f /path/to/file/binary.bin -p COM4:115200

In this example, STM32_Programmer_CLI application has to be in the environment path.

Installation

htrun is distributed along with greentea-host module as a dependency sources and its command line tool called htrun.

Installation from PyPI (Python Package Index)

greentea-host module is distributed via PyPI. We recommend you use the application pip.

Note: Python 2.7.9 onwards include pip by default, so you may have pip already.

To install mbed-ls from PyPI use command:

$ pip install greentea-host --upgrade

Installation from Python sources

To install the mbed test suite, first clone the greentea repository:

$ git clone https://github.com/ARMmbed/greentea.git

Change the directory to the greentea directory:

$ cd greentea

Now you are ready to install htrun:

$ python setup.py install

Note: setup.py will install both greentea (gt) and htrun command line tools.

Checking installation

To check whether the installation was successful try running the htrun --help command and check that it returns information (you may need to restart your terminal first):

$ htrun --help
Usage: htrun [options]

Flash, reset and perform host supervised tests on Mbed enabled platforms

Options:
  -h, --help            show this help message and exit

Greentea host tests runner (htrun)

Mbed's test suite (codenamed Greentea) supports the test supervisor concept. This concept is realized by this module. htrun is a collection of host tests. Host test is script written in Python, which is executed in parallel with the test suite runner (a binary running on the target hardware / device under test) to monitor the test execution's progress or to control the test flow (interaction with the mbed device under test - DUT). The host test is also responsible for grabbing the test result, or deducing it from the test runner's behavior.

Key-value protocol was developed and is used to provide communication layer between DUT (device under test) and host computer. Key-value protocol defined host computer as master and DUT as slave.

  • Slave side APIs and key-value protocol implementation is encapsulated in greentea-client module.
  • Master side APIs and key-value protocol is encapsulated in htrun.

htrun responsibilities are:

  • Flash mbed device with given binary.
  • Reset mbed device after flashing to start test suite execution.
  • Use key-value protocol to handshake with device and make sure correct host test script is executed to supervise test suite execution.
  • Run key-value protocol state machine and execute event callbacks.
  • Monitor serial port traffic to parse valid key-value protocol events.
  • Make decision if test test suite passed / failed / returned error.
  • Provide command line tool interface, command: htrun after module installation (on host).
  • Provide few basic host test implementations which can be used out of the box for test development. For example the basic host test (called default or default_auto) just parses events from DUT and finished host test execution when end event is received. Other included in this module host tests can help you to test timers or RTC.

Key-value protocol overview

  • Text based protocol, format {{KEY;VALUE}}}.
  • Master-slave mode where host is master and DUT is slave.

Design draft

  • Simple key-value protocol is introduced. It is used to communicate between DUT and host. Protocol main features:
  • Protocol introduced is master-slave protocol, where master is host and slave is device under test.
  • Transport layer consist of simple {{ KEY ; VALUE }} \n text messages sent by slave (DUT). Both key and value are strings with allowed character set limitations (to simplify parsing and protocol parser itself). Message ends with required by DUT K-V parser \n character.
  • DUT always (except for handshake phase) initializes communication by sending key-value message to host.
  • To avoid miscommunication between master and slave simple handshake protocol is introduces:
    • Master (host) sends sync packet: {{__sync;UUID-STRING}}} with message value containing random UUID string.
    • DUT waits for {{__sync;...}} message in input stream and replies with the same packer {{__sync;...}}.
    • After correct sync packet is received by master, messages {{__timeout;%d}} and {{__host_test_name}} are expected.
    • Host parses DUTs tx stream and generates events sent to host test.
    • Each event is a tuple of (key, value, timestamp), where key and value are extracted from message and
  • Host tests are now driven by simple async feature. Event state machine on master side is used to process events from DUT. Each host test is capable of registering callbacks, functions which will be executed when event occur. Event name is identical with KEY in key-value pair send as event from/to DUT.
  • DUT slave side uses simple parser to parse key-value pairs from stream. All non key-value data will be ignored. Blocking wait for an event API is provided: This implies usage of master-slave exchange between DUT and host where DUT uses non-blocking send event API to send to host (master) event and can wait for response. Master implements corresponding response after receiving event and processing data.
    • Message parsing transforms key-value string message to Python event in this order:
      • {{key;value}} string captured on DUT output.
    • key-value data becomes a recognizable message with key (string) and value (string) payload.
    • Event is formed in host test, a tuple of key (string), value (string), timestamp where timestamp is time of message reception in Python time.time() format (float, time in seconds since the epoch as a floating point number.).
  • Each host test registers callbacks for available events.
  • Few keys' names in key-value messaging protocol are promoted to be considered "system events". Their names are used by event loop mechanism to communicate between DUT, host and various internal components. Please do not use restricted even names for your own private events. What's more:
    • User can't register callbacks to "system events" with few exceptions.
    • Reserved event/message keys have leading __ in name:
      • __sync - sync message, used by master and DUT to handshake.
      • __notify_sync_failed - sent by host when sync response not received from DUT.
      • __timeout - timeout in sec, sent by DUT after {{sync;UUID}} is received.
      • __version - greentea-client version send from DUT to host.
      • __host_test_name - host test name, sent by DUT after {{sync;UUID}} is received.
      • __notify_prn - sent by host test to print log message.
      • __notify_conn_lost - sent by host test's connection process to notify serial port connection lost.
      • __notify_complete - sent by DUT, async notificaion about test case result (true, false, none).
      • __coverage_start - sent by DUT, coverage data.
      • __testcase_start - sent by DUT, test case start data.
      • __testcase_finish - sent by DUT, test case result.
      • __exit - sent by DUT, test suite execution finished.
      • __exit_event_queue - sent by host test, indicating no more events expected.
    • Non-Reserved event/message keys have leading __ in name:
      • __rxd_line - Event triggered when \n was found on DUT RXD channel. It can be overridden (self.register_callback('__rxd_line', <callback_function>)) and used by user. Event is sent by host test to notify a new line of text was received on RXD channel. __rxd_line event payload (value) in a line of text received from DUT over RXD.
  • Each host test (master side) has four functions used by async framework:
    • setup() used to initialize host test and register callbacks.
    • result() used to return test case result when notify_complete() is not called.
    • teardown() used to finalize and resource freeing. It is guaranteed that teardown() will be always called after timeout or async test completion().
    • notify_complete(result : bool) used by host test to notify test case result. This result will be read after test suite TIMEOUTs or after DUT send __exit message (test suite execution finished event).
    • self.send_kv(key : string, value : string) - send key-value message to DUT.
    • self.log(text : string) - send event __notify_prn with text as payload (value). Your message will be printed in log.
  • Result returned from host test is a test suite result. Test cases results are reported by DUT, usually using modified utest framework.

Greentea client API

greentea-client is a C++ client library that provides greentea_send_kv API for sending and greentea_parse_kv API to receive key-value pairs with the Greentea host test tool.

  • Slave side key-value protocol API, see here for details.

Key-value transport protocol sequence

Key-value protocol has few parts:

  • Handshake - synchronize master and slave.
  • Preamble exchange - DUT informs host about test parameters such as client version, test suite timeout, requested host test name etc. After this part is finished master will create requested host test and attach callbacks to user events.
  • Event exchange - key-value event exchange between slave and master. In this exchange in general slave (DUT) will initialize communication. This part may end with ending pair of events end and __exit where end event carries test suite result returned by DUT and __exit event marks test suite ended and exited. After __exit event is received there will be no more communication between DUT and host test.

Handshake

Hanshake between DUT and host is a sequence of __sync events send between host (master) and DUT (slave). This is currently only situation when master initiates communication first. Handshake should provide synchronization point where master and slave are starting the same session.

After reset:

  • DUT calls function GREENTEA_SETUP(timeout, "host test name"); which
  • calls immediately greentea_parse_kv (blocking parse of input serial port for event {{__sync;UUID}}).
  • When __sync packet is parsed in the stream DUT sends back (echoes) __sync event with the same UUID as payload. UUID is a random value e.g. 5f8dbbd2-199a-449c-b286-343a57da7a37.
                           DUT (slave)        host (master)
                             -----               -----
                               |                   |
                DUT reset ---> |                   |
                               |                   |
greentea_parse_kv(key,value)   |                   |
-------[ blocking ]----------->|                   |
                               |                   |
                               .                   .
                               .                   .
                               |                   |  self.send_kv("__sync", UUID)
                               |  {{__sync;UUID}}  |<-----------------------------
                               |<------------------|
                               |                   |
                               |                   |
greentea_parse_kv              |  {{__sync;UUID}}  |
echoes __sync event with       |------------------>|
the same UUID to master        |                   |
                               |                   |

Example of handshake from htrun log:

[1458565465.35][SERI][INF] reset device using 'default' plugin...
[1458565465.60][SERI][INF] wait for it...
[1458565466.60][CONN][INF] sending preamble '2f554b1c-bbbf-4b1b-b1f0-f45493282f2c'
[1458565466.60][SERI][TXD] mbedmbedmbedmbedmbedmbedmbedmbedmbedmbed
[1458565466.60][SERI][TXD] {{__sync;2f554b1c-bbbf-4b1b-b1f0-f45493282f2c}}
[1458565466.74][CONN][INF] found SYNC in stream: {{__sync;2f554b1c-bbbf-4b1b-b1f0-f45493282f2c}}, queued...
[1458565466.74][HTST][INF] sync KV found, uuid=2f554b1c-bbbf-4b1b-b1f0-f45493282f2c, timestamp=1458565466.743000
[1458565466.74][CONN][RXD] {{__sync;2f554b1c-bbbf-4b1b-b1f0-f45493282f2c}}

Preamble exchange

This phase comes just after handshake phase. DUT informs host about test parameters such as client version, timeout, requested host test name etc. After this part is finished master will create requested host test and attach callbacks to user events. This phase is ended with __host_test_name being received by host. After __host_test_name event is received

DUT (slave)              host (master)
  -----                     -----
    |                         |
    |    {{__version;%s}}     |
    |------------------------>|
    |                         |
    |    {{__timeout;%d}}     |
    |------------------------>|
    |                         |
    | {{__host_test_name;%s}} |
    |------------------------>|
    |                         |

Example of handshake from htrun log:

  • DUT code:
void main() {
    GREENTEA_CLIENT(5, "default_auto");
    // ...
}
  • Corresponding log:
[1458565466.76][CONN][INF] found KV pair in stream: {{__version;0.1.8}}, queued...
[1458565466.76][CONN][RXD] {{__version;0.1.8}}
[1458565466.76][HTST][INF] DUT greentea-client version: 0.1.8
[1458565466.77][CONN][INF] found KV pair in stream: {{__timeout;5}}, queued...
[1458565466.77][HTST][INF] setting timeout to: 5 sec
[1458565466.78][CONN][RXD] {{__timeout;5}}
[1458565466.81][CONN][INF] found KV pair in stream: {{__host_test_name;default_auto}}, queued...
[1458565466.81][HTST][INF] host test setup() call...
[1458565466.81][HTST][INF] CALLBACKs updated
[1458565466.81][HTST][INF] host test detected: default_auto
[1458565466.81][CONN][RXD] {{__host_test_name;default_auto}}

Event exchange

In this phase DUT and host exchange events and host side is calling callbacks registered to each of the events sent from DUT. DUT can use function greentea_parse_kv to parse input stream for next incoming key-value event. After __host_test_name event is received and before any event is consumed during this stage:

  • Host state machine loads host test object by name provided in payload of __host_test_name event.E.g. event ```{{____host_test_name;default_auto}} will load host test named "default_auto".
  • Host state machine loads callbacks registered by user in host test setup phase and hooks them to event machine. Now host is ready to handle test suite test execution. From this moment each event sent from DUT will be handled by corresponding callback registered by user in host test setup. Unknown events will not be handled and warning will be printed in log.

DUT (slave)      host (master)
  -----             -----
    |                 |
    |                 |        Host Test
    |                 |         -----
    |                 |  create   |
    |                 |---------->|
    |                 |           |
    |                 |           |
    | {{key1;value}}  |           |
    |---------------->|           |          ht.setup()
    |       .         |           |<---[ user register callbacks ]---
    |       .         |           |
    |       .         |           |  host.callbacks.update(ht.get_callbacks())
    |       .         |           |<---[ host state machine ]------------------
    | {{key2;value}}  |           |
    |---------------->|           |
    |                 |           |
    |                 |           |
    |                 |           | ht.callbacks[key1](key, value, timestamp)
    |                 |           |<------------------------------------------
    |                 |           | ht.callbacks[key2](key, value, timestamp)
    |                 |           |<------------------------------------------
    |                 |           |
    |                 |           |
    -  - - - - - - - -  - - - -     - -
          TEST CASE FLOW CONTINUES
    -  - - - - - - - -  - - - -     - -
    |                 |           |
    |                 |           | ht.notify_complete(true)
    |                 |           | (sets test suite 'result' to true
    |                 |           |<----------------
    |                 |           |
    |                 |           |
    | {{end;success}} |           |
    |---------------->|           |
    |                 |           |
    | {{__exit;%d}}   |           |
    |---------------->|           |
    |                 |           |
    |                 |           | result = ht.result()
    |                 |           |<----------------
    |                 |           |
    |                 |           | ht.teardown()
    |                 |           |<----------------
    |                 |           |
    |                 |           |

  • After DUT send __exit or after timeout it is guaranteed that host test teardown() function will be called. This call is blocking, please make sure your tear down function finishes.

DUT - host test case workflow

DUT implementation

int main() {
    // 1. Handshake between DUT and host and
    // 2. Send test case related data
    GREENTEA_SETUP(15, "gimme_auto");  // __timeout, __host_test_name

    // Send to master {{gimme_something; some_stuff}}
    greentea_send_kv("gimme_something", "some_stuff");

    char key[16] = {0};
    char value[32] = {0};
    // Blocking wait for master response for {{gimme_something; some_stuff}}
    greentea_parse_kv(key, value, sizeof(key), sizeof(value));

    fprintf(stderr, "Received from master %s, %s", key, value);
    GREENTEA_TESTSUITE_RESULT(true);    // __exit
}

Example of corresponding host test

class GimmeAuto(BaseHostTest):
    """ Simple, basic host test's test runner waiting for serial port
        output from MUT, no supervision over test running in MUT is executed.
    """

    __result = None
    name = "gimme_auto"

    def _callback_gimme_something(self, key, value, timestamp):
        # You've received {{gimme_something;*}}

        # We will send DUT some data back...
        # And now decide about test case result
        if value == 'some_stuff':
            # Message payload/value was 'some_stuff'
            # We can for example return true from test
            self.send_kv("print_this", "This is what I wanted %s"% value)
            self.notify_complete(True)
        else:
            self.send_kv("print_this", "This not what I wanted :(")
            self.notify_complete(False)

    def setup(self):
        # Register callback for message 'gimme_something' from DUT
        self.register_callback("gimme_something", self._callback_gimme_something)

    def result(self):
        # Define your test result here
        # Or use self.notify_complete(bool) to pass result anytime!
        return self.__result

    def teardown(self):
        # Release resources here after test is completed
        pass

Log:

[1454926794.22][HTST][INF] copy image onto target...
        1 file(s) copied.
[1454926801.48][HTST][INF] starting host test process...
[1454926802.01][CONN][INF] starting connection process...
[1454926802.01][CONN][INF] initializing serial port listener...
[1454926802.01][SERI][INF] serial(port=COM188, baudrate=9600)
[1454926802.02][SERI][INF] reset device using 'default' plugin...
[1454926802.27][SERI][INF] wait for it...
[1454926803.27][CONN][INF] sending preamble '9caa42a0-28a0-4b80-ba1d-befb4e43a4c1'...
[1454926803.27][SERI][TXD] mbedmbedmbedmbedmbedmbedmbedmbedmbedmbed
[1454926803.27][SERI][TXD] {{__sync;9caa42a0-28a0-4b80-ba1d-befb4e43a4c1}}
[1454926803.40][CONN][RXD] {{__sync;9caa42a0-28a0-4b80-ba1d-befb4e43a4c1}}
[1454926803.40][CONN][INF] found SYNC in stream: {{__sync;9caa42a0-28a0-4b80-ba1d-befb4e43a4c1}}, queued...
[1454926803.40][HTST][INF] sync KV found, uuid=9caa42a0-28a0-4b80-ba1d-befb4e43a4c1, timestamp=1454926803.405000
[1454926803.42][CONN][RXD] {{__timeout;15}}
[1454926803.42][CONN][INF] found KV pair in stream: {{__timeout;15}}, queued...
[1454926803.42][HTST][INF] setting timeout to: 15 sec
[1454926803.45][CONN][RXD] {{__host_test_name;gimme_auto}}
[1454926803.45][CONN][INF] found KV pair in stream: {{__host_test_name;gimme_auto}}, queued...
[1454926803.45][HTST][INF] host test setup() call...
[1454926803.45][HTST][INF] CALLBACKs updated
[1454926803.45][HTST][INF] host test detected: gimme_auto
[1454926803.48][CONN][RXD] {{gimme_something;some_stuff}}
[1454926803.48][CONN][INF] found KV pair in stream: {{gimme_something;some_stuff}}, queued...
[1454926803.48][SERI][TXD] {{print_this;This is what I wanted some_stuff}}
[1454926803.48][HTST][INF] __notify_complete(True)
[1454926803.62][CONN][RXD] Received from master print_this, This is what I wanted some_stuf
[1454926803.62][CONN][RXD] {{end;success}}
[1454926803.62][CONN][INF] found KV pair in stream: {{end;success}}, queued...
[1454926803.62][HTST][ERR] orphan event in main phase: {{end;success}}, timestamp=1454926803.625000
[1454926803.63][CONN][RXD] {{__exit;0}}
[1454926803.63][CONN][INF] found KV pair in stream: {{__exit;0}}, queued...
[1454926803.63][HTST][INF] __exit(0)
[1454926803.63][HTST][INF] test suite run finished after 0.21 sec...
[1454926803.63][HTST][INF] exited with code: None
[1454926803.63][HTST][INF] 0 events in queue
[1454926803.63][HTST][INF] stopped consuming events
[1454926803.63][HTST][INF] host test result() skipped, received: True
[1454926803.63][HTST][INF] calling blocking teardown()
[1454926803.63][HTST][INF] teardown() finished
[1454926803.63][HTST][INF] {{result;success}}
mbedgt: mbed-host-test-runner: stopped
mbedgt: mbed-host-test-runner: returned 'OK'
mbedgt: test on hardware with target id: 02400226d94b0e770000000000000000000000002492f3cf
mbedgt: test suite 'mbed-drivers-test-gimme' ......................................................... OK in 10.02 sec
mbedgt: shuffle seed: 0.3631708941
mbedgt: test suite report:
+---------------+---------------+-------------------------+--------+--------------------+-------------+
| target        | platform_name | test suite              | result | elapsed_time (sec) | copy_method |
+---------------+---------------+-------------------------+--------+--------------------+-------------+
| frdm-k64f-gcc | K64F          | mbed-drivers-test-gimme | OK     | 10.02              | shell       |
+---------------+---------------+-------------------------+--------+--------------------+-------------+
mbedgt: test suite results: 1 OK

Host test examples

Return result after __exit

class GimmeAuto(BaseHostTest):
    """ Simple, basic host test's test runner waiting for serial port
        output from MUT, no supervision over test running in MUT is executed.
    """

    __result = None
    name = "gimme_auto"

    def _callback_gimme_something(self, key, value, timestamp):
        # You've received {{gimme_something;*}}

        # We will send DUT some data back...
        # And now decide about test case result
        if value == 'some_stuff':
            # Message payload/value was 'some_stuff'
            # We can for example return true from test
            self.send_kv("print_this", "This is what I wanted %s"% value)
            self.__result = True
        else:
            self.send_kv("print_this", "This not what I wanted :(")
            self.__result = False

    def setup(self):
        # Register callback for message 'gimme_something' from DUT
        self.register_callback("gimme_something", self._callback_gimme_something)

    def result(self):
        # Define your test result here
        # Or use self.notify_complete(bool) to pass result anytime!
        return self.__result

    def teardown(self):
        # Release resources here after test is completed
        pass

Corresponding log:

[1454926627.11][HTST][INF] copy image onto target...
        1 file(s) copied.
[1454926634.38][HTST][INF] starting host test process...
[1454926634.93][CONN][INF] starting connection process...
[1454926634.93][CONN][INF] initializing serial port listener...
[1454926634.93][SERI][INF] serial(port=COM188, baudrate=9600)
[1454926634.94][SERI][INF] reset device using 'default' plugin...
[1454926635.19][SERI][INF] wait for it...
[1454926636.19][CONN][INF] sending preamble '9a743ff3-45e6-44cf-9e2a-9a83e6205184'...
[1454926636.19][SERI][TXD] mbedmbedmbedmbedmbedmbedmbedmbedmbedmbed
[1454926636.19][SERI][TXD] {{__sync;9a743ff3-45e6-44cf-9e2a-9a83e6205184}}
[1454926636.33][CONN][RXD] {{__sync;9a743ff3-45e6-44cf-9e2a-9a83e6205184}}
[1454926636.33][CONN][INF] found SYNC in stream: {{__sync;9a743ff3-45e6-44cf-9e2a-9a83e6205184}}, queued...
[1454926636.33][HTST][INF] sync KV found, uuid=9a743ff3-45e6-44cf-9e2a-9a83e6205184, timestamp=1454926636.331000
[1454926636.34][CONN][RXD] {{__timeout;15}}
[1454926636.34][CONN][INF] found KV pair in stream: {{__timeout;15}}, queued...
[1454926636.34][HTST][INF] setting timeout to: 15 sec
[1454926636.38][CONN][RXD] {{__host_test_name;gimme_auto}}
[1454926636.38][CONN][INF] found KV pair in stream: {{__host_test_name;gimme_auto}}, queued...
[1454926636.38][HTST][INF] host test setup() call...
[1454926636.38][HTST][INF] CALLBACKs updated
[1454926636.38][HTST][INF] host test detected: gimme_auto
[1454926636.41][CONN][RXD] {{gimme_something;some_stuff}}
[1454926636.41][CONN][INF] found KV pair in stream: {{gimme_something;some_stuff}}, queued...
[1454926636.41][SERI][TXD] {{print_this;This is what I wanted some_stuff}}
[1454926636.54][CONN][RXD] Received from master print_this, This is what I wanted some_stuf
[1454926636.54][CONN][RXD] {{end;success}}
[1454926636.54][CONN][INF] found KV pair in stream: {{end;success}}, queued...
[1454926636.55][HTST][ERR] orphan event in main phase: {{end;success}}, timestamp=1454926636.541000
[1454926636.56][CONN][RXD] {{__exit;0}}
[1454926636.56][CONN][INF] found KV pair in stream: {{__exit;0}}, queued...
[1454926636.56][HTST][INF] __exit(0)
[1454926636.56][HTST][INF] test suite run finished after 0.22 sec...
[1454926636.56][HTST][INF] exited with code: None
[1454926636.56][HTST][INF] 0 events in queue
[1454926636.56][HTST][INF] stopped consuming events
[1454926636.56][HTST][INF] host test result(): True
[1454926636.56][HTST][INF] calling blocking teardown()
[1454926636.56][HTST][INF] teardown() finished
[1454926636.56][HTST][INF] {{result;success}}
mbedgt: mbed-host-test-runner: stopped
mbedgt: mbed-host-test-runner: returned 'OK'
mbedgt: test on hardware with target id: 02400226d94b0e770000000000000000000000002492f3cf
mbedgt: test suite 'mbed-drivers-test-gimme' ......................................................... OK in 10.04 sec
mbedgt: shuffle seed: 0.3866075474
mbedgt: test suite report:
+---------------+---------------+-------------------------+--------+--------------------+-------------+
| target        | platform_name | test suite              | result | elapsed_time (sec) | copy_method |
+---------------+---------------+-------------------------+--------+--------------------+-------------+
| frdm-k64f-gcc | K64F          | mbed-drivers-test-gimme | OK     | 10.04              | shell       |
+---------------+---------------+-------------------------+--------+--------------------+-------------+
mbedgt: test suite results: 1 OK

Writing DUT test suite (slave side)

DUT test suite with single test case

We can use few methods to structure out test suite and test cases. Simpliest would be to use greentea-client API and wrap one test case inside out test suite. This way of creating test suite is useful when you want to:

  • write only one test case inside test suite,
  • make example application (example as a test) or
  • when your test suite is calling blocking forever function. For example all types of UDP/TCP servers which run in forever loop are in this category. In this case we do not expect from DUT __exit event at all and host test should be designed in such a way that it always return result.

DUT always finishes execution

In this example DUT code uses greentea-client to sync (GREENTEA_SETUP) and pass result (GREENTEA_TESTSUITE_RESULT) to Greentea. This is very simple example of how you can write tests. Note that in this example test suite only implements one test case. Actually test suite is test case at the same time. Result passed to GREENTEA_TESTSUITE_RESULT will be at the same time test case result.

  • DUT implementation:
#include "greentea-client/test_env.h"

int app_start(int, char*[]) {

    bool result = true;
    GREENTEA_SETUP(15, "default_auto");

    // test case execution and assertions

    GREENTEA_TESTSUITE_RESULT(result);
    return 0;
}

DUT test suite never finishes execution

Test suite is implemented so that it will never exit / finish its execution. For example main() or app_start() functions are implemented using infinite (endless) loop. This property have for example UDP/TCP servers (listening forever), all sorts of echo servers etc.

In this example DUT code uses greentea-client to sync (GREENTEA_SETUP) with Greentea. We are not calling GREENTEA_TESTSUITE_RESULT(result) at any time. In this example host test is responsible for providing test suite result using self.notify_complete() API or self.result() function.

You need to write and specify by name your custom host test:

  • DUT side uses second argument of GREENTEA_SETUP(timeout, host_test_name) function:
GREENTEA_SETUP(15, "wait_us_auto");
  • You need to place your custom host test in <module>/test/host_tests directory.

    • Do not forget to name host test accordingly. See below example host test name class member.
  • DUT implementation using my_host_test custom host test:

#include "greentea-client/test_env.h"

void recv() {
    // receive from client
}

int app_start(int, char*[]) {

    Ethernet eth(TCP_SERVER, PORT, recv);
    GREENTEA_SETUP(15, "my_host_test");

    eth.listen();   // Blocking forever

    return 0;
}
  • Example host test template:
from htrun import BaseHostTest

class YourCustomHostTest(BaseHostTest):

    name = "my_host_test"   # Host test names used by GREENTEA_CLIENT(..., host_test_name)

    __result = False    # Result in case of timeout!

    def _callback_for_event(self, key, value, timestamp):
        #
        # Host test API:
        #
        # self.notify_complete(result : bool)
        #
        # """! Notify main even loop that host test finished processing
        #      @param result True for success, False failure. If None - no action in main even loop
        # """
        #
        # self.send_kv(key : string, value : string)
        #
        # """! Send Key-Value data to DUT
        #      @param key Event key
        #      @param value Event payload
        # """
        #
        # self.log(text : string)
        #
        # """! Send log message to main event loop
        #      @param text log message
        # """
        pass

    def setup(self):
        # TODO:
        # * Initialize your resources
        # * Register callbacks:
        #
        # Host test API:
        #
        # self.register_callback(event_name, callable, force=False)
        #
        # """! Register callback for a specific event (key: event name)
        #     @param key String with name of the event
        #     @param callback Callable which will be registered for event "key"
        #     @param force God mode, if set to True you can add callback on any system event
        # """
        pass

    def teardown(self):
        # Destroy all resources used by host test.
        # For example open sockets, open files, auxiliary threads and processes.
        pass

    def result(self):
        # Returns host test result (True, False or None)
        # This function will be called when test suite ends (also timeout).
        # Use when you want to pass result after host state machine stops.
        return __result

Parsing text received from DUT (line by line)

Example of host test expecting Runtime error ... CallbackNode ... string in DUT output. We will use allowed to override __rxd_line event to hook to DUT RXD channel lines of text.

Before Greentea v0.2.0

from sys import stdout
from htrun import BaseHostTest

class DetectRuntimeError(BaseHostTest):

    name = 'detect_runtime_error'

    def test(self, selftest):
        result = selftest.RESULT_FAILURE
        try:
            while True:
                line = selftest.mbed.serial_readline()

                if line is None:
                    return selftest.RESULT_IO_SERIAL

                stdout.write(line)
                stdout.flush()

                line = line.strip()

                if line.startswith("Runtime error") and line.find("CallbackNode") != -1:
                    result = selftest.RESULT_SUCCESS
                    break

        except KeyboardInterrupt, _:
            selftest.notify("\r\n[CTRL+C] exit")
            result = selftest.RESULT_ERROR

        return result

Using __rdx_line event

from htrun import BaseHostTest

class DetectRuntimeError(BaseHostTest):
    """! We _expect_ to detect 'Runtime error' """

    __result = False

    def callback__rxd_line(self, key, value, timeout):
        #
        # Parse line of text received over e.g. serial from DUT
        #
        line = value.strip()
        if line.startswith("Runtime error") and "CallbackNode" in line:
            # We've found exepcted "Runtime error" string in DUTs output stream
            self.notify_complete(True)

    def setup(self):
        # Force, we force callback registration even it is a restricted one (starts with '__')
        self.register_callback('__rxd_line', self.callback__rxd_line, force=True)

    def result(self):
        # We will return here (False) when we reach timeout of the test
        return self.__result

    def teardown(self):
        pass

htrun new log format:

  • [timestamp][source][level] - new log format, where:
    • timestamp - returned by Python's time.time().
    • source - log source.
      • CONN - connection process (pooling for connection source e.g. serial port),
      • SERI - serial port wrapper with standard read, write, flush interface,
      • HTST - host test object, HostTestBase derived object,
      • PLGN - host test plugins, type BasePlugin of the plugin,
      • COPY - host test plugins, type CopyMethod of the plugin,
      • REST - host test plugins, type ResetMethod of the plugin,
    • level - logging level:
      • INF (info),
      • WRN (warning),
      • ERR (error).
      • TXD (host's TX channel, to DUT).
      • RXD (host's RX channel, from DUT).

Log example

  • [1455218713.87][CONN][RXD] {{__sync;a7ace3a2-4025-4950-b9fc-a3671103387a}}:
  • Logged from CONN (connection process).
  • RXD channel emitted {{__sync;a7ace3a2-4025-4950-b9fc-a3671103387a}}.
  • Time stamp: 2016-02-11 19:53:27, see below:

Plugins

In order to work with platforms for which the hardware is still under development, and hence may not have an mbed interface chip, some "hook" files are required. Operation with these platforms is a matter for the platform development teams involved and is not, in general, supported by ARM.

SARA NBIOT EVK

The SARA NBIOT EVK board must be connected to a Windows PC using a Segger JLink box, which is used for downloading code and resetting the board. The USB port on the EVK must also be connected to the same PC. To make use of these hooks you will also require access to some proprietary tools that can be requested from u-blox.

Testing mbed-os examples

mbed-os examples are essentially sample apps written as inspirational code for developers to understand the mbed-os APIs and coding paradigms. Before every mbed-os release all examples are tested across all supported configs and platforms. There is already a large set examples available and as they grow it is important to automate them. Hence automating examples make sense. Although it is important not to pollute them with test like instrumentation. As that will defeat the purpose of examples being simple and specific.

Hence the strategy for testing examples is based on observation instead of interaction. An example's serial logging is captured and converted into a templated log. All successive executions of this example should match this log.

Templated log simply means a log with text that does not change or regular expressions replacing original text. Below is an example of the templated log:


							      >	Using Ethernet LWIP

							      >	Client IP Address is 10.2.203.139

							      >	Connecting with developer.mbed.org

Starting the TLS handshake...								Starting the TLS handshake...

							      >	TLS connection to developer.mbed.org established

Server certificate:								Server certificate:

							      >
								    cert. version     : 3
							      >
								    serial number     : 11:21:B8:47:9B:21:6C:B1:C6:AF:BC:5D:0
							      >
								    issuer name       : C=BE, O=GlobalSign nv-sa, CN=GlobalSi
							      >
								    subject name      : C=GB, ST=Cambridgeshire, L=Cambridge,
							      >
								    issued  on        : 2016-03-03 12:26:08
							      >
								    expires on        : 2017-04-05 10:31:02
							      >
								    signed using      : RSA with SHA-256
							      >
								    RSA key size      : 2048 bits
							      >
								    basic constraints : CA=false
							      >
								    subject alt name  : *.mbed.com, mbed.org, *.mbed.org, mbe
							      >
								    key usage         : Digital Signature, Key Encipherment
							      >
								    ext key usage     : TLS Web Server Authentication, TLS We

Certificate verification passed								Certificate verification passed




							      >	HTTPS: Received 439 chars from server

							      >	HTTPS: Received 200 OK status ... [OK]

HTTPS: Received 'Hello world!' status ... [OK]								HTTPS: Received 'Hello world!' status ... [OK]

HTTPS: Received message:								HTTPS: Received message:




							      >	HTTP/1.1 200 OK

							      >	Server: nginx/1.7.10

							      >	Date: Thu, 01 Dec 2016 13:56:32 GMT

							      >	Content-Type: text/plain

							      >	Content-Length: 14

							      >	Connection: keep-alive

							      >	Last-Modified: Fri, 27 Jul 2012 13:30:34 GMT

							      >	Accept-Ranges: bytes

							      >	Cache-Control: max-age=36000

							      >	Expires: Thu, 01 Dec 2016 23:56:32 GMT

							      >	X-Upstream-L3: 172.17.0.3:80

							      >	X-Upstream-L2: developer-sjc-indigo-2-nginx

							      >	Strict-Transport-Security: max-age=31536000; includeSubdomain




Hello world!								Hello world!

Please observe above that all the lines that have data that changes from execution to execution (on right) have been removed. It makes it possible htrun to compare these logs. htrun matches lines from the compare log (on left) one by one. It keeps on looking for a line until it matches. Once matched it moves on to match the next line. If it finds all lines from the compare log in the target serial output stream. Then it halts and passes the examples.

Another example with regular examples is shown below:


  SHA-256                  :\s*\d+ Kb/s,\s*\d+ cycles/byte							      |	  SHA-256                  :       1922 Kb/s,         61 cycl

  SHA-512                  :\s*\d+ Kb/s,\s*\d+ cycles/byte							      |	  SHA-512                  :        614 Kb/s,        191 cycl

  AES-CBC-128              :\s*\d+ Kb/s,\s*\d+ cycles/byte							      |	  AES-CBC-128              :       1401 Kb/s,         83 cycl

  AES-CBC-192              :\s*\d+ Kb/s,\s*\d+ cycles/byte							      |	  AES-CBC-192              :       1231 Kb/s,         95 cycl

  AES-CBC-256              :\s*\d+ Kb/s,\s*\d+ cycles/byte							      |	  AES-CBC-256              :       1097 Kb/s,        106 cycl

  AES-GCM-128              :\s*\d+ Kb/s,\s*\d+ cycles/byte							      |	  AES-GCM-128              :        429 Kb/s,        273 cycl

  AES-GCM-192              :\s*\d+ Kb/s,\s*\d+ cycles/byte							      |	  AES-GCM-192              :        412 Kb/s,        285 cycl

  AES-GCM-256              :\s*\d+ Kb/s,\s*\d+ cycles/byte							      |	  AES-GCM-256              :        395 Kb/s,        297 cycl

  AES-CCM-128              :\s*\d+ Kb/s,\s*\d+ cycles/byte							      |	  AES-CCM-128              :        604 Kb/s,        194 cycl

  AES-CCM-192              :\s*\d+ Kb/s,\s*\d+ cycles/byte							      |	  AES-CCM-192              :        539 Kb/s,        217 cycl

  AES-CCM-256              :\s*\d+ Kb/s,\s*\d+ cycles/byte							      |	  AES-CCM-256              :        487 Kb/s,        241 cycl

  CTR_DRBG \(NOPR\)          :\s*\d+ Kb/s,\s*\d+ cycles/byte							      |	  CTR_DRBG (NOPR)          :       1145 Kb/s,        102 cycl

  CTR_DRBG \(PR\)            :\s*\d+ Kb/s,\s*\d+ cycles/byte							      |	  CTR_DRBG (PR)            :        821 Kb/s,        142 cycl

  HMAC_DRBG SHA-256 \(NOPR\) :\s*\d+ Kb/s,\s*\d+ cycles/byte							      |	  HMAC_DRBG SHA-256 (NOPR) :        219 Kb/s,        537 cycl

  HMAC_DRBG SHA-256 \(PR\)   :\s*\d+ Kb/s,\s*\d+ cycles/byte							      |	  HMAC_DRBG SHA-256 (PR)   :        193 Kb/s,        612 cycl

  RSA-2048                 :\s*\d+ ms/ public							      |	  RSA-2048                 :      30 ms/ public

  RSA-2048                 :\s*\d+ ms/private							      |	  RSA-2048                 :    1054 ms/private

  RSA-4096                 :\s*\d+ ms/ public							      |	  RSA-4096                 :     101 ms/ public

  RSA-4096                 :\s*\d+ ms/private							      |	  RSA-4096                 :    5790 ms/private

  ECDHE-secp384r1          :\s*\d+ ms/handshake							      |	  ECDHE-secp384r1          :    1023 ms/handshake

  ECDHE-secp256r1          :\s*\d+ ms/handshake							      |	  ECDHE-secp256r1          :     678 ms/handshake

  ECDHE-Curve25519         :\s*\d+ ms/handshake							      |	  ECDHE-Curve25519         :     580 ms/handshake

  ECDH-secp384r1           :\s*\d+ ms/handshake							      |	  ECDH-secp384r1           :     503 ms/handshake

  ECDH-secp256r1           :\s*\d+ ms/handshake							      |	  ECDH-secp256r1           :     336 ms/handshake

  ECDH-Curve25519          :\s*\d+ ms/handshake							      |	  ECDH-Curve25519          :     300 ms/handshake

To capture a log use following option:

htrun -d D: -p COM46 -m K64F -f .\BUILD\K64F\GCC_ARM\benchmark.bin --serial-output-file compare.log

Option --serial-output-file takes file name as argument and writes the target serial output to the file. Edit the file to remove lines that will change in successive executions. Put regular expressions if needed at places like benchmark numbers in above log. With these edits you are left with a template good for comparison.

Use following command to test the example and the comparison log:

htrun -d D: -p COM46 -m K64F -f .\BUILD\K64F\GCC_ARM\benchmark.bin --compare-log compare.log

In case an application requires more time to process data and generate results, you can use the option --polling-timeout to override the default timeout setting.

A tested comparison log can be checked into GitHub with the examples and can be used in the CI for example verification.

greentea's People

Contributors

adbridge avatar bittailor avatar bogdanm avatar bridadan avatar c1728p9 avatar cmonr avatar conorpkeegan avatar geky avatar ithinuel avatar jacobrosenthal avatar jeromecoutant avatar kegilbert avatar liyouzhou avatar mazimkhan avatar mlnx avatar mray190 avatar patater avatar pi-anl avatar przemekwirkus avatar rajkan01 avatar rwalton-arm avatar sentimentron avatar studavekar avatar theotherjimmy avatar wernerlewis avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

greentea's Issues

[devel_transport] Junit reporting incosistent data

Greentea reports when fail not showing full list of test cases they should cover.
We get drops in test case e4xecution and no "red" chart part for test case execution trend.

Example:

<testsuites errors="1" failures="1" skipped="0" tests="2" time="27.3049998283">
    <testsuite errors="0" failures="0" name="core-util.frdm-k64f-armcc" skipped="0" tests="0" time="0"/>
    <testsuite errors="0" failures="0" name="core-util.frdm-k64f-armcc" skipped="0" tests="0" time="0"/>
    <testsuite errors="0" failures="0" name="core-util.frdm-k64f-armcc" skipped="0" tests="0" time="0"/>
    <testsuite errors="0" failures="0" name="core-util.frdm-k64f-armcc" skipped="0" tests="0" time="0"/>
    <testsuite errors="0" failures="0" name="core-util.frdm-k64f-armcc" skipped="0" tests="0" time="0"/>
    <testsuite errors="0" failures="1" name="core-util.frdm-k64f-armcc" skipped="0" tests="1" time="9.06999993324"></testsuite>
    <testsuite errors="0" failures="0" name="core-util.frdm-k64f-armcc" skipped="0" tests="0" time="0"/>
    <testsuite errors="0" failures="0" name="core-util.frdm-k64f-armcc" skipped="0" tests="0" time="0"/>
    <testsuite errors="1" failures="0" name="core-util.frdm-k64f-armcc" skipped="0" tests="1" time="18.2349998951">
        <testcase classname="core-util.frdm-k64f-armcc.core-util-test-sbrk-mini" name="sbrk-mini" time="18.235000">
            <error type="error">[1456748505.39][HTST][INF] copy image onto target...
                1 file(s) copied.
            </error>
</testsuite>
</testsuites>

mbedgt fails to run mbed 3.0 tests as configured on jenkins

Please review the logs at the following locations to determine the mbedgt problem(s) causing the tests not to run:

http://10.2.202.156:8080/view/mbed_3.0/job/mbed_3.0_build_test_mbed_net_socket_abstract_Freescale_FRDM_K64F_arm/5/consolehttp://10.2.202.156:8080/view/mbed_3.0/job/mbed_3.0_build_test_mbed_net_socket_abstract_Freescale_FRDM_K64F_arm/5/console

mbedgt: calling yotta to build your sources and tests: yotta -v --target=frdm-k64f-armcc,* build
mbedgt: [ret=1] Command: ['yotta', '-v', '--target=frdm-k64f-armcc,*', 'build']
mbed-ls: detected KL46Z, console at: COM27, mounted at: P:
========================================= =========================================

All tests result in IOERR_SERIAL on Linux

Here is the console output.
Even with the new firmware for FRDM-k64f board, I get the same error.

hasnain@ubuntu:~/Documents/mbed-drivers$ mbedgt --target=frdm-k64f-gcc
mbedgt: yotta search for existing mbed-target
mbedgt: current yotta target is: not set
mbed-ls: detecting connected mbed-enabled devices...
detected K64F, console at: /dev/ttyACM0, mounted at: /media/hasnain/MBED
mbedgt: scan available targets for 'K64F' platform...
mbedgt: yotta search for mbed-target:k64f
mbedgt: using 'frdm-k64f-gcc' target, prepare to build
mbedgt: calling yotta to build your sources and tests: yotta -v --target=frdm-k64f-gcc,* build
info: generate for target: frdm-k64f-gcc 0.0.23 at /home/hasnain/Documents/mbed-drivers/yotta_targets/frdm-k64f-gcc
GCC version is: 4.9.3
-- Configuring done
-- Generating done
-- Build files have been written to: /home/hasnain/Documents/mbed-drivers/build/frdm-k64f-gcc
ninja: no work to do.
mbedgt: yotta build successful
mbedgt: running tests for 'frdm-k64f-gcc' target
running host test...
test 'mbed-drivers-test-echo' .......................................................... IOERR_SERIAL in 17.34 sec
running host test...
test 'mbed-drivers-test-time_us' ....................................................... IOERR_SERIAL in 16.84 sec
running host test...
test 'mbed-drivers-test-serial_interrupt' .............................................. IOERR_SERIAL in 17.37 sec
running host test...
test 'mbed-drivers-test-blinky' ........................................................ IOERR_SERIAL in 16.87 sec
running host test...
test 'mbed-drivers-test-functionpointer' ............................................... IOERR_SERIAL in 16.84 se

[devel_transport] Error when decoding 'socket' test results

01:02:17 Traceback (most recent call last):
01:02:17   File "C:\jslv3_2\ws\gtt\venv\Scripts\mbedgt-script.py", line 9, in <module>
01:02:17     load_entry_point('mbed-greentea', 'console_scripts', 'mbedgt')()
01:02:17   File "c:\jslv3_2\ws\gtt\venv\src\mbed-greentea\mbed_greentea\mbed_greentea_cli.py", line 315, in main
01:02:17     cli_ret = main_cli(opts, args)
01:02:17   File "c:\jslv3_2\ws\gtt\venv\src\mbed-greentea\mbed_greentea\mbed_greentea_cli.py", line 842, in main_cli
01:02:17     junit_report = exporter_testcase_junit(test_report, test_suite_properties=yotta_module.get_data())
01:02:17   File "c:\jslv3_2\ws\gtt\venv\src\mbed-greentea\mbed_greentea\mbed_report_api.py", line 203, in exporter_testcase_junit
01:02:17     tc_stderr = test['single_test_output'].decode('unicode_escape').encode('ascii','ignore')
01:02:17 UnicodeDecodeError: 'unicodeescape' codec can't decode bytes in position 25420-25421: truncated \UXXXXXXXX escape

Full console here: http://e108747.cambridge.arm.com:8080/job/gtt/205/console

Improve ambiguous missing serial port error message

Currently, when greentea can't find the serial port, it outputs an ambiguous error message that doesn't indicate to the user what went wrong or how to fix the problem.

$ mbedgt -V 
mbedgt: checking for yotta target in current directory
        reason: no --target switch set
mbedgt: checking yotta target in current directory
        calling yotta: yotta --plain target
mbedgt: assuming default target as 'frdm-k64f-gcc'
mbedgt: detecting connected mbed-enabled devices...
mbedgt: detected 1 device
mbedgt: can't detect all properties of the device!
        use 0 instances for testing
mbedgt: no platform/target matching tests were found!
mbedgt: no target matching platforms were found!
mbedgt: exited with code -110
mbedgt: completed in 0.39 sec
$ mbedls
+---------------------+----------------------------+---------------------+-------------------+--------------------------------+
|platform_name        |platform_name_unique        |mount_point          |serial_port        |target_id                       |
+---------------------+----------------------------+---------------------+-------------------+--------------------------------+
|K64F                 |K64F[0]                     |/Volumes/MBED        |unknown            |0240020152A06E54AF5E93EC        |
+---------------------+----------------------------+---------------------+-------------------+--------------------------------+

This error message should be improved to indicate to the user what went wrong exactly: that greentea can't find the serial port for the device.

[devel_transport] Add greentea-client dependency detection

Change:

  • In order to detect if yotta module is using greentea-client (and new Greentea 0.2.x with async host test model) we need to add API for Greentea before and after devel_transport changes.
  • Greentea before v0.2.x (mbed-greentea<0.2.0) should:
    • detect presence of greentea-client dependency/testDependency (in module.json) and if such exist propose upgrade to latest greentea: pip install mbed-greentea>=0.2.0 --upgrade.
    • if no greentea-client dependency/testDependency in yotta module - normal operation.
  • Greentea from v0.2.0 (mbed-greentea>=0.2.0) should:
    • detect presence of greentea-client dependency/testDependency (in module.json) - normal operation.
    • if no greentea-client dependency/testDependency in yotta module (in module.json):
      • Propose downgrade to Greentea before v0.2.0: pip install mbed-greentea<0.2.0 --upgrade or
      • propose solution (point to porting guide for new async model).

Failing tests should dump their console output by default

A failing test should show its console output once failure has been detected.

The first person to notice a failing test may not be the original author of the change. Having tests dump console output will help reduce the time it takes to do root-cause analysis.

All tests result in IOERR_SERIAL on Linux

Everything works fine for setting up the machine.

However when the results are started by 'mbedgt --target=frdm-k64f-gcc' , all the test results in 'IOERR_SERIAL'

Check localy downloaded targets for 'mbed-target' keyword

Currently Greentea uses only yotta search command to check if given board name (platform_name) is compatible with given yotta target.
We should also scal locally in module for target.json files and add this to compatibility list.

Use 115200 baudrate for test execution

Brendan made some changes to target.json and configurationto use default 115k as test case baudrate.
We need to align to changes made.

See my comments to this change: ARMmbed/mbed-drivers#128 (comment)

Note 1: Configuration should be read from config.json.
Note 2: Brendan told me that default 115k baud-rate is a default value set in requirement.

No platform or test found - warning level

All mbedgt printed are green (info level), thus there are two warings/or potentially error from a user (no test found).

mbedgt: yotta build for target 'frdm-k64f-gcc' was successful
mbedgt: test case filter (specified with -n option)
        test name 'socket-test-test-tcp_echo_client_v0' not found in CTestTestFile.cmake (specified with -n option)
mbedgt: invalid test case names (specified with -n option)
        note: test case names are case sensitive
        note: see list of available test cases below
mbedgt: available tests for built targets, location 'C:\Code\git_repo\github\yotta_thing\niklas-socket-test\build'
        target 'frdm-k64f-gcc':
        test 'socket-test-test-time_protocol_v0'
        test 'socket-test-test-udp_echo_server_v0'
        test 'socket-test-test-tcp_client_echo_v0'
        test 'socket-test-test-dns_resolve_v0'
        test 'socket-test-test-tcp_download_v0'
        test 'socket-test-test-socket_addr_v0'
mbedgt: running 0 tests for target 'frdm-k64f-gcc' and platform 'K64F'
        use 1 instance for testing
mbedgt: no platform/target matching tests were found!

List - if no test available, the output is nto clear

\mbed-drivers (master)
ฮป mbedgt --list
mbedgt: available tests for built targets, location 'C:\Code\git_repo\github\yotta_thing\mbed-drivers\build'

Example: execute 'mbedgt -t TARGET_NAME -n TEST_NAME' to run test TEST_NAME for target TARGET_NAME

It does not release the serial port when timeouts

It's happening lately that I have to restart a board. I could not find this reported (open or close), I recall it was already reported.

Env:
Target: k64f, OS: windows, mbedgt 0.1.14

// mbedgt time-outs because of the test block
// running mbedgt again
mbedgt: mbed-host-test-runner: started
MBED: Instrumentation: "COM64" and disk: "D:"
HOST: Copy image onto target...
        1 file(s) copied.
HOST: Initialize serial port...
........................................mbedgt: mbed-host-test-runner: stopped
mbedgt: mbed-host-test-runner: returned 'TIMEOUT'

Host test process is not being killed

An example, udp server is not terminated when a test timeouts, this is observed under windows.

An example of the udp server:

# Copyright 2015 ARM Limited
#
# Licensed under the Apache License, Version 2.0
# See LICENSE file for details.

import sys
import socket
import time
from sys import stdout
from SocketServer import BaseRequestHandler, UDPServer
from mbed_host_tests import BaseHostTest

class UDPEchoClient_Handler(BaseRequestHandler):
    def handle(self):
        """ One handle per connection
        """
        data, socket = self.request
        if '{{end}}' in data:
            print
            print data
        else:
            stdout.write('HOST: {:>4} <= {}'.format(len(data), data))
        socket.sendto(data, self.client_address)

class UDPEchoClientTest(BaseHostTest):
    """
    """
    name = 'sockets_udp_echo_client'

    def send_server_ip_port(self, selftest, ip_address, port_no):
        c = selftest.mbed.serial_readline() # 'UDPCllient waiting for server IP and port...'
        if c is None:
            selftest.print_result(selftest.RESULT_IO_SERIAL)
            return
        selftest.notify(c.strip())

        # time.sleep(2)

        connection_str = ip_address + ":" + str(port_no) + "\n"
        selftest.notify("HOST: Sending server IP Address to target... {}".format(connection_str))
        selftest.mbed.serial_write(connection_str)

        c = selftest.mbed.serial_readline() # 'UDPCllient waiting for server IP and port...'
        if c is None:
            self.print_result(selftest.RESULT_IO_SERIAL)
            return
        selftest.notify(c.strip())
        return selftest.RESULT_PASSIVE

    def test(self, selftest):
        # We need to discover SERVEP_IP and set up SERVER_PORT
        # Note: Port 7 is Echo Protocol:
        #
        # Port number rationale:
        #
        # The Echo Protocol is a service in the Internet Protocol Suite defined
        # in RFC 862. It was originally proposed for testing and measurement
        # of round-trip times[citation needed] in IP networks.
        #
        # A host may connect to a server that supports the Echo Protocol using
        # the Transmission Control Protocol (TCP) or the User Datagram Protocol
        # (UDP) on the well-known port number 7. The server sends back an
        # identical copy of the data it received.
        SERVER_IP = str(socket.gethostbyname(socket.getfqdn()))
        SERVER_PORT = 32765

        # Returning none will suppress host test from printing success code
        self.server = UDPServer((SERVER_IP, SERVER_PORT), UDPEchoClient_Handler)
        self.server.allow_reuse_address = True
        print "HOST: Listening for UDP connections: " + SERVER_IP + ":" + str(SERVER_PORT)
        self.send_server_ip_port(selftest, SERVER_IP, SERVER_PORT)
        try:
           self.server.serve_forever()
        except:
            self.rampDown()

    def rampDown(self):
        self.server.server_close()

# if __name__ == '__main__':
#     UDPEchoClientTest().test()

Support for J-Link to flash target

Hi,
MbedOS porting on new microcontroller is in progress. Currently I can use only J-Link to flash binaries onto my board. But mbedhtrun expects below copy methods to flash binary:
-c COPY_METHOD, --copy=COPY_METHOD
Copy (flash the target) method selector. Plugin
support: copy, cp, default, eACommander, eACommander-
usb, shell, shutil, stlink, xcopy
Is there a way to use J-Link to flash binary in mbedhtrun command?

mbed-greentea doesn't install using python 3

PS C:\Users\robtay01\Documents\GitHub\testbench-agent> pip install mbed-greentea
Collecting mbed-greentea
  Downloading mbed-greentea-0.1.19.zip (84kB)
    100% |################################| 86kB 3.7MB/s
Collecting PrettyTable>=0.7.2 (from mbed-greentea)
  Downloading prettytable-0.7.2.tar.bz2
Collecting PySerial==2.7 (from mbed-greentea)
  Downloading pyserial-2.7.tar.gz (122kB)
    100% |################################| 122kB 2.3MB/s
Collecting mbed-host-tests>=0.1.18 (from mbed-greentea)
  Downloading mbed-host-tests-0.1.24.zip (102kB)
    100% |################################| 106kB 3.4MB/s
Collecting mbed-ls (from mbed-greentea)
  Downloading mbed-ls-0.1.29.zip (55kB)
    100% |################################| 57kB 4.6MB/s
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 20, in <module>
      File "C:\Users\robtay01\AppData\Local\Temp\pip-build-gmyho16q\mbed-ls\setup.py", line 38, in <module>
        long_description=read('README.md'),
      File "C:\Users\robtay01\AppData\Local\Temp\pip-build-gmyho16q\mbed-ls\setup.py", line 33, in read
        return open(os.path.join(os.path.dirname(__file__), fname)).read()
      File "c:\users\robtay01\appdata\local\programs\python\python35\lib\encodings\cp1252.py", line 23, in decode
        return codecs.charmap_decode(input,self.errors,decoding_table)[0]
    UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position 11113: character maps to <undefined>

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in C:\Users\robtay01\AppData\Local\Temp\pip-build-gmyho16q\m
bed-ls
You are using pip version 7.1.2, however version 8.0.2 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.

Please add support for coverage output

This implements the host side of gcov code coverage on mbed-gcc. The device side is implemented in:

When a test completes, MBED_HOSTTEST_RESULT() emits either {{success}} or {{failure}} and {{end}} as normal. Following {{end}}, gcov_exit() is invoked. gcov expects to be operating on a filesystem, where the code was compiled, so it attempts to output to gcda files in the same directory as the object file that they cover. _open() is overridden to output the file name in a greentea-style output tag. _write is overridden to output hex-encoded bytes, and close is overridden to encode another greentea-style output tag for example:

{{timeout;20}}
{{host_test_name;default_auto}}
{{description;Basic}}
{{test_id;MBED_A1}}
{{start}}
{{success}}
{{end}}
{{coverage_start;path/to/build/frdm-k64f-gcc/ym/ualloc/source/CMakeFiles/ualloc.dir/malloc.c.gcda}}
616463677238303436e9841b000000a370000000743e2891d40d000001000000b67a050000000000
1fae0000000000001fae000000000000ff3fc5000000000200000000000000000000000000000000
00000000000000005f0b000000000000000000000000000000000000800100000100000000000000
80010000000000009700000002000000000000002e01000000000000060000000300000000000000
12000000000000000800000004000000000000002000000000000000050000000500000000000000
19000000000000000800000006000000000000003000000000000000090000000700000000000000
3f000000000000000d00000008000000000000006900000000000000040000000b00000000000000
2c000000000000000a0000000c000000000000007c00000000000000030000000e00000000000000
2c000000000000000400000010000000000000004000000000000000050000001500000000000000
69000000000000000100000020000000000000002000000000000000010000003200000000000000
32000000000000000100000066000000000000006600000000000000080000007700000000000000
b803000000000000080000001fae000000000000f870050000000000000000010300000005000000
9d555c453eb2bbc00000a10104000000000000000000000000000000000000000000000103000000
040000001f1780513eb2bbc00000a101040000000000000000000000000000000000000000000001
03000000030000005bd527c2f94ab37c0000a1010400000000000000000000000000000000000000
000000010300000002000000a37cb51df94ab37c0000a10104000000000000000000000000000000
000000000000000103000000010000006d9f0213f94ab37c0000a101040000000500000000000000
050000000000000000000000{{coverage_end}}

Ideally, greentea would read this output and create a file at path/to/build/frdm-k64f-gcc/ym/ualloc/source/CMakeFiles/ualloc.dir/malloc.c.gcda and populate it with the binary equivalent of everything between the coverage tags. The {{coverage_start;<path>}} and {{coverage_end}} tags can occur many times, one of each file in the build.

Currently, only gcov output is supported, since it can be generated without a trace port.

One possible optimization would be to add a command to change the serial port speed when the coverage output starts. Coverage of even mbed-test-basic generates enormous quantities of data.

cc @PrzemekWirkus

Selftest - synch method to wait client

We are having currently problems with serial when printing some additional data, the snippet shows it how:

client side

    MBED_HOSTTEST_TIMEOUT(40);
    MBED_HOSTTEST_SELECT(sockets_udp_echo_client);
    MBED_HOSTTEST_DESCRIPTION(UDP Echo Server);
    MBED_HOSTTEST_START("MBED_OS");

    static EthernetInterface eth;
    TEST_ASSERT_EQUAL(0, eth.init());
    TEST_ASSERT_EQUAL(0, eth.connect());
    TEST_ASSERT_EQUAL(SOCKET_ERROR_NONE, lwipv4_socket_init());

    sock = new UDPSocket(SOCKET_STACK_LWIP_IPV4);
    TEST_ASSERT_NOT_NULL(sock);

    sock->setOnError(on_error);
    sock->setOnReadable(on_rx);

    TEST_ASSERT_EQUAL(SOCKET_ERROR_NONE, sock->open(SOCKET_AF_INET4));

    status_t status = greentea_test_setup_handler(number_of_cases);
    printf("MBED: UDPClient IP Address is %s\n", eth.getIPAddress());
    printf("MBED: UDPClient waiting for server IP and port...\n");
    // scan for an IP Address and set it
   // here block client  until the ip address is received from HOST

host side:

    def send_server_ip_port(self, selftest, ip_address, port_no):
        connection_str = ip_address + ":" + str(port_no) + "\n"
        selftest.notify("HOST: Sending server IP Address to target... {}".format(connection_str))
        selftest.mbed.serial_write(connection_str)
        return selftest.RESULT_PASSIVE

    def test(self, selftest):
        SERVER_IP = str(socket.gethostbyname(socket.getfqdn()))
        SERVER_PORT = 32765

        server = UDPServer((SERVER_IP, SERVER_PORT), UDPEchoClient_Handler)
        server.allow_reuse_address = True
        selftest.dump_serial()
        self.send_server_ip_port(selftest, SERVER_IP, SERVER_PORT)
        server.serve_forever()

The above works if 2 prints are removed from the client side. The idea here is to create a method for selftest to read the input from a client until there's a string match ? Client would send "Waiting for IP", the host test would do selftest.mbed.string_match('Waiting for IP').

Any other ideas for this?

[Concept] Add support for test case id tagging

Description

One binary can contain may test cases (test fixtures) with a unique test case ids.
We could add support to yield many test case id results per one test case execution.

Related PRs and changes:

New success code for test case

New success code for test case is an integer with following properties:
Range of MBED_HOSTTEST_TESTCASE_FINISH() success:

+---------------+--------------+---------------+
|  success < 0  | success == 0 |  success > 0  |
+---------------+--------------+---------------+
| <------ ERROR |      OK      | FAIL -------> |
+---------------+--------------+---------------+

Example simple test case inside current test source code

// Somewhere in C++ test case file in your yotta module...
// My test case TESTCASE_NAME implementation
{
    int success = 0; // 0 for success! ;)
    MBED_HOSTTEST_TESTCASE_START(TESTCASE_NAME);

    // Do your testing bit here...

    // Make sure to set "success" to proper value:
    // 0 - 'success' result of the test case
    // >0 - 'failure' result of the test case
    // <0 - 'inconclusive' result of the test case

    MBED_HOSTTEST_TESTCASE_FINISH(TESTCASE_NAME,success);
}

You can think about this also like this:

if (result_of_my_test_case == 0) {
    // OK case !
    success = 0;
} else if (result_of_my_test_case > 0) {
    // FAILed case ! 
    // You can add any arbitrary and meaningful for you value < 0.
    // E.g. you can do success = 404; to mark in your test case 
    // that "server" returned 404 error.
    success = 404;    
} else if (result_of_my_test_case < 0) {
    // ERROR, test case execution was inconclusive
    // You can add any arbitrary and meaningful for you value > 0.
    // E.g. success = -1; when your test framework cough exception.
    success = -1;
}

Rationale

We need to move to new mode of work where one binary (test suite) can report multiple test cases results from automated run.

Changes

  • Added macros to mbed-drivers/test_env.h:
#define MBED_HOSTTEST_TESTCASE_START(TESTCASE)  notify_testcase_start(#TESTCASE)
#define MBED_HOSTTEST_TESTCASE_FINISH(TESTCASE,SUCCESS)   notify_testcase_completion(#TESTCASE,SUCCESS)
  • Added macros implementation:
/** \brief Notifies test case start
  * \param Test Case ID name
  *
  * This function notifies test environment abort test case execution start.
  *
  */
void notify_testcase_start(const char *testcase_id)
{
    printf("{{testcase_start;%s}}" NL, testcase_id);
}

/** \brief Return partial (test case) result from test suite
  * \param Test Case ID name
  * \param Success code, 0 - success, >0 failure reason, <0 inconclusive
  *
  * This function passes partial test suite's test case result to test
  * environment.
  * Each test suite (in many cases one binary with tests) can return
  * multiple partial results used to track test case results.
  *
  * Test designers can use success code to return test case:
  * success == 0 - PASS, test case execution was successful.
  * success > 0  - FAILure, e.g. success == 404 can be used to
  *                pass "Server not found".
  * success < 0  - Inconclusive test case execution, e.g.
  *
  */
void notify_testcase_completion(const char *testcase_id, const int success)
{
    printf("{{testcase_finish;%s;%d}}" NL, testcase_id, success);
}
  • Added corresponding macros' equivalents on host test side:
selftest.testcase_start(testcase_name)
selftest.testcase_finish(testcase_name, testcase_result)

Example:

class RTCTest(BaseHostTest):
    def test(self, selftest):
        test_result = True
        selftest.testcase_start("RTC0001")
        # Test case execution
        selftest.testcase_finish("RTC0001", test_result)
        # ...

Example "STL" mbed-drivers test case source code with new macros in use

Note: We will modify in this example mbed-driver's STL.

We are adding two macros at the beginning of the test case and the end of it:

MBED_HOSTTEST_TESTCASE_START(STL001);
// test case execution
MBED_HOSTTEST_TESTCASE_FINISH(STL001, success_code);

Originally this test case was designed to run multiple checks and return one result, but now we can get multiple results from each test case and summary result from test suite passed via already used macro:

MBED_HOSTTEST_RESULT();
void runTest()
{
    int p_integers[] = {POSITIVE_INTEGERS};
    int n_integers[] = {NEGATIVE_INTEGERS};
    float floats[] = {FLOATS};
    bool result = true;

    MBED_HOSTTEST_TIMEOUT(10);
    MBED_HOSTTEST_SELECT(default_auto);
    MBED_HOSTTEST_DESCRIPTION(C++ STL);
    MBED_HOSTTEST_START("MBED_A3"); 

    // Test case STL001
    {
        MBED_HOSTTEST_TESTCASE_START(STL001);   // New macro
        std::vector<int> v_pints(p_integers, p_integers + TABLE_SIZE(p_integers));
        bool equal_result = std::equal(v_pints.begin(), v_pints.end(), p_integers);
        result = result && equal_result;
        MBED_HOSTTEST_TESTCASE_FINISH(STL001, !result); // New macro
    }

    // Test case STL002
    {
        MBED_HOSTTEST_TESTCASE_START(STL002);   // New macro
        const char* floats_str[] = {FLOATS_STR};
        float floats_transform[TABLE_SIZE(floats_str)] = {0.0};
        std::transform(floats_str, floats_str + TABLE_SIZE(floats_str), floats_transform, atof);
        bool equal_result = std::equal(floats_transform, floats_transform + TABLE_SIZE(floats_transform), floats);
        result = result && equal_result;
        MBED_HOSTTEST_TESTCASE_FINISH(STL002, !result); // New macro

        std::for_each(floats_str, floats_str + TABLE_SIZE(floats_str), printString());
        printf("\r\n");
        std::for_each(floats_transform, floats_transform + TABLE_SIZE(floats_transform), printFloat());
        printf("\r\n");
    }

Example host test for RTC test cases with new functions

In this examples we refactored test(self, selftest) function and added two new functions with two very similar test cases (we are only changing look count).

Changes:

  • We will still use return value from test(self, selftest) to give feedback from test suite.
  • We will add new two functions:
selftest.testcase_start("RTC0001")
# Your test case here...
selftest.testcase_finish("RTC0001", test_result)

Note that in this case test case is captured inside host test and not inside binary with mbed code.

class RTCTest(BaseHostTest):
    PATTERN_RTC_VALUE = "\[(\d+)\] \[(\d+-\d+-\d+ \d+:\d+:\d+ [AaPpMm]{2})\]"
    re_detect_rtc_value = re.compile(PATTERN_RTC_VALUE)

    def test(self, selftest):
        test_result = []
        test_result.append(self.test_rtc001(selftest))
        test_result.append(self.test_rtc002(selftest))
        return selftest.RESULT_SUCCESS if all(test_result) else selftest.RESULT_FAILURE

    def test_rtc001(self, selftest):
        test_result = True
        start = time()
        sec_prev = 0
        selftest.testcase_start("RTC0001")
        for i in range(0, 3):
            # Timeout changed from default: we need to wait longer for some boards to start-up
            c = selftest.mbed.serial_readline(timeout=10)
            if c is None:
                return selftest.RESULT_IO_SERIAL
            selftest.notify(c.strip())
            delta = time() - start
            m = self.re_detect_rtc_value.search(c)
            if m and len(m.groups()):
                sec = int(m.groups()[0])
                time_str = m.groups()[1]
                correct_time_str = strftime("%Y-%m-%d %H:%M:%S %p", gmtime(float(sec)))
                single_result = time_str == correct_time_str and sec > 0 and sec > sec_prev
                test_result = test_result and single_result
                result_msg = "OK" if single_result else "FAIL"
                selftest.notify("HOST: [%s] [%s] received time %+d sec after %.2f sec... %s"% (sec, time_str, sec - sec_prev, delta, result_msg))
                sec_prev = sec
            else:
                test_result = False
                break
            start = time()
        selftest.testcase_finish("RTC0001", test_result)
        return test_result

    def test_rtc002(self, selftest):
        test_result = True
        start = time()
        sec_prev = 0
        selftest.testcase_start("RTC0002")
        for i in range(0, 5):
            # Timeout changed from default: we need to wait longer for some boards to start-up
            c = selftest.mbed.serial_readline(timeout=10)
            if c is None:
                return selftest.RESULT_IO_SERIAL
            selftest.notify(c.strip())
            delta = time() - start
            m = self.re_detect_rtc_value.search(c)
            if m and len(m.groups()):
                sec = int(m.groups()[0])
                time_str = m.groups()[1]
                correct_time_str = strftime("%Y-%m-%d %H:%M:%S %p", gmtime(float(sec)))
                single_result = time_str == correct_time_str and sec > 0 and sec > sec_prev
                test_result = test_result and single_result
                result_msg = "OK" if single_result else "FAIL"
                selftest.notify("HOST: [%s] [%s] received time %+d sec after %.2f sec... %s"% (sec, time_str, sec - sec_prev, delta, result_msg))
                sec_prev = sec
            else:
                test_result = False
                break
            start = time()
        selftest.testcase_finish("RTC0002", test_result)
        return test_result

Example reporting

$ mbedgt -V -n mbed-drivers-test-rtc,mbed-drivers-test-stl,mbed-drivers-test-cstring
...
mbedgt: mbed-host-test-runner: stopped
mbedgt: mbed-host-test-runner: returned 'OK'
mbedgt: test on hardware with target id: 02400226489a1e6c000000000000000000000000b543e3d4
mbedgt: test suite 'mbed-drivers-test-stl' ........................................................... OK in 2.91 sec
        test case 'STL001' ........................................................................... OK in 0.00 sec
        test case 'STL002' ........................................................................... OK in 0.01 sec
        test case 'STL003' ........................................................................... OK in 0.01 sec
        test case 'STL004' ........................................................................... OK in 0.00 sec
mbedgt: test suite report:
+---------------+---------------+---------------------------+--------+--------------------+-------------+
| target        | platform_name | test suite                | result | elapsed_time (sec) | copy_method |
+---------------+---------------+---------------------------+--------+--------------------+-------------+
| frdm-k64f-gcc | K64F          | mbed-drivers-test-rtc     | OK     | 8.71               | shell       |
| frdm-k64f-gcc | K64F          | mbed-drivers-test-cstring | FAIL   | 2.95               | shell       |
| frdm-k64f-gcc | K64F          | mbed-drivers-test-stl     | OK     | 2.91               | shell       |
+---------------+---------------+---------------------------+--------+--------------------+-------------+
mbedgt: test suite results: 1 FAIL / 2 OK
mbedgt: test case report:
+---------------+---------------+---------------------------+------------+--------+--------------------+-------------+
| target        | platform_name | test suite                | test case  | result | elapsed_time (sec) | copy_method |
+---------------+---------------+---------------------------+------------+--------+--------------------+-------------+
| frdm-k64f-gcc | K64F          | mbed-drivers-test-rtc     | RTC0001    | OK     | 3.12               | shell       |
| frdm-k64f-gcc | K64F          | mbed-drivers-test-rtc     | RTC0002    | OK     | 4.19               | shell       |
| frdm-k64f-gcc | K64F          | mbed-drivers-test-cstring | STRINGS001 | OK     | 0.01               | shell       |
| frdm-k64f-gcc | K64F          | mbed-drivers-test-cstring | STRINGS002 | OK     | 0.01               | shell       |
| frdm-k64f-gcc | K64F          | mbed-drivers-test-cstring | STRINGS003 | OK     | 0.01               | shell       |
| frdm-k64f-gcc | K64F          | mbed-drivers-test-cstring | STRINGS004 | FAIL   | 0.0                | shell       |
| frdm-k64f-gcc | K64F          | mbed-drivers-test-cstring | STRINGS005 | FAIL   | 0.0                | shell       |
| frdm-k64f-gcc | K64F          | mbed-drivers-test-cstring | STRINGS006 | FAIL   | 0.0                | shell       |
| frdm-k64f-gcc | K64F          | mbed-drivers-test-cstring | STRINGS007 | FAIL   | 0.01               | shell       |
| frdm-k64f-gcc | K64F          | mbed-drivers-test-cstring | STRINGS008 | FAIL   | 0.0                | shell       |
| frdm-k64f-gcc | K64F          | mbed-drivers-test-stl     | STL001     | OK     | 0.0                | shell       |
| frdm-k64f-gcc | K64F          | mbed-drivers-test-stl     | STL002     | OK     | 0.01               | shell       |
| frdm-k64f-gcc | K64F          | mbed-drivers-test-stl     | STL003     | OK     | 0.01               | shell       |
| frdm-k64f-gcc | K64F          | mbed-drivers-test-stl     | STL004     | OK     | 0.0                | shell       |
+---------------+---------------+---------------------------+------------+--------+--------------------+-------------+
mbedgt: test case results: 5 FAIL / 9 OK
mbedgt: completed in 105.04 sec
mbedgt: exited with code 1

mbedgt fails with [Errno 13] Permission denied

When I try to run mbedgt with the tcpecho_client_auto test on mac OSX, it fails with [Errno 13] Permission denied

The full log is as follows:

HOST: Copy image onto target...
HOST: Initialize serial port...
........port ready!
HOST: Reset target...
HOST: Property 'timeout' = '20'
HOST: Property 'host_test_name' = 'tcpecho_client_auto'
HOST: Property 'description' = 'TCP echo client'
HOST: Property 'test_id' = 'NET_4'
HOST: Start test...
[Errno 13] Permission denied

{{error}}
{{end}}

greentea exits with error code when no tests are found in a yotta module

Some mbedos repos are expected to have tests in future. mbed-greentea command can not be added now or until tests exist as it returns with error code causing Jenkins job i.e. build to fail.
Hence a command line switch can be added that skipps testing if there are no tests available and exit without error.
Corresponding jira tickets is IOTSYST-583

[Blocker] v0.2.0 fails on mac OS X

When I run mbedgt on mac OS X, I get this error:

[1457091608.42][HTST][INF] copy image onto target...
[1457091614.67][HTST][INF] starting host test process...
[1457091614.67][HTST][ERR] something went wrong in event main loop!
[1457091614.67][HTST][INF] ==== Traceback start ====
Traceback (most recent call last):
  File "build/bdist.macosx-10.9-x86_64/egg/mbed_host_tests/host_tests_runner/host_test_default.py", line 120, in run_test
    if event_queue.qsize():
  File "/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/queues.py", line 143, in qsize
    return self._maxsize - self._sem._semlock._get_value()
NotImplementedError
[1457091614.67][HTST][INF] ==== Traceback end ====
[1457091614.67][HTST][INF] test suite run finished after 0.00 sec...
[1457091614.67][HTST][INF] CONN exited with code: None
Traceback (most recent call last):
  File "/usr/local/bin/mbedhtrun", line 9, in <module>
    load_entry_point('mbed-host-tests==0.2.0', 'console_scripts', 'mbedhtrun')()
  File "build/bdist.macosx-10.9-x86_64/egg/mbed_host_tests/mbedhtrun.py", line 32, in main
  File "build/bdist.macosx-10.9-x86_64/egg/mbed_host_tests/host_tests_runner/host_test_default.py", line 291, in execute
  File "build/bdist.macosx-10.9-x86_64/egg/mbed_host_tests/host_tests_runner/host_test_default.py", line 215, in run_test
  File "/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/queues.py", line 143, in qsize
    return self._maxsize - self._sem._semlock._get_value()
NotImplementedError

greentea fails to run with a local host-test

Here is my output

$ mbedgt -V --target frdm-k64f -n $testname
Traceback (most recent call last):
  File "/usr/local/bin/mbedgt", line 9, in <module>
    load_entry_point('mbed-greentea==0.1.14', 'console_scripts', 'mbedgt')()
  File "/usr/local/lib/python2.7/site-packages/mbed_greentea/mbed_greentea_cli.py", line 105, in main
    copy_methods_str = "Plugin support: " + ', '.join(mbed_host_tests.host_tests_plugins.get_plugin_caps('CopyMethod'))
NameError: global name 'mbed_host_tests' is not defined

I have tried removing and reinstalling mbed-greentea, mbed-host-tests, and mbed-ls

Build files(.bin) exist in test folder, test framework can't load it in frdm-k64f

Setup: Linux (VM-ware)
Board: frdm-k64f
compiler: gcc & armcc
K64f firmware versions: 0226 and 0225
ISSUE with GCC: with GCC all tests pass with status OK. However A message appears.
cp: cannot create regular file โ€˜/media/hasnain/MBED/XXXX.binโ€™: No such file or directory
ISSUE with armcc: same as gcc alongwith some test cases Timinig out.

TRACE for gcc:

hasnain@ubuntu:~/Desktop/OOB/mbed-drivers$ sudo mbedgt --target=frdm-k64f-gcc
mbedgt: detecting connected mbed-enabled devices...
mbedgt: detected 1 device
detected 'K64F', console at '/dev/ttyACM0', mounted at '/media/hasnain/MBED'
mbedgt: scan available targets for 'K64F' platform...
mbedgt: yotta search for mbed-target 'k64f'
calling yotta: yotta search -k mbed-target:k64f target
mbedgt: using 'frdm-k64f-gcc' target, prepare to build
mbedgt: building your sources and tests with yotta...
calling yotta: yotta -v --target=frdm-k64f-gcc,* build
info: generate for target: frdm-k64f-gcc 0.2.0 at /home/hasnain/Desktop/OOB/mbed-drivers/yotta_targets/frdm-k64f-gcc
GCC version is: 4.9.3
-- Configuring done
-- Generating done
-- Build files have been written to: /home/hasnain/Desktop/OOB/mbed-drivers/build/frdm-k64f-gcc
ninja: no work to do.
mbedgt: yotta build for target 'frdm-k64f-gcc' was successful
mbedgt: running tests for target 'frdm-k64f-gcc'
running host test...
test 'mbed-drivers-test-serial_interrupt' .............................................. OK in 6.31 sec
running host test...
cp: cannot create regular file โ€˜/media/hasnain/MBED/mbed-drivers-test-blinky.binโ€™: No such file or directory
test 'mbed-drivers-test-blinky' ........................................................ OK in 6.23 sec
running host test...
cp: cannot create regular file โ€˜/media/hasnain/MBED/mbed-drivers-test-div.binโ€™: No such file or directory
test 'mbed-drivers-test-div' ........................................................... OK in 6.26 sec
running host test...
cp: cannot create regular file โ€˜/media/hasnain/MBED/mbed-drivers-test-cstring.binโ€™: No such file or directory
test 'mbed-drivers-test-cstring' ....................................................... OK in 6.21 sec
running host test...
cp: cannot create regular file โ€˜/media/hasnain/MBED/mbed-drivers-test-stdio.binโ€™: No such file or directory
test 'mbed-drivers-test-stdio' ......................................................... OK in 6.21 sec
running host test...
cp: cannot create regular file โ€˜/media/hasnain/MBED/mbed-drivers-test-stl.binโ€™: No such file or directory
test 'mbed-drivers-test-stl' ........................................................... OK in 6.30 sec
running host test...
cp: cannot create regular file โ€˜/media/hasnain/MBED/mbed-drivers-test-rtc.binโ€™: No such file or directory
test 'mbed-drivers-test-rtc' ........................................................... OK in 6.28 sec
running host test...
cp: cannot create regular file โ€˜/media/hasnain/MBED/mbed-drivers-test-dev_null.binโ€™: No such file or directory
test 'mbed-drivers-test-dev_null' ...................................................... OK in 6.22 sec
running host test...
cp: cannot create regular file โ€˜/media/hasnain/MBED/mbed-drivers-test-cpp.binโ€™: No such file or directory
test 'mbed-drivers-test-cpp' ........................................................... OK in 6.23 sec
running host test...
cp: cannot create regular file โ€˜/media/hasnain/MBED/mbed-drivers-test-timeout.binโ€™: No such file or directory
test 'mbed-drivers-test-timeout' ....................................................... OK in 6.20 sec
running host test...
cp: cannot create regular file โ€˜/media/hasnain/MBED/mbed-drivers-test-basic.binโ€™: No such file or directory
test 'mbed-drivers-test-basic' ......................................................... OK in 6.17 sec
running host test...
cp: cannot create regular file โ€˜/media/hasnain/MBED/mbed-drivers-test-ticker.binโ€™: No such file or directory
test 'mbed-drivers-test-ticker' ........................................................ OK in 6.08 sec
running host test...
cp: cannot create regular file โ€˜/media/hasnain/MBED/mbed-drivers-test-ticker_2.binโ€™: No such file or directory
test 'mbed-drivers-test-ticker_2' ...................................................... OK in 6.21 sec
running host test...
cp: cannot create regular file โ€˜/media/hasnain/MBED/mbed-drivers-test-heap_and_stack.binโ€™: No such file or directory
test 'mbed-drivers-test-heap_and_stack' ................................................ OK in 6.19 sec
running host test...
cp: cannot create regular file โ€˜/media/hasnain/MBED/mbed-drivers-test-echo.binโ€™: No such file or directory
test 'mbed-drivers-test-echo' .......................................................... OK in 6.18 sec
running host test...
cp: cannot create regular file โ€˜/media/hasnain/MBED/mbed-drivers-test-hello.binโ€™: No such file or directory
test 'mbed-drivers-test-hello' ......................................................... OK in 6.29 sec
running host test...
cp: cannot create regular file โ€˜/media/hasnain/MBED/mbed-drivers-test-time_us.binโ€™: No such file or directory
test 'mbed-drivers-test-time_us' ....................................................... OK in 6.22 sec
running host test...
cp: cannot create regular file โ€˜/media/hasnain/MBED/mbed-drivers-test-sleep_timeout.binโ€™: No such file or directory
test 'mbed-drivers-test-sleep_timeout' ................................................. OK in 6.22 sec
running host test...
cp: cannot create regular file โ€˜/media/hasnain/MBED/mbed-drivers-test-ticker_3.binโ€™: No such file or directory
test 'mbed-drivers-test-ticker_3' ...................................................... OK in 6.21 sec
running host test...
cp: cannot create regular file โ€˜/media/hasnain/MBED/mbed-drivers-test-detect.binโ€™: No such file or directory
test 'mbed-drivers-test-detect' ........................................................ OK in 6.25 sec
mbedgt: test report:
+---------------+---------------+------------------------------------+--------+--------------------+-------------+
| target | platform_name | test | result | elapsed_time (sec) | copy_method |
+---------------+---------------+------------------------------------+--------+--------------------+-------------+
| frdm-k64f-gcc | K64F | mbed-drivers-test-serial_interrupt | OK | 6.31 | shell |
| frdm-k64f-gcc | K64F | mbed-drivers-test-blinky | OK | 6.23 | shell |
| frdm-k64f-gcc | K64F | mbed-drivers-test-div | OK | 6.26 | shell |
| frdm-k64f-gcc | K64F | mbed-drivers-test-dev_null | OK | 6.22 | shell |
| frdm-k64f-gcc | K64F | mbed-drivers-test-stdio | OK | 6.21 | shell |
| frdm-k64f-gcc | K64F | mbed-drivers-test-sleep_timeout | OK | 6.22 | shell |
| frdm-k64f-gcc | K64F | mbed-drivers-test-ticker | OK | 6.08 | shell |
| frdm-k64f-gcc | K64F | mbed-drivers-test-rtc | OK | 6.28 | shell |
| frdm-k64f-gcc | K64F | mbed-drivers-test-cstring | OK | 6.21 | shell |
| frdm-k64f-gcc | K64F | mbed-drivers-test-cpp | OK | 6.23 | shell |
| frdm-k64f-gcc | K64F | mbed-drivers-test-timeout | OK | 6.2 | shell |
| frdm-k64f-gcc | K64F | mbed-drivers-test-basic | OK | 6.17 | shell |
| frdm-k64f-gcc | K64F | mbed-drivers-test-ticker_3 | OK | 6.21 | shell |
| frdm-k64f-gcc | K64F | mbed-drivers-test-ticker_2 | OK | 6.21 | shell |
| frdm-k64f-gcc | K64F | mbed-drivers-test-heap_and_stack | OK | 6.19 | shell |
| frdm-k64f-gcc | K64F | mbed-drivers-test-hello | OK | 6.29 | shell |
| frdm-k64f-gcc | K64F | mbed-drivers-test-time_us | OK | 6.22 | shell |
| frdm-k64f-gcc | K64F | mbed-drivers-test-stl | OK | 6.3 | shell |
| frdm-k64f-gcc | K64F | mbed-drivers-test-echo | OK | 6.18 | shell |
| frdm-k64f-gcc | K64F | mbed-drivers-test-detect | OK | 6.25 | shell |
+---------------+---------------+------------------------------------+--------+--------------------+-------------+

Result: 20 OK
Completed in 370.12 sec

TRACE for armcc:

hasnain@ubuntu:~/Desktop/OOB/mbed-drivers$ sudo mbedgt --target=frdm-k64f-armcc
mbedgt: detecting connected mbed-enabled devices...
mbedgt: detected 1 device
detected 'K64F', console at '/dev/ttyACM0', mounted at '/media/hasnain/MBED'
mbedgt: scan available targets for 'K64F' platform...
mbedgt: yotta search for mbed-target 'k64f'
calling yotta: yotta search -k mbed-target:k64f target
mbedgt: using 'frdm-k64f-armcc' target, prepare to build
mbedgt: building your sources and tests with yotta...
calling yotta: yotta -v --target=frdm-k64f-armcc,* build
info: generate for target: frdm-k64f-armcc 0.1.4 at /home/hasnain/Desktop/OOB/mbed-drivers/yotta_targets/frdm-k64f-armcc
CMake Warning at /home/hasnain/Desktop/OOB/mbed-drivers/yotta_modules/uvisor-lib/source/CMakeLists.txt:43 (message):

       *******************************************************************
       * WARNING (uvisor-lib): unsupported platform; your code will still
       *                       work but no security feature is provided;
       *                       UVISOR_DISABLED is set by default
       *******************************************************************

-- Configuring done
-- Generating done
-- Build files have been written to: /home/hasnain/Desktop/OOB/mbed-drivers/build/frdm-k64f-armcc
ninja: no work to do.
mbedgt: yotta build for target 'frdm-k64f-armcc' was successful
mbedgt: running tests for target 'frdm-k64f-armcc'
running host test...
test 'mbed-drivers-test-serial_interrupt' .............................................. TIMEOUT in 20.26 sec
running host test...
cp: cannot create regular file โ€˜/media/hasnain/MBED/mbed-drivers-test-blinky.binโ€™: No such file or directory
test 'mbed-drivers-test-blinky' ........................................................ TIMEOUT in 20.26 sec
running host test...
cp: cannot create regular file โ€˜/media/hasnain/MBED/mbed-drivers-test-div.binโ€™: No such file or directory
test 'mbed-drivers-test-div' ........................................................... TIMEOUT in 20.26 sec
running host test...
cp: cannot create regular file โ€˜/media/hasnain/MBED/mbed-drivers-test-cstring.binโ€™: No such file or directory
test 'mbed-drivers-test-cstring' ....................................................... TIMEOUT in 20.26 sec
running host test...
cp: cannot create regular file โ€˜/media/hasnain/MBED/mbed-drivers-test-stdio.binโ€™: No such file or directory
test 'mbed-drivers-test-stdio' ......................................................... OK in 6.24 sec
running host test...
cp: cannot create regular file โ€˜/media/hasnain/MBED/mbed-drivers-test-stl.binโ€™: No such file or directory
test 'mbed-drivers-test-stl' ........................................................... TIMEOUT in 20.26 sec
running host test...
cp: cannot create regular file โ€˜/media/hasnain/MBED/mbed-drivers-test-rtc.binโ€™: No such file or directory
test 'mbed-drivers-test-rtc' ........................................................... OK in 6.24 sec
running host test...
cp: cannot create regular file โ€˜/media/hasnain/MBED/mbed-drivers-test-dev_null.binโ€™: No such file or directory
test 'mbed-drivers-test-dev_null' ...................................................... TIMEOUT in 20.26 sec
running host test...
cp: cannot create regular file โ€˜/media/hasnain/MBED/mbed-drivers-test-cpp.binโ€™: No such file or directory
test 'mbed-drivers-test-cpp' ........................................................... OK in 6.25 sec
running host test...
cp: cannot create regular file โ€˜/media/hasnain/MBED/mbed-drivers-test-timeout.binโ€™: No such file or directory
test 'mbed-drivers-test-timeout' ....................................................... TIMEOUT in 20.25 sec
running host test...
cp: cannot create regular file โ€˜/media/hasnain/MBED/mbed-drivers-test-basic.binโ€™: No such file or directory
test 'mbed-drivers-test-basic' ......................................................... OK in 6.19 sec
running host test...
cp: cannot create regular file โ€˜/media/hasnain/MBED/mbed-drivers-test-ticker.binโ€™: No such file or directory
test 'mbed-drivers-test-ticker' ........................................................ OK in 6.29 sec
running host test...
cp: cannot create regular file โ€˜/media/hasnain/MBED/mbed-drivers-test-ticker_2.binโ€™: No such file or directory
test 'mbed-drivers-test-ticker_2' ...................................................... TIMEOUT in 20.27 sec
running host test...
cp: cannot create regular file โ€˜/media/hasnain/MBED/mbed-drivers-test-heap_and_stack.binโ€™: No such file or directory
test 'mbed-drivers-test-heap_and_stack' ................................................ TIMEOUT in 20.26 sec
running host test...
cp: cannot create regular file โ€˜/media/hasnain/MBED/mbed-drivers-test-echo.binโ€™: No such file or directory
test 'mbed-drivers-test-echo' .......................................................... TIMEOUT in 20.27 sec
running host test...
cp: cannot create regular file โ€˜/media/hasnain/MBED/mbed-drivers-test-hello.binโ€™: No such file or directory
test 'mbed-drivers-test-hello' ......................................................... TIMEOUT in 20.26 sec
running host test...
cp: cannot create regular file โ€˜/media/hasnain/MBED/mbed-drivers-test-time_us.binโ€™: No such file or directory
test 'mbed-drivers-test-time_us' ....................................................... TIMEOUT in 20.27 sec
running host test...
cp: cannot create regular file โ€˜/media/hasnain/MBED/mbed-drivers-test-sleep_timeout.binโ€™: No such file or directory
test 'mbed-drivers-test-sleep_timeout' ................................................. TIMEOUT in 20.27 sec
running host test...
cp: cannot create regular file โ€˜/media/hasnain/MBED/mbed-drivers-test-ticker_3.binโ€™: No such file or directory
test 'mbed-drivers-test-ticker_3' ...................................................... TIMEOUT in 20.27 sec
running host test...
cp: cannot create regular file โ€˜/media/hasnain/MBED/mbed-drivers-test-detect.binโ€™: No such file or directory
test 'mbed-drivers-test-detect' ........................................................ TIMEOUT in 20.27 sec
mbedgt: test report:
+-----------------+---------------+------------------------------------+---------+--------------------+-------------+
| target | platform_name | test | result | elapsed_time (sec) | copy_method |
+-----------------+---------------+------------------------------------+---------+--------------------+-------------+
| frdm-k64f-armcc | K64F | mbed-drivers-test-serial_interrupt | TIMEOUT | 20.26 | shell |
| frdm-k64f-armcc | K64F | mbed-drivers-test-blinky | TIMEOUT | 20.26 | shell |
| frdm-k64f-armcc | K64F | mbed-drivers-test-div | TIMEOUT | 20.26 | shell |
| frdm-k64f-armcc | K64F | mbed-drivers-test-dev_null | TIMEOUT | 20.26 | shell |
| frdm-k64f-armcc | K64F | mbed-drivers-test-stdio | OK | 6.24 | shell |
| frdm-k64f-armcc | K64F | mbed-drivers-test-sleep_timeout | TIMEOUT | 20.27 | shell |
| frdm-k64f-armcc | K64F | mbed-drivers-test-ticker | OK | 6.29 | shell |
| frdm-k64f-armcc | K64F | mbed-drivers-test-rtc | OK | 6.24 | shell |
| frdm-k64f-armcc | K64F | mbed-drivers-test-cstring | TIMEOUT | 20.26 | shell |
| frdm-k64f-armcc | K64F | mbed-drivers-test-cpp | OK | 6.25 | shell |
| frdm-k64f-armcc | K64F | mbed-drivers-test-timeout | TIMEOUT | 20.25 | shell |
| frdm-k64f-armcc | K64F | mbed-drivers-test-basic | OK | 6.19 | shell |
| frdm-k64f-armcc | K64F | mbed-drivers-test-ticker_3 | TIMEOUT | 20.27 | shell |
| frdm-k64f-armcc | K64F | mbed-drivers-test-ticker_2 | TIMEOUT | 20.27 | shell |
| frdm-k64f-armcc | K64F | mbed-drivers-test-heap_and_stack | TIMEOUT | 20.26 | shell |
| frdm-k64f-armcc | K64F | mbed-drivers-test-hello | TIMEOUT | 20.26 | shell |
| frdm-k64f-armcc | K64F | mbed-drivers-test-time_us | TIMEOUT | 20.27 | shell |
| frdm-k64f-armcc | K64F | mbed-drivers-test-stl | TIMEOUT | 20.26 | shell |
| frdm-k64f-armcc | K64F | mbed-drivers-test-echo | TIMEOUT | 20.27 | shell |
| frdm-k64f-armcc | K64F | mbed-drivers-test-detect | TIMEOUT | 20.27 | shell |
+-----------------+---------------+------------------------------------+---------+--------------------+-------------+

Result: 5 OK / 15 TIMEOUT
Completed in 580.94 sec

Debugging is difficult with greentea-enabled tests

I would like a way to put greentea into a mode that does not copy the test before running, ignores timeouts, etc. so that I can attach a debugger to the DUT and debug a test that interacts with a host-test.

IOERR_SERIAL using ARMCC even with new FRDM firmware

This issue is actually addressed in the README.md
But for the sake of clearer OOB, I am forced to create an issue here.

-- Configuring done
-- Generating done
-- Build files have been written to: /home/hasnain/Documents/mbed-drivers/build/frdm-k64f-armcc
ninja: no work to do.
mbedgt: yotta build successful
mbedgt: running tests for 'frdm-k64f-armcc' target
running host test...
test 'mbed-drivers-test-echo' .......................................................... IOERR_SERIAL in 17.09 sec
running host test...
test 'mbed-drivers-test-time_us' ....................................................... IOERR_SERIAL in 16.83 sec
running host test...
test 'mbed-drivers-test-serial_interrupt' .............................................. IOERR_SERIAL in 17.12 sec
running host test...
test 'mbed-drivers-test-blinky' ........................................................ IOERR_SERIAL in 16.82 sec
running host test...
^Z
[2]+ Stopped mbedgt --target=frdm-k64f-armcc

mbedgt --list unexpected error for module with no build directory

Hi

Steps to reproduce the problem:

  1. git clone [email protected]:ARMmbed/mbed-drivers.git
  2. cd mbed-drivers/
  3. yt target frdm-k64f-gcc
  4. mbedgt --list

This is the output trace of the exception:

simhug01@E107851 /d/datastore/public/jobs/yr2016/2245/work/20160107/mbed-drivers (master)
$ mbedgt --list
โ†[31mโ†[1mmbedgt: โ†[0munexpected error:
[Error 3] The system cannot find the path specified: './build/.'
Traceback (most recent call last):
File "c:\mbed_tools\Python27\Scripts\mbedgt-script.py", line 9, in
load_entry_point('mbed-greentea==0.1.14', 'console_scripts', 'mbedgt')()
File "C:\mbed_tools\Python27\lib\site-packages\mbed_greentea\mbed_greentea_cli.py", line 245, in main
cli_ret = main_cli(opts, args)
File "C:\mbed_tools\Python27\lib\site-packages\mbed_greentea\mbed_greentea_cli.py", line 352, in main_cli
list_binaries_for_targets()
File "C:\mbed_tools\Python27\lib\site-packages\mbed_greentea\cmake_handlers.py", line 84, in list_binaries_for_targets
sub_dirs = [os.path.join(dir, o) for o in os.listdir(dir) if os.path.isdir(os.path.join(dir, o))]
WindowsError: [Error 3] The system cannot find the path specified: './build/.'
โ†[0m
simhug01@E107851 /d/datastore/public/jobs/yr2016/2245/work/20160107/mbed-drivers (master)

Thanks
Simon

mbedgt fails at using the serial port under Linux for the K64F target

~/mbed/mbed-os/mbed-alpha3-rc-201505141620/libraries/mbed-sdk$ mbedgt --target=frdm-k64f-gcc
...
mbedgt: running tests...
    test 'mbed-test-detect' ...................................................... SKIPPED
    test 'mbed-test-functionpointer' ............................................. IOERR_SERIAL
    test 'mbed-test-div' ......................................................... IOERR_SERIAL
    test 'mbed-test-dev_null' .................................................... IOERR_SERIAL
    test 'mbed-test-stl' ......................................................... SKIPPED
    test 'mbed-test-sleep_timeout' ............................................... SKIPPED
    test 'mbed-test-blinky' ...................................................... SKIPPED
    test 'mbed-test-timeout' ..................................................... IOERR_SERIAL
    test 'mbed-test-heap_and_stack' .............................................. SKIPPED
    test 'mbed-test-rtc' ......................................................... IOERR_SERIAL
    test 'mbed-test-cpp' ......................................................... IOERR_SERIAL
    test 'mbed-test-echo' ........................................................ IOERR_SERIAL
    test 'mbed-test-ticker_3' .................................................... IOERR_SERIAL
    test 'mbed-test-ticker_2' .................................................... IOERR_SERIAL
    test 'mbed-test-cstring' ..................................................... SKIPPED
    test 'mbed-test-time_us' ..................................................... IOERR_SERIAL
    test 'mbed-test-ticker' ...................................................... IOERR_SERIAL
    test 'mbed-test-serial_interrupt' ............................................ SKIPPED

Feature request: Sort tests in order in list and report

When you have many test to run, it is difficult to find the test you want in the list. Also the order of list changes between different runs which also makes it harder to find.

If the order of execution causes bugs, there is also merit for debugging in executing tests in a particular order.

Windows - 100 cpu usage after tests completition

Using mbedgt 0.0.10, windows 7, frdm-k64f , test for mbed-core repository.

I run the tests, all of them run for this board, the cpu started to be 100 during tests, and stayed there (no dropping below 100 percent). once finished, my CPU usage was still 100 percent. I was not able to do anything, barely to move the pointer to the Start button to restart PC :/

Host test error - hidden, does not stop the execution

The console is misleading and does not highlight the error, still using 0.1.14 mbedgt.

HOST: Error! While loading local host test module 'C:\Code\git_repo\github\yotta_thing\niklas-socket-test\test\host_tests\tcp_echo_client.py
'                                                                                                                                           
HOST: invalid syntax (tcp_echo_client.py, line 90)                                                                                          
MBED: Instrumentation: "COM64" and disk: "D:"                                                                                               
HOST: Copy image onto target...                                                                                                             
        1 file(s) copied.                                                                                                                   
HOST: Initialize serial port...                                                                                                             
...port ready!                                                                                                                              
HOST: Reset target...                                                                                                                       
HOST: Detecting test case properties...                                                                                                     
HOST: Property 'timeout' = '60'                                                                                                             
HOST: Property 'host_test_name' = 'tcp_echo_client'                                                                                         
HOST: Property 'description' = 'TCP echo client unit test'                                                                                  
HOST: Property 'test_id' = 'TCP echo client unit test'                                                                                      
HOST: Start test...                                                                                                                         
HOST: Error! Unknown host test name 'tcp_echo_client' (use 'mbedhtrun --list' to verify)!                                                   
HOST: Error! You can use switch '-e <dir>' to specify local directory with host tests to load                                               

I assume the error:
HOST: Error! While loading local host test module 'C:\Code\git_repo\github\yotta_thing\niklas-socket-test\test\host_tests\tcp_echo_client.py

should stop the execution ?

Post-test hook

When generating coverage output, a command needs to be run after each test to aggregate the data that was generated from the test. This should not be specific to gcov, so a generic post-test hook seems like the right solution.

This feature is to support #32.

For the specific gcov use-case, after each test, the following commands need to be run:

lcov --gcov-tool arm-none-eabi-gcov  --capture --directory <build path> \
--output-file <build path>/test/<test name>.info
find . -name "*.gcda" | xargs rm -f

After all tests have run, the following command should be run, one -a entry for each passing test:

lcov --gcov-tool arm-none-eabi-gcov -a <build path>/test/<test1 name>.info \
[-a <build path>/test/<test2 name>.info] --output-file <result path>.info

This will aggregate all data generated from each test into its own lcov info file. These info files can then be aggregated into a single info file covering all tests that have run.

The post-test hook could be either a python script or a command line. If a command line, then accepting a command to be parsed with the python format language might be beneficial, for example:

mbedgt --post-test-hook="lcov --gcov-tool arm-none-eabi-gcov  --capture \
--directory {build_path} --output-file {build_path}/test/{test_name}.info"

Support for option requirement.txt with host tests

Host tests are written independent of greentea and htrun. They can use python packages that may not be installed on the CI slaves.
Hence host test developers should be allowed to specify their python package requirements in an optional requirement.txt file. This file can be checked in with the host test script.

mbedgt fails at using the frdm-k64f-armcc platform

From the documentation, it is not clear whether mbedgt could work without arguments.
When invoking mbedgt --config, I see support for these targets:

C:\...\mbed-sdk>mbedgt --config
mbed-ls: detecting connected mbed-enabled devices...
mbed-ls: detected K64F, console at: COM31, mounted at: G:
yotta: search for mbed-target:k64f
        found target 'frdm-k64f-gcc'
        found target 'frdm-k64f-armcc'
mbedgt: available targets:
        got yotta target 'frdm-k64f-gcc'
        got yotta target 'frdm-k64f-armcc'

Example: execute 'mbedgt --target=TARGET_NAME' to start testing for TARGET_NAME target

Then, when launching mbedgt without arguments, the 'frdm-k64f-gcc' target builds ok and the tests pass.
However, there are lots of IOERR_COPY errors for the 'frdm-k64f-armcc' target:

C:\mbed\mbed-os\mbed-alpha3-rc-201505181200\libraries\mbed-sdk>mbedgt
mbed-ls: detecting connected mbed-enabled devices...
mbed-ls: detected K64F, console at: COM31, mounted at: G:
yotta: search for mbed-target:k64f
        found target 'frdm-k64f-gcc'
        found target 'frdm-k64f-armcc'
mbedgt: available targets:
        got yotta target 'frdm-k64f-gcc'
mbedgt: calling yotta to build your sources and tests: yotta -v --target=frdm-k64f-gcc,* build
info: generate for target: frdm-k64f-gcc 0.0.16 at C:\mbed\mbed-os\mbed-alpha3-rc-201505181200\libraries\mbed-sdk\yotta_targets\frdm-k64f-gcc
mbedOS.cmake included
GCC-C.cmake included
mbedOS-GNU-C.cmake included
GCC-GXX.cmake included
mbedOS-GNU-CXX.cmake included
GCC version is: 4.8.4
-- The ASM compiler identification is GNU
-- Found assembler: C:/ARM_GCC_4.8_2014q3/bin/arm-none-eabi-gcc.exe
GNU-ASM.cmake included
GNU-ASM.cmake included
-- Configuring done
-- Generating done
-- Build files have been written to: C:/mbed/mbed-os/mbed-alpha3-rc-201505181200/libraries/mbed-sdk/build/frdm-k64f-gcc
[107/160] Building C object ym/mbed-hal-ksdk-mcu/source/CMakeFiles/mbed-hal-ksdk-mcu.dir...965d684c6c84d04a/libraries/mbed-sdk/yotta_modules/mbed-hal-ksdk-mcu/source/i2c_api.c.obj
C:/mbed/mbed-os/mbed-alpha3-rc-201505181200/libraries/mbed-sdk/yotta_modules/mbed-hal-ksdk-mcu/source/i2c_api.c:42:12: warning: 'i2c_tx_event_check' declared 'static' but never def
ined [-Wunused-function]
 static int i2c_tx_event_check(i2c_t *obj);
            ^
[149/160] Linking CXX executable test/mbed-test-rtc
c:/arm_gcc_4.8_2014q3/bin/../lib/gcc/arm-none-eabi/4.8.4/../../../../arm-none-eabi/bin/ld.exe: test/mbed-test-rtc: section .uvisor.secure lma 0xb300 adjusted to 0xb400
[160/160] Linking CXX executable test/mbed-test-timeout
mbedgt: running tests...
        test 'mbed-test-detect' ...................................................... SKIPPED
        test 'mbed-test-functionpointer' ............................................. TIMEOUT
        test 'mbed-test-div' ......................................................... OK
        test 'mbed-test-dev_null' .................................................... OK
        test 'mbed-test-stl' ......................................................... SKIPPED
        test 'mbed-test-sleep_timeout' ............................................... SKIPPED
        test 'mbed-test-blinky' ...................................................... SKIPPED
        test 'mbed-test-timeout' ..................................................... OK
        test 'mbed-test-heap_and_stack' .............................................. SKIPPED
        test 'mbed-test-rtc' ......................................................... OK
        test 'mbed-test-cpp' ......................................................... OK
        test 'mbed-test-echo' ........................................................ OK
        test 'mbed-test-ticker_3' .................................................... OK
        test 'mbed-test-ticker_2' .................................................... OK
        test 'mbed-test-cstring' ..................................................... SKIPPED
        test 'mbed-test-time_us' ..................................................... OK
        test 'mbed-test-ticker' ...................................................... OK
        test 'mbed-test-serial_interrupt' ............................................ SKIPPED
        test 'mbed-test-call_before_main' ............................................ OK
        test 'mbed-test-hello' ....................................................... OK
        test 'mbed-test-stdio' ....................................................... OK
        test 'mbed-test-basic' ....................................................... OK
        got yotta target 'frdm-k64f-armcc'
mbedgt: calling yotta to build your sources and tests: yotta -v --target=frdm-k64f-armcc,* build
info: generate for target: frdm-k64f-armcc 0.0.10 at C:\mbed\mbed-os\mbed-alpha3-rc-201505181200\libraries\mbed-sdk\yotta_targets\frdm-k64f-armcc
mbedOS.cmake included
ARMCC-C.cmake included
mbedOS-GNU-C.cmake included
ARMCC-CXX.cmake included
mbedOS-GNU-CXX.cmake included
ARMCC-ASM.cmake included
-- Configuring done
-- Generating done
-- Build files have been written to: C:/mbed/mbed-os/mbed-alpha3-rc-201505181200/libraries/mbed-sdk/build/frdm-k64f-armcc
ninja: no work to do.
mbedgt: running tests...
        test 'mbed-test-detect' ...................................................... SKIPPED
        test 'mbed-test-functionpointer' ............................................. IOERR_COPY
Traceback (most recent call last):
  File "C:\Python27\Scripts\mbedhtrun-script.py", line 9, in <module>
    load_entry_point('mbed-host-tests==0.1.5', 'console_scripts', 'mbedhtrun')()
  File "build\bdist.win32\egg\mbed_host_tests\mbedhtrun.py", line 26, in main
  File "build\bdist.win32\egg\mbed_host_tests\__init__.py", line 108, in run
  File "build\bdist.win32\egg\mbed_host_tests\__init__.py", line 122, in execute
  File "build\bdist.win32\egg\mbed_host_tests\host_tests_runner\mbed_base.py", line 74, in init_serial
  File "build\bdist.win32\egg\mbed_host_tests\host_tests_runner\mbed_base.py", line 96, in pool_for_serial_init
IOError: [Errno 22] Invalid argument
        test 'mbed-test-div' ......................................................... IOERR_COPY
Traceback (most recent call last):
  File "C:\Python27\Scripts\mbedhtrun-script.py", line 9, in <module>
    load_entry_point('mbed-host-tests==0.1.5', 'console_scripts', 'mbedhtrun')()
  File "build\bdist.win32\egg\mbed_host_tests\mbedhtrun.py", line 26, in main
  File "build\bdist.win32\egg\mbed_host_tests\__init__.py", line 108, in run
  File "build\bdist.win32\egg\mbed_host_tests\__init__.py", line 122, in execute
  File "build\bdist.win32\egg\mbed_host_tests\host_tests_runner\mbed_base.py", line 74, in init_serial
  File "build\bdist.win32\egg\mbed_host_tests\host_tests_runner\mbed_base.py", line 96, in pool_for_serial_init
IOError: [Errno 22] Invalid argument
        test 'mbed-test-dev_null' .................................................... IOERR_COPY
        test 'mbed-test-stl' ......................................................... SKIPPED
        test 'mbed-test-sleep_timeout' ............................................... SKIPPED
        test 'mbed-test-blinky' ...................................................... SKIPPED
Traceback (most recent call last):
  File "C:\Python27\Scripts\mbedhtrun-script.py", line 9, in <module>
    load_entry_point('mbed-host-tests==0.1.5', 'console_scripts', 'mbedhtrun')()
  File "build\bdist.win32\egg\mbed_host_tests\mbedhtrun.py", line 26, in main
  File "build\bdist.win32\egg\mbed_host_tests\__init__.py", line 108, in run
  File "build\bdist.win32\egg\mbed_host_tests\__init__.py", line 122, in execute
  File "build\bdist.win32\egg\mbed_host_tests\host_tests_runner\mbed_base.py", line 74, in init_serial
  File "build\bdist.win32\egg\mbed_host_tests\host_tests_runner\mbed_base.py", line 96, in pool_for_serial_init
IOError: [Errno 22] Invalid argument
        test 'mbed-test-timeout' ..................................................... IOERR_COPY
        test 'mbed-test-heap_and_stack' .............................................. SKIPPED
Traceback (most recent call last):
  File "C:\Python27\Scripts\mbedhtrun-script.py", line 9, in <module>
    load_entry_point('mbed-host-tests==0.1.5', 'console_scripts', 'mbedhtrun')()
  File "build\bdist.win32\egg\mbed_host_tests\mbedhtrun.py", line 26, in main
  File "build\bdist.win32\egg\mbed_host_tests\__init__.py", line 108, in run
  File "build\bdist.win32\egg\mbed_host_tests\__init__.py", line 122, in execute
  File "build\bdist.win32\egg\mbed_host_tests\host_tests_runner\mbed_base.py", line 74, in init_serial
  File "build\bdist.win32\egg\mbed_host_tests\host_tests_runner\mbed_base.py", line 96, in pool_for_serial_init
IOError: [Errno 22] Invalid argument
        test 'mbed-test-rtc' ......................................................... IOERR_COPY
Traceback (most recent call last):
  File "C:\Python27\Scripts\mbedhtrun-script.py", line 9, in <module>
    load_entry_point('mbed-host-tests==0.1.5', 'console_scripts', 'mbedhtrun')()
  File "build\bdist.win32\egg\mbed_host_tests\mbedhtrun.py", line 26, in main
  File "build\bdist.win32\egg\mbed_host_tests\__init__.py", line 108, in run
  File "build\bdist.win32\egg\mbed_host_tests\__init__.py", line 122, in execute
  File "build\bdist.win32\egg\mbed_host_tests\host_tests_runner\mbed_base.py", line 74, in init_serial
  File "build\bdist.win32\egg\mbed_host_tests\host_tests_runner\mbed_base.py", line 96, in pool_for_serial_init
IOError: [Errno 22] Invalid argument
        test 'mbed-test-cpp' ......................................................... IOERR_COPY
Traceback (most recent call last):
  File "C:\Python27\Scripts\mbedhtrun-script.py", line 9, in <module>
    load_entry_point('mbed-host-tests==0.1.5', 'console_scripts', 'mbedhtrun')()
  File "build\bdist.win32\egg\mbed_host_tests\mbedhtrun.py", line 26, in main
  File "build\bdist.win32\egg\mbed_host_tests\__init__.py", line 108, in run
  File "build\bdist.win32\egg\mbed_host_tests\__init__.py", line 122, in execute
  File "build\bdist.win32\egg\mbed_host_tests\host_tests_runner\mbed_base.py", line 74, in init_serial
  File "build\bdist.win32\egg\mbed_host_tests\host_tests_runner\mbed_base.py", line 96, in pool_for_serial_init
IOError: [Errno 22] Invalid argument
        test 'mbed-test-echo' ........................................................ IOERR_COPY
Traceback (most recent call last):
  File "C:\Python27\Scripts\mbedhtrun-script.py", line 9, in <module>
    load_entry_point('mbed-host-tests==0.1.5', 'console_scripts', 'mbedhtrun')()
  File "build\bdist.win32\egg\mbed_host_tests\mbedhtrun.py", line 26, in main
  File "build\bdist.win32\egg\mbed_host_tests\__init__.py", line 108, in run
  File "build\bdist.win32\egg\mbed_host_tests\__init__.py", line 122, in execute
  File "build\bdist.win32\egg\mbed_host_tests\host_tests_runner\mbed_base.py", line 74, in init_serial
  File "build\bdist.win32\egg\mbed_host_tests\host_tests_runner\mbed_base.py", line 96, in pool_for_serial_init
IOError: [Errno 22] Invalid argument
        test 'mbed-test-ticker_3' .................................................... IOERR_COPY
Traceback (most recent call last):
  File "C:\Python27\Scripts\mbedhtrun-script.py", line 9, in <module>
    load_entry_point('mbed-host-tests==0.1.5', 'console_scripts', 'mbedhtrun')()
  File "build\bdist.win32\egg\mbed_host_tests\mbedhtrun.py", line 26, in main
  File "build\bdist.win32\egg\mbed_host_tests\__init__.py", line 108, in run
  File "build\bdist.win32\egg\mbed_host_tests\__init__.py", line 122, in execute
  File "build\bdist.win32\egg\mbed_host_tests\host_tests_runner\mbed_base.py", line 74, in init_serial
  File "build\bdist.win32\egg\mbed_host_tests\host_tests_runner\mbed_base.py", line 96, in pool_for_serial_init
IOError: [Errno 22] Invalid argument
        Traceback (most recent call last):
test 'mbed-test-ticker_2' ....................................................  File "C:\Python27\Scripts\mbedhtrun-script.py", line 9, in <module>
 IOERR_COPY
        load_entry_point('mbed-host-tests==0.1.5', 'console_scripts', 'mbedhtrun')()
test 'mbed-test-cstring' .....................................................  File "build\bdist.win32\egg\mbed_host_tests\mbedhtrun.py", line 26, in main
 SKIPPED
  File "build\bdist.win32\egg\mbed_host_tests\__init__.py", line 108, in run
  File "build\bdist.win32\egg\mbed_host_tests\__init__.py", line 122, in execute
  File "build\bdist.win32\egg\mbed_host_tests\host_tests_runner\mbed_base.py", line 74, in init_serial
  File "build\bdist.win32\egg\mbed_host_tests\host_tests_runner\mbed_base.py", line 96, in pool_for_serial_init
IOError: [Errno 22] Invalid argument
Traceback (most recent call last):
Traceback (most recent call last):
  File "C:\Python27\Scripts\mbedhtrun-script.py", line 9, in <module>
  File "C:\Python27\Scripts\mbedgt-script.py", line 9, in <module>
    load_entry_point('mbed-host-tests==0.1.5', 'console_scripts', 'mbedhtrun')()
    load_entry_point('mbed-greentea==0.0.5', 'console_scripts', 'mbedgt')()
  File "build\bdist.win32\egg\mbed_host_tests\mbedhtrun.py", line 26, in main
  File "build\bdist.win32\egg\mbed_greentea\mbed_greentea_cli.py", line 200, in main
  File "build\bdist.win32\egg\mbed_host_tests\__init__.py", line 108, in run
  File "build\bdist.win32\egg\mbed_greentea\mbed_test_api.py", line 228, in run_host_test
  File "build\bdist.win32\egg\mbed_host_tests\__init__.py", line 116, in execute
  File "build\bdist.win32\egg\mbed_greentea\mbed_test_api.py", line 157, in get_char_from_queue
  File "build\bdist.win32\egg\mbed_host_tests\host_tests_runner\mbed_base.py", line 185, in copy_image
  File "C:\Python27\lib\Queue.py", line 177, in get
KeyboardInterrupt
    self.not_empty.wait(remaining)
  File "C:\Python27\lib\threading.py", line 359, in wait
    _sleep(delay)
KeyboardInterrupt
Exception in thread Thread-27 (most likely raised during interpreter shutdown):

So, if arguments are required, I think the corresponding checks should be added to the parameter parsing section. Otherewise, all the listed tests should run without errors.

Win7: 'NoneType' object has no attribue 'lower'

OS: Windows 7 SP1 inside VirtualBox on OS X host

Installation: After installing yotta using the Windows installer v0.1.4 and then installing greentea using pip install mbed-greentea inside the yotta command shell.

Setup: Using mbed-drivers as a test environment with frdm-k64f-gcc target and a K64F board connected to the VM. mbedls output:

(workspace) C:\Users\username\mbed-drivers>mbedls
+---------------------+----------------------------+-------------------+-------------------+--------------------------------+
|platform_name        |platform_name_unique        |mount_point        |serial_port        |target_id                       |
+---------------------+----------------------------+-------------------+-------------------+--------------------------------+
|K64F                 |K64F[0]                     |F:                 |COM4               |02400201AA3F4E7757C1B3CF        |
|unknown              |None[0]                     |E:                 |COM3               |066BFF555055835087015049        |
+---------------------+----------------------------+-------------------+-------------------+--------------------------------+

I'm not sure what the unknown platform name is.

Problem: Python throws a stack-trace when attempting mbedgt -t frdm-k64f-gcc

(workspace) C:\Users\username\mbed-drivers>mbedgt -t frdm-k64f-gcc
mbedgt: detecting connected mbed-enabled devices...
mbedgt: detected 2 devices
        detected '', console at 'COM3', mounted at 'E:'
mbedgt: scan available targets for '' platform...
mbedgt: Unexpected error:
        'NoneType' object has no attribute 'lower'
Traceback (most recent call last):
  File "C:\yotta\python\Lib\runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "C:\yotta\python\Lib\runpy.py", line 72, in _run_code
    exec code in run_globals
  File "C:\yotta\workspace\Scripts\mbedgt.exe\__main__.py", line 9, in <module>
  File "c:\yotta\workspace\lib\site-packages\mbed_greentea\mbed_greentea_cli.py", line 210, in main
    cli_ret = main_cli(opts, args)
  File "c:\yotta\workspace\lib\site-packages\mbed_greentea\mbed_greentea_cli.py", line 318, in main_cli
    mut_info = get_mbed_clasic_target_info(mut['platform_name'])
  File "c:\yotta\workspace\lib\site-packages\mbed_greentea\mbed_target_info.py", line 187, in get_mbed_clasic_target_info
    TARGET_INFO_MAPPING = add_target_info_mapping(mbed_classic_name)
  File "c:\yotta\workspace\lib\site-packages\mbed_greentea\mbed_target_info.py", line 145, in add_target_info_mapping
    yotta_target_search = get_mbed_targets_from_yotta(mbed_classic_name)
  File "c:\yotta\workspace\lib\site-packages\mbed_greentea\mbed_target_info.py", line 117, in get_mbed_targets_from_yotta
    cmd = ['yotta', '--plain', 'search', '-k', 'mbed-target:%s'% mbed_classic_name.lower().strip(), 'target']
AttributeError: 'NoneType' object has no attribute 'lower'

@PrzemekWirkus

Naming module and entry script is inconsistent

I have often a problem with upgrading greentea, running it via command line or even finding this repository - recall a name which I should use. pip install mbedgt/mbed-greentea/greentea/mbed-gt ?

repository name: greentea
module name: mbed-greentea
entry point: mbedgt

I would propose to add to entry point mbed-greentea (greentea might be too general for use?).

This might apply to htrun (its much more inconsistent there).

[devel_transport] Greentea fails the test case when it is terminated at host side.

See PR https://github.com/ARMmbed/socket-test/pull/28

The tests are failing as target do not finish the test. As it implements a forever TCP/UDP server. The tests are terminated at host side when test finishes. Tests are essentially one test in one binary/Test Suite. Greentea should be able to determine correct test result.

Solution:
host test can generate the prints that greentea parses for determining test case summary/results. Example is notify_complete.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.