From patchwork Tue Nov 8 15:50:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Masami Hiramatsu (Google)" X-Patchwork-Id: 17113 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2790182wru; Tue, 8 Nov 2022 07:51:16 -0800 (PST) X-Google-Smtp-Source: AMsMyM5a5sNc6aoG2vMSY3yYTnjkMl0qoODJPc4c39A/iY6YoNkO+W/zJz92ahLLpkGu3FgI4pnp X-Received: by 2002:a05:6402:1004:b0:464:778:c516 with SMTP id c4-20020a056402100400b004640778c516mr34710617edu.348.1667922676279; Tue, 08 Nov 2022 07:51:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667922676; cv=none; d=google.com; s=arc-20160816; b=ewCxzMEHBwzkU3bFLdhRyoEHxfMHd9bLYpZyk6ZZE/FyHyi/dI8gGEeNFxiOD4ZXg4 /CIWOddFcwa95gGTeor4mcdiG0tDbfVH/EfacA99ALvxHomvFUheh+W6mSHSqe90sLvA /NoQyv4czl1gMqYnsnSwWwY8yY+CtbzpoGqIBsAXkL/3OLwiwAjeMwEzc0H0RmK1pnDt uGBy4ciM+/i27AEj2pFf77CcpSiMqG/5+XGSWrKenLLHgETtAtCJHSi5C6sRg9JH8FrS HPNOVeDSvuNZuQaFWBda8er/pz1Nf4fHVJQ7K754HGXevbl2nOYMPlpRnuQ8q97v04vg ULEA== 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=Em3I7kB9syzxEmBE65aR38zzGes8pI9JL8Crnp8b/k0=; b=AJUBaXqgJFR1cniqsK9Vpv82ut/1lIgofC3ILaENxBctxB9PyPxy3zGhQCLE+bihDO wWQSvIUkO67cXiEZrXQxamtZ4Tw1sJ4VQqVS+qy1xopTUS7b+3JEfZiXHUhpJV/jTvPb 6V/3OSE1pspImxb0tP3ASdeEcnYkujjJngPUYsGQpw8kiVTsTPh6QnerSyOAtiOxeBR4 /aFZwBU9DElbefVugTBOUAwsl/FnVqvyWR4XSB+Ol0FxZFWmep+V8mN153KpfqPiX3DE 57N8fivCtlOkCm/dt8pHaeD5F3nfKxuErTs7A5LO2FlDcaERiYZcFLj90k1s/pveq6DU tm1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=jmJOd5tL; 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 mp23-20020a1709071b1700b00782a5657512si14344640ejc.416.2022.11.08.07.50.52; Tue, 08 Nov 2022 07:51:16 -0800 (PST) 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=jmJOd5tL; 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 S234610AbiKHPu0 (ORCPT + 99 others); Tue, 8 Nov 2022 10:50:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38420 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234606AbiKHPuP (ORCPT ); Tue, 8 Nov 2022 10:50:15 -0500 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 626835C778; Tue, 8 Nov 2022 07:50:14 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id CEFC9CE1C04; Tue, 8 Nov 2022 15:50:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 96DF5C433C1; Tue, 8 Nov 2022 15:50:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1667922611; bh=5l8khZ1P9sioaYF0TNk9KOSmOx0dNhLQfbQv88Ag2GU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jmJOd5tLr2rZ8+4PpywGm9an1ASrxZWDnV/e5slb8g2RnRHqCmGwINtQ0pcWTLyxL kUU8pqouH6BHKUWc9ZtJJxv121Iptz13Rw9+dsSqBFM3g4OjNvd+UFN+a8Jv4yDdH9 XvCXTYAX487i4T5i/NYCVHTAzsX/yEi4R78qq+1lBEjzDPdACh/c+oPezk/ASygmGS GkLs8T8xw9H7khaioLq/GJuPMMVd2IfahFyNB81K2wJqVy1IqtVM62Sxf8fiPsAahb grW3AjO+4cirMehZnRH3AbU8Af2/O/cUDy/sLM4z6WJNQ4QqyV0SFOzopf+QxVbN9N yWbeH/GzR+KaQ== From: "Masami Hiramatsu (Google)" To: linux-trace-kernel@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Steven Rostedt , mhiramat@kernel.org, Florent Revest , Mark Rutland , Will Deacon Subject: [RFC PATCH 6/9] lib/test_fprobe: Add a testcase for skipping exit_handler Date: Wed, 9 Nov 2022 00:50:07 +0900 Message-Id: <166792260740.919356.5736843826698103180.stgit@devnote3> X-Mailer: git-send-email 2.38.1.431.g37b22c650d-goog In-Reply-To: <166792255429.919356.14116090269057513181.stgit@devnote3> References: <166792255429.919356.14116090269057513181.stgit@devnote3> User-Agent: StGit/0.19 MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748943688150931528?= X-GMAIL-MSGID: =?utf-8?q?1748943688150931528?= From: Masami Hiramatsu (Google) Add a testcase for skipping exit_handler if entry_handler returns !0. Signed-off-by: Masami Hiramatsu (Google) --- lib/test_fprobe.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/lib/test_fprobe.c b/lib/test_fprobe.c index e78176d252ae..926d5104b291 100644 --- a/lib/test_fprobe.c +++ b/lib/test_fprobe.c @@ -21,6 +21,7 @@ static u32 (*target_nest)(u32 value, u32 (*nest)(u32)); static unsigned long target_ip; static unsigned long target2_ip; static unsigned long target_nest_ip; +static int entry_return_value; static noinline u32 fprobe_selftest_target(u32 value) { @@ -52,7 +53,7 @@ static notrace int fp_entry_handler(struct fprobe *fp, unsigned long ip, } else KUNIT_EXPECT_NULL(current_test, data); - return 0; + return entry_return_value; } static notrace void fp_exit_handler(struct fprobe *fp, unsigned long ip, @@ -205,6 +206,28 @@ static void test_fprobe_nest(struct kunit *test) KUNIT_EXPECT_EQ(test, 0, unregister_fprobe(&fp)); } +static void test_fprobe_skip(struct kunit *test) +{ + struct fprobe fp = { + .entry_handler = fp_entry_handler, + .exit_handler = fp_exit_handler, + }; + + current_test = test; + KUNIT_EXPECT_EQ(test, 0, register_fprobe(&fp, "fprobe_selftest_target", NULL)); + + entry_return_value = 1; + entry_val = 0; + exit_val = 0; + target(rand1); + KUNIT_EXPECT_NE(test, 0, entry_val); + KUNIT_EXPECT_EQ(test, 0, exit_val); + KUNIT_EXPECT_EQ(test, 0, fp.nmissed); + entry_return_value = 0; + + KUNIT_EXPECT_EQ(test, 0, unregister_fprobe(&fp)); +} + static unsigned long get_ftrace_location(void *func) { unsigned long size, addr = (unsigned long)func; @@ -237,6 +260,7 @@ static struct kunit_case fprobe_testcases[] = { KUNIT_CASE(test_fprobe_syms), KUNIT_CASE(test_fprobe_data), KUNIT_CASE(test_fprobe_nest), + KUNIT_CASE(test_fprobe_skip), {} };