Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: TYBLE16_simple_data_logger TYBLE16_MP3_Air
lwip_unittests.c
00001 #include "lwip_check.h" 00002 00003 #include "ip4/test_ip4.h" 00004 #include "ip6/test_ip6.h" 00005 #include "udp/test_udp.h" 00006 #include "tcp/test_tcp.h" 00007 #include "tcp/test_tcp_oos.h" 00008 #include "core/test_def.h" 00009 #include "core/test_mem.h" 00010 #include "core/test_netif.h" 00011 #include "core/test_pbuf.h" 00012 #include "core/test_timers.h" 00013 #include "etharp/test_etharp.h" 00014 #include "dhcp/test_dhcp.h" 00015 #include "mdns/test_mdns.h" 00016 #include "mqtt/test_mqtt.h" 00017 #include "api/test_sockets.h" 00018 00019 #include "lwip/init.h" 00020 #if !NO_SYS 00021 #include "lwip/tcpip.h" 00022 #endif 00023 00024 Suite* create_suite(const char* name, testfunc *tests, size_t num_tests, SFun setup, SFun teardown) 00025 { 00026 size_t i; 00027 Suite *s = suite_create(name); 00028 00029 for(i = 0; i < num_tests; i++) { 00030 TCase *tc_core = tcase_create(name); 00031 if ((setup != NULL) || (teardown != NULL)) { 00032 tcase_add_checked_fixture(tc_core, setup, teardown); 00033 } 00034 tcase_add_named_test(tc_core, tests[i]); 00035 suite_add_tcase(s, tc_core); 00036 } 00037 return s; 00038 } 00039 00040 void lwip_check_ensure_no_alloc(unsigned int skip) 00041 { 00042 int i; 00043 unsigned int mask; 00044 00045 if (!(skip & SKIP_HEAP)) { 00046 fail_unless(lwip_stats.mem.used == 0); 00047 } 00048 for (i = 0, mask = 1; i < MEMP_MAX; i++, mask <<= 1) { 00049 if (!(skip & mask)) { 00050 fail_unless(lwip_stats.memp[i]->used == 0); 00051 } 00052 } 00053 } 00054 00055 #ifdef LWIP_UNITTESTS_LIB 00056 int lwip_unittests_run(void) 00057 #else 00058 int main(void) 00059 #endif 00060 { 00061 int number_failed; 00062 SRunner *sr; 00063 size_t i; 00064 suite_getter_fn* suites[] = { 00065 ip4_suite, 00066 ip6_suite, 00067 udp_suite, 00068 tcp_suite, 00069 tcp_oos_suite, 00070 def_suite, 00071 mem_suite, 00072 netif_suite, 00073 pbuf_suite, 00074 timers_suite, 00075 etharp_suite, 00076 dhcp_suite, 00077 mdns_suite, 00078 mqtt_suite, 00079 sockets_suite 00080 }; 00081 size_t num = sizeof(suites)/sizeof(void*); 00082 LWIP_ASSERT("No suites defined", num > 0); 00083 00084 #if NO_SYS 00085 lwip_init(); 00086 #else 00087 tcpip_init(NULL, NULL); 00088 #endif 00089 00090 sr = srunner_create((suites[0])()); 00091 srunner_set_xml(sr, "lwip_unittests.xml"); 00092 for(i = 1; i < num; i++) { 00093 srunner_add_suite(sr, ((suite_getter_fn*)suites[i])()); 00094 } 00095 00096 #ifdef LWIP_UNITTESTS_NOFORK 00097 srunner_set_fork_status(sr, CK_NOFORK); 00098 #endif 00099 #ifdef LWIP_UNITTESTS_FORK 00100 srunner_set_fork_status(sr, CK_FORK); 00101 #endif 00102 00103 srunner_run_all(sr, CK_NORMAL); 00104 number_failed = srunner_ntests_failed(sr); 00105 srunner_free(sr); 00106 return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE; 00107 }
Generated on Tue Jul 12 2022 13:54:30 by
