mirror of
https://github.com/zeromq/libzmq.git
synced 2024-12-27 15:41:05 +08:00
Problem: tests without test framework
Solution: migrate to Unity
This commit is contained in:
parent
e17232f725
commit
740780293a
@ -941,12 +941,14 @@ if HAVE_VMCI
|
||||
test_apps += test_pair_vmci test_reqrep_vmci
|
||||
|
||||
test_pair_vmci_SOURCES = tests/test_pair_vmci.cpp
|
||||
test_pair_vmci_LDADD = src/libzmq.la
|
||||
test_pair_vmci_LDADD = src/libzmq.la ${UNITY_LIBS}
|
||||
test_pair_vmci_CPPFLAGS = ${UNITY_CPPFLAGS}
|
||||
test_pair_vmci_LDFLAGS = @LIBZMQ_VMCI_LDFLAGS@
|
||||
test_pair_vmci_CXXFLAGS = @LIBZMQ_VMCI_CXXFLAGS@
|
||||
|
||||
test_reqrep_vmci_SOURCES = tests/test_reqrep_vmci.cpp
|
||||
test_reqrep_vmci_LDADD = src/libzmq.la
|
||||
test_reqrep_vmci_LDADD = src/libzmq.la ${UNITY_LIBS}
|
||||
test_reqrep_vmci_CPPFLAGS = ${UNITY_CPPFLAGS}
|
||||
test_reqrep_vmci_LDFLAGS = @LIBZMQ_VMCI_LDFLAGS@
|
||||
test_reqrep_vmci_CXXFLAGS = @LIBZMQ_VMCI_CXXFLAGS@
|
||||
|
||||
|
@ -32,37 +32,41 @@
|
||||
#include <vmci_sockets.h>
|
||||
|
||||
#include "testutil.hpp"
|
||||
#include "testutil_unity.hpp"
|
||||
|
||||
int main (void)
|
||||
void setUp ()
|
||||
{
|
||||
setup_test_environment ();
|
||||
void *ctx = zmq_ctx_new ();
|
||||
assert (ctx);
|
||||
setup_test_context ();
|
||||
}
|
||||
|
||||
void tearDown ()
|
||||
{
|
||||
teardown_test_context ();
|
||||
}
|
||||
|
||||
void test_pair_vmci ()
|
||||
{
|
||||
std::stringstream s;
|
||||
s << "vmci://" << VMCISock_GetLocalCID () << ":" << 5560;
|
||||
std::string endpoint = s.str ();
|
||||
|
||||
void *sb = zmq_socket (ctx, ZMQ_PAIR);
|
||||
assert (sb);
|
||||
int rc = zmq_bind (sb, endpoint.c_str ());
|
||||
assert (rc == 0);
|
||||
void *sb = test_context_socket (ZMQ_PAIR);
|
||||
TEST_ASSERT_SUCCESS_ERRNO (zmq_bind (sb, endpoint.c_str ()));
|
||||
|
||||
void *sc = zmq_socket (ctx, ZMQ_PAIR);
|
||||
assert (sc);
|
||||
rc = zmq_connect (sc, endpoint.c_str ());
|
||||
assert (rc == 0);
|
||||
void *sc = test_context_socket (ZMQ_PAIR);
|
||||
TEST_ASSERT_SUCCESS_ERRNO (zmq_connect (sc, endpoint.c_str ()));
|
||||
|
||||
bounce (sb, sc);
|
||||
|
||||
rc = zmq_close (sc);
|
||||
assert (rc == 0);
|
||||
|
||||
rc = zmq_close (sb);
|
||||
assert (rc == 0);
|
||||
|
||||
rc = zmq_ctx_term (ctx);
|
||||
assert (rc == 0);
|
||||
|
||||
return 0;
|
||||
test_context_socket_close (sc);
|
||||
test_context_socket_close (sb);
|
||||
}
|
||||
|
||||
int main (void)
|
||||
{
|
||||
setup_test_environment ();
|
||||
|
||||
UNITY_BEGIN ();
|
||||
RUN_TEST (test_pair_vmci);
|
||||
return UNITY_END ();
|
||||
}
|
||||
|
@ -32,37 +32,41 @@
|
||||
#include <vmci_sockets.h>
|
||||
|
||||
#include "testutil.hpp"
|
||||
#include "testutil_unity.hpp"
|
||||
|
||||
int main (void)
|
||||
void setUp ()
|
||||
{
|
||||
setup_test_environment ();
|
||||
void *ctx = zmq_ctx_new ();
|
||||
assert (ctx);
|
||||
setup_test_context ();
|
||||
}
|
||||
|
||||
void tearDown ()
|
||||
{
|
||||
teardown_test_context ();
|
||||
}
|
||||
|
||||
void test_reqrep_vmci ()
|
||||
{
|
||||
std::stringstream s;
|
||||
s << "vmci://" << VMCISock_GetLocalCID () << ":" << 5560;
|
||||
std::string endpoint = s.str ();
|
||||
|
||||
void *sb = zmq_socket (ctx, ZMQ_REP);
|
||||
assert (sb);
|
||||
int rc = zmq_bind (sb, endpoint.c_str ());
|
||||
assert (rc == 0);
|
||||
void *sb = test_context_socket (ZMQ_REP);
|
||||
TEST_ASSERT_SUCCESS_ERRNO (zmq_bind (sb, endpoint.c_str ()));
|
||||
|
||||
void *sc = zmq_socket (ctx, ZMQ_REQ);
|
||||
assert (sc);
|
||||
rc = zmq_connect (sc, endpoint.c_str ());
|
||||
assert (rc == 0);
|
||||
void *sc = test_context_socket (ZMQ_REQ);
|
||||
TEST_ASSERT_SUCCESS_ERRNO (zmq_connect (sc, endpoint.c_str ()));
|
||||
|
||||
bounce (sb, sc);
|
||||
|
||||
rc = zmq_close (sc);
|
||||
assert (rc == 0);
|
||||
|
||||
rc = zmq_close (sb);
|
||||
assert (rc == 0);
|
||||
|
||||
rc = zmq_ctx_term (ctx);
|
||||
assert (rc == 0);
|
||||
|
||||
return 0;
|
||||
test_context_socket_close (sc);
|
||||
test_context_socket_close (sb);
|
||||
}
|
||||
|
||||
int main (void)
|
||||
{
|
||||
setup_test_environment ();
|
||||
|
||||
UNITY_BEGIN ();
|
||||
RUN_TEST (test_reqrep_vmci);
|
||||
return UNITY_END ();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user