]> git.proxmox.com Git - mirror_ovs.git/blob - tests/check-structs.at
tests/ovs_client: Remove broken debug code
[mirror_ovs.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_KEYWORDS([check-structs])
6 AT_SKIP_IF([test $HAVE_PYTHON = no])
7 AT_DATA([test.h], [$1
8 ])
9 AT_CHECK_UNQUOTED([$PYTHON check_structs test.h], [$2], [$3], [$4])])
10
11 AT_SETUP([check struct tail padding])
12 RUN_STRUCT_CHECKER(
13 [struct xyz {
14 ovs_be16 x;
15 };],
16 [1], [],
17 [test.h:3: warning: struct xyz needs 2 bytes of tail padding
18 ])
19 AT_CLEANUP
20
21 AT_SETUP([check struct internal alignment])
22 RUN_STRUCT_CHECKER(
23 [struct xyzzy {
24 ovs_be16 x;
25 ovs_be32 y;
26 };],
27 [1], [],
28 [test.h:3: warning: struct xyzzy member y is 2 bytes short of 4-byte alignment
29 ])
30 AT_CLEANUP
31
32 AT_SETUP([check struct declared size])
33 RUN_STRUCT_CHECKER(
34 [struct wibble {
35 ovs_be64 z;
36 };
37 OFP_ASSERT(sizeof(struct wibble) == 12);
38 ],
39 [1], [],
40 [test.h:4: warning: struct wibble is 8 bytes long but declared as 12
41 ])
42 AT_CLEANUP
43
44 AT_SETUP([check wrong struct's declared size])
45 RUN_STRUCT_CHECKER(
46 [struct moo {
47 ovs_be64 bar;
48 };
49 OFP_ASSERT(sizeof(struct moo) == 8);
50 struct wibble {
51 ovs_be64 z;
52 };
53 OFP_ASSERT(sizeof(struct moo) == 8);
54 ], [1], [], [test.h:8: warning: checking size of struct moo but struct wibble was most recently defined
55 ])
56 AT_CLEANUP