9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync/** @file
b736c553dbde2c3b2533c93c57d9b7f07714371cvboxsync * IPRT - Testcase Framework.
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync */
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync
9cabb72c6d6feb65e839ce50765643b98bb9a301vboxsync/*
c7814cf6e1240a519cbec0441e033d0e2470ed00vboxsync * Copyright (C) 2009-2013 Oracle Corporation
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
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>
e8f169c27c5303b27b62741c66ed248e14771f9dvboxsync#include <iprt/assert.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. */
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsynctypedef R3PTRTYPE(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
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync/** @name RTTEST_C_XXX - Flags for RTTestCreateEx.
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync * @{ */
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync/** Whether to check the IPRT_TEST_XXX variables when constructing the
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync * instance. The following environment variables get checks:
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync *
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync * - IPRT_TEST_MAX_LEVEL: String value indicating which level.
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync * The env. var. is applied if the program specified the default level
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync * (by passing RTTESTLVL_INVALID).
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync *
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync * - IPRT_TEST_PIPE: The native pipe/fifo handle to write XML
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync * results to.
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync * The env. var. is applied if iNativeTestPipe is -1.
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync *
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync * - IPRT_TEST_FILE: Path to file/named-pipe/fifo/whatever to
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync * write XML results to.
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync * The env. var. is applied if the program specified a NULL path, it is
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync * not applied if the program hands us an empty string.
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync *
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync * - IPRT_TEST_OMIT_TOP_TEST: If present, this makes the XML output omit
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync * the top level test element.
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync * The env. var is applied when present.
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync *
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync */
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync#define RTTEST_C_USE_ENV RT_BIT(0)
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync/** Whether to omit the top test in the XML. */
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync#define RTTEST_C_XML_OMIT_TOP_TEST RT_BIT(1)
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync/** Whether to delay the top test XML element until testing commences. */
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync#define RTTEST_C_XML_DELAY_TOP_TEST RT_BIT(2)
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync/** Whether to try install the test instance in the test TLS slot. Setting
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync * this flag is incompatible with using the RTTestIXxxx variant of the API. */
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync#define RTTEST_C_NO_TLS RT_BIT(3)
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync/** Mask containing the valid bits. */
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync#define RTTEST_C_VALID_MASK UINT32_C(0x0000000f)
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync/** @} */
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync/**
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync * Creates a test instance.
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync *
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync * @returns IPRT status code.
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync * @param pszTest The test name.
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync * @param pszXmlFile The XML output file/pipe/whatever.
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync * @param fFlags Flags, see RTTEST_C_XXX.
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync * @param enmMaxLevel The max message level. Use RTTESTLVL_INVALID for
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync * the default output level or one from the
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync * environment. If specified, the environment variable
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync * will not be able to override it.
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync * @param iNativeTestPipe Native handle to a test pipe. -1 if not interested.
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync * @param pszXmlFile The XML output file name. If NULL the environment
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync * may be used. To selectively avoid that, pass an
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync * empty string.
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync * @param phTest Where to store the test instance handle.
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync *
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync * @note At the moment, we don't fail if @a pszXmlFile or @a iNativeTestPipe
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync * fails to open. This may change later.
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync */
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsyncRTR3DECL(int) RTTestCreateEx(const char *pszTest, uint32_t fFlags, RTTESTLVL enmMaxLevel,
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync RTHCINTPTR iNativeTestPipe, const char *pszXmlFile, PRTTEST phTest);
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync
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
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync/**
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync * Variant of RTTestInitAndCreate that includes IPRT init flags and argument
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync * vectors.
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync *
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync * @returns RTEXITCODE_SUCCESS on success. On failure an error message is
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync * printed and a suitable exit code is return.
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync *
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync * @param cArgs Pointer to the argument count.
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync * @param ppapszArgs Pointer to the argument vector pointer.
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync * @param fRtInit Flags, see RTR3INIT_XXX.
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync * @param pszTest The test name.
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync * @param phTest Where to store the test instance handle.
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync */
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsyncRTR3DECL(RTEXITCODE) RTTestInitExAndCreate(int cArgs, char ***papszArgs, uint32_t fRtInit, const char *pszTest, PRTTEST phTest);
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync
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
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync/**
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync * Changes the test case name.
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync *
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync * @returns IRPT status code.
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync * @param hTest The test handle. If NIL_RTTEST we'll use the one
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync * associated with the calling thread.
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync * @param pszName The new test case name. Empty string is not accepted,
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync * nor are strings longer than 127 chars. Keep it short
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync * but descriptive.
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync */
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsyncRTR3DECL(int) RTTestChangeName(RTTEST hTest, const char *pszName);
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync
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 *
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync * @returns Number of chars printed, negative numbers are IPRT error codes.
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 *
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync * @returns Number of chars printed, negative numbers are IPRT error codes.
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 *
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync * @returns Number of chars printed, negative numbers are IPRT error codes.
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
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync/**
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync * Marks the current test as 'SKIPPED' and optionally displays a message
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync * explaining why.
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync *
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync * @returns Number of chars printed, negative numbers are IPRT error codes.
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync * @param hTest The test handle. If NIL_RTTEST we'll use the one
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync * associated with the calling thread.
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync * @param pszFormat The message. No trailing newline. Can be NULL or empty.
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync * @param ... The arguments.
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync */
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsyncRTR3DECL(int) RTTestSkipped(RTTEST hTest, const char *pszFormat, ...);
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync/**
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync * Marks the current test as 'SKIPPED' and optionally displays a message
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync * explaining why.
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync *
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync * @returns Number of chars printed, negative numbers are IPRT error codes.
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync * @param hTest The test handle. If NIL_RTTEST we'll use the one
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync * associated with the calling thread.
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync * @param pszFormat The message. No trailing newline. Can be NULL or empty.
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync * @param va The arguments.
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync */
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsyncRTR3DECL(int) RTTestSkippedV(RTTEST hTest, const char *pszFormat, va_list va);
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync/**
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync * Value units.
e8f169c27c5303b27b62741c66ed248e14771f9dvboxsync *
e8f169c27c5303b27b62741c66ed248e14771f9dvboxsync * @remarks This is an interface where we have to be binary compatible with both
e8f169c27c5303b27b62741c66ed248e14771f9dvboxsync * older versions of this header and other components using the same
e8f169c27c5303b27b62741c66ed248e14771f9dvboxsync * contant values.
e8f169c27c5303b27b62741c66ed248e14771f9dvboxsync * @remarks When adding a new item:
e8f169c27c5303b27b62741c66ed248e14771f9dvboxsync * - Always add at the end of the list - do NOT group it.
e8f169c27c5303b27b62741c66ed248e14771f9dvboxsync * - Add it to rtTestUnitName in r3/test.cpp.
e8f169c27c5303b27b62741c66ed248e14771f9dvboxsync * - include/VBox/VMMDevTesting.h (VMMDEV_TESTING_UNIT_XXX).
e8f169c27c5303b27b62741c66ed248e14771f9dvboxsync * - Add it to g_aszBs2TestUnitNames in
e8f169c27c5303b27b62741c66ed248e14771f9dvboxsync * TestSuite/bootsectors/bootsector2-common-routines.mac.
e8f169c27c5303b27b62741c66ed248e14771f9dvboxsync *
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync */
97566036db1dc1dba46ed21be4e147c728fd1027vboxsynctypedef enum RTTESTUNIT
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync{
e8f169c27c5303b27b62741c66ed248e14771f9dvboxsync /** The customary invalid zero value. */
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync RTTESTUNIT_INVALID = 0,
e8f169c27c5303b27b62741c66ed248e14771f9dvboxsync
e8f169c27c5303b27b62741c66ed248e14771f9dvboxsync RTTESTUNIT_PCT, /**< Percentage (10^-2). */
e8f169c27c5303b27b62741c66ed248e14771f9dvboxsync RTTESTUNIT_BYTES, /**< Bytes. */
e8f169c27c5303b27b62741c66ed248e14771f9dvboxsync RTTESTUNIT_BYTES_PER_SEC, /**< Bytes per second. */
e8f169c27c5303b27b62741c66ed248e14771f9dvboxsync RTTESTUNIT_KILOBYTES, /**< Kilobytes. */
e8f169c27c5303b27b62741c66ed248e14771f9dvboxsync RTTESTUNIT_KILOBYTES_PER_SEC, /**< Kilobytes per second. */
e8f169c27c5303b27b62741c66ed248e14771f9dvboxsync RTTESTUNIT_MEGABYTES, /**< Megabytes. */
e8f169c27c5303b27b62741c66ed248e14771f9dvboxsync RTTESTUNIT_MEGABYTES_PER_SEC, /**< Megabytes per second. */
e8f169c27c5303b27b62741c66ed248e14771f9dvboxsync RTTESTUNIT_PACKETS, /**< Packets. */
e8f169c27c5303b27b62741c66ed248e14771f9dvboxsync RTTESTUNIT_PACKETS_PER_SEC, /**< Packets per second. */
e8f169c27c5303b27b62741c66ed248e14771f9dvboxsync RTTESTUNIT_FRAMES, /**< Frames. */
e8f169c27c5303b27b62741c66ed248e14771f9dvboxsync RTTESTUNIT_FRAMES_PER_SEC, /**< Frames per second. */
e8f169c27c5303b27b62741c66ed248e14771f9dvboxsync RTTESTUNIT_OCCURRENCES, /**< Occurrences. */
e8f169c27c5303b27b62741c66ed248e14771f9dvboxsync RTTESTUNIT_OCCURRENCES_PER_SEC, /**< Occurrences per second. */
e8f169c27c5303b27b62741c66ed248e14771f9dvboxsync RTTESTUNIT_CALLS, /**< Calls. */
e8f169c27c5303b27b62741c66ed248e14771f9dvboxsync RTTESTUNIT_CALLS_PER_SEC, /**< Calls per second. */
e8f169c27c5303b27b62741c66ed248e14771f9dvboxsync RTTESTUNIT_ROUND_TRIP, /**< Round trips. */
e8f169c27c5303b27b62741c66ed248e14771f9dvboxsync RTTESTUNIT_SECS, /**< Seconds. */
e8f169c27c5303b27b62741c66ed248e14771f9dvboxsync RTTESTUNIT_MS, /**< Milliseconds. */
e8f169c27c5303b27b62741c66ed248e14771f9dvboxsync RTTESTUNIT_NS, /**< Nanoseconds. */
e8f169c27c5303b27b62741c66ed248e14771f9dvboxsync RTTESTUNIT_NS_PER_CALL, /**< Nanoseconds per call. */
e8f169c27c5303b27b62741c66ed248e14771f9dvboxsync RTTESTUNIT_NS_PER_FRAME, /**< Nanoseconds per frame. */
e8f169c27c5303b27b62741c66ed248e14771f9dvboxsync RTTESTUNIT_NS_PER_OCCURRENCE, /**< Nanoseconds per occurrence. */
e8f169c27c5303b27b62741c66ed248e14771f9dvboxsync RTTESTUNIT_NS_PER_PACKET, /**< Nanoseconds per frame. */
e8f169c27c5303b27b62741c66ed248e14771f9dvboxsync RTTESTUNIT_NS_PER_ROUND_TRIP, /**< Nanoseconds per round trip. */
e8f169c27c5303b27b62741c66ed248e14771f9dvboxsync RTTESTUNIT_INSTRS, /**< Instructions. */
e8f169c27c5303b27b62741c66ed248e14771f9dvboxsync RTTESTUNIT_INSTRS_PER_SEC, /**< Instructions per second. */
e8f169c27c5303b27b62741c66ed248e14771f9dvboxsync RTTESTUNIT_NONE, /**< No unit. */
e8f169c27c5303b27b62741c66ed248e14771f9dvboxsync RTTESTUNIT_PP1K, /**< Parts per thousand (10^-3). */
e8f169c27c5303b27b62741c66ed248e14771f9dvboxsync RTTESTUNIT_PP10K, /**< Parts per ten thousand (10^-4). */
e8f169c27c5303b27b62741c66ed248e14771f9dvboxsync RTTESTUNIT_PPM, /**< Parts per million (10^-6). */
e8f169c27c5303b27b62741c66ed248e14771f9dvboxsync RTTESTUNIT_PPB, /**< Parts per billion (10^-9). */
e8f169c27c5303b27b62741c66ed248e14771f9dvboxsync
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync /** The end of valid units. */
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync RTTESTUNIT_END
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync} RTTESTUNIT;
e8f169c27c5303b27b62741c66ed248e14771f9dvboxsyncAssertCompile(RTTESTUNIT_INSTRS == 0x19);
e8f169c27c5303b27b62741c66ed248e14771f9dvboxsyncAssertCompile(RTTESTUNIT_NONE == 0x1b);
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync/**
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync * Report a named test result value.
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync *
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync * This is typically used for benchmarking but can be used for other purposes
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync * like reporting limits of some implementation. The value gets associated with
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync * the current sub test, the name must be unique within the sub test.
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync *
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync * @returns IPRT status code.
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync *
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync * @param hTest The test handle. If NIL_RTTEST we'll use the one
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync * associated with the calling thread.
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync * @param pszName The value name.
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync * @param u64Value The value.
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync * @param enmUnit The value unit.
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync */
97566036db1dc1dba46ed21be4e147c728fd1027vboxsyncRTR3DECL(int) RTTestValue(RTTEST hTest, const char *pszName, uint64_t u64Value, RTTESTUNIT enmUnit);
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync/**
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync * Same as RTTestValue, except that the name is now a format string.
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync *
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync * @returns IPRT status code.
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync *
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync * @param hTest The test handle. If NIL_RTTEST we'll use the one
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync * associated with the calling thread.
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync * @param u64Value The value.
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync * @param enmUnit The value unit.
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync * @param pszNameFmt The value name format string.
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync * @param ... String arguments.
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync */
97566036db1dc1dba46ed21be4e147c728fd1027vboxsyncRTR3DECL(int) RTTestValueF(RTTEST hTest, uint64_t u64Value, RTTESTUNIT enmUnit, const char *pszNameFmt, ...);
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync/**
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync * Same as RTTestValue, except that the name is now a format string.
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync *
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync * @returns IPRT status code.
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync *
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync * @param hTest The test handle. If NIL_RTTEST we'll use the one
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync * associated with the calling thread.
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync * @param u64Value The value.
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync * @param enmUnit The value unit.
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync * @param pszNameFmt The value name format string.
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync * @param va_list String arguments.
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync */
97566036db1dc1dba46ed21be4e147c728fd1027vboxsyncRTR3DECL(int) RTTestValueV(RTTEST hTest, uint64_t u64Value, RTTESTUNIT enmUnit, const char *pszNameFmt, va_list va);
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
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync/**
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync * Get the error count of the current sub test.
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync *
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync * @returns The error counter, UINT32_MAX if no valid test handle.
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync * @param hTest The test handle. If NIL_RTTEST we'll use the one
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync * associated with the calling thread.
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync */
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsyncRTR3DECL(uint32_t) RTTestSubErrorCount(RTTEST hTest);
b379286f0d2c8d82f5a575eb907c7476aa6ae84bvboxsync
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 *
218bcb38b2c98c6237bee045b3a5968cd8843a2dvboxsync * If the expression is false, call RTTestFailed giving the line number and
218bcb38b2c98c6237bee045b3a5968cd8843a2dvboxsync * expression, then return @a rcRet.
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 *
218bcb38b2c98c6237bee045b3a5968cd8843a2dvboxsync * If the expression is false, call RTTestFailed giving the line number and
218bcb38b2c98c6237bee045b3a5968cd8843a2dvboxsync * expression, then return void.
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)
218bcb38b2c98c6237bee045b3a5968cd8843a2dvboxsync/** @def RTTEST_CHECK_BREAK
218bcb38b2c98c6237bee045b3a5968cd8843a2dvboxsync * Check whether a boolean expression holds true.
218bcb38b2c98c6237bee045b3a5968cd8843a2dvboxsync *
218bcb38b2c98c6237bee045b3a5968cd8843a2dvboxsync * If the expression is false, call RTTestFailed giving the line number and
218bcb38b2c98c6237bee045b3a5968cd8843a2dvboxsync * expression, then break.
218bcb38b2c98c6237bee045b3a5968cd8843a2dvboxsync *
218bcb38b2c98c6237bee045b3a5968cd8843a2dvboxsync * @param hTest The test handle.
218bcb38b2c98c6237bee045b3a5968cd8843a2dvboxsync * @param expr The expression to evaluate.
218bcb38b2c98c6237bee045b3a5968cd8843a2dvboxsync */
218bcb38b2c98c6237bee045b3a5968cd8843a2dvboxsync#define RTTEST_CHECK_BREAK(hTest, expr) \
218bcb38b2c98c6237bee045b3a5968cd8843a2dvboxsync if (!(expr)) { \
218bcb38b2c98c6237bee045b3a5968cd8843a2dvboxsync RTTestFailed((hTest), "line %u: %s", __LINE__, #expr); \
218bcb38b2c98c6237bee045b3a5968cd8843a2dvboxsync break; \
218bcb38b2c98c6237bee045b3a5968cd8843a2dvboxsync } else do {} 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)
218bcb38b2c98c6237bee045b3a5968cd8843a2dvboxsync/** @def RTTEST_CHECK_RC_BREAK
218bcb38b2c98c6237bee045b3a5968cd8843a2dvboxsync * Check whether an expression returns a specific IPRT style status code.
218bcb38b2c98c6237bee045b3a5968cd8843a2dvboxsync *
218bcb38b2c98c6237bee045b3a5968cd8843a2dvboxsync * If a different status code is return, call RTTestFailed giving the line
218bcb38b2c98c6237bee045b3a5968cd8843a2dvboxsync * number, expression, actual and expected status codes, then break.
218bcb38b2c98c6237bee045b3a5968cd8843a2dvboxsync *
218bcb38b2c98c6237bee045b3a5968cd8843a2dvboxsync * @param hTest The test handle.
218bcb38b2c98c6237bee045b3a5968cd8843a2dvboxsync * @param rcExpr The expression resulting in an IPRT status code.
218bcb38b2c98c6237bee045b3a5968cd8843a2dvboxsync * @param rcExpect The expected return code. This may be referenced
218bcb38b2c98c6237bee045b3a5968cd8843a2dvboxsync * more than once by the macro.
218bcb38b2c98c6237bee045b3a5968cd8843a2dvboxsync */
218bcb38b2c98c6237bee045b3a5968cd8843a2dvboxsync#define RTTEST_CHECK_RC_BREAK(hTest, rcExpr, rcExpect) \
218bcb38b2c98c6237bee045b3a5968cd8843a2dvboxsync if (1) { \
218bcb38b2c98c6237bee045b3a5968cd8843a2dvboxsync int rcCheck = (rcExpr); \
218bcb38b2c98c6237bee045b3a5968cd8843a2dvboxsync if (rcCheck != (rcExpect)) { \
218bcb38b2c98c6237bee045b3a5968cd8843a2dvboxsync RTTestFailed((hTest), "line %u: %s: expected %Rrc, got %Rrc", __LINE__, #rcExpr, (rcExpect), rcCheck); \
218bcb38b2c98c6237bee045b3a5968cd8843a2dvboxsync break; \
218bcb38b2c98c6237bee045b3a5968cd8843a2dvboxsync } \
218bcb38b2c98c6237bee045b3a5968cd8843a2dvboxsync } else do {} 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
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync/**
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync * Report a named test result value.
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync *
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync * This is typically used for benchmarking but can be used for other purposes
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync * like reporting limits of some implementation. The value gets associated with
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync * the current sub test, the name must be unique within the sub test.
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync *
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync * @returns IPRT status code.
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync *
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync * @param pszName The value name.
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync * @param u64Value The value.
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync * @param enmUnit The value unit.
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync */
97566036db1dc1dba46ed21be4e147c728fd1027vboxsyncRTR3DECL(int) RTTestIValue(const char *pszName, uint64_t u64Value, RTTESTUNIT enmUnit);
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync/**
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync * Same as RTTestValue, except that the name is now a format string.
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync *
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync * @returns IPRT status code.
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync *
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync * @param u64Value The value.
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync * @param enmUnit The value unit.
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync * @param pszNameFmt The value name format string.
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync * @param ... String arguments.
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync */
97566036db1dc1dba46ed21be4e147c728fd1027vboxsyncRTR3DECL(int) RTTestIValueF(uint64_t u64Value, RTTESTUNIT enmUnit, const char *pszNameFmt, ...);
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync/**
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync * Same as RTTestValue, except that the name is now a format string.
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync *
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync * @returns IPRT status code.
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync *
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync * @param u64Value The value.
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync * @param enmUnit The value unit.
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync * @param pszNameFmt The value name format string.
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync * @param va_list String arguments.
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync */
97566036db1dc1dba46ed21be4e147c728fd1027vboxsyncRTR3DECL(int) RTTestIValueV(uint64_t u64Value, RTTESTUNIT enmUnit, const char *pszNameFmt, va_list va);
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync
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
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync/**
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync * Increments the error counter, prints a failure message and returns the
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync * specified status code.
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync *
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync * This is mainly a convenience method for saving vertical space in the source
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync * code.
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync *
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync * @returns @a rcRet
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync * @param rcRet The IPRT status code to return.
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync * @param pszFormat The message. No trailing newline.
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync * @param va The arguments.
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync */
97566036db1dc1dba46ed21be4e147c728fd1027vboxsyncRTR3DECL(int) RTTestIFailedRcV(int rcRet, const char *pszFormat, va_list va);
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync/**
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync * Increments the error counter, prints a failure message and returns the
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync * specified status code.
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync *
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync * This is mainly a convenience method for saving vertical space in the source
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync * code.
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync *
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync * @returns @a rcRet
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync * @param rcRet The IPRT status code to return.
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync * @param pszFormat The message. No trailing newline.
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync * @param ... The arguments.
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync */
97566036db1dc1dba46ed21be4e147c728fd1027vboxsyncRTR3DECL(int) RTTestIFailedRc(int rcRet, const char *pszFormat, ...);
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync
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
218bcb38b2c98c6237bee045b3a5968cd8843a2dvboxsync * expression, then return @a rcRet.
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
218bcb38b2c98c6237bee045b3a5968cd8843a2dvboxsync * expression, then return void.
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)
218bcb38b2c98c6237bee045b3a5968cd8843a2dvboxsync/** @def RTTESTI_CHECK_RETV
218bcb38b2c98c6237bee045b3a5968cd8843a2dvboxsync * Check whether a boolean expression holds true, returns void on false.
218bcb38b2c98c6237bee045b3a5968cd8843a2dvboxsync *
218bcb38b2c98c6237bee045b3a5968cd8843a2dvboxsync * If the expression is false, call RTTestIFailed giving the line number and
218bcb38b2c98c6237bee045b3a5968cd8843a2dvboxsync * expression, then break.
218bcb38b2c98c6237bee045b3a5968cd8843a2dvboxsync *
218bcb38b2c98c6237bee045b3a5968cd8843a2dvboxsync * @param expr The expression to evaluate.
218bcb38b2c98c6237bee045b3a5968cd8843a2dvboxsync */
218bcb38b2c98c6237bee045b3a5968cd8843a2dvboxsync#define RTTESTI_CHECK_BREAK(expr) \
218bcb38b2c98c6237bee045b3a5968cd8843a2dvboxsync if (!(expr)) { \
218bcb38b2c98c6237bee045b3a5968cd8843a2dvboxsync RTTestIFailed("line %u: %s", __LINE__, #expr); \
218bcb38b2c98c6237bee045b3a5968cd8843a2dvboxsync break; \
c4e76628bde7234c0f813ea4dcfa6c24df6895ddvboxsync } else do {} 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)
c4e76628bde7234c0f813ea4dcfa6c24df6895ddvboxsync/** @def RTTESTI_CHECK_MSG_BREAK
c4e76628bde7234c0f813ea4dcfa6c24df6895ddvboxsync * Check whether a boolean expression holds true, returns on false.
c4e76628bde7234c0f813ea4dcfa6c24df6895ddvboxsync *
c4e76628bde7234c0f813ea4dcfa6c24df6895ddvboxsync * If the expression is false, call RTTestIFailed giving the line number and
c4e76628bde7234c0f813ea4dcfa6c24df6895ddvboxsync * expression.
c4e76628bde7234c0f813ea4dcfa6c24df6895ddvboxsync *
c4e76628bde7234c0f813ea4dcfa6c24df6895ddvboxsync * @param expr The expression to evaluate.
c4e76628bde7234c0f813ea4dcfa6c24df6895ddvboxsync * @param DetailsArgs Argument list for RTTestIFailureDetails, including
c4e76628bde7234c0f813ea4dcfa6c24df6895ddvboxsync * parenthesis.
c4e76628bde7234c0f813ea4dcfa6c24df6895ddvboxsync * @param rcRet What to return on failure.
c4e76628bde7234c0f813ea4dcfa6c24df6895ddvboxsync */
c4e76628bde7234c0f813ea4dcfa6c24df6895ddvboxsync#define RTTESTI_CHECK_MSG_BREAK(expr, DetailsArgs) \
c4e76628bde7234c0f813ea4dcfa6c24df6895ddvboxsync if (!(expr)) { \
c4e76628bde7234c0f813ea4dcfa6c24df6895ddvboxsync RTTestIFailed("line %u: %s", __LINE__, #expr); \
c4e76628bde7234c0f813ea4dcfa6c24df6895ddvboxsync RTTestIFailureDetails DetailsArgs; \
c4e76628bde7234c0f813ea4dcfa6c24df6895ddvboxsync break; \
c4e76628bde7234c0f813ea4dcfa6c24df6895ddvboxsync } else do {} 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
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)
218bcb38b2c98c6237bee045b3a5968cd8843a2dvboxsync/** @def RTTESTI_CHECK_RC_BREAK
218bcb38b2c98c6237bee045b3a5968cd8843a2dvboxsync * Check whether an expression returns a specific IPRT style status code.
218bcb38b2c98c6237bee045b3a5968cd8843a2dvboxsync *
218bcb38b2c98c6237bee045b3a5968cd8843a2dvboxsync * If a different status code is return, call RTTestIFailed giving the line
218bcb38b2c98c6237bee045b3a5968cd8843a2dvboxsync * number, expression, actual and expected status codes, then break.
218bcb38b2c98c6237bee045b3a5968cd8843a2dvboxsync *
218bcb38b2c98c6237bee045b3a5968cd8843a2dvboxsync * @param rcExpr The expression resulting in an IPRT status code.
218bcb38b2c98c6237bee045b3a5968cd8843a2dvboxsync * @param rcExpect The expected return code. This may be referenced
218bcb38b2c98c6237bee045b3a5968cd8843a2dvboxsync * more than once by the macro.
218bcb38b2c98c6237bee045b3a5968cd8843a2dvboxsync */
218bcb38b2c98c6237bee045b3a5968cd8843a2dvboxsync#define RTTESTI_CHECK_RC_BREAK(rcExpr, rcExpect) \
218bcb38b2c98c6237bee045b3a5968cd8843a2dvboxsync if (1) { \
218bcb38b2c98c6237bee045b3a5968cd8843a2dvboxsync int rcCheck = (rcExpr); \
218bcb38b2c98c6237bee045b3a5968cd8843a2dvboxsync if (rcCheck != (rcExpect)) { \
218bcb38b2c98c6237bee045b3a5968cd8843a2dvboxsync RTTestIFailed("line %u: %s: expected %Rrc, got %Rrc", __LINE__, #rcExpr, (rcExpect), rcCheck); \
218bcb38b2c98c6237bee045b3a5968cd8843a2dvboxsync break; \
218bcb38b2c98c6237bee045b3a5968cd8843a2dvboxsync } \
218bcb38b2c98c6237bee045b3a5968cd8843a2dvboxsync } else do {} while (0)
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)
755b872f5d5cf0e938e01be4f3ce380529ae8550vboxsync/** @def RTTESTI_CHECK_RC_OK_BREAK
755b872f5d5cf0e938e01be4f3ce380529ae8550vboxsync * Check whether a IPRT style status code indicates success.
755b872f5d5cf0e938e01be4f3ce380529ae8550vboxsync *
755b872f5d5cf0e938e01be4f3ce380529ae8550vboxsync * If a different status code is return, call RTTestIFailed giving the line
755b872f5d5cf0e938e01be4f3ce380529ae8550vboxsync * number, expression, actual and expected status codes, then break.
755b872f5d5cf0e938e01be4f3ce380529ae8550vboxsync *
755b872f5d5cf0e938e01be4f3ce380529ae8550vboxsync * @param rcExpr The expression resulting in an IPRT status code.
755b872f5d5cf0e938e01be4f3ce380529ae8550vboxsync */
755b872f5d5cf0e938e01be4f3ce380529ae8550vboxsync#define RTTESTI_CHECK_RC_OK_BREAK(rcExpr) \
755b872f5d5cf0e938e01be4f3ce380529ae8550vboxsync do { \
755b872f5d5cf0e938e01be4f3ce380529ae8550vboxsync int rcCheck = (rcExpr); \
755b872f5d5cf0e938e01be4f3ce380529ae8550vboxsync if (RT_FAILURE(rcCheck)) { \
755b872f5d5cf0e938e01be4f3ce380529ae8550vboxsync RTTestIFailed("line %u: %s: %Rrc", __LINE__, #rcExpr, rcCheck); \
755b872f5d5cf0e938e01be4f3ce380529ae8550vboxsync break; \
755b872f5d5cf0e938e01be4f3ce380529ae8550vboxsync } \
755b872f5d5cf0e938e01be4f3ce380529ae8550vboxsync } 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