Message ID | 20230525042133.212534-2-davidgow@google.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp112783vqr; Wed, 24 May 2023 21:51:50 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7Vgfj1Dszncj1cNMLQpG1NcYO2LvJedfSehZdV/O+Wt7m/Bqz+COMUi6wD+tHiWa2D5W7+ X-Received: by 2002:a05:6a00:2190:b0:64f:85a9:3a20 with SMTP id h16-20020a056a00219000b0064f85a93a20mr984539pfi.22.1684990310360; Wed, 24 May 2023 21:51:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684990310; cv=none; d=google.com; s=arc-20160816; b=XZmgNCjBam3yJXPdnk196T1zfuzc0X9bPFcikyWwV1jVzUo4foo8h1dxIv51VfQYVk BvGlJitWQVKHgqRpTirKZchJijjf0sL2Aw89dWLjc1YzVCz7pmPZt8u2CuribsoZmjbL pkHx/cXl0IxEybzpl9qukz0Y25uMSREog0zJ8vp/JNeVJv/KsKPtkGxzIHlJ2GPqsog0 gvue+kk4hkqlXJtknzAIp331lDjstC1pu6Ik6KRj63MTFJxrbXthSUANN7wqJinkoTG2 wKVYN32UBcpMbYwoFZuiQGPvlATf2bnvRtI7yJP8u6ffAaGeRZf2WeI3ppsEC6FOwFSn nbWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:dkim-signature; bh=h22KcdDW+e3HIJ3qCk8f6uRtdHrJbepUzOMtxc5VPwI=; b=R0bmyvFUk0/r52zKAWiLVwTmOU/ttFPd8crEJaO0++/CNKgSkQfSFyikDnQQRlOKRv DJ6ZlyV4H3J5XGBg0isXiPvkgie8F2ioecrbrax2TCz9gbGXXD/TIy4UgVnPe5MUYPJg QNmO3MAqvJxAXw07ny2FU3UgTZQukX/4+m5Caz927O28KpSu8lvQXmfLcsv0FF20oYJD hOH2Dryhdg4Ey91P+hbGZR8mrnHD09jqIlfnlF+n+dee4RZ5DDr8krhYtoHImREXR4SS cwkI1BIG/9YTavYMP0I8sQlPJ+E43AEI/TcUZT7ibC2FcsqHUdxp4ruKb+QUG8TybinF fj7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=CGWwt3EY; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i129-20020a625487000000b0064d48952fd6si598756pfb.28.2023.05.24.21.51.34; Wed, 24 May 2023 21:51:50 -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=@google.com header.s=20221208 header.b=CGWwt3EY; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233958AbjEYEVz (ORCPT <rfc822;ahmedalshaiji.dev@gmail.com> + 99 others); Thu, 25 May 2023 00:21:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47876 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233044AbjEYEVv (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 25 May 2023 00:21:51 -0400 Received: from mail-yw1-x1149.google.com (mail-yw1-x1149.google.com [IPv6:2607:f8b0:4864:20::1149]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2396DA1 for <linux-kernel@vger.kernel.org>; Wed, 24 May 2023 21:21:50 -0700 (PDT) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-5657dbf8cecso2721697b3.3 for <linux-kernel@vger.kernel.org>; Wed, 24 May 2023 21:21:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1684988509; x=1687580509; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=h22KcdDW+e3HIJ3qCk8f6uRtdHrJbepUzOMtxc5VPwI=; b=CGWwt3EY0REZavrmYjs32dYAglkBR8cgjqeEK3OHeWZjUJ2pxNnkNCEg0jT0dnDBP3 cWYJbc25APeCHHmdmS/2iGMxKJ3h2zEO658jN8FsJxZyAoVmOAlei1YO3Kuhcqi+cJ9c uVOiI37b9BW3E3n9eg1sGRsrAYZdBlTbnEitdiISsAZnHfFT6nlmKEXUEm7hAejLPVvC e+D5gRufPO4dg+RfwHEqyF/e9PqsCnqbrdsb2Vkz5+1c4G+X2mhNHqP9OqrRofcheN4u LsreVlXoRHtUazSWdfB+PT5+th2suuaCZzdWUsuAycqVGwUyJqpG6jMBnZkAUvEG1xz0 XmcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684988509; x=1687580509; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=h22KcdDW+e3HIJ3qCk8f6uRtdHrJbepUzOMtxc5VPwI=; b=PKU/i5ICmdJVGbTGSlpYukMvJr4SilEQBSp2uTJ5ElyMOzG6BiGTXd+Jo2i8xy20Nt ZjIgy6u68adJIUsZXzQM6ZCmtNn3WZLzOpQNh7MSD2TtibaghEv/+eDcwPIetoFXoZcd pnMQN4OrlJ29vH7qLaTgnDCegqDIo+BQ1wWZiwkqJP4jph8xDU+waAp2gWJZQAXjDy7t CarJitv5H7cYrHO7H12HffRcuod59XE1fXMyxuWvlO9tpfpNo2DTMN0b6nbZgKvIgTgM S8JPElSNgSDBGPa3iiQIy64JiVnztjKabZCBIjKpR+gcofNHFn9dwW09/8PizOX6Xi0g XwSg== X-Gm-Message-State: AC+VfDyg6G7vch/mj7oKMyIOmDWerkG5AKKB5ecxaCwVLYGfx5s0XPGl CqLv33rYKWrJRKVNSJcWSUQuqts6g0ddDA== X-Received: from slicestar.c.googlers.com ([fda3:e722:ac3:cc00:4f:4b78:c0a8:20a1]) (user=davidgow job=sendgmr) by 2002:a81:ae68:0:b0:561:94a8:29c5 with SMTP id g40-20020a81ae68000000b0056194a829c5mr11971369ywk.4.1684988509366; Wed, 24 May 2023 21:21:49 -0700 (PDT) Date: Thu, 25 May 2023 12:21:29 +0800 In-Reply-To: <20230525042133.212534-1-davidgow@google.com> Mime-Version: 1.0 References: <20230525042133.212534-1-davidgow@google.com> X-Mailer: git-send-email 2.41.0.rc0.172.g3f132b7071-goog Message-ID: <20230525042133.212534-2-davidgow@google.com> Subject: [PATCH v3 2/4] kunit: executor_test: Use kunit_add_action() From: David Gow <davidgow@google.com> To: Matti Vaittinen <mazziesaccount@gmail.com>, Daniel Latypov <dlatypov@google.com>, Maxime Ripard <maxime@cerno.tech>, Benjamin Berg <benjamin@sipsolutions.net>, Brendan Higgins <brendan.higgins@linux.dev>, Stephen Boyd <sboyd@kernel.org>, Shuah Khan <skhan@linuxfoundation.org>, Rae Moar <rmoar@google.com> Cc: David Gow <davidgow@google.com>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, "Rafael J . Wysocki" <rafael@kernel.org>, Heikki Krogerus <heikki.krogerus@linux.intel.com>, Jonathan Cameron <jic23@kernel.org>, Sadiya Kazi <sadiyakazi@google.com>, Jonathan Corbet <corbet@lwn.net>, linux-doc@vger.kernel.org, kunit-dev@googlegroups.com, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Benjamin Berg <benjamin.berg@intel.com> Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766840399291822428?= X-GMAIL-MSGID: =?utf-8?q?1766840399291822428?= |
Series |
[v3,1/4] kunit: Add kunit_add_action() to defer a call until test exit
|
|
Commit Message
David Gow
May 25, 2023, 4:21 a.m. UTC
Now we have the kunit_add_action() function, we can use it to implement kfree_at_end() and free_subsuite_at_end() without the need for extra helper functions. Reviewed-by: Benjamin Berg <benjamin.berg@intel.com> Reviewed-by: Maxime Ripard <maxime@cerno.tech> Tested-by: Maxime Ripard <maxime@cerno.tech> Signed-off-by: David Gow <davidgow@google.com> --- No changes since v2: https://lore.kernel.org/linux-kselftest/20230518083849.2631178-2-davidgow@google.com/ Changes since v1: https://lore.kernel.org/linux-kselftest/20230421084226.2278282-3-davidgow@google.com/ - Use the kunit_action_t typedef Changes since RFCv2: https://lore.kernel.org/linux-kselftest/20230331080411.981038-3-davidgow@google.com/ - Don't use the no-longer-extant kunit_defer_func_t typedef. - Don't pass a GFP pointer in. --- lib/kunit/executor_test.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/lib/kunit/executor_test.c b/lib/kunit/executor_test.c index 0cea31c27b23..ce6749af374d 100644 --- a/lib/kunit/executor_test.c +++ b/lib/kunit/executor_test.c @@ -125,11 +125,6 @@ kunit_test_suites(&executor_test_suite); /* Test helpers */ -static void kfree_res_free(struct kunit_resource *res) -{ - kfree(res->data); -} - /* Use the resource API to register a call to kfree(to_free). * Since we never actually use the resource, it's safe to use on const data. */ @@ -138,8 +133,10 @@ static void kfree_at_end(struct kunit *test, const void *to_free) /* kfree() handles NULL already, but avoid allocating a no-op cleanup. */ if (IS_ERR_OR_NULL(to_free)) return; - kunit_alloc_resource(test, NULL, kfree_res_free, GFP_KERNEL, - (void *)to_free); + + kunit_add_action(test, + (kunit_action_t *)kfree, + (void *)to_free); } static struct kunit_suite *alloc_fake_suite(struct kunit *test,