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