tstRTR0CommonDriver.h revision 533240a0b68828716de5ebea7afaf56720aa6ae7
/* $Id$ */
/** @file
* IPRT R0 Testcase - Common header for the testcase drivers.
*/
/*
* Copyright (C) 2010 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 "tstRTR0CommonReq.h"
/*******************************************************************************
* Global Variables *
*******************************************************************************/
/** The test handle. */
/** The test & service name. */
char g_szSrvName[64];
/** The length of the service name. */
/** The base address of the service module. */
void *g_pvImageBase;
/**
* Initializes the test driver.
*
* This means creating a test instance (RTTEST), initializing the support
* library, and loading the service module.
*
* @returns RTEXITCODE_SUCCESS on success, appropriate exit code on failure.
* @param pszTestServiceName The name of the test and service. This
* will be used when creating the test
* instance as well as when talking with the
* kernel side of the test.
*
* The ring-0 module name will be derived from
* this + '.r0'.
*
* The service request handler function name
* will be derived by upper casing the first
* chars and appending 'SrvReqHandler'.
*
*/
{
/*
* Init the test.
*/
if (rcExit != RTEXITCODE_SUCCESS)
return rcExit;
/*
* Init the globals.
*/
if (rc != VINF_SUCCESS)
{
return RTTestSummaryAndDestroy(g_hTest);
}
/*
* Initialize the support driver session.
*/
if (RT_FAILURE(rc))
{
return RTTestSummaryAndDestroy(g_hTest);
}
if (RT_SUCCESS(rc))
if (RT_SUCCESS(rc))
if (RT_FAILURE(rc))
{
return RTTestSummaryAndDestroy(g_hTest);
}
if (RT_FAILURE(rc))
{
return RTTestSummaryAndDestroy(g_hTest);
}
/*
* Do the sanity checks.
*/
RTTESTI_CHECK_RC(rc = SUPR3CallR0Service(g_szSrvName, g_cchSrvName, RTTSTR0REQ_SANITY_OK, 0, &Req.Hdr), VINF_SUCCESS);
if (RT_FAILURE(rc))
return RTTestSummaryAndDestroy(g_hTest);
return RTTestSummaryAndDestroy(g_hTest);
RTTESTI_CHECK_RC(rc = SUPR3CallR0Service(g_szSrvName, g_cchSrvName, RTTSTR0REQ_SANITY_FAILURE, 0, &Req.Hdr), VINF_SUCCESS);
if (RT_FAILURE(rc))
return RTTestSummaryAndDestroy(g_hTest);
if (rc)
{
return RTTestSummaryAndDestroy(g_hTest);
}
return RTEXITCODE_SUCCESS;
}
/**
* Processes the messages in the request.
*
* @returns true on success, false on failure.
* @param pReq The request.
*/
{
/*
* Process the message strings.
*
* We can have multiple failures and info messages packed into szMsg. They
* are separated by a double newline. The kind of message is indicated by
* the first character, '!' means error and '?' means info message.
*/
bool fRc = true;
{
do
{
do
*--pszEnd = '\0';
if (*pszCur == '!')
{
fRc = false;
}
else
} while (pszNext);
}
return fRc;
}
/**
* Performs a simple test with an argument (@a u64Arg).
*
* @returns true on success, false on failure.
* @param uOperation The operation to perform.
* @param u64Arg 64-bit argument.
* @param pszTestFmt The sub-test name.
* @param ... Format arguments.
*/
{
if (RT_FAILURE(rc))
{
return false;
}
return rtR3TestR0ProcessMessages(&Req);
}
/**
* Performs a simple test.
*
* @returns true on success, false on failure.
* @param uOperation The operation to perform.
* @param pszTestFmt The sub-test name.
* @param ... Format arguments.
*/
{
if (RT_FAILURE(rc))
{
return false;
}
return rtR3TestR0ProcessMessages(&Req);
}
#endif