mirror of
https://github.com/zeromq/libzmq.git
synced 2024-12-13 02:42:58 +01:00
Merge pull request #743 from ricnewton/master
Add test case for many sockets
This commit is contained in:
commit
1596a5e871
@ -620,6 +620,7 @@ set(tests
|
||||
test_issue_566
|
||||
test_shutdown_stress
|
||||
test_timeo
|
||||
test_many_sockets
|
||||
)
|
||||
if(NOT WIN32)
|
||||
list(APPEND tests
|
||||
|
@ -42,7 +42,8 @@ noinst_PROGRAMS = test_system \
|
||||
test_inproc_connect \
|
||||
test_issue_566 \
|
||||
test_proxy \
|
||||
test_abstract_ipc
|
||||
test_abstract_ipc \
|
||||
test_many_sockets
|
||||
|
||||
if !ON_MINGW
|
||||
noinst_PROGRAMS += test_shutdown_stress \
|
||||
@ -103,6 +104,7 @@ test_inproc_connect_SOURCES = test_inproc_connect.cpp
|
||||
test_issue_566_SOURCES = test_issue_566.cpp
|
||||
test_proxy_SOURCES = test_proxy.cpp
|
||||
test_abstract_ipc_SOURCES = test_abstract_ipc.cpp
|
||||
test_many_sockets_SOURCES = test_many_sockets.cpp
|
||||
if !ON_MINGW
|
||||
test_shutdown_stress_SOURCES = test_shutdown_stress.cpp
|
||||
test_pair_ipc_SOURCES = test_pair_ipc.cpp testutil.hpp
|
||||
|
51
tests/test_many_sockets.cpp
Normal file
51
tests/test_many_sockets.cpp
Normal file
@ -0,0 +1,51 @@
|
||||
/*
|
||||
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/>.
|
||||
*/
|
||||
|
||||
#include "testutil.hpp"
|
||||
#include <zmq.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
const int no_of_sockets = 5000;
|
||||
|
||||
int main(void)
|
||||
{
|
||||
setup_test_environment();
|
||||
|
||||
void *ctx = zmq_ctx_new();
|
||||
void *sockets[no_of_sockets];
|
||||
|
||||
int sockets_created = 0;
|
||||
|
||||
for ( int i = 0; i < no_of_sockets; ++i )
|
||||
{
|
||||
sockets[i] = zmq_socket(ctx, ZMQ_PAIR);
|
||||
if (sockets[i])
|
||||
++sockets_created;
|
||||
}
|
||||
|
||||
assert(sockets_created < no_of_sockets);
|
||||
|
||||
for ( int i = 0; i < no_of_sockets; ++i )
|
||||
if (sockets[i])
|
||||
zmq_close (sockets[i]);
|
||||
|
||||
zmq_ctx_destroy (ctx);
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user