VirtualBox

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

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

tstShflSize: don't depend on VBoxRT

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