tstRTLocalIpc.cpp revision a289da5a6549242471e79096dabe53a03206047d
/* $Id$ */
/** @file
* IPRT Testcase - RTLocalIpc.
*/
/*
* Copyright (C) 2013 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*
* The contents of this file may alternatively be used under the terms
* of the Common Development and Distribution License Version 1.0
* (CDDL) only, as it comes in the "COPYING.CDDL" file of the
* VirtualBox OSE distribution, in which case the provisions of the
* CDDL are applicable instead of those of the GPL.
*
* You may elect to license modified versions of this file under the
* terms and conditions of either the GPL or the CDDL or both.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
#include <iprt/localipc.h>
typedef struct LOCALIPCTHREADCTX
{
/** The IPC server handle. */
/** The test handle. */
static int testServerListenAndCancel2(const char *pszExecPath)
{
return rc;
}
{
return 0;
}
{
if (RT_SUCCESS(rc))
{
/* Spawn a simple worker thread and let it listen for incoming connections.
* In the meanwhile we try to cancel the server and see what happens. */
if (RT_SUCCESS(rc))
{
do
{
} while (0);
}
else
}
else
return VINF_SUCCESS;
}
{
int rc;
RTTestPrintf(pCtx->hTest, RTTESTLVL_INFO, "testSessionConnectionThread: Listening for incoming connections ...\n");
for (;;)
{
RTTestPrintf(pCtx->hTest, RTTESTLVL_DEBUG, "testSessionConnectionThread: Listening returned with rc=%Rrc\n", rc);
if (RT_SUCCESS(rc))
{
RTTestPrintf(pCtx->hTest, RTTESTLVL_INFO, "testSessionConnectionThread: Got new client connection\n");
}
else
break;
}
return rc;
}
{
do
{
RTTEST_CHECK_RC_BREAK(hTest, RTLocalIpcSessionConnect(&clientSession, "tstRTLocalIpcSessionConnection",
0 /* Flags */), VINF_SUCCESS);
} while (0);
}
{
if (RT_SUCCESS(rc))
{
#ifndef VBOX_TESTCASES_WITH_NO_THREADING
/* Spawn a simple worker thread and let it listen for incoming connections.
* In the meanwhile we try to cancel the server and see what happens. */
if (RT_SUCCESS(rc))
{
do
{
int threadRc;
}
while (0);
}
else
#else
do
{
if (RT_SUCCESS(rc))
{
}
else
} while (0);
#endif
}
else
return VINF_SUCCESS;
}
{
int rc;
for (;;)
{
RTTestPrintf(pCtx->hTest, RTTESTLVL_INFO, "testSessionWaitThread: Listening for incoming connections ...\n");
if (RT_SUCCESS(rc))
{
RTTestPrintf(pCtx->hTest, RTTESTLVL_INFO, "testSessionWaitThread: Got new client connection, waiting a bit ...\n");
RTThreadSleep(2000);
}
else
{
RTTestPrintf(pCtx->hTest, RTTESTLVL_INFO, "testSessionWaitThread: Listening ended with rc=%Rrc\n", rc);
break;
}
}
return rc;
}
{
do
{
0 /* Flags */), VINF_SUCCESS);
/* Next, try 60s timeout. Should be returning way earlier because the server closed the
* connection after the first client connected. */
/* Last try, also should fail because the server should be not around anymore. */
} while (0);
}
{
if (RT_SUCCESS(rc))
{
/* Spawn a simple worker thread and let it listen for incoming connections.
* In the meanwhile we try to cancel the server and see what happens. */
if (RT_SUCCESS(rc))
{
do
{
/* Wait for the server thread to terminate. */
int threadRc;
/* Check if the child ran successfully. */
}
while (0);
}
else
}
else
return VINF_SUCCESS;
}
{
return RTEXITCODE_FAILURE;
/* Note: We assume argv[2] always contains the actual test type to perform. */
if (rcExit)
return rcExit;
RTAssertSetMayPanic(false);
#ifdef DEBUG_andy
RTAssertSetQuiet(true);
#endif
return RTTestSummaryAndDestroy(hTest);
}
{
if ( argc > 2
if (rcExit)
return rcExit;
char szExecPath[RTPATH_MAX];
RTTestISub("Basics");
RTAssertSetMayPanic(false);
#ifdef DEBUG_andy
RTAssertSetQuiet(true);
#endif
/* Server-side. */
RTTESTI_CHECK_RC_RET(RTLocalIpcServerCreate(&ipcServer, "BasicTest", 0 /* Invalid flags */), VERR_INVALID_PARAMETER, 1);
RTTESTI_CHECK_RC_RET(RTLocalIpcServerCreate(&ipcServer, "BasicTest", 1234 /* Invalid flags */), VERR_INVALID_PARAMETER, 1);
/* Basic server creation / destruction. */
RTTESTI_CHECK_RC_RET(RTLocalIpcServerCreate(&ipcServer, "BasicTest", RTLOCALIPC_FLAGS_MULTI_SESSION), VINF_SUCCESS, 1);
/* Client-side (per session). */
RTTESTI_CHECK_RC_RET(RTLocalIpcSessionConnect(&ipcSession, "BasicTest", 1234 /* Invalid flags */), VERR_INVALID_PARAMETER, 1);
/* Basic client creation / destruction. */
RTTESTI_CHECK_RC_RET(RTLocalIpcSessionConnect(&ipcSession, "BasicTest", 0), VERR_FILE_NOT_FOUND, 1);
if (RTTestErrorCount(hTest) == 0)
{
}
/*
* Summary.
*/
return RTTestSummaryAndDestroy(hTest);
}