Received: by 2002:a89:48b:0:b0:1f5:f2ab:c469 with SMTP id a11csp47949lqd; Tue, 23 Apr 2024 14:13:23 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWBu8ra3xFdLNS3oNlDW74mnZ3pkA1NV48GoV8r16uTVVsoYk+0f8V0d85phR7xIEe7X5KdJe1CEu9lBgT+Tl7qrqUgec3eO3hSBT7yDg== X-Google-Smtp-Source: AGHT+IGyiPhiAzw6Gp+QTwQuep5UTekmzMuZY1zkBd9S4tRF0XwxYqHu2CccGOy4G4RMV+xMCyrf X-Received: by 2002:a17:907:7801:b0:a55:ae98:3aae with SMTP id la1-20020a170907780100b00a55ae983aaemr255742ejc.30.1713906803624; Tue, 23 Apr 2024 14:13:23 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713906803; cv=pass; d=google.com; s=arc-20160816; b=gxDvSu8/J+ufMCnuYuV9ogACw8wTlOJGR17RVzZZMEJfZUA4kLOWgLqO5RIdKgtVjz uNbZXNPGHk5DpO1yvakZ2U2y1Pl278FbRnZQiRpfVCx5L9VKk5tgNyjaeR63ASixmAya +qO6iX+mTCnGntqfFt6jyhpqFio/8rMR+zjWh3hh4jfDPLMY34Vacd9Qm6tuL5BJI1qk wfzkw7U8+hEMombXUYQ9Z+bcZwbjpx4ff8B2jS87JjML39nIuuxS/jkTBlntjLQw+QJx CWFViKpCgEaguJmGveu2PwbIWZxdUNoq6pgBr4jnHbWagxvjaqXECVGSJaCkA23lgsJg AvmQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=9J1SHCnjXki1s8tfPNEpfyniTQlQg6e6yMISySpF958=; fh=zzpQWYhm5dc0DovLR6WOpZnu8XEEMRF6EXpLAGDIbm4=; b=w5vUhG3Ddm7Ts34XQakKuwVrjvtlMfX14U7BuACm6U718LH9x9yvf2ERIzkAdbvZ3S csTB3Q15Ys7xUXsukHV/HeSxGSkFwQaxq6fyftVXmtoCHdr5Vv0/D7ZNc++RKbNZ/CgL h9KM5EudiQ55uEsxM3O61D08oqKgCBtYoE6GIVkMtuFGVHzM0yUL9AxSxF8FWaKtxVRK 5arLxRsaM5rhqdiTYBsiBrTvtlshSm+DOwe1WOErUXP6FwYh1w/Tuk/N5Cc4vawQvVtr tqQ/IFmnK3tFqZYoGTNJ3BUst1f1euaV8PI9PR4OdUs+BtSD7HD9pan/QBb54cAtZCB+ 1pJg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="vPiC37X/"; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-155911-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-155911-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id bs5-20020a170906d1c500b00a556eb07678si7769142ejb.77.2024.04.23.14.13.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Apr 2024 14:13:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-155911-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="vPiC37X/"; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-155911-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-155911-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com 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 am.mirrors.kernel.org (Postfix) with ESMTPS id 3421C1F262DE for ; Tue, 23 Apr 2024 21:13:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B4356143868; Tue, 23 Apr 2024 21:13:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="vPiC37X/" Received: from mail-qt1-f182.google.com (mail-qt1-f182.google.com [209.85.160.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5819C1369BE for ; Tue, 23 Apr 2024 21:13:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.182 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713906794; cv=none; b=MNYkX+Ef6OtxHhgcWjo2ZHJz/RJUfeb5CKPoVQx/ICeK25r4gQFY8bipDnCwRibzD91j3SqV+lho67v00MlL9tE9mm6m3ObG6yLO9byiFG3O1SWZcelnAFcL9l/gvNTrsjTPClz1zLDSdRwmSB9O1hWOV6RMlKIaFx5ots2VxUE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713906794; c=relaxed/simple; bh=myriipUeoB1/JaZQkm9XDuzk4YU50w6UP6wACK7rMbE=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=XDLgI9XIytiKe4sY0ZScEF6IO7IyRWzn0eNf5dLD5L7QlPKkIAt1THE5VtUCVj2sONEEybEY/88/FIiOs/EaDepd1VFTg3v6qWYXM+AWAAp7GVMbopfCcW8X68f6YYkk2OwUIcC6GATTQzhwFRvlH+J5FyJPGMgkEx644ISvOTw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=vPiC37X/; arc=none smtp.client-ip=209.85.160.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Received: by mail-qt1-f182.google.com with SMTP id d75a77b69052e-43989e6ca42so109321cf.0 for ; Tue, 23 Apr 2024 14:13:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1713906792; x=1714511592; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=9J1SHCnjXki1s8tfPNEpfyniTQlQg6e6yMISySpF958=; b=vPiC37X/7mbQcx4t0bJ9bDv+KoQXL82NykU+1qdHjQoDxR2bWngPIfNwuAH4uzYahV mVmEjcuLGIuzPh40vrWHitSWxIBNNYmPs12PfHz5RpAVopLsu05K/YU0o7shVTI898vC 3uzgohy4W9c6swA4D7uHfGXy+T32jdrjiTYC12X1XIg2vNxbf8dmV19+ETymYKKB/o7W b/iFNdOyxRQdhvzgBEkM0/PIPXZQpOR6zEwtezE19t7CBigMGWetfv1r0enHEJHELUjc O7g+K2wK7DXBtrNXchoi97S4YoJQ3/P/PO0b8gCtSUNLd4PJ43E1xBAWpyIwN4n56iHj k31A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713906792; x=1714511592; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9J1SHCnjXki1s8tfPNEpfyniTQlQg6e6yMISySpF958=; b=TClGV9vm+Huzd0DCT99d9zifpOB4QgtbIjWTGuH+oFsW6R9cIRQvYzqXUWAmHpowYX m0luoMVDqQ7PC2xiYg9JVI5R4e7FIj6nsIa0OJRf87pPClst2ifIU+E8whCP/GhIN6GY +y19B2P206ZzvtJtjx5D+dvZ8/t7zKDYmK+3PYUHzMKFNB2I6zqjMo+YaIqY9bes+bns vdn1GVWeyQwhvocDF3lQ3QsFOCAytFclReaT6RvC1gX3dc5uXQSzNlsQ2KHpVwgZsC8v WjKjrzdA78y1kMkYVXBMryJKnFABYy7wuvxrFQhrK4coos8TYA9veIGUy0bPy6jbOARM fZjQ== X-Forwarded-Encrypted: i=1; AJvYcCUbezlzcR7MaCoEyyczacFFkssoEcULwrNpo+fR6eTgOudu6cKryphHlLJxkcEVdXWGBlfCf80IWY9+pXMo3uWpwqqQ+q39sbmSXA1L X-Gm-Message-State: AOJu0YztO+GcihHrVdUkvNpsVleSCvAT1uTMnfnieopGRKUpjLmsBsx0 KhKPIAhzZfe9nYK0BeczzT4kRm3mZi6ZOHYFVS1PIJpmmCvbHS0ZFU8qsQvBdOrV10uut08fd9k FGVVOKuaRa/dchu9wV/tDDZRowIeQg4BRmIHH X-Received: by 2002:ac8:6d0:0:b0:431:8176:e4e5 with SMTP id j16-20020ac806d0000000b004318176e4e5mr13491qth.13.1713906792165; Tue, 23 Apr 2024 14:13:12 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240423090808.242389-1-davidgow@google.com> In-Reply-To: <20240423090808.242389-1-davidgow@google.com> From: Rae Moar Date: Tue, 23 Apr 2024 17:12:59 -0400 Message-ID: Subject: Re: [PATCH] kunit: test: Move fault tests behind KUNIT_FAULT_TEST Kconfig option To: David Gow Cc: =?UTF-8?B?TWlja2HDq2wgU2FsYcO8bg==?= , Shuah Khan , Guenter Roeck , kunit-dev@googlegroups.com, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, Apr 23, 2024 at 5:08=E2=80=AFAM David Gow wro= te: > > 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@ro= eck-us.net/ > Fixes: 82b0beff3497 ("kunit: Add tests for fault") > Signed-off-by: David Gow Hello! This looks good to me. Very useful! Reviewed-by: Rae Moar Thanks! -Rae > --- > 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 s= uite > 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 tes= ts may > + trigger a kernel BUG(), and the associated stack trace, even wh= en they > + pass. If this conflicts with your test infrastrcture (or is con= fusing > + 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 = =3D { > .test_cases =3D 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(struc= t 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[] =3D { > -#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 >