summaryrefslogtreecommitdiff
path: root/third_party/lwip-1.4.1/test/unit/udp
diff options
context:
space:
mode:
authorYuval Adam <yuv.adm@gmail.com>2014-08-08 14:42:07 +0300
committerYuval Adam <yuv.adm@gmail.com>2014-08-08 14:42:07 +0300
commita6163888f3c56123b1db313743c6147ba498732c (patch)
treeff7d15d991d1d09ba6cbc0cec80924f57445bfdd /third_party/lwip-1.4.1/test/unit/udp
parentc3e4c9a25c2910d2d66d52215b3406b13d5b23d5 (diff)
Add third_party libs
Diffstat (limited to 'third_party/lwip-1.4.1/test/unit/udp')
-rw-r--r--third_party/lwip-1.4.1/test/unit/udp/test_udp.c68
-rw-r--r--third_party/lwip-1.4.1/test/unit/udp/test_udp.h8
2 files changed, 76 insertions, 0 deletions
diff --git a/third_party/lwip-1.4.1/test/unit/udp/test_udp.c b/third_party/lwip-1.4.1/test/unit/udp/test_udp.c
new file mode 100644
index 0000000..3157db8
--- /dev/null
+++ b/third_party/lwip-1.4.1/test/unit/udp/test_udp.c
@@ -0,0 +1,68 @@
+#include "test_udp.h"
+
+#include "lwip/udp.h"
+#include "lwip/stats.h"
+
+#if !LWIP_STATS || !UDP_STATS || !MEMP_STATS
+#error "This tests needs UDP- and MEMP-statistics enabled"
+#endif
+
+/* Helper functions */
+static void
+udp_remove_all(void)
+{
+ struct udp_pcb *pcb = udp_pcbs;
+ struct udp_pcb *pcb2;
+
+ while(pcb != NULL) {
+ pcb2 = pcb;
+ pcb = pcb->next;
+ udp_remove(pcb2);
+ }
+ fail_unless(lwip_stats.memp[MEMP_UDP_PCB].used == 0);
+}
+
+/* Setups/teardown functions */
+
+static void
+udp_setup(void)
+{
+ udp_remove_all();
+}
+
+static void
+udp_teardown(void)
+{
+ udp_remove_all();
+}
+
+
+/* Test functions */
+
+START_TEST(test_udp_new_remove)
+{
+ struct udp_pcb* pcb;
+ LWIP_UNUSED_ARG(_i);
+
+ fail_unless(lwip_stats.memp[MEMP_UDP_PCB].used == 0);
+
+ pcb = udp_new();
+ fail_unless(pcb != NULL);
+ if (pcb != NULL) {
+ fail_unless(lwip_stats.memp[MEMP_UDP_PCB].used == 1);
+ udp_remove(pcb);
+ fail_unless(lwip_stats.memp[MEMP_UDP_PCB].used == 0);
+ }
+}
+END_TEST
+
+
+/** Create the suite including all tests for this module */
+Suite *
+udp_suite(void)
+{
+ TFun tests[] = {
+ test_udp_new_remove,
+ };
+ return create_suite("UDP", tests, sizeof(tests)/sizeof(TFun), udp_setup, udp_teardown);
+}
diff --git a/third_party/lwip-1.4.1/test/unit/udp/test_udp.h b/third_party/lwip-1.4.1/test/unit/udp/test_udp.h
new file mode 100644
index 0000000..af790d1
--- /dev/null
+++ b/third_party/lwip-1.4.1/test/unit/udp/test_udp.h
@@ -0,0 +1,8 @@
+#ifndef __TEST_UDP_H__
+#define __TEST_UDP_H__
+
+#include "../lwip_check.h"
+
+Suite* udp_suite(void);
+
+#endif