@@ -939,6 +939,68 @@ def test_child_dependencies():
939939 assert edt .get_node ("/child-binding/child-1/grandchild" ) in dep_node .required_by
940940 assert edt .get_node ("/child-binding/child-2" ) in dep_node .required_by
941941
942+ def test_child_phandle_circular_dependency (tmp_path ):
943+ '''Test parent phandles to child states do not create dependency cycles.'''
944+
945+ binding_dir = tmp_path / "bindings"
946+ binding_dir .mkdir ()
947+
948+ binding_file = binding_dir / "test-stm.yaml"
949+ binding_file .write_text ("""
950+ description: Generic child state dependency test
951+
952+ compatible: "test,stm"
953+
954+ properties:
955+ states:
956+ type: phandles
957+
958+ child-binding:
959+ description: state node
960+ properties:
961+ next-state:
962+ type: int
963+ """ , encoding = "utf-8" )
964+
965+ dts_file = tmp_path / "child-descendant-ref.dts"
966+ dts_file .write_text ("""
967+ /dts-v1/;
968+
969+ / {
970+ test_stm {
971+ compatible = "test,stm";
972+ states = <&state1 &state2 &state3>;
973+
974+ state1: state1 {
975+ next-state = <2>;
976+ };
977+
978+ state2: state2 {
979+ next-state = <3>;
980+ };
981+
982+ state3: state3 {
983+ next-state = <1>;
984+ };
985+ };
986+ };
987+ """ , encoding = "utf-8" )
988+
989+ edt = edtlib .EDT (os .fspath (dts_file ), [os .fspath (binding_dir )])
990+
991+ parent = edt .get_node ("/test_stm" )
992+ states = [
993+ edt .get_node ("/test_stm/state1" ),
994+ edt .get_node ("/test_stm/state2" ),
995+ edt .get_node ("/test_stm/state3" ),
996+ ]
997+
998+ assert parent .props ["states" ].val == states
999+ for state in states :
1000+ assert parent not in state .required_by
1001+ assert state not in parent .depends_on
1002+ assert parent in state .depends_on
1003+
9421004def test_slice_errs (tmp_path ):
9431005 '''Test error messages from the internal _slice() helper'''
9441006
0 commit comments