2023-06-05 00:16:05 +01:00
|
|
|
/* SPDX-License-Identifier: MPL-2.0 */
|
2015-12-07 18:19:45 +06:00
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <sstream>
|
|
|
|
#include <vmci_sockets.h>
|
|
|
|
|
|
|
|
#include "testutil.hpp"
|
2019-03-22 09:30:09 -04:00
|
|
|
#include "testutil_unity.hpp"
|
2015-12-07 18:19:45 +06:00
|
|
|
|
2019-03-24 12:51:28 -04:00
|
|
|
SETUP_TEARDOWN_TESTCONTEXT
|
2015-12-07 18:19:45 +06:00
|
|
|
|
2019-03-22 09:30:09 -04:00
|
|
|
void test_reqrep_vmci ()
|
|
|
|
{
|
2023-01-31 00:28:38 +00:00
|
|
|
unsigned int cid = VMCISock_GetLocalCID ();
|
|
|
|
if (cid == VMADDR_CID_ANY)
|
|
|
|
TEST_IGNORE_MESSAGE ("VMCI environment unavailable, skipping test");
|
2015-12-07 18:19:45 +06:00
|
|
|
std::stringstream s;
|
2023-01-31 00:28:38 +00:00
|
|
|
s << "vmci://" << cid << ":" << 5560;
|
2015-12-07 18:19:45 +06:00
|
|
|
std::string endpoint = s.str ();
|
|
|
|
|
2021-02-20 18:08:25 +00:00
|
|
|
void *sb = test_context_socket (ZMQ_DEALER);
|
2021-09-21 19:06:56 +01:00
|
|
|
int rc = zmq_bind (sb, endpoint.c_str ());
|
2023-01-12 00:36:35 +00:00
|
|
|
if (rc < 0 && (errno == EAFNOSUPPORT || errno == EPROTONOSUPPORT))
|
2021-09-21 19:06:56 +01:00
|
|
|
TEST_IGNORE_MESSAGE ("VMCI not supported");
|
|
|
|
TEST_ASSERT_SUCCESS_ERRNO (rc);
|
2015-12-07 18:19:45 +06:00
|
|
|
|
2021-02-20 18:08:25 +00:00
|
|
|
void *sc = test_context_socket (ZMQ_DEALER);
|
2019-03-22 09:30:09 -04:00
|
|
|
TEST_ASSERT_SUCCESS_ERRNO (zmq_connect (sc, endpoint.c_str ()));
|
2015-12-07 18:19:45 +06:00
|
|
|
|
2023-01-12 00:36:35 +00:00
|
|
|
bounce (sb, sc);
|
2015-12-07 18:19:45 +06:00
|
|
|
|
2021-02-20 18:08:25 +00:00
|
|
|
test_context_socket_close_zero_linger (sc);
|
|
|
|
test_context_socket_close_zero_linger (sb);
|
2019-03-22 09:30:09 -04:00
|
|
|
}
|
2015-12-07 18:19:45 +06:00
|
|
|
|
2019-03-22 09:30:09 -04:00
|
|
|
int main (void)
|
|
|
|
{
|
|
|
|
setup_test_environment ();
|
2015-12-07 18:19:45 +06:00
|
|
|
|
2019-03-22 09:30:09 -04:00
|
|
|
UNITY_BEGIN ();
|
|
|
|
RUN_TEST (test_reqrep_vmci);
|
|
|
|
return UNITY_END ();
|
2015-12-07 18:19:45 +06:00
|
|
|
}
|