VirtualBox

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

Last change on this file was 98103, checked in by vboxsync, 17 months ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.7 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-2023 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * SPDX-License-Identifier: GPL-3.0-only
26 */
27
28
29/*********************************************************************************************************************************
30* Header Files *
31*********************************************************************************************************************************/
32#include <VBox/shflsvc.h>
33#include <iprt/string.h>
34#include <iprt/stream.h>
35
36#define STRUCT(t, size) \
37 do { \
38 if (fPrintChecks) \
39 RTPrintf(" STRUCT(" #t ", %d);\n", (int)sizeof(t)); \
40 else if ((size) != sizeof(t)) \
41 { \
42 RTPrintf("%30s: %d expected %d!\n", #t, (int)sizeof(t), (size)); \
43 cErrors++; \
44 } \
45 else if (!fQuiet)\
46 RTPrintf("%30s: %d\n", #t, (int)sizeof(t)); \
47 } while (0)
48
49
50int main(int argc, char **argv)
51{
52 unsigned cErrors = 0;
53
54 /*
55 * Prints the code below if any argument was giving.
56 */
57 bool fQuiet = argc == 2 && !strcmp(argv[1], "quiet");
58 bool fPrintChecks = !fQuiet && argc != 1;
59
60 RTPrintf("tstShflSizes: TESTING\n");
61
62 /*
63 * The checks.
64 */
65 STRUCT(SHFLROOT, 4);
66 STRUCT(SHFLHANDLE, 8);
67 STRUCT(SHFLSTRING, 6);
68 STRUCT(SHFLCREATERESULT, 4);
69 STRUCT(SHFLCREATEPARMS, 108);
70 STRUCT(SHFLMAPPING, 8);
71 STRUCT(SHFLDIRINFO, 128);
72 STRUCT(SHFLVOLINFO, 40);
73 STRUCT(SHFLFSOBJATTR, 44);
74 STRUCT(SHFLFSOBJINFO, 92);
75#ifdef VBOX_WITH_64_BITS_GUESTS
76/* The size of the guest structures depends on the current architecture bit count (ARCH_BITS)
77 * because the HGCMFunctionParameter structure differs in 32 and 64 bit guests.
78 * The host VMMDev device takes care about this.
79 *
80 * Therefore this testcase verifies whether structure sizes are correct for the current ARCH_BITS.
81 */
82# if ARCH_BITS == 64
83 STRUCT(VBoxSFQueryMappings, 88);
84 STRUCT(VBoxSFQueryMapName, 72);
85 STRUCT(VBoxSFMapFolder_Old, 88);
86 STRUCT(VBoxSFMapFolder, 104);
87 STRUCT(VBoxSFUnmapFolder, 56);
88 STRUCT(VBoxSFCreate, 88);
89 STRUCT(VBoxSFClose, 72);
90 STRUCT(VBoxSFRead, 120);
91 STRUCT(VBoxSFWrite, 120);
92 STRUCT(VBoxSFLock, 120);
93 STRUCT(VBoxSFFlush, 72);
94 STRUCT(VBoxSFList, 168);
95 STRUCT(VBoxSFInformation, 120);
96 STRUCT(VBoxSFRemove, 88);
97 STRUCT(VBoxSFRename, 104);
98# elif ARCH_BITS == 32
99 STRUCT(VBoxSFQueryMappings, 24+52);
100 STRUCT(VBoxSFQueryMapName, 24+40); /* this was changed from 52 in 21976 after VBox-1.4. */
101 STRUCT(VBoxSFMapFolder_Old, 24+52);
102 STRUCT(VBoxSFMapFolder, 24+64);
103 STRUCT(VBoxSFUnmapFolder, 24+28);
104 STRUCT(VBoxSFCreate, 24+52);
105 STRUCT(VBoxSFClose, 24+40);
106 STRUCT(VBoxSFRead, 24+76);
107 STRUCT(VBoxSFWrite, 24+76);
108 STRUCT(VBoxSFLock, 24+76);
109 STRUCT(VBoxSFFlush, 24+40);
110 STRUCT(VBoxSFList, 24+112);
111 STRUCT(VBoxSFInformation, 24+76);
112 STRUCT(VBoxSFRemove, 24+52);
113 STRUCT(VBoxSFRename, 24+64);
114# else
115# error "Unsupported ARCH_BITS"
116# endif /* ARCH_BITS */
117#else
118 STRUCT(VBoxSFQueryMappings, 24+52);
119 STRUCT(VBoxSFQueryMapName, 24+40); /* this was changed from 52 in 21976 after VBox-1.4. */
120 STRUCT(VBoxSFMapFolder_Old, 24+52);
121 STRUCT(VBoxSFMapFolder, 24+64);
122 STRUCT(VBoxSFUnmapFolder, 24+28);
123 STRUCT(VBoxSFCreate, 24+52);
124 STRUCT(VBoxSFClose, 24+40);
125 STRUCT(VBoxSFRead, 24+76);
126 STRUCT(VBoxSFWrite, 24+76);
127 STRUCT(VBoxSFLock, 24+76);
128 STRUCT(VBoxSFFlush, 24+40);
129 STRUCT(VBoxSFList, 24+112);
130 STRUCT(VBoxSFInformation, 24+76);
131 STRUCT(VBoxSFRemove, 24+52);
132 STRUCT(VBoxSFRename, 24+64);
133#endif /* VBOX_WITH_64_BITS_GUESTS */
134
135 /*
136 * The summary.
137 */
138 if (!cErrors)
139 RTPrintf("tstShflSizes: SUCCESS\n");
140 else
141 RTPrintf("tstShflSizes: FAILURE - %d errors\n", cErrors);
142 return !!cErrors;
143}
144
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use