Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp1729490rwr; Thu, 20 Apr 2023 21:25:28 -0700 (PDT) X-Google-Smtp-Source: AKy350ZMJmUjQA4F2tkrXx9+VAJvW7Ah9fMSDWN1AT5Hrodoy67iFWtoTxG0WPX3XVIDrjW2iQXr X-Received: by 2002:a17:90a:ff03:b0:247:78eb:cb96 with SMTP id ce3-20020a17090aff0300b0024778ebcb96mr3581145pjb.17.1682051127797; Thu, 20 Apr 2023 21:25:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682051127; cv=none; d=google.com; s=arc-20160816; b=GuRLkucX8MbLZdVrH95D5figAmgWDoFh4adjOwetv3vUvvr5Z0/riAjCgW4jtmitiK jRwVElxJNLnPjwZRnOvlmxl1OojC0unBTltgez5DAmQa5D8VfnDFApCSMBzM40eNhlJH 7H5xwRTY15PkHSsBH3WH95UFSfXsHjlFqQ+y++Asw7waUJYb9DMCLxk9rahunR22Lwq7 mjWr+h5zBNmSGJiXKchdnr1hqmS+O1t9kDCmwz9ql+uuaSI+S4Y6JrPEeM8ic6w2Irms NPwAbn9wtupvsX8XWqcRg8kGbhGJsPp9VE1NG8oFdPCj3dWxxdX5U5kCXyaHRb9eSOyy fNSQ== 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=EHcf3TtAxqYUDjiNAmiyf7rcYOiQRzr3HgI4M/rAcaU=; b=vvUeSyv1EM6CxpQr0AtOX9+X//0lWzKDykBjrWTFkUZteptQNTLTrIAAYQ43EtTXTD G5IZbP4Z6f+PRsV2chizV2JGJjrteIO3Jnug/p23iSSV5KfBIynke7EQPINWd82Ceyea NcZ6AqRH68Ox2fuqbw7clDjWAbjRRoy6+wPNqPAXqFXOsd8yIXGghjIeuvbmonSxSw3v 15YDvhrnb+cWm6dLAaO/+VFA1NLy5ivXjP4wb+nWnxGZzecP0tPlCsvC9LSecDTvHTsq eYaKygsrqx0wZaXw1dMi4LjcsYcScyzBV+XI/LLOaCTC0xMfDBMXY9DqsO8F57T8lyaw CHug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b="vhOy+/6X"; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 6-20020a17090a190600b002476dde42c7si3513461pjg.170.2023.04.20.21.25.13; Thu, 20 Apr 2023 21:25:27 -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="vhOy+/6X"; 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 S233906AbjDUEC7 (ORCPT + 99 others); Fri, 21 Apr 2023 00:02:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49662 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233801AbjDUECk (ORCPT ); Fri, 21 Apr 2023 00:02:40 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CB42E524B for ; Thu, 20 Apr 2023 21:02:38 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-b8f566ea5e6so3701161276.0 for ; Thu, 20 Apr 2023 21:02:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1682049758; x=1684641758; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=EHcf3TtAxqYUDjiNAmiyf7rcYOiQRzr3HgI4M/rAcaU=; b=vhOy+/6XGUNImozjW6uXE3awKrpBeiSgUUKudpv9mylXFGdVs6orwkvboBIKJ+gUSI fYZxsGRNlFm42JgTEFcUFLD1/1BFY8psdjXBoP38wBHcHbK+wyMHxCGzN+w61d7gytkU vu9cmM7aNMUhG0WLCVGBj+xxPFj9ebAu54bdHCIxwewn0vAO1Cqhp29CDwt7vEBNgg9Q jrC7EJhVkPl+hArDZNM17DQB7/02YtPjoh48F2mhv8wHzWaUCan39/Vnac6KexCLRV0V hXowYu8GYiC8PFpOmN/hmhw7rl1DR50qb8sDWApZ6QcE+iUGe+OnLapi388bUTfWh++g r0YQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682049758; x=1684641758; 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=EHcf3TtAxqYUDjiNAmiyf7rcYOiQRzr3HgI4M/rAcaU=; b=IbPBEW7Mtu1F/fyGtDDG2ngqweLkraf9f3WFnh7rBEXdjeChRQhcwyGBg0T9MR609p A1LlQDHZ3O2upyt4iAbRQWE4URMD1rFLDAtR9jrzuWDluCgW07tbfvHSJpMYSV8fRvbB a1NWesYw1Ehzt4PdFMULLCp+BaXGv9v/IAw8UEGpNlrlANhFm0GvcYPWVQbFXCFDGTLM fUWWh16N4ySaYw0mT4pWqBu0XvrFu8U9jj7wh91Xeqo5FllIWTG/dID3nG3F4t5763qh 9+DUBWhVa9w1RipZ5p86mSJeTQy0k43wp03tGsQ6DjMjWlNwqMrsuGu7VjMpOSoZuJlx 69gg== X-Gm-Message-State: AAQBX9dkZjH2SbnOhJHHpdCluYLBNaN+DOqtLmdLK2a4oxyw5GwBvbpv iy9expqJPO4PC2lqFGM2UmfI7IzwF25lmg== X-Received: from slicestar.c.googlers.com ([fda3:e722:ac3:cc00:4f:4b78:c0a8:20a1]) (user=davidgow job=sendgmr) by 2002:a05:690c:2b88:b0:54c:15ad:11e4 with SMTP id en8-20020a05690c2b8800b0054c15ad11e4mr897255ywb.0.1682049758080; Thu, 20 Apr 2023 21:02:38 -0700 (PDT) Date: Fri, 21 Apr 2023 12:02:18 +0800 In-Reply-To: <20230421040218.2156548-1-davidgow@google.com> Mime-Version: 1.0 References: <20230421040218.2156548-1-davidgow@google.com> X-Mailer: git-send-email 2.40.0.634.g4ca3ef3211-goog Message-ID: <20230421040218.2156548-4-davidgow@google.com> Subject: [PATCH v3 4/4] kunit: example: Provide example exit functions From: David Gow To: Benjamin Berg , Brendan Higgins , Shuah Khan , Rae Moar , Daniel Latypov Cc: David Gow , maxime@cerno.tech, Stephen Boyd , kunit-dev@googlegroups.com, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Sadiya Kazi 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: X-Mailing-List: linux-kernel@vger.kernel.org Add an example .exit and .suite_exit function to the KUnit example suite. Given exit functions are a bit more subtle than init functions (due to running in a different kthread, and running even after tests or test init functions fail), providing an easy place to experiment with them is useful. Signed-off-by: David Gow --- This patch was introduced in v3. --- lib/kunit/kunit-example-test.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/lib/kunit/kunit-example-test.c b/lib/kunit/kunit-example-test.c index cd8b7e51d02b..24315c882b31 100644 --- a/lib/kunit/kunit-example-test.c +++ b/lib/kunit/kunit-example-test.c @@ -41,6 +41,16 @@ static int example_test_init(struct kunit *test) return 0; } +/* + * This is run once after each test case, see the comment on + * example_test_suite for more information. + */ +static void example_test_exit(struct kunit *test) +{ + kunit_info(test, "cleaning up\n"); +} + + /* * This is run once before all test cases in the suite. * See the comment on example_test_suite for more information. @@ -52,6 +62,16 @@ static int example_test_init_suite(struct kunit_suite *suite) return 0; } +/* + * This is run once after all test cases in the suite. + * See the comment on example_test_suite for more information. + */ +static void example_test_exit_suite(struct kunit_suite *suite) +{ + kunit_info(suite, "exiting suite\n"); +} + + /* * This test should always be skipped. */ @@ -211,7 +231,9 @@ static struct kunit_case example_test_cases[] = { static struct kunit_suite example_test_suite = { .name = "example", .init = example_test_init, + .exit = example_test_exit, .suite_init = example_test_init_suite, + .suite_exit = example_test_exit_suite, .test_cases = example_test_cases, }; -- 2.40.0.634.g4ca3ef3211-goog