test/psock/test_psock_create_from_descriptor.cpp
TEST(create)
{
    allocator* alloc = nullptr;
    psock* s = nullptr;
    int lhs;
    int rhs;

    /* we should be able to create a malloc allocator. */
    TEST_ASSERT(
        STATUS_SUCCESS == malloc_allocator_create(&alloc));

    /* we should be able to create a socket pair. */
    TEST_ASSERT(
        STATUS_SUCCESS ==
            socket_utility_socketpair(AF_UNIX, SOCK_STREAM, 0, &lhs, &rhs));

    /* close the rhs; we don't need it. */
    close(rhs);

    /* we should be able to create a psock from the lhs socket. */
    TEST_ASSERT(
        STATUS_SUCCESS ==
            psock_create_from_descriptor(
                &s, alloc, lhs));

    /* we should be able to release the socket, which in turn will close the lhs
     * descriptor. */
    TEST_ASSERT(
        STATUS_SUCCESS ==
            resource_release(psock_resource_handle(s)));

    /* clean up. */
    TEST_ASSERT(
        STATUS_SUCCESS == resource_release(allocator_resource_handle(alloc)));
}
/**
 * Verify that we can create and release a psock instance created from a
 * descriptor.
 */
Verify that we can create and release a psock instance created from a
descriptor.
Verify that we can create and release a psock instance created from a descriptor .
TEST(create)
{
    allocator* alloc = nullptr;
    psock* s = nullptr;
    int lhs;
    int rhs;
    TEST_ASSERT(
        STATUS_SUCCESS == malloc_allocator_create(&alloc));
    TEST_ASSERT(
        STATUS_SUCCESS ==
            socket_utility_socketpair(AF_UNIX, SOCK_STREAM, 0, &lhs, &rhs));
    close(rhs);
    TEST_ASSERT(
        STATUS_SUCCESS ==
            psock_create_from_descriptor(
                &s, alloc, lhs));
    TEST_ASSERT(
        STATUS_SUCCESS ==
            resource_release(psock_resource_handle(s)));
    TEST_ASSERT(
        STATUS_SUCCESS == resource_release(allocator_resource_handle(alloc)));
}
TEST ( create ) { allocator * alloc = nullptr ; psock * s = nullptr ; int lhs ; int rhs ; TEST_ASSERT ( STATUS_SUCCESS == malloc_allocator_create ( & alloc ) ) ; TEST_ASSERT ( STATUS_SUCCESS == socket_utility_socketpair ( AF_UNIX , SOCK_STREAM , 0 , & lhs , & rhs ) ) ; close ( rhs ) ; TEST_ASSERT ( STATUS_SUCCESS == psock_create_from_descriptor ( & s , alloc , lhs ) ) ; TEST_ASSERT ( STATUS_SUCCESS == resource_release ( psock_resource_handle ( s ) ) ) ; TEST_ASSERT ( STATUS_SUCCESS == resource_release ( allocator_resource_handle ( alloc ) ) ) ; }
Verify that we can create and release a psock instance created from a
 descriptor.
Verify that we can create and release a psock instance created from a descriptor .
/* we should be able to create a malloc allocator. */ /* we should be able to create a socket pair. */ /* close the rhs; we don't need it. */ /* we should be able to create a psock from the lhs socket. */ /* we should be able to release the socket, which in turn will close the lhs
     * descriptor. */ /* clean up. */