u-boot.lists.denx.de archive mirror
 help / color / mirror / Atom feed
From: Simon Glass <sjg@chromium.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 10/19] fdt: dtoc: Add a full set of property tests
Date: Sun, 16 Apr 2017 20:22:24 -0600	[thread overview]
Message-ID: <20170417022233.28101-11-sjg@chromium.org> (raw)
In-Reply-To: <20170417022233.28101-1-sjg@chromium.org>

The tests don't currently cover all the different property types. Add a
new test which checks each property type in turn, to make sure each has
the correct type and value.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 tools/binman/fdt_test.py           | 46 ++++++++++++++++++++++++++++++++++++++
 tools/binman/test/45_prop_test.dts | 23 +++++++++++++++++++
 2 files changed, 69 insertions(+)
 create mode 100644 tools/binman/test/45_prop_test.dts

diff --git a/tools/binman/fdt_test.py b/tools/binman/fdt_test.py
index 12edeaba6c..65fb947386 100644
--- a/tools/binman/fdt_test.py
+++ b/tools/binman/fdt_test.py
@@ -11,6 +11,7 @@ import sys
 import tempfile
 import unittest
 
+import fdt
 from fdt_select import FdtScan
 import fdt_util
 import tools
@@ -37,6 +38,51 @@ class TestFdt(unittest.TestCase):
         dt = FdtScan(fname)
         self._DeleteProp(dt)
 
+    def testFdtNormalProp(self):
+        fname = self.GetCompiled('45_prop_test.dts')
+        dt = FdtScan(fname)
+        node = dt.GetNode('/binman/intel-me')
+        self.assertEquals('intel-me', node.name)
+        val = fdt_util.GetString(node, 'filename')
+        self.assertEquals(str, type(val))
+        self.assertEquals('me.bin', val)
+
+        prop = node.props['intval']
+        self.assertEquals(fdt.TYPE_INT, prop.type)
+        self.assertEquals(3, fdt_util.GetInt(node, 'intval'))
+
+        prop = node.props['intarray']
+        self.assertEquals(fdt.TYPE_INT, prop.type)
+        self.assertEquals(list, type(prop.value))
+        self.assertEquals(2, len(prop.value))
+        self.assertEquals([5, 6],
+                          [fdt_util.fdt32_to_cpu(val) for val in prop.value])
+
+        prop = node.props['byteval']
+        self.assertEquals(fdt.TYPE_BYTE, prop.type)
+        self.assertEquals(chr(8), prop.value)
+
+        prop = node.props['bytearray']
+        self.assertEquals(fdt.TYPE_BYTE, prop.type)
+        self.assertEquals(list, type(prop.value))
+        self.assertEquals(str, type(prop.value[0]))
+        self.assertEquals(3, len(prop.value))
+        self.assertEquals([chr(1), '#', '4'], prop.value)
+
+        prop = node.props['longbytearray']
+        self.assertEquals(fdt.TYPE_INT, prop.type)
+        self.assertEquals(0x090a0b0c, fdt_util.GetInt(node, 'longbytearray'))
+
+        prop = node.props['stringval']
+        self.assertEquals(fdt.TYPE_STRING, prop.type)
+        self.assertEquals('message2', fdt_util.GetString(node, 'stringval'))
+
+        prop = node.props['stringarray']
+        self.assertEquals(fdt.TYPE_STRING, prop.type)
+        self.assertEquals(list, type(prop.value))
+        self.assertEquals(3, len(prop.value))
+        self.assertEquals(['another', 'multi-word', 'message'], prop.value)
+
     def testFdtFallback(self):
         fname = self.GetCompiled('34_x86_ucode.dts')
         dt = FdtScan(fname, True)
diff --git a/tools/binman/test/45_prop_test.dts b/tools/binman/test/45_prop_test.dts
new file mode 100644
index 0000000000..d22e460d29
--- /dev/null
+++ b/tools/binman/test/45_prop_test.dts
@@ -0,0 +1,23 @@
+/dts-v1/;
+
+/ {
+	#address-cells = <1>;
+	#size-cells = <1>;
+
+	binman {
+		sort-by-pos;
+		end-at-4gb;
+		size = <16>;
+		intel-me {
+			filename = "me.bin";
+			pos-unset;
+			intval = <3>;
+			intarray = <5 6>;
+			byteval = [08];
+			bytearray = [01 23 34];
+			longbytearray = [09 0a 0b 0c];
+			stringval = "message2";
+			stringarray = "another", "multi-word", "message";
+		};
+	};
+};
-- 
2.12.2.762.g0e3151a226-goog

  parent reply	other threads:[~2017-04-17  2:22 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-17  2:22 [U-Boot] [PATCH 00/19] fdt: Move to the new upstream pylibfdt library Simon Glass
2017-04-17  2:22 ` [U-Boot] [PATCH 01/19] pci: Correct cast for sandbox Simon Glass
2017-05-02 11:27   ` sjg at google.com
2017-04-17  2:22 ` [U-Boot] [PATCH 02/19] fdt: Correct cast for sandbox in fdtdec_setup_memory_size() Simon Glass
2017-05-02 11:27   ` sjg at google.com
2017-04-17  2:22 ` [U-Boot] [PATCH 03/19] fdt: Use SPDX format for licenses in the libfdt headers Simon Glass
2017-04-17 13:05   ` Tom Rini
2017-04-17 13:13     ` Masahiro Yamada
2017-04-17 13:33       ` Tom Rini
2017-04-17 13:47         ` Simon Glass
2017-04-17 14:01           ` Tom Rini
2017-05-02 11:27             ` sjg at google.com
2017-04-17  2:22 ` [U-Boot] [PATCH 04/19] fdt: Move header files into lib/libfdt Simon Glass
2017-05-02 11:27   ` sjg at google.com
2017-04-17  2:22 ` [U-Boot] [PATCH 05/19] fdt: Allow swig options to be provided by Makefile Simon Glass
2017-05-02 11:27   ` sjg at google.com
2017-04-17  2:22 ` [U-Boot] [PATCH 06/19] fdt: Add all source files to the libfdt build Simon Glass
2017-05-02 11:27   ` sjg at google.com
2017-04-17  2:22 ` [U-Boot] [PATCH 07/19] fdt: Rename existing python libfdt module Simon Glass
2017-05-02 11:27   ` sjg at google.com
2017-04-17  2:22 ` [U-Boot] [PATCH 08/19] fdt: Build the new " Simon Glass
2017-05-02 11:27   ` sjg at google.com
2017-04-17  2:22 ` [U-Boot] [PATCH 09/19] fdt: Update fdt_test to use 'dt' instead of 'fdt' Simon Glass
2017-05-02 11:27   ` sjg at google.com
2017-04-17  2:22 ` Simon Glass [this message]
2017-05-02 11:27   ` [U-Boot] [PATCH 10/19] fdt: dtoc: Add a full set of property tests sjg at google.com
2017-04-17  2:22 ` [U-Boot] [PATCH 11/19] fdt: Support use of the new python libfdt library Simon Glass
2017-05-02 11:27   ` sjg at google.com
2017-04-17  2:22 ` [U-Boot] [PATCH 12/19] fdt: Makefile: Build python libfdt library if needed Simon Glass
2017-05-02 11:27   ` sjg at google.com
2017-04-17  2:22 ` [U-Boot] [PATCH 13/19] fdt: Stop building the old python libfdt module Simon Glass
2017-05-02 11:27   ` sjg at google.com
2017-04-17  2:22 ` [U-Boot] [PATCH 14/19] fdt: Drop use of the legacy libfdt python module Simon Glass
2017-05-02 11:27   ` sjg at google.com
2017-04-17  2:22 ` [U-Boot] [PATCH 15/19] fdt: Drop fdt_fallback library Simon Glass
2017-05-02 11:27   ` sjg at google.com
2017-04-17  2:22 ` [U-Boot] [PATCH 16/19] binman: Drop a special case related to fdt_fallback Simon Glass
2017-05-02 11:27   ` sjg at google.com
2017-04-17  2:22 ` [U-Boot] [PATCH 17/19] fdt: Merge fdt_normal with its base class Simon Glass
2017-05-02 11:27   ` sjg at google.com
2017-04-17  2:22 ` [U-Boot] [PATCH 18/19] binman: Rename fdt variable to dtb Simon Glass
2017-05-02 11:27   ` sjg at google.com
2017-04-17  2:22 ` [U-Boot] [PATCH 19/19] fdt: Drop fdt_select.py Simon Glass
2017-05-02 11:27   ` sjg at google.com
2017-04-18 16:25 ` [U-Boot] [PATCH 00/19] fdt: Move to the new upstream pylibfdt library Tom Rini
2017-04-18 16:27   ` Simon Glass
2017-04-18 16:33     ` Tom Rini
2017-04-18 16:48       ` Simon Glass
2017-04-19 14:27         ` Tom Rini
2017-05-02 11:31           ` 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=20170417022233.28101-11-sjg@chromium.org \
    --to=sjg@chromium.org \
    --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;
as well as URLs for NNTP newsgroup(s).