summaryrefslogtreecommitdiff
path: root/tools/dtoc
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2021-02-03 06:00:56 -0700
committerSimon Glass <sjg@chromium.org>2021-03-22 19:23:27 +1300
commitdff51a524c873673fc19f31927ba25445784fb35 (patch)
tree9d92e056aee4a6e1aa69016cb114d2931f67bfe8 /tools/dtoc
parentacf5cb88b403540408e87d078d916269df371584 (diff)
downloadu-boot-dff51a524c873673fc19f31927ba25445784fb35.tar.gz
u-boot-dff51a524c873673fc19f31927ba25445784fb35.tar.bz2
u-boot-dff51a524c873673fc19f31927ba25445784fb35.zip
dtoc: Move test files into a test/ directory
It is confusing to have the test files in the same places as the implementation. Move them into a separate directory. Add a helper function for test_dtoc, to avoid repeating the same path. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'tools/dtoc')
-rw-r--r--tools/dtoc/test/dtoc_test.dts (renamed from tools/dtoc/dtoc_test.dts)0
-rw-r--r--tools/dtoc/test/dtoc_test_add_prop.dts (renamed from tools/dtoc/dtoc_test_add_prop.dts)0
-rw-r--r--tools/dtoc/test/dtoc_test_addr32.dts (renamed from tools/dtoc/dtoc_test_addr32.dts)0
-rw-r--r--tools/dtoc/test/dtoc_test_addr32_64.dts (renamed from tools/dtoc/dtoc_test_addr32_64.dts)0
-rw-r--r--tools/dtoc/test/dtoc_test_addr64.dts (renamed from tools/dtoc/dtoc_test_addr64.dts)0
-rw-r--r--tools/dtoc/test/dtoc_test_addr64_32.dts (renamed from tools/dtoc/dtoc_test_addr64_32.dts)0
-rw-r--r--tools/dtoc/test/dtoc_test_aliases.dts (renamed from tools/dtoc/dtoc_test_aliases.dts)0
-rw-r--r--tools/dtoc/test/dtoc_test_bad_reg.dts (renamed from tools/dtoc/dtoc_test_bad_reg.dts)0
-rw-r--r--tools/dtoc/test/dtoc_test_bad_reg2.dts (renamed from tools/dtoc/dtoc_test_bad_reg2.dts)0
-rw-r--r--tools/dtoc/test/dtoc_test_driver_alias.dts (renamed from tools/dtoc/dtoc_test_driver_alias.dts)0
-rw-r--r--tools/dtoc/test/dtoc_test_empty.dts (renamed from tools/dtoc/dtoc_test_empty.dts)0
-rw-r--r--tools/dtoc/test/dtoc_test_invalid_driver.dts (renamed from tools/dtoc/dtoc_test_invalid_driver.dts)0
-rw-r--r--tools/dtoc/test/dtoc_test_phandle.dts (renamed from tools/dtoc/dtoc_test_phandle.dts)0
-rw-r--r--tools/dtoc/test/dtoc_test_phandle_bad.dts (renamed from tools/dtoc/dtoc_test_phandle_bad.dts)0
-rw-r--r--tools/dtoc/test/dtoc_test_phandle_bad2.dts (renamed from tools/dtoc/dtoc_test_phandle_bad2.dts)0
-rw-r--r--tools/dtoc/test/dtoc_test_phandle_cd_gpios.dts (renamed from tools/dtoc/dtoc_test_phandle_cd_gpios.dts)0
-rw-r--r--tools/dtoc/test/dtoc_test_phandle_reorder.dts (renamed from tools/dtoc/dtoc_test_phandle_reorder.dts)0
-rw-r--r--tools/dtoc/test/dtoc_test_phandle_single.dts (renamed from tools/dtoc/dtoc_test_phandle_single.dts)0
-rw-r--r--tools/dtoc/test/dtoc_test_scan_drivers.cxx (renamed from tools/dtoc/dtoc_test_scan_drivers.cxx)0
-rw-r--r--tools/dtoc/test/dtoc_test_simple.dts (renamed from tools/dtoc/dtoc_test_simple.dts)0
-rwxr-xr-xtools/dtoc/test_dtoc.py2
-rwxr-xr-xtools/dtoc/test_fdt.py31
-rw-r--r--tools/dtoc/test_src_scan.py3
23 files changed, 24 insertions, 12 deletions
diff --git a/tools/dtoc/dtoc_test.dts b/tools/dtoc/test/dtoc_test.dts
index b2259483a6..b2259483a6 100644
--- a/tools/dtoc/dtoc_test.dts
+++ b/tools/dtoc/test/dtoc_test.dts
diff --git a/tools/dtoc/dtoc_test_add_prop.dts b/tools/dtoc/test/dtoc_test_add_prop.dts
index fa296e5552..fa296e5552 100644
--- a/tools/dtoc/dtoc_test_add_prop.dts
+++ b/tools/dtoc/test/dtoc_test_add_prop.dts
diff --git a/tools/dtoc/dtoc_test_addr32.dts b/tools/dtoc/test/dtoc_test_addr32.dts
index 239045497c..239045497c 100644
--- a/tools/dtoc/dtoc_test_addr32.dts
+++ b/tools/dtoc/test/dtoc_test_addr32.dts
diff --git a/tools/dtoc/dtoc_test_addr32_64.dts b/tools/dtoc/test/dtoc_test_addr32_64.dts
index 7599d5b0a5..7599d5b0a5 100644
--- a/tools/dtoc/dtoc_test_addr32_64.dts
+++ b/tools/dtoc/test/dtoc_test_addr32_64.dts
diff --git a/tools/dtoc/dtoc_test_addr64.dts b/tools/dtoc/test/dtoc_test_addr64.dts
index 263d251386..263d251386 100644
--- a/tools/dtoc/dtoc_test_addr64.dts
+++ b/tools/dtoc/test/dtoc_test_addr64.dts
diff --git a/tools/dtoc/dtoc_test_addr64_32.dts b/tools/dtoc/test/dtoc_test_addr64_32.dts
index 85e4f5fdae..85e4f5fdae 100644
--- a/tools/dtoc/dtoc_test_addr64_32.dts
+++ b/tools/dtoc/test/dtoc_test_addr64_32.dts
diff --git a/tools/dtoc/dtoc_test_aliases.dts b/tools/dtoc/test/dtoc_test_aliases.dts
index ae33716863..ae33716863 100644
--- a/tools/dtoc/dtoc_test_aliases.dts
+++ b/tools/dtoc/test/dtoc_test_aliases.dts
diff --git a/tools/dtoc/dtoc_test_bad_reg.dts b/tools/dtoc/test/dtoc_test_bad_reg.dts
index 1312acb619..1312acb619 100644
--- a/tools/dtoc/dtoc_test_bad_reg.dts
+++ b/tools/dtoc/test/dtoc_test_bad_reg.dts
diff --git a/tools/dtoc/dtoc_test_bad_reg2.dts b/tools/dtoc/test/dtoc_test_bad_reg2.dts
index 3e9efa43af..3e9efa43af 100644
--- a/tools/dtoc/dtoc_test_bad_reg2.dts
+++ b/tools/dtoc/test/dtoc_test_bad_reg2.dts
diff --git a/tools/dtoc/dtoc_test_driver_alias.dts b/tools/dtoc/test/dtoc_test_driver_alias.dts
index da7973b2e5..da7973b2e5 100644
--- a/tools/dtoc/dtoc_test_driver_alias.dts
+++ b/tools/dtoc/test/dtoc_test_driver_alias.dts
diff --git a/tools/dtoc/dtoc_test_empty.dts b/tools/dtoc/test/dtoc_test_empty.dts
index b2259483a6..b2259483a6 100644
--- a/tools/dtoc/dtoc_test_empty.dts
+++ b/tools/dtoc/test/dtoc_test_empty.dts
diff --git a/tools/dtoc/dtoc_test_invalid_driver.dts b/tools/dtoc/test/dtoc_test_invalid_driver.dts
index 914ac3e899..914ac3e899 100644
--- a/tools/dtoc/dtoc_test_invalid_driver.dts
+++ b/tools/dtoc/test/dtoc_test_invalid_driver.dts
diff --git a/tools/dtoc/dtoc_test_phandle.dts b/tools/dtoc/test/dtoc_test_phandle.dts
index a71acffc69..a71acffc69 100644
--- a/tools/dtoc/dtoc_test_phandle.dts
+++ b/tools/dtoc/test/dtoc_test_phandle.dts
diff --git a/tools/dtoc/dtoc_test_phandle_bad.dts b/tools/dtoc/test/dtoc_test_phandle_bad.dts
index a3ddc59585..a3ddc59585 100644
--- a/tools/dtoc/dtoc_test_phandle_bad.dts
+++ b/tools/dtoc/test/dtoc_test_phandle_bad.dts
diff --git a/tools/dtoc/dtoc_test_phandle_bad2.dts b/tools/dtoc/test/dtoc_test_phandle_bad2.dts
index fe25f565fb..fe25f565fb 100644
--- a/tools/dtoc/dtoc_test_phandle_bad2.dts
+++ b/tools/dtoc/test/dtoc_test_phandle_bad2.dts
diff --git a/tools/dtoc/dtoc_test_phandle_cd_gpios.dts b/tools/dtoc/test/dtoc_test_phandle_cd_gpios.dts
index 241743e73e..241743e73e 100644
--- a/tools/dtoc/dtoc_test_phandle_cd_gpios.dts
+++ b/tools/dtoc/test/dtoc_test_phandle_cd_gpios.dts
diff --git a/tools/dtoc/dtoc_test_phandle_reorder.dts b/tools/dtoc/test/dtoc_test_phandle_reorder.dts
index aa71d56f27..aa71d56f27 100644
--- a/tools/dtoc/dtoc_test_phandle_reorder.dts
+++ b/tools/dtoc/test/dtoc_test_phandle_reorder.dts
diff --git a/tools/dtoc/dtoc_test_phandle_single.dts b/tools/dtoc/test/dtoc_test_phandle_single.dts
index aacd0b15fa..aacd0b15fa 100644
--- a/tools/dtoc/dtoc_test_phandle_single.dts
+++ b/tools/dtoc/test/dtoc_test_phandle_single.dts
diff --git a/tools/dtoc/dtoc_test_scan_drivers.cxx b/tools/dtoc/test/dtoc_test_scan_drivers.cxx
index f448767670..f448767670 100644
--- a/tools/dtoc/dtoc_test_scan_drivers.cxx
+++ b/tools/dtoc/test/dtoc_test_scan_drivers.cxx
diff --git a/tools/dtoc/dtoc_test_simple.dts b/tools/dtoc/test/dtoc_test_simple.dts
index 1c87b89192..1c87b89192 100644
--- a/tools/dtoc/dtoc_test_simple.dts
+++ b/tools/dtoc/test/dtoc_test_simple.dts
diff --git a/tools/dtoc/test_dtoc.py b/tools/dtoc/test_dtoc.py
index 6865d949a0..523f0a923e 100755
--- a/tools/dtoc/test_dtoc.py
+++ b/tools/dtoc/test_dtoc.py
@@ -72,7 +72,7 @@ def get_dtb_file(dts_fname, capture_stderr=False):
Returns:
str: Filename of compiled file in output directory
"""
- return fdt_util.EnsureCompiled(os.path.join(OUR_PATH, dts_fname),
+ return fdt_util.EnsureCompiled(os.path.join(OUR_PATH, 'test', dts_fname),
capture_stderr=capture_stderr)
diff --git a/tools/dtoc/test_fdt.py b/tools/dtoc/test_fdt.py
index e8fbbd5d10..1c3a8a2ab1 100755
--- a/tools/dtoc/test_fdt.py
+++ b/tools/dtoc/test_fdt.py
@@ -48,6 +48,17 @@ def _GetPropertyValue(dtb, node, prop_name):
data = dtb.GetContents()[offset:offset + len(prop.value)]
return prop, [chr(x) for x in data]
+def find_dtb_file(dts_fname):
+ """Locate a test file in the test/ directory
+
+ Args:
+ dts_fname (str): Filename to find, e.g. 'dtoc_test_simple.dts]
+
+ Returns:
+ str: Path to the test filename
+ """
+ return os.path.join('tools/dtoc/test', dts_fname)
+
class TestFdt(unittest.TestCase):
"""Tests for the Fdt module
@@ -64,7 +75,7 @@ class TestFdt(unittest.TestCase):
tools.FinaliseOutputDir()
def setUp(self):
- self.dtb = fdt.FdtScan('tools/dtoc/dtoc_test_simple.dts')
+ self.dtb = fdt.FdtScan(find_dtb_file('dtoc_test_simple.dts'))
def testFdt(self):
"""Test that we can open an Fdt"""
@@ -141,7 +152,7 @@ class TestNode(unittest.TestCase):
tools.FinaliseOutputDir()
def setUp(self):
- self.dtb = fdt.FdtScan('tools/dtoc/dtoc_test_simple.dts')
+ self.dtb = fdt.FdtScan(find_dtb_file('dtoc_test_simple.dts'))
self.node = self.dtb.GetNode('/spl-test')
def testOffset(self):
@@ -203,7 +214,7 @@ class TestNode(unittest.TestCase):
def testLookupPhandle(self):
"""Test looking up a single phandle"""
- dtb = fdt.FdtScan('tools/dtoc/dtoc_test_phandle.dts')
+ dtb = fdt.FdtScan(find_dtb_file('dtoc_test_phandle.dts'))
node = dtb.GetNode('/phandle-source2')
prop = node.props['clocks']
target = dtb.GetNode('/phandle-target')
@@ -222,7 +233,7 @@ class TestProp(unittest.TestCase):
tools.FinaliseOutputDir()
def setUp(self):
- self.dtb = fdt.FdtScan('tools/dtoc/dtoc_test_simple.dts')
+ self.dtb = fdt.FdtScan(find_dtb_file('dtoc_test_simple.dts'))
self.node = self.dtb.GetNode('/spl-test')
self.fdt = self.dtb.GetFdtObj()
@@ -230,7 +241,7 @@ class TestProp(unittest.TestCase):
self.assertEqual(None, self.dtb.GetNode('missing'))
def testPhandle(self):
- dtb = fdt.FdtScan('tools/dtoc/dtoc_test_phandle.dts')
+ dtb = fdt.FdtScan(find_dtb_file('dtoc_test_phandle.dts'))
node = dtb.GetNode('/phandle-source2')
prop = node.props['clocks']
self.assertTrue(fdt32_to_cpu(prop.value) > 0)
@@ -488,7 +499,7 @@ class TestFdtUtil(unittest.TestCase):
tools.FinaliseOutputDir()
def setUp(self):
- self.dtb = fdt.FdtScan('tools/dtoc/dtoc_test_simple.dts')
+ self.dtb = fdt.FdtScan(find_dtb_file('dtoc_test_simple.dts'))
self.node = self.dtb.GetNode('/spl-test')
def testGetInt(self):
@@ -531,7 +542,7 @@ class TestFdtUtil(unittest.TestCase):
str(e.exception))
def testGetPhandleList(self):
- dtb = fdt.FdtScan('tools/dtoc/dtoc_test_phandle.dts')
+ dtb = fdt.FdtScan(find_dtb_file('dtoc_test_phandle.dts'))
node = dtb.GetNode('/phandle-source2')
self.assertEqual([1], fdt_util.GetPhandleList(node, 'clocks'))
node = dtb.GetNode('/phandle-source')
@@ -551,7 +562,7 @@ class TestFdtUtil(unittest.TestCase):
self.assertEqual(0, fdt_util.fdt_cells_to_cpu(val, 0))
self.assertEqual(2, fdt_util.fdt_cells_to_cpu(val, 1))
- dtb2 = fdt.FdtScan('tools/dtoc/dtoc_test_addr64.dts')
+ dtb2 = fdt.FdtScan(find_dtb_file('dtoc_test_addr64.dts'))
node1 = dtb2.GetNode('/test1')
val = node1.props['reg'].value
self.assertEqual(0x1234, fdt_util.fdt_cells_to_cpu(val, 2))
@@ -565,7 +576,7 @@ class TestFdtUtil(unittest.TestCase):
def testEnsureCompiled(self):
"""Test a degenerate case of this function (file already compiled)"""
- dtb = fdt_util.EnsureCompiled('tools/dtoc/dtoc_test_simple.dts')
+ dtb = fdt_util.EnsureCompiled(find_dtb_file('dtoc_test_simple.dts'))
self.assertEqual(dtb, fdt_util.EnsureCompiled(dtb))
def testEnsureCompiledTmpdir(self):
@@ -574,7 +585,7 @@ class TestFdtUtil(unittest.TestCase):
old_outdir = tools.outdir
tools.outdir= None
tmpdir = tempfile.mkdtemp(prefix='test_fdt.')
- dtb = fdt_util.EnsureCompiled('tools/dtoc/dtoc_test_simple.dts',
+ dtb = fdt_util.EnsureCompiled(find_dtb_file('dtoc_test_simple.dts'),
tmpdir)
self.assertEqual(tmpdir, os.path.dirname(dtb))
shutil.rmtree(tmpdir)
diff --git a/tools/dtoc/test_src_scan.py b/tools/dtoc/test_src_scan.py
index a0b0e097eb..a7eba3005e 100644
--- a/tools/dtoc/test_src_scan.py
+++ b/tools/dtoc/test_src_scan.py
@@ -59,7 +59,8 @@ class TestSrcScan(unittest.TestCase):
def test_additional(self):
"""Test with additional drivers to scan"""
scan = src_scan.Scanner(
- None, True, [None, '', 'tools/dtoc/dtoc_test_scan_drivers.cxx'])
+ None, True,
+ [None, '', 'tools/dtoc/test/dtoc_test_scan_drivers.cxx'])
scan.scan_drivers()
self.assertIn('sandbox_gpio_alias2', scan._driver_aliases)
self.assertEqual('sandbox_gpio',