diff options
author | Simon Glass | 2017-11-12 21:52:17 -0700 |
---|---|---|
committer | Simon Glass | 2017-11-22 18:05:38 -0700 |
commit | aab660fe18ac24ee859a203f517f939685af5e10 (patch) | |
tree | 99224572d1717ab6ce088f6b6f843b6ea5da7355 /tools | |
parent | 251f5867c96138fdc6987e5659d15726d1b0329f (diff) |
dtoc: Fix up tests
The tool has changed slightly since it was originally written. Update the
tests to suit.
Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/dtoc/test_dtoc.py | 82 |
1 files changed, 37 insertions, 45 deletions
diff --git a/tools/dtoc/test_dtoc.py b/tools/dtoc/test_dtoc.py index cc009b2a256..41ed80e6dad 100644 --- a/tools/dtoc/test_dtoc.py +++ b/tools/dtoc/test_dtoc.py @@ -26,6 +26,27 @@ import tools 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. + */ + +#include <stdbool.h> +#include <libfdt.h>''' + +C_HEADER = '''/* + * DO NOT MODIFY + * + * This file was generated by dtoc from a .dtb (device tree binary) file. + */ + +#include <common.h> +#include <dm.h> +#include <dt-structs.h> +''' + + def get_dtb_file(dts_fname): """Compile a .dts file to a .dtb @@ -104,13 +125,12 @@ class TestDtoc(unittest.TestCase): dtb_platdata.run_steps(['struct'], dtb_file, False, output) with open(output) as infile: lines = infile.read().splitlines() - self.assertEqual(['#include <stdbool.h>', '#include <libfdt.h>'], lines) + self.assertEqual(HEADER.splitlines(), lines) dtb_platdata.run_steps(['platdata'], dtb_file, False, output) with open(output) as infile: lines = infile.read().splitlines() - self.assertEqual(['#include <common.h>', '#include <dm.h>', - '#include <dt-structs.h>', ''], lines) + self.assertEqual(C_HEADER.splitlines() + [''], lines) def test_simple(self): """Test output from some simple nodes with various types of data""" @@ -119,8 +139,7 @@ class TestDtoc(unittest.TestCase): dtb_platdata.run_steps(['struct'], dtb_file, False, output) with open(output) as infile: data = infile.read() - self.assertEqual('''#include <stdbool.h> -#include <libfdt.h> + self.assertEqual(HEADER + ''' struct dtd_sandbox_i2c_test { }; struct dtd_sandbox_pmic_test { @@ -144,10 +163,7 @@ struct dtd_sandbox_spl_test_2 { dtb_platdata.run_steps(['platdata'], dtb_file, False, output) with open(output) as infile: data = infile.read() - self.assertEqual('''#include <common.h> -#include <dm.h> -#include <dt-structs.h> - + self.assertEqual(C_HEADER + ''' static struct dtd_sandbox_spl_test dtv_spl_test = { \t.bytearray\t\t= {0x6, 0x0, 0x0}, \t.byteval\t\t= 0x5, @@ -225,8 +241,7 @@ U_BOOT_DEVICE(pmic_at_9) = { dtb_platdata.run_steps(['struct'], dtb_file, False, output) with open(output) as infile: data = infile.read() - self.assertEqual('''#include <stdbool.h> -#include <libfdt.h> + self.assertEqual(HEADER + ''' struct dtd_source { \tstruct phandle_2_arg clocks[4]; }; @@ -238,10 +253,7 @@ struct dtd_target { dtb_platdata.run_steps(['platdata'], dtb_file, False, output) with open(output) as infile: data = infile.read() - self.assertEqual('''#include <common.h> -#include <dm.h> -#include <dt-structs.h> - + self.assertEqual(C_HEADER + ''' static struct dtd_target dtv_phandle_target = { \t.intval\t\t\t= 0x0, }; @@ -291,8 +303,7 @@ U_BOOT_DEVICE(phandle_source) = { dtb_platdata.run_steps(['struct'], dtb_file, False, output) with open(output) as infile: data = infile.read() - self.assertEqual('''#include <stdbool.h> -#include <libfdt.h> + self.assertEqual(HEADER + ''' struct dtd_compat1 { \tfdt32_t\t\tintval; }; @@ -303,10 +314,7 @@ struct dtd_compat1 { dtb_platdata.run_steps(['platdata'], dtb_file, False, output) with open(output) as infile: data = infile.read() - self.assertEqual('''#include <common.h> -#include <dm.h> -#include <dt-structs.h> - + self.assertEqual(C_HEADER + ''' static struct dtd_compat1 dtv_spl_test = { \t.intval\t\t\t= 0x1, }; @@ -325,8 +333,7 @@ U_BOOT_DEVICE(spl_test) = { dtb_platdata.run_steps(['struct'], dtb_file, False, output) with open(output) as infile: data = infile.read() - self.assertEqual('''#include <stdbool.h> -#include <libfdt.h> + self.assertEqual(HEADER + ''' struct dtd_test1 { \tfdt64_t\t\treg[2]; }; @@ -341,10 +348,7 @@ struct dtd_test3 { dtb_platdata.run_steps(['platdata'], dtb_file, False, output) with open(output) as infile: data = infile.read() - self.assertEqual('''#include <common.h> -#include <dm.h> -#include <dt-structs.h> - + self.assertEqual(C_HEADER + ''' static struct dtd_test1 dtv_test1 = { \t.reg\t\t\t= {0x1234, 0x5678}, }; @@ -381,8 +385,7 @@ U_BOOT_DEVICE(test3) = { dtb_platdata.run_steps(['struct'], dtb_file, False, output) with open(output) as infile: data = infile.read() - self.assertEqual('''#include <stdbool.h> -#include <libfdt.h> + self.assertEqual(HEADER + ''' struct dtd_test1 { \tfdt32_t\t\treg[2]; }; @@ -394,10 +397,7 @@ struct dtd_test2 { dtb_platdata.run_steps(['platdata'], dtb_file, False, output) with open(output) as infile: data = infile.read() - self.assertEqual('''#include <common.h> -#include <dm.h> -#include <dt-structs.h> - + self.assertEqual(C_HEADER + ''' static struct dtd_test1 dtv_test1 = { \t.reg\t\t\t= {0x1234, 0x5678}, }; @@ -425,8 +425,7 @@ U_BOOT_DEVICE(test2) = { dtb_platdata.run_steps(['struct'], dtb_file, False, output) with open(output) as infile: data = infile.read() - self.assertEqual('''#include <stdbool.h> -#include <libfdt.h> + self.assertEqual(HEADER + ''' struct dtd_test1 { \tfdt64_t\t\treg[2]; }; @@ -441,10 +440,7 @@ struct dtd_test3 { dtb_platdata.run_steps(['platdata'], dtb_file, False, output) with open(output) as infile: data = infile.read() - self.assertEqual('''#include <common.h> -#include <dm.h> -#include <dt-structs.h> - + self.assertEqual(C_HEADER + ''' static struct dtd_test1 dtv_test1 = { \t.reg\t\t\t= {0x123400000000, 0x5678}, }; @@ -481,8 +477,7 @@ U_BOOT_DEVICE(test3) = { dtb_platdata.run_steps(['struct'], dtb_file, False, output) with open(output) as infile: data = infile.read() - self.assertEqual('''#include <stdbool.h> -#include <libfdt.h> + self.assertEqual(HEADER + ''' struct dtd_test1 { \tfdt64_t\t\treg[2]; }; @@ -497,10 +492,7 @@ struct dtd_test3 { dtb_platdata.run_steps(['platdata'], dtb_file, False, output) with open(output) as infile: data = infile.read() - self.assertEqual('''#include <common.h> -#include <dm.h> -#include <dt-structs.h> - + self.assertEqual(C_HEADER + ''' static struct dtd_test1 dtv_test1 = { \t.reg\t\t\t= {0x1234, 0x567800000000}, }; |