Specifying default length of UUID for Greentea

This creates a macro for the UUID length used by Greentea. This cuts
down on the use of "magic numbers" in test cases that use
the GREENTEA_SETUP_UUID function.
pull/4369/head
Brian Daniels 2017-05-22 18:39:12 -05:00 committed by Martin Kojtal
parent d451d1795e
commit 6e76fce4fc
4 changed files with 11 additions and 6 deletions

View File

@ -29,7 +29,7 @@ namespace {
char rx_buffer[MBED_CFG_UDP_CLIENT_ECHO_BUFFER_SIZE] = {0};
const char ASCII_MAX = '~' - ' ';
const int ECHO_LOOPS = 16;
char uuid[48] = {0};
char uuid[GREENTEA_UUID_LENGTH] = {0};
}
void prep_buffer(char *uuid, char *tx_buffer, size_t tx_size) {
@ -127,7 +127,7 @@ void test_udp_echo() {
// Test setup
utest::v1::status_t test_setup(const size_t number_of_cases) {
GREENTEA_SETUP_UUID(120, "udp_echo", uuid, 48);
GREENTEA_SETUP_UUID(120, "udp_echo", uuid, GREENTEA_UUID_LENGTH);
return verbose_test_setup_handler(number_of_cases);
}

View File

@ -32,7 +32,7 @@ const int ECHO_LOOPS = 16;
EthernetInterface net;
SocketAddress udp_addr;
Mutex iomutex;
char uuid[48] = {0};
char uuid[GREENTEA_UUID_LENGTH] = {0};
// NOTE: assuming that "id" stays in the single digits
void prep_buffer(int id, char *uuid, char *tx_buffer, size_t tx_size) {
@ -202,7 +202,7 @@ void test_udp_echo_parallel() {
// Test setup
utest::v1::status_t test_setup(const size_t number_of_cases) {
GREENTEA_SETUP_UUID(120, "udp_echo", uuid, 48);
GREENTEA_SETUP_UUID(120, "udp_echo", uuid, GREENTEA_UUID_LENGTH);
return verbose_test_setup_handler(number_of_cases);
}

View File

@ -43,6 +43,11 @@
#define TEST_ENV_TESTCASE_FINISH GREENTEA_TEST_ENV_TESTCASE_FINISH
#define TEST_ENV_TESTCASE_SUMMARY GREENTEA_TEST_ENV_TESTCASE_SUMMARY
/**
* Default length for UUID buffers (used during the sync process)
*/
#define GREENTEA_UUID_LENGTH 48
/**
* Generic test suite transport protocol keys
*/

View File

@ -91,8 +91,8 @@ void _GREENTEA_SETUP_COMMON(const int timeout, const char *host_test_name, char
* 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);
char _value[GREENTEA_UUID_LENGTH] = {0};
_GREENTEA_SETUP_COMMON(timeout, host_test_name, _value, GREENTEA_UUID_LENGTH);
}
/** \brief Handshake with host and send setup data (timeout and host test name)