]> git.proxmox.com Git - ovs.git/blame - tests/check-structs.at
raft: Fix the problem of stuck in candidate role forever.
[ovs.git] / tests / check-structs.at
CommitLineData
05b3c97b
BP
1AT_BANNER([struct alignment checker unit tests])
2
3m4_define([check_structs], [$top_srcdir/build-aux/check-structs])
4m4_define([RUN_STRUCT_CHECKER],
f937ccc2 5 [AT_KEYWORDS([check-structs])
05b3c97b
BP
6 AT_DATA([test.h], [$1
7])
1ca0323e 8 AT_CHECK_UNQUOTED([$PYTHON3 check_structs test.h], [$2], [$3], [$4])])
05b3c97b
BP
9
10AT_SETUP([check struct tail padding])
11RUN_STRUCT_CHECKER(
12[struct xyz {
cd03c7c8 13 ovs_be16 x;
05b3c97b
BP
14};],
15 [1], [],
16 [test.h:3: warning: struct xyz needs 2 bytes of tail padding
17])
18AT_CLEANUP
19
20AT_SETUP([check struct internal alignment])
21RUN_STRUCT_CHECKER(
22[struct xyzzy {
cd03c7c8
BP
23 ovs_be16 x;
24 ovs_be32 y;
05b3c97b
BP
25};],
26 [1], [],
27 [test.h:3: warning: struct xyzzy member y is 2 bytes short of 4-byte alignment
28])
29AT_CLEANUP
30
31AT_SETUP([check struct declared size])
32RUN_STRUCT_CHECKER(
33[struct wibble {
cd03c7c8 34 ovs_be64 z;
05b3c97b
BP
35};
36OFP_ASSERT(sizeof(struct wibble) == 12);
37],
38 [1], [],
39 [test.h:4: warning: struct wibble is 8 bytes long but declared as 12
40])
41AT_CLEANUP
f937ccc2
BP
42
43AT_SETUP([check wrong struct's declared size])
44RUN_STRUCT_CHECKER(
45[struct moo {
cd03c7c8 46 ovs_be64 bar;
f937ccc2
BP
47};
48OFP_ASSERT(sizeof(struct moo) == 8);
49struct wibble {
cd03c7c8 50 ovs_be64 z;
f937ccc2
BP
51};
52OFP_ASSERT(sizeof(struct moo) == 8);
53], [1], [], [test.h:8: warning: checking size of struct moo but struct wibble was most recently defined
54])
55AT_CLEANUP