linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Marco Elver <elver@google.com>
To: David Gow <davidgow@google.com>
Cc: Brendan Higgins <brendanhiggins@google.com>,
	Alan Maguire <alan.maguire@oracle.com>,
	Daniel Latypov <dlatypov@google.com>,
	Shuah Khan <skhan@linuxfoundation.org>,
	kunit-dev@googlegroups.com, linux-kselftest@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH kunit-fixes v5 3/4] kunit: test: Add example tests which are always skipped
Date: Fri, 25 Jun 2021 12:52:16 +0200	[thread overview]
Message-ID: <CANpmjNOA8rRzdt-AXsshVff3909TXBx=hHVUkfqX55677EnJFg@mail.gmail.com> (raw)
In-Reply-To: <20210625065815.322131-3-davidgow@google.com>

On Fri, 25 Jun 2021 at 08:58, David Gow <davidgow@google.com> wrote:
>
> Add two new tests to the example test suite, both of 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().
>
> Note that these tests are enabled by default, so a default run of KUnit
> will have two skipped tests.
>
> Signed-off-by: David Gow <davidgow@google.com>
> Reviewed-by: Daniel Latypov <dlatypov@google.com>
> Reviewed-by: Brendan Higgins <brendanhiggins@google.com>

Reviewed-by: Marco Elver <elver@google.com>


> ---
>
> No changes since v4:
> https://lore.kernel.org/linux-kselftest/20210611070802.1318911-3-davidgow@google.com/
>
> No changes since v3:
> https://lore.kernel.org/linux-kselftest/20210608065111.610297-1-davidgow@google.com/
>
> No changes since v2:
> https://lore.kernel.org/linux-kselftest/20210528075932.347154-3-davidgow@google.com/
>
> Changes since v1:
> https://lore.kernel.org/linux-kselftest/20210526081112.3652290-3-davidgow@google.com/
> - These tests are now part of the example test suite.
> - Use kunit_info() instead of kunit_log(KERN_INFO, ...)
> - Use KUNIT_FAIL() to assert the test is not executing for skip_test
>
>  lib/kunit/kunit-example-test.c | 31 +++++++++++++++++++++++++++++++
>  1 file changed, 31 insertions(+)
>
> diff --git a/lib/kunit/kunit-example-test.c b/lib/kunit/kunit-example-test.c
> index be1164ecc476..51099b0ca29c 100644
> --- a/lib/kunit/kunit-example-test.c
> +++ b/lib/kunit/kunit-example-test.c
> @@ -40,6 +40,35 @@ static int example_test_init(struct kunit *test)
>         return 0;
>  }
>
> +/*
> + * This test should always be skipped.
> + */
> +static void example_skip_test(struct kunit *test)
> +{
> +       /* This line should run */
> +       kunit_info(test, "You should not see a line below.");
> +
> +       /* Skip (and abort) the test */
> +       kunit_skip(test, "this test should be skipped");
> +
> +       /* This line should not execute */
> +       KUNIT_FAIL(test, "You should not see this line.");
> +}
> +
> +/*
> + * This test should always be marked skipped.
> + */
> +static void example_mark_skipped_test(struct kunit *test)
> +{
> +       /* This line should run */
> +       kunit_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_info(test, "You should see this line.");
> +}
>  /*
>   * Here we make a list of all the test cases we want to add to the test suite
>   * below.
> @@ -52,6 +81,8 @@ static struct kunit_case example_test_cases[] = {
>          * test suite.
>          */
>         KUNIT_CASE(example_simple_test),
> +       KUNIT_CASE(example_skip_test),
> +       KUNIT_CASE(example_mark_skipped_test),
>         {}
>  };
>
> --
> 2.32.0.93.g670b81a890-goog
>

  reply	other threads:[~2021-06-25 10:52 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-25  6:58 [PATCH kunit-fixes v5 1/4] kunit: Support skipped tests David Gow
2021-06-25  6:58 ` [PATCH kunit-fixes v5 2/4] kunit: tool: Support skipped tests in kunit_tool David Gow
2021-06-25  6:58 ` [PATCH kunit-fixes v5 3/4] kunit: test: Add example tests which are always skipped David Gow
2021-06-25 10:52   ` Marco Elver [this message]
2021-06-25  6:58 ` [PATCH kunit-fixes v5 4/4] kasan: test: make use of kunit_skip() David Gow
2021-06-25 16:43 ` [PATCH kunit-fixes v5 1/4] kunit: Support skipped tests Shuah Khan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CANpmjNOA8rRzdt-AXsshVff3909TXBx=hHVUkfqX55677EnJFg@mail.gmail.com' \
    --to=elver@google.com \
    --cc=alan.maguire@oracle.com \
    --cc=brendanhiggins@google.com \
    --cc=davidgow@google.com \
    --cc=dlatypov@google.com \
    --cc=kunit-dev@googlegroups.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=skhan@linuxfoundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).