Changeset 96512 in vbox
- Timestamp:
- Aug 26, 2022 3:16:40 AM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/testcase/tstDeviceStructSize.cpp
r96407 r96512 169 169 170 170 171 #include < stdio.h>171 #include <iprt/stream.h> 172 172 173 173 … … 185 185 if (off != RT_OFFSETOF(type, m)) \ 186 186 { \ 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)); \ 189 189 rc++; \ 190 190 } \ 191 191 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); \ 193 193 } while (0) 194 194 … … 202 202 if (size != sizeof(type)) \ 203 203 { \ 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)); \ 206 206 rc++; \ 207 207 } \ 208 208 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)); \ 210 210 } while (0) 211 211 … … 218 218 if (RT_OFFSETOF(strct, member) & ((align) - 1) ) \ 219 219 { \ 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)) ); \ 227 227 rc++; \ 228 228 } \ … … 236 236 if (RT_ALIGN_Z(sizeof(type), (align)) != sizeof(type)) \ 237 237 { \ 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)); \ 245 245 rc++; \ 246 246 } \ … … 256 256 if (sizeof(p->member.s) > sizeof(p->member.padding)) \ 257 257 { \ 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))); \ 260 260 rc++; \ 261 261 } \ 262 262 else if (RT_ALIGN_Z(sizeof(p->member.padding), (align)) != sizeof(p->member.padding)) \ 263 263 { \ 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))); \ 266 266 rc++; \ 267 267 } \ … … 277 277 if (sizeof(p->s) > sizeof(p->padding)) \ 278 278 { \ 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)); \ 281 281 rc++; \ 282 282 } \ … … 292 292 if (sizeof(p->member) > sizeof(p->pad_member)) \ 293 293 { \ 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)); \ 296 296 rc++; \ 297 297 } \ … … 304 304 do \ 305 305 { \ 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)); \ 307 307 } while (0) 308 308 … … 311 311 { 312 312 int rc = 0; 313 printf("tstDeviceStructSize: TESTING\n");313 RTPrintf("tstDeviceStructSize: TESTING\n"); 314 314 315 315 /* Assert sanity */ … … 438 438 * Compare HC and RC. 439 439 */ 440 printf("tstDeviceStructSize: Comparing HC and RC...\n");440 RTPrintf("tstDeviceStructSize: Comparing HC and RC...\n"); 441 441 # include "tstDeviceStructSizeRC.h" 442 442 #endif … … 446 446 */ 447 447 if (rc) 448 printf("tstDeviceStructSize: FAILURE - %d errors\n", rc);448 RTPrintf("tstDeviceStructSize: FAILURE - %d errors\n", rc); 449 449 else 450 printf("tstDeviceStructSize: SUCCESS\n");450 RTPrintf("tstDeviceStructSize: SUCCESS\n"); 451 451 return rc; 452 452 }
Note:
See TracChangeset
for help on using the changeset viewer.