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-2007 Sun Microsystems, Inc.
|
---|
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 (GPL) as published by the Free Software
|
---|
14 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
15 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
16 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
17 | *
|
---|
18 | * The contents of this file may alternatively be used under the terms
|
---|
19 | * of the Common Development and Distribution License Version 1.0
|
---|
20 | * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
|
---|
21 | * VirtualBox OSE distribution, in which case the provisions of the
|
---|
22 | * CDDL are applicable instead of those of the GPL.
|
---|
23 | *
|
---|
24 | * You may elect to license modified versions of this file under the
|
---|
25 | * terms and conditions of either the GPL or the CDDL or both.
|
---|
26 | *
|
---|
27 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
|
---|
28 | * Clara, CA 95054 USA or visit http://www.sun.com if you need
|
---|
29 | * additional information or have any questions.
|
---|
30 | */
|
---|
31 |
|
---|
32 |
|
---|
33 | /*******************************************************************************
|
---|
34 | * Header Files *
|
---|
35 | *******************************************************************************/
|
---|
36 | #include <VBox/sup.h>
|
---|
37 | #include <VBox/param.h>
|
---|
38 | #include <iprt/initterm.h>
|
---|
39 | #include <iprt/stream.h>
|
---|
40 | #include <string.h>
|
---|
41 |
|
---|
42 |
|
---|
43 | int main(int argc, char **argv)
|
---|
44 | {
|
---|
45 | int cErrors = 0;
|
---|
46 | int rc = 0;
|
---|
47 | RTR3InitAndSUPLib();
|
---|
48 | rc = SUPR3Init(NULL);
|
---|
49 | cErrors += rc != 0;
|
---|
50 | if (!rc)
|
---|
51 | {
|
---|
52 | void *pv;
|
---|
53 | rc = SUPPageAlloc(1, &pv);
|
---|
54 | cErrors += rc != 0;
|
---|
55 | if (!rc)
|
---|
56 | {
|
---|
57 | memset(pv, 0xff, PAGE_SIZE);
|
---|
58 | rc = SUPPageFree(pv, 1);
|
---|
59 | cErrors += rc != 0;
|
---|
60 | if (rc)
|
---|
61 | RTPrintf("tstPage: SUPPageFree() failed rc=%d\n", rc);
|
---|
62 | }
|
---|
63 | else
|
---|
64 | RTPrintf("tstPage: SUPPageAlloc(1,) failed rc=%d\n", rc);
|
---|
65 |
|
---|
66 | /*
|
---|
67 | * Big chunk.
|
---|
68 | */
|
---|
69 | rc = SUPPageAlloc(1023, &pv);
|
---|
70 | cErrors += rc != 0;
|
---|
71 | if (!rc)
|
---|
72 | {
|
---|
73 | memset(pv, 0xfe, 1023 << PAGE_SHIFT);
|
---|
74 | rc = SUPPageFree(pv, 1023);
|
---|
75 | cErrors += rc != 0;
|
---|
76 | if (rc)
|
---|
77 | RTPrintf("tstPage: SUPPageFree() failed rc=%d\n", rc);
|
---|
78 | }
|
---|
79 | else
|
---|
80 | RTPrintf("tstPage: SUPPageAlloc(1,) failed rc=%d\n", rc);
|
---|
81 |
|
---|
82 |
|
---|
83 | //rc = SUPTerm();
|
---|
84 | cErrors += rc != 0;
|
---|
85 | if (rc)
|
---|
86 | RTPrintf("tstPage: SUPTerm failed rc=%d\n", rc);
|
---|
87 | }
|
---|
88 | else
|
---|
89 | RTPrintf("tstPage: SUPR3Init failed rc=%d\n", rc);
|
---|
90 |
|
---|
91 | if (!cErrors)
|
---|
92 | RTPrintf("tstPage: SUCCESS\n");
|
---|
93 | else
|
---|
94 | RTPrintf("tstPage: FAILURE - %d errors\n", cErrors);
|
---|
95 | return !!cErrors;
|
---|
96 | }
|
---|