devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Gibson <david-xT8FGy+AXnRB3Ne2BGzF6laj5H9X9Tb+@public.gmane.org>
To: Pantelis Antoniou
	<pantelis.antoniou-OWPKS81ov/FWk0Htik3J/w@public.gmane.org>
Cc: Jon Loeliger <jdl-CYoMK+44s/E@public.gmane.org>,
	Grant Likely <glikely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org>,
	Frank Rowand
	<frowand.list-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	Rob Herring <robherring2-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	Jan Luebbe <jlu-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>,
	Sascha Hauer <s.hauer-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>,
	Phil Elwell <phil-FnsA7b+Nu9XbIbC87yuRow@public.gmane.org>,
	Simon Glass <sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>,
	Maxime Ripard
	<maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>,
	Thomas Petazzoni
	<thomas.petazzoni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>,
	Boris Brezillon
	<boris.brezillon-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>,
	Antoine Tenart
	<antoine.tenart-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>,
	Stephen Boyd
	<stephen.boyd-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
	Devicetree Compiler
	<devicetree-compiler-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH v11 3/7] tests: Add check_path test
Date: Tue, 29 Nov 2016 13:40:15 +1100	[thread overview]
Message-ID: <20161129024015.GF13307@umbus.fritz.box> (raw)
In-Reply-To: <1480349141-14145-4-git-send-email-pantelis.antoniou-OWPKS81ov/FWk0Htik3J/w@public.gmane.org>

[-- Attachment #1: Type: text/plain, Size: 4113 bytes --]

On Mon, Nov 28, 2016 at 06:05:37PM +0200, Pantelis Antoniou wrote:
> Add a test that checks for existence or not of a node.
> It is useful for testing the various cases when generating
> symbols and fixups for dynamic device tree objects.
> 
> Signed-off-by: Pantelis Antoniou <pantelis.antoniou-OWPKS81ov/FWk0Htik3J/w@public.gmane.org>

Can you please add a test-for-the-test by putting a couple of
invocations of this on test_tree1 into the runner script (one 'exists'
and one 'not-exists' should suffice).

> ---
>  tests/.gitignore     |  1 +
>  tests/Makefile.tests |  3 +-
>  tests/check_path.c   | 82 ++++++++++++++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 85 insertions(+), 1 deletion(-)
>  create mode 100644 tests/check_path.c
> 
> diff --git a/tests/.gitignore b/tests/.gitignore
> index 354b565..9e209d5 100644
> --- a/tests/.gitignore
> +++ b/tests/.gitignore
> @@ -8,6 +8,7 @@ tmp.*
>  /asm_tree_dump
>  /boot-cpuid
>  /char_literal
> +/check_path
>  /del_node
>  /del_property
>  /dtbs_equal_ordered
> diff --git a/tests/Makefile.tests b/tests/Makefile.tests
> index eb039c5..3d7a4f8 100644
> --- a/tests/Makefile.tests
> +++ b/tests/Makefile.tests
> @@ -25,7 +25,8 @@ LIB_TESTS_L = get_mem_rsv \
>  	integer-expressions \
>  	property_iterate \
>  	subnode_iterate \
> -	overlay overlay_bad_fixup
> +	overlay overlay_bad_fixup \
> +	check_path
>  LIB_TESTS = $(LIB_TESTS_L:%=$(TESTS_PREFIX)%)
>  
>  LIBTREE_TESTS_L = truncated_property
> diff --git a/tests/check_path.c b/tests/check_path.c
> new file mode 100644
> index 0000000..0d6a73b
> --- /dev/null
> +++ b/tests/check_path.c
> @@ -0,0 +1,82 @@
> +/*
> + * libfdt - Flat Device Tree manipulation
> + *	Testcase for node existence
> + * Copyright (C) 2016 Konsulko Inc.
> + *
> + * This library is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public License
> + * as published by the Free Software Foundation; either version 2.1 of
> + * the License, or (at your option) any later version.
> + *
> + * This library is distributed in the hope that it will be useful, but
> + * WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with this library; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
> + */
> +
> +#include <stdio.h>
> +
> +#include <libfdt.h>
> +
> +#include "tests.h"
> +
> +#define CHECK(code) \
> +	{ \
> +		if (code) \
> +			FAIL(#code ": %s", fdt_strerror(code)); \
> +	}
> +
> +/* 4k ought to be enough for anybody */
> +#define FDT_COPY_SIZE	(4 * 1024)
> +
> +static void *open_dt(char *path)
> +{
> +	void *dt, *copy;
> +
> +	dt = load_blob(path);
> +	copy = xmalloc(FDT_COPY_SIZE);
> +
> +	/*
> +	 * Resize our DTs to 4k so that we have room to operate on
> +	 */
> +	CHECK(fdt_open_into(dt, copy, FDT_COPY_SIZE));
> +
> +	return copy;
> +}
> +
> +int main(int argc, char *argv[])
> +{
> +	void *fdt_base;
> +	int fail_config, exists, check_exists;
> +
> +	test_init(argc, argv);
> +	fail_config = 0;
> +
> +	if (argc != 4)
> +		fail_config = 1;
> +
> +	if (!fail_config) {
> +		if (!strcmp(argv[2], "exists"))
> +			check_exists = 1;
> +		else if (!strcmp(argv[2], "not-exists"))
> +			check_exists = 0;
> +		else
> +			fail_config = 1;
> +	}
> +
> +	if (fail_config)
> +		CONFIG("Usage: %s <base dtb> <[exists|not-exists]> <node-path>", argv[0]);
> +
> +	fdt_base = open_dt(argv[1]);
> +
> +	exists = fdt_path_offset(fdt_base, argv[3]) >= 0;
> +
> +	if (exists == check_exists)
> +		PASS();
> +	else
> +		FAIL();
> +}

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

  parent reply	other threads:[~2016-11-29  2:40 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-28 16:05 [PATCH v11 0/4] dtc: Dynamic DT support Pantelis Antoniou
     [not found] ` <1480349141-14145-1-git-send-email-pantelis.antoniou-OWPKS81ov/FWk0Htik3J/w@public.gmane.org>
2016-11-28 16:05   ` [PATCH v11 1/7] dtc: Document the dynamic plugin internals Pantelis Antoniou
2016-11-28 16:05   ` [PATCH v11 2/7] dtc: Plugin and fixup support Pantelis Antoniou
     [not found]     ` <1480349141-14145-3-git-send-email-pantelis.antoniou-OWPKS81ov/FWk0Htik3J/w@public.gmane.org>
2016-11-29  2:38       ` David Gibson
2016-11-28 16:05   ` [PATCH v11 3/7] tests: Add check_path test Pantelis Antoniou
     [not found]     ` <1480349141-14145-4-git-send-email-pantelis.antoniou-OWPKS81ov/FWk0Htik3J/w@public.gmane.org>
2016-11-29  2:40       ` David Gibson [this message]
2016-11-28 16:05   ` [PATCH v11 4/7] tests: Add overlay tests Pantelis Antoniou
     [not found]     ` <1480349141-14145-5-git-send-email-pantelis.antoniou-OWPKS81ov/FWk0Htik3J/w@public.gmane.org>
2016-11-29  3:08       ` David Gibson
     [not found]         ` <20161129030807.GH13307-K0bRW+63XPQe6aEkudXLsA@public.gmane.org>
2016-11-29 11:11           ` Pantelis Antoniou
     [not found]             ` <17F182F7-CDF7-4052-86C2-B40505706ED4-OWPKS81ov/FWk0Htik3J/w@public.gmane.org>
2016-11-30  0:35               ` David Gibson
2016-11-30  9:04                 ` Pantelis Antoniou
2016-11-28 16:05   ` [PATCH v11 5/7] overlay: Documentation for the overlay sugar syntax Pantelis Antoniou
     [not found]     ` <1480349141-14145-6-git-send-email-pantelis.antoniou-OWPKS81ov/FWk0Htik3J/w@public.gmane.org>
2016-11-29  3:10       ` David Gibson
     [not found]         ` <20161129031054.GI13307-K0bRW+63XPQe6aEkudXLsA@public.gmane.org>
2016-11-29  4:36           ` Frank Rowand
     [not found]             ` <583D05B7.4040109-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-11-29  5:10               ` David Gibson
     [not found]                 ` <20161129051042.GO13307-K0bRW+63XPQe6aEkudXLsA@public.gmane.org>
2016-11-29 16:45                   ` Frank Rowand
     [not found]                     ` <583DB09C.7060105-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-11-30  0:39                       ` David Gibson
2016-11-30  9:07                         ` Pantelis Antoniou
2016-11-28 16:05   ` [PATCH v11 6/7] overlay: Add syntactic sugar version of overlays Pantelis Antoniou
2016-11-28 16:05   ` [PATCH v11 7/7] tests: Add a test for overlays syntactic sugar Pantelis Antoniou

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=20161129024015.GF13307@umbus.fritz.box \
    --to=david-xt8fgy+axnrb3ne2bgzf6laj5h9x9tb+@public.gmane.org \
    --cc=antoine.tenart-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org \
    --cc=boris.brezillon-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org \
    --cc=devicetree-compiler-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=frowand.list-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=glikely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org \
    --cc=jdl-CYoMK+44s/E@public.gmane.org \
    --cc=jlu-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org \
    --cc=maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org \
    --cc=pantelis.antoniou-OWPKS81ov/FWk0Htik3J/w@public.gmane.org \
    --cc=phil-FnsA7b+Nu9XbIbC87yuRow@public.gmane.org \
    --cc=robherring2-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=s.hauer-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org \
    --cc=sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org \
    --cc=stephen.boyd-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
    --cc=thomas.petazzoni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org \
    /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;
as well as URLs for NNTP newsgroup(s).