diff options
-rw-r--r-- | tools/binman/control.py | 6 | ||||
-rw-r--r-- | tools/binman/ftest.py | 7 | ||||
-rw-r--r-- | tools/binman/test/346_remove_template.dts | 49 |
3 files changed, 61 insertions, 1 deletions
diff --git a/tools/binman/control.py b/tools/binman/control.py index e73c598298c..81f61e3e152 100644 --- a/tools/binman/control.py +++ b/tools/binman/control.py @@ -522,9 +522,13 @@ def _ProcessTemplates(parent): def _RemoveTemplates(parent): """Remove any templates in the binman description """ + del_nodes = [] for node in parent.subnodes: if node.name.startswith('template'): - node.Delete() + del_nodes.append(node) + + for node in del_nodes: + node.Delete() def PrepareImagesAndDtbs(dtb_fname, select_images, update_fdt, use_expanded, indir): """Prepare the images to be processed and select the device tree diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py index 1a92a99b511..948fcc02259 100644 --- a/tools/binman/ftest.py +++ b/tools/binman/ftest.py @@ -7990,5 +7990,12 @@ fdt fdtmap Extract the devicetree blob from the fdtmap """Test an image with an FIT with multiple FDT images using NAME""" self.CheckFitFdt('345_fit_fdt_name.dts', use_seq_num=False) + def testRemoveTemplate(self): + """Test whether template is removed""" + TestFunctional._MakeInputFile('my-blob.bin', b'blob') + TestFunctional._MakeInputFile('my-blob2.bin', b'other') + self._DoTestFile('346_remove_template.dts', + force_missing_bintools='openssl',) + if __name__ == "__main__": unittest.main() diff --git a/tools/binman/test/346_remove_template.dts b/tools/binman/test/346_remove_template.dts new file mode 100644 index 00000000000..e05229f3ebc --- /dev/null +++ b/tools/binman/test/346_remove_template.dts @@ -0,0 +1,49 @@ +// SPDX-License-Identifier: GPL-2.0+ + +/dts-v1/; +/ { + binman: binman { + multiple-images; + + template_1: template-1 { + section { + phandle1: my-blob.bin { + filename = "my-blob.bin"; + type = "blob-ext"; + }; + }; + }; + template_2: template-2 { + section { + ti-secure { + content = <&phandle2>; + keyfile = "key.pem"; + }; + phandle2: my-blob.bin { + filename = "my-blob.bin"; + type = "blob-ext"; + }; + }; + }; + template_3: template-3 { + section { + phandle3: my-blob.bin { + filename = "my-blob.bin"; + type = "blob-ext"; + }; + }; + }; + + file1 { + insert-template = <&template_1>; + }; + + file2 { + insert-template = <&template_2>; + }; + + file3 { + insert-template = <&template_3>; + }; + }; +}; |