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
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"""
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 {
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,
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];
};
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,
};
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;
};
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,
};
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];
};
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},
};
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];
};
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},
};
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];
};
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},
};
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];
};
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},
};