mirror of
https://gitlab.com/buildroot.org/buildroot.git
synced 2026-09-10 08:14:09 -09:00
support/testing: add new test for dtc
Add a test that runs the dtc commandline tools. To test devicetree
compilation, we use an example devicetree from the dtc project. The
example source is GPL-2.0+ licensed.
Signed-off-by: Brandon Maier <brandon.maier@gmail.com>
Signed-off-by: Arnout Vandecappelle <arnout@mind.be>
(cherry picked from commit 9b69034160)
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
This commit is contained in:
39
support/testing/tests/package/test_dtc.py
Normal file
39
support/testing/tests/package/test_dtc.py
Normal file
@@ -0,0 +1,39 @@
|
||||
import os
|
||||
|
||||
import infra.basetest
|
||||
|
||||
|
||||
class TestDtc(infra.basetest.BRTest):
|
||||
config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \
|
||||
"""
|
||||
BR2_PACKAGE_DTC=y
|
||||
BR2_PACKAGE_DTC_PROGRAMS=y
|
||||
BR2_ROOTFS_OVERLAY="{}"
|
||||
# BR2_TARGET_ROOTFS_TAR is not set
|
||||
BR2_TARGET_ROOTFS_CPIO=y
|
||||
""".format(
|
||||
# overlay to add a bats test suite
|
||||
infra.filepath("tests/package/test_dtc/rootfs-overlay"))
|
||||
|
||||
def test_run(self):
|
||||
cpio_file = os.path.join(self.builddir, "images", "rootfs.cpio")
|
||||
self.emulator.boot(arch="armv7",
|
||||
kernel="builtin",
|
||||
options=["-initrd", cpio_file])
|
||||
|
||||
self.emulator.login()
|
||||
|
||||
# Test 'dtc'
|
||||
self.assertRunOk("dtc -I dts -O dtb -o /tmp/test_tree1.dtb /test_tree1.dts")
|
||||
|
||||
# Test 'fdtdump'
|
||||
self.assertRunOk("fdtdump /tmp/test_tree1.dtb")
|
||||
|
||||
# Test 'fdtget'
|
||||
out, exit_code = self.emulator.run("fdtget -t s /tmp/test_tree1.dtb / compatible")
|
||||
self.assertEqual(out[0].strip(), "test_tree1")
|
||||
|
||||
# Test 'fdtput'
|
||||
self.assertRunOk("fdtput -t s /tmp/test_tree1.dtb / compatible 'test set compatible'")
|
||||
out, exit_code = self.emulator.run("fdtget -t s /tmp/test_tree1.dtb / compatible")
|
||||
self.assertEqual(out[0].strip(), "test set compatible")
|
||||
@@ -0,0 +1,48 @@
|
||||
/* From https://git.kernel.org/pub/scm/utils/dtc/dtc.git/tree/tests/test_tree1.dts?id=99031e3a4a6e479466ae795790b44727434ca27d */
|
||||
|
||||
/dts-v1/;
|
||||
|
||||
/memreserve/ 0xdeadbeef00000000 0x100000;
|
||||
/memreserve/ 123456789 010000;
|
||||
|
||||
/ {
|
||||
compatible = "test_tree1";
|
||||
prop-int = <0xdeadbeef>;
|
||||
prop-int64 = /bits/ 64 <0xdeadbeef01abcdef>;
|
||||
prop-str = "hello world";
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
|
||||
subnode@1 {
|
||||
compatible = "subnode1";
|
||||
reg = <1>;
|
||||
prop-int = [deadbeef];
|
||||
|
||||
subsubnode {
|
||||
compatible = "subsubnode1", "subsubnode";
|
||||
placeholder = "this is a placeholder string", "string2";
|
||||
prop-int = <0xdeadbeef>;
|
||||
};
|
||||
|
||||
ss1 {
|
||||
};
|
||||
};
|
||||
|
||||
subnode@2 {
|
||||
reg = <2>;
|
||||
linux,phandle = <0x2000>;
|
||||
prop-int = <123456789>;
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
|
||||
ssn0: subsubnode@0 {
|
||||
reg = <0>;
|
||||
phandle = <0x2001>;
|
||||
compatible = "subsubnode2", "subsubnode";
|
||||
prop-int = <0726746425>;
|
||||
};
|
||||
|
||||
ss2 {
|
||||
};
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user