Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp880841pxv; Fri, 25 Jun 2021 00:00:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyuS/ZY3dut4Vr5FRKCg7eiUbkeHQIqwH3vjbqefIf9XxlTgYZ4Pwyn4XXHTyeD7cNo88iI X-Received: by 2002:a17:906:480a:: with SMTP id w10mr9279741ejq.18.1624604439231; Fri, 25 Jun 2021 00:00:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624604439; cv=none; d=google.com; s=arc-20160816; b=clOmB3DiGtO+s6gcU/fnNSolqjior2ggd5wES32uu5n3pwdHVOQgV/w6BX8/g86Thz AVuxQ0rVHCz2PsAatfnn5K1fplvkNZOjo8VU+lnmxO0OWZrecDRiVL4NCo0iWrNYVX1n vAoDWuuygCzxM4hB9R59gw4WjN1H13ZKjsVerCUF9xs2dxtrVVvgZRZtuEVlDNuxp8X+ /ryOH87n6HVQTPkMicy+XWsYtqXeVXhmMp/bguIbOrD8fHYUbAka+qzno1V/vIQDD/LO +VyrfYYQ8xGuAsukuHhua3uG2F+gBnCffbMPqtPGWszi0DDx+GoRaC4J0ID5e8aSfZnr Qi5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:references:mime-version :message-id:in-reply-to:date:dkim-signature; bh=oc9ussIVPpLKNQyBAih5iA2F2VxRRfpcgUOh/ls8NWQ=; b=KbVW2lQhnsexYA1d6gF9zbbIACcgcyp+fkQ5/PtzhL8KVVynjwdu7T6TqbWdAqaatY 84RRzfIwz3uQa/TuRFxrM5FAvWjtAEgGQNEvIuxvwtsAVdozpRLqjHniXIPYfv+TmJXK OZsEJqCiWDKTsXGVAvK5EdX6IGjIUNrRPcfhAvMq4PbtJSutp4Jeb/SkLAqkhNufJcMy zqkNq8lvIJPrDzG2DWYL5JRALrhGnLmGjyRAyqxpTO8alA0upCLNnTAB8zcIkHXZePHo RIWvng5j/X3V0vpCG2D4ElPf+8iIKiX5KzHCn4Zf6tREw1a/rtlK6rl13CPGdHwlEIhi 0j+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Bok1hqFg; 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 be4si5371606edb.319.2021.06.25.00.00.01; Fri, 25 Jun 2021 00:00:39 -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=Bok1hqFg; 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 S229906AbhFYHAu (ORCPT + 99 others); Fri, 25 Jun 2021 03:00:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39770 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229915AbhFYHAr (ORCPT ); Fri, 25 Jun 2021 03:00:47 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B770DC061574 for ; Thu, 24 Jun 2021 23:58:25 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id j190-20020a253cc70000b029054c72781aa2so2974013yba.9 for ; Thu, 24 Jun 2021 23:58:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=oc9ussIVPpLKNQyBAih5iA2F2VxRRfpcgUOh/ls8NWQ=; b=Bok1hqFg+ciy5bGnz9jNah5nkTl+BmwEKBVWa3dSs5nK1pY9AyaE8s6JjPDQtXj/T7 AUR8FawUkze6o4AQAW6TCjXJEhhdlRIfov+9tcUCjUEGp6Q2YYaU1Uu1b1owJW2LBe6x ez2BroXx8KuKvcte6kbASBNnXkVpt5kyBlCRzQqCu8hecHWwPpcUFeX79tNIcFU9hTzp hKgyrHFpYeIBlEdmvgjkA1QE74dLb1NjhKMg9CcoqghN4jebh6RP93ZeAnjw69G2CFln LOhMvM6Pv/H6qPQbJdMek4OtDyE1m2nK8W549H6FeX0mN8jh/wR38ZnYsl/+xLIG4boL YVyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=oc9ussIVPpLKNQyBAih5iA2F2VxRRfpcgUOh/ls8NWQ=; b=g1QSsoac3wmAgdK4jyg+qMop5DFQFVAVOGwq0Xpoi9CgXXEFEOWuYfWc4y9bxCrw5K K7JVfOUjCV2eYaLswpelbXy6347zWtm0bKa8Aht4DgegzcPjGZ5q1QcPuA3MwYJLlL8B Q4mlOdGONV2keYPZybcfHR7jVnez+ggmOo9EGGZsPGauJ5y4TX/hHe8BGhz/BRGPiVfq 9vzvpJtxc585UM5FGX1I7V4qa27aq1idMrXEmSsjbFJwDEpqmWxcJZkIoWXP/A+DJR+X YUOZjcgPcHxq4u2o9Gn1dZJ8FBaacj3vAMSaJ/DmyNlAWHRiYzIA/p9Fd0tLsVGscU24 9ONw== X-Gm-Message-State: AOAM530UJASDDmpGqCEU4Eg/xxDBPlosiNQ2Ueuh1GPgEVwVkdzTOx9D RTStxPpwJ1rwjDJOpBgTZXRrdWAvhishng== X-Received: from spirogrip.svl.corp.google.com ([2620:15c:2cb:201:bd17:f9ad:979a:a3a9]) (user=davidgow job=sendgmr) by 2002:a25:a549:: with SMTP id h67mr10715684ybi.393.1624604304936; Thu, 24 Jun 2021 23:58:24 -0700 (PDT) Date: Thu, 24 Jun 2021 23:58:14 -0700 In-Reply-To: <20210625065815.322131-1-davidgow@google.com> Message-Id: <20210625065815.322131-3-davidgow@google.com> Mime-Version: 1.0 References: <20210625065815.322131-1-davidgow@google.com> X-Mailer: git-send-email 2.32.0.93.g670b81a890-goog Subject: [PATCH kunit-fixes v5 3/4] kunit: test: Add example tests which are always skipped From: David Gow To: Brendan Higgins , Alan Maguire Cc: David Gow , Daniel Latypov , Shuah Khan , Marco Elver , 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 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 --- 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