0
0
mirror of https://github.com/zeromq/libzmq.git synced 2024-12-27 15:41:05 +08:00

Merge pull request #760 from shancat/move_linger_test

Move linger test to issue repo.
This commit is contained in:
Pieter Hintjens 2013-11-24 13:02:47 -08:00
commit b91ef997ce
3 changed files with 4 additions and 101 deletions

View File

@ -581,7 +581,7 @@ if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug") # Why?
endif()
enable_testing()
set(tests
set(tests
test_system
test_pair_inproc
test_pair_tcp
@ -596,7 +596,6 @@ set(tests
test_immediate
test_last_endpoint
test_term_endpoint
test_linger
test_router_mandatory
test_probe_router
test_stream
@ -631,7 +630,7 @@ list(APPEND tests
test_fork
test_proxy
)
endif()
endif()
foreach(test ${tests})
add_executable(${test} tests/${test}.cpp)
@ -644,7 +643,7 @@ foreach(test ${tests})
add_test(NAME ${test} WORKING_DIRECTORY ${LIBRARY_OUTPUT_PATH} COMMAND ${test})
else()
add_test(NAME ${test} COMMAND ${test})
endif()
endif()
endforeach()
#-----------------------------------------------------------------------------

View File

@ -17,7 +17,6 @@ noinst_PROGRAMS = test_system \
test_immediate \
test_last_endpoint \
test_term_endpoint \
test_linger \
test_monitor \
test_router_mandatory \
test_router_handover \
@ -73,7 +72,6 @@ test_hwm_SOURCES = test_hwm.cpp
test_reqrep_device_SOURCES = test_reqrep_device.cpp
test_sub_forward_SOURCES = test_sub_forward.cpp
test_invalid_rep_SOURCES = test_invalid_rep.cpp
test_linger_SOURCES = test_linger.cpp
test_msg_flags_SOURCES = test_msg_flags.cpp
test_connect_resolve_SOURCES = test_connect_resolve.cpp
test_immediate_SOURCES = test_immediate.cpp
@ -125,8 +123,7 @@ endif
# Run the test cases
TESTS = $(noinst_PROGRAMS)
XFAIL_TESTS = test_linger
if !ON_LINUX
XFAIL_TESTS += test_abstract_ipc
XFAIL_TESTS = test_abstract_ipc
endif

View File

@ -1,93 +0,0 @@
/*
Copyright (c) 2007-2013 Contributors as noted in the AUTHORS file
This file is part of 0MQ.
0MQ is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
0MQ is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// This test case should be moved or added to issues repository, perhaps,
// or alternatively we can change policy that issue test cases should be
// added to the main build when they're useful. -- PH 2013/09/02
#include "testutil.hpp"
#define URL "tcp://127.0.0.1:5560"
// Sender connects a PUSH socket and sends a message of a given size,
// closing the socket and terminating the context immediately.
// LINGER should prevent this from dropping messages.
static void sender (void *vsize)
{
void *context = zmq_ctx_new ();
void *push = zmq_socket (context, ZMQ_PUSH);
size_t size = ((size_t *) vsize) [0];
int rc = zmq_connect (push, URL);
assert (rc == 0);
zmq_msg_t msg;
rc = zmq_msg_init_size (&msg, size);
assert (rc == 0);
char *buf = (char *) zmq_msg_data (&msg);
assert (buf != NULL);
memset (buf, 'x', size);
rc = zmq_msg_send (&msg, push, 0);
assert ((size_t) rc == size);
rc = zmq_msg_close (&msg);
assert (rc == 0);
rc = zmq_close (push);
assert (rc == 0);
rc = zmq_ctx_term (context);
assert (rc == 0);
}
int main (void)
{
void *context = zmq_ctx_new ();
void *pull = zmq_socket (context, ZMQ_PULL);
zmq_msg_t msg;
int rc = zmq_bind (pull, URL);
assert (rc == 0);
// Symptom of test failure is message never received
int rcvtimeo = 100;
rc = zmq_setsockopt (pull, ZMQ_RCVTIMEO, &rcvtimeo, sizeof (int));
assert (rc == 0);
// Single test case that currently provokes failure in libzmq
// Note that socket will wait as long as receive timeout, before
// returning a "resource unavailable" or an assertion failure in
// poller_base.cpp:31.
size_t size = 4000000;
// Start the sender thread and get message
void *send_thread = zmq_threadstart (&sender, (void *) &size);
zmq_msg_init (&msg);
rc = zmq_msg_recv (&msg, pull, 0);
assert ((size_t) rc == size);
zmq_msg_close (&msg);
zmq_threadclose (send_thread);
zmq_close (pull);
zmq_ctx_term (context);
return 0;
}