VirtualBox

source: vbox/trunk/include/iprt/test.h@ 18364

Last change on this file since 18364 was 18364, checked in by vboxsync, 16 years ago

RTTest: kick-off for testcase helpers.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 6.8 KB
Line 
1/** @file
2 * IPRT - Test.
3 */
4
5/*
6 * Copyright (C) 2009 Sun Microsystems, Inc.
7 *
8 * This file is part of VirtualBox Open Source Edition (OSE), as
9 * available from http://www.virtualbox.org. This file is free software;
10 * you can redistribute it and/or modify it under the terms of the GNU
11 * General Public License (GPL) as published by the Free Software
12 * Foundation, in version 2 as it comes in the "COPYING" file of the
13 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
14 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
15 *
16 * The contents of this file may alternatively be used under the terms
17 * of the Common Development and Distribution License Version 1.0
18 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
19 * VirtualBox OSE distribution, in which case the provisions of the
20 * CDDL are applicable instead of those of the GPL.
21 *
22 * You may elect to license modified versions of this file under the
23 * terms and conditions of either the GPL or the CDDL or both.
24 *
25 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
26 * Clara, CA 95054 USA or visit http://www.sun.com if you need
27 * additional information or have any questions.
28 */
29
30#ifndef ___iprt_test_h
31#define ___iprt_test_h
32
33#include <iprt/cdefs.h>
34#include <iprt/types.h>
35#include <iprt/stdarg.h>
36
37/** A test handle. */
38typedef struct RTTESTINT *RTTEST;
39/** A pointer to a test handle. */
40typedef RTTEST *PRTTEST;
41/** A const pointer to a test handle. */
42typedef RTTEST const *PCRTTEST;
43
44/** A NIL Test handle. */
45#define NIL_RTTEST ((RTTEST)0)
46
47
48__BEGIN_DECLS
49
50
51/**
52 * Creates a test instance.
53 *
54 * @returns IPRT status code.
55 * @param pszTest The test name.
56 * @param phTest Where to store the test instance handle.
57 */
58RTR3DECL(int) RTTestCreate(const char *pszTest, PRTTEST phTest);
59
60/**
61 * Destroys a test instance previously created by RTTestCreate.
62 *
63 * @returns IPRT status code.
64 * @param hTest The test handle. NIL_RTTEST is ignored.
65 */
66RTR3DECL(int) RTTestDestroy(RTTEST hTest);
67
68/**
69 * Allocate a block of guarded memory.
70 *
71 * @returns IPRT status code.
72 * @param hTest The test handle. If NIL_RTTEST we'll use the one
73 * associated with the calling thread.
74 * @param cb The amount of memory to allocate.
75 * @param cbAlign The alignment of the returned block.
76 * @param fHead Head or tail optimized guard.
77 * @param ppvUser Where to return the pointer to the block.
78 */
79RTR3DECL(int) RTTestGuardedAlloc(RTTEST hTest, size_t cb, uint32_t cbAlign, bool fHead, void **ppvUser);
80
81/**
82 * Allocates a block of guarded memory where the guarded is immediately after
83 * the user memory.
84 *
85 * @returns Pointer to the allocated memory. NULL on failure.
86 * @param hTest The test handle. If NIL_RTTEST we'll use the one
87 * associated with the calling thread.
88 * @param cb The amount of memory to allocate.
89 */
90RTR3DECL(void *) RTTestGuardedAllocTail(RTTEST hTest, size_t cb);
91
92/**
93 * Allocates a block of guarded memory where the guarded is right in front of
94 * the user memory.
95 *
96 * @returns Pointer to the allocated memory. NULL on failure.
97 * @param hTest The test handle. If NIL_RTTEST we'll use the one
98 * associated with the calling thread.
99 * @param cb The amount of memory to allocate.
100 */
101RTR3DECL(void *) RTTestGuardedAllocHead(RTTEST hTest, size_t cb);
102
103/**
104 * Frees a block of guarded memory.
105 *
106 * @returns IPRT status code.
107 * @param hTest The test handle. If NIL_RTTEST we'll use the one
108 * associated with the calling thread.
109 * @param pv The memory. NULL is ignored.
110 */
111RTR3DECL(int) RTTestGuardedFree(RTTEST hTest, void *pv);
112
113/**
114 * Test vprintf making sure the output starts on a new line.
115 *
116 * @returns Number of chars printed.
117 * @param hTest The test handle. If NIL_RTTEST we'll use the one
118 * associated with the calling thread.
119 * @param pszFormat The message.
120 * @param va Arguments.
121 */
122RTR3DECL(int) RTTestPrintfNlV(RTTEST hTest, const char *pszFormat, va_list va);
123
124/**
125 * Test printf making sure the output starts on a new line.
126 *
127 * @returns Number of chars printed.
128 * @param hTest The test handle. If NIL_RTTEST we'll use the one
129 * associated with the calling thread.
130 * @param pszFormat The message.
131 * @param ... Arguments.
132 */
133RTR3DECL(int) RTTestPrintfNl(RTTEST hTest, const char *pszFormat, ...);
134
135/**
136 * Test vprintf, makes sure lines are prefixed and so forth.
137 *
138 * @returns Number of chars printed.
139 * @param hTest The test handle. If NIL_RTTEST we'll use the one
140 * associated with the calling thread.
141 * @param pszFormat The message.
142 * @param va Arguments.
143 */
144RTR3DECL(int) RTTestPrintfV(RTTEST hTest, const char *pszFormat, va_list va);
145
146/**
147 * Test printf, makes sure lines are prefixed and so forth.
148 *
149 * @returns Number of chars printed.
150 * @param hTest The test handle. If NIL_RTTEST we'll use the one
151 * associated with the calling thread.
152 * @param pszFormat The message.
153 * @param ... Arguments.
154 */
155RTR3DECL(int) RTTestPrintf(RTTEST hTest, const char *pszFormat, ...);
156
157/**
158 * Prints the test banner.
159 *
160 * @returns Number of chars printed.
161 * @param hTest The test handle. If NIL_RTTEST we'll use the one
162 * associated with the calling thread.
163 */
164RTR3DECL(int) RTTestBanner(RTTEST hTest);
165
166/**
167 * Summaries the test, destroys the test instance and return an exit code.
168 *
169 * @returns Test program exit code.
170 * @param hTest The test handle. If NIL_RTTEST we'll use the one
171 * associated with the calling thread.
172 */
173RTR3DECL(int) RTTestSummaryAndDestroy(RTTEST hTest);
174
175/**
176 * Increments the error counter.
177 *
178 * @returns IPRT status code.
179 * @param hTest The test handle. If NIL_RTTEST we'll use the one
180 * associated with the calling thread.
181 */
182RTR3DECL(int) RTTestErrorInc(RTTEST hTest);
183
184/**
185 * Increments the error counter and prints a failure message.
186 *
187 * @returns IPRT status code.
188 * @param hTest The test handle. If NIL_RTTEST we'll use the one
189 * associated with the calling thread.
190 * @param pszFormat The message. No trailing newline.
191 * @param va The arguments.
192 */
193RTR3DECL(int) RTTestFailedV(RTTEST hTest, const char *pszFormat, va_list va);
194
195/**
196 * Increments the error counter and prints a failure message.
197 *
198 * @returns IPRT status code.
199 * @param hTest The test handle. If NIL_RTTEST we'll use the one
200 * associated with the calling thread.
201 * @param pszFormat The message. No trailing newline.
202 * @param ... The arguments.
203 */
204RTR3DECL(int) RTTestFailed(RTTEST hTest, const char *pszFormat, ...);
205
206__END_DECLS
207
208#endif
209
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette