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