def test_child_binding(): '''Test 'child-binding:' in bindings''' edt = edtlib.EDT("test.dts", ["test-bindings"]) child1 = edt.get_node("/child-binding/child-1") child2 = edt.get_node("/child-binding/child-2") grandchild = edt.get_node("/child-binding/child-1/grandchild") assert str(child1.binding_path) == hpath("test-bindings/child-binding.yaml") assert str(child1.description) == "child node" assert str(child1.props) == "OrderedDict([('child-prop', <Property, name: child-prop, type: int, value: 1>)])" assert str(child2.binding_path) == hpath("test-bindings/child-binding.yaml") assert str(child2.description) == "child node" assert str(child2.props) == "OrderedDict([('child-prop', <Property, name: child-prop, type: int, value: 3>)])" assert str(grandchild.binding_path) == hpath("test-bindings/child-binding.yaml") assert str(grandchild.description) == "grandchild node" assert str(grandchild.props) == "OrderedDict([('grandchild-prop', <Property, name: grandchild-prop, type: int, value: 2>)])" binding_file = Path("test-bindings/child-binding.yaml").resolve() top = edtlib.Binding(binding_file, {}) child = top.child_binding assert Path(top.path) == binding_file assert Path(child.path) == binding_file assert top.compatible == 'top-binding' assert child.compatible is None binding_file = Path("test-bindings/child-binding-with-compat.yaml").resolve() top = edtlib.Binding(binding_file, {}) child = top.child_binding assert Path(top.path) == binding_file assert Path(child.path) == binding_file assert top.compatible == 'top-binding-with-compat' assert child.compatible == 'child-compat'
def load_base_binding(): # Make a Binding object for base.yaml. # # This helps separate presentation for properties common to all # nodes from node-specific properties. base_yaml = ZEPHYR_BASE / 'dts' / 'bindings' / 'base' / 'base.yaml' if not base_yaml.is_file(): sys.exit(f'Expected to find base.yaml at {base_yaml}') return edtlib.Binding(os.fspath(base_yaml), {}, require_compatible=False, require_description=False)