Skip to content

Commit b44e7e9

Browse files
bridadanadbridge
authored andcommitted
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.
1 parent dfae18a commit b44e7e9

File tree

4 files changed

+11
-6
lines changed

4 files changed

+11
-6
lines changed

features/FEATURE_LWIP/TESTS/mbedmicro-net/udp_echo/main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ namespace {
2929
char rx_buffer[MBED_CFG_UDP_CLIENT_ECHO_BUFFER_SIZE] = {0};
3030
const char ASCII_MAX = '~' - ' ';
3131
const int ECHO_LOOPS = 16;
32-
char uuid[48] = {0};
32+
char uuid[GREENTEA_UUID_LENGTH] = {0};
3333
}
3434

3535
void prep_buffer(char *uuid, char *tx_buffer, size_t tx_size) {
@@ -127,7 +127,7 @@ void test_udp_echo() {
127127

128128
// Test setup
129129
utest::v1::status_t test_setup(const size_t number_of_cases) {
130-
GREENTEA_SETUP_UUID(120, "udp_echo", uuid, 48);
130+
GREENTEA_SETUP_UUID(120, "udp_echo", uuid, GREENTEA_UUID_LENGTH);
131131
return verbose_test_setup_handler(number_of_cases);
132132
}
133133

features/FEATURE_LWIP/TESTS/mbedmicro-net/udp_echo_parallel/main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const int ECHO_LOOPS = 16;
3232
EthernetInterface net;
3333
SocketAddress udp_addr;
3434
Mutex iomutex;
35-
char uuid[48] = {0};
35+
char uuid[GREENTEA_UUID_LENGTH] = {0};
3636

3737
// NOTE: assuming that "id" stays in the single digits
3838
void prep_buffer(int id, char *uuid, char *tx_buffer, size_t tx_size) {
@@ -202,7 +202,7 @@ void test_udp_echo_parallel() {
202202

203203
// Test setup
204204
utest::v1::status_t test_setup(const size_t number_of_cases) {
205-
GREENTEA_SETUP_UUID(120, "udp_echo", uuid, 48);
205+
GREENTEA_SETUP_UUID(120, "udp_echo", uuid, GREENTEA_UUID_LENGTH);
206206
return verbose_test_setup_handler(number_of_cases);
207207
}
208208

features/frameworks/greentea-client/greentea-client/test_env.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@
4343
#define TEST_ENV_TESTCASE_FINISH GREENTEA_TEST_ENV_TESTCASE_FINISH
4444
#define TEST_ENV_TESTCASE_SUMMARY GREENTEA_TEST_ENV_TESTCASE_SUMMARY
4545

46+
/**
47+
* Default length for UUID buffers (used during the sync process)
48+
*/
49+
#define GREENTEA_UUID_LENGTH 48
50+
4651
/**
4752
* Generic test suite transport protocol keys
4853
*/

features/frameworks/greentea-client/source/greentea_test_env.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ void _GREENTEA_SETUP_COMMON(const int timeout, const char *host_test_name, char
9191
* This function is blocking.
9292
*/
9393
void GREENTEA_SETUP(const int timeout, const char *host_test_name) {
94-
char _value[48] = {0};
95-
_GREENTEA_SETUP_COMMON(timeout, host_test_name, _value, 48);
94+
char _value[GREENTEA_UUID_LENGTH] = {0};
95+
_GREENTEA_SETUP_COMMON(timeout, host_test_name, _value, GREENTEA_UUID_LENGTH);
9696
}
9797

9898
/** \brief Handshake with host and send setup data (timeout and host test name)

0 commit comments

Comments
 (0)