Re: [PATCH v2 01/11] of: Load KUnit DTB from of_core_init()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Quoting Stephen Boyd (2023-03-21 11:15:19)
> Quoting Rob Herring (2023-03-21 10:33:03)
> > On Wed, Mar 15, 2023 at 11:37:18AM -0700, Stephen Boyd wrote:
> > > diff --git a/drivers/of/of_test.c b/drivers/of/of_test.c
> > > new file mode 100644
> > > index 000000000000..a4d70ac344ad
> > > --- /dev/null
> > > +++ b/drivers/of/of_test.c
> > > @@ -0,0 +1,43 @@
> > > +// SPDX-License-Identifier: GPL-2.0
> > > +/*
> > > + * KUnit tests for OF APIs
> > > + */
> > > +#include <linux/kconfig.h>
> > > +#include <linux/of.h>
> > > +
> > > +#include <kunit/test.h>
> > > +
> > > +/*
> > > + * 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("/"));
> > > +}
> > > +
> > > +/*
> > > + * Test that the /__symbols__ node exists.
> > > + */
> > > +static void dtb_symbols_node_exists(struct kunit *test)
> > > +{
> > > +     KUNIT_EXPECT_NOT_ERR_OR_NULL(test, of_find_node_by_path("/__symbols__"));
> > > +}
> > 
> > Many base DTs will not have this. And the kunit tests themselves 
> > shouldn't need it because they should be independent of the base tree.
> > 
> 
> When I try to apply an overlay it fails 
> 
>  OF: overlay: no fragments or symbols in overlay
>  OF: overlay: init_overlay_changeset() failed, ret = -22
>      # of_overlay_apply_kunit_apply: ASSERTION FAILED at drivers/of/overlay_test.c:18
>      Expected 0 == ({ extern uint8_t __dtbo_kunit_overlay_test_begin[]; extern uint8_t __dtbo_kunit_overlay_test_end[]; __of_overlay_apply_kunit((test), __dtbo_kunit_overlay_test_begin, __dtbo_kunit_overlay_test_end); }), but
>          ({ extern uint8_t __dtbo_kunit_overlay_test_begin[]; extern uint8_t __dtbo_kunit_overlay_test_end[]; __of_overlay_apply_kunit((test), __dtbo_kunit_overlay_test_begin, __dtbo_kunit_overlay_test_end); }) == -12 (0xfffffffffffffff4)
>  [FAILED] of_overlay_apply_kunit_apply
> 
> Now I'm trying to hack on the fake root node to see if I can make it work.
> 

Aha I figured it out. Needed to read more documentation.

---8<---
diff --git a/drivers/of/kunit_overlay_test.dtso b/drivers/of/kunit_overlay_test.dtso
index e3ced1467dd9..7688f9ef1b6b 100644
--- a/drivers/of/kunit_overlay_test.dtso
+++ b/drivers/of/kunit_overlay_test.dtso
@@ -2,7 +2,7 @@
 /dts-v1/;
 /plugin/;
 
-/ {
+&{/} {
 	test-kunit {
 		compatible = "test,kunit-empty";
 	};




[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux