Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp3504716rwl; Mon, 27 Mar 2023 15:22:34 -0700 (PDT) X-Google-Smtp-Source: AKy350YT1z+8KqwbEb0ta2MJMiLsk53NhQLMskPNl2LXJcY0CqgY0Z5OcwMCHYY/M4WszZzjBKCM X-Received: by 2002:a17:902:d2c4:b0:1a1:ca4d:120a with SMTP id n4-20020a170902d2c400b001a1ca4d120amr19888627plc.7.1679955754488; Mon, 27 Mar 2023 15:22:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679955754; cv=none; d=google.com; s=arc-20160816; b=iqG0PF+3YW5gWpZ0x+Tjxnc1ajjERkgzVYjPLfLNB9ydhOM+AxF2/nLOIVgtGyzcBs GWkUZo1CVyS+WLK682ml1lmRsA0ZwPO95NfSsisCWRkWxNBpumx8X4KH+G7OuaX6/GAW e8af7I1m8lCZVartHjep4G6HyuMCXd18lN7I6BqiD065sw6oEj1OmsL9xKMjZkOkQwr1 AtH8VYwNDwE7btHo+lWevYjUEqoLpqY+TkciWMUlsgiO4rYO4/NiCbeqA5Twav/jV1o8 nzywsN8w6RynB3CknOwYiHu3rA7dZfOklK5BGB2HEb3quBZsJFnyizgFZTy1+Kgj1vth sLKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=P+KfLniK1zvNo/VfKW9Zoq7yP3YvZsyz+bYVCPlk9yM=; b=CKSzky3mWZGWtK/XkbgGbVanDCqicmv1R3m1B0K6rbwnK6IxTsXQRIZQzXE1AtoeGd xCYiAb0wSHa5NndaoDTdeR2/QZ73wkpoRGTCqe3jQwJsBBDwZhy2ijzbKKlJ8zRDsu2H wEgjuHgnXynczW0dG9TXjhkfYoA2sc5Dqm/wGtIT1FxASTidaFCWO7qHeGtZXv9stE8o Jr8heCc6DeC/WU6aebOFzwx95qGJGUoCqO3ln1mUDX+V2c/oEOjNuOYuiWMZfNy0sayp 5UdMR/QfyT1eXjhOd+UXKvlcswqhsGYeVI7ZKi9gBHhE1xzGR9XeL+ytnuMLTluKkjnR meTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=A07LNRrk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l5-20020a63ba45000000b0050c08fcd35asi28219881pgu.71.2023.03.27.15.22.22; Mon, 27 Mar 2023 15:22:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=A07LNRrk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231717AbjC0WWH (ORCPT + 99 others); Mon, 27 Mar 2023 18:22:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53662 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230412AbjC0WWG (ORCPT ); Mon, 27 Mar 2023 18:22:06 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9148B19AB; Mon, 27 Mar 2023 15:22:04 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 43834B819A5; Mon, 27 Mar 2023 22:22:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 624DDC4339C; Mon, 27 Mar 2023 22:22:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1679955721; bh=36NmJOfvymqOUa86Xso6Y3noQoP8kgcFeJ65vzin3Zw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=A07LNRrkcsI2/KLWfm9DfgHmIVnCrLxs45YeWwY9JyI55diZsluhyqXJiofBBLI57 aktf1oFcKlpX3nR6zKUa7dsvuujFKsbc2am0m0bsuNynboAvz9A2uF5Pgx4fPnCqhQ 5vDfm78cXE3aFkVxSGDm0YuC2mx+L8HHQ2Rl2XYQ4KLK3UkFKBDQ0HHOprF6hZw+kT 8rifNS8tCdUr7/rYxOvcuVPUnmzh9+AEJLym5SDcnSCzBplVH5WPHsyqZ09WDwvynG yoAPuEyjhkq9P1ZygfxcdTdTYWgDZG2M7Z4lqBsK+ICXLukiyXA83Pai+A4eLgSZab xV2GiLqGaXTUA== From: Stephen Boyd To: Michael Turquette , Stephen Boyd Cc: linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, patches@lists.linux.dev, Brendan Higgins , David Gow , Greg Kroah-Hartman , "Rafael J . Wysocki" , Rob Herring , Frank Rowand , Christian Marangi , Krzysztof Kozlowski , devicetree@vger.kernel.org, linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com, Maxime Ripard Subject: [PATCH v3 01/11] of: Add KUnit test to confirm DTB is loaded Date: Mon, 27 Mar 2023 15:21:49 -0700 Message-Id: <20230327222159.3509818-2-sboyd@kernel.org> X-Mailer: git-send-email 2.40.0.348.gf938b09366-goog In-Reply-To: <20230327222159.3509818-1-sboyd@kernel.org> References: <20230327222159.3509818-1-sboyd@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-5.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add a simple KUnit test that confirms a DTB has been loaded, i.e. there is a root node. Cc: Rob Herring Cc: Frank Rowand Signed-off-by: Stephen Boyd --- drivers/of/.kunitconfig | 3 +++ drivers/of/Kconfig | 9 +++++++++ drivers/of/Makefile | 2 ++ drivers/of/of_test.c | 34 ++++++++++++++++++++++++++++++++++ 4 files changed, 48 insertions(+) create mode 100644 drivers/of/.kunitconfig create mode 100644 drivers/of/of_test.c diff --git a/drivers/of/.kunitconfig b/drivers/of/.kunitconfig new file mode 100644 index 000000000000..5a8fee11978c --- /dev/null +++ b/drivers/of/.kunitconfig @@ -0,0 +1,3 @@ +CONFIG_KUNIT=y +CONFIG_OF=y +CONFIG_OF_KUNIT_TEST=y diff --git a/drivers/of/Kconfig b/drivers/of/Kconfig index 194e090ceee8..1b995cecf5be 100644 --- a/drivers/of/Kconfig +++ b/drivers/of/Kconfig @@ -37,6 +37,15 @@ config OF_UNITTEST If unsure, say N here. This option is not safe to enable. +config OF_KUNIT_TEST + tristate "Devicetree KUnit DTB Test" if !KUNIT_ALL_TESTS + depends on KUNIT + default KUNIT_ALL_TESTS + help + This option builds KUnit unit tests for device tree infrastructure. + + If unsure, say N here, but this option is safe to enable. + config OF_ALL_DTBS bool "Build all Device Tree Blobs" depends on COMPILE_TEST diff --git a/drivers/of/Makefile b/drivers/of/Makefile index cbae92c5ed02..b11a8adcb985 100644 --- a/drivers/of/Makefile +++ b/drivers/of/Makefile @@ -19,4 +19,6 @@ obj-y += kexec.o endif endif +obj-$(CONFIG_OF_KUNIT_TEST) += of_test.o + obj-$(CONFIG_OF_UNITTEST) += unittest-data/ diff --git a/drivers/of/of_test.c b/drivers/of/of_test.c new file mode 100644 index 000000000000..08b670aee083 --- /dev/null +++ b/drivers/of/of_test.c @@ -0,0 +1,34 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * KUnit tests for OF APIs + */ +#include +#include + +#include + +/* + * Test that the root node / exists. + */ +static void dtb_root_node_exists(struct kunit *test) +{ + KUNIT_EXPECT_NOT_ERR_OR_NULL(test, of_find_node_by_path("/")); +} + +static struct kunit_case dtb_test_cases[] = { + KUNIT_CASE(dtb_root_node_exists), + {} +}; + +/* + * Test suite to confirm a live DTB is loaded. + */ +static struct kunit_suite dtb_suite = { + .name = "dtb", + .test_cases = dtb_test_cases, +}; + +kunit_test_suites( + &dtb_suite, +); +MODULE_LICENSE("GPL"); -- https://git.kernel.org/pub/scm/linux/kernel/git/clk/linux.git/ https://git.kernel.org/pub/scm/linux/kernel/git/sboyd/spmi.git