Skip to content

Commit 5b46bb1

Browse files
author
Bruce Ashfield
committed
sanity: add embedded lop and phandle replacment sanity test (example)
Add a test that shows how a dts file can carry instructions to lopper on how to intepret the properties found in the dts file itself. In this example we show that on the first run the phandle is left as a number and on the second it is converted to a symbolic reference. Signed-off-by: Bruce Ashfield <bruce.ashfield@amd.com>
1 parent fa0c035 commit 5b46bb1

File tree

3 files changed

+4592
-0
lines changed

3 files changed

+4592
-0
lines changed

lopper/selftest/assist-sanity.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,48 @@ def is_compat( node, compat_string_to_test ):
3838
return assist_reference
3939
return ""
4040

41+
def phandle_meta_test( sdt, pass_number ):
42+
print( f"[INFO]: running phandle_meta_test: {sdt.output_file} pass: {pass_number}" )
43+
44+
try:
45+
if pass_number == "one":
46+
sdt.write( sdt.tree, sdt.output_file )
47+
else:
48+
sdt.write( sdt.tree, sdt.output_file )
49+
#sdt.write( sdt.tree, '/tmp/foo.dts' )
50+
#sdt.tree.print()
51+
except Exception as e:
52+
print( f"[ERROR]: {e}" )
53+
return False
54+
55+
if pass_number == "one":
56+
phandle_link_is_number = False
57+
with open( sdt.output_file ) as fp:
58+
for line in fp:
59+
if re.search( r"phandle-link.*?=.*?<0x.*>;", line ):
60+
phandle_link_is_number = True
61+
62+
if phandle_link_is_number:
63+
print( "[PASSED]: phandle-link is a number (no symbolic replacement)" )
64+
else:
65+
print( "[FAILED]: phandle-link is a number (symbolic or not found)" )
66+
67+
return phandle_link_is_number
68+
69+
if pass_number == "two":
70+
phandle_link_is_sym = False
71+
with open( sdt.output_file ) as fp:
72+
for line in fp:
73+
if re.search( r"phandle-link.*?=.*?<&amba>;", line ):
74+
phandle_link_is_sym = True
75+
76+
if phandle_link_is_sym:
77+
print( "[PASSED]: phandle-link is symbolic (replacement)" )
78+
else:
79+
print( "[FAILED]: phandle-link is a number (no replacement done)" )
80+
81+
return phandle_link_is_sym
82+
4183
def overlay_test( sdt ):
4284
overlay_tree = LopperTree()
4385

@@ -325,6 +367,12 @@ def assist_reference( tgt_node, sdt, options ):
325367
if "overlay_test" in args:
326368
overlay_test( sdt )
327369
return True
370+
elif "phandle_meta_test_1" in args:
371+
phandle_meta_test( sdt, "one" )
372+
return True
373+
elif "phandle_meta_test_2" in args:
374+
phandle_meta_test( sdt, "two" )
375+
return True
328376
else:
329377
domains_access_test( sdt )
330378
return True

0 commit comments

Comments
 (0)