From aab660fe18ac24ee859a203f517f939685af5e10 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 12 Nov 2017 21:52:17 -0700 Subject: [PATCH] dtoc: Fix up tests The tool has changed slightly since it was originally written. Update the tests to suit. Signed-off-by: Simon Glass --- tools/dtoc/test_dtoc.py | 82 +++++++++++++++++++---------------------- 1 file changed, 37 insertions(+), 45 deletions(-) diff --git a/tools/dtoc/test_dtoc.py b/tools/dtoc/test_dtoc.py index cc009b2a25..41ed80e6da 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 +#include ''' + +C_HEADER = '''/* + * DO NOT MODIFY + * + * This file was generated by dtoc from a .dtb (device tree binary) file. + */ + +#include +#include +#include +''' + + 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 ', '#include '], 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 ', '#include ', - '#include ', ''], 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 -#include + 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 -#include -#include - + 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 -#include + 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 -#include -#include - + 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 -#include + 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 -#include -#include - + 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 -#include + 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 -#include -#include - + 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 -#include + 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 -#include -#include - + 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 -#include + 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 -#include -#include - + 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 -#include + 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 -#include -#include - + self.assertEqual(C_HEADER + ''' static struct dtd_test1 dtv_test1 = { \t.reg\t\t\t= {0x1234, 0x567800000000}, }; -- 2.39.5