From patchwork Mon Sep 9 01:29:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Feng Tang X-Patchwork-Id: 13795732 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 598E3CD4F4C for ; Mon, 9 Sep 2024 01:30:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D819A6B0100; Sun, 8 Sep 2024 21:30:22 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D32736B0102; Sun, 8 Sep 2024 21:30:22 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BF7E76B0103; Sun, 8 Sep 2024 21:30:22 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id A08B36B0100 for ; Sun, 8 Sep 2024 21:30:22 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 5EC121A1D6F for ; Mon, 9 Sep 2024 01:30:22 +0000 (UTC) X-FDA: 82543469484.14.2594D33 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.15]) by imf30.hostedemail.com (Postfix) with ESMTP id 4E5B680016 for ; Mon, 9 Sep 2024 01:30:20 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=Nq8Qelke; spf=pass (imf30.hostedemail.com: domain of feng.tang@intel.com designates 198.175.65.15 as permitted sender) smtp.mailfrom=feng.tang@intel.com; dmarc=pass (policy=none) header.from=intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1725845286; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=7vVZ50kdJDNFI19gsV94XEZMSmlP1RCFkWL2RtPs6kk=; b=h0q+5K+eZJVX67G81kYUvI7e8Lv95vqe9Q4urUI+PSLP1FW7gb+Gwj3jvhilIdzf5kXiDw L4UscnU8Ap44D9wI9fHsW3UNnBKot6+qlkYKxDVrQhAa8Kzx9gwFeZET0QyjcDaeA3gTT5 hDGtxBLJnx6wCPB5Ph9V6qciy2Z4Ah0= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=Nq8Qelke; spf=pass (imf30.hostedemail.com: domain of feng.tang@intel.com designates 198.175.65.15 as permitted sender) smtp.mailfrom=feng.tang@intel.com; dmarc=pass (policy=none) header.from=intel.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725845286; a=rsa-sha256; cv=none; b=jYvVaMMKye2/p0DK61tBf2l/yBFTwRQTE6t6rucGV3pxUETMkIsFHhIZvvLG9ErXBV3vUt +rrnxf5XMaoKCsypt2mSh8XQF/oJjeyT5JtLJibCTeycEwTigfmLHMr/lUY9uAlWBmviQ1 z6tnSI7gd82hzhZOXp/NKTnMsV1QX3g= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1725845420; x=1757381420; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=sd4pFelEU/QdXj5ouoP5PRXHKn8qGUrWc/AAyu1UHpU=; b=Nq8QelkeHuFcOZnhF3FEEfIcgM3sT9yQzoPvF78Ttfv1mUx8L2ePEpaE mogHTkDHJiDiDlvzRNgiJgmHanq44ZYHwn6LfaUlpsvjkfiLir7IOm4Yc Yd6ZT8puYmkz5ncNvv6eczcwyb2CgQb26GKhP5lWh1S3KQSEbyBnMcXul J7epsH/nv5iQrYgvFIMOuV07YOJUsHIZxYR9PN9uK8OnEVTvdQLoqvjSL R28PGRTZfJzgRwHbR0W7yLEJ/vOOArs98jwu2xMGCZ1720H6b0zp5MwLe s+zM57l/KiRDhUXnu8SvK68vuCC4m7j3MOLLsUxkM6z4eFz+sdltKIreZ w==; X-CSE-ConnectionGUID: AjhE5LMKTluqRaVCQGcx0w== X-CSE-MsgGUID: T22d4ZFqSH2RCkkmYrcAng== X-IronPort-AV: E=McAfee;i="6700,10204,11189"; a="28258148" X-IronPort-AV: E=Sophos;i="6.10,213,1719903600"; d="scan'208";a="28258148" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by orvoesa107.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Sep 2024 18:30:20 -0700 X-CSE-ConnectionGUID: WDU907LnRC+3vfLghWzWkw== X-CSE-MsgGUID: 4FEk/tfqQaKVE8AxVIBYaQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.10,213,1719903600"; d="scan'208";a="66486499" Received: from feng-clx.sh.intel.com ([10.239.159.50]) by orviesa009.jf.intel.com with ESMTP; 08 Sep 2024 18:30:15 -0700 From: Feng Tang To: Vlastimil Babka , Andrew Morton , Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Roman Gushchin , Hyeonggon Yoo <42.hyeyoo@gmail.com>, Andrey Konovalov , Marco Elver , Shuah Khan , David Gow , Danilo Krummrich Cc: linux-mm@kvack.org, kasan-dev@googlegroups.com, linux-kernel@vger.kernel.org, Feng Tang Subject: [PATCH 4/5] kunit: kfence: Make KFENCE_TEST_REQUIRES macro available for all kunit case Date: Mon, 9 Sep 2024 09:29:57 +0800 Message-Id: <20240909012958.913438-5-feng.tang@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240909012958.913438-1-feng.tang@intel.com> References: <20240909012958.913438-1-feng.tang@intel.com> MIME-Version: 1.0 X-Rspamd-Server: r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f/cxqR0AQNI93pDp lvMRwfzt Dw0JOuM3Sw/A+dyXVgq3Yf1V502yWIA0MTgaFk2lCUIcbMXla+A48maAH/pU4DmoUzfDfhvp8+vocAAgQQ34CUzFaCAg7iOCa+xXfZKhWqKsiL8TUCKQSVkvwvVSGaJJTeyJebAH6n5n/n3RQv0vlWZJXvuO9+wVsBlW3YJDpFBOc7QjaCU1m02EXnSy31EIQUJ7ejDXcTlqV9Pq/hOumXUMmAsbSRDqNB7xEMEfuQggNzxucDTdveJ1cIWABXpLs2r4rSDTkF/9YaVGcfIQZZBnUmq1zoQy17pjhbBp8ZFKBoOg= 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: List-Subscribe: List-Unsubscribe: KFENCE_TEST_REQUIRES macro is convenient for judging if a prerequisite of a test case exists. Lift it into kunit/test.h so that all kunit test cases can benefit from it. Signed-off-by: Feng Tang Reviewed-by: Alexander Potapenko Reviewed-by: Marco Elver --- include/kunit/test.h | 6 ++++++ mm/kfence/kfence_test.c | 9 ++------- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/include/kunit/test.h b/include/kunit/test.h index 5ac237c949a0..8a8027e10b89 100644 --- a/include/kunit/test.h +++ b/include/kunit/test.h @@ -643,6 +643,12 @@ void __printf(2, 3) kunit_log_append(struct string_stream *log, const char *fmt, WRITE_ONCE(test->last_seen.line, __LINE__); \ } while (0) +#define KUNIT_TEST_REQUIRES(test, cond) do { \ + if (!(cond)) \ + kunit_skip((test), "Test requires: " #cond); \ +} while (0) + + /** * KUNIT_SUCCEED() - A no-op expectation. Only exists for code clarity. * @test: The test context object. diff --git a/mm/kfence/kfence_test.c b/mm/kfence/kfence_test.c index 00fd17285285..5dbb22c8c44f 100644 --- a/mm/kfence/kfence_test.c +++ b/mm/kfence/kfence_test.c @@ -32,11 +32,6 @@ #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; @@ -561,7 +556,7 @@ static void test_init_on_free(struct kunit *test) }; int i; - KFENCE_TEST_REQUIRES(test, IS_ENABLED(CONFIG_INIT_ON_FREE_DEFAULT_ON)); + KUNIT_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); @@ -609,7 +604,7 @@ static void test_gfpzero(struct kunit *test) int i; /* Skip if we think it'd take too long. */ - KFENCE_TEST_REQUIRES(test, kfence_sample_interval <= 100); + KUNIT_TEST_REQUIRES(test, kfence_sample_interval <= 100); setup_test_cache(test, size, 0, NULL); buf1 = test_alloc(test, size, GFP_KERNEL, ALLOCATE_ANY);