summaryrefslogtreecommitdiff
path: root/src/VBox/VMM/testcase/tstVMM.cpp
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@baserock.org>2014-03-26 19:21:20 +0000
committer <>2014-05-08 15:03:54 +0000
commitfb123f93f9f5ce42c8e5785d2f8e0edaf951740e (patch)
treec2103d76aec5f1f10892cd1d3a38e24f665ae5db /src/VBox/VMM/testcase/tstVMM.cpp
parent58ed4748338f9466599adfc8a9171280ed99e23f (diff)
downloadVirtualBox-master.tar.gz
Imported from /home/lorry/working-area/delta_VirtualBox/VirtualBox-4.3.10.tar.bz2.HEADVirtualBox-4.3.10master
Diffstat (limited to 'src/VBox/VMM/testcase/tstVMM.cpp')
-rw-r--r--src/VBox/VMM/testcase/tstVMM.cpp112
1 files changed, 69 insertions, 43 deletions
diff --git a/src/VBox/VMM/testcase/tstVMM.cpp b/src/VBox/VMM/testcase/tstVMM.cpp
index e5ed29a0..2e77560f 100644
--- a/src/VBox/VMM/testcase/tstVMM.cpp
+++ b/src/VBox/VMM/testcase/tstVMM.cpp
@@ -4,7 +4,7 @@
*/
/*
- * Copyright (C) 2006-2007 Oracle Corporation
+ * Copyright (C) 2006-2013 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
@@ -54,7 +54,8 @@ static uint32_t g_cCpus = 1;
/*******************************************************************************
* Internal Functions *
*******************************************************************************/
-VMMR3DECL(int) VMMDoTest(PVM pVM); /* Linked into VMM, see ../VMMTests.cpp. */
+VMMR3DECL(int) VMMDoTest(PVM pVM); /* Linked into VMM, see ../VMMTests.cpp. */
+VMMR3DECL(int) VMMDoBruteForceMsrs(PVM pVM); /* Ditto. */
/** Dummy timer callback. */
@@ -139,38 +140,51 @@ DECLCALLBACK(int) tstTMWorker(PVM pVM, RTTEST hTest)
/** PDMR3LdrEnumModules callback, see FNPDMR3ENUM. */
static DECLCALLBACK(int)
-tstVMMLdrEnum(PVM pVM, const char *pszFilename, const char *pszName, RTUINTPTR ImageBase, size_t cbImage, bool fGC, void *pvUser)
+tstVMMLdrEnum(PVM pVM, const char *pszFilename, const char *pszName, RTUINTPTR ImageBase, size_t cbImage,
+ PDMLDRCTX enmCtx, void *pvUser)
{
- NOREF(pVM); NOREF(pszFilename); NOREF(fGC); NOREF(pvUser); NOREF(cbImage);
+ NOREF(pVM); NOREF(pszFilename); NOREF(enmCtx); NOREF(pvUser); NOREF(cbImage);
RTPrintf("tstVMM: %RTptr %s\n", ImageBase, pszName);
return VINF_SUCCESS;
}
static DECLCALLBACK(int)
-tstVMMConfigConstructor(PVM pVM, void *pvUser)
+tstVMMConfigConstructor(PUVM pUVM, PVM pVM, void *pvUser)
{
NOREF(pvUser);
int rc = CFGMR3ConstructDefaultTree(pVM);
- if ( RT_SUCCESS(rc)
- && g_cCpus > 1)
+ if (RT_SUCCESS(rc))
{
PCFGMNODE pRoot = CFGMR3GetRoot(pVM);
- CFGMR3RemoveValue(pRoot, "NumCPUs");
- rc = CFGMR3InsertInteger(pRoot, "NumCPUs", g_cCpus);
- RTTESTI_CHECK_MSG_RET(RT_SUCCESS(rc), ("CFGMR3InsertInteger(pRoot,\"NumCPUs\",) -> %Rrc\n", rc), rc);
-
- CFGMR3RemoveValue(pRoot, "HwVirtExtForced");
- rc = CFGMR3InsertInteger(pRoot, "HwVirtExtForced", true);
- RTTESTI_CHECK_MSG_RET(RT_SUCCESS(rc), ("CFGMR3InsertInteger(pRoot,\"HwVirtExtForced\",) -> %Rrc\n", rc), rc);
-
- PCFGMNODE pHwVirtExt = CFGMR3GetChild(pRoot, "HWVirtExt");
- CFGMR3RemoveNode(pHwVirtExt);
- rc = CFGMR3InsertNode(pRoot, "HWVirtExt", &pHwVirtExt);
- RTTESTI_CHECK_MSG_RET(RT_SUCCESS(rc), ("CFGMR3InsertNode(pRoot,\"HWVirtExt\",) -> %Rrc\n", rc), rc);
- rc = CFGMR3InsertInteger(pHwVirtExt, "Enabled", true);
- RTTESTI_CHECK_MSG_RET(RT_SUCCESS(rc), ("CFGMR3InsertInteger(pHwVirtExt,\"Enabled\",) -> %Rrc\n", rc), rc);
- rc = CFGMR3InsertInteger(pHwVirtExt, "64bitEnabled", false);
- RTTESTI_CHECK_MSG_RET(RT_SUCCESS(rc), ("CFGMR3InsertInteger(pHwVirtExt,\"64bitEnabled\",) -> %Rrc\n", rc), rc);
+ if (g_cCpus < 2)
+ {
+ rc = CFGMR3InsertInteger(pRoot, "HMEnabled", false);
+ RTTESTI_CHECK_MSG_RET(RT_SUCCESS(rc),
+ ("CFGMR3InsertInteger(pRoot,\"HMEnabled\",) -> %Rrc\n", rc), rc);
+ }
+ else if (g_cCpus > 1)
+ {
+ CFGMR3RemoveValue(pRoot, "NumCPUs");
+ rc = CFGMR3InsertInteger(pRoot, "NumCPUs", g_cCpus);
+ RTTESTI_CHECK_MSG_RET(RT_SUCCESS(rc),
+ ("CFGMR3InsertInteger(pRoot,\"NumCPUs\",) -> %Rrc\n", rc), rc);
+
+ CFGMR3RemoveValue(pRoot, "HwVirtExtForced");
+ rc = CFGMR3InsertInteger(pRoot, "HwVirtExtForced", true);
+ RTTESTI_CHECK_MSG_RET(RT_SUCCESS(rc),
+ ("CFGMR3InsertInteger(pRoot,\"HwVirtExtForced\",) -> %Rrc\n", rc), rc);
+ PCFGMNODE pHwVirtExt = CFGMR3GetChild(pRoot, "HWVirtExt");
+ CFGMR3RemoveNode(pHwVirtExt);
+ rc = CFGMR3InsertNode(pRoot, "HWVirtExt", &pHwVirtExt);
+ RTTESTI_CHECK_MSG_RET(RT_SUCCESS(rc),
+ ("CFGMR3InsertNode(pRoot,\"HWVirtExt\",) -> %Rrc\n", rc), rc);
+ rc = CFGMR3InsertInteger(pHwVirtExt, "Enabled", true);
+ RTTESTI_CHECK_MSG_RET(RT_SUCCESS(rc),
+ ("CFGMR3InsertInteger(pHwVirtExt,\"Enabled\",) -> %Rrc\n", rc), rc);
+ rc = CFGMR3InsertInteger(pHwVirtExt, "64bitEnabled", false);
+ RTTESTI_CHECK_MSG_RET(RT_SUCCESS(rc),
+ ("CFGMR3InsertInteger(pHwVirtExt,\"64bitEnabled\",) -> %Rrc\n", rc), rc);
+ }
}
return rc;
}
@@ -181,16 +195,10 @@ int main(int argc, char **argv)
/*
* Init runtime and the test environment.
*/
- int rc = RTR3InitExe(argc, &argv, RTR3INIT_FLAGS_SUPLIB);
- if (RT_FAILURE(rc))
- return RTMsgInitFailure(rc);
RTTEST hTest;
- rc = RTTestCreate("tstVMM", &hTest);
- if (RT_FAILURE(rc))
- {
- RTPrintf("tstVMM: RTTestCreate failed: %Rrc\n", rc);
- return 1;
- }
+ RTEXITCODE rcExit = RTTestInitExAndCreate(argc, &argv, RTR3INIT_FLAGS_SUPLIB, "tstVMM", &hTest);
+ if (rcExit != RTEXITCODE_SUCCESS)
+ return rcExit;
/*
* Parse arguments.
@@ -202,7 +210,7 @@ int main(int argc, char **argv)
};
enum
{
- kTstVMMTest_VMM, kTstVMMTest_TM
+ kTstVMMTest_VMM, kTstVMMTest_TM, kTstVMMTest_MSRs
} enmTestOpt = kTstVMMTest_VMM;
int ch;
@@ -222,6 +230,8 @@ int main(int argc, char **argv)
enmTestOpt = kTstVMMTest_VMM;
else if (!strcmp("tm", ValueUnion.psz))
enmTestOpt = kTstVMMTest_TM;
+ else if (!strcmp("msr", ValueUnion.psz) || !strcmp("msrs", ValueUnion.psz))
+ enmTestOpt = kTstVMMTest_MSRs;
else
{
RTPrintf("tstVMM: unknown test: '%s'\n", ValueUnion.psz);
@@ -230,11 +240,11 @@ int main(int argc, char **argv)
break;
case 'h':
- RTPrintf("usage: tstVMM [--cpus|-c cpus] [--test <vmm|tm>]\n");
+ RTPrintf("usage: tstVMM [--cpus|-c cpus] [--test <vmm|tm|msr>]\n");
return 1;
case 'V':
- RTPrintf("$Revision: 78835 $\n");
+ RTPrintf("$Revision: 91444 $\n");
return 0;
default:
@@ -247,7 +257,8 @@ int main(int argc, char **argv)
*/
RTPrintf(TESTCASE ": Initializing...\n");
PVM pVM;
- rc = VMR3Create(g_cCpus, NULL, NULL, NULL, tstVMMConfigConstructor, NULL, &pVM);
+ PUVM pUVM;
+ int rc = VMR3Create(g_cCpus, NULL, NULL, NULL, tstVMMConfigConstructor, NULL, &pVM, &pUVM);
if (RT_SUCCESS(rc))
{
PDMR3LdrEnumModules(pVM, tstVMMLdrEnum, NULL);
@@ -262,9 +273,10 @@ int main(int argc, char **argv)
case kTstVMMTest_VMM:
{
RTTestSub(hTest, "VMM");
- rc = VMR3ReqCallWait(pVM, VMCPUID_ANY, (PFNRT)VMMDoTest, 1, pVM);
+ rc = VMR3ReqCallWaitU(pUVM, VMCPUID_ANY, (PFNRT)VMMDoTest, 1, pVM);
if (RT_FAILURE(rc))
RTTestFailed(hTest, "VMMDoTest failed: rc=%Rrc\n", rc);
+ STAMR3Dump(pUVM, "*");
break;
}
@@ -273,29 +285,43 @@ int main(int argc, char **argv)
RTTestSub(hTest, "TM");
for (VMCPUID idCpu = 1; idCpu < g_cCpus; idCpu++)
{
- rc = VMR3ReqCallNoWait(pVM, idCpu, (PFNRT)tstTMWorker, 2, pVM, hTest);
+ rc = VMR3ReqCallNoWaitU(pUVM, idCpu, (PFNRT)tstTMWorker, 2, pVM, hTest);
if (RT_FAILURE(rc))
RTTestFailed(hTest, "VMR3ReqCall failed: rc=%Rrc\n", rc);
}
- rc = VMR3ReqCallWait(pVM, 0 /*idDstCpu*/, (PFNRT)tstTMWorker, 2, pVM, hTest);
+ rc = VMR3ReqCallWaitU(pUVM, 0 /*idDstCpu*/, (PFNRT)tstTMWorker, 2, pVM, hTest);
if (RT_FAILURE(rc))
RTTestFailed(hTest, "VMMDoTest failed: rc=%Rrc\n", rc);
+ STAMR3Dump(pUVM, "*");
break;
}
- }
- STAMR3Dump(pVM, "*");
+ case kTstVMMTest_MSRs:
+ {
+ RTTestSub(hTest, "MSRs");
+ if (g_cCpus == 1)
+ {
+ rc = VMR3ReqCallWaitU(pUVM, 0 /*idDstCpu*/, (PFNRT)VMMDoBruteForceMsrs, 1, pVM);
+ if (RT_FAILURE(rc))
+ RTTestFailed(hTest, "VMMDoBruteForceMsrs failed: rc=%Rrc\n", rc);
+ }
+ else
+ RTTestFailed(hTest, "The MSR test can only be run with one VCpu!\n");
+ break;
+ }
+ }
/*
* Cleanup.
*/
- rc = VMR3PowerOff(pVM);
+ rc = VMR3PowerOff(pUVM);
if (RT_FAILURE(rc))
RTTestFailed(hTest, "VMR3PowerOff failed: rc=%Rrc\n", rc);
- rc = VMR3Destroy(pVM);
+ rc = VMR3Destroy(pUVM);
if (RT_FAILURE(rc))
RTTestFailed(hTest, "VMR3Destroy failed: rc=%Rrc\n", rc);
+ VMR3ReleaseUVM(pUVM);
}
else
RTTestFailed(hTest, "VMR3Create failed: rc=%Rrc\n", rc);