summaryrefslogtreecommitdiff
path: root/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-test.h
blob: dad47d64903c5b7b5738be9b9d81f540604fa42b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
/* $Id$ */
/** @file
 * BS3Kit - Bs3Test internal header.
 */

/*
 * Copyright (C) 2007-2022 Oracle Corporation
 *
 * This file is part of VirtualBox Open Source Edition (OSE), as
 * available from http://www.virtualbox.org. This file is free software;
 * you can redistribute it and/or modify it under the terms of the GNU
 * General Public License (GPL) as published by the Free Software
 * Foundation, in version 2 as it comes in the "COPYING" file of the
 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
 *
 * The contents of this file may alternatively be used under the terms
 * of the Common Development and Distribution License Version 1.0
 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
 * VirtualBox OSE distribution, in which case the provisions of the
 * CDDL are applicable instead of those of the GPL.
 *
 * You may elect to license modified versions of this file under the
 * terms and conditions of either the GPL or the CDDL or both.
 */

#ifndef BS3KIT_INCLUDED_bs3_cmn_test_h
#define BS3KIT_INCLUDED_bs3_cmn_test_h
#ifndef RT_WITHOUT_PRAGMA_ONCE
# pragma once
#endif

#include "bs3kit.h"
#include <VBox/VMMDevTesting.h>


/** Indicates whether the VMMDev is operational. */
#ifndef DOXYGEN_RUNNING
# define g_fbBs3VMMDevTesting BS3_DATA_NM(g_fbBs3VMMDevTesting)
#endif
extern bool                 g_fbBs3VMMDevTesting;

/** The number of tests that have failed. */
#ifndef DOXYGEN_RUNNING
# define g_cusBs3TestErrors BS3_DATA_NM(g_cusBs3TestErrors)
#endif
extern uint16_t             g_cusBs3TestErrors;

/** The start error count of the current subtest. */
#ifndef DOXYGEN_RUNNING
# define g_cusBs3SubTestAtErrors BS3_DATA_NM(g_cusBs3SubTestAtErrors)
#endif
extern uint16_t             g_cusBs3SubTestAtErrors;

/**  Whether we've reported the sub-test result or not. */
#ifndef DOXYGEN_RUNNING
# define g_fbBs3SubTestReported BS3_DATA_NM(g_fbBs3SubTestReported)
#endif
extern bool                 g_fbBs3SubTestReported;
/** Whether the sub-test has been skipped or not. */
#ifndef DOXYGEN_RUNNING
# define g_fbBs3SubTestSkipped BS3_DATA_NM(g_fbBs3SubTestSkipped)
#endif
extern bool                 g_fbBs3SubTestSkipped;

/** The number of sub tests. */
#ifndef DOXYGEN_RUNNING
# define g_cusBs3SubTests   BS3_DATA_NM(g_cusBs3SubTests)
#endif
extern uint16_t             g_cusBs3SubTests;

/** The number of sub tests that failed. */
#ifndef DOXYGEN_RUNNING
# define g_cusBs3SubTestsFailed BS3_DATA_NM(g_cusBs3SubTestsFailed)
#endif
extern uint16_t             g_cusBs3SubTestsFailed;

/** VMMDEV_TESTING_UNIT_XXX -> string */
#ifndef DOXYGEN_RUNNING
# define g_aszBs3TestUnitNames BS3_DATA_NM(g_aszBs3TestUnitNames)
#endif
extern char const           g_aszBs3TestUnitNames[][12];

/** The test name. */
extern const char BS3_FAR  *g_pszBs3Test_c16;
extern const char          *g_pszBs3Test_c32;
extern const char          *g_pszBs3Test_c64;

/** The subtest name. */
#ifndef DOXYGEN_RUNNING
# define g_szBs3SubTest     BS3_DATA_NM(g_szBs3SubTest)
#endif
extern char                 g_szBs3SubTest[64];


/**
 * Sends a command to VMMDev followed by a single string.
 *
 * If the VMMDev is not present or is not being used, this function will
 * do nothing.
 *
 * @param   uCmd        The command.
 * @param   pszString   The string.
 */
#ifndef DOXYGEN_RUNNING
# define bs3TestSendCmdWithStr BS3_CMN_NM(bs3TestSendCmdWithStr)
#endif
BS3_DECL(void) bs3TestSendCmdWithStr(uint32_t uCmd, const char BS3_FAR *pszString);

/**
 * Sends a command to VMMDev followed by a 32-bit unsigned integer value.
 *
 * If the VMMDev is not present or is not being used, this function will
 * do nothing.
 *
 * @param   uCmd        The command.
 * @param   uValue      The value.
 */
#ifndef DOXYGEN_RUNNING
# define bs3TestSendCmdWithU32 BS3_CMN_NM(bs3TestSendCmdWithU32)
#endif
BS3_DECL(void) bs3TestSendCmdWithU32(uint32_t uCmd, uint32_t uValue);

/**
 * Checks if the VMMDev is configured for testing.
 *
 * @returns true / false.
 */
#ifndef DOXYGEN_RUNNING
# define bs3TestIsVmmDevTestingPresent BS3_CMN_NM(bs3TestIsVmmDevTestingPresent)
#endif
BS3_DECL(bool) bs3TestIsVmmDevTestingPresent(void);

/**
 * Similar to rtTestSubCleanup.
 */
#ifndef DOXYGEN_RUNNING
# define bs3TestSubCleanup BS3_CMN_NM(bs3TestSubCleanup)
#endif
BS3_DECL(void) bs3TestSubCleanup(void);

/**
 * @callback_method_impl{FNBS3STRFORMATOUTPUT,
 *      Used by Bs3TestFailedV and Bs3TestSkippedV.
 *
 *      The @a pvUser parameter must point a BS3TESTFAILEDBUF structure. }
 */
#ifndef DOXYGEN_RUNNING
# define bs3TestFailedStrOutput BS3_CMN_NM(bs3TestFailedStrOutput)
#endif
BS3_DECL_CALLBACK(size_t) bs3TestFailedStrOutput(char ch, void BS3_FAR *pvUser);

/**
 * Output buffering for bs3TestFailedStrOutput.
 */
typedef struct BS3TESTFAILEDBUF
{
    /** Initialize to false. */
    bool    fNewLine;
    /** Initialize to zero. */
    uint8_t cchBuf;
    /** Buffer, uninitialized. */
    char    achBuf[128];
} BS3TESTFAILEDBUF;
/** Pointer to a bs3TestFailedStrOutput buffer.  */
typedef BS3TESTFAILEDBUF BS3_FAR *PBS3TESTFAILEDBUF;

#endif /* !BS3KIT_INCLUDED_bs3_cmn_test_h */