Skip to content

Commit 81bedff

Browse files
committed
lwip: Added hash to mac addresses during tests
Avoids accidentally using a part of the uuid that isn't very unique. ie, the mac address component of type 1 uuids.
1 parent 2761a8c commit 81bedff

File tree

12 files changed

+89
-14
lines changed

12 files changed

+89
-14
lines changed

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,15 @@ void test_bring_up_down() {
5252
// Test setup
5353
utest::v1::status_t test_setup(const size_t number_of_cases) {
5454
char uuid[48] = {0};
55-
GREENTEA_SETUP_UUID(120, "default_auto", uuid, 48);
56-
mbed_set_mac_address(uuid, /*coerce control bits*/ 1);
55+
GREENTEA_SETUP_UUID(120, "default_auto", uuid, sizeof(uuid));
56+
57+
// create mac address based on uuid
58+
uint64_t mac = 0;
59+
for (int i = 0; i < sizeof(uuid); i++) {
60+
mac += uuid[i];
61+
}
62+
mbed_set_mac_address((const char*)mac, /*coerce control bits*/ 1);
63+
5764
return verbose_test_setup_handler(number_of_cases);
5865
}
5966

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,15 @@ void test_dns_literal_pref() {
9393
utest::v1::status_t test_setup(const size_t number_of_cases) {
9494
char uuid[48] = {0};
9595
GREENTEA_SETUP_UUID(120, "default_auto", uuid, 48);
96-
mbed_set_mac_address(uuid, /*coerce control bits*/ 1);
96+
97+
// create mac address based on uuid
98+
uint64_t mac = 0;
99+
for (int i = 0; i < sizeof(uuid); i++) {
100+
mac += uuid[i];
101+
}
102+
mbed_set_mac_address((const char*)mac, /*coerce control bits*/ 1);
97103
net_bringup();
104+
98105
return verbose_test_setup_handler(number_of_cases);
99106
}
100107

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,14 @@ void prep_buffer(char *tx_buffer, size_t tx_size) {
3131
int main() {
3232
char uuid[48] = {0};
3333
GREENTEA_SETUP_UUID(120, "tcp_echo", uuid, 48);
34-
mbed_set_mac_address(uuid, /*coerce control bits TRUE */ 1);
34+
35+
// create mac address based on uuid
36+
uint64_t mac = 0;
37+
for (int i = 0; i < sizeof(uuid); i++) {
38+
mac += uuid[i];
39+
}
40+
mbed_set_mac_address((const char*)mac, /*coerce control bits*/ 1);
41+
3542
EthernetInterface eth;
3643
int err = eth.connect();
3744

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,13 @@ Echo echoers[MBED_CFG_TCP_CLIENT_ECHO_THREADS];
9090
int main() {
9191
char uuid[48] = {0};
9292
GREENTEA_SETUP_UUID(120, "tcp_echo", uuid, 48);
93-
mbed_set_mac_address(uuid, /*coerce control bits*/ 1);
93+
94+
// create mac address based on uuid
95+
uint64_t mac = 0;
96+
for (int i = 0; i < sizeof(uuid); i++) {
97+
mac += uuid[i];
98+
}
99+
mbed_set_mac_address((const char*)mac, /*coerce control bits*/ 1);
94100

95101
int err = net.connect();
96102
TEST_ASSERT_EQUAL(0, err);

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,16 @@ bool find_substring(const char *first, const char *last, const char *s_first, co
3838
int main() {
3939
char uuid[48] = {0};
4040
GREENTEA_SETUP_UUID(120, "default_auto", uuid, 48);
41-
mbed_set_mac_address(uuid, /*coerce control bits*/ 1);
41+
42+
// create mac address based on uuid
43+
uint64_t mac = 0;
44+
for (int i = 0; i < sizeof(uuid); i++) {
45+
mac += uuid[i];
46+
}
47+
mbed_set_mac_address((const char*)mac, /*coerce control bits*/ 1);
4248

4349
bool result = false;
4450
EthernetInterface eth;
45-
//eth.init(); //Use DHCP
4651
eth.connect();
4752
printf("TCP client IP Address is %s\r\n", eth.get_ip_address());
4853

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,13 @@ void generate_buffer(uint8_t **buffer, size_t *size, size_t min, size_t max) {
110110
int main() {
111111
char uuid[48] = {0};
112112
GREENTEA_SETUP_UUID(120, "tcp_echo", uuid, 48);
113-
mbed_set_mac_address(uuid, /*coerce control bits*/ 1);
113+
114+
// create mac address based on uuid
115+
uint64_t mac = 0;
116+
for (int i = 0; i < sizeof(uuid); i++) {
117+
mac += uuid[i];
118+
}
119+
mbed_set_mac_address((const char*)mac, /*coerce control bits*/ 1);
114120

115121
generate_buffer(&buffer, &buffer_size,
116122
MBED_CFG_TCP_CLIENT_PACKET_PRESSURE_MIN,

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,13 @@ PressureTest *pressure_tests[MBED_CFG_TCP_CLIENT_PACKET_PRESSURE_THREADS];
227227
int main() {
228228
char uuid[48] = {0};
229229
GREENTEA_SETUP_UUID(120, "tcp_echo", uuid, 48);
230-
mbed_set_mac_address(uuid, /*coerce control bits*/ 1);
230+
231+
// create mac address based on uuid
232+
uint64_t mac = 0;
233+
for (int i = 0; i < sizeof(uuid); i++) {
234+
mac += uuid[i];
235+
}
236+
mbed_set_mac_address((const char*)mac, /*coerce control bits*/ 1);
231237

232238
uint8_t *buffer;
233239
size_t buffer_size;

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,13 @@ const int udp_dtls_handshake_count = sizeof(udp_dtls_handshake_pattern) / sizeof
3434
int main() {
3535
char uuid[48] = {0};
3636
GREENTEA_SETUP_UUID(120, "udp_shotgun", uuid, 48);
37-
mbed_set_mac_address(uuid, /*coerce control bits*/ 1);
37+
38+
// create mac address based on uuid
39+
uint64_t mac = 0;
40+
for (int i = 0; i < sizeof(uuid); i++) {
41+
mac += uuid[i];
42+
}
43+
mbed_set_mac_address((const char*)mac, /*coerce control bits*/ 1);
3844

3945
EthernetInterface eth;
4046
int err = eth.connect();

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,14 @@ int main() {
4646
GREENTEA_SETUP_UUID(120, "udp_echo", uuid, 48);
4747
printf("Got a uuid of %s\r\n", uuid);
4848
size_t uuid_len = strlen(uuid);
49+
50+
// create mac address based on uuid
51+
uint64_t mac = 0;
52+
for (int i = 0; i < sizeof(uuid); i++) {
53+
mac += uuid[i];
54+
}
55+
mbed_set_mac_address((const char*)mac, /*coerce control bits*/ 1);
56+
4957
EthernetInterface eth;
5058

5159
int err = eth.connect();

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,15 @@ int main() {
160160
char uuid[48] = {0};
161161
GREENTEA_SETUP_UUID(120, "udp_echo", uuid, 48);
162162
printf("Got a uuid of %s\r\n", uuid);
163-
mbed_set_mac_address(uuid, /*coerce control bits*/ 1);
164-
165163
size_t uuid_len = strlen(uuid);
166164

165+
// create mac address based on uuid
166+
uint64_t mac = 0;
167+
for (int i = 0; i < sizeof(uuid); i++) {
168+
mac += uuid[i];
169+
}
170+
mbed_set_mac_address((const char*)mac, /*coerce control bits*/ 1);
171+
167172
int err = net.connect();
168173
TEST_ASSERT_EQUAL(0, err);
169174

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,13 @@ void generate_buffer(uint8_t **buffer, size_t *size, size_t min, size_t max) {
113113
int main() {
114114
char uuid[48] = {0};
115115
GREENTEA_SETUP_UUID(120, "udp_echo", uuid, 48);
116-
mbed_set_mac_address(uuid, /*coerce control bits*/ 1);
116+
117+
// create mac address based on uuid
118+
uint64_t mac = 0;
119+
for (int i = 0; i < sizeof(uuid); i++) {
120+
mac += uuid[i];
121+
}
122+
mbed_set_mac_address((const char*)mac, /*coerce control bits*/ 1);
117123

118124
generate_buffer(&buffer, &buffer_size,
119125
MBED_CFG_UDP_CLIENT_PACKET_PRESSURE_MIN,

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,13 @@ PressureTest *pressure_tests[MBED_CFG_UDP_CLIENT_PACKET_PRESSURE_THREADS];
252252
int main() {
253253
char uuid[48] = {0};
254254
GREENTEA_SETUP_UUID(120, "udp_echo", uuid, 48);
255-
mbed_set_mac_address(uuid, /*coerce control bits*/ 1);
255+
256+
// create mac address based on uuid
257+
uint64_t mac = 0;
258+
for (int i = 0; i < sizeof(uuid); i++) {
259+
mac += uuid[i];
260+
}
261+
mbed_set_mac_address((const char*)mac, /*coerce control bits*/ 1);
256262

257263
uint8_t *buffer;
258264
size_t buffer_size;

0 commit comments

Comments
 (0)