Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp2808728lqt; Tue, 23 Apr 2024 02:08:47 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX2t3VB8CXiFbyC2YD3Aw0uf8YrBgBO+I/tkl49llwJ6jYqlVEq6ra7smg4hdzlARuKdC03lwe7RRM2c6HHGcrWDzt9C5r8FRnJIxp6sg== X-Google-Smtp-Source: AGHT+IHWpHHnzRhF1udH9HTdBfy5Woo6btY3FTmGGbPo1T775b9G1SXU/Mn0Q/D/5DJygQ4J6ppq X-Received: by 2002:a05:620a:e05:b0:78d:70a4:f8c4 with SMTP id y5-20020a05620a0e0500b0078d70a4f8c4mr14225491qkm.3.1713863327211; Tue, 23 Apr 2024 02:08:47 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713863327; cv=pass; d=google.com; s=arc-20160816; b=Qk4oqNEp/U7ONCwb2GKQUrbK/VszavqWLGptPBNt0J1Qglka7VfQI/urmiLafndW7q Deiodjo+r63Y5yHvEaltrcqJp1ktNQG8ORwa/RDgDKqujSYljU3U+nKHECP2T88Mrwlo qduFSpyEY4PQbyqMji5Frh3aUs4lwb1weK7ULDk6KrMJo0piId0bW1111T2hRGQ3ioDR XglVeucalL0dzToEwA1k3IWek314iJCjD6NOCprnpWk1Rwb5I+c+XHTunc6CouGxEFwx NAcZ6g/zEQWu3xAhEvoC0QE24EyNK3LRw2KtfgOtInyYJG+5cZ6buV+Je3UpNskGpa3n nBvQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:dkim-signature; bh=fVAaYYUYRjsITzR+rLStFX9oltnbfPIIpZ1fuxXV7XI=; fh=qhkroRzejBpiKwkf1RbYq9SQtmkKxwbJLJ0plmzrV5c=; b=SazGl788M0w1PyhgifzKkfea7uonr2tGRcjq2Ur/1HWwNak8Mf/QrMX9Tw2fjsiuv+ y+eA2WHfkY+g5gUrFGL8Xk/OmE5UDjo5iXs3YAh9e6osMn+9F0IkuAIpvt6G9rT+uBZB 5J5mLBbLehsk1aN/qUtq7Z2Fay0nvs8m6e676P2UdgV3LW6t26fH100uqhpxhfTiKHmt ELO8Sv11N4aLoqM3mkgvc5Uxop7Babvi7QjKeyLpJeqjh1o+yPHQsVWZ26Dsl4FT8M14 OBfjeYH+IGZJamkamlyArtndCZ9Dy1rNVTbWhy3Whfkpsr89cuU5bcDAHwO6J6QDmc6D bmZQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=M5S60Rmp; arc=pass (i=1 spf=pass spfdomain=flex--davidgow.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-154761-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-154761-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id os8-20020a05620a810800b0078ed6b5a285si11903085qkn.214.2024.04.23.02.08.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Apr 2024 02:08:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-154761-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=M5S60Rmp; arc=pass (i=1 spf=pass spfdomain=flex--davidgow.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-154761-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-154761-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id B2B891C21596 for ; Tue, 23 Apr 2024 09:08:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D9D475BAD7; Tue, 23 Apr 2024 09:08:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="M5S60Rmp" Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.201]) (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 7D49558234 for ; Tue, 23 Apr 2024 09:08:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713863296; cv=none; b=VXY6qWoACfd3pWigJfFioKYdRPVHDBJchr2ADxP4BoNRflDXkaeHxOtxDEIZ8cTTVJj/ye5q+s8P6qlBVsfn/wuBXOXZvFI67pDEqCE+gnCn+zdONLgMQgtDsjCwXk45T+UOXhDhwmmbxYDXjOaDjoVtswYQpT9b23hnz8VB22g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713863296; c=relaxed/simple; bh=0rV1Ku+pcVQFW3sVe5g2nnNHm4ytFcT2WipJXX42ZRk=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=gru282T6yUfonR7XKBGQbpbDy+K0/f8KRjLHX7pXyEaRfTjoQ7uFk7w952ENSaIwgkKRuew3qjHU2YqJMuKTsnXC8rh5geunvYp9ZbbW2Zumo4snQAKWQjfB3d5JSCk1k06Et6gY21Z7teka/INXlaHTNoZgGsdGzA/Ch4xIoZU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--davidgow.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=M5S60Rmp; arc=none smtp.client-ip=209.85.128.201 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=flex--davidgow.bounces.google.com Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-61acc68c1bdso69072077b3.1 for ; Tue, 23 Apr 2024 02:08:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1713863293; x=1714468093; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=fVAaYYUYRjsITzR+rLStFX9oltnbfPIIpZ1fuxXV7XI=; b=M5S60RmpzD8ZgBm3CSJU+/oXKdMchLrX1cFpQGpFulesF/MfM1Akkbt90ys3wkTRIu 1jaTJrt2AO+9rRc1i7JAkV1qTmE9MklvKS+CfjrsR1U7aCrEyc1rYyipY27QP8B6zTVr Hzjseug4YncjOFim+3t1lqdy7YLUadWhmk3uyv7GqINASNR5OeOEiLbfnN8+quDR3XC2 UZQCULFZ5n6B//Xg02QifcAWoiSmHx5S8nduS/KWRAd27+IpnGn0M4BbsYm/zv9p+98e nT7IX82+J6WfQOi7+hKFRQ66AhZGHwfL8MgLgGN5VjC2scMb/oPQO3EFvmQq+VwZ5lCT 86uA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713863293; x=1714468093; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=fVAaYYUYRjsITzR+rLStFX9oltnbfPIIpZ1fuxXV7XI=; b=GQ87J6CR91SJcWR5pYcCzGSrydN+n6H3nQrGZTH+eFoV/95MCrZoITL5NiEOiSCfMI 9MrPfganMz+bA7NA6CrStBRirUmlfe47gQ2RwfkZ0UG4o8HkUGVO+JdREfULZIa1RtoJ A9lPH1JSrdqI5ehCJCH8su0x3IWkvgen44qolqhRYPciHmB9lVh9hgPZRY4IjbGWBq3v lNotn3yAViJ9AWDP363cQn7gNMMaUzu5RCJvUdbXLxS/Z6T4A31kWDO72oB+zZIgyg9e YxDXq+EToGZAjOpk5LThurmcRl2AhwHhr3nwiL67qaqOsvnlbbb0Nx0Bc6B8t+psj11b di0g== X-Forwarded-Encrypted: i=1; AJvYcCUYQuUCKnOBt2KaBKFXsuBMSjwQpooX9rWwrO27AcdqwmaKA7Q2Eo8vcVqpH9ls2J8zdFXkliQYwi7NPTXyZYQvDSnYAwqb7TQ5JE3X X-Gm-Message-State: AOJu0YxLtuW3Hkv1xqNubaPhNrlaInG/04oREkTGio0YSMdq+Hlulw8o +SfO12ZfACwlUvZ80xU6Ol80UZ4S9QERjZmp7pChhExA+LFtHVdaKCQl8eqLmsv+LF+Jy+cBVgr GGSEe3BOaTQ== X-Received: from slicestar.c.googlers.com ([fda3:e722:ac3:cc00:4f:4b78:c0a8:20a1]) (user=davidgow job=sendgmr) by 2002:a05:6902:1023:b0:dda:c4ec:7db5 with SMTP id x3-20020a056902102300b00ddac4ec7db5mr691696ybt.4.1713863293622; Tue, 23 Apr 2024 02:08:13 -0700 (PDT) Date: Tue, 23 Apr 2024 17:08:06 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Mailer: git-send-email 2.44.0.769.g3c40516874-goog Message-ID: <20240423090808.242389-1-davidgow@google.com> Subject: [PATCH] kunit: test: Move fault tests behind KUNIT_FAULT_TEST Kconfig option From: David Gow To: Rae Moar , "=?UTF-8?q?Micka=C3=ABl=20Sala=C3=BCn?=" , Shuah Khan , Guenter Roeck Cc: David Gow , kunit-dev@googlegroups.com, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" 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 --- 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