Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp3009571lqt; Tue, 23 Apr 2024 08:05:42 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVHxRrLRXaRhALvZXfjZeQqOsxmhHfvq2b07AVUtDX0nUDiDENvPFTvrtNBme2SjBQsjH8mzSG7pcCLal9xYK4Bm0rpM/J61fTq1QVG4g== X-Google-Smtp-Source: AGHT+IG3xhDyfiZ5Ujix0bQF9J1+6fdo0szDgYEC0G5a9NuSxdvz13XM3HfMDeADNfsoNb5SAdIK X-Received: by 2002:ac2:4c92:0:b0:519:3ce:a12b with SMTP id d18-20020ac24c92000000b0051903cea12bmr10305501lfl.23.1713884742402; Tue, 23 Apr 2024 08:05:42 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713884742; cv=pass; d=google.com; s=arc-20160816; b=JlG0Hbv4pTi0a2wprGNsYc6rzW5n8q/BmHfDGJdOSbA2j2uCidFbtMtiTx0K8bdgis YQ06Uj7N2NqxHcdEIIiMygYFYLjMoMbsG3I2kvltH/JvV99P+B2o3v8qAT4USAhIIkVi AC9uatxJ/MdtYjFNafs2F5lSgb13TXPx6rngf6zeIh6jHqkknJ4lXXn2gqlkA5d7oP8v i5np0xzzyOX0HVND4I/kjFf8wfYrohSsElW/1eDIZMd8JqWO0SCE5FvTDUBtwlZyqZLU alWu6zf9F6pxXXnYkLJuVVjnKdSF556jQKGQagx0C3XSDCpgnLsRX60LLplhSgBHHNsk Qwsw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=vH/9pBNO98LBrjRzB5zOtxGV6xOAm93i9A8wL9mr3O0=; fh=QCmBwOMpk8fbQNWykAH5YfOmklOnQZn5WzC/7U6xyDY=; b=imZ+n528waN38NQcd0Q2lTluWCmFxT+kftW6oB4UI2w0POurWUCe/3jBn1K5D0HepV OA6GM7nrqEwzN/9Xk88ENSuyW/7IvKXV3KzAS8rul+soq7Zz6aF2Roc9fVb5hmsOsa/i /BEzZiGl4riagGi+2X49tbjnEnfLvaNsAoqHNcdKfTFDJp0WycVqHi0GPQAXD0Pt2ml5 2ECunno4B2H6NepP3ala4uWuyuRJrzCEHmTpmwMLjJs1aRKpQAXYbUW6i8UlgSKeImFr nmwxF8CZUIUIA+r7c9Q9dbC+SBXeuXBvFfIeJDaSTJeU3TrStsfUJezTb8wPJiKr7NT/ 4Atw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Iouqw4mQ; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-155421-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-155421-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id va1-20020a17090711c100b00a51c5517900si7129975ejb.1008.2024.04.23.08.05.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Apr 2024 08:05:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-155421-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=@kernel.org header.s=k20201202 header.b=Iouqw4mQ; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-155421-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-155421-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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 am.mirrors.kernel.org (Postfix) with ESMTPS id 230681F23060 for ; Tue, 23 Apr 2024 15:05:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 303F613BAE8; Tue, 23 Apr 2024 15:05:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Iouqw4mQ" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 4735F12EBE7; Tue, 23 Apr 2024 15:05:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713884733; cv=none; b=b3AyBeOlp3+g58tgDa/UooU2NboKC6DW47Aukq2sl68LOwCc5vHYQ02Shapnt+IpX5ewMyVm8NrKZbQvAlcyz5QoTaToiwMZvbGNFuGtN4CxR/lcwh07eRRqOyy6Jt/Xf1hVwj8AW9kpVV+iSlWXVuDLt0qMuATPI5RIdTnwlRQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713884733; c=relaxed/simple; bh=rhecxeD2cGyz50/rzIf8qdv6WpuU26577Z2AHZCuTww=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=JVZmo0FfgCdKkzQNBCH+I82WAZJYWnZ3qCUVbF04P1c313ZgHZaxT+6Hj+1E6lw8RVVo23VCFwotT7VQ5UsQ+3yRKBVAFbzgongK2kkLSktSBITf/U1UFb4Ji1OMiFHQX6bSvWUQ9Epo2bPBQBAdW9sHXCf2WwISDQiE7hKWEnM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Iouqw4mQ; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id A3D6AC2BD10; Tue, 23 Apr 2024 15:05:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1713884732; bh=rhecxeD2cGyz50/rzIf8qdv6WpuU26577Z2AHZCuTww=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Iouqw4mQZBJgFmb3LgZ98QJhyGYQvc+EInq511gxjyPNMtiaum2vNq2Bl+Mg4qHXk Ens6L+4d3LJ7hd+zWQCJaLT5DrWIFqiasL0rRDPLSEGmWCxVidMINn/MTcMgW5Q2Cu RGf/Kj7hBmo/dOIJI842Lz+RqBecO4Fa0SOseDLKHnYJY1Mn1/wiXg6lEOMPfVPv03 WFA65VhAAb12rWp+V2bSkIzQQF6bLEP6T7d3S743Jo0auOzhv5OawT9x5btL8kC5Yw prpPY5s0WmWhGzwv2S5B6ZRNvPXnaWhn7II8vvJR1gvk6bWGd2Xzaj2sclfCpVFcZa rh5X9WIN6nOwQ== Date: Tue, 23 Apr 2024 10:05:30 -0500 From: Rob Herring To: Stephen Boyd Cc: Maxime Ripard , Greg Kroah-Hartman , Brendan Higgins , Rae Moar , linux-kselftest@vger.kernel.org, David Gow , Christian Marangi , linux-kernel@vger.kernel.org, "Rafael J . Wysocki" , kunit-dev@googlegroups.com, patches@lists.linux.dev, linux-clk@vger.kernel.org, Michael Turquette , Saravana Kannan , Krzysztof Kozlowski , Conor Dooley , Daniel Latypov , devicetree@vger.kernel.org Subject: Re: [PATCH v4 01/10] of: Add test managed wrappers for of_overlay_apply()/of_node_put() Message-ID: <171388470076.215446.15104256542666415343.robh@kernel.org> References: <20240422232404.213174-1-sboyd@kernel.org> <20240422232404.213174-2-sboyd@kernel.org> 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=us-ascii Content-Disposition: inline In-Reply-To: <20240422232404.213174-2-sboyd@kernel.org> On Mon, 22 Apr 2024 16:23:54 -0700, Stephen Boyd wrote: > Add test managed wrappers for of_overlay_apply() that automatically > removes the overlay when the test is finished. This API is intended for > use by KUnit tests that test code which relies on 'struct device_node's > and of_*() APIs. > > KUnit tests will call of_overlay_apply_kunit() to load an overlay that's > been built into the kernel image. When the test is complete, the overlay > will be removed. > > This has a few benefits: > > 1) It keeps the tests hermetic because the overlay is removed when the > test is complete. Tests won't even be aware that an overlay was > loaded in another test. > > 2) The overlay code can live right next to the unit test that loads it. > The overlay and the unit test can be compiled into one kernel module > if desired. > > 3) We can test different device tree configurations by loading > different overlays. The overlays can be written for a specific test, > and there can be many of them loaded per-test without needing to jam > all possible combinations into one DTB. > > 4) It also allows KUnit to test device tree dependent code on any > architecture, not just UML. This allows KUnit tests to test > architecture specific device tree code. > > There are some potential pitfalls though. Test authors need to be > careful to not overwrite properties in the live tree. The easiest way to > do this is to add and remove nodes with a 'kunit-' prefix, almost > guaranteeing that the same node won't be present in the tree loaded at > boot. > > Suggested-by: Rob Herring > Cc: Rob Herring > Cc: Saravana Kannan > Signed-off-by: Stephen Boyd > --- > Documentation/dev-tools/kunit/api/index.rst | 11 +++ > Documentation/dev-tools/kunit/api/of.rst | 13 +++ > drivers/of/Makefile | 1 + > drivers/of/of_kunit.c | 99 +++++++++++++++++++++ > include/kunit/of.h | 94 +++++++++++++++++++ > 5 files changed, 218 insertions(+) > create mode 100644 Documentation/dev-tools/kunit/api/of.rst > create mode 100644 drivers/of/of_kunit.c > create mode 100644 include/kunit/of.h > Reviewed-by: Rob Herring (Arm)