summaryrefslogtreecommitdiff
path: root/tools/dtoc/test_dtoc.py
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2021-04-26 23:19:48 +0300
committerSimon Glass <sjg@chromium.org>2021-04-29 13:23:37 +0300
commit170732523bad74cd3a19c3993ba06c789c843ccf (patch)
tree401de0544216ee9f24ab84eff43e07b192d13efe /tools/dtoc/test_dtoc.py
parent0fe44dc676855ae195e6532e0bed56f53bd3346c (diff)
downloadu-boot-170732523bad74cd3a19c3993ba06c789c843ccf.tar.xz
dtoc: Correct dtoc output when testing
At present each invocation of run_steps() updates OUTPUT_FILES_COMMON, since it does not make a copy of the dict. This is fine for a single invocation, but for tests, run_steps() is invoked many times. As a result it may include unwanted items from the previous run, if it happens that a test runs twice on the same CPU. The problem has not been noticied previously, as there are few enough tests and enough CPUs that is is rare for the 'wrong' combination of tests to run together. Fix this by making a copy of the dict, before updating it. Update the tests to suit, taking account of the files that are no-longer generated. With this fix, we no-longer generate files which are not needed for a particular state of OF_PLATDATA_INST, so the check_instantiate() function is not needed anymore. It has become dead code and so fails the code-coverage test (dtoc -T). Remove it. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'tools/dtoc/test_dtoc.py')
-rwxr-xr-xtools/dtoc/test_dtoc.py51
1 files changed, 21 insertions, 30 deletions
diff --git a/tools/dtoc/test_dtoc.py b/tools/dtoc/test_dtoc.py
index a05e3d9ed6..0b2805feed 100755
--- a/tools/dtoc/test_dtoc.py
+++ b/tools/dtoc/test_dtoc.py
@@ -74,10 +74,6 @@ UCLASS_HEADER_COMMON = '''/*
*/
'''
-UCLASS_HEADER = UCLASS_HEADER_COMMON + '''
-/* This file is not used: --instantiate was not enabled */
-'''
-
# Scanner saved from a previous run of the tests (to speed things up)
saved_scan = None
@@ -412,7 +408,6 @@ U_BOOT_DRVINFO(spl_test3) = {
};
'''
- uclass_text = UCLASS_HEADER
uclass_text_inst = '''
#include <common.h>
@@ -512,15 +507,6 @@ DM_UCLASS_INST(testfdt) = {
};
'''
- device_text = '''/*
- * DO NOT MODIFY
- *
- * Declares the DM_DEVICE_INST() records.
- * This was generated by dtoc from a .dtb (device tree binary) file.
- */
-
-/* This file is not used: --instantiate was not enabled */
-'''
device_text_inst = '''/*
* DO NOT MODIFY
*
@@ -833,8 +819,7 @@ DM_DEVICE_INST(test0) = {
self.run_test(['all'], dtb_file, output)
data = tools.ReadFile(output, binary=False)
self._check_strings(
- self.decl_text + self.device_text + self.platdata_text +
- self.struct_text + self.uclass_text, data)
+ self.decl_text + self.platdata_text + self.struct_text, data)
def test_driver_alias(self):
"""Test output from a device tree file with a driver alias"""
@@ -1537,8 +1522,7 @@ U_BOOT_DRVINFO(spl_test2) = {
self.run_test(['all'], dtb_file, output)
data = tools.ReadFile(output, binary=False)
self._check_strings(
- self.decl_text + self.device_text + self.platdata_text +
- self.struct_text + self.uclass_text, data)
+ self.decl_text + self.platdata_text + self.struct_text, data)
def test_no_command(self):
"""Test running dtoc without a command"""
@@ -1566,8 +1550,7 @@ U_BOOT_DRVINFO(spl_test2) = {
self.assertIn("Must specify either output or output_dirs, not both",
str(exc.exception))
- def test_output_dirs(self):
- """Test outputting files to a directory"""
+ def check_output_dirs(self, instantiate):
# Remove the directory so that files from other tests are not there
tools._RemoveOutputDir()
tools.PrepareOutputDir(None)
@@ -1579,14 +1562,30 @@ U_BOOT_DRVINFO(spl_test2) = {
self.assertEqual(2, len(fnames))
dtb_platdata.run_steps(
- ['all'], dtb_file, False, None, [outdir], None, False,
+ ['all'], dtb_file, False, None, [outdir], None, instantiate,
warning_disabled=True, scan=copy_scan())
fnames = glob.glob(outdir + '/*')
- self.assertEqual(7, len(fnames))
+ return fnames
+
+ def test_output_dirs(self):
+ """Test outputting files to a directory"""
+ fnames = self.check_output_dirs(False)
+ self.assertEqual(5, len(fnames))
leafs = set(os.path.basename(fname) for fname in fnames)
self.assertEqual(
{'dt-structs-gen.h', 'source.dts', 'dt-plat.c', 'source.dtb',
+ 'dt-decl.h'},
+ leafs)
+
+ def test_output_dirs_inst(self):
+ """Test outputting files to a directory with instantiation"""
+ fnames = self.check_output_dirs(True)
+ self.assertEqual(6, len(fnames))
+
+ leafs = set(os.path.basename(fname) for fname in fnames)
+ self.assertEqual(
+ {'dt-structs-gen.h', 'source.dts', 'source.dtb',
'dt-uclass.c', 'dt-decl.h', 'dt-device.c'},
leafs)
@@ -1785,14 +1784,6 @@ U_BOOT_DRVINFO(spl_test2) = {
self._check_strings(self.decl_text_inst, data)
- self.run_test(['platdata'], dtb_file, output, True)
- with open(output) as infile:
- data = infile.read()
-
- self._check_strings(C_HEADER_PRE + '''
-/* This file is not used: --instantiate was enabled */
-''', data)
-
self.run_test(['uclass'], dtb_file, output, True)
with open(output) as infile:
data = infile.read()