From 5ea9dccf02eb26d146dbc1fdb3106135612820ae Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 8 Nov 2020 20:36:17 -0700 Subject: fdt: Use an Enum for the data type Use an Enum instead of the current ad-hoc constants, so that there is a data type associated with each 'type' value. Signed-off-by: Simon Glass --- tools/dtoc/test_dtoc.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'tools/dtoc/test_dtoc.py') diff --git a/tools/dtoc/test_dtoc.py b/tools/dtoc/test_dtoc.py index a5836e04b7a..6dd8a5ca473 100755 --- a/tools/dtoc/test_dtoc.py +++ b/tools/dtoc/test_dtoc.py @@ -134,13 +134,13 @@ class TestDtoc(unittest.TestCase): def test_get_value(self): """Test operation of get_value() function""" self.assertEqual('0x45', - get_value(fdt.TYPE_INT, struct.pack('>I', 0x45))) + get_value(fdt.Type.INT, struct.pack('>I', 0x45))) self.assertEqual('0x45', - get_value(fdt.TYPE_BYTE, struct.pack('I', 0x45))) - self.assertEqual('"test"', get_value(fdt.TYPE_STRING, 'test')) - self.assertEqual('true', get_value(fdt.TYPE_BOOL, None)) + get_value(fdt.Type.BYTE, struct.pack('>I', 0x45))) + self.assertEqual('"test"', get_value(fdt.Type.STRING, 'test')) + self.assertEqual('true', get_value(fdt.Type.BOOL, None)) def test_get_compat_name(self): """Test operation of get_compat_name() function""" -- cgit v1.2.3 From caa4daa2ae3dc0a3e516addea5772c9af76abcb0 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 3 Dec 2020 16:55:18 -0700 Subject: dm: treewide: Rename 'platdata' variables to just 'plat' We use 'priv' for private data but often use 'platdata' for platform data. We can't really use 'pdata' since that is ambiguous (it could mean private or platform data). Rename some of the latter variables to end with 'plat' for consistency. Signed-off-by: Simon Glass --- tools/dtoc/test_dtoc.py | 66 ++++++++++++++++++++++++------------------------- 1 file changed, 33 insertions(+), 33 deletions(-) (limited to 'tools/dtoc/test_dtoc.py') diff --git a/tools/dtoc/test_dtoc.py b/tools/dtoc/test_dtoc.py index 6dd8a5ca473..6992a66c884 100755 --- a/tools/dtoc/test_dtoc.py +++ b/tools/dtoc/test_dtoc.py @@ -217,7 +217,7 @@ static struct dtd_sandbox_i2c_test dtv_i2c_at_0 = { }; U_BOOT_DEVICE(i2c_at_0) = { \t.name\t\t= "sandbox_i2c_test", -\t.platdata\t= &dtv_i2c_at_0, +\t.plat\t= &dtv_i2c_at_0, \t.platdata_size\t= sizeof(dtv_i2c_at_0), \t.parent_idx\t= -1, }; @@ -229,7 +229,7 @@ static struct dtd_sandbox_pmic_test dtv_pmic_at_9 = { }; U_BOOT_DEVICE(pmic_at_9) = { \t.name\t\t= "sandbox_pmic_test", -\t.platdata\t= &dtv_pmic_at_9, +\t.plat\t= &dtv_pmic_at_9, \t.platdata_size\t= sizeof(dtv_pmic_at_9), \t.parent_idx\t= 0, }; @@ -249,7 +249,7 @@ static struct dtd_sandbox_spl_test dtv_spl_test = { }; U_BOOT_DEVICE(spl_test) = { \t.name\t\t= "sandbox_spl_test", -\t.platdata\t= &dtv_spl_test, +\t.plat\t= &dtv_spl_test, \t.platdata_size\t= sizeof(dtv_spl_test), \t.parent_idx\t= -1, }; @@ -268,7 +268,7 @@ static struct dtd_sandbox_spl_test dtv_spl_test2 = { }; U_BOOT_DEVICE(spl_test2) = { \t.name\t\t= "sandbox_spl_test", -\t.platdata\t= &dtv_spl_test2, +\t.plat\t= &dtv_spl_test2, \t.platdata_size\t= sizeof(dtv_spl_test2), \t.parent_idx\t= -1, }; @@ -281,7 +281,7 @@ static struct dtd_sandbox_spl_test dtv_spl_test3 = { }; U_BOOT_DEVICE(spl_test3) = { \t.name\t\t= "sandbox_spl_test", -\t.platdata\t= &dtv_spl_test3, +\t.plat\t= &dtv_spl_test3, \t.platdata_size\t= sizeof(dtv_spl_test3), \t.parent_idx\t= -1, }; @@ -291,7 +291,7 @@ static struct dtd_sandbox_spl_test_2 dtv_spl_test4 = { }; U_BOOT_DEVICE(spl_test4) = { \t.name\t\t= "sandbox_spl_test_2", -\t.platdata\t= &dtv_spl_test4, +\t.plat\t= &dtv_spl_test4, \t.platdata_size\t= sizeof(dtv_spl_test4), \t.parent_idx\t= -1, }; @@ -325,7 +325,7 @@ static struct dtd_sandbox_gpio dtv_gpios_at_0 = { }; U_BOOT_DEVICE(gpios_at_0) = { \t.name\t\t= "sandbox_gpio", -\t.platdata\t= &dtv_gpios_at_0, +\t.plat\t= &dtv_gpios_at_0, \t.platdata_size\t= sizeof(dtv_gpios_at_0), \t.parent_idx\t= -1, }; @@ -357,7 +357,7 @@ static struct dtd_invalid dtv_spl_test = { }; U_BOOT_DEVICE(spl_test) = { \t.name\t\t= "invalid", -\t.platdata\t= &dtv_spl_test, +\t.plat\t= &dtv_spl_test, \t.platdata_size\t= sizeof(dtv_spl_test), \t.parent_idx\t= -1, }; @@ -392,7 +392,7 @@ static struct dtd_target dtv_phandle2_target = { }; U_BOOT_DEVICE(phandle2_target) = { \t.name\t\t= "target", -\t.platdata\t= &dtv_phandle2_target, +\t.plat\t= &dtv_phandle2_target, \t.platdata_size\t= sizeof(dtv_phandle2_target), \t.parent_idx\t= -1, }; @@ -403,7 +403,7 @@ static struct dtd_target dtv_phandle3_target = { }; U_BOOT_DEVICE(phandle3_target) = { \t.name\t\t= "target", -\t.platdata\t= &dtv_phandle3_target, +\t.plat\t= &dtv_phandle3_target, \t.platdata_size\t= sizeof(dtv_phandle3_target), \t.parent_idx\t= -1, }; @@ -414,7 +414,7 @@ static struct dtd_target dtv_phandle_target = { }; U_BOOT_DEVICE(phandle_target) = { \t.name\t\t= "target", -\t.platdata\t= &dtv_phandle_target, +\t.plat\t= &dtv_phandle_target, \t.platdata_size\t= sizeof(dtv_phandle_target), \t.parent_idx\t= -1, }; @@ -429,7 +429,7 @@ static struct dtd_source dtv_phandle_source = { }; U_BOOT_DEVICE(phandle_source) = { \t.name\t\t= "source", -\t.platdata\t= &dtv_phandle_source, +\t.plat\t= &dtv_phandle_source, \t.platdata_size\t= sizeof(dtv_phandle_source), \t.parent_idx\t= -1, }; @@ -441,7 +441,7 @@ static struct dtd_source dtv_phandle_source2 = { }; U_BOOT_DEVICE(phandle_source2) = { \t.name\t\t= "source", -\t.platdata\t= &dtv_phandle_source2, +\t.plat\t= &dtv_phandle_source2, \t.platdata_size\t= sizeof(dtv_phandle_source2), \t.parent_idx\t= -1, }; @@ -479,7 +479,7 @@ static struct dtd_target dtv_phandle_target = { }; U_BOOT_DEVICE(phandle_target) = { \t.name\t\t= "target", -\t.platdata\t= &dtv_phandle_target, +\t.plat\t= &dtv_phandle_target, \t.platdata_size\t= sizeof(dtv_phandle_target), \t.parent_idx\t= -1, }; @@ -491,7 +491,7 @@ static struct dtd_source dtv_phandle_source2 = { }; U_BOOT_DEVICE(phandle_source2) = { \t.name\t\t= "source", -\t.platdata\t= &dtv_phandle_source2, +\t.plat\t= &dtv_phandle_source2, \t.platdata_size\t= sizeof(dtv_phandle_source2), \t.parent_idx\t= -1, }; @@ -514,7 +514,7 @@ static struct dtd_target dtv_phandle2_target = { }; U_BOOT_DEVICE(phandle2_target) = { \t.name\t\t= "target", -\t.platdata\t= &dtv_phandle2_target, +\t.plat\t= &dtv_phandle2_target, \t.platdata_size\t= sizeof(dtv_phandle2_target), \t.parent_idx\t= -1, }; @@ -525,7 +525,7 @@ static struct dtd_target dtv_phandle3_target = { }; U_BOOT_DEVICE(phandle3_target) = { \t.name\t\t= "target", -\t.platdata\t= &dtv_phandle3_target, +\t.plat\t= &dtv_phandle3_target, \t.platdata_size\t= sizeof(dtv_phandle3_target), \t.parent_idx\t= -1, }; @@ -536,7 +536,7 @@ static struct dtd_target dtv_phandle_target = { }; U_BOOT_DEVICE(phandle_target) = { \t.name\t\t= "target", -\t.platdata\t= &dtv_phandle_target, +\t.plat\t= &dtv_phandle_target, \t.platdata_size\t= sizeof(dtv_phandle_target), \t.parent_idx\t= -1, }; @@ -551,7 +551,7 @@ static struct dtd_source dtv_phandle_source = { }; U_BOOT_DEVICE(phandle_source) = { \t.name\t\t= "source", -\t.platdata\t= &dtv_phandle_source, +\t.plat\t= &dtv_phandle_source, \t.platdata_size\t= sizeof(dtv_phandle_source), \t.parent_idx\t= -1, }; @@ -563,7 +563,7 @@ static struct dtd_source dtv_phandle_source2 = { }; U_BOOT_DEVICE(phandle_source2) = { \t.name\t\t= "source", -\t.platdata\t= &dtv_phandle_source2, +\t.plat\t= &dtv_phandle_source2, \t.platdata_size\t= sizeof(dtv_phandle_source2), \t.parent_idx\t= -1, }; @@ -621,7 +621,7 @@ static struct dtd_test1 dtv_test1 = { }; U_BOOT_DEVICE(test1) = { \t.name\t\t= "test1", -\t.platdata\t= &dtv_test1, +\t.plat\t= &dtv_test1, \t.platdata_size\t= sizeof(dtv_test1), \t.parent_idx\t= -1, }; @@ -632,7 +632,7 @@ static struct dtd_test2 dtv_test2 = { }; U_BOOT_DEVICE(test2) = { \t.name\t\t= "test2", -\t.platdata\t= &dtv_test2, +\t.plat\t= &dtv_test2, \t.platdata_size\t= sizeof(dtv_test2), \t.parent_idx\t= -1, }; @@ -643,7 +643,7 @@ static struct dtd_test3 dtv_test3 = { }; U_BOOT_DEVICE(test3) = { \t.name\t\t= "test3", -\t.platdata\t= &dtv_test3, +\t.plat\t= &dtv_test3, \t.platdata_size\t= sizeof(dtv_test3), \t.parent_idx\t= -1, }; @@ -676,7 +676,7 @@ static struct dtd_test1 dtv_test1 = { }; U_BOOT_DEVICE(test1) = { \t.name\t\t= "test1", -\t.platdata\t= &dtv_test1, +\t.plat\t= &dtv_test1, \t.platdata_size\t= sizeof(dtv_test1), \t.parent_idx\t= -1, }; @@ -687,7 +687,7 @@ static struct dtd_test2 dtv_test2 = { }; U_BOOT_DEVICE(test2) = { \t.name\t\t= "test2", -\t.platdata\t= &dtv_test2, +\t.plat\t= &dtv_test2, \t.platdata_size\t= sizeof(dtv_test2), \t.parent_idx\t= -1, }; @@ -723,7 +723,7 @@ static struct dtd_test1 dtv_test1 = { }; U_BOOT_DEVICE(test1) = { \t.name\t\t= "test1", -\t.platdata\t= &dtv_test1, +\t.plat\t= &dtv_test1, \t.platdata_size\t= sizeof(dtv_test1), \t.parent_idx\t= -1, }; @@ -734,7 +734,7 @@ static struct dtd_test2 dtv_test2 = { }; U_BOOT_DEVICE(test2) = { \t.name\t\t= "test2", -\t.platdata\t= &dtv_test2, +\t.plat\t= &dtv_test2, \t.platdata_size\t= sizeof(dtv_test2), \t.parent_idx\t= -1, }; @@ -745,7 +745,7 @@ static struct dtd_test3 dtv_test3 = { }; U_BOOT_DEVICE(test3) = { \t.name\t\t= "test3", -\t.platdata\t= &dtv_test3, +\t.plat\t= &dtv_test3, \t.platdata_size\t= sizeof(dtv_test3), \t.parent_idx\t= -1, }; @@ -781,7 +781,7 @@ static struct dtd_test1 dtv_test1 = { }; U_BOOT_DEVICE(test1) = { \t.name\t\t= "test1", -\t.platdata\t= &dtv_test1, +\t.plat\t= &dtv_test1, \t.platdata_size\t= sizeof(dtv_test1), \t.parent_idx\t= -1, }; @@ -792,7 +792,7 @@ static struct dtd_test2 dtv_test2 = { }; U_BOOT_DEVICE(test2) = { \t.name\t\t= "test2", -\t.platdata\t= &dtv_test2, +\t.plat\t= &dtv_test2, \t.platdata_size\t= sizeof(dtv_test2), \t.parent_idx\t= -1, }; @@ -803,7 +803,7 @@ static struct dtd_test3 dtv_test3 = { }; U_BOOT_DEVICE(test3) = { \t.name\t\t= "test3", -\t.platdata\t= &dtv_test3, +\t.plat\t= &dtv_test3, \t.platdata_size\t= sizeof(dtv_test3), \t.parent_idx\t= -1, }; @@ -854,7 +854,7 @@ static struct dtd_sandbox_spl_test dtv_spl_test = { }; U_BOOT_DEVICE(spl_test) = { \t.name\t\t= "sandbox_spl_test", -\t.platdata\t= &dtv_spl_test, +\t.plat\t= &dtv_spl_test, \t.platdata_size\t= sizeof(dtv_spl_test), \t.parent_idx\t= -1, }; @@ -865,7 +865,7 @@ static struct dtd_sandbox_spl_test dtv_spl_test2 = { }; U_BOOT_DEVICE(spl_test2) = { \t.name\t\t= "sandbox_spl_test", -\t.platdata\t= &dtv_spl_test2, +\t.plat\t= &dtv_spl_test2, \t.platdata_size\t= sizeof(dtv_spl_test2), \t.parent_idx\t= -1, }; -- cgit v1.2.3 From 4f50086ad6d69c355a07389fb436c64c92ec614a Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 3 Dec 2020 16:55:19 -0700 Subject: dm: Rename 'platdata_size' to 'plat_size' Rename this to be consistent with the change from 'platdata'. Signed-off-by: Simon Glass --- tools/dtoc/test_dtoc.py | 66 ++++++++++++++++++++++++------------------------- 1 file changed, 33 insertions(+), 33 deletions(-) (limited to 'tools/dtoc/test_dtoc.py') diff --git a/tools/dtoc/test_dtoc.py b/tools/dtoc/test_dtoc.py index 6992a66c884..4913d950218 100755 --- a/tools/dtoc/test_dtoc.py +++ b/tools/dtoc/test_dtoc.py @@ -218,7 +218,7 @@ static struct dtd_sandbox_i2c_test dtv_i2c_at_0 = { U_BOOT_DEVICE(i2c_at_0) = { \t.name\t\t= "sandbox_i2c_test", \t.plat\t= &dtv_i2c_at_0, -\t.platdata_size\t= sizeof(dtv_i2c_at_0), +\t.plat_size\t= sizeof(dtv_i2c_at_0), \t.parent_idx\t= -1, }; @@ -230,7 +230,7 @@ static struct dtd_sandbox_pmic_test dtv_pmic_at_9 = { U_BOOT_DEVICE(pmic_at_9) = { \t.name\t\t= "sandbox_pmic_test", \t.plat\t= &dtv_pmic_at_9, -\t.platdata_size\t= sizeof(dtv_pmic_at_9), +\t.plat_size\t= sizeof(dtv_pmic_at_9), \t.parent_idx\t= 0, }; @@ -250,7 +250,7 @@ static struct dtd_sandbox_spl_test dtv_spl_test = { U_BOOT_DEVICE(spl_test) = { \t.name\t\t= "sandbox_spl_test", \t.plat\t= &dtv_spl_test, -\t.platdata_size\t= sizeof(dtv_spl_test), +\t.plat_size\t= sizeof(dtv_spl_test), \t.parent_idx\t= -1, }; @@ -269,7 +269,7 @@ static struct dtd_sandbox_spl_test dtv_spl_test2 = { U_BOOT_DEVICE(spl_test2) = { \t.name\t\t= "sandbox_spl_test", \t.plat\t= &dtv_spl_test2, -\t.platdata_size\t= sizeof(dtv_spl_test2), +\t.plat_size\t= sizeof(dtv_spl_test2), \t.parent_idx\t= -1, }; @@ -282,7 +282,7 @@ static struct dtd_sandbox_spl_test dtv_spl_test3 = { U_BOOT_DEVICE(spl_test3) = { \t.name\t\t= "sandbox_spl_test", \t.plat\t= &dtv_spl_test3, -\t.platdata_size\t= sizeof(dtv_spl_test3), +\t.plat_size\t= sizeof(dtv_spl_test3), \t.parent_idx\t= -1, }; @@ -292,7 +292,7 @@ static struct dtd_sandbox_spl_test_2 dtv_spl_test4 = { U_BOOT_DEVICE(spl_test4) = { \t.name\t\t= "sandbox_spl_test_2", \t.plat\t= &dtv_spl_test4, -\t.platdata_size\t= sizeof(dtv_spl_test4), +\t.plat_size\t= sizeof(dtv_spl_test4), \t.parent_idx\t= -1, }; @@ -326,7 +326,7 @@ static struct dtd_sandbox_gpio dtv_gpios_at_0 = { U_BOOT_DEVICE(gpios_at_0) = { \t.name\t\t= "sandbox_gpio", \t.plat\t= &dtv_gpios_at_0, -\t.platdata_size\t= sizeof(dtv_gpios_at_0), +\t.plat_size\t= sizeof(dtv_gpios_at_0), \t.parent_idx\t= -1, }; @@ -358,7 +358,7 @@ static struct dtd_invalid dtv_spl_test = { U_BOOT_DEVICE(spl_test) = { \t.name\t\t= "invalid", \t.plat\t= &dtv_spl_test, -\t.platdata_size\t= sizeof(dtv_spl_test), +\t.plat_size\t= sizeof(dtv_spl_test), \t.parent_idx\t= -1, }; @@ -393,7 +393,7 @@ static struct dtd_target dtv_phandle2_target = { U_BOOT_DEVICE(phandle2_target) = { \t.name\t\t= "target", \t.plat\t= &dtv_phandle2_target, -\t.platdata_size\t= sizeof(dtv_phandle2_target), +\t.plat_size\t= sizeof(dtv_phandle2_target), \t.parent_idx\t= -1, }; @@ -404,7 +404,7 @@ static struct dtd_target dtv_phandle3_target = { U_BOOT_DEVICE(phandle3_target) = { \t.name\t\t= "target", \t.plat\t= &dtv_phandle3_target, -\t.platdata_size\t= sizeof(dtv_phandle3_target), +\t.plat_size\t= sizeof(dtv_phandle3_target), \t.parent_idx\t= -1, }; @@ -415,7 +415,7 @@ static struct dtd_target dtv_phandle_target = { U_BOOT_DEVICE(phandle_target) = { \t.name\t\t= "target", \t.plat\t= &dtv_phandle_target, -\t.platdata_size\t= sizeof(dtv_phandle_target), +\t.plat_size\t= sizeof(dtv_phandle_target), \t.parent_idx\t= -1, }; @@ -430,7 +430,7 @@ static struct dtd_source dtv_phandle_source = { U_BOOT_DEVICE(phandle_source) = { \t.name\t\t= "source", \t.plat\t= &dtv_phandle_source, -\t.platdata_size\t= sizeof(dtv_phandle_source), +\t.plat_size\t= sizeof(dtv_phandle_source), \t.parent_idx\t= -1, }; @@ -442,7 +442,7 @@ static struct dtd_source dtv_phandle_source2 = { U_BOOT_DEVICE(phandle_source2) = { \t.name\t\t= "source", \t.plat\t= &dtv_phandle_source2, -\t.platdata_size\t= sizeof(dtv_phandle_source2), +\t.plat_size\t= sizeof(dtv_phandle_source2), \t.parent_idx\t= -1, }; @@ -480,7 +480,7 @@ static struct dtd_target dtv_phandle_target = { U_BOOT_DEVICE(phandle_target) = { \t.name\t\t= "target", \t.plat\t= &dtv_phandle_target, -\t.platdata_size\t= sizeof(dtv_phandle_target), +\t.plat_size\t= sizeof(dtv_phandle_target), \t.parent_idx\t= -1, }; @@ -492,7 +492,7 @@ static struct dtd_source dtv_phandle_source2 = { U_BOOT_DEVICE(phandle_source2) = { \t.name\t\t= "source", \t.plat\t= &dtv_phandle_source2, -\t.platdata_size\t= sizeof(dtv_phandle_source2), +\t.plat_size\t= sizeof(dtv_phandle_source2), \t.parent_idx\t= -1, }; @@ -515,7 +515,7 @@ static struct dtd_target dtv_phandle2_target = { U_BOOT_DEVICE(phandle2_target) = { \t.name\t\t= "target", \t.plat\t= &dtv_phandle2_target, -\t.platdata_size\t= sizeof(dtv_phandle2_target), +\t.plat_size\t= sizeof(dtv_phandle2_target), \t.parent_idx\t= -1, }; @@ -526,7 +526,7 @@ static struct dtd_target dtv_phandle3_target = { U_BOOT_DEVICE(phandle3_target) = { \t.name\t\t= "target", \t.plat\t= &dtv_phandle3_target, -\t.platdata_size\t= sizeof(dtv_phandle3_target), +\t.plat_size\t= sizeof(dtv_phandle3_target), \t.parent_idx\t= -1, }; @@ -537,7 +537,7 @@ static struct dtd_target dtv_phandle_target = { U_BOOT_DEVICE(phandle_target) = { \t.name\t\t= "target", \t.plat\t= &dtv_phandle_target, -\t.platdata_size\t= sizeof(dtv_phandle_target), +\t.plat_size\t= sizeof(dtv_phandle_target), \t.parent_idx\t= -1, }; @@ -552,7 +552,7 @@ static struct dtd_source dtv_phandle_source = { U_BOOT_DEVICE(phandle_source) = { \t.name\t\t= "source", \t.plat\t= &dtv_phandle_source, -\t.platdata_size\t= sizeof(dtv_phandle_source), +\t.plat_size\t= sizeof(dtv_phandle_source), \t.parent_idx\t= -1, }; @@ -564,7 +564,7 @@ static struct dtd_source dtv_phandle_source2 = { U_BOOT_DEVICE(phandle_source2) = { \t.name\t\t= "source", \t.plat\t= &dtv_phandle_source2, -\t.platdata_size\t= sizeof(dtv_phandle_source2), +\t.plat_size\t= sizeof(dtv_phandle_source2), \t.parent_idx\t= -1, }; @@ -622,7 +622,7 @@ static struct dtd_test1 dtv_test1 = { U_BOOT_DEVICE(test1) = { \t.name\t\t= "test1", \t.plat\t= &dtv_test1, -\t.platdata_size\t= sizeof(dtv_test1), +\t.plat_size\t= sizeof(dtv_test1), \t.parent_idx\t= -1, }; @@ -633,7 +633,7 @@ static struct dtd_test2 dtv_test2 = { U_BOOT_DEVICE(test2) = { \t.name\t\t= "test2", \t.plat\t= &dtv_test2, -\t.platdata_size\t= sizeof(dtv_test2), +\t.plat_size\t= sizeof(dtv_test2), \t.parent_idx\t= -1, }; @@ -644,7 +644,7 @@ static struct dtd_test3 dtv_test3 = { U_BOOT_DEVICE(test3) = { \t.name\t\t= "test3", \t.plat\t= &dtv_test3, -\t.platdata_size\t= sizeof(dtv_test3), +\t.plat_size\t= sizeof(dtv_test3), \t.parent_idx\t= -1, }; @@ -677,7 +677,7 @@ static struct dtd_test1 dtv_test1 = { U_BOOT_DEVICE(test1) = { \t.name\t\t= "test1", \t.plat\t= &dtv_test1, -\t.platdata_size\t= sizeof(dtv_test1), +\t.plat_size\t= sizeof(dtv_test1), \t.parent_idx\t= -1, }; @@ -688,7 +688,7 @@ static struct dtd_test2 dtv_test2 = { U_BOOT_DEVICE(test2) = { \t.name\t\t= "test2", \t.plat\t= &dtv_test2, -\t.platdata_size\t= sizeof(dtv_test2), +\t.plat_size\t= sizeof(dtv_test2), \t.parent_idx\t= -1, }; @@ -724,7 +724,7 @@ static struct dtd_test1 dtv_test1 = { U_BOOT_DEVICE(test1) = { \t.name\t\t= "test1", \t.plat\t= &dtv_test1, -\t.platdata_size\t= sizeof(dtv_test1), +\t.plat_size\t= sizeof(dtv_test1), \t.parent_idx\t= -1, }; @@ -735,7 +735,7 @@ static struct dtd_test2 dtv_test2 = { U_BOOT_DEVICE(test2) = { \t.name\t\t= "test2", \t.plat\t= &dtv_test2, -\t.platdata_size\t= sizeof(dtv_test2), +\t.plat_size\t= sizeof(dtv_test2), \t.parent_idx\t= -1, }; @@ -746,7 +746,7 @@ static struct dtd_test3 dtv_test3 = { U_BOOT_DEVICE(test3) = { \t.name\t\t= "test3", \t.plat\t= &dtv_test3, -\t.platdata_size\t= sizeof(dtv_test3), +\t.plat_size\t= sizeof(dtv_test3), \t.parent_idx\t= -1, }; @@ -782,7 +782,7 @@ static struct dtd_test1 dtv_test1 = { U_BOOT_DEVICE(test1) = { \t.name\t\t= "test1", \t.plat\t= &dtv_test1, -\t.platdata_size\t= sizeof(dtv_test1), +\t.plat_size\t= sizeof(dtv_test1), \t.parent_idx\t= -1, }; @@ -793,7 +793,7 @@ static struct dtd_test2 dtv_test2 = { U_BOOT_DEVICE(test2) = { \t.name\t\t= "test2", \t.plat\t= &dtv_test2, -\t.platdata_size\t= sizeof(dtv_test2), +\t.plat_size\t= sizeof(dtv_test2), \t.parent_idx\t= -1, }; @@ -804,7 +804,7 @@ static struct dtd_test3 dtv_test3 = { U_BOOT_DEVICE(test3) = { \t.name\t\t= "test3", \t.plat\t= &dtv_test3, -\t.platdata_size\t= sizeof(dtv_test3), +\t.plat_size\t= sizeof(dtv_test3), \t.parent_idx\t= -1, }; @@ -855,7 +855,7 @@ static struct dtd_sandbox_spl_test dtv_spl_test = { U_BOOT_DEVICE(spl_test) = { \t.name\t\t= "sandbox_spl_test", \t.plat\t= &dtv_spl_test, -\t.platdata_size\t= sizeof(dtv_spl_test), +\t.plat_size\t= sizeof(dtv_spl_test), \t.parent_idx\t= -1, }; @@ -866,7 +866,7 @@ static struct dtd_sandbox_spl_test dtv_spl_test2 = { U_BOOT_DEVICE(spl_test2) = { \t.name\t\t= "sandbox_spl_test", \t.plat\t= &dtv_spl_test2, -\t.platdata_size\t= sizeof(dtv_spl_test2), +\t.plat_size\t= sizeof(dtv_spl_test2), \t.parent_idx\t= -1, }; -- cgit v1.2.3 From acfb5308f5e51fd1f4428618d704ad0de2358871 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Tue, 22 Dec 2020 19:30:20 -0700 Subject: sandbox: Drop unnecessary test node The spl-test4 node deliberately has an invalid compatible string. This causes a warning from dtoc and the check it does is not really necessary. Drop it, to avoid the warning and associated confusion. Signed-off-by: Simon Glass --- tools/dtoc/test_dtoc.py | 12 ------------ 1 file changed, 12 deletions(-) (limited to 'tools/dtoc/test_dtoc.py') diff --git a/tools/dtoc/test_dtoc.py b/tools/dtoc/test_dtoc.py index 4913d950218..49ab75b85da 100755 --- a/tools/dtoc/test_dtoc.py +++ b/tools/dtoc/test_dtoc.py @@ -204,8 +204,6 @@ struct dtd_sandbox_spl_test { \tconst char *\tstringarray[3]; \tconst char *\tstringval; }; -struct dtd_sandbox_spl_test_2 { -}; ''', data) self.run_test(['platdata'], dtb_file, output) @@ -286,16 +284,6 @@ U_BOOT_DEVICE(spl_test3) = { \t.parent_idx\t= -1, }; -/* Node /spl-test4 index 5 */ -static struct dtd_sandbox_spl_test_2 dtv_spl_test4 = { -}; -U_BOOT_DEVICE(spl_test4) = { -\t.name\t\t= "sandbox_spl_test_2", -\t.plat\t= &dtv_spl_test4, -\t.plat_size\t= sizeof(dtv_spl_test4), -\t.parent_idx\t= -1, -}; - ''' + C_EMPTY_POPULATE_PHANDLE_DATA, data) def test_driver_alias(self): -- cgit v1.2.3 From 7d637c122d772e472a211f6aa3f33cbe3c3e243c Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Wed, 23 Dec 2020 08:11:23 -0700 Subject: dtoc: Convert _drivers to a dict At present this member holds a simple list of driver names. Update it to be a dict of DriverInfo, with the name being the key. This will allow more information to be added about each driver, in future patches. Signed-off-by: Simon Glass --- tools/dtoc/test_dtoc.py | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'tools/dtoc/test_dtoc.py') diff --git a/tools/dtoc/test_dtoc.py b/tools/dtoc/test_dtoc.py index 49ab75b85da..c76942c9e2d 100755 --- a/tools/dtoc/test_dtoc.py +++ b/tools/dtoc/test_dtoc.py @@ -906,3 +906,13 @@ U_BOOT_DEVICE(spl_test2) = { with test_util.capture_sys_output() as (stdout, stderr): dtb_platdata.run_steps(['struct'], dtb_file, False, output, True, [driver_fn]) + + def testDriver(self): + """Test the Driver class""" + drv1 = dtb_platdata.Driver('fred') + drv2 = dtb_platdata.Driver('mary') + drv3 = dtb_platdata.Driver('fred') + self.assertEqual("Driver(name='fred')", str(drv1)) + self.assertEqual(drv1, drv3) + self.assertNotEqual(drv1, drv2) + self.assertNotEqual(drv2, drv3) -- cgit v1.2.3 From 67b5ec54a5c19452c7aa33c693f281cc18a37d09 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 28 Dec 2020 20:34:47 -0700 Subject: dtoc: Tidy up pylint warnings in test Tidy up this file to reduce the number of pylint warnings. Signed-off-by: Simon Glass --- tools/dtoc/test_dtoc.py | 156 ++++++++++++++++++++++++++---------------------- 1 file changed, 85 insertions(+), 71 deletions(-) (limited to 'tools/dtoc/test_dtoc.py') diff --git a/tools/dtoc/test_dtoc.py b/tools/dtoc/test_dtoc.py index c76942c9e2d..4bf90444e14 100755 --- a/tools/dtoc/test_dtoc.py +++ b/tools/dtoc/test_dtoc.py @@ -12,21 +12,20 @@ tool. import collections import os import struct -import sys import tempfile import unittest -from dtoc import dtb_platdata from dtb_platdata import conv_name_to_c from dtb_platdata import get_compat_name from dtb_platdata import get_value from dtb_platdata import tab_to +from dtoc import dtb_platdata from dtoc import fdt from dtoc import fdt_util from patman import test_util from patman import tools -our_path = os.path.dirname(os.path.realpath(__file__)) +OUR_PATH = os.path.dirname(os.path.realpath(__file__)) HEADER = '''/* @@ -56,18 +55,21 @@ C_EMPTY_POPULATE_PHANDLE_DATA = '''void dm_populate_phandle_data(void) { } ''' +# This is a test so is allowed to access private things in the module it is +# testing +# pylint: disable=W0212 def get_dtb_file(dts_fname, capture_stderr=False): """Compile a .dts file to a .dtb Args: - dts_fname: Filename of .dts file in the current directory - capture_stderr: True to capture and discard stderr output + dts_fname (str): Filename of .dts file in the current directory + capture_stderr (bool): True to capture and discard stderr output Returns: - Filename of compiled file in output directory + 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, dts_fname), capture_stderr=capture_stderr) @@ -80,20 +82,21 @@ class TestDtoc(unittest.TestCase): @classmethod def tearDownClass(cls): - tools._RemoveOutputDir() + tools.FinaliseOutputDir() - def _WritePythonString(self, fname, data): + @staticmethod + def _write_python_string(fname, data): """Write a string with tabs expanded as done in this Python file Args: - fname: Filename to write to - data: Raw string to convert + fname (str): Filename to write to + data (str): Raw string to convert """ data = data.replace('\t', '\\t') - with open(fname, 'w') as fd: - fd.write(data) + with open(fname, 'w') as fout: + fout.write(data) - def _CheckStrings(self, expected, actual): + def _check_strings(self, expected, actual): """Check that a string matches its expected value If the strings do not match, they are written to the /tmp directory in @@ -101,17 +104,24 @@ class TestDtoc(unittest.TestCase): easy comparison and update of the tests. Args: - expected: Expected string - actual: Actual string + expected (str): Expected string + actual (str): Actual string """ if expected != actual: - self._WritePythonString('/tmp/binman.expected', expected) - self._WritePythonString('/tmp/binman.actual', actual) + self._write_python_string('/tmp/binman.expected', expected) + self._write_python_string('/tmp/binman.actual', actual) print('Failures written to /tmp/binman.{expected,actual}') - self.assertEquals(expected, actual) + self.assertEqual(expected, actual) + @staticmethod + def run_test(args, dtb_file, output): + """Run a test using dtoc - def run_test(self, args, dtb_file, output): + Args: + args (list of str): List of arguments for dtoc + dtb_file (str): Filename of .dtb file + output (str): Filename of output file + """ dtb_platdata.run_steps(args, dtb_file, False, output, True) def test_name(self): @@ -160,7 +170,7 @@ class TestDtoc(unittest.TestCase): prop = Prop(['rockchip,rk3399-sdhci-5.1', 'arasan,sdhci-5.1', 'third']) node = Node({'compatible': prop}) self.assertEqual((['rockchip_rk3399_sdhci_5_1', - 'arasan_sdhci_5_1', 'third']), + 'arasan_sdhci_5_1', 'third']), get_compat_name(node)) def test_empty_file(self): @@ -185,7 +195,7 @@ class TestDtoc(unittest.TestCase): self.run_test(['struct'], dtb_file, output) with open(output) as infile: data = infile.read() - self._CheckStrings(HEADER + ''' + self._check_strings(HEADER + ''' struct dtd_sandbox_i2c_test { }; struct dtd_sandbox_pmic_test { @@ -209,7 +219,7 @@ struct dtd_sandbox_spl_test { self.run_test(['platdata'], dtb_file, output) with open(output) as infile: data = infile.read() - self._CheckStrings(C_HEADER + ''' + self._check_strings(C_HEADER + ''' /* Node /i2c@0 index 0 */ static struct dtd_sandbox_i2c_test dtv_i2c_at_0 = { }; @@ -293,7 +303,7 @@ U_BOOT_DEVICE(spl_test3) = { self.run_test(['struct'], dtb_file, output) with open(output) as infile: data = infile.read() - self._CheckStrings(HEADER + ''' + self._check_strings(HEADER + ''' struct dtd_sandbox_gpio { \tconst char *\tgpio_bank_name; \tbool\t\tgpio_controller; @@ -304,7 +314,7 @@ struct dtd_sandbox_gpio { self.run_test(['platdata'], dtb_file, output) with open(output) as infile: data = infile.read() - self._CheckStrings(C_HEADER + ''' + self._check_strings(C_HEADER + ''' /* Node /gpios@0 index 0 */ static struct dtd_sandbox_gpio dtv_gpios_at_0 = { \t.gpio_bank_name\t\t= "a", @@ -326,20 +336,20 @@ void dm_populate_phandle_data(void) { """Test output from a device tree file with an invalid driver""" dtb_file = get_dtb_file('dtoc_test_invalid_driver.dts') output = tools.GetOutputFilename('output') - with test_util.capture_sys_output() as (stdout, stderr): + with test_util.capture_sys_output() as _: dtb_platdata.run_steps(['struct'], dtb_file, False, output) with open(output) as infile: data = infile.read() - self._CheckStrings(HEADER + ''' + self._check_strings(HEADER + ''' struct dtd_invalid { }; ''', data) - with test_util.capture_sys_output() as (stdout, stderr): + with test_util.capture_sys_output() as _: dtb_platdata.run_steps(['platdata'], dtb_file, False, output) with open(output) as infile: data = infile.read() - self._CheckStrings(C_HEADER + ''' + self._check_strings(C_HEADER + ''' /* Node /spl-test index 0 */ static struct dtd_invalid dtv_spl_test = { }; @@ -361,7 +371,7 @@ void dm_populate_phandle_data(void) { self.run_test(['struct'], dtb_file, output) with open(output) as infile: data = infile.read() - self._CheckStrings(HEADER + ''' + self._check_strings(HEADER + ''' struct dtd_source { \tstruct phandle_2_arg clocks[4]; }; @@ -373,7 +383,7 @@ struct dtd_target { self.run_test(['platdata'], dtb_file, output) with open(output) as infile: data = infile.read() - self._CheckStrings(C_HEADER + ''' + self._check_strings(C_HEADER + ''' /* Node /phandle2-target index 0 */ static struct dtd_target dtv_phandle2_target = { \t.intval\t\t\t= 0x1, @@ -445,7 +455,7 @@ void dm_populate_phandle_data(void) { self.run_test(['struct'], dtb_file, output) with open(output) as infile: data = infile.read() - self._CheckStrings(HEADER + ''' + self._check_strings(HEADER + ''' struct dtd_source { \tstruct phandle_0_arg clocks[1]; }; @@ -461,7 +471,7 @@ struct dtd_target { self.run_test(['platdata'], dtb_file, output) with open(output) as infile: data = infile.read() - self._CheckStrings(C_HEADER + ''' + self._check_strings(C_HEADER + ''' /* Node /phandle-target index 1 */ static struct dtd_target dtv_phandle_target = { }; @@ -495,7 +505,7 @@ void dm_populate_phandle_data(void) { dtb_platdata.run_steps(['platdata'], dtb_file, False, output, True) with open(output) as infile: data = infile.read() - self._CheckStrings(C_HEADER + ''' + self._check_strings(C_HEADER + ''' /* Node /phandle2-target index 0 */ static struct dtd_target dtv_phandle2_target = { \t.intval\t\t\t= 0x1, @@ -565,20 +575,20 @@ void dm_populate_phandle_data(void) { dtb_file = get_dtb_file('dtoc_test_phandle_bad.dts', capture_stderr=True) output = tools.GetOutputFilename('output') - with self.assertRaises(ValueError) as e: + with self.assertRaises(ValueError) as exc: self.run_test(['struct'], dtb_file, output) self.assertIn("Cannot parse 'clocks' in node 'phandle-source'", - str(e.exception)) + str(exc.exception)) def test_phandle_bad2(self): """Test a phandle target missing its #*-cells property""" dtb_file = get_dtb_file('dtoc_test_phandle_bad2.dts', capture_stderr=True) output = tools.GetOutputFilename('output') - with self.assertRaises(ValueError) as e: + with self.assertRaises(ValueError) as exc: self.run_test(['struct'], dtb_file, output) self.assertIn("Node 'phandle-target' has no cells property", - str(e.exception)) + str(exc.exception)) def test_addresses64(self): """Test output from a node with a 'reg' property with na=2, ns=2""" @@ -587,7 +597,7 @@ void dm_populate_phandle_data(void) { self.run_test(['struct'], dtb_file, output) with open(output) as infile: data = infile.read() - self._CheckStrings(HEADER + ''' + self._check_strings(HEADER + ''' struct dtd_test1 { \tfdt64_t\t\treg[2]; }; @@ -602,7 +612,7 @@ struct dtd_test3 { self.run_test(['platdata'], dtb_file, output) with open(output) as infile: data = infile.read() - self._CheckStrings(C_HEADER + ''' + self._check_strings(C_HEADER + ''' /* Node /test1 index 0 */ static struct dtd_test1 dtv_test1 = { \t.reg\t\t\t= {0x1234, 0x5678}, @@ -645,7 +655,7 @@ U_BOOT_DEVICE(test3) = { self.run_test(['struct'], dtb_file, output) with open(output) as infile: data = infile.read() - self._CheckStrings(HEADER + ''' + self._check_strings(HEADER + ''' struct dtd_test1 { \tfdt32_t\t\treg[2]; }; @@ -657,7 +667,7 @@ struct dtd_test2 { self.run_test(['platdata'], dtb_file, output) with open(output) as infile: data = infile.read() - self._CheckStrings(C_HEADER + ''' + self._check_strings(C_HEADER + ''' /* Node /test1 index 0 */ static struct dtd_test1 dtv_test1 = { \t.reg\t\t\t= {0x1234, 0x5678}, @@ -689,7 +699,7 @@ U_BOOT_DEVICE(test2) = { self.run_test(['struct'], dtb_file, output) with open(output) as infile: data = infile.read() - self._CheckStrings(HEADER + ''' + self._check_strings(HEADER + ''' struct dtd_test1 { \tfdt64_t\t\treg[2]; }; @@ -704,7 +714,7 @@ struct dtd_test3 { self.run_test(['platdata'], dtb_file, output) with open(output) as infile: data = infile.read() - self._CheckStrings(C_HEADER + ''' + self._check_strings(C_HEADER + ''' /* Node /test1 index 0 */ static struct dtd_test1 dtv_test1 = { \t.reg\t\t\t= {0x123400000000, 0x5678}, @@ -747,7 +757,7 @@ U_BOOT_DEVICE(test3) = { self.run_test(['struct'], dtb_file, output) with open(output) as infile: data = infile.read() - self._CheckStrings(HEADER + ''' + self._check_strings(HEADER + ''' struct dtd_test1 { \tfdt64_t\t\treg[2]; }; @@ -762,7 +772,7 @@ struct dtd_test3 { self.run_test(['platdata'], dtb_file, output) with open(output) as infile: data = infile.read() - self._CheckStrings(C_HEADER + ''' + self._check_strings(C_HEADER + ''' /* Node /test1 index 0 */ static struct dtd_test1 dtv_test1 = { \t.reg\t\t\t= {0x1234, 0x567800000000}, @@ -803,20 +813,21 @@ U_BOOT_DEVICE(test3) = { # Capture stderr since dtc will emit warnings for this file dtb_file = get_dtb_file('dtoc_test_bad_reg.dts', capture_stderr=True) output = tools.GetOutputFilename('output') - with self.assertRaises(ValueError) as e: + with self.assertRaises(ValueError) as exc: self.run_test(['struct'], dtb_file, output) self.assertIn("Node 'spl-test' reg property is not an int", - str(e.exception)) + str(exc.exception)) def test_bad_reg2(self): """Test that a reg property with an invalid cell count is detected""" # Capture stderr since dtc will emit warnings for this file dtb_file = get_dtb_file('dtoc_test_bad_reg2.dts', capture_stderr=True) output = tools.GetOutputFilename('output') - with self.assertRaises(ValueError) as e: + with self.assertRaises(ValueError) as exc: self.run_test(['struct'], dtb_file, output) - self.assertIn("Node 'spl-test' reg property has 3 cells which is not a multiple of na + ns = 1 + 1)", - str(e.exception)) + self.assertIn( + "Node 'spl-test' reg property has 3 cells which is not a multiple of na + ns = 1 + 1)", + str(exc.exception)) def test_add_prop(self): """Test that a subequent node can add a new property to a struct""" @@ -825,7 +836,7 @@ U_BOOT_DEVICE(test3) = { self.run_test(['struct'], dtb_file, output) with open(output) as infile: data = infile.read() - self._CheckStrings(HEADER + ''' + self._check_strings(HEADER + ''' struct dtd_sandbox_spl_test { \tfdt32_t\t\tintarray; \tfdt32_t\t\tintval; @@ -835,7 +846,7 @@ struct dtd_sandbox_spl_test { self.run_test(['platdata'], dtb_file, output) with open(output) as infile: data = infile.read() - self._CheckStrings(C_HEADER + ''' + self._check_strings(C_HEADER + ''' /* Node /spl-test index 0 */ static struct dtd_sandbox_spl_test dtv_spl_test = { \t.intval\t\t\t= 0x1, @@ -860,37 +871,40 @@ U_BOOT_DEVICE(spl_test2) = { ''' + C_EMPTY_POPULATE_PHANDLE_DATA, data) - def testStdout(self): + def test_stdout(self): """Test output to stdout""" dtb_file = get_dtb_file('dtoc_test_simple.dts') - with test_util.capture_sys_output() as (stdout, stderr): + with test_util.capture_sys_output() as _: self.run_test(['struct'], dtb_file, '-') - def testNoCommand(self): + def test_no_command(self): """Test running dtoc without a command""" - with self.assertRaises(ValueError) as e: + with self.assertRaises(ValueError) as exc: self.run_test([], '', '') self.assertIn("Please specify a command: struct, platdata", - str(e.exception)) + str(exc.exception)) - def testBadCommand(self): + def test_bad_command(self): """Test running dtoc with an invalid command""" dtb_file = get_dtb_file('dtoc_test_simple.dts') output = tools.GetOutputFilename('output') - with self.assertRaises(ValueError) as e: + with self.assertRaises(ValueError) as exc: self.run_test(['invalid-cmd'], dtb_file, output) self.assertIn("Unknown command 'invalid-cmd': (use: struct, platdata)", - str(e.exception)) + str(exc.exception)) - def testScanDrivers(self): + @staticmethod + def test_scan_drivers(): """Test running dtoc with additional drivers to scan""" dtb_file = get_dtb_file('dtoc_test_simple.dts') output = tools.GetOutputFilename('output') - with test_util.capture_sys_output() as (stdout, stderr): - dtb_platdata.run_steps(['struct'], dtb_file, False, output, True, - [None, '', 'tools/dtoc/dtoc_test_scan_drivers.cxx']) + with test_util.capture_sys_output() as _: + dtb_platdata.run_steps( + ['struct'], dtb_file, False, output, True, + [None, '', 'tools/dtoc/dtoc_test_scan_drivers.cxx']) - def testUnicodeError(self): + @staticmethod + def test_unicode_error(): """Test running dtoc with an invalid unicode file To be able to perform this test without adding a weird text file which @@ -900,14 +914,14 @@ U_BOOT_DEVICE(spl_test2) = { dtb_file = get_dtb_file('dtoc_test_simple.dts') output = tools.GetOutputFilename('output') driver_fn = '/tmp/' + next(tempfile._get_candidate_names()) - with open(driver_fn, 'wb+') as df: - df.write(b'\x81') + with open(driver_fn, 'wb+') as fout: + fout.write(b'\x81') - with test_util.capture_sys_output() as (stdout, stderr): + with test_util.capture_sys_output() as _: dtb_platdata.run_steps(['struct'], dtb_file, False, output, True, - [driver_fn]) + [driver_fn]) - def testDriver(self): + def test_driver(self): """Test the Driver class""" drv1 = dtb_platdata.Driver('fred') drv2 = dtb_platdata.Driver('mary') -- cgit v1.2.3 From f62cea0e205c905632be3aefa82b10ef36ce8a25 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 28 Dec 2020 20:34:48 -0700 Subject: dtoc: Use None to mean stdout At present dtoc uses '-' internally to mean that output should go to stdout. This is not necessary and None is more convenient. Update it. Signed-off-by: Simon Glass --- tools/dtoc/test_dtoc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tools/dtoc/test_dtoc.py') diff --git a/tools/dtoc/test_dtoc.py b/tools/dtoc/test_dtoc.py index 4bf90444e14..41a10eb4004 100755 --- a/tools/dtoc/test_dtoc.py +++ b/tools/dtoc/test_dtoc.py @@ -875,7 +875,7 @@ U_BOOT_DEVICE(spl_test2) = { """Test output to stdout""" dtb_file = get_dtb_file('dtoc_test_simple.dts') with test_util.capture_sys_output() as _: - self.run_test(['struct'], dtb_file, '-') + self.run_test(['struct'], dtb_file, None) def test_no_command(self): """Test running dtoc without a command""" -- cgit v1.2.3 From de846cbb307486a1533dcf4d5c28568412149ddb Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 28 Dec 2020 20:34:49 -0700 Subject: dtoc: Test the stdout output Normally dtoc outputs to a file but it also offers a way to write output to stdout. At present the test for that does not actually check that the output is correct. Add this to the test. This uses a member variable to hold the expected text, so it can be used in muitiple places. Signed-off-by: Simon Glass --- tools/dtoc/test_dtoc.py | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) (limited to 'tools/dtoc/test_dtoc.py') diff --git a/tools/dtoc/test_dtoc.py b/tools/dtoc/test_dtoc.py index 41a10eb4004..7cf2a5187c6 100755 --- a/tools/dtoc/test_dtoc.py +++ b/tools/dtoc/test_dtoc.py @@ -188,14 +188,7 @@ class TestDtoc(unittest.TestCase): self.assertEqual(C_HEADER.splitlines() + [''] + C_EMPTY_POPULATE_PHANDLE_DATA.splitlines(), lines) - def test_simple(self): - """Test output from some simple nodes with various types of data""" - dtb_file = get_dtb_file('dtoc_test_simple.dts') - output = tools.GetOutputFilename('output') - self.run_test(['struct'], dtb_file, output) - with open(output) as infile: - data = infile.read() - self._check_strings(HEADER + ''' + struct_text = HEADER + ''' struct dtd_sandbox_i2c_test { }; struct dtd_sandbox_pmic_test { @@ -214,12 +207,9 @@ struct dtd_sandbox_spl_test { \tconst char *\tstringarray[3]; \tconst char *\tstringval; }; -''', data) +''' - self.run_test(['platdata'], dtb_file, output) - with open(output) as infile: - data = infile.read() - self._check_strings(C_HEADER + ''' + platdata_text = C_HEADER + ''' /* Node /i2c@0 index 0 */ static struct dtd_sandbox_i2c_test dtv_i2c_at_0 = { }; @@ -294,7 +284,23 @@ U_BOOT_DEVICE(spl_test3) = { \t.parent_idx\t= -1, }; -''' + C_EMPTY_POPULATE_PHANDLE_DATA, data) +''' + C_EMPTY_POPULATE_PHANDLE_DATA + + def test_simple(self): + """Test output from some simple nodes with various types of data""" + dtb_file = get_dtb_file('dtoc_test_simple.dts') + output = tools.GetOutputFilename('output') + self.run_test(['struct'], dtb_file, output) + with open(output) as infile: + data = infile.read() + + self._check_strings(self.struct_text, data) + + self.run_test(['platdata'], dtb_file, output) + with open(output) as infile: + data = infile.read() + + self._check_strings(self.platdata_text, data) def test_driver_alias(self): """Test output from a device tree file with a driver alias""" @@ -874,8 +880,9 @@ U_BOOT_DEVICE(spl_test2) = { def test_stdout(self): """Test output to stdout""" dtb_file = get_dtb_file('dtoc_test_simple.dts') - with test_util.capture_sys_output() as _: + with test_util.capture_sys_output() as (stdout, _): self.run_test(['struct'], dtb_file, None) + self._check_strings(self.struct_text, stdout.getvalue()) def test_no_command(self): """Test running dtoc without a command""" -- cgit v1.2.3 From 192c111cfce0684fa1cbbd4a4bd3df03720ef7a6 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 28 Dec 2020 20:34:50 -0700 Subject: dtoc: Allow providing a directory to write files to At present dtoc writes only a single file on each invocation. U-Boot writes the two files it needs by separate invocations of dtoc. Since dtoc now scans all U-Boot driver source, this is fairly slow (about 1 second per file). It would be better if dtoc could write all the files at once. In preparation for this, add a way to specify an output directory for the files. Signed-off-by: Simon Glass --- tools/dtoc/test_dtoc.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'tools/dtoc/test_dtoc.py') diff --git a/tools/dtoc/test_dtoc.py b/tools/dtoc/test_dtoc.py index 7cf2a5187c6..b023a1e14a5 100755 --- a/tools/dtoc/test_dtoc.py +++ b/tools/dtoc/test_dtoc.py @@ -122,7 +122,7 @@ class TestDtoc(unittest.TestCase): dtb_file (str): Filename of .dtb file output (str): Filename of output file """ - dtb_platdata.run_steps(args, dtb_file, False, output, True) + dtb_platdata.run_steps(args, dtb_file, False, output, [], True) def test_name(self): """Test conversion of device tree names to C identifiers""" @@ -343,7 +343,7 @@ void dm_populate_phandle_data(void) { dtb_file = get_dtb_file('dtoc_test_invalid_driver.dts') output = tools.GetOutputFilename('output') with test_util.capture_sys_output() as _: - dtb_platdata.run_steps(['struct'], dtb_file, False, output) + dtb_platdata.run_steps(['struct'], dtb_file, False, output, []) with open(output) as infile: data = infile.read() self._check_strings(HEADER + ''' @@ -352,7 +352,7 @@ struct dtd_invalid { ''', data) with test_util.capture_sys_output() as _: - dtb_platdata.run_steps(['platdata'], dtb_file, False, output) + dtb_platdata.run_steps(['platdata'], dtb_file, False, output, []) with open(output) as infile: data = infile.read() self._check_strings(C_HEADER + ''' @@ -508,7 +508,7 @@ void dm_populate_phandle_data(void) { """Test that phandle targets are generated when unsing cd-gpios""" dtb_file = get_dtb_file('dtoc_test_phandle_cd_gpios.dts') output = tools.GetOutputFilename('output') - dtb_platdata.run_steps(['platdata'], dtb_file, False, output, True) + dtb_platdata.run_steps(['platdata'], dtb_file, False, output, [], True) with open(output) as infile: data = infile.read() self._check_strings(C_HEADER + ''' @@ -907,7 +907,7 @@ U_BOOT_DEVICE(spl_test2) = { output = tools.GetOutputFilename('output') with test_util.capture_sys_output() as _: dtb_platdata.run_steps( - ['struct'], dtb_file, False, output, True, + ['struct'], dtb_file, False, output, [], True, [None, '', 'tools/dtoc/dtoc_test_scan_drivers.cxx']) @staticmethod @@ -925,8 +925,8 @@ U_BOOT_DEVICE(spl_test2) = { fout.write(b'\x81') with test_util.capture_sys_output() as _: - dtb_platdata.run_steps(['struct'], dtb_file, False, output, True, - [driver_fn]) + dtb_platdata.run_steps(['struct'], dtb_file, False, output, [], + True, [driver_fn]) def test_driver(self): """Test the Driver class""" -- cgit v1.2.3 From be44f27156bf46807049a0e1c303626d05f781f8 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 28 Dec 2020 20:34:51 -0700 Subject: dtoc: Allow outputing to multiple files Implement the 'output directory' feature, allowing dtoc to write the output files separately to the supplied directories. This allows us to handle the struct and platdata output in one run of dtoc. Signed-off-by: Simon Glass --- tools/dtoc/test_dtoc.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'tools/dtoc/test_dtoc.py') diff --git a/tools/dtoc/test_dtoc.py b/tools/dtoc/test_dtoc.py index b023a1e14a5..6f9af905e82 100755 --- a/tools/dtoc/test_dtoc.py +++ b/tools/dtoc/test_dtoc.py @@ -884,6 +884,14 @@ U_BOOT_DEVICE(spl_test2) = { self.run_test(['struct'], dtb_file, None) self._check_strings(self.struct_text, stdout.getvalue()) + def test_multi_to_file(self): + """Test output of multiple pieces to a single file""" + dtb_file = get_dtb_file('dtoc_test_simple.dts') + output = tools.GetOutputFilename('output') + self.run_test(['struct,platdata'], dtb_file, output) + data = tools.ReadFile(output, binary=False) + self._check_strings(self.struct_text + self.platdata_text, data) + def test_no_command(self): """Test running dtoc without a command""" with self.assertRaises(ValueError) as exc: -- cgit v1.2.3 From 10cbd3b7da12e993c67d56182d30294661a93619 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 28 Dec 2020 20:34:52 -0700 Subject: dtoc: Add an 'all' command With upcoming changes, dtoc will output several files for different of-platdata components. Add a way to output all ava!ilable files at once ('all'), to the appropriate directories, without needing to specify each one invidually. This puts the commands in alphabetical order, so update the tests accordingly. Signed-off-by: Simon Glass --- tools/dtoc/test_dtoc.py | 40 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-) (limited to 'tools/dtoc/test_dtoc.py') diff --git a/tools/dtoc/test_dtoc.py b/tools/dtoc/test_dtoc.py index 6f9af905e82..fb65f284ceb 100755 --- a/tools/dtoc/test_dtoc.py +++ b/tools/dtoc/test_dtoc.py @@ -10,6 +10,7 @@ tool. """ import collections +import glob import os import struct import tempfile @@ -302,6 +303,11 @@ U_BOOT_DEVICE(spl_test3) = { self._check_strings(self.platdata_text, data) + # Try the 'all' command + self.run_test(['all'], dtb_file, output) + data = tools.ReadFile(output, binary=False) + self._check_strings(self.platdata_text + self.struct_text, data) + def test_driver_alias(self): """Test output from a device tree file with a driver alias""" dtb_file = get_dtb_file('dtoc_test_driver_alias.dts') @@ -888,9 +894,9 @@ U_BOOT_DEVICE(spl_test2) = { """Test output of multiple pieces to a single file""" dtb_file = get_dtb_file('dtoc_test_simple.dts') output = tools.GetOutputFilename('output') - self.run_test(['struct,platdata'], dtb_file, output) + self.run_test(['all'], dtb_file, output) data = tools.ReadFile(output, binary=False) - self._check_strings(self.struct_text + self.platdata_text, data) + self._check_strings(self.platdata_text + self.struct_text, data) def test_no_command(self): """Test running dtoc without a command""" @@ -905,7 +911,7 @@ U_BOOT_DEVICE(spl_test2) = { output = tools.GetOutputFilename('output') with self.assertRaises(ValueError) as exc: self.run_test(['invalid-cmd'], dtb_file, output) - self.assertIn("Unknown command 'invalid-cmd': (use: struct, platdata)", + self.assertIn("Unknown command 'invalid-cmd': (use: platdata, struct)", str(exc.exception)) @staticmethod @@ -945,3 +951,31 @@ U_BOOT_DEVICE(spl_test2) = { self.assertEqual(drv1, drv3) self.assertNotEqual(drv1, drv2) self.assertNotEqual(drv2, drv3) + + def test_output_conflict(self): + """Test a conflict between and output dirs and output file""" + with self.assertRaises(ValueError) as exc: + dtb_platdata.run_steps(['all'], None, False, 'out', ['cdir'], True) + 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""" + # Remove the directory so that files from other tests are not there + tools._RemoveOutputDir() + tools.PrepareOutputDir(None) + + # This should create the .dts and .dtb in the output directory + dtb_file = get_dtb_file('dtoc_test_simple.dts') + outdir = tools.GetOutputDir() + fnames = glob.glob(outdir + '/*') + self.assertEqual(2, len(fnames)) + + dtb_platdata.run_steps(['all'], dtb_file, False, None, [outdir], True) + fnames = glob.glob(outdir + '/*') + self.assertEqual(4, len(fnames)) + + leafs = set(os.path.basename(fname) for fname in fnames) + self.assertEqual( + {'dt-structs-gen.h', 'source.dts', 'dt-platdata.c', 'source.dtb'}, + leafs) -- cgit v1.2.3 From 20e442ab2df355450006574fff178c746d254a18 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 28 Dec 2020 20:34:54 -0700 Subject: dm: Rename U_BOOT_DEVICE() to U_BOOT_DRVINFO() The current macro is a misnomer since it does not declare a device directly. Instead, it declares driver_info record which U-Boot uses at runtime to create a device. The distinction seems somewhat minor most of the time, but is becomes quite confusing when we actually want to declare a device, with of-platdata. We are left trying to distinguish between a device which isn't actually device, and a device that is (perhaps an 'instance'?) It seems better to rename this macro to describe what it actually is. The macros is not widely used, since boards should use devicetree to declare devices. Rename it to U_BOOT_DRVINFO(), which indicates clearly that this is declaring a new driver_info record, not a device. Signed-off-by: Simon Glass --- tools/dtoc/test_dtoc.py | 66 ++++++++++++++++++++++++------------------------- 1 file changed, 33 insertions(+), 33 deletions(-) (limited to 'tools/dtoc/test_dtoc.py') diff --git a/tools/dtoc/test_dtoc.py b/tools/dtoc/test_dtoc.py index fb65f284ceb..dbd4e3bf1d4 100755 --- a/tools/dtoc/test_dtoc.py +++ b/tools/dtoc/test_dtoc.py @@ -44,7 +44,7 @@ C_HEADER = '''/* * This file was generated by dtoc from a .dtb (device tree binary) file. */ -/* Allow use of U_BOOT_DEVICE() in this file */ +/* Allow use of U_BOOT_DRVINFO() in this file */ #define DT_PLATDATA_C #include @@ -214,7 +214,7 @@ struct dtd_sandbox_spl_test { /* Node /i2c@0 index 0 */ static struct dtd_sandbox_i2c_test dtv_i2c_at_0 = { }; -U_BOOT_DEVICE(i2c_at_0) = { +U_BOOT_DRVINFO(i2c_at_0) = { \t.name\t\t= "sandbox_i2c_test", \t.plat\t= &dtv_i2c_at_0, \t.plat_size\t= sizeof(dtv_i2c_at_0), @@ -226,7 +226,7 @@ static struct dtd_sandbox_pmic_test dtv_pmic_at_9 = { \t.low_power\t\t= true, \t.reg\t\t\t= {0x9, 0x0}, }; -U_BOOT_DEVICE(pmic_at_9) = { +U_BOOT_DRVINFO(pmic_at_9) = { \t.name\t\t= "sandbox_pmic_test", \t.plat\t= &dtv_pmic_at_9, \t.plat_size\t= sizeof(dtv_pmic_at_9), @@ -246,7 +246,7 @@ static struct dtd_sandbox_spl_test dtv_spl_test = { \t.stringarray\t\t= {"multi-word", "message", ""}, \t.stringval\t\t= "message", }; -U_BOOT_DEVICE(spl_test) = { +U_BOOT_DRVINFO(spl_test) = { \t.name\t\t= "sandbox_spl_test", \t.plat\t= &dtv_spl_test, \t.plat_size\t= sizeof(dtv_spl_test), @@ -265,7 +265,7 @@ static struct dtd_sandbox_spl_test dtv_spl_test2 = { \t.stringarray\t\t= {"another", "multi-word", "message"}, \t.stringval\t\t= "message2", }; -U_BOOT_DEVICE(spl_test2) = { +U_BOOT_DRVINFO(spl_test2) = { \t.name\t\t= "sandbox_spl_test", \t.plat\t= &dtv_spl_test2, \t.plat_size\t= sizeof(dtv_spl_test2), @@ -278,7 +278,7 @@ static struct dtd_sandbox_spl_test dtv_spl_test3 = { \t\t0x0}, \t.stringarray\t\t= {"one", "", ""}, }; -U_BOOT_DEVICE(spl_test3) = { +U_BOOT_DRVINFO(spl_test3) = { \t.name\t\t= "sandbox_spl_test", \t.plat\t= &dtv_spl_test3, \t.plat_size\t= sizeof(dtv_spl_test3), @@ -333,7 +333,7 @@ static struct dtd_sandbox_gpio dtv_gpios_at_0 = { \t.gpio_controller\t= true, \t.sandbox_gpio_count\t= 0x14, }; -U_BOOT_DEVICE(gpios_at_0) = { +U_BOOT_DRVINFO(gpios_at_0) = { \t.name\t\t= "sandbox_gpio", \t.plat\t= &dtv_gpios_at_0, \t.plat_size\t= sizeof(dtv_gpios_at_0), @@ -365,7 +365,7 @@ struct dtd_invalid { /* Node /spl-test index 0 */ static struct dtd_invalid dtv_spl_test = { }; -U_BOOT_DEVICE(spl_test) = { +U_BOOT_DRVINFO(spl_test) = { \t.name\t\t= "invalid", \t.plat\t= &dtv_spl_test, \t.plat_size\t= sizeof(dtv_spl_test), @@ -400,7 +400,7 @@ struct dtd_target { static struct dtd_target dtv_phandle2_target = { \t.intval\t\t\t= 0x1, }; -U_BOOT_DEVICE(phandle2_target) = { +U_BOOT_DRVINFO(phandle2_target) = { \t.name\t\t= "target", \t.plat\t= &dtv_phandle2_target, \t.plat_size\t= sizeof(dtv_phandle2_target), @@ -411,7 +411,7 @@ U_BOOT_DEVICE(phandle2_target) = { static struct dtd_target dtv_phandle3_target = { \t.intval\t\t\t= 0x2, }; -U_BOOT_DEVICE(phandle3_target) = { +U_BOOT_DRVINFO(phandle3_target) = { \t.name\t\t= "target", \t.plat\t= &dtv_phandle3_target, \t.plat_size\t= sizeof(dtv_phandle3_target), @@ -422,7 +422,7 @@ U_BOOT_DEVICE(phandle3_target) = { static struct dtd_target dtv_phandle_target = { \t.intval\t\t\t= 0x0, }; -U_BOOT_DEVICE(phandle_target) = { +U_BOOT_DRVINFO(phandle_target) = { \t.name\t\t= "target", \t.plat\t= &dtv_phandle_target, \t.plat_size\t= sizeof(dtv_phandle_target), @@ -437,7 +437,7 @@ static struct dtd_source dtv_phandle_source = { \t\t\t{1, {12, 13}}, \t\t\t{4, {}},}, }; -U_BOOT_DEVICE(phandle_source) = { +U_BOOT_DRVINFO(phandle_source) = { \t.name\t\t= "source", \t.plat\t= &dtv_phandle_source, \t.plat_size\t= sizeof(dtv_phandle_source), @@ -449,7 +449,7 @@ static struct dtd_source dtv_phandle_source2 = { \t.clocks\t\t\t= { \t\t\t{4, {}},}, }; -U_BOOT_DEVICE(phandle_source2) = { +U_BOOT_DRVINFO(phandle_source2) = { \t.name\t\t= "source", \t.plat\t= &dtv_phandle_source2, \t.plat_size\t= sizeof(dtv_phandle_source2), @@ -487,7 +487,7 @@ struct dtd_target { /* Node /phandle-target index 1 */ static struct dtd_target dtv_phandle_target = { }; -U_BOOT_DEVICE(phandle_target) = { +U_BOOT_DRVINFO(phandle_target) = { \t.name\t\t= "target", \t.plat\t= &dtv_phandle_target, \t.plat_size\t= sizeof(dtv_phandle_target), @@ -499,7 +499,7 @@ static struct dtd_source dtv_phandle_source2 = { \t.clocks\t\t\t= { \t\t\t{1, {}},}, }; -U_BOOT_DEVICE(phandle_source2) = { +U_BOOT_DRVINFO(phandle_source2) = { \t.name\t\t= "source", \t.plat\t= &dtv_phandle_source2, \t.plat_size\t= sizeof(dtv_phandle_source2), @@ -522,7 +522,7 @@ void dm_populate_phandle_data(void) { static struct dtd_target dtv_phandle2_target = { \t.intval\t\t\t= 0x1, }; -U_BOOT_DEVICE(phandle2_target) = { +U_BOOT_DRVINFO(phandle2_target) = { \t.name\t\t= "target", \t.plat\t= &dtv_phandle2_target, \t.plat_size\t= sizeof(dtv_phandle2_target), @@ -533,7 +533,7 @@ U_BOOT_DEVICE(phandle2_target) = { static struct dtd_target dtv_phandle3_target = { \t.intval\t\t\t= 0x2, }; -U_BOOT_DEVICE(phandle3_target) = { +U_BOOT_DRVINFO(phandle3_target) = { \t.name\t\t= "target", \t.plat\t= &dtv_phandle3_target, \t.plat_size\t= sizeof(dtv_phandle3_target), @@ -544,7 +544,7 @@ U_BOOT_DEVICE(phandle3_target) = { static struct dtd_target dtv_phandle_target = { \t.intval\t\t\t= 0x0, }; -U_BOOT_DEVICE(phandle_target) = { +U_BOOT_DRVINFO(phandle_target) = { \t.name\t\t= "target", \t.plat\t= &dtv_phandle_target, \t.plat_size\t= sizeof(dtv_phandle_target), @@ -559,7 +559,7 @@ static struct dtd_source dtv_phandle_source = { \t\t\t{1, {12, 13}}, \t\t\t{4, {}},}, }; -U_BOOT_DEVICE(phandle_source) = { +U_BOOT_DRVINFO(phandle_source) = { \t.name\t\t= "source", \t.plat\t= &dtv_phandle_source, \t.plat_size\t= sizeof(dtv_phandle_source), @@ -571,7 +571,7 @@ static struct dtd_source dtv_phandle_source2 = { \t.cd_gpios\t\t= { \t\t\t{4, {}},}, }; -U_BOOT_DEVICE(phandle_source2) = { +U_BOOT_DRVINFO(phandle_source2) = { \t.name\t\t= "source", \t.plat\t= &dtv_phandle_source2, \t.plat_size\t= sizeof(dtv_phandle_source2), @@ -629,7 +629,7 @@ struct dtd_test3 { static struct dtd_test1 dtv_test1 = { \t.reg\t\t\t= {0x1234, 0x5678}, }; -U_BOOT_DEVICE(test1) = { +U_BOOT_DRVINFO(test1) = { \t.name\t\t= "test1", \t.plat\t= &dtv_test1, \t.plat_size\t= sizeof(dtv_test1), @@ -640,7 +640,7 @@ U_BOOT_DEVICE(test1) = { static struct dtd_test2 dtv_test2 = { \t.reg\t\t\t= {0x1234567890123456, 0x9876543210987654}, }; -U_BOOT_DEVICE(test2) = { +U_BOOT_DRVINFO(test2) = { \t.name\t\t= "test2", \t.plat\t= &dtv_test2, \t.plat_size\t= sizeof(dtv_test2), @@ -651,7 +651,7 @@ U_BOOT_DEVICE(test2) = { static struct dtd_test3 dtv_test3 = { \t.reg\t\t\t= {0x1234567890123456, 0x9876543210987654, 0x2, 0x3}, }; -U_BOOT_DEVICE(test3) = { +U_BOOT_DRVINFO(test3) = { \t.name\t\t= "test3", \t.plat\t= &dtv_test3, \t.plat_size\t= sizeof(dtv_test3), @@ -684,7 +684,7 @@ struct dtd_test2 { static struct dtd_test1 dtv_test1 = { \t.reg\t\t\t= {0x1234, 0x5678}, }; -U_BOOT_DEVICE(test1) = { +U_BOOT_DRVINFO(test1) = { \t.name\t\t= "test1", \t.plat\t= &dtv_test1, \t.plat_size\t= sizeof(dtv_test1), @@ -695,7 +695,7 @@ U_BOOT_DEVICE(test1) = { static struct dtd_test2 dtv_test2 = { \t.reg\t\t\t= {0x12345678, 0x98765432, 0x2, 0x3}, }; -U_BOOT_DEVICE(test2) = { +U_BOOT_DRVINFO(test2) = { \t.name\t\t= "test2", \t.plat\t= &dtv_test2, \t.plat_size\t= sizeof(dtv_test2), @@ -731,7 +731,7 @@ struct dtd_test3 { static struct dtd_test1 dtv_test1 = { \t.reg\t\t\t= {0x123400000000, 0x5678}, }; -U_BOOT_DEVICE(test1) = { +U_BOOT_DRVINFO(test1) = { \t.name\t\t= "test1", \t.plat\t= &dtv_test1, \t.plat_size\t= sizeof(dtv_test1), @@ -742,7 +742,7 @@ U_BOOT_DEVICE(test1) = { static struct dtd_test2 dtv_test2 = { \t.reg\t\t\t= {0x1234567890123456, 0x98765432}, }; -U_BOOT_DEVICE(test2) = { +U_BOOT_DRVINFO(test2) = { \t.name\t\t= "test2", \t.plat\t= &dtv_test2, \t.plat_size\t= sizeof(dtv_test2), @@ -753,7 +753,7 @@ U_BOOT_DEVICE(test2) = { static struct dtd_test3 dtv_test3 = { \t.reg\t\t\t= {0x1234567890123456, 0x98765432, 0x2, 0x3}, }; -U_BOOT_DEVICE(test3) = { +U_BOOT_DRVINFO(test3) = { \t.name\t\t= "test3", \t.plat\t= &dtv_test3, \t.plat_size\t= sizeof(dtv_test3), @@ -789,7 +789,7 @@ struct dtd_test3 { static struct dtd_test1 dtv_test1 = { \t.reg\t\t\t= {0x1234, 0x567800000000}, }; -U_BOOT_DEVICE(test1) = { +U_BOOT_DRVINFO(test1) = { \t.name\t\t= "test1", \t.plat\t= &dtv_test1, \t.plat_size\t= sizeof(dtv_test1), @@ -800,7 +800,7 @@ U_BOOT_DEVICE(test1) = { static struct dtd_test2 dtv_test2 = { \t.reg\t\t\t= {0x12345678, 0x9876543210987654}, }; -U_BOOT_DEVICE(test2) = { +U_BOOT_DRVINFO(test2) = { \t.name\t\t= "test2", \t.plat\t= &dtv_test2, \t.plat_size\t= sizeof(dtv_test2), @@ -811,7 +811,7 @@ U_BOOT_DEVICE(test2) = { static struct dtd_test3 dtv_test3 = { \t.reg\t\t\t= {0x12345678, 0x9876543210987654, 0x2, 0x3}, }; -U_BOOT_DEVICE(test3) = { +U_BOOT_DRVINFO(test3) = { \t.name\t\t= "test3", \t.plat\t= &dtv_test3, \t.plat_size\t= sizeof(dtv_test3), @@ -863,7 +863,7 @@ struct dtd_sandbox_spl_test { static struct dtd_sandbox_spl_test dtv_spl_test = { \t.intval\t\t\t= 0x1, }; -U_BOOT_DEVICE(spl_test) = { +U_BOOT_DRVINFO(spl_test) = { \t.name\t\t= "sandbox_spl_test", \t.plat\t= &dtv_spl_test, \t.plat_size\t= sizeof(dtv_spl_test), @@ -874,7 +874,7 @@ U_BOOT_DEVICE(spl_test) = { static struct dtd_sandbox_spl_test dtv_spl_test2 = { \t.intarray\t\t= 0x5, }; -U_BOOT_DEVICE(spl_test2) = { +U_BOOT_DRVINFO(spl_test2) = { \t.name\t\t= "sandbox_spl_test", \t.plat\t= &dtv_spl_test2, \t.plat_size\t= sizeof(dtv_spl_test2), -- cgit v1.2.3 From d1055d681af40963d1c4b1a517ae131f738983f4 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 28 Dec 2020 20:35:00 -0700 Subject: dtoc: Add a header comment to each generated file It is currently fairly obvious what the two generated files are for, but this will change as more are added. It is helpful for readers to describe the purpose of each file. Add a header commment field to OutputFile and use it to generate a comment at the top of each file. Signed-off-by: Simon Glass --- tools/dtoc/test_dtoc.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'tools/dtoc/test_dtoc.py') diff --git a/tools/dtoc/test_dtoc.py b/tools/dtoc/test_dtoc.py index dbd4e3bf1d4..2e4dd2b24d2 100755 --- a/tools/dtoc/test_dtoc.py +++ b/tools/dtoc/test_dtoc.py @@ -32,7 +32,8 @@ OUR_PATH = os.path.dirname(os.path.realpath(__file__)) HEADER = '''/* * DO NOT MODIFY * - * This file was generated by dtoc from a .dtb (device tree binary) file. + * Defines the structs used to hold devicetree data. + * This was generated by dtoc from a .dtb (device tree binary) file. */ #include @@ -41,7 +42,8 @@ HEADER = '''/* C_HEADER = '''/* * DO NOT MODIFY * - * This file was generated by dtoc from a .dtb (device tree binary) file. + * Declares the U_BOOT_DRIVER() records and platform data. + * This was generated by dtoc from a .dtb (device tree binary) file. */ /* Allow use of U_BOOT_DRVINFO() in this file */ -- cgit v1.2.3 From f31fa99a9ed92c223fbf56e07eae57e7bdea19ae Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 28 Dec 2020 20:35:01 -0700 Subject: dtoc: Rename dt-platdata.c to dt-plat.c Use this new name to be consistent with the rest of U-Boot, which talks about 'plat' for the platform data, which is what this file holds. Signed-off-by: Simon Glass --- tools/dtoc/test_dtoc.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tools/dtoc/test_dtoc.py') diff --git a/tools/dtoc/test_dtoc.py b/tools/dtoc/test_dtoc.py index 2e4dd2b24d2..d56cd311fa1 100755 --- a/tools/dtoc/test_dtoc.py +++ b/tools/dtoc/test_dtoc.py @@ -47,7 +47,7 @@ C_HEADER = '''/* */ /* Allow use of U_BOOT_DRVINFO() in this file */ -#define DT_PLATDATA_C +#define DT_PLAT_C #include #include @@ -979,5 +979,5 @@ U_BOOT_DRVINFO(spl_test2) = { leafs = set(os.path.basename(fname) for fname in fnames) self.assertEqual( - {'dt-structs-gen.h', 'source.dts', 'dt-platdata.c', 'source.dtb'}, + {'dt-structs-gen.h', 'source.dts', 'dt-plat.c', 'source.dtb'}, leafs) -- cgit v1.2.3 From 1e0f3f46bd9afed12b331cbe945abd4046250ed5 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 28 Dec 2020 20:35:03 -0700 Subject: dtoc: Allow specifying the base directory for tests The base directory of U-Boot, where the source is, it currently calculated from the directory of the dtb_platdata.py script. If this is installed elsewhere that will not work. Also it is inconvenient for tests. Add a parameter to allow specifying this base directory. To test this, pass a temporary directory with some files in it and check that they are passed to scan_driver(). Signed-off-by: Simon Glass --- tools/dtoc/test_dtoc.py | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'tools/dtoc/test_dtoc.py') diff --git a/tools/dtoc/test_dtoc.py b/tools/dtoc/test_dtoc.py index d56cd311fa1..c517fd5c4ef 100755 --- a/tools/dtoc/test_dtoc.py +++ b/tools/dtoc/test_dtoc.py @@ -12,9 +12,11 @@ tool. import collections import glob import os +import shutil import struct import tempfile import unittest +from unittest import mock from dtb_platdata import conv_name_to_c from dtb_platdata import get_compat_name @@ -981,3 +983,35 @@ U_BOOT_DRVINFO(spl_test2) = { self.assertEqual( {'dt-structs-gen.h', 'source.dts', 'dt-plat.c', 'source.dtb'}, leafs) + + def test_scan_dirs(self): + """Test scanning of source directories""" + def add_file(fname): + pathname = os.path.join(indir, fname) + dirname = os.path.dirname(pathname) + os.makedirs(dirname, exist_ok=True) + tools.WriteFile(pathname, '', binary=False) + fname_list.append(pathname) + + try: + outdir = tools.GetOutputDir() + indir = tempfile.mkdtemp(prefix='dtoc.') + dtb_file = get_dtb_file('dtoc_test_simple.dts') + + fname_list = [] + add_file('fname.c') + add_file('dir/fname2.c') + + # Mock out scan_driver and check that it is called with the + # expected files + with mock.patch.object(dtb_platdata.DtbPlatdata, "scan_driver") \ + as mocked: + dtb_platdata.run_steps(['all'], dtb_file, False, None, [outdir], + True, basedir=indir) + self.assertEqual(2, len(mocked.mock_calls)) + self.assertEqual(mock.call(fname_list[0]), + mocked.mock_calls[0]) + self.assertEqual(mock.call(fname_list[1]), + mocked.mock_calls[1]) + finally: + shutil.rmtree(indir) -- cgit v1.2.3 From 9eca08dc5986c9e00bb68a4529ec9404a282bc57 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 28 Dec 2020 20:35:04 -0700 Subject: dtoc: Output nodes in order Previously we had to worry about nodes being output before those that they depended on, thus causing build errors. So the current algorithm is careful to output nodes in the right order. We now use a different method for outputting phandles that does not involve pointers. Also we plan to add a 'declarations' header file to declare all drivers as 'extern'. Update the code to drop the dependency checking and output in a simple loop. This makes the output easier to follow since drivers are in order of thier indices (0, 1, ...), which is also the order it appears in in the linker list. Signed-off-by: Simon Glass --- tools/dtoc/test_dtoc.py | 64 ++++++++++++++++++++++++------------------------- 1 file changed, 32 insertions(+), 32 deletions(-) (limited to 'tools/dtoc/test_dtoc.py') diff --git a/tools/dtoc/test_dtoc.py b/tools/dtoc/test_dtoc.py index c517fd5c4ef..f17d2e4b45d 100755 --- a/tools/dtoc/test_dtoc.py +++ b/tools/dtoc/test_dtoc.py @@ -422,17 +422,6 @@ U_BOOT_DRVINFO(phandle3_target) = { \t.parent_idx\t= -1, }; -/* Node /phandle-target index 4 */ -static struct dtd_target dtv_phandle_target = { -\t.intval\t\t\t= 0x0, -}; -U_BOOT_DRVINFO(phandle_target) = { -\t.name\t\t= "target", -\t.plat\t= &dtv_phandle_target, -\t.plat_size\t= sizeof(dtv_phandle_target), -\t.parent_idx\t= -1, -}; - /* Node /phandle-source index 2 */ static struct dtd_source dtv_phandle_source = { \t.clocks\t\t\t= { @@ -460,6 +449,17 @@ U_BOOT_DRVINFO(phandle_source2) = { \t.parent_idx\t= -1, }; +/* Node /phandle-target index 4 */ +static struct dtd_target dtv_phandle_target = { +\t.intval\t\t\t= 0x0, +}; +U_BOOT_DRVINFO(phandle_target) = { +\t.name\t\t= "target", +\t.plat\t= &dtv_phandle_target, +\t.plat_size\t= sizeof(dtv_phandle_target), +\t.parent_idx\t= -1, +}; + void dm_populate_phandle_data(void) { } ''', data) @@ -488,16 +488,6 @@ struct dtd_target { with open(output) as infile: data = infile.read() self._check_strings(C_HEADER + ''' -/* Node /phandle-target index 1 */ -static struct dtd_target dtv_phandle_target = { -}; -U_BOOT_DRVINFO(phandle_target) = { -\t.name\t\t= "target", -\t.plat\t= &dtv_phandle_target, -\t.plat_size\t= sizeof(dtv_phandle_target), -\t.parent_idx\t= -1, -}; - /* Node /phandle-source2 index 0 */ static struct dtd_source dtv_phandle_source2 = { \t.clocks\t\t\t= { @@ -510,6 +500,16 @@ U_BOOT_DRVINFO(phandle_source2) = { \t.parent_idx\t= -1, }; +/* Node /phandle-target index 1 */ +static struct dtd_target dtv_phandle_target = { +}; +U_BOOT_DRVINFO(phandle_target) = { +\t.name\t\t= "target", +\t.plat\t= &dtv_phandle_target, +\t.plat_size\t= sizeof(dtv_phandle_target), +\t.parent_idx\t= -1, +}; + void dm_populate_phandle_data(void) { } ''', data) @@ -544,17 +544,6 @@ U_BOOT_DRVINFO(phandle3_target) = { \t.parent_idx\t= -1, }; -/* Node /phandle-target index 4 */ -static struct dtd_target dtv_phandle_target = { -\t.intval\t\t\t= 0x0, -}; -U_BOOT_DRVINFO(phandle_target) = { -\t.name\t\t= "target", -\t.plat\t= &dtv_phandle_target, -\t.plat_size\t= sizeof(dtv_phandle_target), -\t.parent_idx\t= -1, -}; - /* Node /phandle-source index 2 */ static struct dtd_source dtv_phandle_source = { \t.cd_gpios\t\t= { @@ -582,6 +571,17 @@ U_BOOT_DRVINFO(phandle_source2) = { \t.parent_idx\t= -1, }; +/* Node /phandle-target index 4 */ +static struct dtd_target dtv_phandle_target = { +\t.intval\t\t\t= 0x0, +}; +U_BOOT_DRVINFO(phandle_target) = { +\t.name\t\t= "target", +\t.plat\t= &dtv_phandle_target, +\t.plat_size\t= sizeof(dtv_phandle_target), +\t.parent_idx\t= -1, +}; + void dm_populate_phandle_data(void) { } ''', data) -- cgit v1.2.3 From d960f0db289144a80553e4d226d5dd145d63926a Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 28 Dec 2020 20:35:05 -0700 Subject: dtoc: Drop dm_populate_phandle_data() This has not been needed since parent information was added and we started using indicies for references to other drivers instead of pointers. It was kept around in the expectation that it might be needed later. However with the latest updates, it doesn't seem likely that we'll need this in the foreseeable future. Drop dm_populate_phandle_data() from dtoc and driver model. Signed-off-by: Simon Glass --- tools/dtoc/test_dtoc.py | 29 +++++++---------------------- 1 file changed, 7 insertions(+), 22 deletions(-) (limited to 'tools/dtoc/test_dtoc.py') diff --git a/tools/dtoc/test_dtoc.py b/tools/dtoc/test_dtoc.py index f17d2e4b45d..bcbf58c45bc 100755 --- a/tools/dtoc/test_dtoc.py +++ b/tools/dtoc/test_dtoc.py @@ -56,10 +56,6 @@ C_HEADER = '''/* #include ''' -C_EMPTY_POPULATE_PHANDLE_DATA = '''void dm_populate_phandle_data(void) { -} -''' - # This is a test so is allowed to access private things in the module it is # testing # pylint: disable=W0212 @@ -190,8 +186,7 @@ class TestDtoc(unittest.TestCase): self.run_test(['platdata'], dtb_file, output) with open(output) as infile: lines = infile.read().splitlines() - self.assertEqual(C_HEADER.splitlines() + [''] + - C_EMPTY_POPULATE_PHANDLE_DATA.splitlines(), lines) + self.assertEqual(C_HEADER.splitlines() + [''], lines) struct_text = HEADER + ''' struct dtd_sandbox_i2c_test { @@ -289,7 +284,7 @@ U_BOOT_DRVINFO(spl_test3) = { \t.parent_idx\t= -1, }; -''' + C_EMPTY_POPULATE_PHANDLE_DATA +''' def test_simple(self): """Test output from some simple nodes with various types of data""" @@ -344,8 +339,6 @@ U_BOOT_DRVINFO(gpios_at_0) = { \t.parent_idx\t= -1, }; -void dm_populate_phandle_data(void) { -} ''', data) def test_invalid_driver(self): @@ -376,8 +369,6 @@ U_BOOT_DRVINFO(spl_test) = { \t.parent_idx\t= -1, }; -void dm_populate_phandle_data(void) { -} ''', data) def test_phandle(self): @@ -460,8 +451,6 @@ U_BOOT_DRVINFO(phandle_target) = { \t.parent_idx\t= -1, }; -void dm_populate_phandle_data(void) { -} ''', data) def test_phandle_single(self): @@ -510,8 +499,6 @@ U_BOOT_DRVINFO(phandle_target) = { \t.parent_idx\t= -1, }; -void dm_populate_phandle_data(void) { -} ''', data) def test_phandle_cd_gpio(self): @@ -582,8 +569,6 @@ U_BOOT_DRVINFO(phandle_target) = { \t.parent_idx\t= -1, }; -void dm_populate_phandle_data(void) { -} ''', data) def test_phandle_bad(self): @@ -662,7 +647,7 @@ U_BOOT_DRVINFO(test3) = { \t.parent_idx\t= -1, }; -''' + C_EMPTY_POPULATE_PHANDLE_DATA, data) +''', data) def test_addresses32(self): """Test output from a node with a 'reg' property with na=1, ns=1""" @@ -706,7 +691,7 @@ U_BOOT_DRVINFO(test2) = { \t.parent_idx\t= -1, }; -''' + C_EMPTY_POPULATE_PHANDLE_DATA, data) +''', data) def test_addresses64_32(self): """Test output from a node with a 'reg' property with na=2, ns=1""" @@ -764,7 +749,7 @@ U_BOOT_DRVINFO(test3) = { \t.parent_idx\t= -1, }; -''' + C_EMPTY_POPULATE_PHANDLE_DATA, data) +''', data) def test_addresses32_64(self): """Test output from a node with a 'reg' property with na=1, ns=2""" @@ -822,7 +807,7 @@ U_BOOT_DRVINFO(test3) = { \t.parent_idx\t= -1, }; -''' + C_EMPTY_POPULATE_PHANDLE_DATA, data) +''', data) def test_bad_reg(self): """Test that a reg property with an invalid type generates an error""" @@ -885,7 +870,7 @@ U_BOOT_DRVINFO(spl_test2) = { \t.parent_idx\t= -1, }; -''' + C_EMPTY_POPULATE_PHANDLE_DATA, data) +''', data) def test_stdout(self): """Test output to stdout""" -- cgit v1.2.3 From a542a70c2256e2250dfb876fd394e967d6a47156 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 28 Dec 2020 20:35:06 -0700 Subject: dtoc: Split source-code scanning to a separate file Before expanding the scanning features any more, move this into a separate file. This will make it easier to maintain in the future. In particular, it reduces the size of dtb_platdata.py and allows us to add tests specifically for scanning, without going through that file. The pieces moved are the Driver class, the scanning code and the various naming functions, since they mostly depend on the scanning results. So far there is are no separate tests for src_scan. These will be added as new functionality appears. This introduces no functional change. Signed-off-by: Simon Glass --- tools/dtoc/test_dtoc.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'tools/dtoc/test_dtoc.py') diff --git a/tools/dtoc/test_dtoc.py b/tools/dtoc/test_dtoc.py index bcbf58c45bc..8e8dd847c10 100755 --- a/tools/dtoc/test_dtoc.py +++ b/tools/dtoc/test_dtoc.py @@ -18,13 +18,14 @@ import tempfile import unittest from unittest import mock -from dtb_platdata import conv_name_to_c -from dtb_platdata import get_compat_name from dtb_platdata import get_value from dtb_platdata import tab_to from dtoc import dtb_platdata from dtoc import fdt from dtoc import fdt_util +from dtoc import src_scan +from dtoc.src_scan import conv_name_to_c +from dtoc.src_scan import get_compat_name from patman import test_util from patman import tools @@ -933,9 +934,9 @@ U_BOOT_DRVINFO(spl_test2) = { def test_driver(self): """Test the Driver class""" - drv1 = dtb_platdata.Driver('fred') - drv2 = dtb_platdata.Driver('mary') - drv3 = dtb_platdata.Driver('fred') + drv1 = src_scan.Driver('fred') + drv2 = src_scan.Driver('mary') + drv3 = src_scan.Driver('fred') self.assertEqual("Driver(name='fred')", str(drv1)) self.assertEqual(drv1, drv3) self.assertNotEqual(drv1, drv2) @@ -989,8 +990,7 @@ U_BOOT_DRVINFO(spl_test2) = { # Mock out scan_driver and check that it is called with the # expected files - with mock.patch.object(dtb_platdata.DtbPlatdata, "scan_driver") \ - as mocked: + with mock.patch.object(src_scan.Scanner, "scan_driver") as mocked: dtb_platdata.run_steps(['all'], dtb_file, False, None, [outdir], True, basedir=indir) self.assertEqual(2, len(mocked.mock_calls)) -- cgit v1.2.3 From 10ea9c0b059c37e6b2026fe1334d1d57c465984d Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 28 Dec 2020 20:35:07 -0700 Subject: dtoc: Move src_scan tests to a separate file Move the tests related to scanning into their own class, updating them to avoid using dtb_platdata as a pass-through. Signed-off-by: Simon Glass --- tools/dtoc/test_dtoc.py | 73 ------------------------------------------------- 1 file changed, 73 deletions(-) (limited to 'tools/dtoc/test_dtoc.py') diff --git a/tools/dtoc/test_dtoc.py b/tools/dtoc/test_dtoc.py index 8e8dd847c10..d961d67b8fc 100755 --- a/tools/dtoc/test_dtoc.py +++ b/tools/dtoc/test_dtoc.py @@ -12,18 +12,14 @@ tool. import collections import glob import os -import shutil import struct -import tempfile import unittest -from unittest import mock from dtb_platdata import get_value from dtb_platdata import tab_to from dtoc import dtb_platdata from dtoc import fdt from dtoc import fdt_util -from dtoc import src_scan from dtoc.src_scan import conv_name_to_c from dtoc.src_scan import get_compat_name from patman import test_util @@ -904,44 +900,6 @@ U_BOOT_DRVINFO(spl_test2) = { self.assertIn("Unknown command 'invalid-cmd': (use: platdata, struct)", str(exc.exception)) - @staticmethod - def test_scan_drivers(): - """Test running dtoc with additional drivers to scan""" - dtb_file = get_dtb_file('dtoc_test_simple.dts') - output = tools.GetOutputFilename('output') - with test_util.capture_sys_output() as _: - dtb_platdata.run_steps( - ['struct'], dtb_file, False, output, [], True, - [None, '', 'tools/dtoc/dtoc_test_scan_drivers.cxx']) - - @staticmethod - def test_unicode_error(): - """Test running dtoc with an invalid unicode file - - To be able to perform this test without adding a weird text file which - would produce issues when using checkpatch.pl or patman, generate the - file at runtime and then process it. - """ - dtb_file = get_dtb_file('dtoc_test_simple.dts') - output = tools.GetOutputFilename('output') - driver_fn = '/tmp/' + next(tempfile._get_candidate_names()) - with open(driver_fn, 'wb+') as fout: - fout.write(b'\x81') - - with test_util.capture_sys_output() as _: - dtb_platdata.run_steps(['struct'], dtb_file, False, output, [], - True, [driver_fn]) - - def test_driver(self): - """Test the Driver class""" - drv1 = src_scan.Driver('fred') - drv2 = src_scan.Driver('mary') - drv3 = src_scan.Driver('fred') - self.assertEqual("Driver(name='fred')", str(drv1)) - self.assertEqual(drv1, drv3) - self.assertNotEqual(drv1, drv2) - self.assertNotEqual(drv2, drv3) - def test_output_conflict(self): """Test a conflict between and output dirs and output file""" with self.assertRaises(ValueError) as exc: @@ -969,34 +927,3 @@ U_BOOT_DRVINFO(spl_test2) = { self.assertEqual( {'dt-structs-gen.h', 'source.dts', 'dt-plat.c', 'source.dtb'}, leafs) - - def test_scan_dirs(self): - """Test scanning of source directories""" - def add_file(fname): - pathname = os.path.join(indir, fname) - dirname = os.path.dirname(pathname) - os.makedirs(dirname, exist_ok=True) - tools.WriteFile(pathname, '', binary=False) - fname_list.append(pathname) - - try: - outdir = tools.GetOutputDir() - indir = tempfile.mkdtemp(prefix='dtoc.') - dtb_file = get_dtb_file('dtoc_test_simple.dts') - - fname_list = [] - add_file('fname.c') - add_file('dir/fname2.c') - - # Mock out scan_driver and check that it is called with the - # expected files - with mock.patch.object(src_scan.Scanner, "scan_driver") as mocked: - dtb_platdata.run_steps(['all'], dtb_file, False, None, [outdir], - True, basedir=indir) - self.assertEqual(2, len(mocked.mock_calls)) - self.assertEqual(mock.call(fname_list[0]), - mocked.mock_calls[0]) - self.assertEqual(mock.call(fname_list[1]), - mocked.mock_calls[1]) - finally: - shutil.rmtree(indir) -- cgit v1.2.3