1 | /** @file
|
---|
2 | *
|
---|
3 | * VBox Debugger GUI, dummy testcase.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2007 Oracle Corporation
|
---|
8 | *
|
---|
9 | * Oracle Corporation confidential
|
---|
10 | * All rights reserved
|
---|
11 | */
|
---|
12 |
|
---|
13 |
|
---|
14 | /*******************************************************************************
|
---|
15 | * Header Files *
|
---|
16 | *******************************************************************************/
|
---|
17 | #include <qapplication.h>
|
---|
18 | #include <VBox/dbggui.h>
|
---|
19 | #include <VBox/vm.h>
|
---|
20 | #include <VBox/err.h>
|
---|
21 | #include <iprt/initterm.h>
|
---|
22 | #include <VBox/log.h>
|
---|
23 | #include <iprt/assert.h>
|
---|
24 | #include <iprt/initterm.h>
|
---|
25 | #include <iprt/semaphore.h>
|
---|
26 | #include <iprt/stream.h>
|
---|
27 |
|
---|
28 |
|
---|
29 | #define TESTCASE "tstVBoxDbg"
|
---|
30 |
|
---|
31 |
|
---|
32 | int main(int argc, char **argv)
|
---|
33 | {
|
---|
34 | int cErrors = 0; /* error count. */
|
---|
35 |
|
---|
36 | RTR3InitAndSUPLib();
|
---|
37 | RTPrintf(TESTCASE ": TESTING...\n");
|
---|
38 |
|
---|
39 | /*
|
---|
40 | * Create empty VM.
|
---|
41 | */
|
---|
42 | PVM pVM;
|
---|
43 | int rc = VMR3Create(1, NULL, NULL, NULL, NULL, &pVM);
|
---|
44 | if (RT_SUCCESS(rc))
|
---|
45 | {
|
---|
46 | /*
|
---|
47 | * Instantiate the debugger GUI bits and run them.
|
---|
48 | */
|
---|
49 | QApplication App(argc, argv);
|
---|
50 | PDBGGUI pGui;
|
---|
51 | PCDBGGUIVT pGuiVT;
|
---|
52 | rc = DBGGuiCreateForVM(pVM, &pGui, &pGuiVT);
|
---|
53 | if (RT_SUCCESS(rc))
|
---|
54 | {
|
---|
55 | if (argc <= 1 || argc == 2)
|
---|
56 | {
|
---|
57 | RTPrintf(TESTCASE ": calling pfnShowCommandLine...\n");
|
---|
58 | rc = pGuiVT->pfnShowCommandLine(pGui);
|
---|
59 | if (RT_FAILURE(rc))
|
---|
60 | {
|
---|
61 | RTPrintf(TESTCASE ": error: pfnShowCommandLine failed! rc=%Rrc\n", rc);
|
---|
62 | cErrors++;
|
---|
63 | }
|
---|
64 | }
|
---|
65 |
|
---|
66 | if (argc <= 1 || argc == 3)
|
---|
67 | {
|
---|
68 | RTPrintf(TESTCASE ": calling pfnShowStatistics...\n");
|
---|
69 | pGuiVT->pfnShowStatistics(pGui);
|
---|
70 | if (RT_FAILURE(rc))
|
---|
71 | {
|
---|
72 | RTPrintf(TESTCASE ": error: pfnShowStatistics failed! rc=%Rrc\n", rc);
|
---|
73 | cErrors++;
|
---|
74 | }
|
---|
75 | }
|
---|
76 |
|
---|
77 | pGuiVT->pfnAdjustRelativePos(pGui, 0, 0, 640, 480);
|
---|
78 | RTPrintf(TESTCASE ": calling App.exec()...\n");
|
---|
79 | App.exec();
|
---|
80 | }
|
---|
81 | else
|
---|
82 | {
|
---|
83 | RTPrintf(TESTCASE ": error: DBGGuiCreateForVM failed! rc=%Rrc\n", rc);
|
---|
84 | cErrors++;
|
---|
85 | }
|
---|
86 |
|
---|
87 | /*
|
---|
88 | * Cleanup.
|
---|
89 | */
|
---|
90 | rc = VMR3Destroy(pVM);
|
---|
91 | if (!RT_SUCCESS(rc))
|
---|
92 | {
|
---|
93 | RTPrintf(TESTCASE ": error: failed to destroy vm! rc=%Rrc\n", rc);
|
---|
94 | cErrors++;
|
---|
95 | }
|
---|
96 | }
|
---|
97 | else
|
---|
98 | {
|
---|
99 | RTPrintf(TESTCASE ": fatal error: failed to create vm! rc=%Rrc\n", rc);
|
---|
100 | cErrors++;
|
---|
101 | }
|
---|
102 |
|
---|
103 | /*
|
---|
104 | * Summay and exit.
|
---|
105 | */
|
---|
106 | if (!cErrors)
|
---|
107 | RTPrintf(TESTCASE ": SUCCESS\n");
|
---|
108 | else
|
---|
109 | RTPrintf(TESTCASE ": FAILURE - %d errors\n", cErrors);
|
---|
110 | return !!cErrors;
|
---|
111 | }
|
---|
112 |
|
---|