public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 4/5] test: overlay: Add unit test for stacked overlay
Date: Fri, 07 Jul 2017 13:33:27 +0300	[thread overview]
Message-ID: <1499423607.19864.1.camel@hp800z> (raw)
In-Reply-To: <CAAtXAHf+zULe6G-NVm23SNbvSKP3c6VgrdcLFz8zqbW=gs8qag@mail.gmail.com>

On Fri, 2017-07-07 at 00:48 -0700, Moritz Fischer wrote:
> Hi Pantelis,
> 
> nit inline
> 
> On Fri, Jun 30, 2017 at 9:23 AM, Pantelis Antoniou
> <pantelis.antoniou@konsulko.com> wrote:
> > Verify that stacked overlays work.
> >
> > Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
> 
> Reviewed-by: Moritz Fischer <moritz.fischer@ettus.com>
> > ---
> >  test/overlay/Makefile                     |  1 +
> >  test/overlay/cmd_ut_overlay.c             | 34 ++++++++++++++++++++++++++++++-
> >  test/overlay/test-fdt-overlay-stacked.dts | 21 +++++++++++++++++++
> >  3 files changed, 55 insertions(+), 1 deletion(-)
> >  create mode 100644 test/overlay/test-fdt-overlay-stacked.dts
> >
> > diff --git a/test/overlay/Makefile b/test/overlay/Makefile
> > index 907f085..416645c 100644
> > --- a/test/overlay/Makefile
> > +++ b/test/overlay/Makefile
> > @@ -13,3 +13,4 @@ DTC_FLAGS += -@
> >  # DT overlays
> >  obj-y += test-fdt-base.dtb.o
> >  obj-y += test-fdt-overlay.dtb.o
> > +obj-y += test-fdt-overlay-stacked.dtb.o
> > diff --git a/test/overlay/cmd_ut_overlay.c b/test/overlay/cmd_ut_overlay.c
> > index cbef720..d8f5c8f 100644
> > --- a/test/overlay/cmd_ut_overlay.c
> > +++ b/test/overlay/cmd_ut_overlay.c
> > @@ -20,6 +20,7 @@
> >
> >  extern u32 __dtb_test_fdt_base_begin;
> >  extern u32 __dtb_test_fdt_overlay_begin;
> > +extern u32 __dtb_test_fdt_overlay_stacked_begin;
> >
> >  static int fdt_getprop_u32_by_index(void *fdt, const char *path,
> >                                     const char *name, int index,
> > @@ -201,6 +202,19 @@ static int fdt_overlay_local_phandles(struct unit_test_state *uts)
> >  }
> >  OVERLAY_TEST(fdt_overlay_local_phandles, 0);
> >
> > +static int fdt_overlay_stacked(struct unit_test_state *uts)
> > +{
> > +       void *fdt = uts->priv;
> > +       u32 val = 0;
> > +
> > +       ut_assertok(fdt_getprop_u32(fdt, "/new-local-node", "stacked-test-int-property",
> > +                                   &val));
> > +       ut_asserteq(43, val);
> > +
> > +       return CMD_RET_SUCCESS;
> > +}
> > +OVERLAY_TEST(fdt_overlay_stacked, 0);
> > +
> >  int do_ut_overlay(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
> >  {
> >         struct unit_test *tests = ll_entry_start(struct unit_test,
> > @@ -210,7 +224,8 @@ int do_ut_overlay(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
> >         struct unit_test *test;
> >         void *fdt_base = &__dtb_test_fdt_base_begin;
> >         void *fdt_overlay = &__dtb_test_fdt_overlay_begin;
> > -       void *fdt_base_copy, *fdt_overlay_copy;
> > +       void *fdt_overlay_stacked = &__dtb_test_fdt_overlay_stacked_begin;
> > +       void *fdt_base_copy, *fdt_overlay_copy, *fdt_overlay_stacked_copy;
> >
> >         uts = calloc(1, sizeof(*uts));
> >         if (!uts)
> > @@ -228,6 +243,10 @@ int do_ut_overlay(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
> >         if (!fdt_overlay_copy)
> >                 return -ENOMEM;
> >
> > +       fdt_overlay_stacked_copy = malloc(FDT_COPY_SIZE);
> > +       if (!fdt_overlay_stacked_copy)
> > +               return -ENOMEM;
> > +
> >         /*
> >          * Resize the FDT to 4k so that we have room to operate on
> >          *
> > @@ -245,9 +264,21 @@ int do_ut_overlay(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
> >         ut_assertok(fdt_open_into(fdt_overlay, fdt_overlay_copy,
> >                                   FDT_COPY_SIZE));
> >
> > +       /*
> > +        * Resize the stacked overlay to 4k so that we have room to operate on
> > +        *
> > +        * (and relocate it since the memory might be mapped
> > +        * read-only)
> > +        */
> > +       ut_assertok(fdt_open_into(fdt_overlay_stacked, fdt_overlay_stacked_copy,
> > +                                 FDT_COPY_SIZE));
> > +
> >         /* Apply the overlay */
> >         ut_assertok(fdt_overlay_apply(fdt_base_copy, fdt_overlay_copy));
> >
> > +       /* Apply the stacked overlay */
> > +       ut_assertok(fdt_overlay_apply(fdt_base_copy, fdt_overlay_stacked_copy));
> > +
> >         if (argc == 1)
> >                 printf("Running %d environment tests\n", n_ents);
> >
> > @@ -263,6 +294,7 @@ int do_ut_overlay(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
> >
> >         printf("Failures: %d\n", uts->fail_count);
> >
> > +       free(fdt_overlay_stacked_copy);
> >         free(fdt_overlay_copy);
> >         free(fdt_base_copy);
> >         free(uts);
> > diff --git a/test/overlay/test-fdt-overlay-stacked.dts b/test/overlay/test-fdt-overlay-stacked.dts
> > new file mode 100644
> > index 0000000..9fb7c7b
> > --- /dev/null
> > +++ b/test/overlay/test-fdt-overlay-stacked.dts
> > @@ -0,0 +1,21 @@
> > +/*
> > + * Copyright (c) 2016 NextThing Co
> > + * Copyright (c) 2016 Free Electrons
> > + * Copyright (c) 2018 Konsulko Group
> 
> Are you time-traveling or anticipating a long review process ;-)

It is a file that's been copied and modified so I'm keeping the
copyright lines. 

Long review process? In my open source? It's more likely than you think.

> > + *
> > + * SPDX-License-Identifier:    GPL-2.0+
> > + */
> > +
> > +/dts-v1/;
> > +/plugin/;
> > +
> > +/ {
> > +       /* Test that we can reference an overlay symbol */
> > +       fragment at 0 {
> > +               target = <&local>;
> > +
> > +               __overlay__ {
> > +                       stacked-test-int-property = <43>;
> > +               };
> > +       };
> > +};
> > --
> > 2.1.4
> >

Regards

-- Pantelis

  parent reply	other threads:[~2017-07-07 10:33 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-30 16:22 [U-Boot] [PATCH 0/5] uboot overlays and FIT image Pantelis Antoniou
2017-06-30 16:22 ` [U-Boot] [PATCH 1/5] libfdt.h: Introduce FDT_PATH_MAX Pantelis Antoniou
2017-07-01 14:01   ` Marek Vasut
2017-07-07  3:58     ` Simon Glass
2017-07-07  7:03       ` Pantelis Antoniou
2017-06-30 16:22 ` [U-Boot] [PATCH 2/5] libfdt_env.h: Add <malloc.h> in libfdt environment Pantelis Antoniou
2017-07-01 14:02   ` Marek Vasut
2017-07-04 16:53     ` Pantelis Antoniou
2017-07-07  3:58   ` Simon Glass
2017-06-30 16:23 ` [U-Boot] [PATCH 3/5] fdt: Allow stacked overlays phandle references Pantelis Antoniou
2017-07-01 14:07   ` Marek Vasut
2017-07-04 17:03     ` Pantelis Antoniou
2017-07-05  6:25     ` Lothar Waßmann
2017-07-07  3:58   ` Simon Glass
2017-07-07  7:02     ` Pantelis Antoniou
2017-07-14 13:51       ` Simon Glass
2017-06-30 16:23 ` [U-Boot] [PATCH 4/5] test: overlay: Add unit test for stacked overlay Pantelis Antoniou
2017-07-07  3:58   ` Simon Glass
2017-07-07  7:48   ` Moritz Fischer
2017-07-07  8:32     ` Marek Vasut
2017-07-07 10:33     ` Pantelis Antoniou [this message]
2017-06-30 16:23 ` [U-Boot] [PATCH 5/5] fit: Introduce methods for applying overlays on fit-load Pantelis Antoniou
2017-07-01 14:11   ` Marek Vasut
2017-07-04 17:05     ` Pantelis Antoniou
2017-07-04 22:19       ` stefan.bruens at rwth-aachen.de
2017-07-05  6:32         ` Lothar Waßmann
2017-07-28 18:48 ` [U-Boot] [PATCH 0/5] uboot overlays and FIT image Simon Glass
2017-07-28 19:20   ` Tom Rini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1499423607.19864.1.camel@hp800z \
    --to=pantelis.antoniou@konsulko.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox