From patchwork Wed Sep 22 18:25:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marco Elver X-Patchwork-Id: 12511235 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=-26.3 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_AGENT_GIT,USER_IN_DEF_DKIM_WL autolearn=ham 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 6234BC433F5 for ; Wed, 22 Sep 2021 18:26:02 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 04C9461352 for ; Wed, 22 Sep 2021 18:26:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 04C9461352 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 5FE2494000E; Wed, 22 Sep 2021 14:26:01 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5AD2A6B0095; Wed, 22 Sep 2021 14:26:01 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 49C3C94000E; Wed, 22 Sep 2021 14:26:01 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0046.hostedemail.com [216.40.44.46]) by kanga.kvack.org (Postfix) with ESMTP id 38AD76B0093 for ; Wed, 22 Sep 2021 14:26:01 -0400 (EDT) Received: from smtpin39.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id DB38C8249980 for ; Wed, 22 Sep 2021 18:26:00 +0000 (UTC) X-FDA: 78616038480.39.7392226 Received: from mail-ed1-f74.google.com (mail-ed1-f74.google.com [209.85.208.74]) by imf22.hostedemail.com (Postfix) with ESMTP id 9EA1E1903 for ; Wed, 22 Sep 2021 18:26:00 +0000 (UTC) Received: by mail-ed1-f74.google.com with SMTP id r11-20020aa7cfcb000000b003d4fbd652b9so4064353edy.14 for ; Wed, 22 Sep 2021 11:26:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:message-id:mime-version:subject:from:to:cc; bh=hROscUrgx82P/DRIV1g6rbQ4KwPphWmoM+tTMU2qK8E=; b=tT1s4L2x6/uDOqLYSEh3Cmnj+ZHPMdfbAxewhCnCi7iihLKnXqzVTxuJICz31WdiO4 CdpeOB1ExJfMITOZW+iEJZbkMbCHW5pwhHM1gu8pb3c3YAWVfIbWvD4Py0P1+wAykada NhKdgQHNGCk2ptgfOfgqFKOdDNE12fY8Cc+LRyOvL/nnb9MEnqI1HjqYMbagGowokSND veZavqCog8HDfcRtxdEFAiDHcsY6AKF4WJCx+yz8ub9gnl3VsTL8v01NRVYBokYMidC8 RiSH1FuNAoQFULz/cYNIHqj0a8JEyN3Vd8aVF4v4MPXbobsm84Z3v4yVvTAkiLxdVyaL gzGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=hROscUrgx82P/DRIV1g6rbQ4KwPphWmoM+tTMU2qK8E=; b=e3oKSfSoAhsxkrvNZUMTbLyIxWYR84njCbcY2f0/zUNund5R76CkQVEm7zB7Gh0dfe HWAIPYLaNh/aEn+8SkWE8vj+Xv+DlJ8d5D5qu5udCWvLFylxsdfpW+sHaMyY3lezLgKb dWj6CmxidoLS309l3XqWe9IHcnnRM+VPMks5noXJuB1kTV11fh3FBZNdrSgDYrv3M5as RXVK2HPno+D0ws081IQHSxryw+/LSvRgMgphSphUrMRUrHwUKJIp78Iy4CsKJWLpGQ6E OG1Er1dXV6lHkqw4y2oRYX7hA5JC5fFn6M/7tAXlzKCjmdWZCd7W2VSDDB8VR2drIlKT v58w== X-Gm-Message-State: AOAM532j2VQ4QCRXkY1n2D0jyi/FgNXqmtvdO0hXy8gw2vVgbjd0o6Pp FO1GVWdIvcCoUeLZ3IZfoBb40mEk5A== X-Google-Smtp-Source: ABdhPJy953tfY9ijLr1x+Rwh6kZsYSkYidCYFHPT0Ea43m43CeZ5zIGy0NE+O0TI7KqGRAQSDbBMtY29Og== X-Received: from elver.muc.corp.google.com ([2a00:79e0:15:13:d1cb:58a8:28e2:c853]) (user=elver job=sendgmr) by 2002:a17:906:6c94:: with SMTP id s20mr722795ejr.152.1632335159064; Wed, 22 Sep 2021 11:25:59 -0700 (PDT) Date: Wed, 22 Sep 2021 20:25:41 +0200 Message-Id: <20210922182541.1372400-1-elver@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.33.0.464.g1972c5931b-goog Subject: [PATCH] kfence: test: use kunit_skip() to skip tests From: Marco Elver To: elver@google.com, Andrew Morton Cc: Alexander Potapenko , Dmitry Vyukov , Aleksandr Nogikh , Taras Madan , linux-kernel@vger.kernel.org, linux-mm@kvack.org, kasan-dev@googlegroups.com, David Gow X-Stat-Signature: 8ujczykg8ue147wsydxt6ntkry6zqo74 Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=tT1s4L2x; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf22.hostedemail.com: domain of 3N3VLYQUKCGACJTCPEMMEJC.AMKJGLSV-KKIT8AI.MPE@flex--elver.bounces.google.com designates 209.85.208.74 as permitted sender) smtp.mailfrom=3N3VLYQUKCGACJTCPEMMEJC.AMKJGLSV-KKIT8AI.MPE@flex--elver.bounces.google.com X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 9EA1E1903 X-HE-Tag: 1632335160-550055 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Use the new kunit_skip() to skip tests if requirements were not met. It makes it easier to see in KUnit's summary if there were skipped tests. Signed-off-by: Marco Elver Reviewed-by: David Gow --- mm/kfence/kfence_test.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/mm/kfence/kfence_test.c b/mm/kfence/kfence_test.c index f1690cf54199..695030c1fff8 100644 --- a/mm/kfence/kfence_test.c +++ b/mm/kfence/kfence_test.c @@ -32,6 +32,11 @@ #define arch_kfence_test_address(addr) (addr) #endif +#define KFENCE_TEST_REQUIRES(test, cond) do { \ + if (!(cond)) \ + kunit_skip((test), "Test requires: " #cond); \ +} while (0) + /* Report as observed from console. */ static struct { spinlock_t lock; @@ -555,8 +560,7 @@ static void test_init_on_free(struct kunit *test) }; int i; - if (!IS_ENABLED(CONFIG_INIT_ON_FREE_DEFAULT_ON)) - return; + KFENCE_TEST_REQUIRES(test, IS_ENABLED(CONFIG_INIT_ON_FREE_DEFAULT_ON)); /* Assume it hasn't been disabled on command line. */ setup_test_cache(test, size, 0, NULL); @@ -603,10 +607,8 @@ static void test_gfpzero(struct kunit *test) char *buf1, *buf2; int i; - if (CONFIG_KFENCE_SAMPLE_INTERVAL > 100) { - kunit_warn(test, "skipping ... would take too long\n"); - return; - } + /* Skip if we think it'd take too long. */ + KFENCE_TEST_REQUIRES(test, CONFIG_KFENCE_SAMPLE_INTERVAL <= 100); setup_test_cache(test, size, 0, NULL); buf1 = test_alloc(test, size, GFP_KERNEL, ALLOCATE_ANY);