VirtualBox

source: vbox/trunk/src/VBox/HostServices/SharedFolders/testcase/tstShflSizes.cpp@ 9734

Last change on this file since 9734 was 9460, checked in by vboxsync, 16 years ago

Fixed tstShflSizes for 64 bits hosts.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.3 KB
Line 
1/** @file
2 *
3 * Testcase for shared folder structure sizes.
4 * Run this on Linux and Windows, then compare.
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 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
19 * Clara, CA 95054 USA or visit http://www.sun.com if you need
20 * additional information or have any questions.
21 */
22
23/*******************************************************************************
24* Header Files *
25*******************************************************************************/
26#include <VBox/shflsvc.h>
27#include <iprt/stream.h>
28#include <iprt/string.h>
29
30#define STRUCT(t, size) \
31 do { \
32 if (fPrintChecks) \
33 RTPrintf(" STRUCT(" #t ", %d);\n", (int)sizeof(t)); \
34 else if ((size) != sizeof(t)) \
35 { \
36 RTPrintf("%30s: %d expected %d!\n", #t, (int)sizeof(t), (size)); \
37 cErrors++; \
38 } \
39 else if (!fQuiet)\
40 RTPrintf("%30s: %d\n", #t, (int)sizeof(t)); \
41 } while (0)
42
43
44int main(int argc, char **argv)
45{
46 unsigned cErrors = 0;
47
48 /*
49 * Prints the code below if any argument was giving.
50 */
51 bool fQuiet = argc == 2 && !strcmp(argv[1], "quiet");
52 bool fPrintChecks = !fQuiet && argc != 1;
53
54 RTPrintf("tstShflSizes: TESTING\n");
55
56 /*
57 * The checks.
58 */
59 STRUCT(SHFLROOT, 4);
60 STRUCT(SHFLHANDLE, 8);
61 STRUCT(SHFLSTRING, 6);
62 STRUCT(SHFLCREATERESULT, 4);
63 STRUCT(SHFLCREATEPARMS, 108);
64 STRUCT(SHFLMAPPING, 8);
65 STRUCT(SHFLDIRINFO, 128);
66 STRUCT(SHFLVOLINFO, 40);
67#ifdef VBOX_WITH_64_BITS_GUESTS
68/* The size of the guest structures depends on the current architecture bit count (ARCH_BITS)
69 * because the HGCMFunctionParameter structure differs in 32 and 64 bit guests.
70 * The host VMMDev device takes care about this.
71 *
72 * Therefore this testcase verifies whether structure sizes are correct for the currebt ARCH_BITS.
73 */
74# if ARCH_BITS == 64
75 STRUCT(VBoxSFQueryMappings, 64);
76 STRUCT(VBoxSFQueryMapName, 48);
77 STRUCT(VBoxSFMapFolder_Old, 64);
78 STRUCT(VBoxSFMapFolder, 80);
79 STRUCT(VBoxSFUnmapFolder, 32);
80 STRUCT(VBoxSFCreate, 64);
81 STRUCT(VBoxSFClose, 48);
82 STRUCT(VBoxSFRead, 96);
83 STRUCT(VBoxSFWrite, 96);
84 STRUCT(VBoxSFLock, 96);
85 STRUCT(VBoxSFFlush, 48);
86 STRUCT(VBoxSFList, 144);
87 STRUCT(VBoxSFInformation, 96);
88 STRUCT(VBoxSFRemove, 64);
89 STRUCT(VBoxSFRename, 80);
90# elif ARCH_BITS == 32
91 STRUCT(VBoxSFQueryMappings, 52);
92 STRUCT(VBoxSFQueryMapName, 40); /* this was changed from 52 in 21976 after VBox-1.4. */
93 STRUCT(VBoxSFMapFolder_Old, 52);
94 STRUCT(VBoxSFMapFolder, 64);
95 STRUCT(VBoxSFUnmapFolder, 28);
96 STRUCT(VBoxSFCreate, 52);
97 STRUCT(VBoxSFClose, 40);
98 STRUCT(VBoxSFRead, 76);
99 STRUCT(VBoxSFWrite, 76);
100 STRUCT(VBoxSFLock, 76);
101 STRUCT(VBoxSFFlush, 40);
102 STRUCT(VBoxSFList, 112);
103 STRUCT(VBoxSFInformation, 76);
104 STRUCT(VBoxSFRemove, 52);
105 STRUCT(VBoxSFRename, 64);
106# else
107# error "Unsupported ARCH_BITS"
108# endif /* ARCH_BITS */
109#else
110 STRUCT(VBoxSFQueryMappings, 52);
111 STRUCT(VBoxSFQueryMapName, 40); /* this was changed from 52 in 21976 after VBox-1.4. */
112 STRUCT(VBoxSFMapFolder_Old, 52);
113 STRUCT(VBoxSFMapFolder, 64);
114 STRUCT(VBoxSFUnmapFolder, 28);
115 STRUCT(VBoxSFCreate, 52);
116 STRUCT(VBoxSFClose, 40);
117 STRUCT(VBoxSFRead, 76);
118 STRUCT(VBoxSFWrite, 76);
119 STRUCT(VBoxSFLock, 76);
120 STRUCT(VBoxSFFlush, 40);
121 STRUCT(VBoxSFList, 112);
122 STRUCT(VBoxSFInformation, 76);
123 STRUCT(VBoxSFRemove, 52);
124 STRUCT(VBoxSFRename, 64);
125#endif /* VBOX_WITH_64_BITS_GUESTS */
126
127 /*
128 * The summary.
129 */
130 if (!cErrors)
131 RTPrintf("tstShflSizes: SUCCESS\n");
132 else
133 RTPrintf("tstShflSizes: FAILURE - %d errors\n", cErrors);
134 return !!cErrors;
135}
136
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