Skip to content

Commit bb2d327

Browse files
gekyadbridge
authored andcommitted
lwip: Migrated to utest framework
per @bridadan
1 parent be97cef commit bb2d327

File tree

12 files changed

+243
-80
lines changed

12 files changed

+243
-80
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ utest::v1::status_t test_setup(const size_t number_of_cases) {
5656
}
5757

5858
Case cases[] = {
59-
Case("Testing bringing the network up and down", test_bring_up_down<1>),
60-
Case("Testing bringing the network up and down twice", test_bring_up_down<2>),
59+
Case("Bringing the network up and down", test_bring_up_down<1>),
60+
Case("Bringing the network up and down twice", test_bring_up_down<2>),
6161
};
6262

6363
Specification specification(test_setup, cases);

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,10 @@ utest::v1::status_t test_setup(const size_t number_of_cases) {
9797
}
9898

9999
Case cases[] = {
100-
Case("Testing DNS query", test_dns_query),
101-
Case("Testing DNS preference query", test_dns_query_pref),
102-
Case("Testing DNS literal", test_dns_literal),
103-
Case("Testing DNS preference literal", test_dns_literal_pref),
100+
Case("DNS query", test_dns_query),
101+
Case("DNS preference query", test_dns_query_pref),
102+
Case("DNS literal", test_dns_literal),
103+
Case("DNS preference literal", test_dns_literal_pref),
104104
};
105105

106106
Specification specification(test_setup, cases);

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

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
#include "TCPSocket.h"
1111
#include "greentea-client/test_env.h"
1212
#include "unity/unity.h"
13+
#include "utest.h"
14+
15+
using namespace utest::v1;
1316

1417

1518
#ifndef MBED_CFG_TCP_CLIENT_ECHO_BUFFER_SIZE
@@ -28,14 +31,13 @@ void prep_buffer(char *tx_buffer, size_t tx_size) {
2831
}
2932
}
3033

31-
int main() {
32-
GREENTEA_SETUP(120, "tcp_echo");
34+
void test_tcp_echo() {
3335
EthernetInterface eth;
3436
int err = eth.connect();
3537

3638
if (err) {
3739
printf("MBED: failed to connect with an error of %d\r\n", err);
38-
GREENTEA_TESTSUITE_RESULT(false);
40+
TEST_ASSERT_EQUAL(0, err);
3941
}
4042

4143
printf("MBED: TCPClient IP address is '%s'\n", eth.get_ip_address());
@@ -80,5 +82,22 @@ int main() {
8082

8183
sock.close();
8284
eth.disconnect();
83-
GREENTEA_TESTSUITE_RESULT(result);
85+
TEST_ASSERT_EQUAL(true, result);
86+
}
87+
88+
89+
// Test setup
90+
utest::v1::status_t test_setup(const size_t number_of_cases) {
91+
GREENTEA_SETUP(120, "tcp_echo");
92+
return verbose_test_setup_handler(number_of_cases);
93+
}
94+
95+
Case cases[] = {
96+
Case("TCP echo", test_tcp_echo),
97+
};
98+
99+
Specification specification(test_setup, cases);
100+
101+
int main() {
102+
return !Harness::run(specification);
84103
}

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

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
#include "TCPSocket.h"
1111
#include "greentea-client/test_env.h"
1212
#include "unity/unity.h"
13+
#include "utest.h"
14+
15+
using namespace utest::v1;
1316

1417

1518
#ifndef MBED_CFG_TCP_CLIENT_ECHO_BUFFER_SIZE
@@ -84,11 +87,9 @@ class Echo {
8487
}
8588
};
8689

87-
int main() {
88-
GREENTEA_SETUP(120, "tcp_echo");
8990

91+
void test_tcp_echo_parallel() {
9092
Echo echoers[MBED_CFG_TCP_CLIENT_ECHO_THREADS];
91-
9293
int err = net.connect();
9394
TEST_ASSERT_EQUAL(0, err);
9495

@@ -123,5 +124,20 @@ int main() {
123124
}
124125

125126
net.disconnect();
126-
GREENTEA_TESTSUITE_RESULT(true);
127+
}
128+
129+
// Test setup
130+
utest::v1::status_t test_setup(const size_t number_of_cases) {
131+
GREENTEA_SETUP(120, "tcp_echo");
132+
return verbose_test_setup_handler(number_of_cases);
133+
}
134+
135+
Case cases[] = {
136+
Case("TCP echo parallel", test_tcp_echo_parallel),
137+
};
138+
139+
Specification specification(test_setup, cases);
140+
141+
int main() {
142+
return !Harness::run(specification);
127143
}

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

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111
#include "TCPSocket.h"
1212
#include "greentea-client/test_env.h"
1313
#include "unity/unity.h"
14+
#include "utest.h"
15+
16+
using namespace utest::v1;
17+
1418

1519
namespace {
1620
// Test connection information
@@ -35,9 +39,7 @@ bool find_substring(const char *first, const char *last, const char *s_first, co
3539
return (f != last);
3640
}
3741

38-
int main() {
39-
GREENTEA_SETUP(120, "default_auto");
40-
42+
void test_tcp_hello_world() {
4143
bool result = false;
4244
EthernetInterface eth;
4345
//eth.init(); //Use DHCP
@@ -83,5 +85,22 @@ int main() {
8385
}
8486

8587
eth.disconnect();
86-
GREENTEA_TESTSUITE_RESULT(result);
88+
TEST_ASSERT_EQUAL(true, result);
89+
}
90+
91+
92+
// Test setup
93+
utest::v1::status_t test_setup(const size_t number_of_cases) {
94+
GREENTEA_SETUP(120, "default_auto");
95+
return verbose_test_setup_handler(number_of_cases);
96+
}
97+
98+
Case cases[] = {
99+
Case("TCP hello world", test_tcp_hello_world),
100+
};
101+
102+
Specification specification(test_setup, cases);
103+
104+
int main() {
105+
return !Harness::run(specification);
87106
}

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

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
#include "TCPSocket.h"
1414
#include "greentea-client/test_env.h"
1515
#include "unity/unity.h"
16+
#include "utest.h"
17+
18+
using namespace utest::v1;
1619

1720

1821
#ifndef MBED_CFG_TCP_CLIENT_PACKET_PRESSURE_MIN
@@ -107,8 +110,7 @@ void generate_buffer(uint8_t **buffer, size_t *size, size_t min, size_t max) {
107110
}
108111

109112

110-
int main() {
111-
GREENTEA_SETUP(120, "tcp_echo");
113+
void test_tcp_packet_pressure() {
112114
generate_buffer(&buffer, &buffer_size,
113115
MBED_CFG_TCP_CLIENT_PACKET_PRESSURE_MIN,
114116
MBED_CFG_TCP_CLIENT_PACKET_PRESSURE_MAX);
@@ -123,8 +125,6 @@ int main() {
123125

124126
greentea_send_kv("target_ip", eth.get_ip_address());
125127

126-
bool result = true;
127-
128128
char recv_key[] = "host_port";
129129
char ipbuf[60] = {0};
130130
char portbuf[16] = {0};
@@ -223,5 +223,21 @@ int main() {
223223
MBED_CFG_TCP_CLIENT_PACKET_PRESSURE_MIN) / (1000*timer.read()));
224224

225225
eth.disconnect();
226-
GREENTEA_TESTSUITE_RESULT(result);
226+
}
227+
228+
229+
// Test setup
230+
utest::v1::status_t test_setup(const size_t number_of_cases) {
231+
GREENTEA_SETUP(120, "tcp_echo");
232+
return verbose_test_setup_handler(number_of_cases);
233+
}
234+
235+
Case cases[] = {
236+
Case("TCP packet pressure", test_tcp_packet_pressure),
237+
};
238+
239+
Specification specification(test_setup, cases);
240+
241+
int main() {
242+
return !Harness::run(specification);
227243
}

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

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
#include "TCPSocket.h"
1414
#include "greentea-client/test_env.h"
1515
#include "unity/unity.h"
16+
#include "utest.h"
17+
18+
using namespace utest::v1;
1619

1720

1821
#ifndef MBED_CFG_TCP_CLIENT_PACKET_PRESSURE_MIN
@@ -224,9 +227,7 @@ class PressureTest {
224227
PressureTest *pressure_tests[MBED_CFG_TCP_CLIENT_PACKET_PRESSURE_THREADS];
225228

226229

227-
int main() {
228-
GREENTEA_SETUP(120, "tcp_echo");
229-
230+
void test_tcp_packet_pressure_parallel() {
230231
uint8_t *buffer;
231232
size_t buffer_size;
232233
generate_buffer(&buffer, &buffer_size,
@@ -247,8 +248,6 @@ int main() {
247248

248249
greentea_send_kv("target_ip", net.get_ip_address());
249250

250-
bool result = true;
251-
252251
char recv_key[] = "host_port";
253252
char ipbuf[60] = {0};
254253
char portbuf[16] = {0};
@@ -286,5 +285,21 @@ int main() {
286285
MBED_CFG_TCP_CLIENT_PACKET_PRESSURE_MIN) / (1000*timer.read()));
287286

288287
net.disconnect();
289-
GREENTEA_TESTSUITE_RESULT(result);
288+
}
289+
290+
291+
// Test setup
292+
utest::v1::status_t test_setup(const size_t number_of_cases) {
293+
GREENTEA_SETUP(120, "tcp_echo");
294+
return verbose_test_setup_handler(number_of_cases);
295+
}
296+
297+
Case cases[] = {
298+
Case("TCP packet pressure parallel", test_tcp_packet_pressure_parallel),
299+
};
300+
301+
Specification specification(test_setup, cases);
302+
303+
int main() {
304+
return !Harness::run(specification);
290305
}

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

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
#include "UDPSocket.h"
1111
#include "greentea-client/test_env.h"
1212
#include "unity/unity.h"
13+
#include "utest.h"
14+
15+
using namespace utest::v1;
16+
1317

1418
#ifndef MBED_CFG_UDP_DTLS_HANDSHAKE_BUFFER_SIZE
1519
#define MBED_CFG_UDP_DTLS_HANDSHAKE_BUFFER_SIZE 512
@@ -31,9 +35,7 @@ uint8_t buffer[MBED_CFG_UDP_DTLS_HANDSHAKE_BUFFER_SIZE] = {0};
3135
int udp_dtls_handshake_pattern[] = {MBED_CFG_UDP_DTLS_HANDSHAKE_PATTERN};
3236
const int udp_dtls_handshake_count = sizeof(udp_dtls_handshake_pattern) / sizeof(int);
3337

34-
int main() {
35-
GREENTEA_SETUP(120, "udp_shotgun");
36-
38+
void test_udp_dtls_handshake() {
3739
EthernetInterface eth;
3840
int err = eth.connect();
3941
TEST_ASSERT_EQUAL(0, err);
@@ -127,5 +129,22 @@ int main() {
127129
}
128130

129131
eth.disconnect();
130-
GREENTEA_TESTSUITE_RESULT(result);
132+
TEST_ASSERT_EQUAL(true, result);
133+
}
134+
135+
136+
// Test setup
137+
utest::v1::status_t test_setup(const size_t number_of_cases) {
138+
GREENTEA_SETUP(120, "udp_shotgun");
139+
return verbose_test_setup_handler(number_of_cases);
140+
}
141+
142+
Case cases[] = {
143+
Case("UDP DTLS handshake", test_udp_dtls_handshake),
144+
};
145+
146+
Specification specification(test_setup, cases);
147+
148+
int main() {
149+
return !Harness::run(specification);
131150
}

0 commit comments

Comments
 (0)