VirtualBox

source: vbox/trunk/src/VBox/HostDrivers/Support/testcase/tstPage.cpp@ 23977

Last change on this file since 23977 was 20864, checked in by vboxsync, 16 years ago

SUP,*: API cleanup.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.0 KB
Line 
1/* $Id: tstPage.cpp 20864 2009-06-23 19:19:42Z vboxsync $ */
2/** @file
3 * SUP Testcase - Page allocation interface (ring 3).
4 */
5
6/*
7 * Copyright (C) 2006-2009 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 * 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 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
27 * Clara, CA 95054 USA or visit http://www.sun.com if you need
28 * additional information or have any questions.
29 */
30
31
32/*******************************************************************************
33* Header Files *
34*******************************************************************************/
35#include <VBox/sup.h>
36#include <VBox/param.h>
37#include <iprt/initterm.h>
38#include <iprt/stream.h>
39#include <string.h>
40
41
42int main(int argc, char **argv)
43{
44 int cErrors = 0;
45 int rc = 0;
46 RTR3InitAndSUPLib();
47 rc = SUPR3Init(NULL);
48 cErrors += rc != 0;
49 if (!rc)
50 {
51 void *pv;
52 rc = SUPR3PageAlloc(1, &pv);
53 cErrors += rc != 0;
54 if (!rc)
55 {
56 memset(pv, 0xff, PAGE_SIZE);
57 rc = SUPR3PageFree(pv, 1);
58 cErrors += rc != 0;
59 if (rc)
60 RTPrintf("tstPage: SUPR3PageFree() failed rc=%d\n", rc);
61 }
62 else
63 RTPrintf("tstPage: SUPR3PageAlloc(1,) failed rc=%d\n", rc);
64
65 /*
66 * Big chunk.
67 */
68 rc = SUPR3PageAlloc(1023, &pv);
69 cErrors += rc != 0;
70 if (!rc)
71 {
72 memset(pv, 0xfe, 1023 << PAGE_SHIFT);
73 rc = SUPR3PageFree(pv, 1023);
74 cErrors += rc != 0;
75 if (rc)
76 RTPrintf("tstPage: SUPR3PageFree() failed rc=%d\n", rc);
77 }
78 else
79 RTPrintf("tstPage: SUPR3PageAlloc(1,) failed rc=%d\n", rc);
80
81
82 //rc = SUPR3Term();
83 cErrors += rc != 0;
84 if (rc)
85 RTPrintf("tstPage: SUPR3Term failed rc=%d\n", rc);
86 }
87 else
88 RTPrintf("tstPage: SUPR3Init failed rc=%d\n", rc);
89
90 if (!cErrors)
91 RTPrintf("tstPage: SUCCESS\n");
92 else
93 RTPrintf("tstPage: FAILURE - %d errors\n", cErrors);
94 return !!cErrors;
95}
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette