On Fri, Dec 14, 2018 at 03:34:30PM -0800, Yonghong Song wrote: > This patch added unit tests for different types handling > type->info.kind_flag. The following new tests are added: > $ test_btf > ... > BTF raw test[82] (invalid int kind_flag): OK > BTF raw test[83] (invalid ptr kind_flag): OK > BTF raw test[84] (invalid array kind_flag): OK > BTF raw test[85] (invalid enum kind_flag): OK > BTF raw test[86] (valid fwd kind_flag): OK > BTF raw test[87] (invalid typedef kind_flag): OK > BTF raw test[88] (invalid volatile kind_flag): OK > BTF raw test[89] (invalid const kind_flag): OK > BTF raw test[90] (invalid restrict kind_flag): OK > BTF raw test[91] (invalid func kind_flag): OK > BTF raw test[92] (invalid func_proto kind_flag): OK > BTF raw test[93] (valid struct kind_flag, bitfield_size = 0): OK > BTF raw test[94] (valid struct kind_flag, int member, bitfield_size != 0): > OK > BTF raw test[95] (valid union kind_flag, int member, bitfield_size != 0): OK > BTF raw test[96] (valid struct kind_flag, enum member, bitfield_size != 0): > OK > BTF raw test[97] (valid union kind_flag, enum member, bitfield_size != 0): > OK > BTF raw test[98] (valid struct kind_flag, typedef member, bitfield_size != > 0): OK > BTF raw test[99] (valid union kind_flag, typedef member, bitfield_size != > 0): OK > BTF raw test[100] (invalid struct type, bitfield_size greater than struct > size): OK > BTF raw test[101] (invalid struct type, kind_flag bitfield base_type int > not regular): OK > BTF raw test[102] (invalid struct type, kind_flag base_type int not > regular): OK > BTF raw test[103] (invalid union type, bitfield_size greater than struct > size): OK Would it be useful to add some "struct kind_flag, (int|enum) member, bitfield_size == 0, wrong byte alignment" tests to catch the "!nr_bits && BITS_PER_BYTE_MASKED(struct_bits_off)" in patch 2. The extra tests could be a follow up though.
Or the above tests have covered that already? > ... > PASS:122 SKIP:0 FAIL:0 > > The second parameter name of macro > BTF_INFO_ENC(kind, root, vlen) > in selftests test_btf.c is also renamed from "root" to "kind_flag". > Note that before this patch "root" is not used and always 0. For the tests: Acked-by: Martin KaFai Lau <ka...@fb.com>