tstRTR0Common.h revision 7e3ff7c4e45ee1f8eb46a1aba9d2d8816d337c4a
/* $Id$ */
/** @file
* IPRT R0 Testcase - Common header.
*/
/*
* 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.
*/
#ifndef ___testcase_tstRTR0Common_h
#define ___testcase_tstRTR0Common_h
#include "tstRTR0CommonReq.h"
/*******************************************************************************
* Global Variables *
*******************************************************************************/
/** Global error buffer used by macros and inline functions in this file. */
static char g_szErr[2048];
/**
* Service request handler prolog.
*
* Returns if the input is invalid. Initializes the return packet as well as
* the globals (g_szErr).
*
* @param pReqHdr The request packet header.
*/
#define RTR0TESTR0_SRV_REQ_PROLOG_RET(pReqHdr) \
do \
{ \
return VERR_INVALID_PARAMETER; \
\
return VERR_INVALID_PARAMETER; \
\
/* Initialize the global buffer. */ \
} while (0)
/**
* Service request handler epilog.
*
* Copies any errors or messages into the request packet.
*
* @param pReqHdr The request packet header.
*/
#define RTR0TESTR0_SRV_REQ_EPILOG(pReqHdr) \
do \
{ \
} while (0)
/**
* Implement the sanity check switch-cases of a service request handler.
*/
#define RTR0TESTR0_IMPLEMENT_SANITY_CASES() \
case RTTSTR0REQ_SANITY_OK: \
break; \
case RTTSTR0REQ_SANITY_FAILURE: \
break
/**
* Implements the default switch-case of a service request handler.
* @param uOperation The operation.
*/
#define RTR0TESTR0_IMPLEMENT_DEFAULT_CASE(uOperation) \
default: \
break
/**
* Macro for checking the return code of an API in the ring-0 testcase.
*
* Similar to RTTESTI_CHECK_RC.
*
* @param rcExpr The expression producing the return code. Only
* evaluated once.
* @param rcExpect The expected result. Evaluated multiple times.
*/
do { \
} while (0)
/**
* Same as RTR0TESTR0_CHECK_RC + break.
*/
if (1) \
{ \
{ \
break; \
} \
} else do { } while (0)
/**
* Macro for checking the return code of an API in the ring-0 testcase.
*
* Similar to RTTESTI_CHECK_MSG
*
* @param expr The expression to evaluate.
* @param DetailsArgs Format string + arguments - in paranthesis.
*/
do { \
if (!(expr)) \
{ \
} \
} while (0)
/**
* Same as RTR0TESTR0_CHECK_MSG + break.
*/
if (!(expr)) \
{ \
break; \
} else do { } while (0)
/**
* Same as RTR0TESTR0_CHECK_MSG + return @a rcRete.
*/
do { \
if (!(expr)) \
{ \
return (rcRet); \
} \
} while (0)
/**
* Report an error.
*/
void RTR0TestR0Error(const char *pszFormat, ...)
{
if (cbLeft > 10)
{
if (off)
{
*psz++ = '\n';
*psz++ = '\n';
cbLeft -= 2;
}
*psz++ = '!';
cbLeft--;
}
}
/**
* Append error details.
*/
void RTR0TestR0AppendDetails(const char *pszFormat, ...)
{
}
/**
* Informational message.
*/
void RTR0TestR0Info(const char *pszFormat, ...)
{
if (cbLeft > 10)
{
if (off)
{
*psz++ = '\n';
*psz++ = '\n';
cbLeft -= 2;
}
*psz++ = '?';
cbLeft--;
}
}
#endif