aboutsummaryrefslogtreecommitdiff
path: root/tools/patman/test_util.py
AgeCommit message (Collapse)AuthorFilesLines
2023-03-08patman: Move library functions into a library directorySimon Glass1-216/+0
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-03-08Remove concurrencytestSimon Glass1-2/+2
While our version is better, it is tricky to use it when we are trying to package things with pip. Drop it. Somewhat reduced functionality is provided by the upstream version[1], along with a rather annoying message each time it is used[2] [3]. [1] pip install concurrencytest [2] https://github.com/cgoldberg/concurrencytest/issues/12 [3] https://github.com/cgoldberg/concurrencytest/pull/14 Signed-off-by: Simon Glass <sjg@chromium.org>
2023-03-08Revert "patman: test_util: Print test stdout/stderr within test summaries"Simon Glass1-32/+1
Unfortunately this adds a new feature to concurrencytest and it has not made it upstream to the project[1]. Drop it for now so we can use the upstream module. Once it is applied we can bring this functionality back. [1] https://github.com/cgoldberg/concurrencytest This reverts commit ebcaafcded40da8ae6cb4234c2ba9901c7bee644. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-08-20patman: Don't buffer test output with a single testSimon Glass1-2/+2
When a single test is run we don't need to buffer the test output. This has the unfortunate side effect of suppressing test output, in particular the binman output directory normally printed with the -X option. This is a huge problem since it blocks debugging of tests. We don't actually know how many tests will be run when we set up the suite, so as a work-around, assume that test_name being specified indicates that there is likely only one. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-08-20patman: Put the coverage command-line lastSimon Glass1-2/+1
Put this at the end so it is easier to copy it from the terminal. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-06-28patman: test_util: Print test stdout/stderr within test summariesAlper Nebi Yasak1-1/+32
While running tests for a python tool, the tests' outputs get printed in whatever order they happen to run, without any indication as to which output belongs to which test. Unittest supports capturing these outputs and printing them as part of the test summaries, but when a failure or error occurs it switches back to printing as the tests run. Testtools and subunit tests can do the same as their parts inherit from unittest, but they don't outright expose this functionality. On the unittest side, enable output buffering for the custom test result class. Try to avoid ugly outputs by not printing stdout/stderr before the test summary for low verbosity levels and for successful tests. On the subunit side, implement a custom TestProtocolClient that enables the same underlying functionality and injects the captured streams as additional test details. This causes them to be merged into their test's error traceback message, which is later rebuilt into an exception and passed to our unittest report class. Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2022-06-28patman: test_util: Customize unittest test results for more infoAlper Nebi Yasak1-0/+46
By default, unittest test summaries only print extended info about tests that failed or couldn't run due to an error. Use a custom text result class to print info about more cases: skipped tests, expected failures and unexpected successes. Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
2022-06-28patman: test_util: Use unittest text runner to print test resultsAlper Nebi Yasak1-37/+21
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-28patman: test_util: Handle nonexistent tests while loading testsAlper Nebi Yasak1-16/+5
It's possible to request a specific test to run when trying to run a python tool's tests. If we request a nonexistent test, the unittest loaders generate a fake test that reports this as an error. However, we get these fake tests even when the test exists, because test_util can load tests from multiple places one by one and the test we want only exists in one. The test_util helpers currently remove these fake tests when printing test results, but that's more of a workaround than a proper solution. Instead, don't even try to load the missing tests. Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2022-06-28patman: test_util: Fix printing results for failed testsAlper Nebi Yasak1-1/+1
When printing a python tool's test results, the entire list of failed tests and their tracebacks are reprinted for every failed test. This makes the test output quite unreadable. Fix the loop to print failures and tracebacks one at a time. Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2022-02-09patman: Convert camel case in test_util.pySimon Glass1-4/+4
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 command.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-08patman: Update test_util to run doc testsSimon Glass1-6/+11
At present this function does not run the doctests. Allow the caller to pass these modules in as strings. Update patman to use this. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-07-26binman: Re-enable concurrent testsSimon Glass1-1/+3
With the change to absolute imports the concurrent tests feature unfortunately broke. Fix it. We cannot easy add a warning, since the output messes up tests which check the output. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-07-24binman: Specify the toolpath when running test coverageSimon Glass1-3/+6
At present binman's test coverage runs without a toolpath set. This means that the system tools will be used. That may not be correct if they are out of date or missing and this can result in a reduction in test coverage below 100%. Provide the toolpath to binman in this case. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-07-24patman: Add a 'test' subcommandSimon Glass1-1/+1
At present we use --test to indicate that tests should be run. It is better to use a subcommand for list, like binman. Change it and adjust the existing code to fit under a 'send' subcommand, the default. Give this subcommand the same default arguments as the others. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-07-24patman: Use test_util to show test resultsSimon Glass1-3/+3
This handles skipped tests correctly, so use it instead of the existing code. 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-13/+8
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-20binman: Re-enable concurrent testsSimon Glass1-1/+3
With the change to absolute imports the concurrent tests feature unfortunately broke. Fix it. We cannot easy add a warning, since the output messes up tests which check the output. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-07-20binman: Specify the toolpath when running test coverageSimon Glass1-3/+6
At present binman's test coverage runs without a toolpath set. This means that the system tools will be used. That may not be correct if they are out of date or missing and this can result in a reduction in test coverage below 100%. Provide the toolpath to binman in this case. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-07-20patman: Add a 'test' subcommandSimon Glass1-1/+1
At present we use --test to indicate that tests should be run. It is better to use a subcommand for list, like binman. Change it and adjust the existing code to fit under a 'send' subcommand, the default. Give this subcommand the same default arguments as the others. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-07-20patman: Use test_util to show test resultsSimon Glass1-3/+3
This handles skipped tests correctly, so use it instead of the existing code. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-07-09patman: Drop import of test_util in test_utilSimon Glass1-1/+0
This module doesn't need to import itself. It causes problems on very old Python 3 (e.g. 3.4.0). Drop it. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-04-26patman: Move to absolute importsSimon Glass1-1/+2
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: Move test running/reporting to test_utilSimon Glass1-0/+100
This code is useful in other tools. Move it into a common file so it can be shared. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-04-26patman: Drop the python2 code in test coverageSimon Glass1-7/+8
We don't need to run test coverage with Python 2 now. Drop the special-case code. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-04-26binman: Rename the main moduleSimon Glass1-1/+1
Python does not like the module name being the same as the module directory. To allow buildman modules to be used from other tools, rename it. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-04-26patman: Drop Python 2 StringIO codeSimon Glass1-4/+1
We can rely on Python 3 now, so drop the workaround for importing StringIO. 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-07-24binman: Allow easy importing of entry modulesSimon Glass1-0/+1
At present entry modules can only be accessed using Entry.Lookup() or Entry.Create(). Most of the time this is fine, but sometimes a module needs to provide constants or helper functions useful to other modules. It is easier in this case to use 'import'. Add an __init__ file to permit this. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-24binman: Convert to use ArgumentParserSimon Glass1-2/+3
This class is the new way to handle arguments in Python. Convert binman over to use it. At the same time, introduce commands so that we can separate out the different parts of binman functionality. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-10patman: Update cover-coverage tests for Python 3Simon Glass1-6/+9
We need slightly different commands to run code coverage with Python 3. Update the RunTestCoverage() function to handle this. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-10patman: Convert print statements to Python 3Simon Glass1-7/+9
Update all print statements to be functions, as required by Python 3. Signed-off-by: Simon Glass <sjg@chromium.org>
2018-10-08binman: Run tests concurrentlySimon Glass1-1/+1
At present the tests run one after the other using a single CPU. This is not very efficient. Bring in the concurrencytest module and run the tests concurrently, using one process for each CPU by default. A -P option allows this to be overridden, which is necessary for code-coverage to function correctly. This requires fixing a few tests which are currently not fully independent. At some point we might consider doing this across all pytests in U-Boot. There is a pytest version that supports specifying the number of processes to use, but it did not work for me. Signed-off-by: Simon Glass <sjg@chromium.org>
2018-07-09binman: Move capture_sys_output() to test_utilSimon Glass1-0/+21
This function is useful in various tests. Move it into the common test utility module. Signed-off-by: Simon Glass <sjg@chromium.org>
2018-07-09binman: Move coverage logic into a new test_util fileSimon Glass1-0/+64
At present only binman has the logic for determining Python test coverage but this is useful for other tools also. Move it out into a separate file so it can be used by other tools. Signed-off-by: Simon Glass <sjg@chromium.org>