tstHelp.h revision 17ba03925269c071aa1567eb8c5a49c37a65f62f
/* $Id$ */
/** @file
* VMM testcase - Helper stuff.
*/
/*
* Copyright (C) 2006-2007 innotek GmbH
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License as published by the Free Software Foundation,
* in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
* distribution. VirtualBox OSE is distributed in the hope that it will
* be useful, but WITHOUT ANY WARRANTY of any kind.
*
* If you received this file as part of a commercial VirtualBox
* distribution, then only the terms of your commercial VirtualBox
* license agreement apply instead of the previous paragraph.
*/
#ifndef ___tstHelp_h
#define ___tstHelp_h
/**
* Checks the offset of a data member.
* @param type Type.
* @param off Correct offset.
* @param m Member name.
*/
do { \
{ \
printf("%#010x %s Off by %d!! (off=%#x)\n", RT_OFFSETOF(type, m), #type "." #m, off - RT_OFFSETOF(type, m), off); \
rc++; \
} \
/*else */ \
/*printf("%#08x %s\n", RT_OFFSETOF(type, m), #m);*/ \
} while (0)
/**
* Checks the size of type.
* @param type Type.
* @param size Correct size.
*/
do { \
{ \
printf("sizeof(%s): %#x (%d) Off by %d!!\n", #type, (int)sizeof(type), (int)sizeof(type), (int)(sizeof(type) - size)); \
rc++; \
} \
else \
} while (0)
/**
* Checks the alignment of a struct member.
*/
do \
{ \
{ \
printf("%s::%s offset=%u expected alignment %x, meaning %u off\n", #strct, #member, (unsigned)RT_OFFSETOF(strct, member), \
rc++; \
} \
} while (0)
/**
* Checks that the size of a type is aligned correctly.
*/
do { \
{ \
rc++; \
} \
} while (0)
/**
* Checks that a internal struct padding is big enough.
*/
do \
{ \
strct *p; \
{ \
(int)sizeof(p->member.padding), (int)sizeof(p->member.s), (int)RT_ALIGN_Z(sizeof(p->member.s), 32)); \
rc++; \
} \
} while (0)
/**
* Checks that a internal struct padding is big enough.
*/
#define CHECK_PADDING2(strct) \
do \
{ \
strct *p; \
if (sizeof(p->s) > sizeof(p->padding)) \
{ \
rc++; \
} \
} while (0)
/**
* Checks that a internal struct padding is big enough.
*/
do \
{ \
strct *p; \
if (sizeof(p->member) > sizeof(p->pad_member)) \
{ \
(int)sizeof(p->pad_member), (int)sizeof(p->member)); \
rc++; \
} \
} while (0)
#endif