From mboxrd@z Thu Jan 1 00:00:00 1970 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 7FDBCC77B7C for ; Wed, 10 May 2023 05:39:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235965AbjEJFjC (ORCPT ); Wed, 10 May 2023 01:39:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43778 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235935AbjEJFi5 (ORCPT ); Wed, 10 May 2023 01:38:57 -0400 Received: from mail-yw1-x114a.google.com (mail-yw1-x114a.google.com [IPv6:2607:f8b0:4864:20::114a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CD3CA2D43 for ; Tue, 9 May 2023 22:38:52 -0700 (PDT) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-559fb5bed89so75465127b3.0 for ; Tue, 09 May 2023 22:38:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1683697132; x=1686289132; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=Mfo42Q0Y+93PbUz1Yll6pAE36cAitDEFg/Zj034KFHY=; b=rmd4TKqnOZTd1yPShThAvmZvlcVmX5R+MgeqNKnU3hjsvhOeXoQWw53L4vlBu24w2O uJeQvXfNnt98wUYtlcyRgAKitZINh5JyjVOuwF2GxPSJXqIIV43P6XuSWOqjS5pmNHR6 VWUzt2NU3BYqGgVPQoBsH9Fk3x8n7j9XYXs5WxGPAabxedPFurLRhNz++N8msmsf+MO5 9isTNnVN+Qp9/1ik9kKp3mLdQlDkvGApwVj8S645AWqwdb2rgbtLQBp1C5Bv27LIO3IT zG2Dvkum7WvbQ5CKzfSr4xngncd/YTFZzlcD7oU6Cp1VOBzOSnXoEL7Olo8pNbumiaym Bv0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683697132; x=1686289132; 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=Mfo42Q0Y+93PbUz1Yll6pAE36cAitDEFg/Zj034KFHY=; b=BZPWmdI0/9cHGTC6YqTY19NxcPZ8G8AT5I5MtRGOy2P5aMb4NaKCDJ7Uuy+NwVVob0 vZk+l3iC6DAHNmn+XOQP9kA2Bjri8WQ5RnqdDOIFGX5gTlC4XBntP2qIrzSkGYUF0ELL u10j7YpgrNGb4/5TEroWBotc/dRCrbyuazl1ncTIC6iVQX1gS0YEqaI9S48YcEh1L1cd T5YeAdKmsAXdnmokXgaFS6Qye6dz0xYQ/d64saEpRplcYMdFI5WnV727AnBVG50KEMdn kFK+9KZNXsZ7T1C0yV051vHRzljDSNAWc1jJpMwUoPnPIKmd7WSbJJTZRx2xadTCtecz hLWA== X-Gm-Message-State: AC+VfDz8vbn7buldpjCShcTFMybHpUoQvZ8TC0YXLXpIyCTVnfK2/V1U Q3NtLm12oTU7ycTulky5Nqxfqs7edMwNfQ== X-Google-Smtp-Source: ACHHUZ4e/K50fW2t0YQaNJVoN4iOC0HO0V4/JFVNf7CQLXQsKDEhj8MTD0BwKOn6kf9Vf6zoEUsUiv90+jKT8g== X-Received: from slicestar.c.googlers.com ([fda3:e722:ac3:cc00:4f:4b78:c0a8:20a1]) (user=davidgow job=sendgmr) by 2002:a81:c903:0:b0:556:cacc:1f1d with SMTP id o3-20020a81c903000000b00556cacc1f1dmr10154166ywi.8.1683697132036; Tue, 09 May 2023 22:38:52 -0700 (PDT) Date: Wed, 10 May 2023 13:38:32 +0800 In-Reply-To: <20230510053832.438529-1-davidgow@google.com> Mime-Version: 1.0 References: <20230510053832.438529-1-davidgow@google.com> X-Mailer: git-send-email 2.40.1.521.gf1e218fcd8-goog Message-ID: <20230510053832.438529-4-davidgow@google.com> Subject: [PATCH v4 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" 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. Reviewed-by: Rae Moar Signed-off-by: David Gow --- Changes since v3: https://lore.kernel.org/linux-kselftest/20230421040218.2156548-4-davidgow@google.com/ - Rebased on top of latest kselftest/kunit branch. - Added Reviewed-by tag. 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.1.521.gf1e218fcd8-goog