1 | /** @file
|
---|
2 | * tstDevice: Configuration handling.
|
---|
3 | */
|
---|
4 |
|
---|
5 | /*
|
---|
6 | * Copyright (C) 2020-2022 Oracle Corporation
|
---|
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 |
|
---|
17 | #ifndef VBOX_INCLUDED_SRC_testcase_tstDeviceCfg_h
|
---|
18 | #define VBOX_INCLUDED_SRC_testcase_tstDeviceCfg_h
|
---|
19 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
20 | # pragma once
|
---|
21 | #endif
|
---|
22 |
|
---|
23 | #include <VBox/param.h>
|
---|
24 | #include <VBox/types.h>
|
---|
25 | #include <iprt/err.h>
|
---|
26 |
|
---|
27 | RT_C_DECLS_BEGIN
|
---|
28 |
|
---|
29 | /**
|
---|
30 | * Config item type.
|
---|
31 | */
|
---|
32 | typedef enum TSTDEVCFGITEMTYPE
|
---|
33 | {
|
---|
34 | /** Invalid type. */
|
---|
35 | TSTDEVCFGITEMTYPE_INVALID = 0,
|
---|
36 | /** String type. */
|
---|
37 | TSTDEVCFGITEMTYPE_STRING,
|
---|
38 | /** Integer value encoded in the string. */
|
---|
39 | TSTDEVCFGITEMTYPE_INTEGER,
|
---|
40 | /** Raw bytes. */
|
---|
41 | TSTDEVCFGITEMTYPE_BYTES,
|
---|
42 | /** 32bit hack. */
|
---|
43 | TSTDEVCFGITEMTYPE_32BIT_HACK = 0x7fffffff
|
---|
44 | } TSTDEVCFGITEMTYPE;
|
---|
45 | /** Pointer to a config item type. */
|
---|
46 | typedef TSTDEVCFGITEMTYPE *PTSTDEVCFGITEMTYPE;
|
---|
47 |
|
---|
48 |
|
---|
49 | /**
|
---|
50 | * Testcase config item.
|
---|
51 | */
|
---|
52 | typedef struct TSTDEVCFGITEM
|
---|
53 | {
|
---|
54 | /** The key of the item. */
|
---|
55 | const char *pszKey;
|
---|
56 | /** Type of the config item. */
|
---|
57 | TSTDEVCFGITEMTYPE enmType;
|
---|
58 | /** Type dependent data. */
|
---|
59 | union
|
---|
60 | {
|
---|
61 | /** String value. */
|
---|
62 | const char *psz;
|
---|
63 | /** Integer value. */
|
---|
64 | int64_t i64;
|
---|
65 | /** Raw bytes. */
|
---|
66 | struct
|
---|
67 | {
|
---|
68 | /** Size of the byte buffer. */
|
---|
69 | size_t cb;
|
---|
70 | /** Pointer to the raw buffer. */
|
---|
71 | const void *pv;
|
---|
72 | } RawBytes;
|
---|
73 | } u;
|
---|
74 | } TSTDEVCFGITEM;
|
---|
75 | /** Pointer to a testcase config item. */
|
---|
76 | typedef TSTDEVCFGITEM *PTSTDEVCFGITEM;
|
---|
77 | /** Pointer to a constant testcase config item. */
|
---|
78 | typedef const TSTDEVCFGITEM *PCTSTDEVCFGITEM;
|
---|
79 |
|
---|
80 |
|
---|
81 | /**
|
---|
82 | * A single test.
|
---|
83 | */
|
---|
84 | typedef struct TSTDEVTEST
|
---|
85 | {
|
---|
86 | /** Flag whether to enable the R0 part for testing. */
|
---|
87 | bool fR0Enabled;
|
---|
88 | /** Flag whether to enable the RC part for testing. */
|
---|
89 | bool fRCEnabled;
|
---|
90 | /** Number of configuration items for the device. */
|
---|
91 | uint32_t cCfgItems;
|
---|
92 | /** Pointer to array of configuration items for the device. */
|
---|
93 | PCTSTDEVCFGITEM paCfgItems;
|
---|
94 | /** Number of testcases to run with that device instance. */
|
---|
95 | uint32_t cTestcases;
|
---|
96 | /** Pointer to the array of testcase IDs. */
|
---|
97 | const char **papszTestcaseIds;
|
---|
98 | /** Pointer to the array of testcase configuration item numbers. */
|
---|
99 | uint32_t *pacTestcaseCfgItems;
|
---|
100 | /** Pointer to the array of configuration item array pointers for each testcase. */
|
---|
101 | PCTSTDEVCFGITEM *papTestcaseCfg;
|
---|
102 | } TSTDEVTEST;
|
---|
103 | /** Pointer to a single test. */
|
---|
104 | typedef TSTDEVTEST *PTSTDEVTEST;
|
---|
105 | /** Pointer to a const single test. */
|
---|
106 | typedef const TSTDEVTEST *PCTSTDEVTEST;
|
---|
107 |
|
---|
108 |
|
---|
109 | /**
|
---|
110 | * A device test configuration.
|
---|
111 | */
|
---|
112 | typedef struct TSTDEVCFG
|
---|
113 | {
|
---|
114 | /** The identifier of the device to test. */
|
---|
115 | const char *pszDevName;
|
---|
116 |
|
---|
117 | /** R3 PDM module to load containing the device to test. */
|
---|
118 | const char *pszPdmR3Mod;
|
---|
119 | /** R0 PDM module to load containing the device to test. */
|
---|
120 | const char *pszPdmR0Mod;
|
---|
121 | /** RC PDM module to load containing the device to test. */
|
---|
122 | const char *pszPdmRCMod;
|
---|
123 |
|
---|
124 | /** Testcase module to load. */
|
---|
125 | const char *pszTstDevMod;
|
---|
126 |
|
---|
127 | /** Number of tests configured in the config. */
|
---|
128 | uint32_t cTests;
|
---|
129 | /** The array of tests to execute for the given device - variable in size. */
|
---|
130 | TSTDEVTEST aTests[1];
|
---|
131 | } TSTDEVCFG;
|
---|
132 | /** Pointer to a device test configuration. */
|
---|
133 | typedef TSTDEVCFG *PTSTDEVCFG;
|
---|
134 | /** Pointer to a const device test configuration. */
|
---|
135 | typedef const TSTDEVCFG *PCTSTDEVCFG;
|
---|
136 | /** Pointer to a device test configuration pointer. */
|
---|
137 | typedef TSTDEVCFG *PPTSTDEVCFG;
|
---|
138 |
|
---|
139 |
|
---|
140 | /**
|
---|
141 | * Loads the config from the given file returning the configuration structure on success.
|
---|
142 | *
|
---|
143 | * @returns VBox status code.
|
---|
144 | * @param pszCfgFilename The configuration file path to load.
|
---|
145 | * @param pErrInfo Where to store additional error information if loading the config fails, optional.
|
---|
146 | * @param ppDevTstCfg Where to store the pointer to the created test configuration on success.
|
---|
147 | */
|
---|
148 | DECLHIDDEN(int) tstDevCfgLoad(const char *pszCfgFilename, PRTERRINFO pErrInfo, PCTSTDEVCFG *ppDevTstCfg);
|
---|
149 |
|
---|
150 | /**
|
---|
151 | * Destroys the given test configuration freeing all allocated resources.
|
---|
152 | *
|
---|
153 | * @returns nothing.
|
---|
154 | * @param pDevTstCfg The test configuration to destroy.
|
---|
155 | */
|
---|
156 | DECLHIDDEN(void) tstDevCfgDestroy(PCTSTDEVCFG pDevTstCfg);
|
---|
157 |
|
---|
158 | RT_C_DECLS_END
|
---|
159 |
|
---|
160 | #endif /* !VBOX_INCLUDED_SRC_testcase_tstDeviceCfg_h */
|
---|