summaryrefslogtreecommitdiff
path: root/tools/dtoc/test_fdt.py
AgeCommit message (Collapse)AuthorFilesLines
2023-08-02fdt: Allow copying phandles into templatesSimon Glass1-4/+17
Allow phandles to be copied over from a template. This can potentially cause duplicate phandles, so detect this and report an error. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-08-02dtoc: Add some debugging when copying nodesSimon Glass1-1/+2
Show the operations being performed, when debugging is enabled. Convert a mistaken 'print' in test_copy_subnodes_from_phandles() while we are here. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-08-02dtoc: Make properties dirty when purging themSimon Glass1-3/+13
Without the 'dirty' flag properties are not written back to the devicetree when synced. This means that new properties copied over to a node are not always written out. Fix this and add a test. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-07-20dtoc: Allow inserting a list of nodes into anotherSimon Glass1-0/+39
Provide a way to specify a phandle list of nodes which are to be inserted into an existing node. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-07-20dtoc: Support copying the contents of a node into anotherSimon Glass1-0/+74
This permits implementation of a simple templating system, where a node can be reused as a base for others. For now this adds new subnodes after any existing ones. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-05-04tools: fix TestFdtUtil()Heinrich Schuchardt1-2/+2
Variable old_outdir cannot be used before assignment. The assignment must occur before the try block. tools/dtoc/test_fdt.py:796:26: E0601: Using variable 'old_outdir' before assignment (used-before-assignment) Add missing space in assignment. Fixes: a004f29464d1 ("binman: Tidy up _SetupDtb() to use its own temporary file") Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-03-08patman: Move library functions into a library directorySimon Glass1-3/+4
The patman directory has a number of modules which are used by other tools in U-Boot. This makes it hard to package the tools using pypi since the common files must be copied along with the tool that uses them. To address this, move these files into a new u_boot_pylib library. This can be packaged separately and listed as a dependency of each tool. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-02-14dm: treewide: Complete migration to new driver model schemaSimon Glass1-4/+4
Update various build and test components to use the new schema. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-19dtoc: Add a way to read a phandle with paramsSimon Glass1-0/+11
Add a function to read a phandle and associated name and offset. This is useful for binman. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-09-13dtoc: Drop sys.exit() in test_fdtSimon Glass1-1/+0
This breaks using pytest to run the tests. Drop it. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-08-09dtoc: Correct remaining pylint problems in test_fdtSimon Glass1-113/+141
Fix various camel-case and other naming problems. Update the pylint base file to avoid regressions. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-08-09test_fdt: Convert to use argparseSimon Glass1-19/+20
Drop the deprecated OptionParser. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-08-09dtoc: Move main program into its own functionSimon Glass1-20/+24
Use a function for the main program so everything there doesn't look like a global variable to pylint. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-08-09dtoc: Fix fdt test coverageSimon Glass1-1/+1
Fix a bug that the --processes option was ignored, thus resulting in no test coverage information being generated. Signed-off-by: Simon Glass <sjg@chromium.org> Fixes: 42ae363ddd9 ("dtoc: Update fdt tests to use test_util")
2022-08-09dtoc: Tidy up fdt_tests RunTests()Simon Glass1-6/+9
Pass the options args in rather than using the global variables. Use snake case, fix up comments and use a ternary operator to make pylint happy. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-08-09dtoc: Tidy up fdt_tests RunTestCoverage() argsSimon Glass1-4/+8
Pass the options args in rather than using the global various. Use snake case and fix up comments to make pylint happy. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-06-28patman: test_util: Use unittest text runner to print test resultsAlper Nebi Yasak1-4/+4
The python tools' test utilities handle printing test results, but the output is quite bare compared to an ordinary unittest run. Delegate printing the results to a unittest text runner, which gives us niceties like clear separation between each test's result and how long it took to run the test suite. Unfortunately it does not print info for skipped tests by default, but this can be handled later by a custom test result subclass. It also does not print the tool name; manually print a heading that includes the toolname so that the outputs of each tool's tests are distinguishable in the CI output. Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2022-06-28dtoc: Update fdt tests to use test_utilSimon Glass1-17/+10
Use the common functions to run tests and report results. Ensure that the result code indicates success or failure. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
2022-03-19dtoc: Tidy up implementation of AddStringList()Simon Glass1-0/+8
Refactor this to avoid a loop. Also add a test for an empty string. Signed-off-by: Simon Glass <sjg@chromium.org> Suggested-by: Alper Nebi Yasak <alpernebiyasak@gmail.com> Reviewed-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
2022-03-19dtoc: Make GetArgs() more flexibleSimon Glass1-1/+5
At present it is not possible to have arguments which include spaces. Update the function to only split the args if the property is a single string. This is a bit inconsistent, but might still be useful. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Alper Nebi Yasak <alpernebiyasak@gmail.com> Suggested-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
2022-03-02dtoc: Correct pylint errorsSimon Glass1-3/+3
Fix pylint errors in this directory. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-02-22dtoc: Support reading a list of argumentsSimon Glass1-0/+15
It is helpful to support a string or stringlist containing a list of space-separated arguments, for example: args = "-n fred", "-a", "123"; This resolves to the list: -n fred -a 123 which can be passed to a program as arguments. Add a helper to do the required processing. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-02-22dtoc: Allow deleting nodes and adding them in the same syncSimon Glass1-0/+11
This does not work at present, since the current algorithm assumes that either there are no nodes or all nodes have an offset. If a node is new, but an old node is still in the tree, then syncing fails due to this assumption. Fix it and add a test. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-02-22dtoc: Support deleting a nodeSimon Glass1-0/+9
Add a function to delete a node. This is synced to the tree when requested. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-02-22dtoc: Support adding a string list to a device treeSimon Glass1-0/+8
Add a new function to add a string list. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-02-09patman: Convert camel case in test_util.pySimon Glass1-1/+1
Convert this file to snake case and update all files which use it. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-02-09patman: Convert camel case in tools.pySimon Glass1-16/+16
Convert this file to snake case and update all files which use it. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-12-05dtoc: Add support for reading string-list propertiesSimon Glass1-0/+9
Add a function to read a list of strings from the devicetree. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-12-02dtoc: Add support for reading fixed-length bytes propertiesSimon Glass1-0/+17
Add functions to read a sequence of bytes from the devicetree. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-12-02dtoc: Add support for reading 64-bit intsSimon Glass1-3/+18
Add functions to read a 64-bit integer property from the devicetree. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-12-02dtoc: Bring in the libfdt module automaticallySimon Glass1-0/+6
Use the same technique as with binman to load this module from the U-Boot tree if available. This allows running tests without having to specify the PYTHONPATH variable. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-08-08dtoc: Correct the intarray-widening test caseSimon Glass1-1/+1
This case was intended to check that widening an int array with an int does nothing. Fix it. Reported-by: Walter Lozano <walter.lozano@collabora.com> Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Walter Lozano <walter.lozano@collabora.com>
2021-08-01dtoc: Support widening a bool valueSimon Glass1-2/+16
At present if we see 'ranges' property (with no value) we assume it is a boolean, as per the devicetree spec. But another node may define 'ranges' with a value, forcing us to widen it to an int array. At present this is not supported and causes an error. Fix this and add some test cases. Signed-off-by: Simon Glass <sjg@chromium.org> Reported-by: Tom Rini <trini@konsulko.com>
2021-08-01dtoc: Fix widening an int array to an intSimon Glass1-1/+10
An int array can hold a single int so we should not need to do anything in the widening operation. However due to a quirk in the code, an int[3] widened with an int produced an int[4]. Fix this and add a test. Fix a comment typo while we are here. Signed-off-by: Simon Glass <sjg@chromium.org> Reported-by: Tom Rini <trini@konsulko.com>
2021-03-27dtoc: Add new check that offsets are correctSimon Glass1-0/+16
Add a few more internal checks to make sure offsets are correct, before updating the dtb. To make this easier, update the functions which add a property to return that property,. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-03-27dtoc: Support adding subnodes alongside existing onesSimon Glass1-0/+16
So far we have only needed to add subnodes to empty notds, so have not had to deal with ordering. However this feature is needed for binman's expanded nodes, since there may be another node in the same section. While libfdt adds new properties after existing properties, it adds new subnodes before existing subnodes. This means that we must reorder the nodes in the cached version, so that the ordering remains consistent. Update the sync implementation to sync existing subnodes first, then add new ones, then tidy up the ordering in the cached version. Update the test to cover this behaviour. Also improve the comment about property syncing while we are here. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-03-27dtoc: Add a subnode test for multiple nodesSimon Glass1-12/+30
Add a new test that adds a subnode alongside an existing one, as well as adding properties to a subnode. This will expand to adding multiple subnodes in future patches. Put a node after the one we are adding to so we can check that things sync correctly. The testAddNode() test should be in the TestNode class since it is a node test, so move it. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-03-27dtoc: Improve internal error for Refresh()Simon Glass1-1/+1
Add the node name too so it is easy to see which node failed. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-03-22dtoc: Move test files into a test/ directorySimon Glass1-10/+21
It is confusing to have the test files in the same places as the implementation. Move them into a separate directory. Add a helper function for test_dtoc, to avoid repeating the same path. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-01-31binman: Support alignment of filesSimon Glass1-0/+6
When packing files it is sometimes useful to align the start of each file, e.g. if the flash driver can only access 32-bit-aligned data. Provides a new property to support this. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-12-13patman: Drop tools.ToChar() and ToChars()Simon Glass1-1/+1
This is useful anymore, since we always want to call chr() in Python 3. Drop it and adjust callers to use chr(). Also drop ToChars() which is no-longer used. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-12-13fdt: Use an Enum for the data typeSimon Glass1-16/+16
Use an Enum instead of the current ad-hoc constants, so that there is a data type associated with each 'type' value. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-10-29dtoc: Fix widening of int to bytesSimon Glass1-0/+10
At present an integer is converted to bytes incorrectly. The whole 32-bit integer is inserted as the first element of the byte array, and the other three bytes are skipped. This was not noticed because the unit test did not check it, and the functional test was checking for wrong values. Update the code to handle this as a special case. Add one more test to cover all code paths. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-07-25dtoc: Allow adding variable-sized data to a dtbSimon Glass1-0/+4
Add a method for adding a property containing arbitrary bytes. Make sure that the tree can expand as needed in this case. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-07-24Revert "Merge tag 'dm-pull-20jul20' of git://git.denx.de/u-boot-dm"Tom Rini1-4/+0
This reverts commit 5d3a21df6694ebd66d5c34c9d62a26edc7456fc7, reversing changes made to 56d37f1c564107e27d873181d838571b7d7860e7. Unfortunately this is causing CI failures: https://travis-ci.org/github/trini/u-boot/jobs/711313649 Signed-off-by: Tom Rini <trini@konsulko.com>
2020-07-20dtoc: Allow adding variable-sized data to a dtbSimon Glass1-0/+4
Add a method for adding a property containing arbitrary bytes. Make sure that the tree can expand as needed in this case. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-04-26patman: Tidy up sys.path changesSimon Glass1-2/+1
Now that we are using absolute paths we can remove some of the sys.path mangling that appears in the tools. We only need to add the path to 'tools/' so that everything can find modules relative to that directory. The special paths for finding pylibfdt remain. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-04-26patman: Move to absolute importsSimon Glass1-6/+6
At present patman sets the python path on startup so that it can access the libraries it needs. If we convert to use absolute imports this is not necessary. Move patman to use absolute imports. This requires changes in tools which use the patman libraries (which is most of them). Signed-off-by: Simon Glass <sjg@chromium.org>
2020-04-26patman: Drop references to __future__Simon Glass1-2/+0
We don't need these now that the tools using Python 3. Drop them. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-11-05test_fdt: Move to use Python 3Simon Glass1-1/+1
Update this test to use Python 3 to meet the 2020 deadline. Signed-off-by: Simon Glass <sjg@chromium.org>