Changeset 19466 in vbox for trunk/src/VBox
- Timestamp:
- May 7, 2009 12:22:56 AM (16 years ago)
- Location:
- trunk/src/VBox/VMM
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/CFGM.cpp
r19287 r19466 30 30 * via the pfnCFGMConstructor parameter. To make testcase writing a bit simpler, 31 31 * we allow the callback to be NULL, in which case a simple default 32 * configuration will be created by cfgmR3CreateDefaultTree(). The32 * configuration will be created by CFGMR3ConstructDefaultTree(). The 33 33 * Console::configConstructor() method in Main/ConsoleImpl2.cpp creates the 34 34 * configuration from the XML. … … 76 76 * Internal Functions * 77 77 *******************************************************************************/ 78 static int cfgmR3CreateDefaultTree(PVM pVM);79 78 static void cfgmR3DumpPath(PCFGMNODE pNode, PCDBGFINFOHLP pHlp); 80 79 static void cfgmR3Dump(PCFGMNODE pRoot, unsigned iLevel, PCDBGFINFOHLP pHlp); … … 114 113 115 114 /* 116 * Create the configuration tree.115 * Root Node. 117 116 */ 117 PCFGMNODE pRoot = (PCFGMNODE)MMR3HeapAllocZ(pVM, MM_TAG_CFGM, sizeof(*pRoot)); 118 if (!pRoot) 119 return VERR_NO_MEMORY; 120 pRoot->pVM = pVM; 121 pRoot->cchName = 0; 122 pVM->cfgm.s.pRoot = pRoot; 123 124 /* 125 * Call the constructor if specified, if not use the default one. 126 */ 118 127 if (pfnCFGMConstructor) 119 {120 /*121 * Root Node.122 */123 PCFGMNODE pRoot = (PCFGMNODE)MMR3HeapAllocZ(pVM, MM_TAG_CFGM, sizeof(*pRoot));124 if (!pRoot)125 return VERR_NO_MEMORY;126 pRoot->pVM = pVM;127 pRoot->cchName = 0;128 pVM->cfgm.s.pRoot = pRoot;129 130 /*131 * Call the constructor.132 */133 128 rc = pfnCFGMConstructor(pVM, pvUser); 134 }135 129 else 136 rc = cfgmR3CreateDefaultTree(pVM);130 rc = CFGMR3ConstructDefaultTree(pVM); 137 131 if (RT_SUCCESS(rc)) 138 132 { … … 740 734 741 735 /** 742 * Creates the default configuration. 743 * This assumes an empty tree. 736 * Populates the CFGM tree with the default configuration. 737 * 738 * This assumes an empty tree and is intended for testcases and such that only 739 * need to do very small adjustments to the config. 744 740 * 745 741 * @returns VBox status code. 746 742 * @param pVM VM handle. 747 743 */ 748 static int cfgmR3CreateDefaultTree(PVM pVM)744 VMMR3DECL(int) CFGMR3ConstructDefaultTree(PVM pVM) 749 745 { 750 746 int rc; … … 752 748 #define UPDATERC() do { if (RT_FAILURE(rc) && RT_SUCCESS(rcAll)) rcAll = rc; } while (0) 753 749 754 /* 755 * Root level. 756 */ 757 PCFGMNODE pRoot = (PCFGMNODE)MMR3HeapAllocZ(pVM, MM_TAG_CFGM, sizeof(*pRoot)); 758 if (!pRoot) 759 return VERR_NO_MEMORY; 760 pRoot->pVM = pVM; 761 pRoot->cchName = 0; 762 763 Assert(!pVM->cfgm.s.pRoot); 764 pVM->cfgm.s.pRoot = pRoot; 750 PCFGMNODE pRoot = CFGMR3GetRoot(pVM); 751 AssertReturn(pRoot, VERR_WRONG_ORDER); 765 752 766 753 /* -
trunk/src/VBox/VMM/DBGFSym.cpp
r19193 r19466 25 25 *******************************************************************************/ 26 26 #define LOG_GROUP LOG_GROUP_DBGF 27 #if defined(RT_OS_WINDOWS) && 0//defined(DEBUG_bird) // enabled this is you want to debug win32 guests, the hypervisor of EFI.27 #if defined(RT_OS_WINDOWS) && 1 //defined(DEBUG_bird) // enabled this is you want to debug win32 guests, the hypervisor of EFI. 28 28 # include <Windows.h> 29 29 # define _IMAGEHLP64 -
trunk/src/VBox/VMM/testcase/tstVMM.cpp
r19300 r19466 34 34 #include <iprt/semaphore.h> 35 35 #include <iprt/stream.h> 36 #include <iprt/test.h> 37 #include <iprt/getopt.h> 38 #include <iprt/ctype.h> 36 39 37 40 … … 41 44 #define TESTCASE "tstVMM" 42 45 43 VMMR3DECL(int) VMMDoTest(PVM pVM); 46 47 48 /******************************************************************************* 49 * Global Variables * 50 *******************************************************************************/ 51 static uint32_t g_cCpus = 1; 52 53 54 /******************************************************************************* 55 * Internal Functions * 56 *******************************************************************************/ 57 VMMR3DECL(int) VMMDoTest(PVM pVM); /* Linked into VMM, see ../VMMTests.cpp. */ 58 59 60 /** Dummy timer callback. */ 61 static DECLCALLBACK(void) tstTMDummyCallback(PVM pVM, PTMTIMER pTimer, void *pvUser) 62 { 63 NOREF(pVM); 64 NOREF(pTimer); 65 NOREF(pvUser); 66 } 67 68 69 /** 70 * This is called on each EMT and will beat TM. 71 * 72 * @returns VINF_SUCCESS, test failure is reported via RTTEST. 73 * @param pVM The VM handle. 74 * @param hTest The test handle. 75 */ 76 DECLCALLBACK(int) tstTMWorker(PVM pVM, RTTEST hTest) 77 { 78 VMCPUID idCpu = VMMGetCpuId(pVM); 79 RTTestPrintfNl(hTest, RTTESTLVL_ALWAYS, "idCpu=%d STARTING\n", idCpu); 80 81 /* 82 * Create the test set. 83 */ 84 int rc; 85 PTMTIMER apTimers[5]; 86 for (size_t i = 0; i < RT_ELEMENTS(apTimers); i++) 87 { 88 int rc = TMR3TimerCreateInternal(pVM, i & 1 ? TMCLOCK_VIRTUAL : TMCLOCK_VIRTUAL_SYNC, 89 tstTMDummyCallback, NULL, "test timer", &apTimers[i]); 90 RTTEST_CHECK_RET(hTest, RT_SUCCESS(rc), rc); 91 } 92 93 /* 94 * The run loop. 95 */ 96 unsigned uPrevPct = 0; 97 uint32_t const cLoops = 100000; 98 for (uint32_t iLoop = 0; iLoop < cLoops; iLoop++) 99 { 100 size_t cLeft = RT_ELEMENTS(apTimers); 101 unsigned i = iLoop % RT_ELEMENTS(apTimers); 102 while (cLeft-- > 0) 103 { 104 PTMTIMER pTimer = apTimers[i]; 105 106 if (cLeft == RT_ELEMENTS(apTimers) / 2 107 && TMTimerIsActive(pTimer)) 108 { 109 rc = TMTimerStop(pTimer); 110 RTTEST_CHECK_MSG(hTest, RT_SUCCESS(rc), (hTest, "TMTimerStop: %Rrc\n", rc)); 111 } 112 else 113 { 114 rc = TMTimerSetMicro(pTimer, 50 + cLeft); 115 RTTEST_CHECK_MSG(hTest, RT_SUCCESS(rc), (hTest, "TMTimerSetMicro: %Rrc\n", rc)); 116 } 117 118 /* next */ 119 i = (i + 1) % RT_ELEMENTS(apTimers); 120 } 121 122 if (i % 3) 123 TMR3TimerQueuesDo(pVM); 124 125 /* Progress report. */ 126 unsigned uPct = (unsigned)(100.0 * iLoop / cLoops); 127 if (uPct != uPrevPct) 128 { 129 uPrevPct = uPct; 130 if (!(uPct % 10)) 131 RTTestPrintfNl(hTest, RTTESTLVL_ALWAYS, "idCpu=%d - %3u%%\n", idCpu, uPct); 132 } 133 } 134 135 RTTestPrintfNl(hTest, RTTESTLVL_ALWAYS, "idCpu=%d DONE\n", idCpu); 136 return 0; 137 } 138 44 139 45 140 /** PDMR3LdrEnumModules callback, see FNPDMR3ENUM. */ … … 52 147 } 53 148 149 static DECLCALLBACK(int) 150 tstVMMConfigConstructor(PVM pVM, void *pvUser) 151 { 152 int rc = CFGMR3ConstructDefaultTree(pVM); 153 if ( RT_SUCCESS(rc) 154 && g_cCpus > 1) 155 { 156 PCFGMNODE pRoot = CFGMR3GetRoot(pVM); 157 CFGMR3RemoveValue(pRoot, "NumCPUs"); 158 rc = CFGMR3InsertInteger(pRoot, "NumCPUs", g_cCpus); 159 RTTESTI_CHECK_MSG_RET(RT_SUCCESS(rc), ("CFGMR3InsertInteger(pRoot,\"NumCPUs\",) -> %Rrc\n", rc), rc); 160 161 CFGMR3RemoveValue(pRoot, "HwVirtExtForced"); 162 rc = CFGMR3InsertInteger(pRoot, "HwVirtExtForced", true); 163 RTTESTI_CHECK_MSG_RET(RT_SUCCESS(rc), ("CFGMR3InsertInteger(pRoot,\"HwVirtExtForced\",) -> %Rrc\n", rc), rc); 164 165 PCFGMNODE pHwVirtExt = CFGMR3GetChild(pRoot, "HWVirtExt"); 166 CFGMR3RemoveNode(pHwVirtExt); 167 rc = CFGMR3InsertNode(pRoot, "HWVirtExt", &pHwVirtExt); 168 RTTESTI_CHECK_MSG_RET(RT_SUCCESS(rc), ("CFGMR3InsertNode(pRoot,\"HWVirtExt\",) -> %Rrc\n", rc), rc); 169 rc = CFGMR3InsertInteger(pHwVirtExt, "Enabled", true); 170 RTTESTI_CHECK_MSG_RET(RT_SUCCESS(rc), ("CFGMR3InsertInteger(pHwVirtExt,\"Enabled\",) -> %Rrc\n", rc), rc); 171 rc = CFGMR3InsertInteger(pHwVirtExt, "64bitEnabled", false); 172 RTTESTI_CHECK_MSG_RET(RT_SUCCESS(rc), ("CFGMR3InsertInteger(pHwVirtExt,\"64bitEnabled\",) -> %Rrc\n", rc), rc); 173 } 174 return rc; 175 } 176 54 177 55 178 int main(int argc, char **argv) 56 179 { 57 int rcRet = 0; /* error count. */ 58 59 RTR3InitAndSUPLib(); 60 61 /* 62 * Create empty VM. 180 /* 181 * Init runtime and the test environment. 182 */ 183 int rc = RTR3InitAndSUPLib(); 184 if (RT_FAILURE(rc)) 185 { 186 RTPrintf("tstVMM: RTR3InitAndSUPLib failed: %Rrc\n", rc); 187 return 1; 188 } 189 RTTEST hTest; 190 rc = RTTestCreate("tstVMM", &hTest); 191 if (RT_FAILURE(rc)) 192 { 193 RTPrintf("tstVMM: RTTestCreate failed: %Rrc\n", rc); 194 return 1; 195 } 196 197 /* 198 * Parse arguments. 199 */ 200 static const RTGETOPTDEF s_aOptions[] = 201 { 202 { "--cpus", 'c', RTGETOPT_REQ_UINT8 }, 203 { "--test", 't', RTGETOPT_REQ_STRING }, 204 { "--help", 'h', 0 }, 205 }; 206 enum 207 { 208 kTstVMMTest_VMM, kTstVMMTest_TM 209 } enmTestOpt = kTstVMMTest_VMM; 210 211 int ch; 212 int i = 1; 213 RTGETOPTUNION ValueUnion; 214 RTGETOPTSTATE GetState; 215 RTGetOptInit(&GetState, argc, argv, s_aOptions, RT_ELEMENTS(s_aOptions), 1, 0); 216 while ((ch = RTGetOpt(&GetState, &ValueUnion))) 217 { 218 switch (ch) 219 { 220 case 'c': 221 g_cCpus = ValueUnion.u8; 222 break; 223 224 case 't': 225 if (!strcmp("vmm", ValueUnion.psz)) 226 enmTestOpt = kTstVMMTest_VMM; 227 else if (!strcmp("tm", ValueUnion.psz)) 228 enmTestOpt = kTstVMMTest_TM; 229 else 230 { 231 RTPrintf("tstVMM: unknown test: '%s'\n", ValueUnion.psz); 232 return 1; 233 } 234 break; 235 236 case 'h': 237 RTPrintf("usage: tstVMM [--cpus|-c cpus] [--test <vmm|tm>]\n"); 238 return 1; 239 240 case VINF_GETOPT_NOT_OPTION: 241 RTPrintf("tstVMM: syntax error: non option '%s'\n", ValueUnion.psz); 242 break; 243 244 default: 245 if (ch > 0) 246 { 247 if (RT_C_IS_GRAPH(ch)) 248 RTPrintf("tstVMM: unhandled option: -%c\n", ch); 249 else 250 RTPrintf("tstVMM: unhandled option: %i\n", ch); 251 } 252 else if (ch == VERR_GETOPT_UNKNOWN_OPTION) 253 RTPrintf("tstVMM: unknown option: %s\n", ValueUnion.psz); 254 else if (ValueUnion.pDef) 255 RTPrintf("tstVMM: %s: %Rrs\n", ValueUnion.pDef->pszLong, ch); 256 else 257 RTPrintf("tstVMM: %Rrs\n", ch); 258 return 1; 259 } 260 } 261 262 /* 263 * Create the test VM. 63 264 */ 64 265 RTPrintf(TESTCASE ": Initializing...\n"); 65 266 PVM pVM; 66 int rc = VMR3Create(1, NULL, NULL, NULL, NULL, &pVM);267 rc = VMR3Create(g_cCpus, NULL, NULL, tstVMMConfigConstructor, NULL, &pVM); 67 268 if (RT_SUCCESS(rc)) 68 269 { … … 72 273 73 274 /* 74 * Do t esting.275 * Do the requested testing. 75 276 */ 76 RTPrintf(TESTCASE ": Testing...\n"); 77 PVMREQ pReq1 = NULL; 78 rc = VMR3ReqCall(pVM, VMCPUID_ANY, &pReq1, RT_INDEFINITE_WAIT, (PFNRT)VMMDoTest, 1, pVM); 79 AssertRC(rc); 80 VMR3ReqFree(pReq1); 277 switch (enmTestOpt) 278 { 279 case kTstVMMTest_VMM: 280 { 281 RTTestSub(hTest, "VMM"); 282 PVMREQ pReq1 = NULL; 283 rc = VMR3ReqCall(pVM, VMCPUID_ANY, &pReq1, RT_INDEFINITE_WAIT, (PFNRT)VMMDoTest, 1, pVM); 284 if (RT_FAILURE(rc)) 285 RTTestFailed(hTest, "VMR3ReqCall failed: rc=%Rrc\n", rc); 286 else if (RT_FAILURE(pReq1->iStatus)) 287 RTTestFailed(hTest, "VMMDoTest failed: rc=%Rrc\n", rc); 288 VMR3ReqFree(pReq1); 289 break; 290 } 291 292 case kTstVMMTest_TM: 293 { 294 RTTestSub(hTest, "TM"); 295 for (VMCPUID idCpu = 1; idCpu < g_cCpus; idCpu++) 296 { 297 PVMREQ pReq = NULL; 298 rc = VMR3ReqCallU(pVM->pUVM, idCpu, &pReq, 0, VMREQFLAGS_NO_WAIT, (PFNRT)tstTMWorker, 2, pVM, hTest); 299 if (RT_FAILURE(rc)) 300 RTTestFailed(hTest, "VMR3ReqCall failed: rc=%Rrc\n", rc); 301 } 302 303 PVMREQ pReq1 = NULL; 304 rc = VMR3ReqCall(pVM, 0, &pReq1, RT_INDEFINITE_WAIT, (PFNRT)tstTMWorker, 2, pVM, hTest); 305 if (RT_FAILURE(rc)) 306 RTTestFailed(hTest, "VMR3ReqCall failed: rc=%Rrc\n", rc); 307 else if (RT_FAILURE(pReq1->iStatus)) 308 RTTestFailed(hTest, "VMMDoTest failed: rc=%Rrc\n", rc); 309 VMR3ReqFree(pReq1); 310 break; 311 } 312 } 81 313 82 314 STAMR3Dump(pVM, "*"); … … 86 318 */ 87 319 rc = VMR3Destroy(pVM); 88 if (!RT_SUCCESS(rc)) 89 { 90 RTPrintf(TESTCASE ": error: failed to destroy vm! rc=%Rrc\n", rc); 91 rcRet++; 92 } 320 if (RT_FAILURE(rc)) 321 RTTestFailed(hTest, "VMR3Destroy failed: rc=%Rrc\n", rc); 93 322 } 94 323 else 95 { 96 RTPrintf(TESTCASE ": fatal error: failed to create vm! rc=%Rrc\n", rc); 97 rcRet++; 98 } 99 100 return rcRet; 101 } 324 RTTestFailed(hTest, "VMR3Create failed: rc=%Rrc\n", rc); 325 326 return RTTestSummaryAndDestroy(hTest); 327 }
Note:
See TracChangeset
for help on using the changeset viewer.