summaryrefslogtreecommitdiff
path: root/include/test
AgeCommit message (Collapse)AuthorFilesLines
2020-10-30Merge tag 'dm-pull-30oct20' of ↵Tom Rini1-0/+11
https://gitlab.denx.de/u-boot/custodians/u-boot-dm of-platdata and dtoc improvements sandbox SPL tests binman support for compressed sections
2020-10-30test: Add a test for log filter-*Sean Anderson1-0/+1
This exercises a few success and failure modes of the log filter-* commands. log filter-list is not tested because it's purely informational. I don't think there's a good way to test it except by testing if the output of the command exactly matches a sample run. Signed-off-by: Sean Anderson <seanga2@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2020-10-30test: log: Convert log_test from python to CSean Anderson1-0/+2
When rebasing this series I had to renumber all my log tests because someone made another log test in the meantime. This involved updaing a number in several places (C and python), and it wasn't checked by the compiler. So I though "how hard could it be to just rewrite in C?" And though it wasn't hard, it *was* tedious. Tests are numbered the same as before to allow for easier review. A note that if a test fails, everything after it will probably also fail. This is because that test won't clean up its filters. There's no easy way to do the cleanup, except perhaps removing all filters in a wrapper function. Signed-off-by: Sean Anderson <seanga2@gmail.com>
2020-10-29dm: test: Add a way to run SPL testsSimon Glass1-0/+11
Add a -u flag for U-Boot SPL which requests that unit tests be run. To make this work, export dm_test_main() and update it to skip test features that are not used with of-platdata. To run the tests: $ spl/u-boot-spl -u U-Boot SPL 2020.10-rc5 (Oct 01 2020 - 07:35:39 -0600) Running 0 driver model tests Failures: 0 At present there are no SPL unit tests. Note that there is one wrinkle with these tests. SPL has limited memory available for allocation. Also malloc_simple does not free memory (free() is a nop) and running tests repeatedly causes driver-model to reinit multiple times and allocate memory. Therefore it is not possible to run more than a few tests at a time. One solution is to increase the amount of malloc space in sandbox_spl. This is not a problem for pytest, since it runs each test individually, so for now this is left as is. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-10-06bloblist: Compare addresses rather than pointers in testsSimon Glass1-0/+13
When running these tests on sandbox any failures result in very large or long pointer values which are a pain to work with. Map them to an address so it is easier to diagnose failures. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-08-08cmd: Update the memory-search commandSimon Glass1-0/+1
Add various fixes and improvements to this command that were missed in the original version. Unfortunately I forgot to send v2. - Fix Kconfig name - Use a separate variable for the remaining search length - Correct a minor bug - Move into a separate test suite - Add -q flag to the 'quiet' test to test operation when console is enabled - Enable the feature for sandbox Signed-off-by: Simon Glass <sjg@chromium.org>
2020-08-08test: Add a flag for tests that need console recordingSimon Glass1-0/+1
Allow tests that need console recording to be marked, so they can be skipped if it is not available. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-08-08dm: Rename DM test flags to make them more genericSimon Glass1-0/+10
The test flags used by driver model are currently not available to other tests. Rather than creating two sets of flags, make these flags generic by changing the DM_ prefix to UT_ and moving them to the test.h header. This will allow adding other test flags without confusion. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-08-08test: Add a way to check part of a console line or skip itSimon Glass1-0/+59
Some lines of the output are not worth testing, or not worth testing in their entirety. For example, when checking a hex dump we know that the hex-dump routine can display ASCII so we only need to check the hex bytes, not the ASCII dump. Add a new test macros which can check only part of a console line. Sometimes it is useful to skip a line altogether, so add a macro for that also. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-08-04dm: core: Drop header files from dm/test.hSimon Glass1-0/+1
These header file should not be included in other header files. Remove them and add to each individual file. Add test/test.h to test/ui.h since that is a reasonable place. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-07-17acpi: Support writing a nameSimon Glass1-0/+17
ACPI supports storing names which are made up of multiple path components. Several special cases are supported. Add a function to emit a name. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Wolfgang Wallner <wolfgang.wallner@br-automation.com> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
2020-07-01clk: Add K210 pll supportSean Anderson1-0/+16
This pll code is primarily based on the code from the kendryte standalone sdk in lib/drivers/sysctl.c. k210_pll_calc_config is roughly analogous to the algorithm used to set the pll frequency, but it has been completely rewritten to be fixed-point based. Signed-off-by: Sean Anderson <seanga2@gmail.com> CC: Lukasz Majewski <lukma@denx.de>
2020-05-19command: Remove the cmd_tbl_t typedefSimon Glass2-12/+18
We should not use typedefs in U-Boot. They cannot be used as forward declarations which means that header files must include the full header to access them. Drop the typedef and rename the struct to remove the _s suffix which is now not useful. This requires quite a few header-file additions. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-05-09test: describe naming conventions for macro UNIT_TESTHeinrich Schuchardt1-1/+23
Strict naming conventions have to be followed for Python function generate_ut_subtest() to collect C unit tests to be executed via command 'ut'. Describe the requirements both on the C as well on the Python side. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Stephen Warren <swarren@nvidia.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2020-04-24test: Add the beginnings of some string testsSimon Glass1-0/+1
There are quite a few string functions in U-Boot with no tests. Make a start by adding a test for strtoul(). Signed-off-by: Simon Glass <sjg@chromium.org>
2020-04-16Merge tag 'dm-pull-10apr20-take2' of git://git.denx.de/u-boot-dmTom Rini3-0/+33
Functions for reading indexed values from device tree Enhancements to 'dm' command Log test enhancements and syslog driver DM change to read parent ofdata before children Minor fixes
2020-04-16dm: test: add test case for dev_read_u64 functionDario Binacchi1-0/+16
Add test case to cover dev_read_u64 and dev_read_u64_default functions. Signed-off-by: Dario Binacchi <dariobin@libero.it> Reviewed-by: Simon Glass <sjg@chromium.org>
2020-04-16test: log functions with CONFIG_LOG=nHeinrich Schuchardt2-0/+17
If CONFIG_LOG=n, we still expect output for log_err(), log_warning(), log_notice(), log_info() and in case of DEBUG=1 also for log_debug(). Provide unit tests verifying this. The tests depend on: CONFIG_CONSOLE_RECORD=y CONFIG_LOG=n CONFIG_UT_LOG=y It may be necessary to increase the value of CONFIG_SYS_MALLOC_F_LEN to accommodate CONFIG_CONSOLE_RECORD=y. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Simon Glass <sjg@chromium.org>
2020-04-16test: Add hexdump.h to the unit test headerSimon Glass1-0/+1
Since ut_asserteq_mem() uses bin2hex() we should include this header in ut.h to avoid errors. Add it. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Wolfgang Wallner <wolfgang.wallner@br-automation.com>
2020-02-06test: Add a way to check each line of console outputSimon Glass2-0/+69
When writing tests to check the output from commands it is useful to be able to check the output line by line using an assertion. Add helper macros to support this and to check that there is no unexpected trailing data. Also some commands produce a dump using print_buffer(). Add a way to check that the correct number of bytes are dumped (ignoring the actual contents). Signed-off-by: Simon Glass <sjg@chromium.org>
2020-02-06test: Add underscore prefix to macro parametersSimon Glass1-22/+22
If a test happens to use the same variable as the macro parameter the macro does not work as intended. Add an underscore to guard against this. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-01-09Merge tag 'dm-pull-8jan20' of git://git.denx.de/u-boot-dmTom Rini2-0/+26
dm: Increased separation of ofdata_to_platdata() and probe methods
2020-01-08dm: devres: Add a new OFDATA phaseSimon Glass1-1/+2
Since the ofdata_to_platdata() method can allocate resources, add it as a new devres phase. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-01-08dm: test: Add a test driver for devresSimon Glass1-0/+9
Add a driver which does devres allocations so that we can write tests for devres. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-01-08test: Add functions to find the amount of allocated memorySimon Glass1-0/+16
The malloc() implementations provides a way of finding out the approximate amount of memory that is allocated. Add helper functions to make it easier to access this and see changes over time. This is useful for tests that want to check if memory has been allocated or freed. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-01-07cmd_ut: add a parameter prefix to the function cmd_ut_categoryPhilippe Reynes1-1/+3
There is black magic in the file conftest.py that list all the test unit. Then, all those test unit are called in pytest. This call is done with the end of the name (for example checksum if the full name is bloblist_test_checksum). The result is that only test for dm are really executed. by pytest, all others tests are listed but never executed. This behaviour happens because the dm test unit only check the end of the name and others tests checks the full name. To fix this issue, I've added a prefix to the function cmd_ut_category, and this prefix is removed when looking for the unit test. Signed-off-by: Philippe Reynes <philippe.reynes@softathome.com> Tested-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-11-14tests: add OP-TEE test suiteHeiko Stuebner2-0/+15
OP-TEE can get supplied with a devicetree and will then insert its firmware node and reserved-memory sections into it. As this devicetree often is not the one supplied to a later loaded kernel, a previous commit added functionality to transfer these nodes onto that new devicetree. To make sure this functionality stays intact, also add a test for the transfer functionality. Signed-off-by: Heiko Stuebner <heiko.stuebner@theobroma-systems.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2019-10-27sandbox: test: Show hex values on failureSimon Glass1-1/+2
Quite a few tests use addresses or hex values for comparisons. Add hex output for test failures, e.g.: 0x55ca22fa == reg: Expected 0x55ca22fa (1439310586), got 0x55ea22fb (1441407739) Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
2019-02-09test: provide unit test for memory functionsHeinrich Schuchardt2-0/+15
Memory functions may have architecture specific implementations. These should be tested. Provide unit tests for memset(), memcpy(), memmove(). Provide a 'ut lib' sub-command to execute the tests. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Simon Glass <sjg@chromium.org>
2018-11-26test: Add a simple test for bloblistSimon Glass1-0/+1
Add a unit test for the bloblist functionality and enable bloblist for sandbox. Signed-off-by: Simon Glass <sjg@chromium.org>
2018-09-28test: Add ut_asserteq_memMario Six1-0/+18
Add a unit test assert-method, which compares two given memory areas for byte-wise equality. Signed-off-by: Mario Six <mario.six@gdsys.cc> Reviewed-by: Simon Glass <sjg@chromium.org>
2018-09-23test: unit tests for Unicode functionsHeinrich Schuchardt1-1/+2
Provide unit tests for Unicode functions. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-08-31test: fix typo in cmd_ut_category() descriptionHeinrich Schuchardt1-1/+1
argc = 1: all tests are run argc > 1: only argv[1] is run So we need argc >= 1. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Simon Glass <sjg@chromium.org>
2018-07-19test: Add ut_assertnull macroRamon Fried1-0/+12
Add ut_assertnull macro to include/test/ut.h For testing of functions that returns NULL on errors. Signed-off-by: Ramon Fried <ramon.fried@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2018-05-07SPDX: Convert all of our single license tags to Linux Kernel styleTom Rini6-12/+6
When U-Boot started using SPDX tags we were among the early adopters and there weren't a lot of other examples to borrow from. So we picked the area of the file that usually had a full license text and replaced it with an appropriate SPDX-License-Identifier: entry. Since then, the Linux Kernel has adopted SPDX tags and they place it as the very first line in a file (except where shebangs are used, then it's second line) and with slightly different comment styles than us. In part due to community overlap, in part due to better tag visibility and in part for other minor reasons, switch over to that style. This commit changes all instances where we have a single declared license in the tag as both the before and after are identical in tag contents. There's also a few places where I found we did not have a tag and have introduced one. Signed-off-by: Tom Rini <trini@konsulko.com>
2017-12-04test: compression: Convert to unit test frameworkSimon Glass2-0/+18
Adjust this test to use the unit test framework. Drop the two existing commands for running the tests and replace them with a single 'ut compression' command, with sub-commands. Signed-off-by: Simon Glass <sjg@chromium.org> [trini: Continue to have ret = run_test_internal(...) in run_test so ret is always initialized] Signed-off-by: Tom Rini <trini@konsulko.com>
2017-12-03test: Add a command function for test executionSimon Glass1-0/+16
The logic to either iterate through a list of tests or pick a named test is common to at lest two test suits. Move this logic into a new function and call it from the environment tests. Signed-off-by: Simon Glass <sjg@chromium.org>
2017-06-01dm: test: Fix nit with position of backslashSimon Glass1-1/+1
Line up this backslash with all the others. Signed-off-by: Simon Glass <sjg@chromium.org>
2017-06-01dm: core: Run tests with both livetree and flat treeSimon Glass1-0/+2
Some tests require either livetree or flat tree. Add flags to allow the tests to specify this. Adjust the test runner to run with livetree (if supported) and then flat tree. Some video tests are quite slow and running on flat tree adds little extra test value, so run these on livetree only. Signed-off-by: Simon Glass <sjg@chromium.org>
2017-06-01dm: test: Show the test filename when runningSimon Glass1-0/+2
Show the filename of the test being run. Skip the path and show just the base name. Signed-off-by: Simon Glass <sjg@chromium.org>
2016-08-20tests: Introduce DT overlay testsMaxime Ripard2-0/+17
This adds a bunch of unit tests for the "fdt apply" command. They've all been run successfully in the sandbox. However, as you still require an out-of-tree dtc with overlay support, this is disabled by default. Acked-by: Simon Glass <sjg@chromium.org> Acked-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com> Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
2016-05-03Fix spelling of "occurred".Vagrant Cascadian1-6/+6
Signed-off-by: Vagrant Cascadian <vagrant@debian.org> Reviewed-by: Simon Glass <sjg@chromium.org>
2015-07-22test: Add a macro to check that a value is not an error pointerSimon Glass1-0/+15
Some functions can return ERR_PTR(errval). Add a unit test macro to check that no error is returned in a pointer. Signed-off-by: Simon Glass <sjg@chromium.org>
2015-05-21test: env: Add test framework for envJoe Hershberger2-0/+17
Add a new "env" subcommand to the ut command. This will run unit tests on the env code. This should be targetable to any device that supports the env features needed for the tests. Signed-off-by: Joe Hershberger <joe.hershberger@ni.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2015-05-21test: Return values from the asserts compatible with cmdsJoe Hershberger1-6/+6
The asserts are sometimes called from the context of the test command itself so make sure that a return that happens as a result of a failure is compatible with that command return. When called within a test, the return value is ignored. Signed-off-by: Joe Hershberger <joe.hershberger@ni.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2015-05-21test: dm: Move the time test over to the ut commandJoe Hershberger1-0/+1
Unify the command for running unit tests further by moving the "ut_time" command over to "ut time". Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
2015-05-21test: dm: Move the dm tests over to the ut commandJoe Hershberger1-0/+2
Unify the command for running unit tests further by moving the "dm test" command over to "ut dm". Signed-off-by: Joe Hershberger <joe.hershberger@ni.com> Acked-by: Simon Glass <sjg@chromium.org>
2015-05-21test: Add a common unit test commandJoe Hershberger1-0/+11
Add a command that all other unit tests should be a sub-command of. Also include a command that will run all tests. Signed-off-by: Joe Hershberger <joe.hershberger@ni.com> Acked-by: Simon Glass <sjg@chromium.org>
2015-05-21test: Generalize the unit test frameworkJoe Hershberger2-0/+154
Separate the ability to define tests and assert status of test functions from the dm tests so they can be used more consistently throughout all tests. Signed-off-by: Joe Hershberger <joe.hershberger@ni.com> Reviewed-by: Simon Glass <sjg@chromium.org>