From patchwork Tue Feb 22 07:45:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xu Kuohai X-Patchwork-Id: 12754631 X-Patchwork-Delegate: bpf@iogearbox.net Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6BFD0C43217 for ; Tue, 22 Feb 2022 07:41:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229632AbiBVHmA (ORCPT ); Tue, 22 Feb 2022 02:42:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38896 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229850AbiBVHl4 (ORCPT ); Tue, 22 Feb 2022 02:41:56 -0500 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 338E9D5F69 for ; Mon, 21 Feb 2022 23:34:47 -0800 (PST) Received: from kwepemi500013.china.huawei.com (unknown [172.30.72.54]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4K2rWL45p2zdZWs; Tue, 22 Feb 2022 15:33:34 +0800 (CST) Received: from huawei.com (10.67.174.197) by kwepemi500013.china.huawei.com (7.221.188.120) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.21; Tue, 22 Feb 2022 15:34:44 +0800 From: Xu Kuohai To: CC: Andrii Nakryiko , Alexei Starovoitov , Daniel Borkmann , Yonghong Song , Shuah Khan , Martin KaFai Lau , Song Liu Subject: [PATCH bpf-next 2/2] selftests/bpf: Update btf_dump case for conflict FWD and STRUCT name Date: Tue, 22 Feb 2022 02:45:24 -0500 Message-ID: <20220222074524.1027060-3-xukuohai@huawei.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220222074524.1027060-1-xukuohai@huawei.com> References: <20220222074524.1027060-1-xukuohai@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.67.174.197] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemi500013.china.huawei.com (7.221.188.120) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net Update btf_dump test case for conflict FWD and STRUCT name. Signed-off-by: Xu Kuohai Acked-by: Song Liu --- tools/testing/selftests/bpf/prog_tests/btf_dump.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/bpf/prog_tests/btf_dump.c b/tools/testing/selftests/bpf/prog_tests/btf_dump.c index 9e26903f9170..2539a8f8b098 100644 --- a/tools/testing/selftests/bpf/prog_tests/btf_dump.c +++ b/tools/testing/selftests/bpf/prog_tests/btf_dump.c @@ -150,6 +150,8 @@ static void test_btf_dump_incremental(void) * * enum { VAL = 1 }; * + * struct s; + * * struct s { int x; }; * */ @@ -161,8 +163,11 @@ static void test_btf_dump_incremental(void) id = btf__add_int(btf, "int", 4, BTF_INT_SIGNED); ASSERT_EQ(id, 2, "int_id"); + id = btf__add_fwd(btf, "s", BTF_FWD_STRUCT); + ASSERT_EQ(id, 3, "fwd_id"); + id = btf__add_struct(btf, "s", 4); - ASSERT_EQ(id, 3, "struct_id"); + ASSERT_EQ(id, 4, "struct_id"); err = btf__add_field(btf, "x", 2, 0, 0); ASSERT_OK(err, "field_ok"); @@ -178,6 +183,8 @@ static void test_btf_dump_incremental(void) " VAL = 1,\n" "};\n" "\n" +"struct s;\n" +"\n" "struct s {\n" " int x;\n" "};\n\n", "c_dump1"); @@ -199,7 +206,7 @@ static void test_btf_dump_incremental(void) fseek(dump_buf_file, 0, SEEK_SET); id = btf__add_struct(btf, "s", 4); - ASSERT_EQ(id, 4, "struct_id"); + ASSERT_EQ(id, 5, "struct_id"); err = btf__add_field(btf, "x", 1, 0, 0); ASSERT_OK(err, "field_ok"); err = btf__add_field(btf, "s", 3, 32, 0);