Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp1026456pxv; Fri, 25 Jun 2021 03:54:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwWZJVMHCzHIBSmHSHzzb9clZkp9ihQR8u8U59wbC2iUv4v99Le7PYDVvNh9Ixglh9C56r8 X-Received: by 2002:a05:6e02:16c5:: with SMTP id 5mr6893885ilx.72.1624618475783; Fri, 25 Jun 2021 03:54:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624618475; cv=none; d=google.com; s=arc-20160816; b=XK0IitVvX1d2NDG5LbW9dLV6juFjywMjhdwwDUdUXeer0mFtKuVNni3F4NB/n7jL4h ahfPzkwvtwTBBmEGk8G6ZkWpMBHPg7mALvkkE1xyG3/CTthpMqDPxzbz23I6WpvUAr2Y w+zxEEN3sXtP1ev8qDhNaKyyWzD5q0hSb0P97FhdZFu+UM2bLVNx+hfavyRr5zrI7BNX SNI24vhZmZoarxzZuDfFO44Q2cAnfgfFczJmeTNgBiBTV25zxomih+HCLNYNFog42yFn rMxdGu/eMqG1qkAo9o+Bm2wTq6/KV/AKeq9YBBAfuV3EBWCLT56wp1qfrqiN+rf3sdNt hFSQ== 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=MHkVJi5PUgd4dGkz/e/ZMJIraqqu+hSTTUd8BwkusHs=; b=Ke9G/4C7iXx23HBqah4oLDP4hyYenH6l58XU+LGvqeOQHc7fyqhPAPXiJN9IfMkcde g7q7A8VzCtqcfyFJfSyFykVhB1BrRFOy2yRknahBx11XSRNSvay6XBK5Th+4SN9TzaiC rGQwQ+tHfXhHGwheXbBZIRhu6ZKfqgGu8NeNVRqJ1BWhYS55gaLcJ3iS1a5I80BXHhYZ khffWr3v8Ujsihx84C9G5HbiyLM4Kn4r5LThUIfJC6dqf5nu5cT6jFx0QbwdOQi1klTq b3tv/X8eyUJtvOdjqI0n5H/wL6QV2Qou2cdUDwR57x5lBSyvC8y5dYktg5U4x/igMKTs H7ew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=ENM+I6bs; 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 h13si6191265jas.116.2021.06.25.03.54.21; Fri, 25 Jun 2021 03:54:35 -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=ENM+I6bs; 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 S229458AbhFYKyv (ORCPT + 99 others); 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-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 >