mbed-os/features/frameworks/greentea-client
RAJKUMAR KANAGARAJ 3fc8905315 Fixed the greentea test dependency and incorporated the review comments
-Added the mbedtls,crypto,psa,filesystem,fat,littlefs in baremetal.json to resolve compiler issue
 -Disable metrics that are not available for bare metal
 -Moved the baremetal.json inside TESTS/configs directory
2019-11-05 08:49:27 -08:00
..
greentea-client Can compile without serial 2019-07-22 16:17:52 +02:00
source Fixed the greentea test dependency and incorporated the review comments 2019-11-05 08:49:27 -08:00
README.md Correct example given in greentea-client readme 2019-01-28 16:35:34 -06:00
mbed_lib.json Add placeholder libraries for things we probably refer to as libraries 2019-01-16 14:58:58 -06:00

README.md

Table of contents

greentea-client

greentea-client is a client library for the Greentea test tool when used in an Mbed OS project.

This package implements the client side of the key-value protocol used for communication between the device under test (DUT) and the host. The Greentea tool implements the protocol's host behavior. We use utest as our test harness.

      DUT  <--- serial port connection --->  host
    (client)         .                       (host)
                    .
[greentea-client]   .       [conn_process]               [htrun]
     =====          .      ================             =========
       |            .             |                         |
       |            .             |                         |
       |    {{ key ; value }}     |                         |
       |------------------------->| (key, value, timestamp) |
       |            .             |------------------------>|
       |            .             |                         |
       |            .             |                         |
       |            .             |                         |
       |            .             |                         |
       |            .             |                         |
       |            .             | (key, value, timestamp) |
       |    {{ key ; value }}     |<------------------------|
       |<-------------------------|                         |
       |            .             |                         |
                    .

Concepts

Test suite

A test suite is a binary containing test cases we execute on hardware. The test suite has a beginning and an end (like the main() function would. The test suite may pass, fail or be in an error state (for example, if the test suite times out or there was a serial port connection problem).

Test case

A test case is contained within a test suite. You can have multiple test cases within a test suite. unity assert macros are used to run the checks during the test case. Your test cases may pass, fail or be in an error state.

Key-value protocol

The key-value protocol is a protocol specific to the Greentea test tool. It is used to send messages (events) between the DUT and the host. Each message consists of a key and value pair. A message is surrounded by double curly braces. The key and value are separated by a semicolon (;).

For example, the {{timeout;120}}} string is a key-value message where the key timeout has the value 120. Both greentea-client and Greentea understand this format and can detect key-value messages in a data stream.

Test example

#include "mbed.h"
#include "greentea-client/test_env.h"
#include "utest/utest.h"
#include "unity/unity.h"

void test_case_1_func() {
    // Test case #1 body
    // Here you can run your test cases and assertions
    TEST_ASSERT_TRUE(true);
    TEST_ASSERT_FALSE(false);
}

void test_case_2_func() {
    // Test case #2 body
    // Here you can run your test cases and assertions
    TEST_ASSERT_TRUE(true);
    TEST_ASSERT_FALSE(false);
}

const Case cases[] = {
    Case("Test case #1 name", test_case_1_func),
    Case("Test case #1 name", test_case_2_func)
};

status_t greentea_setup(const size_t number_of_cases) {
    GREENTEA_SETUP(5, "default_auto");
    return greentea_test_setup_handler(number_of_cases);
}

void main(int, char*[]) {
    Harness::run(specification);
}