Prepare Open vSwitch 1.1.2 release.
[sliver-openvswitch.git] / tests / check-structs.at
1 AT_BANNER([struct alignment checker unit tests])
2
3 m4_define([check_structs], [$top_srcdir/build-aux/check-structs])
4 m4_define([RUN_STRUCT_CHECKER], 
5   [AT_SKIP_IF([test $HAVE_PYTHON = no])
6    AT_DATA([test.h], [$1
7 ])
8    AT_CHECK_UNQUOTED([$PYTHON check_structs test.h], [$2], [$3], [$4])])
9
10 AT_SETUP([check struct tail padding])
11 RUN_STRUCT_CHECKER(
12 [struct xyz {
13     uint16_t x;
14 };], 
15   [1], [], 
16   [test.h:3: warning: struct xyz needs 2 bytes of tail padding
17 ])
18 AT_CLEANUP
19
20 AT_SETUP([check struct internal alignment])
21 RUN_STRUCT_CHECKER(
22 [struct xyzzy {
23     uint16_t x;
24     uint32_t y;
25 };], 
26   [1], [], 
27   [test.h:3: warning: struct xyzzy member y is 2 bytes short of 4-byte alignment
28 ])
29 AT_CLEANUP
30
31 AT_SETUP([check struct declared size])
32 RUN_STRUCT_CHECKER(
33 [struct wibble {
34     uint64_t z;
35 };
36 OFP_ASSERT(sizeof(struct wibble) == 12);
37 ], 
38   [1], [], 
39   [test.h:4: warning: struct wibble is 8 bytes long but declared as 12
40 ])
41 AT_CLEANUP