1 | /* $Id: tstPage.cpp 28800 2010-04-27 08:22:32Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * SUP Testcase - Page allocation interface (ring 3).
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2009 Oracle Corporation
|
---|
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 | * The contents of this file may alternatively be used under the terms
|
---|
18 | * of the Common Development and Distribution License Version 1.0
|
---|
19 | * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
|
---|
20 | * VirtualBox OSE distribution, in which case the provisions of the
|
---|
21 | * CDDL are applicable instead of those of the GPL.
|
---|
22 | *
|
---|
23 | * You may elect to license modified versions of this file under the
|
---|
24 | * terms and conditions of either the GPL or the CDDL or both.
|
---|
25 | */
|
---|
26 |
|
---|
27 |
|
---|
28 | /*******************************************************************************
|
---|
29 | * Header Files *
|
---|
30 | *******************************************************************************/
|
---|
31 | #include <VBox/sup.h>
|
---|
32 | #include <VBox/param.h>
|
---|
33 | #include <iprt/initterm.h>
|
---|
34 | #include <iprt/stream.h>
|
---|
35 | #include <string.h>
|
---|
36 |
|
---|
37 |
|
---|
38 | int main(int argc, char **argv)
|
---|
39 | {
|
---|
40 | int cErrors = 0;
|
---|
41 | int rc = 0;
|
---|
42 | RTR3InitAndSUPLib();
|
---|
43 | rc = SUPR3Init(NULL);
|
---|
44 | cErrors += rc != 0;
|
---|
45 | if (!rc)
|
---|
46 | {
|
---|
47 | void *pv;
|
---|
48 | rc = SUPR3PageAlloc(1, &pv);
|
---|
49 | cErrors += rc != 0;
|
---|
50 | if (!rc)
|
---|
51 | {
|
---|
52 | memset(pv, 0xff, PAGE_SIZE);
|
---|
53 | rc = SUPR3PageFree(pv, 1);
|
---|
54 | cErrors += rc != 0;
|
---|
55 | if (rc)
|
---|
56 | RTPrintf("tstPage: SUPR3PageFree() failed rc=%d\n", rc);
|
---|
57 | }
|
---|
58 | else
|
---|
59 | RTPrintf("tstPage: SUPR3PageAlloc(1,) failed rc=%d\n", rc);
|
---|
60 |
|
---|
61 | /*
|
---|
62 | * Big chunk.
|
---|
63 | */
|
---|
64 | rc = SUPR3PageAlloc(1023, &pv);
|
---|
65 | cErrors += rc != 0;
|
---|
66 | if (!rc)
|
---|
67 | {
|
---|
68 | memset(pv, 0xfe, 1023 << PAGE_SHIFT);
|
---|
69 | rc = SUPR3PageFree(pv, 1023);
|
---|
70 | cErrors += rc != 0;
|
---|
71 | if (rc)
|
---|
72 | RTPrintf("tstPage: SUPR3PageFree() failed rc=%d\n", rc);
|
---|
73 | }
|
---|
74 | else
|
---|
75 | RTPrintf("tstPage: SUPR3PageAlloc(1,) failed rc=%d\n", rc);
|
---|
76 |
|
---|
77 |
|
---|
78 | //rc = SUPR3Term();
|
---|
79 | cErrors += rc != 0;
|
---|
80 | if (rc)
|
---|
81 | RTPrintf("tstPage: SUPR3Term failed rc=%d\n", rc);
|
---|
82 | }
|
---|
83 | else
|
---|
84 | RTPrintf("tstPage: SUPR3Init failed rc=%d\n", rc);
|
---|
85 |
|
---|
86 | if (!cErrors)
|
---|
87 | RTPrintf("tstPage: SUCCESS\n");
|
---|
88 | else
|
---|
89 | RTPrintf("tstPage: FAILURE - %d errors\n", cErrors);
|
---|
90 | return !!cErrors;
|
---|
91 | }
|
---|