1 | /* $Id: bs3-cmn-test.h 106061 2024-09-16 14:03:52Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * BS3Kit - Bs3Test internal header.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2007-2024 Oracle and/or its affiliates.
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox base platform packages, as
|
---|
10 | * available from https://www.virtualbox.org.
|
---|
11 | *
|
---|
12 | * This program is free software; you can redistribute it and/or
|
---|
13 | * modify it under the terms of the GNU General Public License
|
---|
14 | * as published by the Free Software Foundation, in version 3 of the
|
---|
15 | * License.
|
---|
16 | *
|
---|
17 | * This program is distributed in the hope that it will be useful, but
|
---|
18 | * WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
20 | * General Public License for more details.
|
---|
21 | *
|
---|
22 | * You should have received a copy of the GNU General Public License
|
---|
23 | * along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
24 | *
|
---|
25 | * The contents of this file may alternatively be used under the terms
|
---|
26 | * of the Common Development and Distribution License Version 1.0
|
---|
27 | * (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
|
---|
28 | * in the VirtualBox distribution, in which case the provisions of the
|
---|
29 | * CDDL are applicable instead of those of the GPL.
|
---|
30 | *
|
---|
31 | * You may elect to license modified versions of this file under the
|
---|
32 | * terms and conditions of either the GPL or the CDDL or both.
|
---|
33 | *
|
---|
34 | * SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
|
---|
35 | */
|
---|
36 |
|
---|
37 | #ifndef BS3KIT_INCLUDED_bs3_cmn_test_h
|
---|
38 | #define BS3KIT_INCLUDED_bs3_cmn_test_h
|
---|
39 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
40 | # pragma once
|
---|
41 | #endif
|
---|
42 |
|
---|
43 | #include "bs3kit.h"
|
---|
44 | #include <VBox/VMMDevTesting.h>
|
---|
45 |
|
---|
46 |
|
---|
47 | /** The test name. */
|
---|
48 | extern const char BS3_FAR *g_pszBs3Test_c16;
|
---|
49 | extern const char *g_pszBs3Test_c32;
|
---|
50 | extern const char *g_pszBs3Test_c64;
|
---|
51 |
|
---|
52 | /** Indicates whether the VMMDev is operational. */
|
---|
53 | #ifndef DOXYGEN_RUNNING
|
---|
54 | # define g_fbBs3VMMDevTesting BS3_DATA_NM(g_fbBs3VMMDevTesting)
|
---|
55 | #endif
|
---|
56 | extern bool g_fbBs3VMMDevTesting;
|
---|
57 |
|
---|
58 | /** The number of tests that have failed. */
|
---|
59 | #ifndef DOXYGEN_RUNNING
|
---|
60 | # define g_cusBs3TestErrors BS3_DATA_NM(g_cusBs3TestErrors)
|
---|
61 | #endif
|
---|
62 | extern uint16_t g_cusBs3TestErrors;
|
---|
63 |
|
---|
64 |
|
---|
65 | /** The subtest name. */
|
---|
66 | #ifndef DOXYGEN_RUNNING
|
---|
67 | # define g_szBs3SubTest BS3_DATA_NM(g_szBs3SubTest)
|
---|
68 | #endif
|
---|
69 | extern char g_szBs3SubTest[64];
|
---|
70 |
|
---|
71 | /** The start error count of the current subtest. */
|
---|
72 | #ifndef DOXYGEN_RUNNING
|
---|
73 | # define g_cusBs3SubTestAtErrors BS3_DATA_NM(g_cusBs3SubTestAtErrors)
|
---|
74 | #endif
|
---|
75 | extern uint16_t g_cusBs3SubTestAtErrors;
|
---|
76 |
|
---|
77 | /** Whether we've reported the sub-test result or not. */
|
---|
78 | #ifndef DOXYGEN_RUNNING
|
---|
79 | # define g_fbBs3SubTestReported BS3_DATA_NM(g_fbBs3SubTestReported)
|
---|
80 | #endif
|
---|
81 | extern bool g_fbBs3SubTestReported;
|
---|
82 | /** Whether the sub-test has been skipped or not. */
|
---|
83 | #ifndef DOXYGEN_RUNNING
|
---|
84 | # define g_fbBs3SubTestSkipped BS3_DATA_NM(g_fbBs3SubTestSkipped)
|
---|
85 | #endif
|
---|
86 | extern bool g_fbBs3SubTestSkipped;
|
---|
87 |
|
---|
88 | /** The number of sub tests. */
|
---|
89 | #ifndef DOXYGEN_RUNNING
|
---|
90 | # define g_cusBs3SubTests BS3_DATA_NM(g_cusBs3SubTests)
|
---|
91 | #endif
|
---|
92 | extern uint16_t g_cusBs3SubTests;
|
---|
93 |
|
---|
94 | /** The number of sub tests that failed. */
|
---|
95 | #ifndef DOXYGEN_RUNNING
|
---|
96 | # define g_cusBs3SubTestsFailed BS3_DATA_NM(g_cusBs3SubTestsFailed)
|
---|
97 | #endif
|
---|
98 | extern uint16_t g_cusBs3SubTestsFailed;
|
---|
99 |
|
---|
100 |
|
---|
101 | /** The subsubtest name. */
|
---|
102 | #ifndef DOXYGEN_RUNNING
|
---|
103 | # define g_szBs3SubSubTest BS3_DATA_NM(g_szBs3SubSubTest)
|
---|
104 | #endif
|
---|
105 | extern char g_szBs3SubSubTest[64];
|
---|
106 |
|
---|
107 | /** The start error count of the current sub-sub-test. */
|
---|
108 | #ifndef DOXYGEN_RUNNING
|
---|
109 | # define g_cusBs3SubSubTestAtErrors BS3_DATA_NM(g_cusBs3SubSubTestAtErrors)
|
---|
110 | #endif
|
---|
111 | extern uint16_t g_cusBs3SubSubTestAtErrors;
|
---|
112 |
|
---|
113 | /** Whether we've reported the sub-sub-test result or not. */
|
---|
114 | #ifndef DOXYGEN_RUNNING
|
---|
115 | # define g_fbBs3SubSubTestReported BS3_DATA_NM(g_fbBs3SubSubTestReported)
|
---|
116 | #endif
|
---|
117 | extern bool g_fbBs3SubSubTestReported;
|
---|
118 | /** Whether the sub-sub-test has been skipped or not. */
|
---|
119 | #ifndef DOXYGEN_RUNNING
|
---|
120 | # define g_fbBs3SubSubTestSkipped BS3_DATA_NM(g_fbBs3SubSubTestSkipped)
|
---|
121 | #endif
|
---|
122 | extern bool g_fbBs3SubSubTestSkipped;
|
---|
123 |
|
---|
124 | /** The number of sub-sub-tests. */
|
---|
125 | #ifndef DOXYGEN_RUNNING
|
---|
126 | # define g_cusBs3SubSubTests BS3_DATA_NM(g_cusBs3SubSubTests)
|
---|
127 | #endif
|
---|
128 | extern uint16_t g_cusBs3SubSubTests;
|
---|
129 |
|
---|
130 | /** The number of sub-sub-tests that failed. */
|
---|
131 | #ifndef DOXYGEN_RUNNING
|
---|
132 | # define g_cusBs3SubSubTestsFailed BS3_DATA_NM(g_cusBs3SubSubTestsFailed)
|
---|
133 | #endif
|
---|
134 | extern uint16_t g_cusBs3SubSubTestsFailed;
|
---|
135 |
|
---|
136 |
|
---|
137 | /** VMMDEV_TESTING_UNIT_XXX -> string */
|
---|
138 | #ifndef DOXYGEN_RUNNING
|
---|
139 | # define g_aszBs3TestUnitNames BS3_DATA_NM(g_aszBs3TestUnitNames)
|
---|
140 | #endif
|
---|
141 | extern char const g_aszBs3TestUnitNames[][12];
|
---|
142 |
|
---|
143 |
|
---|
144 |
|
---|
145 | /**
|
---|
146 | * Sends a command to VMMDev followed by a single string.
|
---|
147 | *
|
---|
148 | * If the VMMDev is not present or is not being used, this function will
|
---|
149 | * do nothing.
|
---|
150 | *
|
---|
151 | * @param uCmd The command.
|
---|
152 | * @param pszString The string.
|
---|
153 | */
|
---|
154 | #ifndef DOXYGEN_RUNNING
|
---|
155 | # define bs3TestSendCmdWithStr BS3_CMN_NM(bs3TestSendCmdWithStr)
|
---|
156 | #endif
|
---|
157 | BS3_DECL(void) bs3TestSendCmdWithStr(uint32_t uCmd, const char BS3_FAR *pszString);
|
---|
158 |
|
---|
159 | /**
|
---|
160 | * Sends a command to VMMDev followed by a 32-bit unsigned integer value.
|
---|
161 | *
|
---|
162 | * If the VMMDev is not present or is not being used, this function will
|
---|
163 | * do nothing.
|
---|
164 | *
|
---|
165 | * @param uCmd The command.
|
---|
166 | * @param uValue The value.
|
---|
167 | */
|
---|
168 | #ifndef DOXYGEN_RUNNING
|
---|
169 | # define bs3TestSendCmdWithU32 BS3_CMN_NM(bs3TestSendCmdWithU32)
|
---|
170 | #endif
|
---|
171 | BS3_DECL(void) bs3TestSendCmdWithU32(uint32_t uCmd, uint32_t uValue);
|
---|
172 |
|
---|
173 | /**
|
---|
174 | * Checks if the VMMDev is configured for testing.
|
---|
175 | *
|
---|
176 | * @returns true / false.
|
---|
177 | */
|
---|
178 | #ifndef DOXYGEN_RUNNING
|
---|
179 | # define bs3TestIsVmmDevTestingPresent BS3_CMN_NM(bs3TestIsVmmDevTestingPresent)
|
---|
180 | #endif
|
---|
181 | BS3_DECL(bool) bs3TestIsVmmDevTestingPresent(void);
|
---|
182 |
|
---|
183 | /**
|
---|
184 | * Similar to rtTestSubSubCleanup.
|
---|
185 | */
|
---|
186 | #ifndef DOXYGEN_RUNNING
|
---|
187 | # define bs3TestSubSubCleanup BS3_CMN_NM(bs3TestSubSubCleanup)
|
---|
188 | #endif
|
---|
189 | BS3_DECL(void) bs3TestSubSubCleanup(void);
|
---|
190 |
|
---|
191 | /**
|
---|
192 | * Similar to rtTestSubCleanup.
|
---|
193 | */
|
---|
194 | #ifndef DOXYGEN_RUNNING
|
---|
195 | # define bs3TestSubCleanup BS3_CMN_NM(bs3TestSubCleanup)
|
---|
196 | #endif
|
---|
197 | BS3_DECL(void) bs3TestSubCleanup(void);
|
---|
198 |
|
---|
199 | /**
|
---|
200 | * @callback_method_impl{FNBS3STRFORMATOUTPUT,
|
---|
201 | * Used by Bs3TestFailedV and Bs3TestSkippedV.
|
---|
202 | *
|
---|
203 | * The @a pvUser parameter must point a BS3TESTFAILEDBUF structure. }
|
---|
204 | */
|
---|
205 | #ifndef DOXYGEN_RUNNING
|
---|
206 | # define bs3TestFailedStrOutput BS3_CMN_NM(bs3TestFailedStrOutput)
|
---|
207 | #endif
|
---|
208 | BS3_DECL_CALLBACK(size_t) bs3TestFailedStrOutput(char ch, void BS3_FAR *pvUser);
|
---|
209 |
|
---|
210 | /**
|
---|
211 | * Output buffering for bs3TestFailedStrOutput.
|
---|
212 | */
|
---|
213 | typedef struct BS3TESTFAILEDBUF
|
---|
214 | {
|
---|
215 | /** Initialize to false. */
|
---|
216 | bool fNewLine;
|
---|
217 | /** Initialize to zero. */
|
---|
218 | uint8_t cchBuf;
|
---|
219 | /** Buffer, uninitialized. */
|
---|
220 | char achBuf[128];
|
---|
221 | } BS3TESTFAILEDBUF;
|
---|
222 | /** Pointer to a bs3TestFailedStrOutput buffer. */
|
---|
223 | typedef BS3TESTFAILEDBUF BS3_FAR *PBS3TESTFAILEDBUF;
|
---|
224 |
|
---|
225 | #endif /* !BS3KIT_INCLUDED_bs3_cmn_test_h */
|
---|
226 |
|
---|