mirror of
https://github.com/zeromq/libzmq.git
synced 2025-03-19 18:03:50 +00: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_apps += test_pair_vmci test_reqrep_vmci
|
||||||
|
|
||||||
test_pair_vmci_SOURCES = tests/test_pair_vmci.cpp
|
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_LDFLAGS = @LIBZMQ_VMCI_LDFLAGS@
|
||||||
test_pair_vmci_CXXFLAGS = @LIBZMQ_VMCI_CXXFLAGS@
|
test_pair_vmci_CXXFLAGS = @LIBZMQ_VMCI_CXXFLAGS@
|
||||||
|
|
||||||
test_reqrep_vmci_SOURCES = tests/test_reqrep_vmci.cpp
|
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_LDFLAGS = @LIBZMQ_VMCI_LDFLAGS@
|
||||||
test_reqrep_vmci_CXXFLAGS = @LIBZMQ_VMCI_CXXFLAGS@
|
test_reqrep_vmci_CXXFLAGS = @LIBZMQ_VMCI_CXXFLAGS@
|
||||||
|
|
||||||
|
@ -32,37 +32,41 @@
|
|||||||
#include <vmci_sockets.h>
|
#include <vmci_sockets.h>
|
||||||
|
|
||||||
#include "testutil.hpp"
|
#include "testutil.hpp"
|
||||||
|
#include "testutil_unity.hpp"
|
||||||
|
|
||||||
int main (void)
|
void setUp ()
|
||||||
{
|
{
|
||||||
setup_test_environment ();
|
setup_test_context ();
|
||||||
void *ctx = zmq_ctx_new ();
|
}
|
||||||
assert (ctx);
|
|
||||||
|
|
||||||
|
void tearDown ()
|
||||||
|
{
|
||||||
|
teardown_test_context ();
|
||||||
|
}
|
||||||
|
|
||||||
|
void test_pair_vmci ()
|
||||||
|
{
|
||||||
std::stringstream s;
|
std::stringstream s;
|
||||||
s << "vmci://" << VMCISock_GetLocalCID () << ":" << 5560;
|
s << "vmci://" << VMCISock_GetLocalCID () << ":" << 5560;
|
||||||
std::string endpoint = s.str ();
|
std::string endpoint = s.str ();
|
||||||
|
|
||||||
void *sb = zmq_socket (ctx, ZMQ_PAIR);
|
void *sb = test_context_socket (ZMQ_PAIR);
|
||||||
assert (sb);
|
TEST_ASSERT_SUCCESS_ERRNO (zmq_bind (sb, endpoint.c_str ()));
|
||||||
int rc = zmq_bind (sb, endpoint.c_str ());
|
|
||||||
assert (rc == 0);
|
|
||||||
|
|
||||||
void *sc = zmq_socket (ctx, ZMQ_PAIR);
|
void *sc = test_context_socket (ZMQ_PAIR);
|
||||||
assert (sc);
|
TEST_ASSERT_SUCCESS_ERRNO (zmq_connect (sc, endpoint.c_str ()));
|
||||||
rc = zmq_connect (sc, endpoint.c_str ());
|
|
||||||
assert (rc == 0);
|
|
||||||
|
|
||||||
bounce (sb, sc);
|
bounce (sb, sc);
|
||||||
|
|
||||||
rc = zmq_close (sc);
|
test_context_socket_close (sc);
|
||||||
assert (rc == 0);
|
test_context_socket_close (sb);
|
||||||
|
}
|
||||||
rc = zmq_close (sb);
|
|
||||||
assert (rc == 0);
|
int main (void)
|
||||||
|
{
|
||||||
rc = zmq_ctx_term (ctx);
|
setup_test_environment ();
|
||||||
assert (rc == 0);
|
|
||||||
|
UNITY_BEGIN ();
|
||||||
return 0;
|
RUN_TEST (test_pair_vmci);
|
||||||
|
return UNITY_END ();
|
||||||
}
|
}
|
||||||
|
@ -32,37 +32,41 @@
|
|||||||
#include <vmci_sockets.h>
|
#include <vmci_sockets.h>
|
||||||
|
|
||||||
#include "testutil.hpp"
|
#include "testutil.hpp"
|
||||||
|
#include "testutil_unity.hpp"
|
||||||
|
|
||||||
int main (void)
|
void setUp ()
|
||||||
{
|
{
|
||||||
setup_test_environment ();
|
setup_test_context ();
|
||||||
void *ctx = zmq_ctx_new ();
|
}
|
||||||
assert (ctx);
|
|
||||||
|
|
||||||
|
void tearDown ()
|
||||||
|
{
|
||||||
|
teardown_test_context ();
|
||||||
|
}
|
||||||
|
|
||||||
|
void test_reqrep_vmci ()
|
||||||
|
{
|
||||||
std::stringstream s;
|
std::stringstream s;
|
||||||
s << "vmci://" << VMCISock_GetLocalCID () << ":" << 5560;
|
s << "vmci://" << VMCISock_GetLocalCID () << ":" << 5560;
|
||||||
std::string endpoint = s.str ();
|
std::string endpoint = s.str ();
|
||||||
|
|
||||||
void *sb = zmq_socket (ctx, ZMQ_REP);
|
void *sb = test_context_socket (ZMQ_REP);
|
||||||
assert (sb);
|
TEST_ASSERT_SUCCESS_ERRNO (zmq_bind (sb, endpoint.c_str ()));
|
||||||
int rc = zmq_bind (sb, endpoint.c_str ());
|
|
||||||
assert (rc == 0);
|
|
||||||
|
|
||||||
void *sc = zmq_socket (ctx, ZMQ_REQ);
|
void *sc = test_context_socket (ZMQ_REQ);
|
||||||
assert (sc);
|
TEST_ASSERT_SUCCESS_ERRNO (zmq_connect (sc, endpoint.c_str ()));
|
||||||
rc = zmq_connect (sc, endpoint.c_str ());
|
|
||||||
assert (rc == 0);
|
|
||||||
|
|
||||||
bounce (sb, sc);
|
bounce (sb, sc);
|
||||||
|
|
||||||
rc = zmq_close (sc);
|
test_context_socket_close (sc);
|
||||||
assert (rc == 0);
|
test_context_socket_close (sb);
|
||||||
|
}
|
||||||
rc = zmq_close (sb);
|
|
||||||
assert (rc == 0);
|
int main (void)
|
||||||
|
{
|
||||||
rc = zmq_ctx_term (ctx);
|
setup_test_environment ();
|
||||||
assert (rc == 0);
|
|
||||||
|
UNITY_BEGIN ();
|
||||||
return 0;
|
RUN_TEST (test_reqrep_vmci);
|
||||||
|
return UNITY_END ();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user