From patchwork Sat Jun 25 05:08:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Gow X-Patchwork-Id: 1648234 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20210112 header.b=kLPh7jI5; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=2404:9400:2:0:216:3eff:fee1:b9f1; helo=lists.ozlabs.org; envelope-from=openbmc-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2404:9400:2:0:216:3eff:fee1:b9f1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LVMbf39DMz9s2R for ; Sat, 25 Jun 2022 15:14:06 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4LVMbf24W5z3cgP for ; Sat, 25 Jun 2022 15:14:06 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20210112 header.b=kLPh7jI5; dkim-atps=neutral X-Original-To: openbmc@lists.ozlabs.org Delivered-To: openbmc@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=flex--davidgow.bounces.google.com (client-ip=2607:f8b0:4864:20::1149; helo=mail-yw1-x1149.google.com; envelope-from=34zi2yggkbwonk5snqy6qyyqvo.mywyzoxlwmvs232.y9vkl2.y1q@flex--davidgow.bounces.google.com; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20210112 header.b=kLPh7jI5; dkim-atps=neutral Received: from mail-yw1-x1149.google.com (mail-yw1-x1149.google.com [IPv6:2607:f8b0:4864:20::1149]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4LVMX42XsVz3chl for ; Sat, 25 Jun 2022 15:10:59 +1000 (AEST) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-2eb7d137101so37152097b3.12 for ; Fri, 24 Jun 2022 22:10:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=lxRgaEQg1Srs91zUrKY1M63p/g6lzTHUgiHduzlet9Y=; b=kLPh7jI5q7r+pBIG2uvOj0f9/VgduN3Cl66+emvk9RWGE49CIfxahnslYSdM4PsHKN Dh6Rg1MQ43C8pc5HmzXYYpGkbhkfBwT7RBV5fNxXM0dRe2WPhyGrTcbCX9iCi/ODr8bK n63piZbTY+wHUIp5oYFbzLv53aADjlHnBHA8xcb+Tts9yib5BnLP9jTBpPdctqcRHG/m dXOgCLB7nAiUC/98Z9CJ7ch7VcJRjG2FR+i7XsX2kfdnqjzveL1yKw/OEW/+8Bj5LXpS AgnqH0rFMy6B0vlre5437FWueZa4NLTPwzxN2JqsGNVgwJ3ZekJVA1JCob+hvQhh1hul 2QBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=lxRgaEQg1Srs91zUrKY1M63p/g6lzTHUgiHduzlet9Y=; b=MYq/pCoaXaql9FzixfbVFzubq0t6tC8aY7m4W30/LG0Gw1j5mXHTyy5yM5DYZXMmZn /WupxdDkjj6zw6hvgqx7igToPvFznMtr8K6fOkjHSTGW0WA8hPaM0P/8T8PEqmGp+gmy eBOSFLU+pleRULt5i+a8zvW9KVkmYxRdirgMyPDSnCJ+57wLY+rW0+mbvxts0Emag1v2 IiSiJijghGXUhNvleznxZOR1d1pznvRv3dRjSeFYIIdw95hnoOvsbILwMuqU9Lsz7/10 snajWXMmrcfdI9LNlJ54TXoqgJm2yC41atmcZuJi7P3l/Kal5yYC94fc+A+JRH20xkOz tYmw== X-Gm-Message-State: AJIora+qXP8mFhzT1AEVmjowZi753aMl5aetcQkMwVtIvAtKDUBcgj2r /9FHvCVg0/hsaN4PP8XvB8GCdmM+AxZzyQ== X-Google-Smtp-Source: AGRyM1vq8WRdwyuaqqjYDvoANpBUCk+2rYA15XbKRFyx26LCrzj2qR+ivjVpQq7LaCKuE34j/7isuUAQXIl4WA== X-Received: from slicestar.c.googlers.com ([fda3:e722:ac3:cc00:4f:4b78:c0a8:20a1]) (user=davidgow job=sendgmr) by 2002:a81:a242:0:b0:317:5a3b:3fc8 with SMTP id z2-20020a81a242000000b003175a3b3fc8mr2818143ywg.424.1656133857015; Fri, 24 Jun 2022 22:10:57 -0700 (PDT) Date: Sat, 25 Jun 2022 13:08:38 +0800 In-Reply-To: <20220625050838.1618469-1-davidgow@google.com> Message-Id: <20220625050838.1618469-5-davidgow@google.com> Mime-Version: 1.0 References: <20220625050838.1618469-1-davidgow@google.com> X-Mailer: git-send-email 2.37.0.rc0.161.g10f37bed90-goog Subject: [PATCH v3 4/5] nitro_enclaves: test: Use kunit_test_suite() macro From: David Gow To: Brendan Higgins , Luis Chamberlain , Jeremy Kerr , Daniel Latypov , Shuah Khan , Andrew Jeffery , Mika Westerberg , Andra Paraschiv , Longpeng , Greg KH X-BeenThere: openbmc@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development list for OpenBMC List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Gow , linux-aspeed@lists.ozlabs.org, =?utf-8?q?Ma=C3=ADra_Canal?= , openbmc@lists.ozlabs.org, linux-usb@vger.kernel.org, linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Matt Johnston , linux-modules@vger.kernel.org, kunit-dev@googlegroups.com Errors-To: openbmc-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "openbmc" The kunit_test_suite() macro previously conflicted with module_init, making it unsuitable for use in the nitro_enclaves test. Now that it's fixed, we can use it instead of a custom call into internal KUnit functions to run the test. As a side-effect, this means that the test results are properly included with other suites when built-in. To celebrate, enable the test by default when KUNIT_ALL_TESTS is set (and NITRO_ENCLAVES enabled). The nitro_enclave tests can now be run via kunit_tool with: ./tools/testing/kunit/kunit.py run --arch=x86_64 \ --kconfig_add CONFIG_PCI=y --kconfig_add CONFIG_SMP=y \ --kconfig_add CONFIG_HOTPLUG_CPU=y \ --kconfig_add CONFIG_VIRT_DRIVERS=y \ --kconfig_add CONFIG_NITRO_ENCLAVES=y \ 'ne_misc_dev_test' (This is a pretty long command, so it may be worth adding a .kunitconfig file at some point, instead.) Reviewed-by: Andra Paraschiv Signed-off-by: David Gow Acked-by: Brendan Higgins --- Changes since v2: https://lore.kernel.org/linux-kselftest/20220621085345.603820-5-davidgow@google.com/ - Add Andra's Reviewed-by tag. Changes since v1: https://lore.kernel.org/linux-kselftest/20220618090310.1174932-5-davidgow@google.com/ - Move the mistakenly-added thunderbolt Kconfig to the previous patch (Thanks Andra) - Add Andra's Acked-by tag. --- drivers/virt/nitro_enclaves/Kconfig | 5 ++-- drivers/virt/nitro_enclaves/ne_misc_dev.c | 27 ------------------- .../virt/nitro_enclaves/ne_misc_dev_test.c | 5 +--- 3 files changed, 4 insertions(+), 33 deletions(-) diff --git a/drivers/virt/nitro_enclaves/Kconfig b/drivers/virt/nitro_enclaves/Kconfig index 2d3d98158121..ce91add81401 100644 --- a/drivers/virt/nitro_enclaves/Kconfig +++ b/drivers/virt/nitro_enclaves/Kconfig @@ -16,8 +16,9 @@ config NITRO_ENCLAVES The module will be called nitro_enclaves. config NITRO_ENCLAVES_MISC_DEV_TEST - bool "Tests for the misc device functionality of the Nitro Enclaves" - depends on NITRO_ENCLAVES && KUNIT=y + bool "Tests for the misc device functionality of the Nitro Enclaves" if !KUNIT_ALL_TESTS + depends on NITRO_ENCLAVES && KUNIT + default KUNIT_ALL_TESTS help Enable KUnit tests for the misc device functionality of the Nitro Enclaves. Select this option only if you will boot the kernel for diff --git a/drivers/virt/nitro_enclaves/ne_misc_dev.c b/drivers/virt/nitro_enclaves/ne_misc_dev.c index 20c881b6a4b6..241b94f62e56 100644 --- a/drivers/virt/nitro_enclaves/ne_misc_dev.c +++ b/drivers/virt/nitro_enclaves/ne_misc_dev.c @@ -1759,35 +1759,10 @@ static long ne_ioctl(struct file *file, unsigned int cmd, unsigned long arg) #if defined(CONFIG_NITRO_ENCLAVES_MISC_DEV_TEST) #include "ne_misc_dev_test.c" - -static inline int ne_misc_dev_test_init(void) -{ - return __kunit_test_suites_init(ne_misc_dev_test_suites); -} - -static inline void ne_misc_dev_test_exit(void) -{ - __kunit_test_suites_exit(ne_misc_dev_test_suites); -} -#else -static inline int ne_misc_dev_test_init(void) -{ - return 0; -} - -static inline void ne_misc_dev_test_exit(void) -{ -} #endif static int __init ne_init(void) { - int rc = 0; - - rc = ne_misc_dev_test_init(); - if (rc < 0) - return rc; - mutex_init(&ne_cpu_pool.mutex); return pci_register_driver(&ne_pci_driver); @@ -1798,8 +1773,6 @@ static void __exit ne_exit(void) pci_unregister_driver(&ne_pci_driver); ne_teardown_cpu_pool(); - - ne_misc_dev_test_exit(); } module_init(ne_init); diff --git a/drivers/virt/nitro_enclaves/ne_misc_dev_test.c b/drivers/virt/nitro_enclaves/ne_misc_dev_test.c index 265797bed0ea..74df43b925be 100644 --- a/drivers/virt/nitro_enclaves/ne_misc_dev_test.c +++ b/drivers/virt/nitro_enclaves/ne_misc_dev_test.c @@ -151,7 +151,4 @@ static struct kunit_suite ne_misc_dev_test_suite = { .test_cases = ne_misc_dev_test_cases, }; -static struct kunit_suite *ne_misc_dev_test_suites[] = { - &ne_misc_dev_test_suite, - NULL -}; +kunit_test_suite(ne_misc_dev_test_suite);