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
17 from dtoc import dtb_platdata
18 from dtb_platdata import conv_name_to_c
19 from dtb_platdata import get_compat_name
20 from dtb_platdata import get_value
21 from dtb_platdata import tab_to
23 from dtoc import fdt_util
24 from patman import test_util
25 from patman import tools
27 our_path = os.path.dirname(os.path.realpath(__file__))
33 * This file was generated by dtoc from a .dtb (device tree binary) file.
37 #include <linux/libfdt.h>'''
42 * This file was generated by dtoc from a .dtb (device tree binary) file.
47 #include <dt-structs.h>
52 def get_dtb_file(dts_fname, capture_stderr=False):
53 """Compile a .dts file to a .dtb
56 dts_fname: Filename of .dts file in the current directory
57 capture_stderr: True to capture and discard stderr output
60 Filename of compiled file in output directory
62 return fdt_util.EnsureCompiled(os.path.join(our_path, dts_fname),
63 capture_stderr=capture_stderr)
66 class TestDtoc(unittest.TestCase):
70 tools.PrepareOutputDir(None)
73 def tearDownClass(cls):
74 tools._RemoveOutputDir()
76 def _WritePythonString(self, fname, data):
77 """Write a string with tabs expanded as done in this Python file
80 fname: Filename to write to
81 data: Raw string to convert
83 data = data.replace('\t', '\\t')
84 with open(fname, 'w') as fd:
87 def _CheckStrings(self, expected, actual):
88 """Check that a string matches its expected value
90 If the strings do not match, they are written to the /tmp directory in
91 the same Python format as is used here in the test. This allows for
92 easy comparison and update of the tests.
95 expected: Expected string
98 if expected != actual:
99 self._WritePythonString('/tmp/binman.expected', expected)
100 self._WritePythonString('/tmp/binman.actual', actual)
101 print('Failures written to /tmp/binman.{expected,actual}')
102 self.assertEquals(expected, actual)
105 """Test conversion of device tree names to C identifiers"""
106 self.assertEqual('serial_at_0x12', conv_name_to_c('serial@0x12'))
107 self.assertEqual('vendor_clock_frequency',
108 conv_name_to_c('vendor,clock-frequency'))
109 self.assertEqual('rockchip_rk3399_sdhci_5_1',
110 conv_name_to_c('rockchip,rk3399-sdhci-5.1'))
112 def test_tab_to(self):
113 """Test operation of tab_to() function"""
114 self.assertEqual('fred ', tab_to(0, 'fred'))
115 self.assertEqual('fred\t', tab_to(1, 'fred'))
116 self.assertEqual('fred was here ', tab_to(1, 'fred was here'))
117 self.assertEqual('fred was here\t\t', tab_to(3, 'fred was here'))
118 self.assertEqual('exactly8 ', tab_to(1, 'exactly8'))
119 self.assertEqual('exactly8\t', tab_to(2, 'exactly8'))
121 def test_get_value(self):
122 """Test operation of get_value() function"""
123 self.assertEqual('0x45',
124 get_value(fdt.TYPE_INT, struct.pack('>I', 0x45)))
125 self.assertEqual('0x45',
126 get_value(fdt.TYPE_BYTE, struct.pack('<I', 0x45)))
127 self.assertEqual('0x0',
128 get_value(fdt.TYPE_BYTE, struct.pack('>I', 0x45)))
129 self.assertEqual('"test"', get_value(fdt.TYPE_STRING, 'test'))
130 self.assertEqual('true', get_value(fdt.TYPE_BOOL, None))
132 def test_get_compat_name(self):
133 """Test operation of get_compat_name() function"""
134 Prop = collections.namedtuple('Prop', ['value'])
135 Node = collections.namedtuple('Node', ['props'])
137 prop = Prop(['rockchip,rk3399-sdhci-5.1', 'arasan,sdhci-5.1'])
138 node = Node({'compatible': prop})
139 self.assertEqual(('rockchip_rk3399_sdhci_5_1', ['arasan_sdhci_5_1']),
140 get_compat_name(node))
142 prop = Prop(['rockchip,rk3399-sdhci-5.1'])
143 node = Node({'compatible': prop})
144 self.assertEqual(('rockchip_rk3399_sdhci_5_1', []),
145 get_compat_name(node))
147 prop = Prop(['rockchip,rk3399-sdhci-5.1', 'arasan,sdhci-5.1', 'third'])
148 node = Node({'compatible': prop})
149 self.assertEqual(('rockchip_rk3399_sdhci_5_1',
150 ['arasan_sdhci_5_1', 'third']),
151 get_compat_name(node))
153 def test_empty_file(self):
154 """Test output from a device tree file with no nodes"""
155 dtb_file = get_dtb_file('dtoc_test_empty.dts')
156 output = tools.GetOutputFilename('output')
157 dtb_platdata.run_steps(['struct'], dtb_file, False, output)
158 with open(output) as infile:
159 lines = infile.read().splitlines()
160 self.assertEqual(HEADER.splitlines(), lines)
162 dtb_platdata.run_steps(['platdata'], dtb_file, False, output)
163 with open(output) as infile:
164 lines = infile.read().splitlines()
165 self.assertEqual(C_HEADER.splitlines() + [''], lines)
167 def test_simple(self):
168 """Test output from some simple nodes with various types of data"""
169 dtb_file = get_dtb_file('dtoc_test_simple.dts')
170 output = tools.GetOutputFilename('output')
171 dtb_platdata.run_steps(['struct'], dtb_file, False, output)
172 with open(output) as infile:
174 self._CheckStrings(HEADER + '''
175 struct dtd_sandbox_i2c_test {
177 struct dtd_sandbox_pmic_test {
181 struct dtd_sandbox_spl_test {
183 \tunsigned char\tbytearray[3];
184 \tunsigned char\tbyteval;
185 \tfdt32_t\t\tintarray[4];
187 \tunsigned char\tlongbytearray[9];
188 \tunsigned char\tnotstring[5];
189 \tconst char *\tstringarray[3];
190 \tconst char *\tstringval;
192 struct dtd_sandbox_spl_test_2 {
196 dtb_platdata.run_steps(['platdata'], dtb_file, False, output)
197 with open(output) as infile:
199 self._CheckStrings(C_HEADER + '''
200 static const struct dtd_sandbox_spl_test dtv_spl_test = {
201 \t.boolval\t\t= true,
202 \t.bytearray\t\t= {0x6, 0x0, 0x0},
204 \t.intarray\t\t= {0x2, 0x3, 0x4, 0x0},
205 \t.intval\t\t\t= 0x1,
206 \t.longbytearray\t\t= {0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf, 0x10,
208 \t.notstring\t\t= {0x20, 0x21, 0x22, 0x10, 0x0},
209 \t.stringarray\t\t= {"multi-word", "message", ""},
210 \t.stringval\t\t= "message",
212 U_BOOT_DEVICE(spl_test) = {
213 \t.name\t\t= "sandbox_spl_test",
214 \t.platdata\t= &dtv_spl_test,
215 \t.platdata_size\t= sizeof(dtv_spl_test),
218 static const struct dtd_sandbox_spl_test dtv_spl_test2 = {
219 \t.bytearray\t\t= {0x1, 0x23, 0x34},
221 \t.intarray\t\t= {0x5, 0x0, 0x0, 0x0},
222 \t.intval\t\t\t= 0x3,
223 \t.longbytearray\t\t= {0x9, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
225 \t.stringarray\t\t= {"another", "multi-word", "message"},
226 \t.stringval\t\t= "message2",
228 U_BOOT_DEVICE(spl_test2) = {
229 \t.name\t\t= "sandbox_spl_test",
230 \t.platdata\t= &dtv_spl_test2,
231 \t.platdata_size\t= sizeof(dtv_spl_test2),
234 static const struct dtd_sandbox_spl_test dtv_spl_test3 = {
235 \t.stringarray\t\t= {"one", "", ""},
237 U_BOOT_DEVICE(spl_test3) = {
238 \t.name\t\t= "sandbox_spl_test",
239 \t.platdata\t= &dtv_spl_test3,
240 \t.platdata_size\t= sizeof(dtv_spl_test3),
243 static const struct dtd_sandbox_spl_test_2 dtv_spl_test4 = {
245 U_BOOT_DEVICE(spl_test4) = {
246 \t.name\t\t= "sandbox_spl_test_2",
247 \t.platdata\t= &dtv_spl_test4,
248 \t.platdata_size\t= sizeof(dtv_spl_test4),
251 static const struct dtd_sandbox_i2c_test dtv_i2c_at_0 = {
253 U_BOOT_DEVICE(i2c_at_0) = {
254 \t.name\t\t= "sandbox_i2c_test",
255 \t.platdata\t= &dtv_i2c_at_0,
256 \t.platdata_size\t= sizeof(dtv_i2c_at_0),
259 static const struct dtd_sandbox_pmic_test dtv_pmic_at_9 = {
260 \t.low_power\t\t= true,
261 \t.reg\t\t\t= {0x9, 0x0},
263 U_BOOT_DEVICE(pmic_at_9) = {
264 \t.name\t\t= "sandbox_pmic_test",
265 \t.platdata\t= &dtv_pmic_at_9,
266 \t.platdata_size\t= sizeof(dtv_pmic_at_9),
271 def test_driver_alias(self):
272 """Test output from a device tree file with a driver alias"""
273 dtb_file = get_dtb_file('dtoc_test_driver_alias.dts')
274 output = tools.GetOutputFilename('output')
275 dtb_platdata.run_steps(['struct'], dtb_file, False, output)
276 with open(output) as infile:
278 self._CheckStrings(HEADER + '''
279 struct dtd_sandbox_gpio {
280 \tconst char *\tgpio_bank_name;
281 \tbool\t\tgpio_controller;
282 \tfdt32_t\t\tsandbox_gpio_count;
284 #define dtd_sandbox_gpio_alias dtd_sandbox_gpio
287 dtb_platdata.run_steps(['platdata'], dtb_file, False, output)
288 with open(output) as infile:
290 self._CheckStrings(C_HEADER + '''
291 static const struct dtd_sandbox_gpio dtv_gpios_at_0 = {
292 \t.gpio_bank_name\t\t= "a",
293 \t.gpio_controller\t= true,
294 \t.sandbox_gpio_count\t= 0x14,
296 U_BOOT_DEVICE(gpios_at_0) = {
297 \t.name\t\t= "sandbox_gpio",
298 \t.platdata\t= &dtv_gpios_at_0,
299 \t.platdata_size\t= sizeof(dtv_gpios_at_0),
304 def test_phandle(self):
305 """Test output from a node containing a phandle reference"""
306 dtb_file = get_dtb_file('dtoc_test_phandle.dts')
307 output = tools.GetOutputFilename('output')
308 dtb_platdata.run_steps(['struct'], dtb_file, False, output)
309 with open(output) as infile:
311 self._CheckStrings(HEADER + '''
313 \tstruct phandle_2_arg clocks[4];
320 dtb_platdata.run_steps(['platdata'], dtb_file, False, output)
321 with open(output) as infile:
323 self._CheckStrings(C_HEADER + '''
324 static const struct dtd_target dtv_phandle_target = {
325 \t.intval\t\t\t= 0x0,
327 U_BOOT_DEVICE(phandle_target) = {
328 \t.name\t\t= "target",
329 \t.platdata\t= &dtv_phandle_target,
330 \t.platdata_size\t= sizeof(dtv_phandle_target),
333 static const struct dtd_target dtv_phandle2_target = {
334 \t.intval\t\t\t= 0x1,
336 U_BOOT_DEVICE(phandle2_target) = {
337 \t.name\t\t= "target",
338 \t.platdata\t= &dtv_phandle2_target,
339 \t.platdata_size\t= sizeof(dtv_phandle2_target),
342 static const struct dtd_target dtv_phandle3_target = {
343 \t.intval\t\t\t= 0x2,
345 U_BOOT_DEVICE(phandle3_target) = {
346 \t.name\t\t= "target",
347 \t.platdata\t= &dtv_phandle3_target,
348 \t.platdata_size\t= sizeof(dtv_phandle3_target),
351 static const struct dtd_source dtv_phandle_source = {
353 \t\t\t{&dtv_phandle_target, {}},
354 \t\t\t{&dtv_phandle2_target, {11}},
355 \t\t\t{&dtv_phandle3_target, {12, 13}},
356 \t\t\t{&dtv_phandle_target, {}},},
358 U_BOOT_DEVICE(phandle_source) = {
359 \t.name\t\t= "source",
360 \t.platdata\t= &dtv_phandle_source,
361 \t.platdata_size\t= sizeof(dtv_phandle_source),
364 static const struct dtd_source dtv_phandle_source2 = {
366 \t\t\t{&dtv_phandle_target, {}},},
368 U_BOOT_DEVICE(phandle_source2) = {
369 \t.name\t\t= "source",
370 \t.platdata\t= &dtv_phandle_source2,
371 \t.platdata_size\t= sizeof(dtv_phandle_source2),
376 def test_phandle_single(self):
377 """Test output from a node containing a phandle reference"""
378 dtb_file = get_dtb_file('dtoc_test_phandle_single.dts')
379 output = tools.GetOutputFilename('output')
380 dtb_platdata.run_steps(['struct'], dtb_file, False, output)
381 with open(output) as infile:
383 self._CheckStrings(HEADER + '''
385 \tstruct phandle_0_arg clocks[1];
392 def test_phandle_reorder(self):
393 """Test that phandle targets are generated before their references"""
394 dtb_file = get_dtb_file('dtoc_test_phandle_reorder.dts')
395 output = tools.GetOutputFilename('output')
396 dtb_platdata.run_steps(['platdata'], dtb_file, False, output)
397 with open(output) as infile:
399 self._CheckStrings(C_HEADER + '''
400 static const struct dtd_target dtv_phandle_target = {
402 U_BOOT_DEVICE(phandle_target) = {
403 \t.name\t\t= "target",
404 \t.platdata\t= &dtv_phandle_target,
405 \t.platdata_size\t= sizeof(dtv_phandle_target),
408 static const struct dtd_source dtv_phandle_source2 = {
410 \t\t\t{&dtv_phandle_target, {}},},
412 U_BOOT_DEVICE(phandle_source2) = {
413 \t.name\t\t= "source",
414 \t.platdata\t= &dtv_phandle_source2,
415 \t.platdata_size\t= sizeof(dtv_phandle_source2),
420 def test_phandle_bad(self):
421 """Test a node containing an invalid phandle fails"""
422 dtb_file = get_dtb_file('dtoc_test_phandle_bad.dts',
424 output = tools.GetOutputFilename('output')
425 with self.assertRaises(ValueError) as e:
426 dtb_platdata.run_steps(['struct'], dtb_file, False, output)
427 self.assertIn("Cannot parse 'clocks' in node 'phandle-source'",
430 def test_phandle_bad2(self):
431 """Test a phandle target missing its #*-cells property"""
432 dtb_file = get_dtb_file('dtoc_test_phandle_bad2.dts',
434 output = tools.GetOutputFilename('output')
435 with self.assertRaises(ValueError) as e:
436 dtb_platdata.run_steps(['struct'], dtb_file, False, output)
437 self.assertIn("Node 'phandle-target' has no '#clock-cells' property",
440 def test_aliases(self):
441 """Test output from a node with multiple compatible strings"""
442 dtb_file = get_dtb_file('dtoc_test_aliases.dts')
443 output = tools.GetOutputFilename('output')
444 dtb_platdata.run_steps(['struct'], dtb_file, False, output)
445 with open(output) as infile:
447 self._CheckStrings(HEADER + '''
451 #define dtd_compat2_1_fred dtd_compat1
452 #define dtd_compat3 dtd_compat1
455 dtb_platdata.run_steps(['platdata'], dtb_file, False, output)
456 with open(output) as infile:
458 self._CheckStrings(C_HEADER + '''
459 static const struct dtd_compat1 dtv_spl_test = {
460 \t.intval\t\t\t= 0x1,
462 U_BOOT_DEVICE(spl_test) = {
463 \t.name\t\t= "compat1",
464 \t.platdata\t= &dtv_spl_test,
465 \t.platdata_size\t= sizeof(dtv_spl_test),
470 def test_addresses64(self):
471 """Test output from a node with a 'reg' property with na=2, ns=2"""
472 dtb_file = get_dtb_file('dtoc_test_addr64.dts')
473 output = tools.GetOutputFilename('output')
474 dtb_platdata.run_steps(['struct'], dtb_file, False, output)
475 with open(output) as infile:
477 self._CheckStrings(HEADER + '''
489 dtb_platdata.run_steps(['platdata'], dtb_file, False, output)
490 with open(output) as infile:
492 self._CheckStrings(C_HEADER + '''
493 static const struct dtd_test1 dtv_test1 = {
494 \t.reg\t\t\t= {0x1234, 0x5678},
496 U_BOOT_DEVICE(test1) = {
497 \t.name\t\t= "test1",
498 \t.platdata\t= &dtv_test1,
499 \t.platdata_size\t= sizeof(dtv_test1),
502 static const struct dtd_test2 dtv_test2 = {
503 \t.reg\t\t\t= {0x1234567890123456, 0x9876543210987654},
505 U_BOOT_DEVICE(test2) = {
506 \t.name\t\t= "test2",
507 \t.platdata\t= &dtv_test2,
508 \t.platdata_size\t= sizeof(dtv_test2),
511 static const struct dtd_test3 dtv_test3 = {
512 \t.reg\t\t\t= {0x1234567890123456, 0x9876543210987654, 0x2, 0x3},
514 U_BOOT_DEVICE(test3) = {
515 \t.name\t\t= "test3",
516 \t.platdata\t= &dtv_test3,
517 \t.platdata_size\t= sizeof(dtv_test3),
522 def test_addresses32(self):
523 """Test output from a node with a 'reg' property with na=1, ns=1"""
524 dtb_file = get_dtb_file('dtoc_test_addr32.dts')
525 output = tools.GetOutputFilename('output')
526 dtb_platdata.run_steps(['struct'], dtb_file, False, output)
527 with open(output) as infile:
529 self._CheckStrings(HEADER + '''
538 dtb_platdata.run_steps(['platdata'], dtb_file, False, output)
539 with open(output) as infile:
541 self._CheckStrings(C_HEADER + '''
542 static const struct dtd_test1 dtv_test1 = {
543 \t.reg\t\t\t= {0x1234, 0x5678},
545 U_BOOT_DEVICE(test1) = {
546 \t.name\t\t= "test1",
547 \t.platdata\t= &dtv_test1,
548 \t.platdata_size\t= sizeof(dtv_test1),
551 static const struct dtd_test2 dtv_test2 = {
552 \t.reg\t\t\t= {0x12345678, 0x98765432, 0x2, 0x3},
554 U_BOOT_DEVICE(test2) = {
555 \t.name\t\t= "test2",
556 \t.platdata\t= &dtv_test2,
557 \t.platdata_size\t= sizeof(dtv_test2),
562 def test_addresses64_32(self):
563 """Test output from a node with a 'reg' property with na=2, ns=1"""
564 dtb_file = get_dtb_file('dtoc_test_addr64_32.dts')
565 output = tools.GetOutputFilename('output')
566 dtb_platdata.run_steps(['struct'], dtb_file, False, output)
567 with open(output) as infile:
569 self._CheckStrings(HEADER + '''
581 dtb_platdata.run_steps(['platdata'], dtb_file, False, output)
582 with open(output) as infile:
584 self._CheckStrings(C_HEADER + '''
585 static const struct dtd_test1 dtv_test1 = {
586 \t.reg\t\t\t= {0x123400000000, 0x5678},
588 U_BOOT_DEVICE(test1) = {
589 \t.name\t\t= "test1",
590 \t.platdata\t= &dtv_test1,
591 \t.platdata_size\t= sizeof(dtv_test1),
594 static const struct dtd_test2 dtv_test2 = {
595 \t.reg\t\t\t= {0x1234567890123456, 0x98765432},
597 U_BOOT_DEVICE(test2) = {
598 \t.name\t\t= "test2",
599 \t.platdata\t= &dtv_test2,
600 \t.platdata_size\t= sizeof(dtv_test2),
603 static const struct dtd_test3 dtv_test3 = {
604 \t.reg\t\t\t= {0x1234567890123456, 0x98765432, 0x2, 0x3},
606 U_BOOT_DEVICE(test3) = {
607 \t.name\t\t= "test3",
608 \t.platdata\t= &dtv_test3,
609 \t.platdata_size\t= sizeof(dtv_test3),
614 def test_addresses32_64(self):
615 """Test output from a node with a 'reg' property with na=1, ns=2"""
616 dtb_file = get_dtb_file('dtoc_test_addr32_64.dts')
617 output = tools.GetOutputFilename('output')
618 dtb_platdata.run_steps(['struct'], dtb_file, False, output)
619 with open(output) as infile:
621 self._CheckStrings(HEADER + '''
633 dtb_platdata.run_steps(['platdata'], dtb_file, False, output)
634 with open(output) as infile:
636 self._CheckStrings(C_HEADER + '''
637 static const struct dtd_test1 dtv_test1 = {
638 \t.reg\t\t\t= {0x1234, 0x567800000000},
640 U_BOOT_DEVICE(test1) = {
641 \t.name\t\t= "test1",
642 \t.platdata\t= &dtv_test1,
643 \t.platdata_size\t= sizeof(dtv_test1),
646 static const struct dtd_test2 dtv_test2 = {
647 \t.reg\t\t\t= {0x12345678, 0x9876543210987654},
649 U_BOOT_DEVICE(test2) = {
650 \t.name\t\t= "test2",
651 \t.platdata\t= &dtv_test2,
652 \t.platdata_size\t= sizeof(dtv_test2),
655 static const struct dtd_test3 dtv_test3 = {
656 \t.reg\t\t\t= {0x12345678, 0x9876543210987654, 0x2, 0x3},
658 U_BOOT_DEVICE(test3) = {
659 \t.name\t\t= "test3",
660 \t.platdata\t= &dtv_test3,
661 \t.platdata_size\t= sizeof(dtv_test3),
666 def test_bad_reg(self):
667 """Test that a reg property with an invalid type generates an error"""
668 # Capture stderr since dtc will emit warnings for this file
669 dtb_file = get_dtb_file('dtoc_test_bad_reg.dts', capture_stderr=True)
670 output = tools.GetOutputFilename('output')
671 with self.assertRaises(ValueError) as e:
672 dtb_platdata.run_steps(['struct'], dtb_file, False, output)
673 self.assertIn("Node 'spl-test' reg property is not an int",
676 def test_bad_reg2(self):
677 """Test that a reg property with an invalid cell count is detected"""
678 # Capture stderr since dtc will emit warnings for this file
679 dtb_file = get_dtb_file('dtoc_test_bad_reg2.dts', capture_stderr=True)
680 output = tools.GetOutputFilename('output')
681 with self.assertRaises(ValueError) as e:
682 dtb_platdata.run_steps(['struct'], dtb_file, False, output)
683 self.assertIn("Node 'spl-test' reg property has 3 cells which is not a multiple of na + ns = 1 + 1)",
686 def test_add_prop(self):
687 """Test that a subequent node can add a new property to a struct"""
688 dtb_file = get_dtb_file('dtoc_test_add_prop.dts')
689 output = tools.GetOutputFilename('output')
690 dtb_platdata.run_steps(['struct'], dtb_file, False, output)
691 with open(output) as infile:
693 self._CheckStrings(HEADER + '''
694 struct dtd_sandbox_spl_test {
695 \tfdt32_t\t\tintarray;
700 dtb_platdata.run_steps(['platdata'], dtb_file, False, output)
701 with open(output) as infile:
703 self._CheckStrings(C_HEADER + '''
704 static const struct dtd_sandbox_spl_test dtv_spl_test = {
705 \t.intval\t\t\t= 0x1,
707 U_BOOT_DEVICE(spl_test) = {
708 \t.name\t\t= "sandbox_spl_test",
709 \t.platdata\t= &dtv_spl_test,
710 \t.platdata_size\t= sizeof(dtv_spl_test),
713 static const struct dtd_sandbox_spl_test dtv_spl_test2 = {
714 \t.intarray\t\t= 0x5,
716 U_BOOT_DEVICE(spl_test2) = {
717 \t.name\t\t= "sandbox_spl_test",
718 \t.platdata\t= &dtv_spl_test2,
719 \t.platdata_size\t= sizeof(dtv_spl_test2),
724 def testStdout(self):
725 """Test output to stdout"""
726 dtb_file = get_dtb_file('dtoc_test_simple.dts')
727 with test_util.capture_sys_output() as (stdout, stderr):
728 dtb_platdata.run_steps(['struct'], dtb_file, False, '-')
730 def testNoCommand(self):
731 """Test running dtoc without a command"""
732 with self.assertRaises(ValueError) as e:
733 dtb_platdata.run_steps([], '', False, '')
734 self.assertIn("Please specify a command: struct, platdata",
737 def testBadCommand(self):
738 """Test running dtoc with an invalid command"""
739 dtb_file = get_dtb_file('dtoc_test_simple.dts')
740 output = tools.GetOutputFilename('output')
741 with self.assertRaises(ValueError) as e:
742 dtb_platdata.run_steps(['invalid-cmd'], dtb_file, False, output)
743 self.assertIn("Unknown command 'invalid-cmd': (use: struct, platdata)",