summaryrefslogtreecommitdiff
path: root/tools/u_boot_pylib
AgeCommit message (Collapse)Author
2025-05-27u_boot_pylib: Add more functions to gitutilSimon Glass
Add functions for checking a branch, showing a commit, etc. to support the new functionality. Git version 2.34.1 ignores --stat if --quiet is given, so adjust the args so that this performs as expected. Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-27patman: Deal with git safe-directory warningSimon Glass
When running tests where the .git directory is not owned by the current user, various warnings are produced and the tests fail. This happens in CI. For patman itself, modify the gitutil.get_top_level() function to return None in this case. Ensure that the warning is not shown, since it creates about 1000 lines of output. For checkpatch, the same warning is produced even though --no-tree is given. Suppress that as well. Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-27u_boot_pylib: Correct pylint warnings in gitutilSimon Glass
Correct various pylint warnings in this file. The remaining ones are three functions with too many arguments (R0913 and R0918) and use of global (W0603). Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-27patman: Clean up creation of the git treeSimon Glass
The test starts with the HEAD pointing to the wrong place, so that the created files appear to be deleted. Fix this by resetting the tree before tests start. Add a check that the tree is clean. Update pygit2 so that the enums are available.
2025-05-27u_boot_pylib: Speed up determining the upstream branchSimon Glass
Use --decorate to quickly detect the upstream branch, since this is much faster than using 'git name-rev' on every possible commit. Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-27u_boot_pylib: Provide directories to gitutil functionsSimon Glass
For testing it is useful to be able to set the current directory used for git operations, as well as the git-repo directory. Update some of the functions to support this. Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-27u_boot_pylib: Tidy up quoting of cc and toSimon Glass
The current approach to calling 'git send-email' puts double quotes around each email address to ensure that it will pass the shell correctly. This is a bit cumbersome and requires using a shell to sort it all out. Drop the quotes and use command.run() instead, to simplify things. This will also make it possible to (later) set the current directory. Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-27u_boot_pylib: Support a fatal level in toutSimon Glass
It is convenient to be able to print a message and exit. Add a new 'fatal' level to support this. Update some assumptions about the level, so that the tools continue to work as now. Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-27patman: Pass the alias dict into gitutil.email_patches()Simon Glass
Rather than accessing the settings module in this function, require the alias dict to be passed in. Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-27patman: Pass the alias dict into gitutil.build_email_list()Simon Glass
Rather than accessing the settings module in this function, require the alias dict to be passed in. Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-27patman: Untangle settings from gitutilSimon Glass
The gitutil module is supposed to be independent from patman but one piece was missed in the series which separated them. Move the settings setup out of gitutil Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-27tools: Plumb in capture controlSimon Glass
Add control of capturing output into u_boot_pylib and the tools which use it. Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-27u_boot_pylib: Allow disabling colour outputSimon Glass
When running tests there is no situation in which we want ANSI output as it makes it much harder to see what is going on in logs, tests, etc. Provide a way to disable this. Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-27u_boot_pylib: Avoid concurrent execution of only one testSimon Glass
There is no point in spinning up multiple processes if there is only one test to execute. Add a check for this. Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-27u_boot_pylib: Add a pagerSimon Glass
It is useful to have a pager when outputting a lot of text. Add support for this in the terminal library, making use of a context manager. Also add a function to indicate whether the output device is a terminal or not, while we are here, to avoid duplicating this code. Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-27u_boot_pylib: Improve ANSI-colour output with backgroundsSimon Glass
The current implementation does not handle background colours very well: - It outputs an incorrect code in some cases, leading to wrong colours - Some functions lack a control for the background Tidy this up so that background colours can be used in more places. Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-27u_boot_pylib: Allow control of capturingSimon Glass
Tests often capture output so they can check it. This means that if the test fails it is not easy to see what the output actually was. Add a -N flag which writes out the output after it has been captured. This is not a perfect solution but it is simple and seems to work well in practice. Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-27patman: Move capture_sys_output() into terminal and renameSimon Glass
This function is sometimes useful outside tests. Also it can affect how terminal output is done, e.g. whether ANSI characters should be emitted or not. Move it out of the test_util package and into terminal. Signed-off-by: Simon Glass <sjg@chromium.org>
2025-04-24python: Use and refer to the venv module rather than virtualenvTom Rini
Using some form of sandbox with Python modules is a long standing best practice with the language. There are a number of ways to have a Python sandbox be created. At this point in time, it seems the Python community is moving towards using the "venv" module provided with Python rather than a separate tool. To match that we make the following changes: - Refer to a "Python sandbox" rather than virtualenv in comments, etc. - Install the python3-venv module in our container and not virtualenv. - In our CI files, invoke "python -m venv" rather than "virtualenv". - In documentation, tell users to install python3-venv and not virtualenv. Signed-off-by: Tom Rini <trini@konsulko.com>
2025-04-11Merge patch series "binman: Check code-coverage requirements"Tom Rini
Simon Glass <sjg@chromium.org> says: This series adds a cover-coverage check to CI for Binman. The iMX8 tests are still not completed, so a work-around is included for those. A few fixes are included for some other problems. Link: https://lore.kernel.org/r/20250410124333.843527-1-sjg@chromium.org
2025-04-11binman: Work around missing test coverageSimon Glass
The iMX8 entry-types don't have proper test coverage. Add a work-around to skip this for now. Signed-off-by: Simon Glass <sjg@chromium.org>
2025-04-11binman: Exclude dist-packages and site-packagesSimon Glass
Newer versions of the python3-coverage tool require a directory separator before and after the directory name. Add this so that system package are not included in the coverage report. Signed-off-by: Simon Glass <sjg@chromium.org>
2025-04-10patman: Show the base commit and branchSimon Glass
It is helpful to know which commit patches are based on, even if that commit might not be available to readers. Add a tag for this in the cover letter. Also add the local-branch name since that may be useful to the writer. Signed-off-by: Simon Glass <sjg@chromium.org>
2025-04-01u_boot_pylib: Clean up pylint warnings in gitutil.pySimon Glass
This file has about 40 pylint warnings, but no errors. Quite a few of these warnings have been there for a while, but most are coming from newer versions of pylint, where people come up with new warnings. The f-string warning is the most common one: C0209: Formatting a regular string which could be an f-string That feature was not available when the code was written, but it is often more convenient than using % with a list of arguments. This patches reduces the number of warnings in this file, with 7 left remaining. Signed-off-by: Simon Glass <sjg@chromium.org>
2025-03-04Merge patch series "tools: Minor clean-ups for the command library"Tom Rini
Simon Glass <sjg@chromium.org> says: This series adds comments and fixes pylint warnings in the command library. It also introduces a new, simpler way of running a single command. Link: https://lore.kernel.org/r/20250203162704.627469-1-sjg@chromium.org
2025-03-04u_boot_pylib: Add a function to run a single commandSimon Glass
Add a helper to avoid needing to use a list within a list for this simple case. Update existing users of runpipe() to use this where possible. Signed-off-by: Simon Glass <sjg@chromium.org>
2025-03-04u_boot_pylib: Fix pylint warnings in commandSimon Glass
This file has a lot of warnings. Before adding any more features, fix those which are straightforward to resolve. Signed-off-by: Simon Glass <sjg@chromium.org>
2025-03-04u_boot_pylib: Add an exception-class for errorsSimon Glass
Throwing an Exception is not very friendly since it is the top-level class of all exceptions. Declare a new class instead. Signed-off-by: Simon Glass <sjg@chromium.org>
2025-03-04u_boot_pylib: Correct case for test_resultSimon Glass
This should be in capitals and defined at the start of the file. Update it. Signed-off-by: Simon Glass <sjg@chromium.org>
2025-02-17u_boot_pylib: Move gitutil into the librarySimon Glass
Move this file into U-Boot's Python library, so that it is no-longer part of patman. This makes a start on: https://source.denx.de/u-boot/custodians/u-boot-dm/-/issues/35 Signed-off-by: Simon Glass <sjg@chromium.org>
2025-02-14python: Create requirements.txt files for each "project"Tom Rini
Rather than have a requirements.txt file that's shared between multiple python projects within U-Boot, create one for each using "pipreqs". Signed-off-by: Tom Rini <trini@konsulko.com>
2024-12-19tools: u_boot_pylib: Allow to append input directories to indirPaul HENRYS
append_input_dirs() can be used to append a list of input directories to indir global list. Signed-off-by: Paul HENRYS <paul.henrys_ext@softathome.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2024-10-18u_boot_pylib: Support running coverage on selected functionsSimon Glass
At present run_test_coverage() assumes you want code coverage for the entire code base. This is the normal situation, but sometimes it is useful to see the coverage provided by just a single test. Add support for this. Signed-off-by: Simon Glass <sjg@chromium.org>
2024-07-03u_boot_pylib: Use correct coverage tool within venvSimon Glass
When running within a Python venv we must use the 'coverage' tool (which is within the venv) so that the venv packages are used in preference to system packages. Otherwise the coverage tests run in a different environment from the normal tests and may fail due to missing packages. Handle this by detecting the venv and changing the tool name. Signed-off-by: Simon Glass <sjg@chromium.org>
2024-07-03buildman: Add a way to limit the number of buildmansSimon Glass
Buildman uses all available CPUs by default, so running more than one or two concurrent processes is not normally useful. However in some CI cases we want to be able to run several jobs at once to save time. For example, in a lab situation we may want to run a test on 20 boards at a time, since only the build step actually takes much CPU. Add an option which allows such a limit. When buildman starts up, it waits until the number of running processes goes below the limit, then claims a spot in the list. The list is maintained with a temporary file. Note that the temp file is user-specific, since it is hard to create a locked temporary file which can be accessed by any user. In most cases, only one user is running jobs on a machine, so this should not matter. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-12-13tools: Move python tools to version 0.0.6Simon Glass
A new release has been done with this version, so update it. Use the version numbers in dependencies also. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-12-13u_boot_pylib: Correct files used for pip releaseSimon Glass
The files list is incorrect and dates from a time when the script was run from a different directory. Update it to match all the other tools. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-12-13u_boot_pylib: Correct readme formattingSimon Glass
Correct a heading which is too short in the readme. Fixes: 75554dfac29 ("patman: Add support for building a u_boot_tools...") Signed-off-by: Simon Glass <sjg@chromium.org>
2023-12-13doc: Update documentation URLSimon Glass
Update to use the new docs.u-boot.org URL for documentation. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-11-02u_boot_pylib: Ensure subprocess is closed downSimon Glass
It isn't clear why we need to have two different paths for closing down the pipe. Unify them and use the Python to avoid this warning: subprocess.py:1127: ResourceWarning: subprocess 83531 is still running Note that this code appears to originally have come from [1] and was committed into the ChromeOS chromiumos/platform/crosutils repo in the bin/cros_image_to_target.py file. The addition of the extra code path came later, so that is chosen for the fixes tag. [1] https://codereview.chromium.org/3391008 Signed-off-by: Simon Glass <sjg@chromium.org> Fixes: a10fd93cbc patman: Make command methods return a CommandResult
2023-07-24buildman: Enable test coverageSimon Glass
Enable measuring test coverage for buildman so we can see the gaps. It is currently at 68%. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-07-20tools: Fix package discovery in pyproject.toml of u_boot_pylib.Maxim Cournoyer
When building from source, setuptools would complain about not finding package via its auto-discovery mechanism. Manually specify how to locate the files, relative to the package's directory. * tools/u_boot_pylib/pyproject.toml: New tool.setuptools.packages.find section. Signed-off-by: Maxim Cournoyer <maxim.cournoyer@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-07-20tools: Fix README file in pyproject.toml of u_boot_pylib.Maxim Cournoyer
* tools/u_boot_pylib/pyproject.toml (readme): Replace README.md with README.rst. Signed-off-by: Maxim Cournoyer <maxim.cournoyer@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-03-08patman: Add support for building a u_boot_tools PyPi packageSimon Glass
Create the necessary files to build this new package. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-03-08patman: Move library functions into a library directorySimon Glass
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>