mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2025-04-16 08:43:17 +00:00
Unit test patch by Erik Ekman: use macro to store correct testcase name
This commit is contained in:
parent
ad66b2bf13
commit
a80c4d147c
@ -66,8 +66,8 @@ END_TEST
|
|||||||
Suite *
|
Suite *
|
||||||
mem_suite(void)
|
mem_suite(void)
|
||||||
{
|
{
|
||||||
TFun tests[] = {
|
testfunc tests[] = {
|
||||||
test_mem_one
|
TESTFUNC(test_mem_one)
|
||||||
};
|
};
|
||||||
return create_suite("MEM", tests, sizeof(tests)/sizeof(TFun), mem_setup, mem_teardown);
|
return create_suite("MEM", tests, sizeof(tests)/sizeof(testfunc), mem_setup, mem_teardown);
|
||||||
}
|
}
|
||||||
|
@ -143,10 +143,10 @@ END_TEST
|
|||||||
Suite *
|
Suite *
|
||||||
pbuf_suite(void)
|
pbuf_suite(void)
|
||||||
{
|
{
|
||||||
TFun tests[] = {
|
testfunc tests[] = {
|
||||||
test_pbuf_copy_zero_pbuf,
|
TESTFUNC(test_pbuf_copy_zero_pbuf),
|
||||||
test_pbuf_split_64k_on_small_pbufs,
|
TESTFUNC(test_pbuf_split_64k_on_small_pbufs),
|
||||||
test_pbuf_queueing_bigger_than_64k
|
TESTFUNC(test_pbuf_queueing_bigger_than_64k)
|
||||||
};
|
};
|
||||||
return create_suite("PBUF", tests, sizeof(tests)/sizeof(TFun), pbuf_setup, pbuf_teardown);
|
return create_suite("PBUF", tests, sizeof(tests)/sizeof(testfunc), pbuf_setup, pbuf_teardown);
|
||||||
}
|
}
|
||||||
|
@ -906,11 +906,11 @@ END_TEST
|
|||||||
Suite *
|
Suite *
|
||||||
dhcp_suite(void)
|
dhcp_suite(void)
|
||||||
{
|
{
|
||||||
TFun tests[] = {
|
testfunc tests[] = {
|
||||||
test_dhcp,
|
TESTFUNC(test_dhcp),
|
||||||
test_dhcp_nak,
|
TESTFUNC(test_dhcp_nak),
|
||||||
test_dhcp_relayed,
|
TESTFUNC(test_dhcp_relayed),
|
||||||
test_dhcp_nak_no_endmarker
|
TESTFUNC(test_dhcp_nak_no_endmarker)
|
||||||
};
|
};
|
||||||
return create_suite("DHCP", tests, sizeof(tests)/sizeof(TFun), dhcp_setup, dhcp_teardown);
|
return create_suite("DHCP", tests, sizeof(tests)/sizeof(testfunc), dhcp_setup, dhcp_teardown);
|
||||||
}
|
}
|
||||||
|
@ -255,8 +255,8 @@ END_TEST
|
|||||||
Suite *
|
Suite *
|
||||||
etharp_suite(void)
|
etharp_suite(void)
|
||||||
{
|
{
|
||||||
TFun tests[] = {
|
testfunc tests[] = {
|
||||||
test_etharp_table
|
TESTFUNC(test_etharp_table)
|
||||||
};
|
};
|
||||||
return create_suite("ETHARP", tests, sizeof(tests)/sizeof(TFun), etharp_setup, etharp_teardown);
|
return create_suite("ETHARP", tests, sizeof(tests)/sizeof(testfunc), etharp_setup, etharp_teardown);
|
||||||
}
|
}
|
||||||
|
@ -13,22 +13,32 @@
|
|||||||
#define EXPECT_RETX(x, y) do { fail_unless(x); if(!(x)) { return y; }} while(0)
|
#define EXPECT_RETX(x, y) do { fail_unless(x); if(!(x)) { return y; }} while(0)
|
||||||
#define EXPECT_RETNULL(x) EXPECT_RETX(x, NULL)
|
#define EXPECT_RETNULL(x) EXPECT_RETX(x, NULL)
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
TFun func;
|
||||||
|
const char *name;
|
||||||
|
} testfunc;
|
||||||
|
|
||||||
|
#define TESTFUNC(x) {(x), "" # x "" }
|
||||||
|
|
||||||
|
/* Modified function from check.h, supplying function name */
|
||||||
|
#define tcase_add_named_test(tc,tf) \
|
||||||
|
_tcase_add_test((tc),(tf).func,(tf).name,0, 0, 0, 1)
|
||||||
|
|
||||||
/** typedef for a function returning a test suite */
|
/** typedef for a function returning a test suite */
|
||||||
typedef Suite* (suite_getter_fn)(void);
|
typedef Suite* (suite_getter_fn)(void);
|
||||||
|
|
||||||
/** Create a test suite */
|
/** Create a test suite */
|
||||||
static Suite* create_suite(const char* name, TFun *tests, size_t num_tests, SFun setup, SFun teardown)
|
static Suite* create_suite(const char* name, testfunc *tests, size_t num_tests, SFun setup, SFun teardown)
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
Suite *s = suite_create(name);
|
Suite *s = suite_create(name);
|
||||||
|
|
||||||
for(i = 0; i < num_tests; i++) {
|
for(i = 0; i < num_tests; i++) {
|
||||||
/* Core test case */
|
TCase *tc_core = tcase_create(name);
|
||||||
TCase *tc_core = tcase_create("Core");
|
|
||||||
if ((setup != NULL) || (teardown != NULL)) {
|
if ((setup != NULL) || (teardown != NULL)) {
|
||||||
tcase_add_checked_fixture(tc_core, setup, teardown);
|
tcase_add_checked_fixture(tc_core, setup, teardown);
|
||||||
}
|
}
|
||||||
tcase_add_test(tc_core, tests[i]);
|
tcase_add_named_test(tc_core, tests[i]);
|
||||||
suite_add_tcase(s, tc_core);
|
suite_add_tcase(s, tc_core);
|
||||||
}
|
}
|
||||||
return s;
|
return s;
|
||||||
|
@ -658,14 +658,14 @@ END_TEST
|
|||||||
Suite *
|
Suite *
|
||||||
tcp_suite(void)
|
tcp_suite(void)
|
||||||
{
|
{
|
||||||
TFun tests[] = {
|
testfunc tests[] = {
|
||||||
test_tcp_new_abort,
|
TESTFUNC(test_tcp_new_abort),
|
||||||
test_tcp_recv_inseq,
|
TESTFUNC(test_tcp_recv_inseq),
|
||||||
test_tcp_fast_retx_recover,
|
TESTFUNC(test_tcp_fast_retx_recover),
|
||||||
test_tcp_fast_rexmit_wraparound,
|
TESTFUNC(test_tcp_fast_rexmit_wraparound),
|
||||||
test_tcp_rto_rexmit_wraparound,
|
TESTFUNC(test_tcp_rto_rexmit_wraparound),
|
||||||
test_tcp_tx_full_window_lost_from_unacked,
|
TESTFUNC(test_tcp_tx_full_window_lost_from_unacked),
|
||||||
test_tcp_tx_full_window_lost_from_unsent
|
TESTFUNC(test_tcp_tx_full_window_lost_from_unsent)
|
||||||
};
|
};
|
||||||
return create_suite("TCP", tests, sizeof(tests)/sizeof(TFun), tcp_setup, tcp_teardown);
|
return create_suite("TCP", tests, sizeof(tests)/sizeof(testfunc), tcp_setup, tcp_teardown);
|
||||||
}
|
}
|
||||||
|
@ -931,28 +931,28 @@ FIN_TEST(test_tcp_recv_ooseq_double_FIN_15, 15)
|
|||||||
Suite *
|
Suite *
|
||||||
tcp_oos_suite(void)
|
tcp_oos_suite(void)
|
||||||
{
|
{
|
||||||
TFun tests[] = {
|
testfunc tests[] = {
|
||||||
test_tcp_recv_ooseq_FIN_OOSEQ,
|
TESTFUNC(test_tcp_recv_ooseq_FIN_OOSEQ),
|
||||||
test_tcp_recv_ooseq_FIN_INSEQ,
|
TESTFUNC(test_tcp_recv_ooseq_FIN_INSEQ),
|
||||||
test_tcp_recv_ooseq_overrun_rxwin,
|
TESTFUNC(test_tcp_recv_ooseq_overrun_rxwin),
|
||||||
test_tcp_recv_ooseq_max_bytes,
|
TESTFUNC(test_tcp_recv_ooseq_max_bytes),
|
||||||
test_tcp_recv_ooseq_max_pbufs,
|
TESTFUNC(test_tcp_recv_ooseq_max_pbufs),
|
||||||
test_tcp_recv_ooseq_double_FIN_0,
|
TESTFUNC(test_tcp_recv_ooseq_double_FIN_0),
|
||||||
test_tcp_recv_ooseq_double_FIN_1,
|
TESTFUNC(test_tcp_recv_ooseq_double_FIN_1),
|
||||||
test_tcp_recv_ooseq_double_FIN_2,
|
TESTFUNC(test_tcp_recv_ooseq_double_FIN_2),
|
||||||
test_tcp_recv_ooseq_double_FIN_3,
|
TESTFUNC(test_tcp_recv_ooseq_double_FIN_3),
|
||||||
test_tcp_recv_ooseq_double_FIN_4,
|
TESTFUNC(test_tcp_recv_ooseq_double_FIN_4),
|
||||||
test_tcp_recv_ooseq_double_FIN_5,
|
TESTFUNC(test_tcp_recv_ooseq_double_FIN_5),
|
||||||
test_tcp_recv_ooseq_double_FIN_6,
|
TESTFUNC(test_tcp_recv_ooseq_double_FIN_6),
|
||||||
test_tcp_recv_ooseq_double_FIN_7,
|
TESTFUNC(test_tcp_recv_ooseq_double_FIN_7),
|
||||||
test_tcp_recv_ooseq_double_FIN_8,
|
TESTFUNC(test_tcp_recv_ooseq_double_FIN_8),
|
||||||
test_tcp_recv_ooseq_double_FIN_9,
|
TESTFUNC(test_tcp_recv_ooseq_double_FIN_9),
|
||||||
test_tcp_recv_ooseq_double_FIN_10,
|
TESTFUNC(test_tcp_recv_ooseq_double_FIN_10),
|
||||||
test_tcp_recv_ooseq_double_FIN_11,
|
TESTFUNC(test_tcp_recv_ooseq_double_FIN_11),
|
||||||
test_tcp_recv_ooseq_double_FIN_12,
|
TESTFUNC(test_tcp_recv_ooseq_double_FIN_12),
|
||||||
test_tcp_recv_ooseq_double_FIN_13,
|
TESTFUNC(test_tcp_recv_ooseq_double_FIN_13),
|
||||||
test_tcp_recv_ooseq_double_FIN_14,
|
TESTFUNC(test_tcp_recv_ooseq_double_FIN_14),
|
||||||
test_tcp_recv_ooseq_double_FIN_15
|
TESTFUNC(test_tcp_recv_ooseq_double_FIN_15)
|
||||||
};
|
};
|
||||||
return create_suite("TCP_OOS", tests, sizeof(tests)/sizeof(TFun), tcp_oos_setup, tcp_oos_teardown);
|
return create_suite("TCP_OOS", tests, sizeof(tests)/sizeof(testfunc), tcp_oos_setup, tcp_oos_teardown);
|
||||||
}
|
}
|
||||||
|
@ -61,8 +61,8 @@ END_TEST
|
|||||||
Suite *
|
Suite *
|
||||||
udp_suite(void)
|
udp_suite(void)
|
||||||
{
|
{
|
||||||
TFun tests[] = {
|
testfunc tests[] = {
|
||||||
test_udp_new_remove,
|
TESTFUNC(test_udp_new_remove),
|
||||||
};
|
};
|
||||||
return create_suite("UDP", tests, sizeof(tests)/sizeof(TFun), udp_setup, udp_teardown);
|
return create_suite("UDP", tests, sizeof(tests)/sizeof(testfunc), udp_setup, udp_teardown);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user