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 X-Spam-Level: X-Spam-Status: No, score=-23.4 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 52919C2B9F4 for ; Fri, 25 Jun 2021 10:52:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 301876144E for ; Fri, 25 Jun 2021 10:52:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230011AbhFYKyv (ORCPT ); Fri, 25 Jun 2021 06:54:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36982 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229445AbhFYKyu (ORCPT ); Fri, 25 Jun 2021 06:54:50 -0400 Received: from mail-oo1-xc2e.google.com (mail-oo1-xc2e.google.com [IPv6:2607:f8b0:4864:20::c2e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B9C2DC061574 for ; Fri, 25 Jun 2021 03:52:28 -0700 (PDT) Received: by mail-oo1-xc2e.google.com with SMTP id d2-20020a4aa5820000b029024c17addfe5so1756672oom.11 for ; Fri, 25 Jun 2021 03:52:28 -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=MHkVJi5PUgd4dGkz/e/ZMJIraqqu+hSTTUd8BwkusHs=; b=ENM+I6bst47g6xp0fxa3wu1HXqWJrJUkjYCHBFgG+0/DP5W/uyjzlNBQhsDH2+cLEK 4rtiUKRBvDC3Qmwa1En4rPnjnGyxG9DNyWhCu8u85yBB9+aRO+48WBREtJqcX0r8eSh+ 035BZJb5tjCPHIia06lG+YZys+es+yDgcQjrHtqbaa9+xYO+WgQ42GJeI40lwH0OC1dh gUrfv45YS+ZdmxSWl9LiYepcEbq/crdhksx4v1+Uuu/uz1kAjk8fcLsNkCYXv9FMozGL 7TofufL/ECZqzaEfeHfTvvDCTmIuejXIoDBi/dGc7XVWVa74w8TrJ5bHmmPraU+iRtaU JXKQ== 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=MHkVJi5PUgd4dGkz/e/ZMJIraqqu+hSTTUd8BwkusHs=; b=MFLWb0VgldddvWSpN1/CVg7k6DuECNPX1gJ6Yskqsr6fvJxgx0bzCji6ZikhnKCDdU opc6OOEsK0lrBMBXvNReXtlnwsrxGcyI497OxrItnH5gsLlDcqQI2nuEEuoeLLOpvSQ9 WdgZ9sVmEz0iozePaGc/wjptMUqQk9P3Fk3xn4IONarZPP9AQo89a3jiExKWH+Move9H A6bFReUAygPZuvCnuJgHGWTYKlz+zVhYtScEKlDzuOoNFpimx0+WAMZXQiuCPhtle/// 8YRP6ZV4qDX+RTAyJAeheSVGefSrVzFia77cjlcmZRTI871IRkk812ieBXyvSDqQPnrq /4LQ== X-Gm-Message-State: AOAM533VcFZt8Xh7msVshjqsE6FoERCGTZ8Fp7cOZSlktODsVhE+8e87 byjWHy4mhtfBZ6vdIYy2uSHYZlXoVUL9VitCJSdNdA== X-Google-Smtp-Source: ABdhPJwQvR7nr/9k9nUvttiDTU6+VyHuKlXbHY7w2j8RwsPiDhordBvFljONCyEjoOkwdD6o6W7gDCGMCToeD0QXfVk= X-Received: by 2002:a4a:9406:: with SMTP id h6mr8636435ooi.36.1624618347906; Fri, 25 Jun 2021 03:52:27 -0700 (PDT) MIME-Version: 1.0 References: <20210625065815.322131-1-davidgow@google.com> <20210625065815.322131-3-davidgow@google.com> In-Reply-To: <20210625065815.322131-3-davidgow@google.com> From: Marco Elver Date: Fri, 25 Jun 2021 12:52:16 +0200 Message-ID: Subject: Re: [PATCH kunit-fixes v5 3/4] kunit: test: Add example tests which are always skipped To: David Gow Cc: Brendan Higgins , Alan Maguire , Daniel Latypov , Shuah Khan , kunit-dev@googlegroups.com, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 25 Jun 2021 at 08:58, David Gow 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 > Reviewed-by: Daniel Latypov > Reviewed-by: Brendan Higgins Reviewed-by: Marco Elver > --- > > 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 >