Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp3115503lqt; Tue, 23 Apr 2024 10:40:05 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVHiAMa4wC4mE2oBuIJiBbylxLt62b1RJW6j+v2bLOspbWerGHHL3cpn5u+UzolOH3VV6nkshvLvwq3VQwnV3XtzOwgzYxrAh+hrlxv9A== X-Google-Smtp-Source: AGHT+IFVG9YcWN+ufZoEYV2L+9kdMbK2vUWaYN1RU0/klQFXJ0EP8UDLDDhp1KKACgn7Ab6o7xqG X-Received: by 2002:a05:6a00:181b:b0:6ed:de2c:77b9 with SMTP id y27-20020a056a00181b00b006edde2c77b9mr4251305pfa.14.1713894005098; Tue, 23 Apr 2024 10:40:05 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713894005; cv=pass; d=google.com; s=arc-20160816; b=woE6/4MTEQPYO7Wk+1p3hH3pwscNqziPwVEI1eIIbqrRBS/VDe2I8OtwBcs4vkNl2l IuC2i2jefg86B9mw+5dyqocSrUty2PV/naxSQG/faGFMis+fmtUjuMBocXi/cefJRyFL b7y8h46Ioj9g23lAKsyJTD5wDK0nIGZdgxLE2LGbUa1X2LkvEbvQtCyKHndpG2dqrKdQ 0tGPxXlbIVOIKTujx0s5IYkwNLQe+sDiUxhRcVVUkwT1u4hDOYvo1dhHIGH4U6CP8W+3 mODq0Xu3K6d4LJl1kKxYKfeUjaEhCVN6VD0d3/9NrVdm4//fPEPoszI9IhkrN8aTfDS1 nRcA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=aa8bQ4MgPkVGwBNOfKMiCELQ2VzkNvsRpWmxISjZRRU=; fh=wz2/iWY9sD1PAuaGoYkxRbOmla9lB0WgbMiDAyvFap0=; b=g4/D6lgFJGFGnjiVpNIj8mPqK7rhdyBdrhCrZKIotxQbFkWElbrgeX+shbKMuWFkEL hGFuDDbFrYQhxR10Vthii1XAh/X76DK4aeNwcCAx2/nIlnYwZCkMBD2n53zbzSbYlQWu skg0rPNGVz15cVl4CWgbO1swGX2aDfaOzw00ydkm5pm7V1r4boG7IunYr8cl5eBeWAvZ A7QL76QgSU5rU7befQIZBWAjIIbtuf7U+8lps5h/4nBNJxkmJ29Ju7n9yZURYQbaBGwk kGFWSvGd99gnFY69ssY8sjcsn7IEiEbHtVbEBrnh9nd8cMU7KRGTxHC6Q1hJyHKtUKjR BqoA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@digikod.net header.s=20191114 header.b=Y55Q53ct; arc=pass (i=1 spf=pass spfdomain=digikod.net dkim=pass dkdomain=digikod.net); spf=pass (google.com: domain of linux-kernel+bounces-155648-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-155648-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id a2-20020a056a000c8200b006efc1f1dfd4si10416778pfv.330.2024.04.23.10.40.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Apr 2024 10:40:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-155648-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@digikod.net header.s=20191114 header.b=Y55Q53ct; arc=pass (i=1 spf=pass spfdomain=digikod.net dkim=pass dkdomain=digikod.net); spf=pass (google.com: domain of linux-kernel+bounces-155648-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-155648-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 292CAB25E1D for ; Tue, 23 Apr 2024 17:15:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 34E5613D8BE; Tue, 23 Apr 2024 17:15:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=digikod.net header.i=@digikod.net header.b="Y55Q53ct" Received: from smtp-42af.mail.infomaniak.ch (smtp-42af.mail.infomaniak.ch [84.16.66.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7EAF113C81E for ; Tue, 23 Apr 2024 17:15:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=84.16.66.175 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713892549; cv=none; b=pm4otMFoxBAYwQ//1LEtJvuKgkjzoHZUjEh936b2wwdyCcDl7aNPd8YH1uSWCdD7fD+P8C2Hv8TD/djI2uMcIRpzjNToXpCUPYHgp+ELaASphlvBLb9b6pl8c9VIL1X/h8pdUJ4A7ma9vNwP27nL1V1MCBt/1q8gamrZH4OmM2E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713892549; c=relaxed/simple; bh=pX9dtei+83WbcGhlmmrQLgeyG4KgE/xvvg03BZojpDc=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=EMUdmnF6jOcsSQEKSNrZ/KMliRIFrGHDPpsn1Fwlsv3vP6UWVDkkz2O799eDxTYWl9b6wLeGipGxsxdxhMuxcwo2hgys81PdorCuhAIsCOx+Hs07454UMFvjIecjekuyrqClFrFWG+bmKmO8Oudrwa8cG0mpnpz6XQc/Ti7z+4Q= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=digikod.net; spf=pass smtp.mailfrom=digikod.net; dkim=pass (1024-bit key) header.d=digikod.net header.i=@digikod.net header.b=Y55Q53ct; arc=none smtp.client-ip=84.16.66.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=digikod.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=digikod.net Received: from smtp-3-0001.mail.infomaniak.ch (smtp-3-0001.mail.infomaniak.ch [10.4.36.108]) by smtp-4-3000.mail.infomaniak.ch (Postfix) with ESMTPS id 4VP7px1nckzDp6; Tue, 23 Apr 2024 19:07:53 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=digikod.net; s=20191114; t=1713892073; bh=pX9dtei+83WbcGhlmmrQLgeyG4KgE/xvvg03BZojpDc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Y55Q53ctaPBwqA8H+m73mMZRMQhB9lv+Y2m7TjW2ZTUmaRh1V4d0vOAWcjxTYfIzE n9qRXiOoVFBjcOXbRJADvB9/yfUDFwY6VKLy/ZzWxjSdQuTpY6aBlMIzl2TixdgWeI ezsQWELEBwtylr0DRzRQ5lcTRlKLgy95AmbXRtkY= Received: from unknown by smtp-3-0001.mail.infomaniak.ch (Postfix) with ESMTPA id 4VP7pw4MDlzHlg; Tue, 23 Apr 2024 19:07:52 +0200 (CEST) Date: Tue, 23 Apr 2024 19:07:51 +0200 From: =?utf-8?Q?Micka=C3=ABl_Sala=C3=BCn?= To: David Gow Cc: Rae Moar , Shuah Khan , Guenter Roeck , kunit-dev@googlegroups.com, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] kunit: test: Move fault tests behind KUNIT_FAULT_TEST Kconfig option Message-ID: <20240423.shuwee5Baesh@digikod.net> References: <20240423090808.242389-1-davidgow@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20240423090808.242389-1-davidgow@google.com> X-Infomaniak-Routing: alpha On Tue, Apr 23, 2024 at 05:08:06PM +0800, David Gow wrote: > The NULL dereference tests in kunit_fault deliberately trigger a kernel > BUG(), and therefore print the associated stack trace, even when the > test passes. This is both annoying (as it bloats the test output), and > can confuse some test harnesses, which assume any BUG() is a failure. > > Allow these tests to be specifically disabled (without disabling all > of KUnit's other tests), by placing them behind the > CONFIG_KUNIT_FAULT_TEST Kconfig option. This is enabled by default, but > can be set to 'n' to disable the test. An empty 'kunit_fault' suite is > left behind, which will automatically be marked 'skipped'. > > As the fault tests already were disabled under UML (as they weren't > compatible with its fault handling), we can simply adapt those > conditions, and add a dependency on !UML for our new option. > > Suggested-by: Guenter Roeck > Link: https://lore.kernel.org/all/928249cc-e027-4f7f-b43f-502f99a1ea63@roeck-us.net/ > Fixes: 82b0beff3497 ("kunit: Add tests for fault") > Signed-off-by: David Gow Good idea! Reviewed-by: Mickaël Salaün > --- > lib/kunit/Kconfig | 11 +++++++++++ > lib/kunit/kunit-test.c | 8 ++++---- > 2 files changed, 15 insertions(+), 4 deletions(-) > > diff --git a/lib/kunit/Kconfig b/lib/kunit/Kconfig > index 68a6daec0aef..34d7242d526d 100644 > --- a/lib/kunit/Kconfig > +++ b/lib/kunit/Kconfig > @@ -24,6 +24,17 @@ config KUNIT_DEBUGFS > test suite, which allow users to see results of the last test suite > run that occurred. > > +config KUNIT_FAULT_TEST > + bool "Enable KUnit tests which print BUG stacktraces" > + depends on KUNIT_TEST > + depends on !UML > + default y > + help > + Enables fault handling tests for the KUnit framework. These tests may > + trigger a kernel BUG(), and the associated stack trace, even when they > + pass. If this conflicts with your test infrastrcture (or is confusing > + or annoying), they can be disabled by setting this to N. > + > config KUNIT_TEST > tristate "KUnit test for KUnit" if !KUNIT_ALL_TESTS > default KUNIT_ALL_TESTS > diff --git a/lib/kunit/kunit-test.c b/lib/kunit/kunit-test.c > index 0fdca5fffaec..e3412e0ca399 100644 > --- a/lib/kunit/kunit-test.c > +++ b/lib/kunit/kunit-test.c > @@ -109,7 +109,7 @@ static struct kunit_suite kunit_try_catch_test_suite = { > .test_cases = kunit_try_catch_test_cases, > }; > > -#ifndef CONFIG_UML > +#if IS_ENABLED(CONFIG_KUNIT_FAULT_TEST) > > static void kunit_test_null_dereference(void *data) > { > @@ -136,12 +136,12 @@ static void kunit_test_fault_null_dereference(struct kunit *test) > KUNIT_EXPECT_TRUE(test, ctx->function_called); > } > > -#endif /* !CONFIG_UML */ > +#endif /* CONFIG_KUNIT_FAULT_TEST */ > > static struct kunit_case kunit_fault_test_cases[] = { > -#ifndef CONFIG_UML > +#if IS_ENABLED(CONFIG_KUNIT_FAULT_TEST) > KUNIT_CASE(kunit_test_fault_null_dereference), > -#endif /* !CONFIG_UML */ > +#endif /* CONFIG_KUNIT_FAULT_TEST */ > {} > }; > > -- > 2.44.0.769.g3c40516874-goog >