VirtualBox

Changeset 96512 in vbox


Ignore:
Timestamp:
Aug 26, 2022 3:16:40 AM (2 years ago)
Author:
vboxsync
Message:

Devices/testcase: ditto. bugref:10261

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/testcase/tstDeviceStructSize.cpp

    r96407 r96512  
    169169
    170170
    171 #include <stdio.h>
     171#include <iprt/stream.h>
    172172
    173173
     
    185185        if (off != RT_OFFSETOF(type, m)) \
    186186        { \
    187             printf("tstDeviceStructSize: Error! %#010x %s  Member offset wrong by %d (should be %d -- but is %d)\n", \
    188                    RT_OFFSETOF(type, m), #type "." #m, off - RT_OFFSETOF(type, m), off, RT_OFFSETOF(type, m)); \
     187            RTPrintf("tstDeviceStructSize: Error! %#010x %s  Member offset wrong by %d (should be %d -- but is %d)\n", \
     188                     RT_OFFSETOF(type, m), #type "." #m, off - RT_OFFSETOF(type, m), off, RT_OFFSETOF(type, m)); \
    189189            rc++; \
    190190        } \
    191191        else  \
    192             printf("%#08x (%d) %s\n", RT_OFFSETOF(type, m), RT_OFFSETOF(type, m), #type "." #m); \
     192            RTPrintf("%#08x (%d) %s\n", RT_OFFSETOF(type, m), RT_OFFSETOF(type, m), #type "." #m); \
    193193    } while (0)
    194194
     
    202202        if (size != sizeof(type)) \
    203203        { \
    204             printf("tstDeviceStructSize: Error! sizeof(%s): %#x (%d)  Size wrong by %d (should be %d -- but is %d)\n", \
    205                    #type, (int)sizeof(type), (int)sizeof(type), (int)sizeof(type) - (int)size, (int)size, (int)sizeof(type)); \
     204            RTPrintf("tstDeviceStructSize: Error! sizeof(%s): %#x (%d)  Size wrong by %d (should be %d -- but is %d)\n", \
     205                     #type, (int)sizeof(type), (int)sizeof(type), (int)sizeof(type) - (int)size, (int)size, (int)sizeof(type)); \
    206206            rc++; \
    207207        } \
    208208        else \
    209             printf("tstDeviceStructSize: info: sizeof(%s): %#x (%d)\n", #type, (int)sizeof(type), (int)sizeof(type)); \
     209            RTPrintf("tstDeviceStructSize: info: sizeof(%s): %#x (%d)\n", #type, (int)sizeof(type), (int)sizeof(type)); \
    210210    } while (0)
    211211
     
    218218        if (RT_OFFSETOF(strct, member) & ((align) - 1) ) \
    219219        { \
    220             printf("tstDeviceStructSize: error! %s::%s offset=%#x (%u) expected alignment %#x, meaning %#x (%u) off\n", \
    221                    #strct, #member, \
    222                    (unsigned)RT_OFFSETOF(strct, member), \
    223                    (unsigned)RT_OFFSETOF(strct, member), \
    224                    (unsigned)(align), \
    225                    (unsigned)(((align) - RT_OFFSETOF(strct, member)) & ((align) - 1)), \
    226                    (unsigned)(((align) - RT_OFFSETOF(strct, member)) & ((align) - 1)) ); \
     220            RTPrintf("tstDeviceStructSize: error! %s::%s offset=%#x (%u) expected alignment %#x, meaning %#x (%u) off\n", \
     221                     #strct, #member, \
     222                     (unsigned)RT_OFFSETOF(strct, member), \
     223                     (unsigned)RT_OFFSETOF(strct, member), \
     224                     (unsigned)(align), \
     225                     (unsigned)(((align) - RT_OFFSETOF(strct, member)) & ((align) - 1)), \
     226                     (unsigned)(((align) - RT_OFFSETOF(strct, member)) & ((align) - 1)) ); \
    227227            rc++; \
    228228        } \
     
    236236        if (RT_ALIGN_Z(sizeof(type), (align)) != sizeof(type)) \
    237237        { \
    238             printf("tstDeviceStructSize: error! %s size=%#x (%u), align=%#x %#x (%u) bytes off\n", \
    239                    #type, \
    240                    (unsigned)sizeof(type), \
    241                    (unsigned)sizeof(type), \
    242                    (align), \
    243                    (unsigned)RT_ALIGN_Z(sizeof(type), align) - (unsigned)sizeof(type), \
    244                    (unsigned)RT_ALIGN_Z(sizeof(type), align) - (unsigned)sizeof(type)); \
     238            RTPrintf("tstDeviceStructSize: error! %s size=%#x (%u), align=%#x %#x (%u) bytes off\n", \
     239                     #type, \
     240                     (unsigned)sizeof(type), \
     241                     (unsigned)sizeof(type), \
     242                     (align), \
     243                     (unsigned)RT_ALIGN_Z(sizeof(type), align) - (unsigned)sizeof(type), \
     244                     (unsigned)RT_ALIGN_Z(sizeof(type), align) - (unsigned)sizeof(type)); \
    245245            rc++; \
    246246        } \
     
    256256        if (sizeof(p->member.s) > sizeof(p->member.padding)) \
    257257        { \
    258             printf("tstDeviceStructSize: error! padding of %s::%s is too small, padding=%d struct=%d correct=%d\n", #strct, #member, \
    259                    (int)sizeof(p->member.padding), (int)sizeof(p->member.s), (int)RT_ALIGN_Z(sizeof(p->member.s), (align))); \
     258            RTPrintf("tstDeviceStructSize: error! padding of %s::%s is too small, padding=%d struct=%d correct=%d\n", #strct, #member, \
     259                     (int)sizeof(p->member.padding), (int)sizeof(p->member.s), (int)RT_ALIGN_Z(sizeof(p->member.s), (align))); \
    260260            rc++; \
    261261        } \
    262262        else if (RT_ALIGN_Z(sizeof(p->member.padding), (align)) != sizeof(p->member.padding)) \
    263263        { \
    264             printf("tstDeviceStructSize: error! padding of %s::%s is misaligned, padding=%d correct=%d\n", #strct, #member, \
    265                    (int)sizeof(p->member.padding), (int)RT_ALIGN_Z(sizeof(p->member.s), (align))); \
     264            RTPrintf("tstDeviceStructSize: error! padding of %s::%s is misaligned, padding=%d correct=%d\n", #strct, #member, \
     265                     (int)sizeof(p->member.padding), (int)RT_ALIGN_Z(sizeof(p->member.s), (align))); \
    266266            rc++; \
    267267        } \
     
    277277        if (sizeof(p->s) > sizeof(p->padding)) \
    278278        { \
    279             printf("tstDeviceStructSize: error! padding of %s is too small, padding=%d struct=%d correct=%d\n", #strct, \
    280                    (int)sizeof(p->padding), (int)sizeof(p->s), (int)RT_ALIGN_Z(sizeof(p->s), 32)); \
     279            RTPrintf("tstDeviceStructSize: error! padding of %s is too small, padding=%d struct=%d correct=%d\n", #strct, \
     280                     (int)sizeof(p->padding), (int)sizeof(p->s), (int)RT_ALIGN_Z(sizeof(p->s), 32)); \
    281281            rc++; \
    282282        } \
     
    292292        if (sizeof(p->member) > sizeof(p->pad_member)) \
    293293        { \
    294             printf("tstDeviceStructSize: error! padding of %s::%s is too small, padding=%d struct=%d\n", #strct, #member, \
    295                    (int)sizeof(p->pad_member), (int)sizeof(p->member)); \
     294            RTPrintf("tstDeviceStructSize: error! padding of %s::%s is too small, padding=%d struct=%d\n", #strct, #member, \
     295                     (int)sizeof(p->pad_member), (int)sizeof(p->member)); \
    296296            rc++; \
    297297        } \
     
    304304    do \
    305305    { \
    306         printf("tstDeviceStructSize: info: %s::%s offset %d sizeof %d\n",  #strct, #member, (int)RT_OFFSETOF(strct, member), (int)RT_SIZEOFMEMB(strct, member)); \
     306        RTPrintf("tstDeviceStructSize: info: %s::%s offset %d sizeof %d\n",  #strct, #member, (int)RT_OFFSETOF(strct, member), (int)RT_SIZEOFMEMB(strct, member)); \
    307307    } while (0)
    308308
     
    311311{
    312312    int rc = 0;
    313     printf("tstDeviceStructSize: TESTING\n");
     313    RTPrintf("tstDeviceStructSize: TESTING\n");
    314314
    315315    /* Assert sanity */
     
    438438     * Compare HC and RC.
    439439     */
    440     printf("tstDeviceStructSize: Comparing HC and RC...\n");
     440    RTPrintf("tstDeviceStructSize: Comparing HC and RC...\n");
    441441# include "tstDeviceStructSizeRC.h"
    442442#endif
     
    446446     */
    447447    if (rc)
    448         printf("tstDeviceStructSize: FAILURE - %d errors\n", rc);
     448        RTPrintf("tstDeviceStructSize: FAILURE - %d errors\n", rc);
    449449    else
    450         printf("tstDeviceStructSize: SUCCESS\n");
     450        RTPrintf("tstDeviceStructSize: SUCCESS\n");
    451451    return rc;
    452452}
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette