Commit 74078029 authored by Simon Giesecke's avatar Simon Giesecke

Problem: tests without test framework

Solution: migrate to Unity
parent e17232f7
...@@ -941,12 +941,14 @@ if HAVE_VMCI ...@@ -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 @@ ...@@ -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);
rc = zmq_ctx_term (ctx); int main (void)
assert (rc == 0); {
setup_test_environment ();
return 0; UNITY_BEGIN ();
RUN_TEST (test_pair_vmci);
return UNITY_END ();
} }
...@@ -32,37 +32,41 @@ ...@@ -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);
rc = zmq_ctx_term (ctx); int main (void)
assert (rc == 0); {
setup_test_environment ();
return 0; UNITY_BEGIN ();
RUN_TEST (test_reqrep_vmci);
return UNITY_END ();
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment