tstShflSizes.cpp revision c161379f4055372228230517aa1700c47e3b9b7f
0N/A/** @file
2027N/A * tstShflSize - Testcase for shared folder structure sizes.
0N/A * Run this on Linux and Windows, then compare.
0N/A */
0N/A
0N/A/*
0N/A * Copyright (C) 2006-2007 Oracle Corporation
0N/A *
0N/A * This file is part of VirtualBox Open Source Edition (OSE), as
0N/A * available from http://www.virtualbox.org. This file is free software;
0N/A * you can redistribute it and/or modify it under the terms of the GNU
0N/A * General Public License (GPL) as published by the Free Software
0N/A * Foundation, in version 2 as it comes in the "COPYING" file of the
0N/A * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
0N/A * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
0N/A */
0N/A
0N/A/*******************************************************************************
1472N/A* Header Files *
1472N/A*******************************************************************************/
1472N/A#include <VBox/shflsvc.h>
0N/A#include <iprt/string.h>
0N/A#include <stdio.h>
0N/A
1879N/A#define STRUCT(t, size) \
1879N/A do { \
1879N/A if (fPrintChecks) \
1879N/A printf(" STRUCT(" #t ", %d);\n", (int)sizeof(t)); \
1879N/A else if ((size) != sizeof(t)) \
1879N/A { \
2252N/A printf("%30s: %d expected %d!\n", #t, (int)sizeof(t), (size)); \
1879N/A cErrors++; \
1879N/A } \
1879N/A else if (!fQuiet)\
1879N/A printf("%30s: %d\n", #t, (int)sizeof(t)); \
1879N/A } while (0)
1879N/A
2076N/A
1879N/Aint main(int argc, char **argv)
1879N/A{
1879N/A unsigned cErrors = 0;
1879N/A
1879N/A /*
1879N/A * Prints the code below if any argument was giving.
1879N/A */
1879N/A bool fQuiet = argc == 2 && !strcmp(argv[1], "quiet");
0N/A bool fPrintChecks = !fQuiet && argc != 1;
0N/A
0N/A printf("tstShflSizes: TESTING\n");
0N/A
0N/A /*
0N/A * The checks.
0N/A */
0N/A STRUCT(SHFLROOT, 4);
0N/A STRUCT(SHFLHANDLE, 8);
0N/A STRUCT(SHFLSTRING, 6);
0N/A STRUCT(SHFLCREATERESULT, 4);
0N/A STRUCT(SHFLCREATEPARMS, 108);
0N/A STRUCT(SHFLMAPPING, 8);
0N/A STRUCT(SHFLDIRINFO, 128);
0N/A STRUCT(SHFLVOLINFO, 40);
2062N/A STRUCT(SHFLFSOBJATTR, 44);
2062N/A STRUCT(SHFLFSOBJINFO, 92);
2062N/A#ifdef VBOX_WITH_64_BITS_GUESTS
0N/A/* The size of the guest structures depends on the current architecture bit count (ARCH_BITS)
0N/A * because the HGCMFunctionParameter structure differs in 32 and 64 bit guests.
0N/A * The host VMMDev device takes care about this.
0N/A *
0N/A * Therefore this testcase verifies whether structure sizes are correct for the current ARCH_BITS.
0N/A */
0N/A# if ARCH_BITS == 64
0N/A STRUCT(VBoxSFQueryMappings, 64);
0N/A STRUCT(VBoxSFQueryMapName, 48);
0N/A STRUCT(VBoxSFMapFolder_Old, 64);
0N/A STRUCT(VBoxSFMapFolder, 80);
0N/A STRUCT(VBoxSFUnmapFolder, 32);
0N/A STRUCT(VBoxSFCreate, 64);
0N/A STRUCT(VBoxSFClose, 48);
1155N/A STRUCT(VBoxSFRead, 96);
0N/A STRUCT(VBoxSFWrite, 96);
0N/A STRUCT(VBoxSFLock, 96);
0N/A STRUCT(VBoxSFFlush, 48);
0N/A STRUCT(VBoxSFList, 144);
1155N/A STRUCT(VBoxSFInformation, 96);
0N/A STRUCT(VBoxSFRemove, 64);
0N/A STRUCT(VBoxSFRename, 80);
0N/A# elif ARCH_BITS == 32
1612N/A STRUCT(VBoxSFQueryMappings, 52);
1612N/A STRUCT(VBoxSFQueryMapName, 40); /* this was changed from 52 in 21976 after VBox-1.4. */
1612N/A STRUCT(VBoxSFMapFolder_Old, 52);
1612N/A STRUCT(VBoxSFMapFolder, 64);
1612N/A STRUCT(VBoxSFUnmapFolder, 28);
0N/A STRUCT(VBoxSFCreate, 52);
0N/A STRUCT(VBoxSFClose, 40);
0N/A STRUCT(VBoxSFRead, 76);
0N/A STRUCT(VBoxSFWrite, 76);
0N/A STRUCT(VBoxSFLock, 76);
0N/A STRUCT(VBoxSFFlush, 40);
0N/A STRUCT(VBoxSFList, 112);
0N/A STRUCT(VBoxSFInformation, 76);
0N/A STRUCT(VBoxSFRemove, 52);
0N/A STRUCT(VBoxSFRename, 64);
0N/A# else
0N/A# error "Unsupported ARCH_BITS"
0N/A# endif /* ARCH_BITS */
0N/A#else
0N/A STRUCT(VBoxSFQueryMappings, 52);
0N/A STRUCT(VBoxSFQueryMapName, 40); /* this was changed from 52 in 21976 after VBox-1.4. */
0N/A STRUCT(VBoxSFMapFolder_Old, 52);
1682N/A STRUCT(VBoxSFMapFolder, 64);
1668N/A STRUCT(VBoxSFUnmapFolder, 28);
0N/A STRUCT(VBoxSFCreate, 52);
0N/A STRUCT(VBoxSFClose, 40);
0N/A STRUCT(VBoxSFRead, 76);
0N/A STRUCT(VBoxSFWrite, 76);
0N/A STRUCT(VBoxSFLock, 76);
0N/A STRUCT(VBoxSFFlush, 40);
0N/A STRUCT(VBoxSFList, 112);
0N/A STRUCT(VBoxSFInformation, 76);
0N/A STRUCT(VBoxSFRemove, 52);
0N/A STRUCT(VBoxSFRename, 64);
0N/A#endif /* VBOX_WITH_64_BITS_GUESTS */
0N/A
1682N/A /*
1668N/A * The summary.
0N/A */
1483N/A if (!cErrors)
0N/A printf("tstShflSizes: SUCCESS\n");
0N/A else
0N/A printf("tstShflSizes: FAILURE - %d errors\n", cErrors);
0N/A return !!cErrors;
0N/A}
0N/A
0N/A