1 | /* $Id: bs3-cmn-test.h 98103 2023-01-17 14:15:46Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * BS3Kit - Bs3Test internal header.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2007-2023 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 | /** Indicates whether the VMMDev is operational. */
|
---|
48 | #ifndef DOXYGEN_RUNNING
|
---|
49 | # define g_fbBs3VMMDevTesting BS3_DATA_NM(g_fbBs3VMMDevTesting)
|
---|
50 | #endif
|
---|
51 | extern bool g_fbBs3VMMDevTesting;
|
---|
52 |
|
---|
53 | /** The number of tests that have failed. */
|
---|
54 | #ifndef DOXYGEN_RUNNING
|
---|
55 | # define g_cusBs3TestErrors BS3_DATA_NM(g_cusBs3TestErrors)
|
---|
56 | #endif
|
---|
57 | extern uint16_t g_cusBs3TestErrors;
|
---|
58 |
|
---|
59 | /** The start error count of the current subtest. */
|
---|
60 | #ifndef DOXYGEN_RUNNING
|
---|
61 | # define g_cusBs3SubTestAtErrors BS3_DATA_NM(g_cusBs3SubTestAtErrors)
|
---|
62 | #endif
|
---|
63 | extern uint16_t g_cusBs3SubTestAtErrors;
|
---|
64 |
|
---|
65 | /** Whether we've reported the sub-test result or not. */
|
---|
66 | #ifndef DOXYGEN_RUNNING
|
---|
67 | # define g_fbBs3SubTestReported BS3_DATA_NM(g_fbBs3SubTestReported)
|
---|
68 | #endif
|
---|
69 | extern bool g_fbBs3SubTestReported;
|
---|
70 | /** Whether the sub-test has been skipped or not. */
|
---|
71 | #ifndef DOXYGEN_RUNNING
|
---|
72 | # define g_fbBs3SubTestSkipped BS3_DATA_NM(g_fbBs3SubTestSkipped)
|
---|
73 | #endif
|
---|
74 | extern bool g_fbBs3SubTestSkipped;
|
---|
75 |
|
---|
76 | /** The number of sub tests. */
|
---|
77 | #ifndef DOXYGEN_RUNNING
|
---|
78 | # define g_cusBs3SubTests BS3_DATA_NM(g_cusBs3SubTests)
|
---|
79 | #endif
|
---|
80 | extern uint16_t g_cusBs3SubTests;
|
---|
81 |
|
---|
82 | /** The number of sub tests that failed. */
|
---|
83 | #ifndef DOXYGEN_RUNNING
|
---|
84 | # define g_cusBs3SubTestsFailed BS3_DATA_NM(g_cusBs3SubTestsFailed)
|
---|
85 | #endif
|
---|
86 | extern uint16_t g_cusBs3SubTestsFailed;
|
---|
87 |
|
---|
88 | /** VMMDEV_TESTING_UNIT_XXX -> string */
|
---|
89 | #ifndef DOXYGEN_RUNNING
|
---|
90 | # define g_aszBs3TestUnitNames BS3_DATA_NM(g_aszBs3TestUnitNames)
|
---|
91 | #endif
|
---|
92 | extern char const g_aszBs3TestUnitNames[][12];
|
---|
93 |
|
---|
94 | /** The test name. */
|
---|
95 | extern const char BS3_FAR *g_pszBs3Test_c16;
|
---|
96 | extern const char *g_pszBs3Test_c32;
|
---|
97 | extern const char *g_pszBs3Test_c64;
|
---|
98 |
|
---|
99 | /** The subtest name. */
|
---|
100 | #ifndef DOXYGEN_RUNNING
|
---|
101 | # define g_szBs3SubTest BS3_DATA_NM(g_szBs3SubTest)
|
---|
102 | #endif
|
---|
103 | extern char g_szBs3SubTest[64];
|
---|
104 |
|
---|
105 |
|
---|
106 | /**
|
---|
107 | * Sends a command to VMMDev followed by a single string.
|
---|
108 | *
|
---|
109 | * If the VMMDev is not present or is not being used, this function will
|
---|
110 | * do nothing.
|
---|
111 | *
|
---|
112 | * @param uCmd The command.
|
---|
113 | * @param pszString The string.
|
---|
114 | */
|
---|
115 | #ifndef DOXYGEN_RUNNING
|
---|
116 | # define bs3TestSendCmdWithStr BS3_CMN_NM(bs3TestSendCmdWithStr)
|
---|
117 | #endif
|
---|
118 | BS3_DECL(void) bs3TestSendCmdWithStr(uint32_t uCmd, const char BS3_FAR *pszString);
|
---|
119 |
|
---|
120 | /**
|
---|
121 | * Sends a command to VMMDev followed by a 32-bit unsigned integer value.
|
---|
122 | *
|
---|
123 | * If the VMMDev is not present or is not being used, this function will
|
---|
124 | * do nothing.
|
---|
125 | *
|
---|
126 | * @param uCmd The command.
|
---|
127 | * @param uValue The value.
|
---|
128 | */
|
---|
129 | #ifndef DOXYGEN_RUNNING
|
---|
130 | # define bs3TestSendCmdWithU32 BS3_CMN_NM(bs3TestSendCmdWithU32)
|
---|
131 | #endif
|
---|
132 | BS3_DECL(void) bs3TestSendCmdWithU32(uint32_t uCmd, uint32_t uValue);
|
---|
133 |
|
---|
134 | /**
|
---|
135 | * Checks if the VMMDev is configured for testing.
|
---|
136 | *
|
---|
137 | * @returns true / false.
|
---|
138 | */
|
---|
139 | #ifndef DOXYGEN_RUNNING
|
---|
140 | # define bs3TestIsVmmDevTestingPresent BS3_CMN_NM(bs3TestIsVmmDevTestingPresent)
|
---|
141 | #endif
|
---|
142 | BS3_DECL(bool) bs3TestIsVmmDevTestingPresent(void);
|
---|
143 |
|
---|
144 | /**
|
---|
145 | * Similar to rtTestSubCleanup.
|
---|
146 | */
|
---|
147 | #ifndef DOXYGEN_RUNNING
|
---|
148 | # define bs3TestSubCleanup BS3_CMN_NM(bs3TestSubCleanup)
|
---|
149 | #endif
|
---|
150 | BS3_DECL(void) bs3TestSubCleanup(void);
|
---|
151 |
|
---|
152 | /**
|
---|
153 | * @callback_method_impl{FNBS3STRFORMATOUTPUT,
|
---|
154 | * Used by Bs3TestFailedV and Bs3TestSkippedV.
|
---|
155 | *
|
---|
156 | * The @a pvUser parameter must point a BS3TESTFAILEDBUF structure. }
|
---|
157 | */
|
---|
158 | #ifndef DOXYGEN_RUNNING
|
---|
159 | # define bs3TestFailedStrOutput BS3_CMN_NM(bs3TestFailedStrOutput)
|
---|
160 | #endif
|
---|
161 | BS3_DECL_CALLBACK(size_t) bs3TestFailedStrOutput(char ch, void BS3_FAR *pvUser);
|
---|
162 |
|
---|
163 | /**
|
---|
164 | * Output buffering for bs3TestFailedStrOutput.
|
---|
165 | */
|
---|
166 | typedef struct BS3TESTFAILEDBUF
|
---|
167 | {
|
---|
168 | /** Initialize to false. */
|
---|
169 | bool fNewLine;
|
---|
170 | /** Initialize to zero. */
|
---|
171 | uint8_t cchBuf;
|
---|
172 | /** Buffer, uninitialized. */
|
---|
173 | char achBuf[128];
|
---|
174 | } BS3TESTFAILEDBUF;
|
---|
175 | /** Pointer to a bs3TestFailedStrOutput buffer. */
|
---|
176 | typedef BS3TESTFAILEDBUF BS3_FAR *PBS3TESTFAILEDBUF;
|
---|
177 |
|
---|
178 | #endif /* !BS3KIT_INCLUDED_bs3_cmn_test_h */
|
---|
179 |
|
---|