1 | /* $Id: tstVMM.cpp 14498 2008-11-24 00:15:19Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VMM Testcase.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2007 Sun Microsystems, Inc.
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | *
|
---|
17 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
|
---|
18 | * Clara, CA 95054 USA or visit http://www.sun.com if you need
|
---|
19 | * additional information or have any questions.
|
---|
20 | */
|
---|
21 |
|
---|
22 |
|
---|
23 | /*******************************************************************************
|
---|
24 | * Header Files *
|
---|
25 | *******************************************************************************/
|
---|
26 | #include <VBox/vm.h>
|
---|
27 | #include <VBox/vmm.h>
|
---|
28 | #include <VBox/cpum.h>
|
---|
29 | #include <VBox/pdm.h>
|
---|
30 | #include <VBox/err.h>
|
---|
31 | #include <VBox/log.h>
|
---|
32 | #include <iprt/assert.h>
|
---|
33 | #include <iprt/runtime.h>
|
---|
34 | #include <iprt/semaphore.h>
|
---|
35 | #include <iprt/stream.h>
|
---|
36 |
|
---|
37 |
|
---|
38 | /*******************************************************************************
|
---|
39 | * Defined Constants And Macros *
|
---|
40 | *******************************************************************************/
|
---|
41 | #define TESTCASE "tstVMM"
|
---|
42 |
|
---|
43 | VMMR3DECL(int) VMMDoTest(PVM pVM);
|
---|
44 |
|
---|
45 | /** PDMR3LdrEnumModules callback, see FNPDMR3ENUM. */
|
---|
46 | static DECLCALLBACK(int)
|
---|
47 | tstVMMLdrEnum(PVM pVM, const char *pszFilename, const char *pszName, RTUINTPTR ImageBase, size_t cbImage, bool fGC, void *pvUser)
|
---|
48 | {
|
---|
49 | NOREF(pVM); NOREF(pszFilename); NOREF(fGC); NOREF(pvUser);
|
---|
50 | RTPrintf("tstVMM: %RTptr %s\n", ImageBase, pszName);
|
---|
51 | return VINF_SUCCESS;
|
---|
52 | }
|
---|
53 |
|
---|
54 |
|
---|
55 | int main(int argc, char **argv)
|
---|
56 | {
|
---|
57 | int rcRet = 0; /* error count. */
|
---|
58 |
|
---|
59 | RTR3InitAndSUPLib();
|
---|
60 |
|
---|
61 | /*
|
---|
62 | * Create empty VM.
|
---|
63 | */
|
---|
64 | RTPrintf(TESTCASE ": Initializing...\n");
|
---|
65 | PVM pVM;
|
---|
66 | int rc = VMR3Create(1, NULL, NULL, NULL, NULL, &pVM);
|
---|
67 | if (RT_SUCCESS(rc))
|
---|
68 | {
|
---|
69 | PDMR3LdrEnumModules(pVM, tstVMMLdrEnum, NULL);
|
---|
70 | RTStrmFlush(g_pStdOut);
|
---|
71 | RTThreadSleep(256);
|
---|
72 |
|
---|
73 | /*
|
---|
74 | * Do testing.
|
---|
75 | */
|
---|
76 | RTPrintf(TESTCASE ": Testing...\n");
|
---|
77 | PVMREQ pReq1 = NULL;
|
---|
78 | rc = VMR3ReqCall(pVM, VMREQDEST_ANY, &pReq1, RT_INDEFINITE_WAIT, (PFNRT)VMMDoTest, 1, pVM);
|
---|
79 | AssertRC(rc);
|
---|
80 | VMR3ReqFree(pReq1);
|
---|
81 |
|
---|
82 | STAMR3Dump(pVM, "*");
|
---|
83 |
|
---|
84 | /*
|
---|
85 | * Cleanup.
|
---|
86 | */
|
---|
87 | rc = VMR3Destroy(pVM);
|
---|
88 | if (!RT_SUCCESS(rc))
|
---|
89 | {
|
---|
90 | RTPrintf(TESTCASE ": error: failed to destroy vm! rc=%d\n", rc);
|
---|
91 | rcRet++;
|
---|
92 | }
|
---|
93 | }
|
---|
94 | else
|
---|
95 | {
|
---|
96 | RTPrintf(TESTCASE ": fatal error: failed to create vm! rc=%d\n", rc);
|
---|
97 | rcRet++;
|
---|
98 | }
|
---|
99 |
|
---|
100 | return rcRet;
|
---|
101 | }
|
---|