Fixes to test cases

- renamed test_stream_disconnect_notifications (too long!)
- removed print statements in that test case
- fixed Makefile.am for test_zap_ipc_creds (was not building)
This commit is contained in:
Pieter Hintjens 2014-01-23 09:23:46 -06:00
parent 8fea78b130
commit 9c228e9374
3 changed files with 8 additions and 25 deletions

2
.gitignore vendored
View File

@ -86,6 +86,8 @@ tests/test_sub_forward_tipc
tests/test_term_endpoint_tipc
tests/test_many_sockets
tests/test_diffserv
tests/test_srcfd
tests/test_stream_disconnect
tests/test*.log
tests/test*.trs
src/platform.hpp*

View File

@ -25,7 +25,7 @@ noinst_PROGRAMS = test_system \
test_probe_router \
test_stream \
test_stream_empty \
test_stream_disconnect_notifications \
test_stream_disconnect \
test_disconnect_inproc \
test_ctx_options \
test_ctx_destroy \
@ -91,7 +91,7 @@ test_router_handover_SOURCES = test_router_handover.cpp
test_probe_router_SOURCES = test_probe_router.cpp
test_stream_SOURCES = test_stream.cpp
test_stream_empty_SOURCES = test_stream_empty.cpp
test_stream_disconnect_notifications_SOURCES = test_stream_disconnect_notifications.cpp
test_stream_disconnect_SOURCES = test_stream_disconnect.cpp
test_disconnect_inproc_SOURCES = test_disconnect_inproc.cpp
test_ctx_options_SOURCES = test_ctx_options.cpp
test_iov_SOURCES = test_iov.cpp
@ -121,7 +121,6 @@ test_reqrep_ipc_SOURCES = test_reqrep_ipc.cpp testutil.hpp
test_timeo_SOURCES = test_timeo.cpp
test_fork_SOURCES = test_fork.cpp
test_filter_ipc_SOURCES = test_filter_ipc.cpp
test_zap_ipc_creds_SOURCES = test_zap_ipc_creds.cpp
endif
if BUILD_TIPC
test_connect_delay_tipc_SOURCES = test_connect_delay_tipc.cpp
@ -141,7 +140,3 @@ XFAIL_TESTS = test_resource
if !ON_LINUX
XFAIL_TESTS += test_abstract_ipc
endif
if !HAVE_IPC_PEERCRED
XFAIL_TESTS += test_zap_ipc_creds
endif

View File

@ -40,9 +40,8 @@ bool has_more (void* socket)
int more = 0;
size_t more_size = sizeof(more);
int rc = zmq_getsockopt (socket, ZMQ_RCVMORE, &more, &more_size);
if (rc != 0) {
if (rc != 0)
return false;
}
return more != 0;
}
@ -136,8 +135,6 @@ int main(int, char**)
int rc = zmq_poll (items, 2, 100);
assert (rc >= 0);
printf ("Event received for step %d.\n", step);
// Check for data received by the server.
if (items [SERVER].revents & ZMQ_POLLIN) {
assert (dialog [step].turn == CLIENT);
@ -164,15 +161,12 @@ int main(int, char**)
// 0-length frame is a disconnection notification. The server
// should receive it as the last step in the dialogue.
if (size == 0) {
printf ("server received disconnection notification!\n");
++step;
assert (step == steps);
}
else {
printf ("server received %d bytes.\n", size);
fprintf(stderr, "size = %d, len = %ld\n", size, strlen(dialog [step].text));
assert((size_t)size == strlen(dialog [step].text));
int cmp = memcmp(dialog [step].text, data, size);
assert ((size_t) size == strlen (dialog [step].text));
int cmp = memcmp (dialog [step].text, data, size);
assert (cmp == 0);
++step;
@ -189,8 +183,6 @@ int main(int, char**)
zmq_msg_size (&data_frame));
// Send the response.
printf ("server sending %d bytes.\n",
(int)zmq_msg_size (&data_frame));
rc = zmq_msg_send (&peer_frame, sockets [SERVER], ZMQ_SNDMORE);
assert (rc != -1);
rc = zmq_msg_send (&data_frame, sockets [SERVER], ZMQ_SNDMORE);
@ -228,13 +220,10 @@ int main(int, char**)
// Make sure payload matches what we expect.
const char * const data = (const char*)zmq_msg_data (&data_frame);
const int size = zmq_msg_size (&data_frame);
fprintf(stderr, "size = %d, len = %ld\n", size, strlen(dialog [step].text));
assert((size_t)size == strlen(dialog [step].text));
assert ((size_t)size == strlen(dialog [step].text));
int cmp = memcmp(dialog [step].text, data, size);
assert (cmp == 0);
printf ("client received %d bytes.\n", size);
++step;
// Prepare the response (next line in the dialog).
@ -246,7 +235,6 @@ int main(int, char**)
memcpy (zmq_msg_data (&data_frame), dialog [step].text, zmq_msg_size (&data_frame));
// Send the response.
printf ("client sending %d bytes.\n", (int)zmq_msg_size (&data_frame));
rc = zmq_msg_send (&peer_frame, sockets [CLIENT], ZMQ_SNDMORE);
assert (rc != -1);
rc = zmq_msg_send (&data_frame, sockets [CLIENT], ZMQ_SNDMORE);
@ -260,8 +248,6 @@ int main(int, char**)
}
}
assert (step == steps);
printf ("Done, exiting now.\n");
rc = zmq_close (sockets [CLIENT]);
assert (rc == 0);
rc = zmq_close (sockets [SERVER]);