Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp5551563pxj; Wed, 26 May 2021 13:21:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz3A4r2YdHQqSNf1Rkj3xDjUdqYGT2YYFM981HFk9zvItILVxHzrFLdVdZv+0bfzJhl2vmB X-Received: by 2002:a05:6402:176b:: with SMTP id da11mr51398edb.234.1622060497638; Wed, 26 May 2021 13:21:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622060497; cv=none; d=google.com; s=arc-20160816; b=ByBanXHOBSJsTb4ihH6goGGd7l7xPkCNbn7lAdljelatfmyzjOxTJlRozohwHNYqjE /5xqgrs2yzqpz5ybw5QEF289Ju2HkdtDxu2Q+J2YIlOd5YCw29LLWzjQQ+kjKY+H/X2S njZb9jCYKSSbVTUxTuNFMfcHZSDVi8LN57vOyuOcYqz5ubaLDGLGaG4BHHgFRPjWUtRq FBozwdaahonCUfrtR0FKskH1ADlXRAIjtOo9hYa0mVZverK+kDVE97HT0iP/qJZUhjTl oCA0yutkeqwB6MVP0JIvhI1WOzSSloMnnlPtUuvru+IudDrPFFCNNCk+1gqJi8XaXQUf FoZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=8SDJrdOBe6ySfeILDdQr6VPuIr0LmlxVhGD8mArU7LU=; b=MXG7NedT1dVgbo+jAYN7RXJXNpzADfdKSIm/sySzx2c5XfUps0mOieNXF8jZoseUZy mjFT0cpbnNnBWf1zbStNu4iFHCdb1YzzVYssHRfpSBP/Blw2HkjXsAj6iRmGaMHuHFSZ 8jlBeTrgZHYd504fcmMbJQPIZqsw0uTwLZ0jkAx1UIZIKnyMkg1MN1ZV334hvAjIs9FL pV6Caxyh6JTVvBRtl/2T8ms3zOp26SHNgrSJLurGeOVpRpu/zHvFmNRDMLRBY/m5f44a PC2SiPFQP3l4QGimTX7Vxce8FNBYYpdBX+1AoYBmB+S1LFKsmTIQTun1xVA7tun2GGFe NxzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=p9yXbqGk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y59si273212ede.390.2021.05.26.13.21.11; Wed, 26 May 2021 13:21:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=p9yXbqGk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S234514AbhEZS76 (ORCPT + 99 others); Wed, 26 May 2021 14:59:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38550 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234424AbhEZS7w (ORCPT ); Wed, 26 May 2021 14:59:52 -0400 Received: from mail-io1-xd32.google.com (mail-io1-xd32.google.com [IPv6:2607:f8b0:4864:20::d32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4F9F6C061574 for ; Wed, 26 May 2021 11:58:19 -0700 (PDT) Received: by mail-io1-xd32.google.com with SMTP id d25so2160603ioe.1 for ; Wed, 26 May 2021 11:58:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=8SDJrdOBe6ySfeILDdQr6VPuIr0LmlxVhGD8mArU7LU=; b=p9yXbqGk0cvod+zrx+1bSBAhif3+gKbuRHcUglongDOLMz4EimhMJsF8bpCYgx7H5r sniXu1Ax7gMidqlYWmqYj/wkA2NVqUy/QIq7M9knO8QALo8AjVfCCYagSI0qzOk3r2FE 3b2g9aE0xg/qBBkcYowKhwqkubXpjWTLDWN+3NRFpC8mXr7jGNUXGSYgWxC9xUKvJYwO UOEyrgBbQvP/0HaMV0Vt+LRFWEqL5x7PgdL4cIiwlFlukiVXNn2tWIXzO5SNe67Il2/r eN6BVW5gfxFqJ+g1Cd9r4VYx8A5SrGYqeqKlWg3sM0xXk91iFVoWgp+c14TVC9NJPWAp G1jQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=8SDJrdOBe6ySfeILDdQr6VPuIr0LmlxVhGD8mArU7LU=; b=EeFilPvnC2Z+tySrE6Z3RsVvpu+F3QmHq/bH73XOU4y+G4Nnbo0t0d8NRO/dI6gYxw kXJgbEAjXlqOoxK9bh076QX3draQHma0HOmr0oqJg3gbRNHAVHHafgsZhkKR8KZG6qTX TXSfjTwUo+MtZHhEzW8gITsHk4y/vxmxS52rpVwXD8xKla0Img0SCpkWVOdNpdx6i1Iy bzQtP+WRK/WdA9fttGtLsl0pWYh2E2nPPWXIzFPPFTuYTUbYK8AyEmdRvpLHwGZvoyBD qYmRrHCIzlcjcM3S3vNPehiw8w11oxsNxR2fB+ODR19vgjDoiW3Nfze0Qm/mlqAng9K1 bgzg== X-Gm-Message-State: AOAM5336IWcrTDRW1CGM1mTwigBlZf7UvEpUpgk9QkFYIS83YD/wxXIN wuPVc2QFYxn79zlk4L0O7U/xedMeDSC32/dXb2Z8OQ== X-Received: by 2002:a02:aa85:: with SMTP id u5mr4725019jai.75.1622055498359; Wed, 26 May 2021 11:58:18 -0700 (PDT) MIME-Version: 1.0 References: <20210526081112.3652290-1-davidgow@google.com> <20210526081112.3652290-3-davidgow@google.com> In-Reply-To: <20210526081112.3652290-3-davidgow@google.com> From: Daniel Latypov Date: Wed, 26 May 2021 11:58:07 -0700 Message-ID: Subject: Re: [PATCH 3/3] kunit: test: Add example_skip test suite which is always skipped To: David Gow Cc: Brendan Higgins , Alan Maguire , Shuah Khan , Marco Elver , KUnit Development , "open list:KERNEL SELFTEST FRAMEWORK" , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 26, 2021 at 1:11 AM 'David Gow' via KUnit Development wrote: > > Add a new KUnit test suite which contains tests which are always > skipped. This is used as an example for how to write tests which are > skipped, and to demonstrate the difference between kunit_skip() and > kunit_mark_skipped(). > > Because these tests do not pass (they're skipped), they are not enabled > by default, or by the KUNIT_ALL_TESTS config option: they must be > enabled explicitly by setting CONFIG_KUNIT_EXAMPLE_SKIP_TEST=y in either > a .config or .kunitconfig file. > > Signed-off-by: David Gow Reviewed-by: Daniel Latypov LGTM, two minor nits, and as noted elsewhere, I'd like it if we could have this be in the normal example test. But even if that doesn't happen, this seems fine to me. > --- > lib/kunit/Kconfig | 15 +++++++++ > lib/kunit/Makefile | 2 ++ > lib/kunit/kunit-example-skip-test.c | 52 +++++++++++++++++++++++++++++ > 3 files changed, 69 insertions(+) > create mode 100644 lib/kunit/kunit-example-skip-test.c > > diff --git a/lib/kunit/Kconfig b/lib/kunit/Kconfig > index 0b5dfb001bac..399fe5f789f7 100644 > --- a/lib/kunit/Kconfig > +++ b/lib/kunit/Kconfig > @@ -45,6 +45,21 @@ config KUNIT_EXAMPLE_TEST > is intended for curious hackers who would like to understand how to > use KUnit for kernel development. > > +config KUNIT_EXAMPLE_SKIP_TEST > + tristate "Skipped test example for KUnit" > + default n > + help > + Enables an example unit test that is always skipped. > + > + This test only exists to help new users understand what KUnit is and > + how it is used. Please refer to the example test itself, > + lib/kunit/example-test.c, for more information. This option is > + intended for curious hackers who would like to understand how to use > + KUnit for kernel development. > + > + Because this test does not pass, it is not enabled by > + CONFIG_KUNIT_ALL_TESTS > + > config KUNIT_ALL_TESTS > tristate "All KUnit tests with satisfied dependencies" > help > diff --git a/lib/kunit/Makefile b/lib/kunit/Makefile > index c49f4ffb6273..8a99ff2f83bd 100644 > --- a/lib/kunit/Makefile > +++ b/lib/kunit/Makefile > @@ -18,3 +18,5 @@ obj-$(CONFIG_KUNIT_TEST) += string-stream-test.o > endif > > obj-$(CONFIG_KUNIT_EXAMPLE_TEST) += kunit-example-test.o > + > +obj-$(CONFIG_KUNIT_EXAMPLE_SKIP_TEST) += kunit-example-skip-test.o > diff --git a/lib/kunit/kunit-example-skip-test.c b/lib/kunit/kunit-example-skip-test.c > new file mode 100644 > index 000000000000..5395ee0be485 > --- /dev/null > +++ b/lib/kunit/kunit-example-skip-test.c > @@ -0,0 +1,52 @@ > +// SPDX-License-Identifier: GPL-2.0 > +/* > + * Example KUnit test which is always skipped. > + * > + * Copyright (C) 2021, Google LLC. > + * Author: David Gow > + */ > + > +#include > + > +/* > + * This test should always be skipped. > + */ > + > +static void example_skip_test(struct kunit *test) > +{ > + /* This line should run */ > + kunit_log(KERN_INFO, test, "You should not see a line below."); Btw, why not "kunit_info(test, ...)" ? > + > + /* Skip (and abort) the test */ > + kunit_skip(test, "this test should be skipped"); > + > + /* This line should not execute */ > + kunit_log(KERN_INFO, test, "You should not see this line."); Would it be more or less confusing to have KUNIT_FAIL(test, "We should not get to this line") maybe in addition or instead of this log? > +} > + > +static void example_mark_skipped_test(struct kunit *test) > +{ > + /* This line should run */ > + kunit_log(KERN_INFO, test, "You should see a line below."); > + > + /* Skip (but do not abort) the test */ > + kunit_mark_skipped(test, "this test should be skipped"); > + > + /* This line should run */ > + kunit_log(KERN_INFO, test, "You should see this line."); > +} > + > +static struct kunit_case example_skip_test_cases[] = { > + KUNIT_CASE(example_skip_test), > + KUNIT_CASE(example_mark_skipped_test), > + {} > +}; > + > +static struct kunit_suite example_skip_test_suite = { > + .name = "example_skip", > + .test_cases = example_skip_test_cases, > +}; > + > +kunit_test_suites(&example_skip_test_suite); > + > +MODULE_LICENSE("GPL v2"); > -- > 2.31.1.818.g46aad6cb9e-goog > > -- > You received this message because you are subscribed to the Google Groups "KUnit Development" group. > To unsubscribe from this group and stop receiving emails from it, send an email to kunit-dev+unsubscribe@googlegroups.com. > To view this discussion on the web visit https://groups.google.com/d/msgid/kunit-dev/20210526081112.3652290-3-davidgow%40google.com.