From patchwork Mon Jul 17 15:24:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Masami Hiramatsu (Google)" X-Patchwork-Id: 121434 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp1213527vqt; Mon, 17 Jul 2023 09:23:30 -0700 (PDT) X-Google-Smtp-Source: APBJJlEUN4g74LUs6fgTV2Sf8CqMSkx+kMfx1DX2wqnB4bYmr7MWUEwXgdjc6f1i7UJcfAovmXzt X-Received: by 2002:a05:6a00:228d:b0:672:264c:e8cf with SMTP id f13-20020a056a00228d00b00672264ce8cfmr3692pfe.7.1689611010472; Mon, 17 Jul 2023 09:23:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689611010; cv=none; d=google.com; s=arc-20160816; b=Yfz5qXjazXy8JRV4P0ZuzqZDqRVgZRsyimOdMcv9b1F4XZg/8avFNL/ezjnX3+2mBL MOyQf4tqTBO8EgnO8ixt/9b7TbaTstRgsDQLC5n/Ng9dII5U3rjC34npJX7CwBnqEln/ O1s5R8tFWH0+TDMVFn5JB/yFbWyNymWQmTl00FeT9vk8ukRo4NV8qBnnVMyBzesUlRms Gqou1gxeWr53bLZBby37w922NmK+pudCilitGs12zGz/WSl1AaPNckYAjUDoEeu0tg+p nhGiwnfcQcGRqyQRbyDHxal5KzlWD3e2mKmFtx4Si0NDAaKlQ/o7QuT4zttJgWgyWXzK YDpg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=VW+zzdjDIPd7XuPZuWt/CBBh6TeYMdhsRU8R9rI/Hd8=; fh=raxTTJvC+dSJYbgfX5JG5gvrVjxTZXczN0HF8iDayLY=; b=XwLBhJ1ZsDNjaF7NuST2PDUYn0gDPiC3kZYnx6MdCSh5L2dSKSJHmGK5Ejxb4eo/ja DJk1kqXYQxLiBdcikddc+jwQYprS7v2JbwKrKaHcoGLQyst0i8Ih88eaonLjvVV/HC45 RoPdqclcBIESoSbUVfEcL+/ztA37xCfd8aEtIKomDdqQpjQ02UQIDTHmvVn8CIteBhXA MG7Hrxl17qyWBoHbp2PisSX9VNmkgCx5w4+FscLC3fKljhRqVdFIMejme8J9NHXv9N5k 3z06nLozflv36s2qVmMI7Vhqs+vA7fCDI4HruX1w1IaxzIAuXSpd/mxiB13+siCYHX/H AYpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=CXPeI9Ol; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n10-20020a65488a000000b00553859c59c1si1626pgs.695.2023.07.17.09.23.16; Mon, 17 Jul 2023 09:23:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=CXPeI9Ol; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232038AbjGQPZm (ORCPT + 99 others); Mon, 17 Jul 2023 11:25:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57376 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231753AbjGQPZQ (ORCPT ); Mon, 17 Jul 2023 11:25:16 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A06C719B0; Mon, 17 Jul 2023 08:24:45 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id BBDA86104A; Mon, 17 Jul 2023 15:24:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2B870C433C7; Mon, 17 Jul 2023 15:24:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1689607482; bh=ApAG9WsE51kt31Nr613fs76Un6BDs5WAbX0BxsdpAn8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CXPeI9Olpd2PQ2cSmU1m8gegxcK4xVk5lVci7yDw8I96t9olXP89EYoBZyaYneToh 76Ytj785hrK0Fc6BmJ9QWoFW4K1kDH4qVftLjgxKIEyfv98xxZbrHxCmPjFLY6i/r7 +4z8fO2yZJAwyiHRz/wuVWBDq3EGn/O0a3aoCzPoOvYyjPuTR5ZSfWj2fhbJ/F/4ux gDZRWt0hxpyGAcAtgkcFG30czTMmtbibdjIQI7zFNi13neGJ1DSfl15vJMzzlaIqnb xIUgJO7bxp18mG797lKvbjacfit1O9feYVfWPGeeC99spMmBTzExUyriXbeMaobdVe FfTbZdcpoUcVw== From: "Masami Hiramatsu (Google)" To: linux-trace-kernel@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Steven Rostedt , mhiramat@kernel.org, Martin KaFai Lau , bpf@vger.kernel.org, Sven Schnelle , Alexei Starovoitov Subject: [PATCH v2 8/9] selftests/ftrace: Add BTF fields access testcases Date: Tue, 18 Jul 2023 00:24:37 +0900 Message-Id: <168960747750.34107.6104527579648222887.stgit@devnote2> X-Mailer: git-send-email 2.25.1 In-Reply-To: <168960739768.34107.15145201749042174448.stgit@devnote2> References: <168960739768.34107.15145201749042174448.stgit@devnote2> User-Agent: StGit/0.19 MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771685554858895198 X-GMAIL-MSGID: 1771685554858895198 From: Masami Hiramatsu (Google) Add test cases for accessing the data structure fields using BTF info. This includes the field access from parameters and retval, and accessing string information. Signed-off-by: Masami Hiramatsu (Google) Reviewed-by: Alan Maguire --- Changes in v2: - Use '$retval' instead of 'retval'. - Add a test that use both '$retval' and '$arg1' for fprobe. --- .../ftrace/test.d/dynevent/add_remove_btfarg.tc | 11 +++++++++++ .../ftrace/test.d/dynevent/fprobe_syntax_errors.tc | 4 ++++ 2 files changed, 15 insertions(+) diff --git a/tools/testing/selftests/ftrace/test.d/dynevent/add_remove_btfarg.tc b/tools/testing/selftests/ftrace/test.d/dynevent/add_remove_btfarg.tc index b89de1771655..93b94468967b 100644 --- a/tools/testing/selftests/ftrace/test.d/dynevent/add_remove_btfarg.tc +++ b/tools/testing/selftests/ftrace/test.d/dynevent/add_remove_btfarg.tc @@ -21,6 +21,8 @@ echo 0 > events/enable echo > dynamic_events TP=kfree +TP2=kmem_cache_alloc +TP3=getname_flags if [ "$FPROBES" ] ; then echo "f:fpevent $TP object" >> dynamic_events @@ -33,6 +35,7 @@ echo > dynamic_events echo "f:fpevent $TP "'$arg1' >> dynamic_events grep -q "fpevent.*object=object" dynamic_events + echo > dynamic_events echo "f:fpevent $TP "'$arg*' >> dynamic_events @@ -45,6 +48,14 @@ fi echo > dynamic_events +echo "t:tpevent $TP2 name=s->name:string" >> dynamic_events +echo "f:fpevent ${TP3}%return path=\$retval->name:string" >> dynamic_events + +grep -q "tpevent.*name=s->name:string" dynamic_events +grep -q "fpevent.*path=\$retval->name:string" dynamic_events + +echo > dynamic_events + if [ "$KPROBES" ] ; then echo "p:kpevent $TP object" >> dynamic_events grep -q "kpevent.*object=object" dynamic_events diff --git a/tools/testing/selftests/ftrace/test.d/dynevent/fprobe_syntax_errors.tc b/tools/testing/selftests/ftrace/test.d/dynevent/fprobe_syntax_errors.tc index 72563b2e0812..49758f77c923 100644 --- a/tools/testing/selftests/ftrace/test.d/dynevent/fprobe_syntax_errors.tc +++ b/tools/testing/selftests/ftrace/test.d/dynevent/fprobe_syntax_errors.tc @@ -103,6 +103,10 @@ check_error 'f vfs_read%return ^$arg*' # NOFENTRY_ARGS check_error 'f vfs_read ^hoge' # NO_BTFARG check_error 'f kfree ^$arg10' # NO_BTFARG (exceed the number of parameters) check_error 'f kfree%return ^$retval' # NO_RETVAL +check_error 'f vfs_read%return $retval->^foo' # NO_PTR_STRCT +check_error 'f vfs_read file->^foo' # NO_BTF_FIELD +check_error 'f vfs_read file^-.foo' # BAD_HYPHEN +check_error 'f vfs_read ^file:string' # BAD_TYPE4STR else check_error 'f vfs_read ^$arg*' # NOSUP_BTFARG check_error 't kfree ^$arg*' # NOSUP_BTFARG