devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Grant Likely <grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org>
To: Simon Glass <sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
Cc: Devicetree Discuss
	<devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org>
Subject: Re: [PATCH 3/9] Add basic tests for dtget
Date: Wed, 6 Jul 2011 12:42:33 -0600	[thread overview]
Message-ID: <20110706184233.GC4871@ponder.secretlab.ca> (raw)
In-Reply-To: <1309892577-23828-4-git-send-email-sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>

On Tue, Jul 05, 2011 at 12:02:51PM -0700, Simon Glass wrote:
> 
> Signed-off-by: Simon Glass <sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>

Yay, testcases.  :-)

g.

> ---
>  tests/dtget-runtest.sh |   30 ++++++++++++++++++++++
>  tests/dtget-test.dts   |   63 ++++++++++++++++++++++++++++++++++++++++++++++++

Rather than creating a new dts file, these test should probably
leverage the existing ones in the tests directory.

>  tests/run_tests.sh     |   33 ++++++++++++++++++++++++-
>  tests/tests.sh         |    1 +
>  4 files changed, 126 insertions(+), 1 deletions(-)
>  create mode 100755 tests/dtget-runtest.sh
>  create mode 100644 tests/dtget-test.dts
> 
> diff --git a/tests/dtget-runtest.sh b/tests/dtget-runtest.sh
> new file mode 100755
> index 0000000..aa2b744
> --- /dev/null
> +++ b/tests/dtget-runtest.sh
> @@ -0,0 +1,30 @@
> +#! /bin/sh
> +
> +. ./tests.sh
> +
> +LOG="tmp.log.$$"
> +EXPECT="tmp.expect.$$"
> +
> +rm -f $TMPFILE $LOG
> +
> +echo "$1" >$EXPECT
> +shift
> +
> +verbose_run_log "$LOG" $VALGRIND "$DTGET" "$@"
> +ret="$?"
> +
> +if [ "$ret" -gt 127 ]; then
> +    signame=$(kill -l $[ret - 128])
> +    FAIL "Killed by SIG$signame"
> +fi
> +
> +diff $EXPECT $LOG
> +ret="$?"
> +
> +rm -f $LOG $EXPECT
> +
> +if [ "$ret" -eq 0 ]; then
> +	PASS
> +else
> +	FAIL
> +fi
> diff --git a/tests/dtget-test.dts b/tests/dtget-test.dts
> new file mode 100644
> index 0000000..79f9633
> --- /dev/null
> +++ b/tests/dtget-test.dts
> @@ -0,0 +1,63 @@
> +/dts-v1/;
> +
> +/memreserve/ 0x1000000000000000 0x0000000002000000;
> +memrsv2: /memreserve/ 0x2000000000000000 0x0100000000000000;
> +/memreserve/ 0x0000000000000000 0x0000000000000014;
> +
> +/ {
> +	model = "MyBoardName";
> +	compatible = "MyBoardName", "MyBoardFamilyName";
> +	#address-cells = <2>;
> +	#size-cells = <2>;
> +
> +	cpus {
> +		linux,phandle = <0x1>;
> +		#address-cells = <1>;
> +		#size-cells = <0>;
> +		PowerPC,970@0 {
> +			name = "PowerPC,970";
> +			device_type = "cpu";
> +			reg = <0x00000000>;
> +			clock-frequency = <1600000000>;
> +			timebase-frequency = <33333333>;
> +			linux,boot-cpu;
> +			i-cache-size = <65536>;
> +			d-cache-size = <32768>;
> +		};
> +
> +		PowerPC,970@1 {
> +			name = "PowerPC,970";
> +			device_type = "cpu";
> +			reg = <0x00000001>;
> +			clock-frequency = <1600000000>;
> +			timebase-frequency = <33333333>;
> +			i-cache-size = <65536>;
> +			d-cache-size = <32768>;
> +		};
> +
> +	};
> +
> +	node: randomnode {
> +		prop: string = str: "foo", "stuffstuff\t\t\t\n\n\n" str_end: ;
> +		blob = [byte: 0a 0b 0c 0d byte_mid: de ea ad be ef byte_end: ];
> +		ref = < cell: &{/memory@0} 0x0 cell_mid: 0xffffffff cell_end: >;
> +		mixed = "abc", pre: [1234] post: , gap: < aligned: 0xa 0xb 0xc>;
> +		tricky1 = [61 lt1: 62 63 00];
> +		subnode: child {
> +		};
> +		/* subnode_end: is auto-generated by node emit */
> +	};
> +	/* node_end: is auto-generated by node emit */
> +
> +	memory@0 {
> +		device_type = "memory";
> +		memreg: reg = <0x00000000 0x00000000 0x00000000 0x20000000>;
> +	};
> +
> +	chosen {
> +		bootargs = "root=/dev/sda2";
> +		linux,platform = <0x600>;
> +	};
> +
> +};
> +
> diff --git a/tests/run_tests.sh b/tests/run_tests.sh
> index 72dda32..01a2b60 100755
> --- a/tests/run_tests.sh
> +++ b/tests/run_tests.sh
> @@ -83,6 +83,12 @@ asm_to_so_test () {
>      run_wrap_test asm_to_so "$@"
>  }
>  
> +run_dtget_test () {
> +    echo -n "$1:	"
> +    shift
> +    base_run_test sh dtget-runtest.sh "$@"
> +}
> +
>  tree1_tests () {
>      TREE=$1
>  
> @@ -388,6 +394,28 @@ dtbs_equal_tests () {
>      cmp_tests test_tree1.dtb $WRONG_TREE1
>  }
>  
> +dtget_tests () {
> +    file=dtget-test.dtb
> +    $DTC -O dtb -o $file ${file%.dtb}.dts 2>/dev/null
> +
> +    # run_dtget_test <test-name> <expected-result> <args>...
> +    run_dtget_test "Simple string" "MyBoardName" $file "/model"
> +    run_dtget_test "Multiple string i" "77 121 66 111 \
> +97 114 100 78 97 109 101 0 77 121 66 111 97 114 100 70 97 109 105 \
> +108 121 78 97 109 101 0" $file "/compatible"
> +    run_dtget_test "Multiple string s" "MyBoardName MyBoardFamilyName" \
> +	-t s $file "/compatible"
> +    run_dtget_test "Integer" "32768" $file "/cpus/PowerPC,970@1/d-cache-size"
> +    run_dtget_test "Integer hex" "8000" -f %x $file \
> +	"/cpus/PowerPC,970@1/d-cache-size"
> +    run_dtget_test "Integer list" "61 62 63 00" -f %02x -t b $file \
> +	"/randomnode/tricky1"
> +    run_dtget_test "Byte list short" "a b c d de ea ad be ef" -f %x -t b \
> +	$file "/randomnode/blob"
> +    run_dtget_test "Integer list short" "a0b0c0d deeaadbe ef000000" -f %x \
> +	-t i $file "/randomnode/blob"
> +}
> +
>  while getopts "vt:m" ARG ; do
>      case $ARG in
>  	"v")
> @@ -403,7 +431,7 @@ while getopts "vt:m" ARG ; do
>  done
>  
>  if [ -z "$TESTSETS" ]; then
> -    TESTSETS="libfdt dtc dtbs_equal"
> +    TESTSETS="libfdt dtc dtbs_equal dtget"
>  fi
>  
>  # Make sure we don't have stale blobs lying around
> @@ -420,6 +448,9 @@ for set in $TESTSETS; do
>  	"dtbs_equal")
>  	    dtbs_equal_tests
>  	    ;;
> +	"dtget")
> +	    dtget_tests
> +	    ;;
>      esac
>  done
>  
> diff --git a/tests/tests.sh b/tests/tests.sh
> index 30ffead..cf7f19e 100644
> --- a/tests/tests.sh
> +++ b/tests/tests.sh
> @@ -11,6 +11,7 @@ FAIL () {
>  }
>  
>  DTC=../dtc
> +DTGET=../dtget
>  
>  verbose_run () {
>      if [ -z "$QUIET_TEST" ]; then
> -- 
> 1.7.3.1
> 

  parent reply	other threads:[~2011-07-06 18:42 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-05 19:02 [PATCH 0/9] Add dtget and dtput for access to fdt from build system Simon Glass
     [not found] ` <1309892577-23828-1-git-send-email-sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
2011-07-05 19:02   ` [PATCH 1/9] Split out is_printable_string() into util.c Simon Glass
     [not found]     ` <1309892577-23828-2-git-send-email-sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
2011-07-06 18:39       ` Grant Likely
2011-07-16  5:44       ` David Gibson
     [not found]         ` <20110716054447.GE4368-787xzQ0H9iQXU02nzanrWNbf9cGiqdzd@public.gmane.org>
2011-07-17 12:43           ` Jon Loeliger
2011-07-05 19:02   ` [PATCH 2/9] Add dtget utility to read property values from device tree Simon Glass
     [not found]     ` <1309892577-23828-3-git-send-email-sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
2011-07-06 18:41       ` Grant Likely
2011-07-19  3:34       ` David Gibson
     [not found]         ` <20110719033437.GB6399-787xzQ0H9iQXU02nzanrWNbf9cGiqdzd@public.gmane.org>
2011-07-28 12:22           ` Simon Glass
     [not found]             ` <CAPnjgZ3GgOx-Sja2Lq2WzYy+FYv3oyUF9vzdZ8RPYE-Hsmjf0Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-09-02 17:54               ` Simon Glass
     [not found]                 ` <CAPnjgZ1mSifP1rSSCZgDCDQvd-PR3Q++Qr_TovJVPW_BrH3fgA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-09-03 14:33                   ` David Gibson
     [not found]                     ` <20110903143355.GB12965-787xzQ0H9iQXU02nzanrWNbf9cGiqdzd@public.gmane.org>
2011-09-04  3:18                       ` Simon Glass
     [not found]                         ` <CAPnjgZ3hB_nfGqVA_4+wQfxuanUn7nhVQMboEFSODK0UvsNqmg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-09-04 11:14                           ` David Gibson
     [not found]                             ` <20110904111448.GA30278-787xzQ0H9iQXU02nzanrWNbf9cGiqdzd@public.gmane.org>
2011-09-04 21:18                               ` Simon Glass
2011-07-05 19:02   ` [PATCH 3/9] Add basic tests for dtget Simon Glass
     [not found]     ` <1309892577-23828-4-git-send-email-sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
2011-07-06 18:42       ` Grant Likely [this message]
2011-07-19  5:40       ` David Gibson
2011-07-05 19:02   ` [PATCH 4/9] Add missing tests to .gitignore Simon Glass
     [not found]     ` <1309892577-23828-5-git-send-email-sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
2011-07-06 18:42       ` Grant Likely
2011-07-16  5:49       ` David Gibson
     [not found]         ` <20110716054944.GF4368-787xzQ0H9iQXU02nzanrWNbf9cGiqdzd@public.gmane.org>
2011-07-17 12:45           ` Jon Loeliger
2011-07-05 19:02   ` [PATCH 5/9] Add utilfdt for common functions, adjust dtget Simon Glass
     [not found]     ` <1309892577-23828-6-git-send-email-sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
2011-07-06 18:43       ` Grant Likely
2011-07-05 19:02   ` [PATCH 6/9] Add new dtput utility to write values to fdt Simon Glass
     [not found]     ` <1309892577-23828-7-git-send-email-sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
2011-07-06 18:46       ` Grant Likely
     [not found]         ` <20110706184626.GF4871-e0URQFbLeQY2iJbIjFUEsiwD8/FfD2ys@public.gmane.org>
2011-09-04  3:23           ` Simon Glass
2011-07-05 19:02   ` [PATCH 7/9] Add some tests for dtput Simon Glass
2011-07-05 19:02   ` [PATCH 8/9] Add dtput to .gitignore Simon Glass
     [not found]     ` <1309892577-23828-9-git-send-email-sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
2011-07-06 18:46       ` Grant Likely
2011-07-05 19:02   ` [PATCH 9/9] dtput: Support adding strings with spaces Simon Glass
     [not found]     ` <1309892577-23828-10-git-send-email-sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
2011-07-06 18:47       ` Grant Likely

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=20110706184233.GC4871@ponder.secretlab.ca \
    --to=grant.likely-s3s/wqlpoipyb63q8fvjnq@public.gmane.org \
    --cc=devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org \
    --cc=sjg-F7+t8E8rja9g9hUCZPvPmw@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).