Merge tag 'dm-pull-9jul19-take2' of https://gitlab.denx.de/u-boot/custodians/u-boot-dm
[oweals/u-boot.git] / test / py / tests / test_ofplatdata.py
1 # SPDX-License-Identifier: GPL-2.0+
2 # Copyright (c) 2016 Google, Inc
3
4 import pytest
5 import u_boot_utils as util
6
7 OF_PLATDATA_OUTPUT = '''
8 of-platdata probe:
9 bool 1
10 byte 05
11 bytearray 06 00 00
12 int 1
13 intarray 2 3 4 0
14 longbytearray 09 0a 0b 0c 0d 0e 0f 10 11
15 string message
16 stringarray "multi-word" "message" ""
17 of-platdata probe:
18 bool 0
19 byte 08
20 bytearray 01 23 34
21 int 3
22 intarray 5 0 0 0
23 longbytearray 09 00 00 00 00 00 00 00 00
24 string message2
25 stringarray "another" "multi-word" "message"
26 of-platdata probe:
27 bool 0
28 byte 00
29 bytearray 00 00 00
30 int 0
31 intarray 0 0 0 0
32 longbytearray 00 00 00 00 00 00 00 00 00
33 string <NULL>
34 stringarray "one" "" ""
35 of-platdata probe:
36 bool 0
37 byte 00
38 bytearray 00 00 00
39 int 0
40 intarray 0 0 0 0
41 longbytearray 00 00 00 00 00 00 00 00 00
42 string <NULL>
43 stringarray "spl" "" ""
44 '''
45
46 @pytest.mark.buildconfigspec('spl_of_platdata')
47 def test_ofplatdata(u_boot_console):
48     """Test that of-platdata can be generated and used in sandbox"""
49     cons = u_boot_console
50     cons.restart_uboot_with_flags(['--show_of_platdata'])
51     output = cons.get_spawn_output().replace('\r', '')
52     assert OF_PLATDATA_OUTPUT in output
53
54 @pytest.mark.buildconfigspec('spl_of_platdata')
55 def test_spl_devicetree(u_boot_console):
56     """Test content of spl device-tree"""
57     cons = u_boot_console
58     dtb = cons.config.build_dir + '/spl/u-boot-spl.dtb'
59     fdtgrep = cons.config.build_dir + '/tools/fdtgrep'
60     output = util.run_and_log(cons, [fdtgrep, '-l', dtb])
61
62     assert "u-boot,dm-pre-reloc" not in output
63     assert "u-boot,dm-pre-proper" not in output
64     assert "u-boot,dm-spl" not in output
65     assert "u-boot,dm-tpl" not in output
66
67     assert "spl-test4" in output
68     assert "spl-test5" not in output
69     assert "spl-test6" not in output
70     assert "spl-test7" in output