Lines Matching +full:child +full:- +full:prop +full:- +full:1

2 # SPDX-License-Identifier: BSD-3-Clause
23 # - to stop on the first failure with shorter traceback output,
24 # use '-x --tb=native'
25 # - to drop into a debugger on failure, use '--pdb'
26 # - to run a particular test function or functions, use
27 # '-k test_function_pattern_goes_here'
34 fd, path = tempfile.mkstemp(prefix='pytest-', suffix='.dts')
36 os.write(fd, dts.encode('utf-8'))
44 representation is expected[1:-1].
46 The [1:] is so that the first line can be put on a separate line
49 dt = parse(dts[1:], include_path)
52 expected = expected[1:-1]
53 assert actual == expected, f'unexpected round-trip on {dts}'
62 parse(dts[1:])
71 parse(dts[1:])
80 parse(dts[1:])
104 - err: error message must be exactly this
105 - err_endswith: error message must end with this
106 - err_matches: error message must match this regular expression
109 assert sum([bool(err), bool(err_endswith), bool(err_matches)]) == 1
129 /dts-v1/;
138 /dts-v1/;
145 e = < 0U 1L 2UL 3LL 4ULL >;
148 h = /bits/ 8 < 0x10 0x20 (-1) >;
149 i = /bits/ 16 < 0x10 0x20 (-1) >;
150 j = /bits/ 32 < 0x10 0x20 (-1) >;
151 k = /bits/ 64 < 0x10 0x20 (-1) >;
156 /dts-v1/;
175 /dts-v1/;
184 /dts-v1/;
193 /dts-v1/;
205 /dts-v1/;
214 /dts-v1/;
224 /dts-v1/;
230 ":4 (column 10): parse error: expected two-digit byte or ']'")
236 /dts-v1/;
245 /dts-v1/;
255 /dts-v1/;
267 /dts-v1/;
275 /dts-v1/;
284 /dts-v1/;
294 /dts-v1/;
300 ":4 (column 7): parse error: character literals must be length 1")
303 /dts-v1/;
309 ":4 (column 7): parse error: character literals must be length 1")
320 /dts-v1/;
324 b = /incbin/ ("{tmp_path}/tmp_bin", 1, 1);
325 c = /incbin/ ("{tmp_path}/tmp_bin", 1, 2);
329 /dts-v1/;
339 /dts-v1/;
346 /dts-v1/;
355 /dts-v1/;
370 /dts-v1/;
409 /dts-v1/;
430 /dts-v1/;
438 ":6 (column 1): parse error: undefined node label 'missing'")
441 /dts-v1/;
449 ":6 (column 1): parse error: node path 'foo' does not start with '/'")
452 /dts-v1/;
460 ":6 (column 1): parse error: component 'foo' in path '/foo' does not exist")
470 /dts-v1/;
486 /dts-v1/;
517 /dts-v1/;
530 /dts-v1/;
561 /dts-v1/;
564 no-unit-addr {
567 unit-addr@ABC {
570 unit-addr-non-numeric@foo-bar {
575 /dts-v1/;
578 no-unit-addr {
580 unit-addr@ABC {
582 unit-addr-non-numeric@foo-bar {
587 verify_unit_addr("/no-unit-addr", "")
588 verify_unit_addr("/unit-addr@ABC", "ABC")
589 verify_unit_addr("/unit-addr-non-numeric@foo-bar", "foo-bar")
595 /dts-v1/;
609 /dts-v1/;
624 /dts-v1/;
635 /dts-v1/;
649 /dts-v1/;
655 phandle = < 1 >;
674 /dts-v1/;
699 /dts-v1/;
703 phandle = < 1 >;
716 /dts-v1/;
732 /dts-v1/;
743 /dts-v1/;
751 ":5 (column 19): parse error: phandle references are only allowed in arrays with 32-bit elements")
754 /dts-v1/;
762 "/foo: bad phandle length (1), expected 4 bytes")
765 /dts-v1/;
776 /dts-v1/;
780 phandle = < (-1) >;
787 /dts-v1/;
802 /dts-v1/;
818 def verify_phandle2node(prop, offset, expected_name): argument
819 phandle = dtlib.to_num(dt.root.props[prop].value[offset:offset + 4])
823 f"'{prop}' is a phandle for the wrong thing"
826 /dts-v1/;
829 phandle_ = < &{/node1} 0 1 >;
830 phandles = < 0 &{/node2} 1 &{/node3} >;
852 /dts-v1/;
867 /dts-v1/;
883 /dts-v1/;
886 keep = < 1 >;
888 /delete-property/ missing;
889 /delete-property/ delete;
896 /delete-property/ y;
900 /dts-v1/;
912 /dts-v1/;
921 /delete-node/ &{/};
925 x = < 1 >;
929 /delete-node/ sub2;
941 /delete-node/ &sub3;
942 /delete-node/ &{/sub4};
945 /dts-v1/;
955 /dts-v1/;
968 /delete-node/ &{/};
971 /dts-v1/;
978 /dts-v1/;
983 /delete-node/ &missing;
988 /dts-v1/;
990 /delete-node/ {
999 with open("same-dir-1", "w") as f:
1002 /include/ "same-dir-2"
1004 with open("same-dir-2", "w") as f:
1007 /include/ "same-dir-3"
1009 with open("same-dir-3", "w") as f:
1015 /dts-v1/;
1018 /include/ "same-dir-1"
1023 /dts-v1/;
1030 """[1:-1]
1039 /dts-v1/;
1044 x = <1>;
1047 subdir_1 = tmp_path / "subdir-1"
1049 with open(subdir_1 / "via-include-path-1", "w") as f:
1051 = /include/ "via-include-path-2"
1054 subdir_2 = tmp_path / "subdir-2"
1056 with open(subdir_2 / "via-include-path-2", "w") as f:
1066 y /include/ "via-include-path-1"
1072 /dts-v1/;
1078 """[1:-1]
1089 ":1 (column 1): parse error: 'missing' could not be found")
1107 "expected '/dts-v1/;' at start of file"):
1122 tmp3.dts:1 (column 1): parse error: recursive /include/:
1123 tmp.dts:1 ->
1124 tmp2.dts:1 ->
1125 tmp3.dts:1 ->
1133 tmp.dts:1 (column 1): parse error: recursive /include/:
1134 tmp.dts:1 ->
1140 '''The /omit-if-no-ref/ marker is a bit of undocumented
1148 /dts-v1/;
1153 /omit-if-no-ref/ referenced {
1159 /omit-if-no-ref/ unreferenced {
1162 l1: /omit-if-no-ref/ unreferenced2 {
1165 /omit-if-no-ref/ l2: unreferenced3 {
1175 /omit-if-no-ref/ &referenced2;
1176 /omit-if-no-ref/ &unreferenced4;
1177 /omit-if-no-ref/ &{/unreferenced5};
1180 /dts-v1/;
1193 /dts-v1/;
1196 /omit-if-no-ref/ x = "";
1199 ":4 (column 21): parse error: /omit-if-no-ref/ can only be used on nodes")
1202 /dts-v1/;
1205 /omit-if-no-ref/ x;
1208 ":4 (column 20): parse error: /omit-if-no-ref/ can only be used on nodes")
1211 /dts-v1/;
1214 /omit-if-no-ref/ {
1221 /dts-v1/;
1224 /omit-if-no-ref/ = < 0 >;
1230 /dts-v1/;
1235 /omit-if-no-ref/ &missing;
1240 /dts-v1/;
1242 /omit-if-no-ref/ {
1250 /dts-v1/;
1253 ter1 = < (0 ? 1 : 0 ? 2 : 3) >;
1254 ter2 = < (0 ? 1 : 1 ? 2 : 3) >;
1255 ter3 = < (1 ? 1 : 0 ? 2 : 3) >;
1256 ter4 = < (1 ? 1 : 1 ? 2 : 3) >;
1258 or2 = < (0 || 1) >;
1259 or3 = < (1 || 0) >;
1260 or4 = < (1 || 1) >;
1262 and2 = < (0 && 1) >;
1263 and3 = < (1 && 0) >;
1264 and4 = < (1 && 1) >;
1265 bitor = < (1 | 2) >;
1268 eq1 = < (1 == 0) >;
1269 eq2 = < (1 == 1) >;
1270 neq1 = < (1 != 0) >;
1271 neq2 = < (1 != 1) >;
1272 lt1 = < (1 < 2) >;
1275 lteq1 = < (1 <= 2) >;
1278 gt1 = < (1 > 2) >;
1281 gteq1 = < (1 >= 2) >;
1287 sub = < (7 - 4) >;
1291 unary_minus = < (-3) >;
1292 bitnot = < (~1) >;
1293 not0 = < (!-1) >;
1295 not2 = < (!1) >;
1297 nest = < (((--3) + (-2)) * (--(-2))) >;
1302 /dts-v1/;
1355 /dts-v1/;
1358 a = < (1/(-1 + 1)) >;
1364 /dts-v1/;
1367 a = < (1%0) >;
1373 '''Comments should be removed when round-tripped to a str.'''
1376 /**//dts-v1//**/;//
1382 */</**/1/***/>/****/;/**/}/*/**/;
1385 /dts-v1/;
1412 /dts-v1/;
1438 "no alias '' found -- did you forget the leading '/' in the node path?",
1442 "no alias 'missing' found -- did you forget the leading '/' in the node path?",
1470 /dts-v1/;
1514 /dts-v1/;
1526 /dts-v1/;
1535 ".* is not valid UTF-8")
1538 /dts-v1/;
1546 "/aliases: alias property name 'A' should include only characters from [0-9a-z-]")
1549 /dts-v1/;
1557 "property 'a' on /aliases in .* points to the non-existent node \"/missing\"")
1562 def verify_type(prop, expected): argument
1563 actual = dt.root.props[prop].type
1564 assert actual == expected, f'{prop} has wrong type'
1567 /dts-v1/;
1575 bytes5 = /bits/ 8 < 1 2 3 >;
1576 num = < 1 >;
1579 nums3 = < 1 2 >;
1580 nums4 = < 1 2 >, < 3 >, < 4 >;
1589 phandle-and-nums-1 = < &node 1 >;
1590 phandle-and-nums-2 = < &node 1 2 &node 3 4 >;
1591 phandle-and-nums-3 = < &node 1 2 >, < &node 3 4 >;
1592 compound1 = < 1 >, [ 02 ];
1617 verify_type("phandle-and-nums-1", dtlib.Type.PHANDLES_AND_NUMS)
1618 verify_type("phandle-and-nums-2", dtlib.Type.PHANDLES_AND_NUMS)
1619 verify_type("phandle-and-nums-3", dtlib.Type.PHANDLES_AND_NUMS)
1629 /dts-v1/;
1632 u = < 1 >;
1634 u8 = /bits/ 8 < 1 >;
1635 u16 = /bits/ 16 < 1 2 >;
1636 u64 = /bits/ 64 < 1 >;
1640 two_u = < 1 2 >;
1642 three_u = < 1 2 3 >;
1643 three_u_split = < 1 >, < 2 >, < 3 >;
1667 def verify_to_num(prop, signed, expected): argument
1669 actual = dt.root.props[prop].to_num(signed)
1671 f"{prop} has bad {signed_str} numeric value"
1673 def verify_to_num_error_matches(prop, expected_re): argument
1675 dt.root.props[prop].to_num()
1677 verify_to_num("u", False, 1)
1678 verify_to_num("u", True, 1)
1680 verify_to_num("s", True, -1)
1705 def verify_to_nums(prop, signed, expected): argument
1707 actual = dt.root.props[prop].to_nums(signed)
1709 f"'{prop}' gives the wrong {signed_str} numbers"
1711 def verify_to_nums_error_matches(prop, expected_re): argument
1713 dt.root.props[prop].to_nums()
1716 verify_to_nums("u", False, [1])
1717 verify_to_nums("two_u", False, [1, 2])
1718 verify_to_nums("two_u", True, [1, 2])
1720 verify_to_nums("two_s", True, [-1, -2])
1721 verify_to_nums("three_u", False, [1, 2, 3])
1722 verify_to_nums("three_u_split", False, [1, 2, 3])
1736 def verify_to_bytes(prop, expected): argument
1737 actual = dt.root.props[prop].to_bytes()
1738 assert actual == expected, f"'{prop}' gives the wrong bytes"
1740 def verify_to_bytes_error_matches(prop, expected_re): argument
1742 dt.root.props[prop].to_bytes()
1759 def verify_to_string(prop, expected): argument
1760 actual = dt.root.props[prop].to_string()
1761 assert actual == expected, f"'{prop}' to_string gives the wrong string"
1763 def verify_to_string_error_matches(prop, expected_re): argument
1765 dt.root.props[prop].to_string()
1782 "in .* is not valid UTF-8")
1786 def verify_to_strings(prop, expected): argument
1787 actual = dt.root.props[prop].to_strings()
1788 assert actual == expected, f"'{prop}' to_strings gives the wrong value"
1790 def verify_to_strings_error_matches(prop, expected_re): argument
1792 dt.root.props[prop].to_strings()
1806 ".* is not valid UTF-8")
1810 def verify_to_node(prop, path): argument
1811 actual = dt.root.props[prop].to_node().path
1812 assert actual == path, f"'{prop}' points at wrong path"
1814 def verify_to_node_error_matches(prop, expected_re): argument
1816 dt.root.props[prop].to_node()
1831 def verify_to_nodes(prop, paths): argument
1832 actual = [node.path for node in dt.root.props[prop].to_nodes()]
1833 assert actual == paths, f"'{prop} gives wrong node paths"
1835 def verify_to_nodes_error_matches(prop, expected_re): argument
1837 dt.root.props[prop].to_nodes()
1856 def verify_to_path(prop, path): argument
1857 actual = dt.root.props[prop].to_path().path
1858 assert actual == path, f"'{prop} gives the wrong path"
1860 def verify_to_path_error_matches(prop, expected_re): argument
1862 dt.root.props[prop].to_path()
1873 "property 'missingpath' on / in .* points to the non-existent node "
1876 # Test top-level to_num() and to_nums()
1878 def verify_raw_to_num(fn, prop, length, signed, expected): argument
1879 actual = fn(dt.root.props[prop].value, length, signed)
1881 f"{fn.__name__}(<{prop}>, {length}, {signed}) gives wrong value"
1892 verify_raw_to_num(dtlib.to_num, "u", None, False, 1)
1893 verify_raw_to_num(dtlib.to_num, "u", 4, False, 1)
1895 verify_raw_to_num(dtlib.to_num, "s", None, True, -1)
1897 verify_raw_to_num(dtlib.to_nums, "u16", 2, False, [1, 2])
1899 verify_raw_to_num(dtlib.to_nums, "two_s", 4, True, [-1, -2])
1915 /dts-v1/;
1932 /dts-v1/;
1950 /dts-v1/;
1961 /dts-v1/;
1973 /dts-v1/;
1983 /dts-v1/;
2000 /dts-v1/;
2012 /dts-v1/;
2021 /delete-node/ &{/bar};
2024 /dts-v1/;
2037 /dts-v1/;
2047 x = < 1 >;
2048 /delete-property/ y;
2052 /dts-v1/;
2062 # Test self-referential node
2066 /dts-v1/;
2075 /dts-v1/;
2090 /dts-v1/;
2092 l1: l2: /memreserve/ (1 + 1) (2 * 2);
2099 /dts-v1/;
2112 /dts-v1/;
2123 /dts-v1/;
2128 y = < 1 >;
2151 /dts-v1/;
2155 \aA0,._+*#?- = &_, &{/aA0,._+@-};
2161 - = [ 01 ];
2167 _: \aA0,._+@- {
2175 /dts-v1/;
2178 aA0,._+*#?- = &_, &{/aA0,._+@-};
2181 - = [ 01 ];
2185 _: aA0,._+@- {
2193 /dts-v1/;
2202 /dts-v1/;
2211 /dts-v1/;
2222 Test that a densely written DTS input round-trips to something
2227 /dts-v1/;/{l1:l2:foo{l3:l4:bar{l5:x=l6:/bits/8<l7:1 l8:2>l9:,[03],"a";};};};
2230 /dts-v1/;
2242 '''Test miscellaneous errors and non-errors.'''
2244 verify_error_endswith("", ":1 (column 1): parse error: expected '/dts-v1/;' at start of file")
2247 /dts-v1/;
2249 ":2 (column 1): parse error: no root node defined")
2252 /dts-v1/; /plugin/;
2254 ":1 (column 11): parse error: /plugin/ is not supported")
2257 /dts-v1/;
2271 /dts-v1/;
2279 # Multiple /dts-v1/ at the start of a file is fine
2281 /dts-v1/;
2282 /dts-v1/;
2288 /dts-v1/;
2296 /dts-v1/;
2310 /dts-v1/;
2319 /dts-v1/;
2322 foo { prop = <3>; };
2325 foo { prop = <4>; };
2329 /dts-v1/;
2333 prop = < 0x4 >;
2340 /dts-v1/;
2352 ref-to-node = <&nodelabel>;
2418 assert dt_copy.label2prop_offset['prop_offset4'][1] == 4
2453 /dts-v1/;
2457 parent-alias = &parent_label;
2460 child {};
2470 child = dt.get_node('/parent/child')
2475 assert child.path == '/newpath/child'
2476 assert child.parent is parent
2477 assert child.parent is dt.get_node('/newpath')
2478 assert dt.get_node('parent-alias') is parent