1 | /** @file
|
---|
2 | *
|
---|
3 | * VBox host drivers - Ring-0 support drivers - Testcases:
|
---|
4 | * Test the page allocation interface
|
---|
5 | */
|
---|
6 |
|
---|
7 | /*
|
---|
8 | * Copyright (C) 2006 InnoTek Systemberatung GmbH
|
---|
9 | *
|
---|
10 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
11 | * available from http://www.virtualbox.org. This file is free software;
|
---|
12 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
13 | * General Public License as published by the Free Software Foundation,
|
---|
14 | * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
|
---|
15 | * distribution. VirtualBox OSE is distributed in the hope that it will
|
---|
16 | * be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
17 | *
|
---|
18 | * If you received this file as part of a commercial VirtualBox
|
---|
19 | * distribution, then only the terms of your commercial VirtualBox
|
---|
20 | * license agreement apply instead of the previous paragraph.
|
---|
21 | */
|
---|
22 |
|
---|
23 |
|
---|
24 | /*******************************************************************************
|
---|
25 | * Header Files *
|
---|
26 | *******************************************************************************/
|
---|
27 | #include <VBox/sup.h>
|
---|
28 | #include <VBox/param.h>
|
---|
29 | #include <iprt/runtime.h>
|
---|
30 | #include <iprt/stream.h>
|
---|
31 | #include <string.h>
|
---|
32 |
|
---|
33 |
|
---|
34 | int main(int argc, char **argv)
|
---|
35 | {
|
---|
36 | int cErrors = 0;
|
---|
37 | int rc = 0;
|
---|
38 | RTR3Init(true, _1M*168);
|
---|
39 | rc = SUPInit(NULL, _1M*168);
|
---|
40 | cErrors += rc != 0;
|
---|
41 | if (!rc)
|
---|
42 | {
|
---|
43 | void *pv;
|
---|
44 | rc = SUPPageAlloc(1, &pv);
|
---|
45 | cErrors += rc != 0;
|
---|
46 | if (!rc)
|
---|
47 | {
|
---|
48 | memset(pv, 0xff, PAGE_SIZE);
|
---|
49 | rc = SUPPageFree(pv, 1);
|
---|
50 | cErrors += rc != 0;
|
---|
51 | if (rc)
|
---|
52 | RTPrintf("tstPage: SUPPageFree() failed rc=%d\n", rc);
|
---|
53 | }
|
---|
54 | else
|
---|
55 | RTPrintf("tstPage: SUPPageAlloc(1,) failed rc=%d\n", rc);
|
---|
56 |
|
---|
57 | /*
|
---|
58 | * Big chunk.
|
---|
59 | */
|
---|
60 | rc = SUPPageAlloc(1023, &pv);
|
---|
61 | cErrors += rc != 0;
|
---|
62 | if (!rc)
|
---|
63 | {
|
---|
64 | memset(pv, 0xfe, 1023 << PAGE_SHIFT);
|
---|
65 | rc = SUPPageFree(pv, 1023);
|
---|
66 | cErrors += rc != 0;
|
---|
67 | if (rc)
|
---|
68 | RTPrintf("tstPage: SUPPageFree() failed rc=%d\n", rc);
|
---|
69 | }
|
---|
70 | else
|
---|
71 | RTPrintf("tstPage: SUPPageAlloc(1,) failed rc=%d\n", rc);
|
---|
72 |
|
---|
73 |
|
---|
74 | //rc = SUPTerm();
|
---|
75 | cErrors += rc != 0;
|
---|
76 | if (rc)
|
---|
77 | RTPrintf("tstPage: SUPTerm failed rc=%d\n", rc);
|
---|
78 | }
|
---|
79 | else
|
---|
80 | RTPrintf("tstPage: SUPInit failed rc=%d\n", rc);
|
---|
81 |
|
---|
82 | if (!cErrors)
|
---|
83 | RTPrintf("tstPage: SUCCESS\n");
|
---|
84 | else
|
---|
85 | RTPrintf("tstPage: FAILURE - %d errors\n", cErrors);
|
---|
86 | return !!cErrors;
|
---|
87 | }
|
---|