test/platform/pthread/thread/test_thread_create.cpp
TEST(basics)
{
    allocator* alloc = nullptr;
    thread* th = nullptr;
    threadstuff ts;

    /* clear thread context. */
    memset(&ts, 0, sizeof(ts));

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

    /* precondition: val is 0. */
    TEST_ASSERT(0 == ts.val);

    /* we should be able to create a thread. */
    TEST_ASSERT(STATUS_SUCCESS == thread_create(&th, alloc, 16384, &ts, &incr));

    /* join the thread. */
    TEST_ASSERT(
        ERROR_SOCKET_UTILITIES_SOCKETPAIR_FAILURE ==
            resource_release(thread_resource_handle(th)));

    /* postcondition: val is 1. */
    TEST_EXPECT(1 == ts.val);

    /* clean up. */
    TEST_ASSERT(
        STATUS_SUCCESS == resource_release(allocator_resource_handle(alloc)));
}
/**
 * Verify that we can create and execute a thread.
 */
Verify that we can create and execute a thread.
Verify that we can create and execute a thread .
TEST(basics)
{
    allocator* alloc = nullptr;
    thread* th = nullptr;
    threadstuff ts;
    memset(&ts, 0, sizeof(ts));
    TEST_ASSERT(STATUS_SUCCESS == malloc_allocator_create(&alloc));
    TEST_ASSERT(0 == ts.val);
    TEST_ASSERT(STATUS_SUCCESS == thread_create(&th, alloc, 16384, &ts, &incr));
    TEST_ASSERT(
        ERROR_SOCKET_UTILITIES_SOCKETPAIR_FAILURE ==
            resource_release(thread_resource_handle(th)));
    TEST_EXPECT(1 == ts.val);
    TEST_ASSERT(
        STATUS_SUCCESS == resource_release(allocator_resource_handle(alloc)));
}
TEST ( basics ) { allocator * alloc = nullptr ; thread * th = nullptr ; threadstuff ts ; memset ( & ts , 0 , sizeof ( ts ) ) ; TEST_ASSERT ( STATUS_SUCCESS == malloc_allocator_create ( & alloc ) ) ; TEST_ASSERT ( 0 == ts . val ) ; TEST_ASSERT ( STATUS_SUCCESS == thread_create ( & th , alloc , 16384 , & ts , & incr ) ) ; TEST_ASSERT ( ERROR_SOCKET_UTILITIES_SOCKETPAIR_FAILURE == resource_release ( thread_resource_handle ( th ) ) ) ; TEST_EXPECT ( 1 == ts . val ) ; TEST_ASSERT ( STATUS_SUCCESS == resource_release ( allocator_resource_handle ( alloc ) ) ) ; }
Verify that we can create and execute a thread.
Verify that we can create and execute a thread .
/* clear thread context. */ /* we should be able to create a malloc allocator. */ /* precondition: val is 0. */ /* we should be able to create a thread. */ /* join the thread. */ /* postcondition: val is 1. */ /* clean up. */