mirror of https://github.com/ARMmbed/mbed-os.git
Adding ability to preserve Greentea UUID in test.
The Greentea UUID can be used as a source of entropy/randomness during the test. This is useful for uniquely identifying a test run.pull/4369/head
parent
98a5262361
commit
551ff03dc0
|
@ -77,6 +77,7 @@ extern const char* GREENTEA_TEST_ENV_LCOV_START;
|
|||
* Greentea-client related API for communication with host side
|
||||
*/
|
||||
void GREENTEA_SETUP(const int, const char *);
|
||||
void GREENTEA_SETUP_UUID(const int timeout, const char *host_test_name, char *buffer, size_t size);
|
||||
void GREENTEA_TESTSUITE_RESULT(const int);
|
||||
void GREENTEA_TESTCASE_START(const char *test_case_name);
|
||||
void GREENTEA_TESTCASE_FINISH(const char *test_case_name, const size_t passes, const size_t failed);
|
||||
|
|
|
@ -60,25 +60,21 @@ static void greentea_notify_completion(const int);
|
|||
static void greentea_notify_version();
|
||||
static void greentea_write_string(const char *str);
|
||||
|
||||
/** \brief Handshake with host and send setup data (timeout and host test name)
|
||||
* \details This function will send preamble to master.
|
||||
* After host test name is received master will invoke host test script
|
||||
* and add hos test's callback handlers to main event loop
|
||||
* This function is blocking.
|
||||
*/
|
||||
void GREENTEA_SETUP(const int timeout, const char *host_test_name) {
|
||||
|
||||
void _GREENTEA_SETUP_COMMON(const int timeout, const char *host_test_name, char *buffer, size_t size) {
|
||||
greentea_metrics_setup();
|
||||
// Key-value protocol handshake function. Waits for {{__sync;...}} message
|
||||
// Sync preamble: "{{__sync;0dad4a9d-59a3-4aec-810d-d5fb09d852c1}}"
|
||||
// Example value of sync_uuid == "0dad4a9d-59a3-4aec-810d-d5fb09d852c1"
|
||||
char _key[8] = {0};
|
||||
char _value[48] = {0};
|
||||
while (1) {
|
||||
greentea_parse_kv(_key, _value, sizeof(_key), sizeof(_value));
|
||||
|
||||
char _key[8] = {0};
|
||||
|
||||
while (1) {
|
||||
greentea_parse_kv(_key, buffer, sizeof(_key), size);
|
||||
greentea_write_string("mbedmbedmbedmbedmbedmbedmbedmbed\r\n");
|
||||
if (strcmp(_key, GREENTEA_TEST_ENV_SYNC) == 0) {
|
||||
// Found correct __sunc message
|
||||
greentea_send_kv(_key, _value);
|
||||
greentea_send_kv(_key, buffer);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -88,6 +84,27 @@ void GREENTEA_SETUP(const int timeout, const char *host_test_name) {
|
|||
greentea_notify_hosttest(host_test_name);
|
||||
}
|
||||
|
||||
/** \brief Handshake with host and send setup data (timeout and host test name)
|
||||
* \details This function will send preamble to master.
|
||||
* After host test name is received master will invoke host test script
|
||||
* and add hos test's callback handlers to main event loop
|
||||
* This function is blocking.
|
||||
*/
|
||||
void GREENTEA_SETUP(const int timeout, const char *host_test_name) {
|
||||
char _value[48] = {0};
|
||||
_GREENTEA_SETUP_COMMON(timeout, host_test_name, _value, 48);
|
||||
}
|
||||
|
||||
/** \brief Handshake with host and send setup data (timeout and host test name)
|
||||
* \details This function will send preamble to master.
|
||||
* After host test name is received master will invoke host test script
|
||||
* and add hos test's callback handlers to main event loop
|
||||
* This function is blocking.
|
||||
*/
|
||||
void GREENTEA_SETUP_UUID(const int timeout, const char *host_test_name, char *buffer, size_t size) {
|
||||
_GREENTEA_SETUP_COMMON(timeout, host_test_name, buffer, size);
|
||||
}
|
||||
|
||||
/** \brief Notify host (__exit message) side that test suite execution was complete
|
||||
* \result Test suite result
|
||||
* \details If __exit is not received by host side we will assume TIMEOUT
|
||||
|
@ -194,7 +211,7 @@ inline void greentea_write_preamble()
|
|||
greentea_serial->putc('{');
|
||||
greentea_serial->putc('{');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Write the postamble characters to the serial port
|
||||
*
|
||||
|
@ -202,7 +219,7 @@ inline void greentea_write_preamble()
|
|||
* for key-value comunication between the target and the host.
|
||||
* This uses a Rawserial object, greentea_serial, which provides
|
||||
* a direct interface to the USBTX and USBRX serial pins and allows
|
||||
* the direct writing of characters using the putc() method.
|
||||
* the direct writing of characters using the putc() method.
|
||||
* This suite of functions are provided to allow for serial communication
|
||||
* to the host from within a thread/ISR.
|
||||
*
|
||||
|
@ -238,8 +255,8 @@ inline void greentea_write_string(const char *str)
|
|||
* \brief Write an int to the serial port
|
||||
*
|
||||
* This function writes an integer value from the target
|
||||
* to the host. The integer value is converted to a string and
|
||||
* and then written character by character directly to the serial
|
||||
* to the host. The integer value is converted to a string and
|
||||
* and then written character by character directly to the serial
|
||||
* port using the greentea_serial, Rawserial object.
|
||||
* sprintf() is used to convert the int to a string. Sprintf if
|
||||
* inherently thread safe so can be used.
|
||||
|
@ -302,7 +319,7 @@ void greentea_send_kv(const char *key, const int val) {
|
|||
greentea_write_postamble();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Encapsulate and send key-value-value message from DUT to host
|
||||
*
|
||||
|
@ -367,10 +384,10 @@ void greentea_send_kv(const char *key, const char *val, const int passes, const
|
|||
/**
|
||||
* \brief Encapsulate and send key-value-value message from DUT to host
|
||||
*
|
||||
* This function uses underlying functions to write directly
|
||||
* to the serial port, (USBTX). This allows key-value-value to be used
|
||||
* This function uses underlying functions to write directly
|
||||
* to the serial port, (USBTX). This allows key-value-value to be used
|
||||
* from within interrupt context.
|
||||
* Both values are integers to avoid integer to string conversion
|
||||
* Both values are integers to avoid integer to string conversion
|
||||
* made by the user.
|
||||
*
|
||||
* Names of the parameters: this function is used to send number
|
||||
|
|
Loading…
Reference in New Issue