devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Simon Glass <sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
To: Devicetree Discuss
	<devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org>
Subject: [PATCH 7/9] Add some tests for dtput
Date: Tue,  5 Jul 2011 12:02:55 -0700	[thread overview]
Message-ID: <1309892577-23828-8-git-send-email-sjg@chromium.org> (raw)
In-Reply-To: <1309892577-23828-1-git-send-email-sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>


Signed-off-by: Simon Glass <sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
---
 tests/dtput-runtest.sh |   50 ++++++++++++++++++++++++++++++++++++++++++++++++
 tests/run_tests.sh     |   40 +++++++++++++++++++++++++++++++++++++-
 tests/tests.sh         |    1 +
 3 files changed, 90 insertions(+), 1 deletions(-)
 create mode 100644 tests/dtput-runtest.sh

diff --git a/tests/dtput-runtest.sh b/tests/dtput-runtest.sh
new file mode 100644
index 0000000..a8c9655
--- /dev/null
+++ b/tests/dtput-runtest.sh
@@ -0,0 +1,50 @@
+#! /bin/sh
+
+# Run script for dtput tests
+# We run dtput to update the device tree, thn dtget to check it
+
+# Usage
+#	dtput-runtest.sh name expected_output dtb_file key value flags
+
+. ./tests.sh
+
+LOG="tmp.log.$$"
+EXPECT="tmp.expect.$$"
+
+rm -f $TMPFILE $LOG
+
+echo "$1" >$EXPECT
+dtb="$2"
+key="$3"
+value="$4"
+flags="$5"
+
+# First run dtput
+verbose_run $VALGRIND "$DTPUT" "$dtb" "$key" $value $flags
+ret="$?"
+
+if [ "$ret" -gt 127 ]; then
+    signame=$(kill -l $[ret - 128])
+    FAIL "Killed by SIG$signame"
+fi
+
+
+# Now dtget to read the value
+verbose_run_log "$LOG" $VALGRIND "$DTGET" "$dtb" "$key" $flags
+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/run_tests.sh b/tests/run_tests.sh
index 01a2b60..d95d1fe 100755
--- a/tests/run_tests.sh
+++ b/tests/run_tests.sh
@@ -84,11 +84,25 @@ asm_to_so_test () {
 }
 
 run_dtget_test () {
+    # run_dtget_test name expected_output dtb_file args...
     echo -n "$1:	"
     shift
     base_run_test sh dtget-runtest.sh "$@"
 }
 
+run_dtput_test () {
+    # run_dtput_test name expected_output dtb_file key value flags
+    echo -n "$1:	"
+    shift
+    output="$1"
+    dtb="$2"
+    key="$3"
+    value="$4"
+    flags="$5"
+    echo output: $output
+    base_run_test sh dtput-runtest.sh "$output" "$dtb" "$key" "$value" "$flags"
+}
+
 tree1_tests () {
     TREE=$1
 
@@ -416,6 +430,27 @@ dtget_tests () {
 	-t i $file "/randomnode/blob"
 }
 
+dtput_tests () {
+    file=dtget-test.dtb
+    $DTC -O dtb -o $file ${file%.dtb}.dts 2>/dev/null
+
+    # run_dtput_test <test-name> <expected-result> <file> <key> <value>
+    run_dtput_test "Simple string" "a_model" $file "/model" "a_model" -ts
+
+    run_dtput_test "Multiple string s" "board1 board2" \
+	$file "/compatible" "board1 board2" -ts
+    run_dtput_test "Integer" "32768" $file "/cpus/PowerPC,970@1/d-cache-size" \
+	"32768"
+    run_dtput_test "Integer hex" "8001" $file \
+	"/cpus/PowerPC,970@1/d-cache-size" 0x8001 "-f %x"
+    run_dtput_test "Integer list" "02 03 04" $file \
+	"/randomnode/tricky1" "02 03 04" "-f %02x -t b"
+    run_dtput_test "Byte list short" "a b c ea ad be ef" \
+	$file "/randomnode/blob" "a b c ea ad be ef" "-f %x -t b"
+    run_dtput_test "Integer list short" "a0b0c0d deeaae ef000000" \
+	$file "/randomnode/blob" "a0b0c0d deeaae ef000000" "-t i -f %x"
+}
+
 while getopts "vt:m" ARG ; do
     case $ARG in
 	"v")
@@ -431,7 +466,7 @@ while getopts "vt:m" ARG ; do
 done
 
 if [ -z "$TESTSETS" ]; then
-    TESTSETS="libfdt dtc dtbs_equal dtget"
+    TESTSETS="libfdt dtc dtbs_equal dtget dtput"
 fi
 
 # Make sure we don't have stale blobs lying around
@@ -451,6 +486,9 @@ for set in $TESTSETS; do
 	"dtget")
 	    dtget_tests
 	    ;;
+	"dtput")
+	    dtput_tests
+	    ;;
     esac
 done
 
diff --git a/tests/tests.sh b/tests/tests.sh
index cf7f19e..bdd3c79 100644
--- a/tests/tests.sh
+++ b/tests/tests.sh
@@ -12,6 +12,7 @@ FAIL () {
 
 DTC=../dtc
 DTGET=../dtget
+DTPUT=../dtput
 
 verbose_run () {
     if [ -z "$QUIET_TEST" ]; then
-- 
1.7.3.1

  parent reply	other threads:[~2011-07-05 19:02 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
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   ` Simon Glass [this message]
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=1309892577-23828-8-git-send-email-sjg@chromium.org \
    --to=sjg-f7+t8e8rja9g9huczpvpmw@public.gmane.org \
    --cc=devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@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).