test.h revision 9c77b083e2ca3a9b509faa9789072f2527422e22
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync/** @file
b736c553dbde2c3b2533c93c57d9b7f07714371cvboxsync * IPRT - Testcase Framework.
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync */
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync/*
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync * Copyright (C) 2009 Sun Microsystems, Inc.
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync *
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync * available from http://www.virtualbox.org. This file is free software;
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync * you can redistribute it and/or modify it under the terms of the GNU
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync * General Public License (GPL) as published by the Free Software
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync *
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync * The contents of this file may alternatively be used under the terms
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync * of the Common Development and Distribution License Version 1.0
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync * VirtualBox OSE distribution, in which case the provisions of the
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync * CDDL are applicable instead of those of the GPL.
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync *
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync * You may elect to license modified versions of this file under the
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync * terms and conditions of either the GPL or the CDDL or both.
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync *
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync * Clara, CA 95054 USA or visit http://www.sun.com if you need
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync * additional information or have any questions.
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync */
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync#ifndef ___iprt_test_h
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync#define ___iprt_test_h
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync#include <iprt/cdefs.h>
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync#include <iprt/types.h>
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync#include <iprt/stdarg.h>
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync
590bfe12ce22cd3716448fbb9f4dc51664bfe5e2vboxsyncRT_C_DECLS_BEGIN
b736c553dbde2c3b2533c93c57d9b7f07714371cvboxsync
b736c553dbde2c3b2533c93c57d9b7f07714371cvboxsync/** @defgroup grp_rt_test RTTest - Testcase Framework.
b736c553dbde2c3b2533c93c57d9b7f07714371cvboxsync * @ingroup grp_rt
b736c553dbde2c3b2533c93c57d9b7f07714371cvboxsync * @{
b736c553dbde2c3b2533c93c57d9b7f07714371cvboxsync */
b736c553dbde2c3b2533c93c57d9b7f07714371cvboxsync
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync/** A test handle. */
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsynctypedef struct RTTESTINT *RTTEST;
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync/** A pointer to a test handle. */
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsynctypedef RTTEST *PRTTEST;
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync/** A const pointer to a test handle. */
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsynctypedef RTTEST const *PCRTTEST;
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync/** A NIL Test handle. */
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync#define NIL_RTTEST ((RTTEST)0)
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync
9474d83dcac691984017f8255821b95ec7642804vboxsync/**
9474d83dcac691984017f8255821b95ec7642804vboxsync * Test message importance level.
9474d83dcac691984017f8255821b95ec7642804vboxsync */
9474d83dcac691984017f8255821b95ec7642804vboxsynctypedef enum RTTESTLVL
9474d83dcac691984017f8255821b95ec7642804vboxsync{
9474d83dcac691984017f8255821b95ec7642804vboxsync /** Invalid 0. */
9474d83dcac691984017f8255821b95ec7642804vboxsync RTTESTLVL_INVALID = 0,
9474d83dcac691984017f8255821b95ec7642804vboxsync /** Message should always be printed. */
9474d83dcac691984017f8255821b95ec7642804vboxsync RTTESTLVL_ALWAYS,
9474d83dcac691984017f8255821b95ec7642804vboxsync /** Failure message. */
9474d83dcac691984017f8255821b95ec7642804vboxsync RTTESTLVL_FAILURE,
9474d83dcac691984017f8255821b95ec7642804vboxsync /** Sub-test banner. */
9474d83dcac691984017f8255821b95ec7642804vboxsync RTTESTLVL_SUB_TEST,
9474d83dcac691984017f8255821b95ec7642804vboxsync /** Info message. */
9474d83dcac691984017f8255821b95ec7642804vboxsync RTTESTLVL_INFO,
9474d83dcac691984017f8255821b95ec7642804vboxsync /** Debug message. */
9474d83dcac691984017f8255821b95ec7642804vboxsync RTTESTLVL_DEBUG,
9474d83dcac691984017f8255821b95ec7642804vboxsync /** The last (invalid). */
9474d83dcac691984017f8255821b95ec7642804vboxsync RTTESTLVL_END
9474d83dcac691984017f8255821b95ec7642804vboxsync} RTTESTLVL;
9474d83dcac691984017f8255821b95ec7642804vboxsync
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync/**
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync * Creates a test instance.
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync *
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync * @returns IPRT status code.
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync * @param pszTest The test name.
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync * @param phTest Where to store the test instance handle.
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync */
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsyncRTR3DECL(int) RTTestCreate(const char *pszTest, PRTTEST phTest);
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync
174e1d5b2d6b6d7c92271d7fcc070c6d0cc92312vboxsync/**
174e1d5b2d6b6d7c92271d7fcc070c6d0cc92312vboxsync * Initializes IPRT and creates a test instance.
174e1d5b2d6b6d7c92271d7fcc070c6d0cc92312vboxsync *
174e1d5b2d6b6d7c92271d7fcc070c6d0cc92312vboxsync * Typical usage is:
174e1d5b2d6b6d7c92271d7fcc070c6d0cc92312vboxsync * @code
174e1d5b2d6b6d7c92271d7fcc070c6d0cc92312vboxsync int main(int argc, char **argv)
174e1d5b2d6b6d7c92271d7fcc070c6d0cc92312vboxsync {
174e1d5b2d6b6d7c92271d7fcc070c6d0cc92312vboxsync RTTEST hTest;
174e1d5b2d6b6d7c92271d7fcc070c6d0cc92312vboxsync int rc = RTTestInitAndCreate("tstSomething", &hTest);
174e1d5b2d6b6d7c92271d7fcc070c6d0cc92312vboxsync if (rc)
174e1d5b2d6b6d7c92271d7fcc070c6d0cc92312vboxsync return rc;
174e1d5b2d6b6d7c92271d7fcc070c6d0cc92312vboxsync ...
174e1d5b2d6b6d7c92271d7fcc070c6d0cc92312vboxsync }
174e1d5b2d6b6d7c92271d7fcc070c6d0cc92312vboxsync @endcode
174e1d5b2d6b6d7c92271d7fcc070c6d0cc92312vboxsync *
9c77b083e2ca3a9b509faa9789072f2527422e22vboxsync * @returns RTEXITCODE_SUCCESS on success. On failure an error message is
9c77b083e2ca3a9b509faa9789072f2527422e22vboxsync * printed and a suitable exit code is return.
174e1d5b2d6b6d7c92271d7fcc070c6d0cc92312vboxsync *
174e1d5b2d6b6d7c92271d7fcc070c6d0cc92312vboxsync * @param pszTest The test name.
174e1d5b2d6b6d7c92271d7fcc070c6d0cc92312vboxsync * @param phTest Where to store the test instance handle.
174e1d5b2d6b6d7c92271d7fcc070c6d0cc92312vboxsync */
9c77b083e2ca3a9b509faa9789072f2527422e22vboxsyncRTR3DECL(RTEXITCODE) RTTestInitAndCreate(const char *pszTest, PRTTEST phTest);
174e1d5b2d6b6d7c92271d7fcc070c6d0cc92312vboxsync
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync/**
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync * Destroys a test instance previously created by RTTestCreate.
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync *
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync * @returns IPRT status code.
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync * @param hTest The test handle. NIL_RTTEST is ignored.
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync */
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsyncRTR3DECL(int) RTTestDestroy(RTTEST hTest);
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync
da769a9c0c94bad4a9c3bd895ea53837b58dc4d4vboxsync/**
da769a9c0c94bad4a9c3bd895ea53837b58dc4d4vboxsync * Changes the default test instance for the calling thread.
da769a9c0c94bad4a9c3bd895ea53837b58dc4d4vboxsync *
da769a9c0c94bad4a9c3bd895ea53837b58dc4d4vboxsync * @returns IPRT status code.
da769a9c0c94bad4a9c3bd895ea53837b58dc4d4vboxsync *
da769a9c0c94bad4a9c3bd895ea53837b58dc4d4vboxsync * @param hNewDefaultTest The new default test. NIL_RTTEST is fine.
da769a9c0c94bad4a9c3bd895ea53837b58dc4d4vboxsync * @param phOldTest Where to store the old test handle. Optional.
da769a9c0c94bad4a9c3bd895ea53837b58dc4d4vboxsync */
da769a9c0c94bad4a9c3bd895ea53837b58dc4d4vboxsyncRTR3DECL(int) RTTestSetDefault(RTTEST hNewDefaultTest, PRTTEST phOldTest);
da769a9c0c94bad4a9c3bd895ea53837b58dc4d4vboxsync
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync/**
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync * Allocate a block of guarded memory.
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync *
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync * @returns IPRT status code.
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync * @param hTest The test handle. If NIL_RTTEST we'll use the one
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync * associated with the calling thread.
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync * @param cb The amount of memory to allocate.
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync * @param cbAlign The alignment of the returned block.
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync * @param fHead Head or tail optimized guard.
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync * @param ppvUser Where to return the pointer to the block.
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync */
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsyncRTR3DECL(int) RTTestGuardedAlloc(RTTEST hTest, size_t cb, uint32_t cbAlign, bool fHead, void **ppvUser);
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync/**
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync * Allocates a block of guarded memory where the guarded is immediately after
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync * the user memory.
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync *
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync * @returns Pointer to the allocated memory. NULL on failure.
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync * @param hTest The test handle. If NIL_RTTEST we'll use the one
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync * associated with the calling thread.
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync * @param cb The amount of memory to allocate.
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync */
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsyncRTR3DECL(void *) RTTestGuardedAllocTail(RTTEST hTest, size_t cb);
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync/**
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync * Allocates a block of guarded memory where the guarded is right in front of
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync * the user memory.
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync *
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync * @returns Pointer to the allocated memory. NULL on failure.
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync * @param hTest The test handle. If NIL_RTTEST we'll use the one
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync * associated with the calling thread.
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync * @param cb The amount of memory to allocate.
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync */
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsyncRTR3DECL(void *) RTTestGuardedAllocHead(RTTEST hTest, size_t cb);
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync/**
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync * Frees a block of guarded memory.
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync *
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync * @returns IPRT status code.
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync * @param hTest The test handle. If NIL_RTTEST we'll use the one
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync * associated with the calling thread.
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync * @param pv The memory. NULL is ignored.
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync */
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsyncRTR3DECL(int) RTTestGuardedFree(RTTEST hTest, void *pv);
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync/**
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync * Test vprintf making sure the output starts on a new line.
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync *
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync * @returns Number of chars printed.
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync * @param hTest The test handle. If NIL_RTTEST we'll use the one
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync * associated with the calling thread.
9474d83dcac691984017f8255821b95ec7642804vboxsync * @param enmLevel Message importance level.
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync * @param pszFormat The message.
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync * @param va Arguments.
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync */
9474d83dcac691984017f8255821b95ec7642804vboxsyncRTR3DECL(int) RTTestPrintfNlV(RTTEST hTest, RTTESTLVL enmLevel, const char *pszFormat, va_list va);
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync/**
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync * Test printf making sure the output starts on a new line.
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync *
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync * @returns Number of chars printed.
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync * @param hTest The test handle. If NIL_RTTEST we'll use the one
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync * associated with the calling thread.
9474d83dcac691984017f8255821b95ec7642804vboxsync * @param enmLevel Message importance level.
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync * @param pszFormat The message.
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync * @param ... Arguments.
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync */
9474d83dcac691984017f8255821b95ec7642804vboxsyncRTR3DECL(int) RTTestPrintfNl(RTTEST hTest, RTTESTLVL enmLevel, const char *pszFormat, ...);
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync/**
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync * Test vprintf, makes sure lines are prefixed and so forth.
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync *
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync * @returns Number of chars printed.
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync * @param hTest The test handle. If NIL_RTTEST we'll use the one
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync * associated with the calling thread.
9474d83dcac691984017f8255821b95ec7642804vboxsync * @param enmLevel Message importance level.
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync * @param pszFormat The message.
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync * @param va Arguments.
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync */
9474d83dcac691984017f8255821b95ec7642804vboxsyncRTR3DECL(int) RTTestPrintfV(RTTEST hTest, RTTESTLVL enmLevel, const char *pszFormat, va_list va);
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync/**
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync * Test printf, makes sure lines are prefixed and so forth.
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync *
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync * @returns Number of chars printed.
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync * @param hTest The test handle. If NIL_RTTEST we'll use the one
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync * associated with the calling thread.
9474d83dcac691984017f8255821b95ec7642804vboxsync * @param enmLevel Message importance level.
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync * @param pszFormat The message.
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync * @param ... Arguments.
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync */
9474d83dcac691984017f8255821b95ec7642804vboxsyncRTR3DECL(int) RTTestPrintf(RTTEST hTest, RTTESTLVL enmLevel, const char *pszFormat, ...);
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync/**
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync * Prints the test banner.
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync *
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync * @returns Number of chars printed.
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync * @param hTest The test handle. If NIL_RTTEST we'll use the one
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync * associated with the calling thread.
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync */
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsyncRTR3DECL(int) RTTestBanner(RTTEST hTest);
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync/**
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync * Summaries the test, destroys the test instance and return an exit code.
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync *
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync * @returns Test program exit code.
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync * @param hTest The test handle. If NIL_RTTEST we'll use the one
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync * associated with the calling thread.
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync */
9c77b083e2ca3a9b509faa9789072f2527422e22vboxsyncRTR3DECL(RTEXITCODE) RTTestSummaryAndDestroy(RTTEST hTest);
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync
50ba3040a0c2b77a195a8239e3572d0036e4b86dvboxsync/**
50ba3040a0c2b77a195a8239e3572d0036e4b86dvboxsync * Skips the test, destroys the test instance and return an exit code.
50ba3040a0c2b77a195a8239e3572d0036e4b86dvboxsync *
50ba3040a0c2b77a195a8239e3572d0036e4b86dvboxsync * @returns Test program exit code.
50ba3040a0c2b77a195a8239e3572d0036e4b86dvboxsync * @param hTest The test handle. If NIL_RTTEST we'll use the one
50ba3040a0c2b77a195a8239e3572d0036e4b86dvboxsync * associated with the calling thread.
50ba3040a0c2b77a195a8239e3572d0036e4b86dvboxsync * @param pszReasonFmt Text explaining why, optional (NULL).
50ba3040a0c2b77a195a8239e3572d0036e4b86dvboxsync * @param va Arguments for the reason format string.
50ba3040a0c2b77a195a8239e3572d0036e4b86dvboxsync */
9c77b083e2ca3a9b509faa9789072f2527422e22vboxsyncRTR3DECL(RTEXITCODE) RTTestSkipAndDestroyV(RTTEST hTest, const char *pszReasonFmt, va_list va);
50ba3040a0c2b77a195a8239e3572d0036e4b86dvboxsync
50ba3040a0c2b77a195a8239e3572d0036e4b86dvboxsync/**
50ba3040a0c2b77a195a8239e3572d0036e4b86dvboxsync * Skips the test, destroys the test instance and return an exit code.
50ba3040a0c2b77a195a8239e3572d0036e4b86dvboxsync *
50ba3040a0c2b77a195a8239e3572d0036e4b86dvboxsync * @returns Test program exit code.
50ba3040a0c2b77a195a8239e3572d0036e4b86dvboxsync * @param hTest The test handle. If NIL_RTTEST we'll use the one
50ba3040a0c2b77a195a8239e3572d0036e4b86dvboxsync * associated with the calling thread.
50ba3040a0c2b77a195a8239e3572d0036e4b86dvboxsync * @param pszReasonFmt Text explaining why, optional (NULL).
88acfa6629a7976c0583c1712d2b5b22a87a5121vboxsync * @param ... Arguments for the reason format string.
50ba3040a0c2b77a195a8239e3572d0036e4b86dvboxsync */
9c77b083e2ca3a9b509faa9789072f2527422e22vboxsyncRTR3DECL(RTEXITCODE) RTTestSkipAndDestroy(RTTEST hTest, const char *pszReasonFmt, ...);
50ba3040a0c2b77a195a8239e3572d0036e4b86dvboxsync
9474d83dcac691984017f8255821b95ec7642804vboxsync/**
9474d83dcac691984017f8255821b95ec7642804vboxsync * Starts a sub-test.
9474d83dcac691984017f8255821b95ec7642804vboxsync *
9474d83dcac691984017f8255821b95ec7642804vboxsync * This will perform an implicit RTTestSubDone() call if that has not been done
9474d83dcac691984017f8255821b95ec7642804vboxsync * since the last RTTestSub call.
9474d83dcac691984017f8255821b95ec7642804vboxsync *
9474d83dcac691984017f8255821b95ec7642804vboxsync * @returns Number of chars printed.
9474d83dcac691984017f8255821b95ec7642804vboxsync * @param hTest The test handle. If NIL_RTTEST we'll use the one
9474d83dcac691984017f8255821b95ec7642804vboxsync * associated with the calling thread.
d544fe535c163a24bf8cd831b39264da292b8adfvboxsync * @param pszSubTest The sub-test name.
9474d83dcac691984017f8255821b95ec7642804vboxsync */
9474d83dcac691984017f8255821b95ec7642804vboxsyncRTR3DECL(int) RTTestSub(RTTEST hTest, const char *pszSubTest);
9474d83dcac691984017f8255821b95ec7642804vboxsync
d544fe535c163a24bf8cd831b39264da292b8adfvboxsync/**
d544fe535c163a24bf8cd831b39264da292b8adfvboxsync * Format string version of RTTestSub.
d544fe535c163a24bf8cd831b39264da292b8adfvboxsync *
d544fe535c163a24bf8cd831b39264da292b8adfvboxsync * See RTTestSub for details.
d544fe535c163a24bf8cd831b39264da292b8adfvboxsync *
d544fe535c163a24bf8cd831b39264da292b8adfvboxsync * @returns Number of chars printed.
d544fe535c163a24bf8cd831b39264da292b8adfvboxsync * @param hTest The test handle. If NIL_RTTEST we'll use the one
d544fe535c163a24bf8cd831b39264da292b8adfvboxsync * associated with the calling thread.
d544fe535c163a24bf8cd831b39264da292b8adfvboxsync * @param pszSubTestFmt The sub-test name format string.
d544fe535c163a24bf8cd831b39264da292b8adfvboxsync * @param ... Arguments.
d544fe535c163a24bf8cd831b39264da292b8adfvboxsync */
d544fe535c163a24bf8cd831b39264da292b8adfvboxsyncRTR3DECL(int) RTTestSubF(RTTEST hTest, const char *pszSubTestFmt, ...);
d544fe535c163a24bf8cd831b39264da292b8adfvboxsync
d544fe535c163a24bf8cd831b39264da292b8adfvboxsync/**
d544fe535c163a24bf8cd831b39264da292b8adfvboxsync * Format string version of RTTestSub.
d544fe535c163a24bf8cd831b39264da292b8adfvboxsync *
d544fe535c163a24bf8cd831b39264da292b8adfvboxsync * See RTTestSub for details.
d544fe535c163a24bf8cd831b39264da292b8adfvboxsync *
d544fe535c163a24bf8cd831b39264da292b8adfvboxsync * @returns Number of chars printed.
d544fe535c163a24bf8cd831b39264da292b8adfvboxsync * @param hTest The test handle. If NIL_RTTEST we'll use the one
d544fe535c163a24bf8cd831b39264da292b8adfvboxsync * associated with the calling thread.
d544fe535c163a24bf8cd831b39264da292b8adfvboxsync * @param pszSubTestFmt The sub-test name format string.
88acfa6629a7976c0583c1712d2b5b22a87a5121vboxsync * @param va Arguments.
d544fe535c163a24bf8cd831b39264da292b8adfvboxsync */
d544fe535c163a24bf8cd831b39264da292b8adfvboxsyncRTR3DECL(int) RTTestSubV(RTTEST hTest, const char *pszSubTestFmt, va_list va);
d544fe535c163a24bf8cd831b39264da292b8adfvboxsync
9474d83dcac691984017f8255821b95ec7642804vboxsync/**
9474d83dcac691984017f8255821b95ec7642804vboxsync * Completes a sub-test.
9474d83dcac691984017f8255821b95ec7642804vboxsync *
9474d83dcac691984017f8255821b95ec7642804vboxsync * @returns Number of chars printed.
9474d83dcac691984017f8255821b95ec7642804vboxsync * @param hTest The test handle. If NIL_RTTEST we'll use the one
9474d83dcac691984017f8255821b95ec7642804vboxsync * associated with the calling thread.
9474d83dcac691984017f8255821b95ec7642804vboxsync */
9474d83dcac691984017f8255821b95ec7642804vboxsyncRTR3DECL(int) RTTestSubDone(RTTEST hTest);
9474d83dcac691984017f8255821b95ec7642804vboxsync
904ef975124106054684a976dfb30f70372372e1vboxsync/**
904ef975124106054684a976dfb30f70372372e1vboxsync * Prints an extended PASSED message, optional.
904ef975124106054684a976dfb30f70372372e1vboxsync *
904ef975124106054684a976dfb30f70372372e1vboxsync * This does not conclude the sub-test, it could be used to report the passing
904ef975124106054684a976dfb30f70372372e1vboxsync * of a sub-sub-to-the-power-of-N-test.
904ef975124106054684a976dfb30f70372372e1vboxsync *
904ef975124106054684a976dfb30f70372372e1vboxsync * @returns IPRT status code.
904ef975124106054684a976dfb30f70372372e1vboxsync * @param hTest The test handle. If NIL_RTTEST we'll use the one
904ef975124106054684a976dfb30f70372372e1vboxsync * associated with the calling thread.
904ef975124106054684a976dfb30f70372372e1vboxsync * @param pszFormat The message. No trailing newline.
904ef975124106054684a976dfb30f70372372e1vboxsync * @param va The arguments.
904ef975124106054684a976dfb30f70372372e1vboxsync */
904ef975124106054684a976dfb30f70372372e1vboxsyncRTR3DECL(int) RTTestPassedV(RTTEST hTest, const char *pszFormat, va_list va);
904ef975124106054684a976dfb30f70372372e1vboxsync
904ef975124106054684a976dfb30f70372372e1vboxsync/**
904ef975124106054684a976dfb30f70372372e1vboxsync * Prints an extended PASSED message, optional.
904ef975124106054684a976dfb30f70372372e1vboxsync *
904ef975124106054684a976dfb30f70372372e1vboxsync * This does not conclude the sub-test, it could be used to report the passing
904ef975124106054684a976dfb30f70372372e1vboxsync * of a sub-sub-to-the-power-of-N-test.
904ef975124106054684a976dfb30f70372372e1vboxsync *
904ef975124106054684a976dfb30f70372372e1vboxsync * @returns IPRT status code.
904ef975124106054684a976dfb30f70372372e1vboxsync * @param hTest The test handle. If NIL_RTTEST we'll use the one
904ef975124106054684a976dfb30f70372372e1vboxsync * associated with the calling thread.
904ef975124106054684a976dfb30f70372372e1vboxsync * @param pszFormat The message. No trailing newline.
904ef975124106054684a976dfb30f70372372e1vboxsync * @param ... The arguments.
904ef975124106054684a976dfb30f70372372e1vboxsync */
904ef975124106054684a976dfb30f70372372e1vboxsyncRTR3DECL(int) RTTestPassed(RTTEST hTest, const char *pszFormat, ...);
904ef975124106054684a976dfb30f70372372e1vboxsync
904ef975124106054684a976dfb30f70372372e1vboxsync
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync/**
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync * Increments the error counter.
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync *
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync * @returns IPRT status code.
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync * @param hTest The test handle. If NIL_RTTEST we'll use the one
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync * associated with the calling thread.
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync */
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsyncRTR3DECL(int) RTTestErrorInc(RTTEST hTest);
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync
4fb518cb2eadd86a2bf117501cd38b05dde47745vboxsync/**
4fb518cb2eadd86a2bf117501cd38b05dde47745vboxsync * Get the current error count.
4fb518cb2eadd86a2bf117501cd38b05dde47745vboxsync *
4fb518cb2eadd86a2bf117501cd38b05dde47745vboxsync * @returns The error counter, UINT32_MAX if no valid test handle.
4fb518cb2eadd86a2bf117501cd38b05dde47745vboxsync * @param hTest The test handle. If NIL_RTTEST we'll use the one
4fb518cb2eadd86a2bf117501cd38b05dde47745vboxsync * associated with the calling thread.
4fb518cb2eadd86a2bf117501cd38b05dde47745vboxsync */
4fb518cb2eadd86a2bf117501cd38b05dde47745vboxsyncRTR3DECL(uint32_t) RTTestErrorCount(RTTEST hTest);
4fb518cb2eadd86a2bf117501cd38b05dde47745vboxsync
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync/**
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync * Increments the error counter and prints a failure message.
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync *
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync * @returns IPRT status code.
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync * @param hTest The test handle. If NIL_RTTEST we'll use the one
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync * associated with the calling thread.
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync * @param pszFormat The message. No trailing newline.
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync * @param va The arguments.
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync */
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsyncRTR3DECL(int) RTTestFailedV(RTTEST hTest, const char *pszFormat, va_list va);
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync/**
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync * Increments the error counter and prints a failure message.
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync *
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync * @returns IPRT status code.
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync * @param hTest The test handle. If NIL_RTTEST we'll use the one
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync * associated with the calling thread.
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync * @param pszFormat The message. No trailing newline.
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync * @param ... The arguments.
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync */
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsyncRTR3DECL(int) RTTestFailed(RTTEST hTest, const char *pszFormat, ...);
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync
904ef975124106054684a976dfb30f70372372e1vboxsync/**
904ef975124106054684a976dfb30f70372372e1vboxsync * Same as RTTestPrintfV with RTTESTLVL_FAILURE.
904ef975124106054684a976dfb30f70372372e1vboxsync *
904ef975124106054684a976dfb30f70372372e1vboxsync * @returns Number of chars printed.
904ef975124106054684a976dfb30f70372372e1vboxsync * @param hTest The test handle. If NIL_RTTEST we'll use the one
904ef975124106054684a976dfb30f70372372e1vboxsync * associated with the calling thread.
904ef975124106054684a976dfb30f70372372e1vboxsync * @param pszFormat The message.
904ef975124106054684a976dfb30f70372372e1vboxsync * @param va Arguments.
904ef975124106054684a976dfb30f70372372e1vboxsync */
904ef975124106054684a976dfb30f70372372e1vboxsyncRTR3DECL(int) RTTestFailureDetailsV(RTTEST hTest, const char *pszFormat, va_list va);
904ef975124106054684a976dfb30f70372372e1vboxsync
904ef975124106054684a976dfb30f70372372e1vboxsync/**
904ef975124106054684a976dfb30f70372372e1vboxsync * Same as RTTestPrintf with RTTESTLVL_FAILURE.
904ef975124106054684a976dfb30f70372372e1vboxsync *
904ef975124106054684a976dfb30f70372372e1vboxsync * @returns Number of chars printed.
904ef975124106054684a976dfb30f70372372e1vboxsync * @param hTest The test handle. If NIL_RTTEST we'll use the one
904ef975124106054684a976dfb30f70372372e1vboxsync * associated with the calling thread.
904ef975124106054684a976dfb30f70372372e1vboxsync * @param pszFormat The message.
904ef975124106054684a976dfb30f70372372e1vboxsync * @param ... Arguments.
904ef975124106054684a976dfb30f70372372e1vboxsync */
904ef975124106054684a976dfb30f70372372e1vboxsyncRTR3DECL(int) RTTestFailureDetails(RTTEST hTest, const char *pszFormat, ...);
904ef975124106054684a976dfb30f70372372e1vboxsync
b736c553dbde2c3b2533c93c57d9b7f07714371cvboxsync
b736c553dbde2c3b2533c93c57d9b7f07714371cvboxsync/** @def RTTEST_CHECK
b736c553dbde2c3b2533c93c57d9b7f07714371cvboxsync * Check whether a boolean expression holds true.
b736c553dbde2c3b2533c93c57d9b7f07714371cvboxsync *
b736c553dbde2c3b2533c93c57d9b7f07714371cvboxsync * If the expression is false, call RTTestFailed giving the line number and expression.
b736c553dbde2c3b2533c93c57d9b7f07714371cvboxsync *
b736c553dbde2c3b2533c93c57d9b7f07714371cvboxsync * @param hTest The test handle.
b736c553dbde2c3b2533c93c57d9b7f07714371cvboxsync * @param expr The expression to evaluate.
b736c553dbde2c3b2533c93c57d9b7f07714371cvboxsync */
b736c553dbde2c3b2533c93c57d9b7f07714371cvboxsync#define RTTEST_CHECK(hTest, expr) \
904ef975124106054684a976dfb30f70372372e1vboxsync do { if (!(expr)) { \
904ef975124106054684a976dfb30f70372372e1vboxsync RTTestFailed((hTest), "line %u: %s", __LINE__, #expr); \
904ef975124106054684a976dfb30f70372372e1vboxsync } \
904ef975124106054684a976dfb30f70372372e1vboxsync } while (0)
f869309f635f9316b613a848e218b7661e3a54bdvboxsync/** @def RTTEST_CHECK_RET
f869309f635f9316b613a848e218b7661e3a54bdvboxsync * Check whether a boolean expression holds true, returns on false.
9474d83dcac691984017f8255821b95ec7642804vboxsync *
9474d83dcac691984017f8255821b95ec7642804vboxsync * If the expression is false, call RTTestFailed giving the line number and expression.
9474d83dcac691984017f8255821b95ec7642804vboxsync *
f869309f635f9316b613a848e218b7661e3a54bdvboxsync * @param hTest The test handle.
f869309f635f9316b613a848e218b7661e3a54bdvboxsync * @param expr The expression to evaluate.
f869309f635f9316b613a848e218b7661e3a54bdvboxsync * @param rcRet What to return on failure.
904ef975124106054684a976dfb30f70372372e1vboxsync */
f869309f635f9316b613a848e218b7661e3a54bdvboxsync#define RTTEST_CHECK_RET(hTest, expr, rcRet) \
904ef975124106054684a976dfb30f70372372e1vboxsync do { if (!(expr)) { \
904ef975124106054684a976dfb30f70372372e1vboxsync RTTestFailed((hTest), "line %u: %s", __LINE__, #expr); \
f869309f635f9316b613a848e218b7661e3a54bdvboxsync return (rcRet); \
904ef975124106054684a976dfb30f70372372e1vboxsync } \
904ef975124106054684a976dfb30f70372372e1vboxsync } while (0)
f869309f635f9316b613a848e218b7661e3a54bdvboxsync/** @def RTTEST_CHECK_RETV
f869309f635f9316b613a848e218b7661e3a54bdvboxsync * Check whether a boolean expression holds true, returns void on false.
904ef975124106054684a976dfb30f70372372e1vboxsync *
904ef975124106054684a976dfb30f70372372e1vboxsync * If the expression is false, call RTTestFailed giving the line number and expression.
904ef975124106054684a976dfb30f70372372e1vboxsync *
904ef975124106054684a976dfb30f70372372e1vboxsync * @param hTest The test handle.
904ef975124106054684a976dfb30f70372372e1vboxsync * @param expr The expression to evaluate.
904ef975124106054684a976dfb30f70372372e1vboxsync */
f869309f635f9316b613a848e218b7661e3a54bdvboxsync#define RTTEST_CHECK_RETV(hTest, expr) \
904ef975124106054684a976dfb30f70372372e1vboxsync do { if (!(expr)) { \
904ef975124106054684a976dfb30f70372372e1vboxsync RTTestFailed((hTest), "line %u: %s", __LINE__, #expr); \
f869309f635f9316b613a848e218b7661e3a54bdvboxsync return; \
904ef975124106054684a976dfb30f70372372e1vboxsync } \
904ef975124106054684a976dfb30f70372372e1vboxsync } while (0)
904ef975124106054684a976dfb30f70372372e1vboxsync
f869309f635f9316b613a848e218b7661e3a54bdvboxsync
f869309f635f9316b613a848e218b7661e3a54bdvboxsync/** @def RTTEST_CHECK_MSG
f869309f635f9316b613a848e218b7661e3a54bdvboxsync * Check whether a boolean expression holds true.
904ef975124106054684a976dfb30f70372372e1vboxsync *
904ef975124106054684a976dfb30f70372372e1vboxsync * If the expression is false, call RTTestFailed giving the line number and expression.
904ef975124106054684a976dfb30f70372372e1vboxsync *
904ef975124106054684a976dfb30f70372372e1vboxsync * @param hTest The test handle.
904ef975124106054684a976dfb30f70372372e1vboxsync * @param expr The expression to evaluate.
904ef975124106054684a976dfb30f70372372e1vboxsync * @param DetailsArgs Argument list for RTTestFailureDetails, including
9474d83dcac691984017f8255821b95ec7642804vboxsync * parenthesis.
9474d83dcac691984017f8255821b95ec7642804vboxsync */
f869309f635f9316b613a848e218b7661e3a54bdvboxsync#define RTTEST_CHECK_MSG(hTest, expr, DetailsArgs) \
9474d83dcac691984017f8255821b95ec7642804vboxsync do { if (!(expr)) { \
9474d83dcac691984017f8255821b95ec7642804vboxsync RTTestFailed((hTest), "line %u: %s", __LINE__, #expr); \
904ef975124106054684a976dfb30f70372372e1vboxsync RTTestFailureDetails DetailsArgs; \
9474d83dcac691984017f8255821b95ec7642804vboxsync } \
9474d83dcac691984017f8255821b95ec7642804vboxsync } while (0)
f869309f635f9316b613a848e218b7661e3a54bdvboxsync/** @def RTTEST_CHECK_MSG_RET
f869309f635f9316b613a848e218b7661e3a54bdvboxsync * Check whether a boolean expression holds true, returns on false.
904ef975124106054684a976dfb30f70372372e1vboxsync *
904ef975124106054684a976dfb30f70372372e1vboxsync * If the expression is false, call RTTestFailed giving the line number and expression.
904ef975124106054684a976dfb30f70372372e1vboxsync *
f869309f635f9316b613a848e218b7661e3a54bdvboxsync * @param hTest The test handle.
f869309f635f9316b613a848e218b7661e3a54bdvboxsync * @param expr The expression to evaluate.
f869309f635f9316b613a848e218b7661e3a54bdvboxsync * @param DetailsArgs Argument list for RTTestFailureDetails, including
f869309f635f9316b613a848e218b7661e3a54bdvboxsync * parenthesis.
f869309f635f9316b613a848e218b7661e3a54bdvboxsync * @param rcRet What to return on failure.
904ef975124106054684a976dfb30f70372372e1vboxsync */
f869309f635f9316b613a848e218b7661e3a54bdvboxsync#define RTTEST_CHECK_MSG_RET(hTest, expr, DetailsArgs, rcRet) \
904ef975124106054684a976dfb30f70372372e1vboxsync do { if (!(expr)) { \
904ef975124106054684a976dfb30f70372372e1vboxsync RTTestFailed((hTest), "line %u: %s", __LINE__, #expr); \
f869309f635f9316b613a848e218b7661e3a54bdvboxsync RTTestFailureDetails DetailsArgs; \
f869309f635f9316b613a848e218b7661e3a54bdvboxsync return (rcRet); \
904ef975124106054684a976dfb30f70372372e1vboxsync } \
904ef975124106054684a976dfb30f70372372e1vboxsync } while (0)
904ef975124106054684a976dfb30f70372372e1vboxsync/** @def RTTEST_CHECK_MSG_RET
904ef975124106054684a976dfb30f70372372e1vboxsync * Check whether a boolean expression holds true, returns void on false.
904ef975124106054684a976dfb30f70372372e1vboxsync *
904ef975124106054684a976dfb30f70372372e1vboxsync * If the expression is false, call RTTestFailed giving the line number and expression.
904ef975124106054684a976dfb30f70372372e1vboxsync *
904ef975124106054684a976dfb30f70372372e1vboxsync * @param hTest The test handle.
904ef975124106054684a976dfb30f70372372e1vboxsync * @param expr The expression to evaluate.
904ef975124106054684a976dfb30f70372372e1vboxsync * @param DetailsArgs Argument list for RTTestFailureDetails, including
904ef975124106054684a976dfb30f70372372e1vboxsync * parenthesis.
904ef975124106054684a976dfb30f70372372e1vboxsync */
904ef975124106054684a976dfb30f70372372e1vboxsync#define RTTEST_CHECK_MSG_RETV(hTest, expr, DetailsArgs) \
904ef975124106054684a976dfb30f70372372e1vboxsync do { if (!(expr)) { \
904ef975124106054684a976dfb30f70372372e1vboxsync RTTestFailed((hTest), "line %u: %s", __LINE__, #expr); \
904ef975124106054684a976dfb30f70372372e1vboxsync RTTestFailureDetails DetailsArgs; \
904ef975124106054684a976dfb30f70372372e1vboxsync return; \
904ef975124106054684a976dfb30f70372372e1vboxsync } \
904ef975124106054684a976dfb30f70372372e1vboxsync } while (0)
904ef975124106054684a976dfb30f70372372e1vboxsync
f869309f635f9316b613a848e218b7661e3a54bdvboxsync
9c62bed1c091ef1a7a99cf9cf7831cb5c42c5604vboxsync/** @def RTTEST_CHECK_RC
9c62bed1c091ef1a7a99cf9cf7831cb5c42c5604vboxsync * Check whether an expression returns a specific IPRT style status code.
9c62bed1c091ef1a7a99cf9cf7831cb5c42c5604vboxsync *
9c62bed1c091ef1a7a99cf9cf7831cb5c42c5604vboxsync * If a different status code is return, call RTTestFailed giving the line
9c62bed1c091ef1a7a99cf9cf7831cb5c42c5604vboxsync * number, expression, actual and expected status codes.
9c62bed1c091ef1a7a99cf9cf7831cb5c42c5604vboxsync *
9c62bed1c091ef1a7a99cf9cf7831cb5c42c5604vboxsync * @param hTest The test handle.
e5a5dce1fd43042795bb84407afe6af5ae878662vboxsync * @param rcExpr The expression resulting in an IPRT status code.
9c62bed1c091ef1a7a99cf9cf7831cb5c42c5604vboxsync * @param rcExpect The expected return code. This may be referenced
9c62bed1c091ef1a7a99cf9cf7831cb5c42c5604vboxsync * more than once by the macro.
9c62bed1c091ef1a7a99cf9cf7831cb5c42c5604vboxsync */
f869309f635f9316b613a848e218b7661e3a54bdvboxsync#define RTTEST_CHECK_RC(hTest, rcExpr, rcExpect) \
f869309f635f9316b613a848e218b7661e3a54bdvboxsync do { \
f869309f635f9316b613a848e218b7661e3a54bdvboxsync int rcCheck = (rcExpr); \
f869309f635f9316b613a848e218b7661e3a54bdvboxsync if (rcCheck != (rcExpect)) { \
f869309f635f9316b613a848e218b7661e3a54bdvboxsync RTTestFailed((hTest), "line %u: %s: expected %Rrc, got %Rrc", __LINE__, #rcExpr, (rcExpect), rcCheck); \
f869309f635f9316b613a848e218b7661e3a54bdvboxsync } \
f869309f635f9316b613a848e218b7661e3a54bdvboxsync } while (0)
f869309f635f9316b613a848e218b7661e3a54bdvboxsync/** @def RTTEST_CHECK_RC_RET
f869309f635f9316b613a848e218b7661e3a54bdvboxsync * Check whether an expression returns a specific IPRT style status code.
f869309f635f9316b613a848e218b7661e3a54bdvboxsync *
f869309f635f9316b613a848e218b7661e3a54bdvboxsync * If a different status code is return, call RTTestFailed giving the line
f869309f635f9316b613a848e218b7661e3a54bdvboxsync * number, expression, actual and expected status codes, then return.
f869309f635f9316b613a848e218b7661e3a54bdvboxsync *
f869309f635f9316b613a848e218b7661e3a54bdvboxsync * @param hTest The test handle.
e5a5dce1fd43042795bb84407afe6af5ae878662vboxsync * @param rcExpr The expression resulting in an IPRT status code.
e5a5dce1fd43042795bb84407afe6af5ae878662vboxsync * This will be assigned to a local rcCheck variable
e5a5dce1fd43042795bb84407afe6af5ae878662vboxsync * that can be used as return value.
f869309f635f9316b613a848e218b7661e3a54bdvboxsync * @param rcExpect The expected return code. This may be referenced
f869309f635f9316b613a848e218b7661e3a54bdvboxsync * more than once by the macro.
f869309f635f9316b613a848e218b7661e3a54bdvboxsync * @param rcRet The return code.
f869309f635f9316b613a848e218b7661e3a54bdvboxsync */
f869309f635f9316b613a848e218b7661e3a54bdvboxsync#define RTTEST_CHECK_RC_RET(hTest, rcExpr, rcExpect, rcRet) \
f869309f635f9316b613a848e218b7661e3a54bdvboxsync do { \
f869309f635f9316b613a848e218b7661e3a54bdvboxsync int rcCheck = (rcExpr); \
f869309f635f9316b613a848e218b7661e3a54bdvboxsync if (rcCheck != (rcExpect)) { \
f869309f635f9316b613a848e218b7661e3a54bdvboxsync RTTestFailed((hTest), "line %u: %s: expected %Rrc, got %Rrc", __LINE__, #rcExpr, (rcExpect), rcCheck); \
f869309f635f9316b613a848e218b7661e3a54bdvboxsync return (rcRet); \
f869309f635f9316b613a848e218b7661e3a54bdvboxsync } \
f869309f635f9316b613a848e218b7661e3a54bdvboxsync } while (0)
f869309f635f9316b613a848e218b7661e3a54bdvboxsync/** @def RTTEST_CHECK_RC_RETV
f869309f635f9316b613a848e218b7661e3a54bdvboxsync * Check whether an expression returns a specific IPRT style status code.
f869309f635f9316b613a848e218b7661e3a54bdvboxsync *
f869309f635f9316b613a848e218b7661e3a54bdvboxsync * If a different status code is return, call RTTestFailed giving the line
f869309f635f9316b613a848e218b7661e3a54bdvboxsync * number, expression, actual and expected status codes, then return.
f869309f635f9316b613a848e218b7661e3a54bdvboxsync *
f869309f635f9316b613a848e218b7661e3a54bdvboxsync * @param hTest The test handle.
e5a5dce1fd43042795bb84407afe6af5ae878662vboxsync * @param rcExpr The expression resulting in an IPRT status code.
f869309f635f9316b613a848e218b7661e3a54bdvboxsync * @param rcExpect The expected return code. This may be referenced
f869309f635f9316b613a848e218b7661e3a54bdvboxsync * more than once by the macro.
f869309f635f9316b613a848e218b7661e3a54bdvboxsync */
f869309f635f9316b613a848e218b7661e3a54bdvboxsync#define RTTEST_CHECK_RC_RETV(hTest, rcExpr, rcExpect) \
9c62bed1c091ef1a7a99cf9cf7831cb5c42c5604vboxsync do { \
9c62bed1c091ef1a7a99cf9cf7831cb5c42c5604vboxsync int rcCheck = (rcExpr); \
9c62bed1c091ef1a7a99cf9cf7831cb5c42c5604vboxsync if (rcCheck != (rcExpect)) { \
9c62bed1c091ef1a7a99cf9cf7831cb5c42c5604vboxsync RTTestFailed((hTest), "line %u: %s: expected %Rrc, got %Rrc", __LINE__, #rcExpr, (rcExpect), rcCheck); \
f869309f635f9316b613a848e218b7661e3a54bdvboxsync return; \
9c62bed1c091ef1a7a99cf9cf7831cb5c42c5604vboxsync } \
9c62bed1c091ef1a7a99cf9cf7831cb5c42c5604vboxsync } while (0)
9c62bed1c091ef1a7a99cf9cf7831cb5c42c5604vboxsync
f869309f635f9316b613a848e218b7661e3a54bdvboxsync
9c62bed1c091ef1a7a99cf9cf7831cb5c42c5604vboxsync/** @def RTTEST_CHECK_RC_OK
9c62bed1c091ef1a7a99cf9cf7831cb5c42c5604vboxsync * Check whether a IPRT style status code indicates success.
9c62bed1c091ef1a7a99cf9cf7831cb5c42c5604vboxsync *
9c62bed1c091ef1a7a99cf9cf7831cb5c42c5604vboxsync * If the status indicates failure, call RTTestFailed giving the line number,
9c62bed1c091ef1a7a99cf9cf7831cb5c42c5604vboxsync * expression and status code.
9c62bed1c091ef1a7a99cf9cf7831cb5c42c5604vboxsync *
9c62bed1c091ef1a7a99cf9cf7831cb5c42c5604vboxsync * @param hTest The test handle.
e5a5dce1fd43042795bb84407afe6af5ae878662vboxsync * @param rcExpr The expression resulting in an IPRT status code.
9c62bed1c091ef1a7a99cf9cf7831cb5c42c5604vboxsync */
9c62bed1c091ef1a7a99cf9cf7831cb5c42c5604vboxsync#define RTTEST_CHECK_RC_OK(hTest, rcExpr) \
9c62bed1c091ef1a7a99cf9cf7831cb5c42c5604vboxsync do { \
9c62bed1c091ef1a7a99cf9cf7831cb5c42c5604vboxsync int rcCheck = (rcExpr); \
9c62bed1c091ef1a7a99cf9cf7831cb5c42c5604vboxsync if (RT_FAILURE(rcCheck)) { \
e5a5dce1fd43042795bb84407afe6af5ae878662vboxsync RTTestFailed((hTest), "line %u: %s: %Rrc", __LINE__, #rcExpr, rcCheck); \
9c62bed1c091ef1a7a99cf9cf7831cb5c42c5604vboxsync } \
9c62bed1c091ef1a7a99cf9cf7831cb5c42c5604vboxsync } while (0)
f869309f635f9316b613a848e218b7661e3a54bdvboxsync/** @def RTTEST_CHECK_RC_OK_RET
f869309f635f9316b613a848e218b7661e3a54bdvboxsync * Check whether a IPRT style status code indicates success.
f869309f635f9316b613a848e218b7661e3a54bdvboxsync *
f869309f635f9316b613a848e218b7661e3a54bdvboxsync * If the status indicates failure, call RTTestFailed giving the line number,
f869309f635f9316b613a848e218b7661e3a54bdvboxsync * expression and status code, then return with the specified value.
f869309f635f9316b613a848e218b7661e3a54bdvboxsync *
f869309f635f9316b613a848e218b7661e3a54bdvboxsync * @param hTest The test handle.
e5a5dce1fd43042795bb84407afe6af5ae878662vboxsync * @param rcExpr The expression resulting in an IPRT status code.
e5a5dce1fd43042795bb84407afe6af5ae878662vboxsync * This will be assigned to a local rcCheck variable
e5a5dce1fd43042795bb84407afe6af5ae878662vboxsync * that can be used as return value.
f869309f635f9316b613a848e218b7661e3a54bdvboxsync * @param rcRet The return code.
f869309f635f9316b613a848e218b7661e3a54bdvboxsync */
f869309f635f9316b613a848e218b7661e3a54bdvboxsync#define RTTEST_CHECK_RC_OK_RET(hTest, rcExpr, rcRet) \
f869309f635f9316b613a848e218b7661e3a54bdvboxsync do { \
f869309f635f9316b613a848e218b7661e3a54bdvboxsync int rcCheck = (rcExpr); \
f869309f635f9316b613a848e218b7661e3a54bdvboxsync if (RT_FAILURE(rcCheck)) { \
e5a5dce1fd43042795bb84407afe6af5ae878662vboxsync RTTestFailed((hTest), "line %u: %s: %Rrc", __LINE__, #rcExpr, rcCheck); \
f869309f635f9316b613a848e218b7661e3a54bdvboxsync return (rcRet); \
f869309f635f9316b613a848e218b7661e3a54bdvboxsync } \
f869309f635f9316b613a848e218b7661e3a54bdvboxsync } while (0)
f869309f635f9316b613a848e218b7661e3a54bdvboxsync/** @def RTTEST_CHECK_RC_OK_RETV
f869309f635f9316b613a848e218b7661e3a54bdvboxsync * Check whether a IPRT style status code indicates success.
f869309f635f9316b613a848e218b7661e3a54bdvboxsync *
f869309f635f9316b613a848e218b7661e3a54bdvboxsync * If the status indicates failure, call RTTestFailed giving the line number,
f869309f635f9316b613a848e218b7661e3a54bdvboxsync * expression and status code, then return.
f869309f635f9316b613a848e218b7661e3a54bdvboxsync *
f869309f635f9316b613a848e218b7661e3a54bdvboxsync * @param hTest The test handle.
e5a5dce1fd43042795bb84407afe6af5ae878662vboxsync * @param rcExpr The expression resulting in an IPRT status code.
f869309f635f9316b613a848e218b7661e3a54bdvboxsync */
f869309f635f9316b613a848e218b7661e3a54bdvboxsync#define RTTEST_CHECK_RC_OK_RETV(hTest, rcExpr) \
f869309f635f9316b613a848e218b7661e3a54bdvboxsync do { \
f869309f635f9316b613a848e218b7661e3a54bdvboxsync int rcCheck = (rcExpr); \
f869309f635f9316b613a848e218b7661e3a54bdvboxsync if (RT_FAILURE(rcCheck)) { \
e5a5dce1fd43042795bb84407afe6af5ae878662vboxsync RTTestFailed((hTest), "line %u: %s: %Rrc", __LINE__, #rcExpr, rcCheck); \
f869309f635f9316b613a848e218b7661e3a54bdvboxsync return; \
f869309f635f9316b613a848e218b7661e3a54bdvboxsync } \
f869309f635f9316b613a848e218b7661e3a54bdvboxsync } while (0)
9c62bed1c091ef1a7a99cf9cf7831cb5c42c5604vboxsync
904ef975124106054684a976dfb30f70372372e1vboxsync
904ef975124106054684a976dfb30f70372372e1vboxsync
904ef975124106054684a976dfb30f70372372e1vboxsync
904ef975124106054684a976dfb30f70372372e1vboxsync/** @name Implicit Test Handle API Variation
904ef975124106054684a976dfb30f70372372e1vboxsync * The test handle is retrieved from the test TLS entry of the calling thread.
904ef975124106054684a976dfb30f70372372e1vboxsync * @{
904ef975124106054684a976dfb30f70372372e1vboxsync */
904ef975124106054684a976dfb30f70372372e1vboxsync
904ef975124106054684a976dfb30f70372372e1vboxsync/**
904ef975124106054684a976dfb30f70372372e1vboxsync * Test vprintf, makes sure lines are prefixed and so forth.
904ef975124106054684a976dfb30f70372372e1vboxsync *
904ef975124106054684a976dfb30f70372372e1vboxsync * @returns Number of chars printed.
904ef975124106054684a976dfb30f70372372e1vboxsync * @param enmLevel Message importance level.
904ef975124106054684a976dfb30f70372372e1vboxsync * @param pszFormat The message.
904ef975124106054684a976dfb30f70372372e1vboxsync * @param va Arguments.
904ef975124106054684a976dfb30f70372372e1vboxsync */
904ef975124106054684a976dfb30f70372372e1vboxsyncRTR3DECL(int) RTTestIPrintfV(RTTESTLVL enmLevel, const char *pszFormat, va_list va);
904ef975124106054684a976dfb30f70372372e1vboxsync
904ef975124106054684a976dfb30f70372372e1vboxsync/**
904ef975124106054684a976dfb30f70372372e1vboxsync * Test printf, makes sure lines are prefixed and so forth.
904ef975124106054684a976dfb30f70372372e1vboxsync *
904ef975124106054684a976dfb30f70372372e1vboxsync * @returns Number of chars printed.
904ef975124106054684a976dfb30f70372372e1vboxsync * @param enmLevel Message importance level.
904ef975124106054684a976dfb30f70372372e1vboxsync * @param pszFormat The message.
904ef975124106054684a976dfb30f70372372e1vboxsync * @param ... Arguments.
904ef975124106054684a976dfb30f70372372e1vboxsync */
904ef975124106054684a976dfb30f70372372e1vboxsyncRTR3DECL(int) RTTestIPrintf(RTTESTLVL enmLevel, const char *pszFormat, ...);
9474d83dcac691984017f8255821b95ec7642804vboxsync
d544fe535c163a24bf8cd831b39264da292b8adfvboxsync/**
d544fe535c163a24bf8cd831b39264da292b8adfvboxsync * Starts a sub-test.
d544fe535c163a24bf8cd831b39264da292b8adfvboxsync *
d544fe535c163a24bf8cd831b39264da292b8adfvboxsync * This will perform an implicit RTTestSubDone() call if that has not been done
d544fe535c163a24bf8cd831b39264da292b8adfvboxsync * since the last RTTestSub call.
d544fe535c163a24bf8cd831b39264da292b8adfvboxsync *
d544fe535c163a24bf8cd831b39264da292b8adfvboxsync * @returns Number of chars printed.
d544fe535c163a24bf8cd831b39264da292b8adfvboxsync * @param pszSubTest The sub-test name.
d544fe535c163a24bf8cd831b39264da292b8adfvboxsync */
d544fe535c163a24bf8cd831b39264da292b8adfvboxsyncRTR3DECL(int) RTTestISub(const char *pszSubTest);
d544fe535c163a24bf8cd831b39264da292b8adfvboxsync
d544fe535c163a24bf8cd831b39264da292b8adfvboxsync/**
d544fe535c163a24bf8cd831b39264da292b8adfvboxsync * Format string version of RTTestSub.
d544fe535c163a24bf8cd831b39264da292b8adfvboxsync *
d544fe535c163a24bf8cd831b39264da292b8adfvboxsync * See RTTestSub for details.
d544fe535c163a24bf8cd831b39264da292b8adfvboxsync *
d544fe535c163a24bf8cd831b39264da292b8adfvboxsync * @returns Number of chars printed.
d544fe535c163a24bf8cd831b39264da292b8adfvboxsync * @param pszSubTestFmt The sub-test name format string.
d544fe535c163a24bf8cd831b39264da292b8adfvboxsync * @param ... Arguments.
d544fe535c163a24bf8cd831b39264da292b8adfvboxsync */
d544fe535c163a24bf8cd831b39264da292b8adfvboxsyncRTR3DECL(int) RTTestISubF(const char *pszSubTestFmt, ...);
d544fe535c163a24bf8cd831b39264da292b8adfvboxsync
d544fe535c163a24bf8cd831b39264da292b8adfvboxsync/**
d544fe535c163a24bf8cd831b39264da292b8adfvboxsync * Format string version of RTTestSub.
d544fe535c163a24bf8cd831b39264da292b8adfvboxsync *
d544fe535c163a24bf8cd831b39264da292b8adfvboxsync * See RTTestSub for details.
d544fe535c163a24bf8cd831b39264da292b8adfvboxsync *
d544fe535c163a24bf8cd831b39264da292b8adfvboxsync * @returns Number of chars printed.
d544fe535c163a24bf8cd831b39264da292b8adfvboxsync * @param pszSubTestFmt The sub-test name format string.
88acfa6629a7976c0583c1712d2b5b22a87a5121vboxsync * @param va Arguments.
d544fe535c163a24bf8cd831b39264da292b8adfvboxsync */
d544fe535c163a24bf8cd831b39264da292b8adfvboxsyncRTR3DECL(int) RTTestISubV(const char *pszSubTestFmt, va_list va);
d544fe535c163a24bf8cd831b39264da292b8adfvboxsync
d544fe535c163a24bf8cd831b39264da292b8adfvboxsync/**
d544fe535c163a24bf8cd831b39264da292b8adfvboxsync * Completes a sub-test.
d544fe535c163a24bf8cd831b39264da292b8adfvboxsync *
d544fe535c163a24bf8cd831b39264da292b8adfvboxsync * @returns Number of chars printed.
d544fe535c163a24bf8cd831b39264da292b8adfvboxsync */
d544fe535c163a24bf8cd831b39264da292b8adfvboxsyncRTR3DECL(int) RTTestISubDone(void);
d544fe535c163a24bf8cd831b39264da292b8adfvboxsync
9474d83dcac691984017f8255821b95ec7642804vboxsync/**
9474d83dcac691984017f8255821b95ec7642804vboxsync * Prints an extended PASSED message, optional.
9474d83dcac691984017f8255821b95ec7642804vboxsync *
9474d83dcac691984017f8255821b95ec7642804vboxsync * This does not conclude the sub-test, it could be used to report the passing
9474d83dcac691984017f8255821b95ec7642804vboxsync * of a sub-sub-to-the-power-of-N-test.
9474d83dcac691984017f8255821b95ec7642804vboxsync *
9474d83dcac691984017f8255821b95ec7642804vboxsync * @returns IPRT status code.
9474d83dcac691984017f8255821b95ec7642804vboxsync * @param pszFormat The message. No trailing newline.
9474d83dcac691984017f8255821b95ec7642804vboxsync * @param va The arguments.
9474d83dcac691984017f8255821b95ec7642804vboxsync */
904ef975124106054684a976dfb30f70372372e1vboxsyncRTR3DECL(int) RTTestIPassedV(const char *pszFormat, va_list va);
9474d83dcac691984017f8255821b95ec7642804vboxsync
9474d83dcac691984017f8255821b95ec7642804vboxsync/**
9474d83dcac691984017f8255821b95ec7642804vboxsync * Prints an extended PASSED message, optional.
9474d83dcac691984017f8255821b95ec7642804vboxsync *
9474d83dcac691984017f8255821b95ec7642804vboxsync * This does not conclude the sub-test, it could be used to report the passing
9474d83dcac691984017f8255821b95ec7642804vboxsync * of a sub-sub-to-the-power-of-N-test.
9474d83dcac691984017f8255821b95ec7642804vboxsync *
9474d83dcac691984017f8255821b95ec7642804vboxsync * @returns IPRT status code.
9474d83dcac691984017f8255821b95ec7642804vboxsync * @param pszFormat The message. No trailing newline.
9474d83dcac691984017f8255821b95ec7642804vboxsync * @param ... The arguments.
9474d83dcac691984017f8255821b95ec7642804vboxsync */
904ef975124106054684a976dfb30f70372372e1vboxsyncRTR3DECL(int) RTTestIPassed(const char *pszFormat, ...);
904ef975124106054684a976dfb30f70372372e1vboxsync
904ef975124106054684a976dfb30f70372372e1vboxsync/**
904ef975124106054684a976dfb30f70372372e1vboxsync * Increments the error counter.
904ef975124106054684a976dfb30f70372372e1vboxsync *
904ef975124106054684a976dfb30f70372372e1vboxsync * @returns IPRT status code.
904ef975124106054684a976dfb30f70372372e1vboxsync */
904ef975124106054684a976dfb30f70372372e1vboxsyncRTR3DECL(int) RTTestIErrorInc(void);
904ef975124106054684a976dfb30f70372372e1vboxsync
4fb518cb2eadd86a2bf117501cd38b05dde47745vboxsync/**
4fb518cb2eadd86a2bf117501cd38b05dde47745vboxsync * Get the current error count.
4fb518cb2eadd86a2bf117501cd38b05dde47745vboxsync *
4fb518cb2eadd86a2bf117501cd38b05dde47745vboxsync * @returns The error counter, UINT32_MAX if no valid test handle.
4fb518cb2eadd86a2bf117501cd38b05dde47745vboxsync */
4fb518cb2eadd86a2bf117501cd38b05dde47745vboxsyncRTR3DECL(uint32_t) RTTestIErrorCount(void);
4fb518cb2eadd86a2bf117501cd38b05dde47745vboxsync
904ef975124106054684a976dfb30f70372372e1vboxsync/**
904ef975124106054684a976dfb30f70372372e1vboxsync * Increments the error counter and prints a failure message.
904ef975124106054684a976dfb30f70372372e1vboxsync *
904ef975124106054684a976dfb30f70372372e1vboxsync * @returns IPRT status code.
904ef975124106054684a976dfb30f70372372e1vboxsync * @param pszFormat The message. No trailing newline.
904ef975124106054684a976dfb30f70372372e1vboxsync * @param va The arguments.
904ef975124106054684a976dfb30f70372372e1vboxsync */
904ef975124106054684a976dfb30f70372372e1vboxsyncRTR3DECL(int) RTTestIFailedV(const char *pszFormat, va_list va);
904ef975124106054684a976dfb30f70372372e1vboxsync
904ef975124106054684a976dfb30f70372372e1vboxsync/**
904ef975124106054684a976dfb30f70372372e1vboxsync * Increments the error counter and prints a failure message.
904ef975124106054684a976dfb30f70372372e1vboxsync *
904ef975124106054684a976dfb30f70372372e1vboxsync * @returns IPRT status code.
904ef975124106054684a976dfb30f70372372e1vboxsync * @param pszFormat The message. No trailing newline.
904ef975124106054684a976dfb30f70372372e1vboxsync * @param ... The arguments.
904ef975124106054684a976dfb30f70372372e1vboxsync */
904ef975124106054684a976dfb30f70372372e1vboxsyncRTR3DECL(int) RTTestIFailed(const char *pszFormat, ...);
904ef975124106054684a976dfb30f70372372e1vboxsync
904ef975124106054684a976dfb30f70372372e1vboxsync/**
904ef975124106054684a976dfb30f70372372e1vboxsync * Same as RTTestIPrintfV with RTTESTLVL_FAILURE.
904ef975124106054684a976dfb30f70372372e1vboxsync *
904ef975124106054684a976dfb30f70372372e1vboxsync * @returns Number of chars printed.
904ef975124106054684a976dfb30f70372372e1vboxsync * @param pszFormat The message.
904ef975124106054684a976dfb30f70372372e1vboxsync * @param va Arguments.
904ef975124106054684a976dfb30f70372372e1vboxsync */
904ef975124106054684a976dfb30f70372372e1vboxsyncRTR3DECL(int) RTTestIFailureDetailsV(const char *pszFormat, va_list va);
904ef975124106054684a976dfb30f70372372e1vboxsync
904ef975124106054684a976dfb30f70372372e1vboxsync/**
904ef975124106054684a976dfb30f70372372e1vboxsync * Same as RTTestIPrintf with RTTESTLVL_FAILURE.
904ef975124106054684a976dfb30f70372372e1vboxsync *
904ef975124106054684a976dfb30f70372372e1vboxsync * @returns Number of chars printed.
904ef975124106054684a976dfb30f70372372e1vboxsync * @param pszFormat The message.
904ef975124106054684a976dfb30f70372372e1vboxsync * @param ... Arguments.
904ef975124106054684a976dfb30f70372372e1vboxsync */
904ef975124106054684a976dfb30f70372372e1vboxsyncRTR3DECL(int) RTTestIFailureDetails(const char *pszFormat, ...);
904ef975124106054684a976dfb30f70372372e1vboxsync
904ef975124106054684a976dfb30f70372372e1vboxsync
904ef975124106054684a976dfb30f70372372e1vboxsync/** @def RTTESTI_CHECK
904ef975124106054684a976dfb30f70372372e1vboxsync * Check whether a boolean expression holds true.
904ef975124106054684a976dfb30f70372372e1vboxsync *
904ef975124106054684a976dfb30f70372372e1vboxsync * If the expression is false, call RTTestIFailed giving the line number and
904ef975124106054684a976dfb30f70372372e1vboxsync * expression.
904ef975124106054684a976dfb30f70372372e1vboxsync *
904ef975124106054684a976dfb30f70372372e1vboxsync * @param expr The expression to evaluate.
904ef975124106054684a976dfb30f70372372e1vboxsync */
904ef975124106054684a976dfb30f70372372e1vboxsync#define RTTESTI_CHECK(expr) \
904ef975124106054684a976dfb30f70372372e1vboxsync do { if (!(expr)) { \
904ef975124106054684a976dfb30f70372372e1vboxsync RTTestIFailed("line %u: %s", __LINE__, #expr); \
904ef975124106054684a976dfb30f70372372e1vboxsync } \
904ef975124106054684a976dfb30f70372372e1vboxsync } while (0)
f869309f635f9316b613a848e218b7661e3a54bdvboxsync/** @def RTTESTI_CHECK_RET
f869309f635f9316b613a848e218b7661e3a54bdvboxsync * Check whether a boolean expression holds true, returns on false.
904ef975124106054684a976dfb30f70372372e1vboxsync *
904ef975124106054684a976dfb30f70372372e1vboxsync * If the expression is false, call RTTestIFailed giving the line number and
904ef975124106054684a976dfb30f70372372e1vboxsync * expression.
904ef975124106054684a976dfb30f70372372e1vboxsync *
f869309f635f9316b613a848e218b7661e3a54bdvboxsync * @param expr The expression to evaluate.
f869309f635f9316b613a848e218b7661e3a54bdvboxsync * @param rcRet What to return on failure.
904ef975124106054684a976dfb30f70372372e1vboxsync */
f869309f635f9316b613a848e218b7661e3a54bdvboxsync#define RTTESTI_CHECK_RET(expr, rcRet) \
904ef975124106054684a976dfb30f70372372e1vboxsync do { if (!(expr)) { \
904ef975124106054684a976dfb30f70372372e1vboxsync RTTestIFailed("line %u: %s", __LINE__, #expr); \
f869309f635f9316b613a848e218b7661e3a54bdvboxsync return (rcRet); \
904ef975124106054684a976dfb30f70372372e1vboxsync } \
904ef975124106054684a976dfb30f70372372e1vboxsync } while (0)
f869309f635f9316b613a848e218b7661e3a54bdvboxsync/** @def RTTESTI_CHECK_RETV
f869309f635f9316b613a848e218b7661e3a54bdvboxsync * Check whether a boolean expression holds true, returns void on false.
904ef975124106054684a976dfb30f70372372e1vboxsync *
904ef975124106054684a976dfb30f70372372e1vboxsync * If the expression is false, call RTTestIFailed giving the line number and
904ef975124106054684a976dfb30f70372372e1vboxsync * expression.
904ef975124106054684a976dfb30f70372372e1vboxsync *
904ef975124106054684a976dfb30f70372372e1vboxsync * @param expr The expression to evaluate.
904ef975124106054684a976dfb30f70372372e1vboxsync */
f869309f635f9316b613a848e218b7661e3a54bdvboxsync#define RTTESTI_CHECK_RETV(expr) \
904ef975124106054684a976dfb30f70372372e1vboxsync do { if (!(expr)) { \
904ef975124106054684a976dfb30f70372372e1vboxsync RTTestIFailed("line %u: %s", __LINE__, #expr); \
f869309f635f9316b613a848e218b7661e3a54bdvboxsync return; \
904ef975124106054684a976dfb30f70372372e1vboxsync } \
904ef975124106054684a976dfb30f70372372e1vboxsync } while (0)
904ef975124106054684a976dfb30f70372372e1vboxsync
f869309f635f9316b613a848e218b7661e3a54bdvboxsync
f869309f635f9316b613a848e218b7661e3a54bdvboxsync/** @def RTTESTI_CHECK_MSG
f869309f635f9316b613a848e218b7661e3a54bdvboxsync * Check whether a boolean expression holds true.
904ef975124106054684a976dfb30f70372372e1vboxsync *
904ef975124106054684a976dfb30f70372372e1vboxsync * If the expression is false, call RTTestIFailed giving the line number and
904ef975124106054684a976dfb30f70372372e1vboxsync * expression.
904ef975124106054684a976dfb30f70372372e1vboxsync *
904ef975124106054684a976dfb30f70372372e1vboxsync * @param expr The expression to evaluate.
904ef975124106054684a976dfb30f70372372e1vboxsync * @param DetailsArgs Argument list for RTTestIFailureDetails, including
904ef975124106054684a976dfb30f70372372e1vboxsync * parenthesis.
904ef975124106054684a976dfb30f70372372e1vboxsync */
f869309f635f9316b613a848e218b7661e3a54bdvboxsync#define RTTESTI_CHECK_MSG(expr, DetailsArgs) \
904ef975124106054684a976dfb30f70372372e1vboxsync do { if (!(expr)) { \
904ef975124106054684a976dfb30f70372372e1vboxsync RTTestIFailed("line %u: %s", __LINE__, #expr); \
904ef975124106054684a976dfb30f70372372e1vboxsync RTTestIFailureDetails DetailsArgs; \
904ef975124106054684a976dfb30f70372372e1vboxsync } \
904ef975124106054684a976dfb30f70372372e1vboxsync } while (0)
f869309f635f9316b613a848e218b7661e3a54bdvboxsync/** @def RTTESTI_CHECK_MSG_RET
f869309f635f9316b613a848e218b7661e3a54bdvboxsync * Check whether a boolean expression holds true, returns on false.
904ef975124106054684a976dfb30f70372372e1vboxsync *
904ef975124106054684a976dfb30f70372372e1vboxsync * If the expression is false, call RTTestIFailed giving the line number and
904ef975124106054684a976dfb30f70372372e1vboxsync * expression.
904ef975124106054684a976dfb30f70372372e1vboxsync *
f869309f635f9316b613a848e218b7661e3a54bdvboxsync * @param expr The expression to evaluate.
f869309f635f9316b613a848e218b7661e3a54bdvboxsync * @param DetailsArgs Argument list for RTTestIFailureDetails, including
f869309f635f9316b613a848e218b7661e3a54bdvboxsync * parenthesis.
f869309f635f9316b613a848e218b7661e3a54bdvboxsync * @param rcRet What to return on failure.
904ef975124106054684a976dfb30f70372372e1vboxsync */
f869309f635f9316b613a848e218b7661e3a54bdvboxsync#define RTTESTI_CHECK_MSG_RET(expr, DetailsArgs, rcRet) \
904ef975124106054684a976dfb30f70372372e1vboxsync do { if (!(expr)) { \
904ef975124106054684a976dfb30f70372372e1vboxsync RTTestIFailed("line %u: %s", __LINE__, #expr); \
f869309f635f9316b613a848e218b7661e3a54bdvboxsync RTTestIFailureDetails DetailsArgs; \
f869309f635f9316b613a848e218b7661e3a54bdvboxsync return (rcRet); \
904ef975124106054684a976dfb30f70372372e1vboxsync } \
904ef975124106054684a976dfb30f70372372e1vboxsync } while (0)
904ef975124106054684a976dfb30f70372372e1vboxsync/** @def RTTESTI_CHECK_MSG_RET
904ef975124106054684a976dfb30f70372372e1vboxsync * Check whether a boolean expression holds true, returns void on false.
904ef975124106054684a976dfb30f70372372e1vboxsync *
904ef975124106054684a976dfb30f70372372e1vboxsync * If the expression is false, call RTTestIFailed giving the line number and
904ef975124106054684a976dfb30f70372372e1vboxsync * expression.
904ef975124106054684a976dfb30f70372372e1vboxsync *
904ef975124106054684a976dfb30f70372372e1vboxsync * @param expr The expression to evaluate.
904ef975124106054684a976dfb30f70372372e1vboxsync * @param DetailsArgs Argument list for RTTestIFailureDetails, including
904ef975124106054684a976dfb30f70372372e1vboxsync * parenthesis.
904ef975124106054684a976dfb30f70372372e1vboxsync */
904ef975124106054684a976dfb30f70372372e1vboxsync#define RTTESTI_CHECK_MSG_RETV(expr, DetailsArgs) \
904ef975124106054684a976dfb30f70372372e1vboxsync do { if (!(expr)) { \
904ef975124106054684a976dfb30f70372372e1vboxsync RTTestIFailed("line %u: %s", __LINE__, #expr); \
904ef975124106054684a976dfb30f70372372e1vboxsync RTTestIFailureDetails DetailsArgs; \
904ef975124106054684a976dfb30f70372372e1vboxsync return; \
904ef975124106054684a976dfb30f70372372e1vboxsync } \
904ef975124106054684a976dfb30f70372372e1vboxsync } while (0)
904ef975124106054684a976dfb30f70372372e1vboxsync
f869309f635f9316b613a848e218b7661e3a54bdvboxsync
9c62bed1c091ef1a7a99cf9cf7831cb5c42c5604vboxsync/** @def RTTESTI_CHECK_RC
9c62bed1c091ef1a7a99cf9cf7831cb5c42c5604vboxsync * Check whether an expression returns a specific IPRT style status code.
9c62bed1c091ef1a7a99cf9cf7831cb5c42c5604vboxsync *
9c62bed1c091ef1a7a99cf9cf7831cb5c42c5604vboxsync * If a different status code is return, call RTTestIFailed giving the line
9c62bed1c091ef1a7a99cf9cf7831cb5c42c5604vboxsync * number, expression, actual and expected status codes.
9c62bed1c091ef1a7a99cf9cf7831cb5c42c5604vboxsync *
e5a5dce1fd43042795bb84407afe6af5ae878662vboxsync * @param rcExpr The expression resulting in an IPRT status code.
9c62bed1c091ef1a7a99cf9cf7831cb5c42c5604vboxsync * @param rcExpect The expected return code. This may be referenced
9c62bed1c091ef1a7a99cf9cf7831cb5c42c5604vboxsync * more than once by the macro.
9c62bed1c091ef1a7a99cf9cf7831cb5c42c5604vboxsync */
9c62bed1c091ef1a7a99cf9cf7831cb5c42c5604vboxsync#define RTTESTI_CHECK_RC(rcExpr, rcExpect) \
9c62bed1c091ef1a7a99cf9cf7831cb5c42c5604vboxsync do { \
9c62bed1c091ef1a7a99cf9cf7831cb5c42c5604vboxsync int rcCheck = (rcExpr); \
9c62bed1c091ef1a7a99cf9cf7831cb5c42c5604vboxsync if (rcCheck != (rcExpect)) { \
9c62bed1c091ef1a7a99cf9cf7831cb5c42c5604vboxsync RTTestIFailed("line %u: %s: expected %Rrc, got %Rrc", __LINE__, #rcExpr, (rcExpect), rcCheck); \
9c62bed1c091ef1a7a99cf9cf7831cb5c42c5604vboxsync } \
9c62bed1c091ef1a7a99cf9cf7831cb5c42c5604vboxsync } while (0)
f869309f635f9316b613a848e218b7661e3a54bdvboxsync/** @def RTTESTI_CHECK_RC_RET
f869309f635f9316b613a848e218b7661e3a54bdvboxsync * Check whether an expression returns a specific IPRT style status code.
f869309f635f9316b613a848e218b7661e3a54bdvboxsync *
f869309f635f9316b613a848e218b7661e3a54bdvboxsync * If a different status code is return, call RTTestIFailed giving the line
f869309f635f9316b613a848e218b7661e3a54bdvboxsync * number, expression, actual and expected status codes, then return.
f869309f635f9316b613a848e218b7661e3a54bdvboxsync *
e5a5dce1fd43042795bb84407afe6af5ae878662vboxsync * @param rcExpr The expression resulting in an IPRT status code.
e5a5dce1fd43042795bb84407afe6af5ae878662vboxsync * This will be assigned to a local rcCheck variable
e5a5dce1fd43042795bb84407afe6af5ae878662vboxsync * that can be used as return value.
f869309f635f9316b613a848e218b7661e3a54bdvboxsync * @param rcExpect The expected return code. This may be referenced
f869309f635f9316b613a848e218b7661e3a54bdvboxsync * more than once by the macro.
f869309f635f9316b613a848e218b7661e3a54bdvboxsync * @param rcRet The return code.
f869309f635f9316b613a848e218b7661e3a54bdvboxsync */
f869309f635f9316b613a848e218b7661e3a54bdvboxsync#define RTTESTI_CHECK_RC_RET(rcExpr, rcExpect, rcRet) \
f869309f635f9316b613a848e218b7661e3a54bdvboxsync do { \
f869309f635f9316b613a848e218b7661e3a54bdvboxsync int rcCheck = (rcExpr); \
f869309f635f9316b613a848e218b7661e3a54bdvboxsync if (rcCheck != (rcExpect)) { \
f869309f635f9316b613a848e218b7661e3a54bdvboxsync RTTestIFailed("line %u: %s: expected %Rrc, got %Rrc", __LINE__, #rcExpr, (rcExpect), rcCheck); \
f869309f635f9316b613a848e218b7661e3a54bdvboxsync return (rcRet); \
f869309f635f9316b613a848e218b7661e3a54bdvboxsync } \
f869309f635f9316b613a848e218b7661e3a54bdvboxsync } while (0)
f869309f635f9316b613a848e218b7661e3a54bdvboxsync/** @def RTTESTI_CHECK_RC_RETV
f869309f635f9316b613a848e218b7661e3a54bdvboxsync * Check whether an expression returns a specific IPRT style status code.
f869309f635f9316b613a848e218b7661e3a54bdvboxsync *
f869309f635f9316b613a848e218b7661e3a54bdvboxsync * If a different status code is return, call RTTestIFailed giving the line
f869309f635f9316b613a848e218b7661e3a54bdvboxsync * number, expression, actual and expected status codes, then return.
f869309f635f9316b613a848e218b7661e3a54bdvboxsync *
e5a5dce1fd43042795bb84407afe6af5ae878662vboxsync * @param rcExpr The expression resulting in an IPRT status code.
f869309f635f9316b613a848e218b7661e3a54bdvboxsync * @param rcExpect The expected return code. This may be referenced
f869309f635f9316b613a848e218b7661e3a54bdvboxsync * more than once by the macro.
f869309f635f9316b613a848e218b7661e3a54bdvboxsync */
f869309f635f9316b613a848e218b7661e3a54bdvboxsync#define RTTESTI_CHECK_RC_RETV(rcExpr, rcExpect) \
f869309f635f9316b613a848e218b7661e3a54bdvboxsync do { \
f869309f635f9316b613a848e218b7661e3a54bdvboxsync int rcCheck = (rcExpr); \
f869309f635f9316b613a848e218b7661e3a54bdvboxsync if (rcCheck != (rcExpect)) { \
f869309f635f9316b613a848e218b7661e3a54bdvboxsync RTTestIFailed("line %u: %s: expected %Rrc, got %Rrc", __LINE__, #rcExpr, (rcExpect), rcCheck); \
f869309f635f9316b613a848e218b7661e3a54bdvboxsync return; \
f869309f635f9316b613a848e218b7661e3a54bdvboxsync } \
f869309f635f9316b613a848e218b7661e3a54bdvboxsync } while (0)
f869309f635f9316b613a848e218b7661e3a54bdvboxsync
9c62bed1c091ef1a7a99cf9cf7831cb5c42c5604vboxsync
9c62bed1c091ef1a7a99cf9cf7831cb5c42c5604vboxsync/** @def RTTESTI_CHECK_RC_OK
9c62bed1c091ef1a7a99cf9cf7831cb5c42c5604vboxsync * Check whether a IPRT style status code indicates success.
9c62bed1c091ef1a7a99cf9cf7831cb5c42c5604vboxsync *
9c62bed1c091ef1a7a99cf9cf7831cb5c42c5604vboxsync * If the status indicates failure, call RTTestIFailed giving the line number,
9c62bed1c091ef1a7a99cf9cf7831cb5c42c5604vboxsync * expression and status code.
9c62bed1c091ef1a7a99cf9cf7831cb5c42c5604vboxsync *
e5a5dce1fd43042795bb84407afe6af5ae878662vboxsync * @param rcExpr The expression resulting in an IPRT status code.
9c62bed1c091ef1a7a99cf9cf7831cb5c42c5604vboxsync */
9c62bed1c091ef1a7a99cf9cf7831cb5c42c5604vboxsync#define RTTESTI_CHECK_RC_OK(rcExpr) \
9c62bed1c091ef1a7a99cf9cf7831cb5c42c5604vboxsync do { \
9c62bed1c091ef1a7a99cf9cf7831cb5c42c5604vboxsync int rcCheck = (rcExpr); \
9c62bed1c091ef1a7a99cf9cf7831cb5c42c5604vboxsync if (RT_FAILURE(rcCheck)) { \
9c62bed1c091ef1a7a99cf9cf7831cb5c42c5604vboxsync RTTestIFailed("line %u: %s: %Rrc", __LINE__, #rcExpr, rcCheck); \
9c62bed1c091ef1a7a99cf9cf7831cb5c42c5604vboxsync } \
9c62bed1c091ef1a7a99cf9cf7831cb5c42c5604vboxsync } while (0)
f869309f635f9316b613a848e218b7661e3a54bdvboxsync/** @def RTTESTI_CHECK_RC_OK_RET
f869309f635f9316b613a848e218b7661e3a54bdvboxsync * Check whether a IPRT style status code indicates success.
f869309f635f9316b613a848e218b7661e3a54bdvboxsync *
f869309f635f9316b613a848e218b7661e3a54bdvboxsync * If the status indicates failure, call RTTestIFailed giving the line number,
f869309f635f9316b613a848e218b7661e3a54bdvboxsync * expression and status code, then return with the specified value.
f869309f635f9316b613a848e218b7661e3a54bdvboxsync *
e5a5dce1fd43042795bb84407afe6af5ae878662vboxsync * @param rcExpr The expression resulting in an IPRT status code.
e5a5dce1fd43042795bb84407afe6af5ae878662vboxsync * This will be assigned to a local rcCheck variable
e5a5dce1fd43042795bb84407afe6af5ae878662vboxsync * that can be used as return value.
f869309f635f9316b613a848e218b7661e3a54bdvboxsync * @param rcRet The return code.
f869309f635f9316b613a848e218b7661e3a54bdvboxsync */
f869309f635f9316b613a848e218b7661e3a54bdvboxsync#define RTTESTI_CHECK_RC_OK_RET(rcExpr, rcRet) \
f869309f635f9316b613a848e218b7661e3a54bdvboxsync do { \
f869309f635f9316b613a848e218b7661e3a54bdvboxsync int rcCheck = (rcExpr); \
f869309f635f9316b613a848e218b7661e3a54bdvboxsync if (RT_FAILURE(rcCheck)) { \
f869309f635f9316b613a848e218b7661e3a54bdvboxsync RTTestIFailed("line %u: %s: %Rrc", __LINE__, #rcExpr, rcCheck); \
f869309f635f9316b613a848e218b7661e3a54bdvboxsync return (rcRet); \
f869309f635f9316b613a848e218b7661e3a54bdvboxsync } \
f869309f635f9316b613a848e218b7661e3a54bdvboxsync } while (0)
f869309f635f9316b613a848e218b7661e3a54bdvboxsync/** @def RTTESTI_CHECK_RC_OK_RETV
f869309f635f9316b613a848e218b7661e3a54bdvboxsync * Check whether a IPRT style status code indicates success.
f869309f635f9316b613a848e218b7661e3a54bdvboxsync *
f869309f635f9316b613a848e218b7661e3a54bdvboxsync * If the status indicates failure, call RTTestIFailed giving the line number,
f869309f635f9316b613a848e218b7661e3a54bdvboxsync * expression and status code, then return.
f869309f635f9316b613a848e218b7661e3a54bdvboxsync *
e5a5dce1fd43042795bb84407afe6af5ae878662vboxsync * @param rcExpr The expression resulting in an IPRT status code.
f869309f635f9316b613a848e218b7661e3a54bdvboxsync */
f869309f635f9316b613a848e218b7661e3a54bdvboxsync#define RTTESTI_CHECK_RC_OK_RETV(rcExpr) \
f869309f635f9316b613a848e218b7661e3a54bdvboxsync do { \
f869309f635f9316b613a848e218b7661e3a54bdvboxsync int rcCheck = (rcExpr); \
f869309f635f9316b613a848e218b7661e3a54bdvboxsync if (RT_FAILURE(rcCheck)) { \
f869309f635f9316b613a848e218b7661e3a54bdvboxsync RTTestIFailed("line %u: %s: %Rrc", __LINE__, #rcExpr, rcCheck); \
f869309f635f9316b613a848e218b7661e3a54bdvboxsync return; \
f869309f635f9316b613a848e218b7661e3a54bdvboxsync } \
f869309f635f9316b613a848e218b7661e3a54bdvboxsync } while (0)
904ef975124106054684a976dfb30f70372372e1vboxsync
904ef975124106054684a976dfb30f70372372e1vboxsync/** @} */
9474d83dcac691984017f8255821b95ec7642804vboxsync
b736c553dbde2c3b2533c93c57d9b7f07714371cvboxsync
b736c553dbde2c3b2533c93c57d9b7f07714371cvboxsync/** @} */
b736c553dbde2c3b2533c93c57d9b7f07714371cvboxsync
590bfe12ce22cd3716448fbb9f4dc51664bfe5e2vboxsyncRT_C_DECLS_END
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync#endif
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync