Skip to content

Commit 6d89635

Browse files
committed
Problem: test_udp not using unity
Solution: migrate to unity, merge into test_radio_dish, and split up test cases
1 parent dc2764f commit 6d89635

4 files changed

Lines changed: 48 additions & 141 deletions

File tree

Makefile.am

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -855,7 +855,6 @@ test_apps += tests/test_poller \
855855
tests/test_thread_safe \
856856
tests/test_timers \
857857
tests/test_radio_dish \
858-
tests/test_udp \
859858
tests/test_scatter_gather \
860859
tests/test_dgram \
861860
tests/test_app_meta
@@ -879,9 +878,6 @@ tests_test_radio_dish_SOURCES = tests/test_radio_dish.cpp
879878
tests_test_radio_dish_LDADD = src/libzmq.la ${UNITY_LIBS}
880879
tests_test_radio_dish_CPPFLAGS = ${UNITY_CPPFLAGS}
881880

882-
tests_test_udp_SOURCES = tests/test_udp.cpp
883-
tests_test_udp_LDADD = src/libzmq.la
884-
885881
tests_test_scatter_gather_SOURCES = tests/test_scatter_gather.cpp
886882
tests_test_scatter_gather_LDADD = src/libzmq.la
887883

tests/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,6 @@ IF (ENABLE_DRAFTS)
132132
test_client_server
133133
test_timers
134134
test_radio_dish
135-
test_udp
136135
test_scatter_gather
137136
test_dgram
138137
test_app_meta

tests/test_radio_dish.cpp

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ void test_join_twice_fails ()
111111
test_context_socket_close (dish);
112112
}
113113

114-
void test_radio_dish ()
114+
void test_radio_dish_tcp_poll ()
115115
{
116116
size_t len = MAX_SOCKET_STRING;
117117
char my_endpoint[MAX_SOCKET_STRING];
@@ -176,6 +176,48 @@ void test_radio_dish ()
176176
test_context_socket_close (radio);
177177
}
178178

179+
void test_dish_connect_fails ()
180+
{
181+
void *dish = test_context_socket (ZMQ_DISH);
182+
183+
// Connecting dish should fail
184+
TEST_ASSERT_FAILURE_ERRNO (ENOCOMPATPROTO,
185+
zmq_connect (dish, "udp://127.0.0.1:5556"));
186+
187+
test_context_socket_close (dish);
188+
}
189+
190+
void test_radio_bind_fails ()
191+
{
192+
void *radio = test_context_socket (ZMQ_RADIO);
193+
194+
// Connecting dish should fail
195+
// Bind radio should fail
196+
TEST_ASSERT_FAILURE_ERRNO (ENOCOMPATPROTO,
197+
zmq_bind (radio, "udp://*:5556"));
198+
199+
test_context_socket_close (radio);
200+
}
201+
202+
void test_radio_dish_udp ()
203+
{
204+
void *radio = test_context_socket (ZMQ_RADIO);
205+
void *dish = test_context_socket (ZMQ_DISH);
206+
207+
TEST_ASSERT_SUCCESS_ERRNO (zmq_bind (dish, "udp://*:5556"));
208+
TEST_ASSERT_SUCCESS_ERRNO (zmq_connect (radio, "udp://127.0.0.1:5556"));
209+
210+
msleep (SETTLE_TIME);
211+
212+
TEST_ASSERT_SUCCESS_ERRNO (zmq_join (dish, "TV"));
213+
214+
msg_send_expect_success (radio, "TV", "Friends");
215+
msg_recv_cmp (dish, "TV", "Friends");
216+
217+
test_context_socket_close (dish);
218+
test_context_socket_close (radio);
219+
}
220+
179221
int main (void)
180222
{
181223
setup_test_environment ();
@@ -184,6 +226,10 @@ int main (void)
184226
RUN_TEST (test_leave_unjoined_fails);
185227
RUN_TEST (test_join_too_long_fails);
186228
RUN_TEST (test_join_twice_fails);
187-
RUN_TEST (test_radio_dish);
229+
RUN_TEST (test_radio_bind_fails);
230+
RUN_TEST (test_dish_connect_fails);
231+
RUN_TEST (test_radio_dish_tcp_poll);
232+
RUN_TEST (test_radio_dish_udp);
233+
188234
return UNITY_END ();
189235
}

tests/test_udp.cpp

Lines changed: 0 additions & 134 deletions
This file was deleted.

0 commit comments

Comments
 (0)