mirror of
https://github.com/zeromq/libzmq.git
synced 2025-03-10 16:06:09 +00:00
Problem: test_heartbeats use no test framework
Solution: migrate to unity
This commit is contained in:
parent
df2fe88b92
commit
f218478237
@ -651,7 +651,8 @@ tests_test_setsockopt_SOURCES = tests/test_setsockopt.cpp
|
|||||||
tests_test_setsockopt_LDADD = src/libzmq.la
|
tests_test_setsockopt_LDADD = src/libzmq.la
|
||||||
|
|
||||||
tests_test_heartbeats_SOURCES = tests/test_heartbeats.cpp
|
tests_test_heartbeats_SOURCES = tests/test_heartbeats.cpp
|
||||||
tests_test_heartbeats_LDADD = src/libzmq.la
|
tests_test_heartbeats_LDADD = src/libzmq.la ${UNITY_LIBS}
|
||||||
|
tests_test_heartbeats_CPPFLAGS = ${UNITY_CPPFLAGS}
|
||||||
|
|
||||||
tests_test_stream_exceeds_buffer_SOURCES = tests/test_stream_exceeds_buffer.cpp
|
tests_test_stream_exceeds_buffer_SOURCES = tests/test_stream_exceeds_buffer.cpp
|
||||||
tests_test_stream_exceeds_buffer_LDADD = src/libzmq.la
|
tests_test_stream_exceeds_buffer_LDADD = src/libzmq.la
|
||||||
|
@ -29,6 +29,19 @@ typedef SOCKET raw_socket;
|
|||||||
typedef int raw_socket;
|
typedef int raw_socket;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <unity.h>
|
||||||
|
|
||||||
|
void setUp ()
|
||||||
|
{
|
||||||
|
// setup_test_context ();
|
||||||
|
}
|
||||||
|
|
||||||
|
void tearDown ()
|
||||||
|
{
|
||||||
|
// teardown_test_context ();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Read one event off the monitor socket; return value and address
|
// Read one event off the monitor socket; return value and address
|
||||||
// by reference, if not null, and event number by value. Returns -1
|
// by reference, if not null, and event number by value. Returns -1
|
||||||
// in case of error.
|
// in case of error.
|
||||||
@ -340,29 +353,62 @@ test_heartbeat_notimeout (int is_curve, int client_type, int server_type)
|
|||||||
assert (rc == 0);
|
assert (rc == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void test_heartbeat_timeout_router ()
|
||||||
|
{
|
||||||
|
test_heartbeat_timeout (ZMQ_ROUTER);
|
||||||
|
}
|
||||||
|
|
||||||
|
void test_heartbeat_timeout_rep ()
|
||||||
|
{
|
||||||
|
test_heartbeat_timeout (ZMQ_REP);
|
||||||
|
}
|
||||||
|
|
||||||
|
#define DEFINE_TESTS(first, second, first_define, second_define) \
|
||||||
|
void test_heartbeat_ttl_##first##_##second () \
|
||||||
|
{ \
|
||||||
|
test_heartbeat_ttl (first_define, second_define); \
|
||||||
|
} \
|
||||||
|
void test_heartbeat_notimeout_##first##_##second () \
|
||||||
|
{ \
|
||||||
|
test_heartbeat_notimeout (0, first_define, second_define); \
|
||||||
|
} \
|
||||||
|
void test_heartbeat_notimeout_##first##_##second##_with_curve () \
|
||||||
|
{ \
|
||||||
|
test_heartbeat_notimeout (1, first_define, second_define); \
|
||||||
|
}
|
||||||
|
|
||||||
|
DEFINE_TESTS (dealer, router, ZMQ_DEALER, ZMQ_ROUTER)
|
||||||
|
DEFINE_TESTS (req, rep, ZMQ_REQ, ZMQ_REP)
|
||||||
|
DEFINE_TESTS (pull, push, ZMQ_PULL, ZMQ_PUSH)
|
||||||
|
DEFINE_TESTS (sub, pub, ZMQ_SUB, ZMQ_PUB)
|
||||||
|
DEFINE_TESTS (pair, pair, ZMQ_PAIR, ZMQ_PAIR)
|
||||||
|
|
||||||
int main (void)
|
int main (void)
|
||||||
{
|
{
|
||||||
setup_test_environment ();
|
setup_test_environment ();
|
||||||
|
|
||||||
test_heartbeat_timeout (ZMQ_ROUTER);
|
UNITY_BEGIN ();
|
||||||
test_heartbeat_timeout (ZMQ_REP);
|
|
||||||
|
|
||||||
test_heartbeat_ttl (ZMQ_DEALER, ZMQ_ROUTER);
|
RUN_TEST (test_heartbeat_timeout_router);
|
||||||
test_heartbeat_ttl (ZMQ_REQ, ZMQ_REP);
|
RUN_TEST (test_heartbeat_timeout_rep);
|
||||||
test_heartbeat_ttl (ZMQ_PULL, ZMQ_PUSH);
|
|
||||||
test_heartbeat_ttl (ZMQ_SUB, ZMQ_PUB);
|
|
||||||
test_heartbeat_ttl (ZMQ_PAIR, ZMQ_PAIR);
|
|
||||||
|
|
||||||
// Run this test without curve
|
RUN_TEST (test_heartbeat_ttl_dealer_router);
|
||||||
test_heartbeat_notimeout (0, ZMQ_DEALER, ZMQ_ROUTER);
|
RUN_TEST (test_heartbeat_ttl_req_rep);
|
||||||
test_heartbeat_notimeout (0, ZMQ_REQ, ZMQ_REP);
|
RUN_TEST (test_heartbeat_ttl_pull_push);
|
||||||
test_heartbeat_notimeout (0, ZMQ_PULL, ZMQ_PUSH);
|
RUN_TEST (test_heartbeat_ttl_sub_pub);
|
||||||
test_heartbeat_notimeout (0, ZMQ_SUB, ZMQ_PUB);
|
RUN_TEST (test_heartbeat_ttl_pair_pair);
|
||||||
test_heartbeat_notimeout (0, ZMQ_PAIR, ZMQ_PAIR);
|
|
||||||
// Then rerun it with curve
|
RUN_TEST (test_heartbeat_notimeout_dealer_router);
|
||||||
test_heartbeat_notimeout (1, ZMQ_DEALER, ZMQ_ROUTER);
|
RUN_TEST (test_heartbeat_notimeout_req_rep);
|
||||||
test_heartbeat_notimeout (1, ZMQ_REQ, ZMQ_REP);
|
RUN_TEST (test_heartbeat_notimeout_pull_push);
|
||||||
test_heartbeat_notimeout (1, ZMQ_PULL, ZMQ_PUSH);
|
RUN_TEST (test_heartbeat_notimeout_sub_pub);
|
||||||
test_heartbeat_notimeout (1, ZMQ_SUB, ZMQ_PUB);
|
RUN_TEST (test_heartbeat_notimeout_pair_pair);
|
||||||
test_heartbeat_notimeout (1, ZMQ_PAIR, ZMQ_PAIR);
|
|
||||||
|
RUN_TEST (test_heartbeat_notimeout_dealer_router_with_curve);
|
||||||
|
RUN_TEST (test_heartbeat_notimeout_req_rep_with_curve);
|
||||||
|
RUN_TEST (test_heartbeat_notimeout_pull_push_with_curve);
|
||||||
|
RUN_TEST (test_heartbeat_notimeout_sub_pub_with_curve);
|
||||||
|
RUN_TEST (test_heartbeat_notimeout_pair_pair_with_curve);
|
||||||
|
|
||||||
|
return UNITY_END ();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user