1 | /* $Id: tstVBInsTstR3.cpp 46571 2013-06-14 16:49:48Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * Instruction Test Environment - IPRT ring-3 driver.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2013 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 |
|
---|
18 |
|
---|
19 | /*******************************************************************************
|
---|
20 | * Header Files *
|
---|
21 | *******************************************************************************/
|
---|
22 | #include <iprt/mem.h>
|
---|
23 | #include <iprt/string.h>
|
---|
24 | #include <iprt/test.h>
|
---|
25 |
|
---|
26 | #ifdef RT_OS_WINDOWS
|
---|
27 | # define NO_LOW_MEM
|
---|
28 | #elif defined(RT_OS_OS2) || defined(RT_OS_HAIKU)
|
---|
29 | # define NO_LOW_MEM
|
---|
30 | #else
|
---|
31 | # include <sys/mman.h>
|
---|
32 | #endif
|
---|
33 |
|
---|
34 |
|
---|
35 | /*******************************************************************************
|
---|
36 | * Structures and Typedefs *
|
---|
37 | *******************************************************************************/
|
---|
38 | #if HC_ARCH_BITS == 64
|
---|
39 | typedef uint64_t VBINSTSTREG;
|
---|
40 | #else
|
---|
41 | typedef uint32_t VBINSTSTREG;
|
---|
42 | #endif
|
---|
43 |
|
---|
44 |
|
---|
45 | /*******************************************************************************
|
---|
46 | * Global Variables *
|
---|
47 | *******************************************************************************/
|
---|
48 | RTTEST g_hTest;
|
---|
49 |
|
---|
50 |
|
---|
51 | RT_C_DECLS_BEGIN
|
---|
52 | extern void *g_pvLowMem4K;
|
---|
53 | DECLASM(void) TestInstrMain(void);
|
---|
54 |
|
---|
55 | DECLEXPORT(void) VBInsTstFailure(const char *pszMessage);
|
---|
56 | DECLEXPORT(void) VBInsTstFailure1(const char *pszFmt, VBINSTSTREG uArg1);
|
---|
57 | DECLEXPORT(void) VBInsTstFailure2(const char *pszFmt, VBINSTSTREG uArg1, VBINSTSTREG uArg2);
|
---|
58 | DECLEXPORT(void) VBInsTstFailure3(const char *pszFmt, VBINSTSTREG uArg1, VBINSTSTREG uArg2, VBINSTSTREG uArg3);
|
---|
59 | DECLEXPORT(void) VBInsTstFailure4(const char *pszFmt, VBINSTSTREG uArg1, VBINSTSTREG uArg2, VBINSTSTREG uArg3, VBINSTSTREG uArg4);
|
---|
60 | RT_C_DECLS_END
|
---|
61 |
|
---|
62 |
|
---|
63 | DECLEXPORT(void) VBInsTstFailure(const char *pszMessage)
|
---|
64 | {
|
---|
65 | RTTestFailed(g_hTest, "%s", pszMessage);
|
---|
66 | }
|
---|
67 |
|
---|
68 | DECLEXPORT(void) VBInsTstFailure1(const char *pszFmt, VBINSTSTREG uArg1)
|
---|
69 | {
|
---|
70 | RTTestFailed(g_hTest, pszFmt, uArg1);
|
---|
71 | }
|
---|
72 |
|
---|
73 |
|
---|
74 | DECLEXPORT(void) VBInsTstFailure2(const char *pszFmt, VBINSTSTREG uArg1, VBINSTSTREG uArg2)
|
---|
75 | {
|
---|
76 | RTTestFailed(g_hTest, pszFmt, uArg1, uArg2);
|
---|
77 | }
|
---|
78 |
|
---|
79 |
|
---|
80 | DECLEXPORT(void) VBInsTstFailure3(const char *pszFmt, VBINSTSTREG uArg1, VBINSTSTREG uArg2, VBINSTSTREG uArg3)
|
---|
81 | {
|
---|
82 | RTTestFailed(g_hTest, pszFmt, uArg1, uArg2, uArg3);
|
---|
83 | }
|
---|
84 |
|
---|
85 |
|
---|
86 | DECLEXPORT(void) VBInsTstFailure4(const char *pszFmt, VBINSTSTREG uArg1, VBINSTSTREG uArg2, VBINSTSTREG uArg3, VBINSTSTREG uArg4)
|
---|
87 | {
|
---|
88 | RTTestFailed(g_hTest, pszFmt, uArg1, uArg2, uArg3, uArg4);
|
---|
89 | }
|
---|
90 |
|
---|
91 |
|
---|
92 |
|
---|
93 |
|
---|
94 | int main()
|
---|
95 | {
|
---|
96 | RTEXITCODE rcExit = RTTestInitAndCreate("VBInsTstR3", &g_hTest);
|
---|
97 | if (rcExit != RTEXITCODE_SUCCESS)
|
---|
98 | return rcExit;
|
---|
99 | RTTestBanner(g_hTest);
|
---|
100 |
|
---|
101 | int rc = RTMemAllocEx(_4K, 0, RTMEMALLOCEX_FLAGS_16BIT_REACH, &g_pvLowMem4K);
|
---|
102 | if (RT_FAILURE(rc))
|
---|
103 | {
|
---|
104 | RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Could not allocate low memory (%Rrc)\n", rc);
|
---|
105 | g_pvLowMem4K = NULL;
|
---|
106 | }
|
---|
107 |
|
---|
108 | TestInstrMain();
|
---|
109 |
|
---|
110 | return RTTestSummaryAndDestroy(g_hTest);
|
---|
111 | }
|
---|
112 |
|
---|