From: Simon Glass <sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
To: Devicetree Discuss
<devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org>
Subject: [PATCH v2 6/6] fdtput: Add basic tests
Date: Wed, 7 Sep 2011 12:54:20 -0700 [thread overview]
Message-ID: <1315425260-2711-7-git-send-email-sjg@chromium.org> (raw)
In-Reply-To: <1315425260-2711-1-git-send-email-sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
These tests verify the major features.
Signed-off-by: Simon Glass <sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
---
Changes in v2:
- Adjust tests for new fdtput arguments
- Add test for multiple strings
- Add test for exhausting fdt space
tests/fdtput-runtest.sh | 55 +++++++++++++++++++++++++++++++++++
tests/run_tests.sh | 73 +++++++++++++++++++++++++++++++++++++++++++++-
tests/tests.sh | 1 +
3 files changed, 127 insertions(+), 2 deletions(-)
create mode 100644 tests/fdtput-runtest.sh
diff --git a/tests/fdtput-runtest.sh b/tests/fdtput-runtest.sh
new file mode 100644
index 0000000..ea51569
--- /dev/null
+++ b/tests/fdtput-runtest.sh
@@ -0,0 +1,55 @@
+#! /bin/sh
+
+# Run script for fdtput tests
+# We run fdtput to update the device tree, thn fdtget to check it
+
+# Usage
+# fdtput-runtest.sh name expected_output dtb_file node property flags value
+
+. ./tests.sh
+
+LOG="tmp.log.$$"
+EXPECT="tmp.expect.$$"
+
+rm -f $TMPFILE $LOG
+
+expect="$1"
+echo "$expect" >$EXPECT
+dtb="$2"
+node="$3"
+property="$4"
+flags="$5"
+shift 5
+value="$@"
+
+# First run fdtput
+verbose_run $VALGRIND "$DTPUT" "$dtb" "$node" "$property" $value $flags
+ret="$?"
+
+if [ "$ret" -ne 0 -a "$expect" = "ERR" ]; then
+ PASS
+fi
+if [ "$ret" -gt 127 ]; then
+ signame=$(kill -l $[ret - 128])
+ FAIL "Killed by SIG$signame"
+fi
+
+# Now fdtget to read the value
+verbose_run_log "$LOG" $VALGRIND "$DTGET" "$dtb" "$node" "$property" $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 9acdeb5..cd03d61 100755
--- a/tests/run_tests.sh
+++ b/tests/run_tests.sh
@@ -90,6 +90,21 @@ run_fdtget_test () {
base_run_test sh fdtget-runtest.sh "$@"
}
+run_fdtput_test () {
+ # run_fdtput_test name expected_output dtb_file node property flags value...
+ echo -n "$1: "
+ shift
+ output="$1"
+ dtb="$2"
+ node="$3"
+ property="$4"
+ flags="$5"
+ shift 5
+ base_run_test sh fdtput-runtest.sh "$output" "$dtb" "$node" "$property" \
+ "$flags" $@
+# base_run_test sh fdtput-runtest.sh "$@"
+}
+
tree1_tests () {
TREE=$1
@@ -415,10 +430,61 @@ fdtget_tests () {
$file /randomnode blob
run_fdtget_test "Integer list short" "a0b0c0d deeaadbe ef000000" -tx \
-t i $file /randomnode blob
- run_fdtget_test "Missing property" ERR -tx \
+ run_fdtget_test "Missing property" ERR -ts \
$file /randomnode doctor-who
}
+fdtput_tests () {
+ file=label01.dtb
+ src=label01.dts
+
+ # Create some test files containing useful strings
+ base=tmp.test0
+ file1=tmp.test1
+ file2=tmp.test2
+ bigfile1=tmp.test3
+ bigfile2=tmp.test4
+
+ # Filter out anything the shell might not like
+ cat $src | tr -d "'\"\n\;/\.\*{}\-" | tr -s "[:blank:]" " " >$base
+
+ # Make two small files
+ head -5 $base >$file1
+ cat $file1 | tr a-z A-Z | cut -c10-30 | sort -r >$file2
+
+ # and two larger ones
+ cat $base > $bigfile1
+ tac $base | tr a-z A-Z | sort -r >$bigfile2
+
+ # Allow just enough space for both file1 and file2
+ (( space = $(stat -c %s $file1) + $(stat -c %s $file2) ))
+ $DTC -O dtb -p $space -o $file ${file%.dtb}.dts 2>/dev/null
+
+ # run_fdtput_test <test-name> <expected-result> <file> <key> <flags>
+ # <args>...
+ run_fdtput_test "Simple string" "a_model" $file / model -ts "a_model"
+ run_fdtput_test "Multiple string s" "board1 board2" \
+ $file / compatible -ts board1 board2
+ run_fdtput_test "Single string with spaces" "board1 board2" \
+ $file / compatible -ts "board1 board2"
+ run_fdtput_test "Integer" "32768" \
+ $file /cpus/PowerPC,970@1 d-cache-size "" "32768"
+ run_fdtput_test "Integer hex" "8001" \
+ $file /cpus/PowerPC,970@1 d-cache-size -tx 0x8001
+ run_fdtput_test "Integer list" "2 3 4" \
+ $file /randomnode tricky1 -tb "02 03 04"
+ run_fdtput_test "Byte list short" "a b c ea ad be ef" \
+ $file /randomnode blob -tbx "a b c ea ad be ef"
+ run_fdtput_test "Integer list short" "a0b0c0d deeaae ef000000" \
+ $file /randomnode blob -tx "a0b0c0d deeaae ef000000"
+ run_fdtput_test "Large string list" "`cat $file1 $file2`" \
+ $file /randomnode blob -ts "`cat $file1`" "`cat $file2`"
+
+ # This should be larger than available space in the fdt ($space)
+ run_fdtput_test "Enormous string list" ERR \
+ $file /randomnode blob -ts "`cat $bigfile1`" "`cat $bigfile2`"
+}
+
while getopts "vt:m" ARG ; do
case $ARG in
"v")
@@ -434,7 +500,7 @@ while getopts "vt:m" ARG ; do
done
if [ -z "$TESTSETS" ]; then
- TESTSETS="libfdt dtc dtbs_equal fdtget"
+ TESTSETS="libfdt dtc dtbs_equal fdtget fdtput"
fi
# Make sure we don't have stale blobs lying around
@@ -454,6 +520,9 @@ for set in $TESTSETS; do
"fdtget")
fdtget_tests
;;
+ "fdtput")
+ fdtput_tests
+ ;;
esac
done
diff --git a/tests/tests.sh b/tests/tests.sh
index d9a0524..6e5e76a 100644
--- a/tests/tests.sh
+++ b/tests/tests.sh
@@ -12,6 +12,7 @@ FAIL () {
DTC=../dtc
DTGET=../fdtget
+DTPUT=../fdtput
verbose_run () {
if [ -z "$QUIET_TEST" ]; then
--
1.7.3.1
next prev parent reply other threads:[~2011-09-07 19:54 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-07 19:54 [PATCH v2 0/6] Add fdtget and fdtput for access to fdt from build system Simon Glass
[not found] ` <1315425260-2711-1-git-send-email-sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
2011-09-07 19:54 ` [PATCH v2 1/6] Add utilfdt for common functions Simon Glass
[not found] ` <1315425260-2711-2-git-send-email-sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
2011-09-08 5:20 ` David Gibson
[not found] ` <20110908052028.GQ30278-787xzQ0H9iQXU02nzanrWNbf9cGiqdzd@public.gmane.org>
2011-09-08 12:37 ` Simon Glass
[not found] ` <CAPnjgZ1J0k93vo1A5ns5OxW5=nesr9pwLMMPAc+gyaOWmtmwuQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-09-09 2:34 ` David Gibson
2011-09-07 19:54 ` [PATCH v2 2/6] ftdump: use util_read_fdt Simon Glass
2011-09-07 19:54 ` [PATCH v2 3/6] Add fdtget utility to read property values from device tree Simon Glass
[not found] ` <1315425260-2711-4-git-send-email-sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
2011-09-08 5:25 ` David Gibson
[not found] ` <20110908052547.GR30278-787xzQ0H9iQXU02nzanrWNbf9cGiqdzd@public.gmane.org>
2011-09-08 12:47 ` Simon Glass
[not found] ` <CAPnjgZ0qnr8VVOX7kCq6wEZ-OxAsxmHkPcTGE7wu1B_9ME_SPA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-09-09 4:49 ` David Gibson
[not found] ` <20110909044945.GF21002-787xzQ0H9iQXU02nzanrWNbf9cGiqdzd@public.gmane.org>
2011-09-09 5:44 ` Simon Glass
[not found] ` <CAPnjgZ3xw7ByV4Yzeot3zgs4oo0zciX2OV_V4vfQ8tGsgLcPvw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-09-12 0:53 ` David Gibson
[not found] ` <20110912005357.GI9025-787xzQ0H9iQXU02nzanrWNbf9cGiqdzd@public.gmane.org>
2011-09-12 4:34 ` Simon Glass
[not found] ` <CAPnjgZ1vevcwCQU+uyjAA3YZd--RhU9MgAF8O8G4Hr5e4CYo_g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-09-16 8:18 ` David Gibson
[not found] ` <20110916081804.GF9025-787xzQ0H9iQXU02nzanrWNbf9cGiqdzd@public.gmane.org>
2011-09-16 16:25 ` Simon Glass
[not found] ` <CAPnjgZ1LUPm9mRft5q=KHGe2h2+Masdh0kGXQ-7j1VTUDsMP7g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-09-19 2:04 ` David Gibson
[not found] ` <20110919020440.GA15001-787xzQ0H9iQXU02nzanrWNbf9cGiqdzd@public.gmane.org>
2011-09-19 5:46 ` Simon Glass
[not found] ` <CAPnjgZ09mO06uruZtC=86BuitUWtQkGQfaHTf25HXK9KzoiD+w-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-09-19 8:05 ` David Gibson
[not found] ` <20110919080557.GA29197-787xzQ0H9iQXU02nzanrWNbf9cGiqdzd@public.gmane.org>
2011-09-19 15:11 ` Simon Glass
2011-09-07 19:54 ` [PATCH v2 4/6] fdtget: Add basic tests Simon Glass
[not found] ` <1315425260-2711-5-git-send-email-sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
2011-09-08 5:27 ` David Gibson
2011-09-07 19:54 ` [PATCH v2 5/6] Add new fdtput utility to write values to fdt Simon Glass
[not found] ` <1315425260-2711-6-git-send-email-sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
2011-09-08 5:32 ` David Gibson
[not found] ` <20110908053209.GT30278-787xzQ0H9iQXU02nzanrWNbf9cGiqdzd@public.gmane.org>
2011-09-08 12:51 ` Simon Glass
[not found] ` <CAPnjgZ2UNjxTz9=sWJ8JFq=AXF1NS4dG6C_BkyHvfDf=ZMVpmg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-09-08 13:00 ` David Gibson
2011-09-07 19:54 ` Simon Glass [this message]
[not found] ` <1315425260-2711-7-git-send-email-sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
2011-09-08 5:32 ` [PATCH v2 6/6] fdtput: Add basic tests David Gibson
[not found] ` <20110908053235.GU30278-787xzQ0H9iQXU02nzanrWNbf9cGiqdzd@public.gmane.org>
2011-09-08 12:55 ` Simon Glass
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=1315425260-2711-7-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).