2 # SPDX-License-Identifier: GPL-2.0+
3 # Copyright (c) 2012 The Chromium OS Authors.
6 """Tests for the dtb_platdata module
8 This includes unit tests for some functions and functional tests for the dtoc
18 from dtoc import dtb_platdata
19 from dtb_platdata import conv_name_to_c
20 from dtb_platdata import get_compat_name
21 from dtb_platdata import get_value
22 from dtb_platdata import tab_to
24 from dtoc import fdt_util
25 from patman import test_util
26 from patman import tools
28 our_path = os.path.dirname(os.path.realpath(__file__))
34 * This file was generated by dtoc from a .dtb (device tree binary) file.
38 #include <linux/libfdt.h>'''
43 * This file was generated by dtoc from a .dtb (device tree binary) file.
48 #include <dt-structs.h>
53 def get_dtb_file(dts_fname, capture_stderr=False):
54 """Compile a .dts file to a .dtb
57 dts_fname: Filename of .dts file in the current directory
58 capture_stderr: True to capture and discard stderr output
61 Filename of compiled file in output directory
63 return fdt_util.EnsureCompiled(os.path.join(our_path, dts_fname),
64 capture_stderr=capture_stderr)
67 class TestDtoc(unittest.TestCase):
71 tools.PrepareOutputDir(None)
74 def tearDownClass(cls):
75 tools._RemoveOutputDir()
77 def _WritePythonString(self, fname, data):
78 """Write a string with tabs expanded as done in this Python file
81 fname: Filename to write to
82 data: Raw string to convert
84 data = data.replace('\t', '\\t')
85 with open(fname, 'w') as fd:
88 def _CheckStrings(self, expected, actual):
89 """Check that a string matches its expected value
91 If the strings do not match, they are written to the /tmp directory in
92 the same Python format as is used here in the test. This allows for
93 easy comparison and update of the tests.
96 expected: Expected string
99 if expected != actual:
100 self._WritePythonString('/tmp/binman.expected', expected)
101 self._WritePythonString('/tmp/binman.actual', actual)
102 print('Failures written to /tmp/binman.{expected,actual}')
103 self.assertEquals(expected, actual)
106 def run_test(self, args, dtb_file, output):
107 dtb_platdata.run_steps(args, dtb_file, False, output, True)
110 """Test conversion of device tree names to C identifiers"""
111 self.assertEqual('serial_at_0x12', conv_name_to_c('serial@0x12'))
112 self.assertEqual('vendor_clock_frequency',
113 conv_name_to_c('vendor,clock-frequency'))
114 self.assertEqual('rockchip_rk3399_sdhci_5_1',
115 conv_name_to_c('rockchip,rk3399-sdhci-5.1'))
117 def test_tab_to(self):
118 """Test operation of tab_to() function"""
119 self.assertEqual('fred ', tab_to(0, 'fred'))
120 self.assertEqual('fred\t', tab_to(1, 'fred'))
121 self.assertEqual('fred was here ', tab_to(1, 'fred was here'))
122 self.assertEqual('fred was here\t\t', tab_to(3, 'fred was here'))
123 self.assertEqual('exactly8 ', tab_to(1, 'exactly8'))
124 self.assertEqual('exactly8\t', tab_to(2, 'exactly8'))
126 def test_get_value(self):
127 """Test operation of get_value() function"""
128 self.assertEqual('0x45',
129 get_value(fdt.TYPE_INT, struct.pack('>I', 0x45)))
130 self.assertEqual('0x45',
131 get_value(fdt.TYPE_BYTE, struct.pack('<I', 0x45)))
132 self.assertEqual('0x0',
133 get_value(fdt.TYPE_BYTE, struct.pack('>I', 0x45)))
134 self.assertEqual('"test"', get_value(fdt.TYPE_STRING, 'test'))
135 self.assertEqual('true', get_value(fdt.TYPE_BOOL, None))
137 def test_get_compat_name(self):
138 """Test operation of get_compat_name() function"""
139 Prop = collections.namedtuple('Prop', ['value'])
140 Node = collections.namedtuple('Node', ['props'])
142 prop = Prop(['rockchip,rk3399-sdhci-5.1', 'arasan,sdhci-5.1'])
143 node = Node({'compatible': prop})
144 self.assertEqual(('rockchip_rk3399_sdhci_5_1', ['arasan_sdhci_5_1']),
145 get_compat_name(node))
147 prop = Prop(['rockchip,rk3399-sdhci-5.1'])
148 node = Node({'compatible': prop})
149 self.assertEqual(('rockchip_rk3399_sdhci_5_1', []),
150 get_compat_name(node))
152 prop = Prop(['rockchip,rk3399-sdhci-5.1', 'arasan,sdhci-5.1', 'third'])
153 node = Node({'compatible': prop})
154 self.assertEqual(('rockchip_rk3399_sdhci_5_1',
155 ['arasan_sdhci_5_1', 'third']),
156 get_compat_name(node))
158 def test_empty_file(self):
159 """Test output from a device tree file with no nodes"""
160 dtb_file = get_dtb_file('dtoc_test_empty.dts')
161 output = tools.GetOutputFilename('output')
162 self.run_test(['struct'], dtb_file, output)
163 with open(output) as infile:
164 lines = infile.read().splitlines()
165 self.assertEqual(HEADER.splitlines(), lines)
167 self.run_test(['platdata'], dtb_file, output)
168 with open(output) as infile:
169 lines = infile.read().splitlines()
170 self.assertEqual(C_HEADER.splitlines() + [''], lines)
172 def test_simple(self):
173 """Test output from some simple nodes with various types of data"""
174 dtb_file = get_dtb_file('dtoc_test_simple.dts')
175 output = tools.GetOutputFilename('output')
176 self.run_test(['struct'], dtb_file, output)
177 with open(output) as infile:
179 self._CheckStrings(HEADER + '''
180 struct dtd_sandbox_i2c_test {
182 struct dtd_sandbox_pmic_test {
186 struct dtd_sandbox_spl_test {
188 \tunsigned char\tbytearray[3];
189 \tunsigned char\tbyteval;
190 \tfdt32_t\t\tintarray[4];
192 \tunsigned char\tlongbytearray[9];
193 \tunsigned char\tnotstring[5];
194 \tconst char *\tstringarray[3];
195 \tconst char *\tstringval;
197 struct dtd_sandbox_spl_test_2 {
201 self.run_test(['platdata'], dtb_file, output)
202 with open(output) as infile:
204 self._CheckStrings(C_HEADER + '''
205 static const struct dtd_sandbox_spl_test dtv_spl_test = {
206 \t.boolval\t\t= true,
207 \t.bytearray\t\t= {0x6, 0x0, 0x0},
209 \t.intarray\t\t= {0x2, 0x3, 0x4, 0x0},
210 \t.intval\t\t\t= 0x1,
211 \t.longbytearray\t\t= {0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf, 0x10,
213 \t.notstring\t\t= {0x20, 0x21, 0x22, 0x10, 0x0},
214 \t.stringarray\t\t= {"multi-word", "message", ""},
215 \t.stringval\t\t= "message",
217 U_BOOT_DEVICE(spl_test) = {
218 \t.name\t\t= "sandbox_spl_test",
219 \t.platdata\t= &dtv_spl_test,
220 \t.platdata_size\t= sizeof(dtv_spl_test),
223 static const struct dtd_sandbox_spl_test dtv_spl_test2 = {
224 \t.bytearray\t\t= {0x1, 0x23, 0x34},
226 \t.intarray\t\t= {0x5, 0x0, 0x0, 0x0},
227 \t.intval\t\t\t= 0x3,
228 \t.longbytearray\t\t= {0x9, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
230 \t.stringarray\t\t= {"another", "multi-word", "message"},
231 \t.stringval\t\t= "message2",
233 U_BOOT_DEVICE(spl_test2) = {
234 \t.name\t\t= "sandbox_spl_test",
235 \t.platdata\t= &dtv_spl_test2,
236 \t.platdata_size\t= sizeof(dtv_spl_test2),
239 static const struct dtd_sandbox_spl_test dtv_spl_test3 = {
240 \t.stringarray\t\t= {"one", "", ""},
242 U_BOOT_DEVICE(spl_test3) = {
243 \t.name\t\t= "sandbox_spl_test",
244 \t.platdata\t= &dtv_spl_test3,
245 \t.platdata_size\t= sizeof(dtv_spl_test3),
248 static const struct dtd_sandbox_spl_test_2 dtv_spl_test4 = {
250 U_BOOT_DEVICE(spl_test4) = {
251 \t.name\t\t= "sandbox_spl_test_2",
252 \t.platdata\t= &dtv_spl_test4,
253 \t.platdata_size\t= sizeof(dtv_spl_test4),
256 static const struct dtd_sandbox_i2c_test dtv_i2c_at_0 = {
258 U_BOOT_DEVICE(i2c_at_0) = {
259 \t.name\t\t= "sandbox_i2c_test",
260 \t.platdata\t= &dtv_i2c_at_0,
261 \t.platdata_size\t= sizeof(dtv_i2c_at_0),
264 static const struct dtd_sandbox_pmic_test dtv_pmic_at_9 = {
265 \t.low_power\t\t= true,
266 \t.reg\t\t\t= {0x9, 0x0},
268 U_BOOT_DEVICE(pmic_at_9) = {
269 \t.name\t\t= "sandbox_pmic_test",
270 \t.platdata\t= &dtv_pmic_at_9,
271 \t.platdata_size\t= sizeof(dtv_pmic_at_9),
276 def test_driver_alias(self):
277 """Test output from a device tree file with a driver alias"""
278 dtb_file = get_dtb_file('dtoc_test_driver_alias.dts')
279 output = tools.GetOutputFilename('output')
280 self.run_test(['struct'], dtb_file, output)
281 with open(output) as infile:
283 self._CheckStrings(HEADER + '''
284 struct dtd_sandbox_gpio {
285 \tconst char *\tgpio_bank_name;
286 \tbool\t\tgpio_controller;
287 \tfdt32_t\t\tsandbox_gpio_count;
289 #define dtd_sandbox_gpio_alias dtd_sandbox_gpio
292 self.run_test(['platdata'], dtb_file, output)
293 with open(output) as infile:
295 self._CheckStrings(C_HEADER + '''
296 static const struct dtd_sandbox_gpio dtv_gpios_at_0 = {
297 \t.gpio_bank_name\t\t= "a",
298 \t.gpio_controller\t= true,
299 \t.sandbox_gpio_count\t= 0x14,
301 U_BOOT_DEVICE(gpios_at_0) = {
302 \t.name\t\t= "sandbox_gpio",
303 \t.platdata\t= &dtv_gpios_at_0,
304 \t.platdata_size\t= sizeof(dtv_gpios_at_0),
309 def test_invalid_driver(self):
310 """Test output from a device tree file with an invalid driver"""
311 dtb_file = get_dtb_file('dtoc_test_invalid_driver.dts')
312 output = tools.GetOutputFilename('output')
313 with test_util.capture_sys_output() as (stdout, stderr):
314 dtb_platdata.run_steps(['struct'], dtb_file, False, output)
315 with open(output) as infile:
317 self._CheckStrings(HEADER + '''
322 with test_util.capture_sys_output() as (stdout, stderr):
323 dtb_platdata.run_steps(['platdata'], dtb_file, False, output)
324 with open(output) as infile:
326 self._CheckStrings(C_HEADER + '''
327 static const struct dtd_invalid dtv_spl_test = {
329 U_BOOT_DEVICE(spl_test) = {
330 \t.name\t\t= "invalid",
331 \t.platdata\t= &dtv_spl_test,
332 \t.platdata_size\t= sizeof(dtv_spl_test),
337 def test_phandle(self):
338 """Test output from a node containing a phandle reference"""
339 dtb_file = get_dtb_file('dtoc_test_phandle.dts')
340 output = tools.GetOutputFilename('output')
341 self.run_test(['struct'], dtb_file, output)
342 with open(output) as infile:
344 self._CheckStrings(HEADER + '''
346 \tstruct phandle_2_arg clocks[4];
353 self.run_test(['platdata'], dtb_file, output)
354 with open(output) as infile:
356 self._CheckStrings(C_HEADER + '''
357 static const struct dtd_target dtv_phandle_target = {
358 \t.intval\t\t\t= 0x0,
360 U_BOOT_DEVICE(phandle_target) = {
361 \t.name\t\t= "target",
362 \t.platdata\t= &dtv_phandle_target,
363 \t.platdata_size\t= sizeof(dtv_phandle_target),
366 static const struct dtd_target dtv_phandle2_target = {
367 \t.intval\t\t\t= 0x1,
369 U_BOOT_DEVICE(phandle2_target) = {
370 \t.name\t\t= "target",
371 \t.platdata\t= &dtv_phandle2_target,
372 \t.platdata_size\t= sizeof(dtv_phandle2_target),
375 static const struct dtd_target dtv_phandle3_target = {
376 \t.intval\t\t\t= 0x2,
378 U_BOOT_DEVICE(phandle3_target) = {
379 \t.name\t\t= "target",
380 \t.platdata\t= &dtv_phandle3_target,
381 \t.platdata_size\t= sizeof(dtv_phandle3_target),
384 static const struct dtd_source dtv_phandle_source = {
386 \t\t\t{&dtv_phandle_target, {}},
387 \t\t\t{&dtv_phandle2_target, {11}},
388 \t\t\t{&dtv_phandle3_target, {12, 13}},
389 \t\t\t{&dtv_phandle_target, {}},},
391 U_BOOT_DEVICE(phandle_source) = {
392 \t.name\t\t= "source",
393 \t.platdata\t= &dtv_phandle_source,
394 \t.platdata_size\t= sizeof(dtv_phandle_source),
397 static const struct dtd_source dtv_phandle_source2 = {
399 \t\t\t{&dtv_phandle_target, {}},},
401 U_BOOT_DEVICE(phandle_source2) = {
402 \t.name\t\t= "source",
403 \t.platdata\t= &dtv_phandle_source2,
404 \t.platdata_size\t= sizeof(dtv_phandle_source2),
409 def test_phandle_single(self):
410 """Test output from a node containing a phandle reference"""
411 dtb_file = get_dtb_file('dtoc_test_phandle_single.dts')
412 output = tools.GetOutputFilename('output')
413 self.run_test(['struct'], dtb_file, output)
414 with open(output) as infile:
416 self._CheckStrings(HEADER + '''
418 \tstruct phandle_0_arg clocks[1];
425 def test_phandle_reorder(self):
426 """Test that phandle targets are generated before their references"""
427 dtb_file = get_dtb_file('dtoc_test_phandle_reorder.dts')
428 output = tools.GetOutputFilename('output')
429 self.run_test(['platdata'], dtb_file, output)
430 with open(output) as infile:
432 self._CheckStrings(C_HEADER + '''
433 static const struct dtd_target dtv_phandle_target = {
435 U_BOOT_DEVICE(phandle_target) = {
436 \t.name\t\t= "target",
437 \t.platdata\t= &dtv_phandle_target,
438 \t.platdata_size\t= sizeof(dtv_phandle_target),
441 static const struct dtd_source dtv_phandle_source2 = {
443 \t\t\t{&dtv_phandle_target, {}},},
445 U_BOOT_DEVICE(phandle_source2) = {
446 \t.name\t\t= "source",
447 \t.platdata\t= &dtv_phandle_source2,
448 \t.platdata_size\t= sizeof(dtv_phandle_source2),
453 def test_phandle_bad(self):
454 """Test a node containing an invalid phandle fails"""
455 dtb_file = get_dtb_file('dtoc_test_phandle_bad.dts',
457 output = tools.GetOutputFilename('output')
458 with self.assertRaises(ValueError) as e:
459 self.run_test(['struct'], dtb_file, output)
460 self.assertIn("Cannot parse 'clocks' in node 'phandle-source'",
463 def test_phandle_bad2(self):
464 """Test a phandle target missing its #*-cells property"""
465 dtb_file = get_dtb_file('dtoc_test_phandle_bad2.dts',
467 output = tools.GetOutputFilename('output')
468 with self.assertRaises(ValueError) as e:
469 self.run_test(['struct'], dtb_file, output)
470 self.assertIn("Node 'phandle-target' has no '#clock-cells' property",
473 def test_aliases(self):
474 """Test output from a node with multiple compatible strings"""
475 dtb_file = get_dtb_file('dtoc_test_aliases.dts')
476 output = tools.GetOutputFilename('output')
477 self.run_test(['struct'], dtb_file, output)
478 with open(output) as infile:
480 self._CheckStrings(HEADER + '''
484 #define dtd_compat2_1_fred dtd_compat1
485 #define dtd_compat3 dtd_compat1
488 self.run_test(['platdata'], dtb_file, output)
489 with open(output) as infile:
491 self._CheckStrings(C_HEADER + '''
492 static const struct dtd_compat1 dtv_spl_test = {
493 \t.intval\t\t\t= 0x1,
495 U_BOOT_DEVICE(spl_test) = {
496 \t.name\t\t= "compat1",
497 \t.platdata\t= &dtv_spl_test,
498 \t.platdata_size\t= sizeof(dtv_spl_test),
503 def test_addresses64(self):
504 """Test output from a node with a 'reg' property with na=2, ns=2"""
505 dtb_file = get_dtb_file('dtoc_test_addr64.dts')
506 output = tools.GetOutputFilename('output')
507 self.run_test(['struct'], dtb_file, output)
508 with open(output) as infile:
510 self._CheckStrings(HEADER + '''
522 self.run_test(['platdata'], dtb_file, output)
523 with open(output) as infile:
525 self._CheckStrings(C_HEADER + '''
526 static const struct dtd_test1 dtv_test1 = {
527 \t.reg\t\t\t= {0x1234, 0x5678},
529 U_BOOT_DEVICE(test1) = {
530 \t.name\t\t= "test1",
531 \t.platdata\t= &dtv_test1,
532 \t.platdata_size\t= sizeof(dtv_test1),
535 static const struct dtd_test2 dtv_test2 = {
536 \t.reg\t\t\t= {0x1234567890123456, 0x9876543210987654},
538 U_BOOT_DEVICE(test2) = {
539 \t.name\t\t= "test2",
540 \t.platdata\t= &dtv_test2,
541 \t.platdata_size\t= sizeof(dtv_test2),
544 static const struct dtd_test3 dtv_test3 = {
545 \t.reg\t\t\t= {0x1234567890123456, 0x9876543210987654, 0x2, 0x3},
547 U_BOOT_DEVICE(test3) = {
548 \t.name\t\t= "test3",
549 \t.platdata\t= &dtv_test3,
550 \t.platdata_size\t= sizeof(dtv_test3),
555 def test_addresses32(self):
556 """Test output from a node with a 'reg' property with na=1, ns=1"""
557 dtb_file = get_dtb_file('dtoc_test_addr32.dts')
558 output = tools.GetOutputFilename('output')
559 self.run_test(['struct'], dtb_file, output)
560 with open(output) as infile:
562 self._CheckStrings(HEADER + '''
571 self.run_test(['platdata'], dtb_file, output)
572 with open(output) as infile:
574 self._CheckStrings(C_HEADER + '''
575 static const struct dtd_test1 dtv_test1 = {
576 \t.reg\t\t\t= {0x1234, 0x5678},
578 U_BOOT_DEVICE(test1) = {
579 \t.name\t\t= "test1",
580 \t.platdata\t= &dtv_test1,
581 \t.platdata_size\t= sizeof(dtv_test1),
584 static const struct dtd_test2 dtv_test2 = {
585 \t.reg\t\t\t= {0x12345678, 0x98765432, 0x2, 0x3},
587 U_BOOT_DEVICE(test2) = {
588 \t.name\t\t= "test2",
589 \t.platdata\t= &dtv_test2,
590 \t.platdata_size\t= sizeof(dtv_test2),
595 def test_addresses64_32(self):
596 """Test output from a node with a 'reg' property with na=2, ns=1"""
597 dtb_file = get_dtb_file('dtoc_test_addr64_32.dts')
598 output = tools.GetOutputFilename('output')
599 self.run_test(['struct'], dtb_file, output)
600 with open(output) as infile:
602 self._CheckStrings(HEADER + '''
614 self.run_test(['platdata'], dtb_file, output)
615 with open(output) as infile:
617 self._CheckStrings(C_HEADER + '''
618 static const struct dtd_test1 dtv_test1 = {
619 \t.reg\t\t\t= {0x123400000000, 0x5678},
621 U_BOOT_DEVICE(test1) = {
622 \t.name\t\t= "test1",
623 \t.platdata\t= &dtv_test1,
624 \t.platdata_size\t= sizeof(dtv_test1),
627 static const struct dtd_test2 dtv_test2 = {
628 \t.reg\t\t\t= {0x1234567890123456, 0x98765432},
630 U_BOOT_DEVICE(test2) = {
631 \t.name\t\t= "test2",
632 \t.platdata\t= &dtv_test2,
633 \t.platdata_size\t= sizeof(dtv_test2),
636 static const struct dtd_test3 dtv_test3 = {
637 \t.reg\t\t\t= {0x1234567890123456, 0x98765432, 0x2, 0x3},
639 U_BOOT_DEVICE(test3) = {
640 \t.name\t\t= "test3",
641 \t.platdata\t= &dtv_test3,
642 \t.platdata_size\t= sizeof(dtv_test3),
647 def test_addresses32_64(self):
648 """Test output from a node with a 'reg' property with na=1, ns=2"""
649 dtb_file = get_dtb_file('dtoc_test_addr32_64.dts')
650 output = tools.GetOutputFilename('output')
651 self.run_test(['struct'], dtb_file, output)
652 with open(output) as infile:
654 self._CheckStrings(HEADER + '''
666 self.run_test(['platdata'], dtb_file, output)
667 with open(output) as infile:
669 self._CheckStrings(C_HEADER + '''
670 static const struct dtd_test1 dtv_test1 = {
671 \t.reg\t\t\t= {0x1234, 0x567800000000},
673 U_BOOT_DEVICE(test1) = {
674 \t.name\t\t= "test1",
675 \t.platdata\t= &dtv_test1,
676 \t.platdata_size\t= sizeof(dtv_test1),
679 static const struct dtd_test2 dtv_test2 = {
680 \t.reg\t\t\t= {0x12345678, 0x9876543210987654},
682 U_BOOT_DEVICE(test2) = {
683 \t.name\t\t= "test2",
684 \t.platdata\t= &dtv_test2,
685 \t.platdata_size\t= sizeof(dtv_test2),
688 static const struct dtd_test3 dtv_test3 = {
689 \t.reg\t\t\t= {0x12345678, 0x9876543210987654, 0x2, 0x3},
691 U_BOOT_DEVICE(test3) = {
692 \t.name\t\t= "test3",
693 \t.platdata\t= &dtv_test3,
694 \t.platdata_size\t= sizeof(dtv_test3),
699 def test_bad_reg(self):
700 """Test that a reg property with an invalid type generates an error"""
701 # Capture stderr since dtc will emit warnings for this file
702 dtb_file = get_dtb_file('dtoc_test_bad_reg.dts', capture_stderr=True)
703 output = tools.GetOutputFilename('output')
704 with self.assertRaises(ValueError) as e:
705 self.run_test(['struct'], dtb_file, output)
706 self.assertIn("Node 'spl-test' reg property is not an int",
709 def test_bad_reg2(self):
710 """Test that a reg property with an invalid cell count is detected"""
711 # Capture stderr since dtc will emit warnings for this file
712 dtb_file = get_dtb_file('dtoc_test_bad_reg2.dts', capture_stderr=True)
713 output = tools.GetOutputFilename('output')
714 with self.assertRaises(ValueError) as e:
715 self.run_test(['struct'], dtb_file, output)
716 self.assertIn("Node 'spl-test' reg property has 3 cells which is not a multiple of na + ns = 1 + 1)",
719 def test_add_prop(self):
720 """Test that a subequent node can add a new property to a struct"""
721 dtb_file = get_dtb_file('dtoc_test_add_prop.dts')
722 output = tools.GetOutputFilename('output')
723 self.run_test(['struct'], dtb_file, output)
724 with open(output) as infile:
726 self._CheckStrings(HEADER + '''
727 struct dtd_sandbox_spl_test {
728 \tfdt32_t\t\tintarray;
733 self.run_test(['platdata'], dtb_file, output)
734 with open(output) as infile:
736 self._CheckStrings(C_HEADER + '''
737 static const struct dtd_sandbox_spl_test dtv_spl_test = {
738 \t.intval\t\t\t= 0x1,
740 U_BOOT_DEVICE(spl_test) = {
741 \t.name\t\t= "sandbox_spl_test",
742 \t.platdata\t= &dtv_spl_test,
743 \t.platdata_size\t= sizeof(dtv_spl_test),
746 static const struct dtd_sandbox_spl_test dtv_spl_test2 = {
747 \t.intarray\t\t= 0x5,
749 U_BOOT_DEVICE(spl_test2) = {
750 \t.name\t\t= "sandbox_spl_test",
751 \t.platdata\t= &dtv_spl_test2,
752 \t.platdata_size\t= sizeof(dtv_spl_test2),
757 def testStdout(self):
758 """Test output to stdout"""
759 dtb_file = get_dtb_file('dtoc_test_simple.dts')
760 with test_util.capture_sys_output() as (stdout, stderr):
761 self.run_test(['struct'], dtb_file, '-')
763 def testNoCommand(self):
764 """Test running dtoc without a command"""
765 with self.assertRaises(ValueError) as e:
766 self.run_test([], '', '')
767 self.assertIn("Please specify a command: struct, platdata",
770 def testBadCommand(self):
771 """Test running dtoc with an invalid command"""
772 dtb_file = get_dtb_file('dtoc_test_simple.dts')
773 output = tools.GetOutputFilename('output')
774 with self.assertRaises(ValueError) as e:
775 self.run_test(['invalid-cmd'], dtb_file, output)
776 self.assertIn("Unknown command 'invalid-cmd': (use: struct, platdata)",