summaryrefslogtreecommitdiffstats
path: root/test/dm/test-main.c
Commit message (Collapse)AuthorAgeFilesLines
* common: Drop asm/global_data.h from common headerSimon Glass2021-02-021-0/+1
| | | | | | | | | | | | Move this out of the common header and include it only where needed. In a number of cases this requires adding "struct udevice;" to avoid adding another large header or in other cases replacing / adding missing header files that had been pulled in, very indirectly. Finally, we have a few cases where we did not need to include <asm/global_data.h> at all, so remove that include. Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: Tom Rini <trini@konsulko.com>
* dm: treewide: Rename ..._platdata variables to just ..._platSimon Glass2020-12-131-2/+2
| | | | | | | Try to maintain some consistency between these variables by using _plat as a suffix for them. Signed-off-by: Simon Glass <sjg@chromium.org>
* dm: core: Drop unused parameter from dm_extended_scan_fdt()Simon Glass2020-12-131-1/+1
| | | | | | | This doesn't need to be passed the devicetree anymore. Drop it. Also rename the function to drop the _fdt suffix. Signed-off-by: Simon Glass <sjg@chromium.org>
* dm: core: Drop unused parameter from dm_scan_fdt()Simon Glass2020-12-131-1/+1
| | | | | | This doesn't need to be passed the devicetree anymore. Drop it. Signed-off-by: Simon Glass <sjg@chromium.org>
* dm: Use driver_info index instead of pointerSimon Glass2020-10-291-4/+20
| | | | | | | | | | | | | | | | | | | | At present we use a 'node' pointer in the of-platadata phandle_n_arg structs. This is a pointer to the struct driver_info for a particular device, and we can use it to obtain the struct udevice pointer itself. Since we don't know the struct udevice pointer until it is allocated in memory, we have to fix up the phandle_n_arg.node at runtime. This is annoying since it requires that SPL's data is writable and adds a small amount of extra (generated) code in the dm_populate_phandle_data() function. Now that we can find a driver_info by its index, it is easier to put the index in the phandle_n_arg structures. Update dtoc to do this, add a new device_get_by_driver_info_idx() to look up a device by drive_info index and update the tests to match. Signed-off-by: Simon Glass <sjg@chromium.org>
* dm: test: Add a way to run SPL testsSimon Glass2020-10-291-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | 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>
* dm: test: Update the test runner to support of-platdataSimon Glass2020-10-291-11/+16
| | | | | | | | | At present DM tests assume that a devicetree is available. This is not the case with of-platadata. Update the code to add this condition. Signed-off-by: Simon Glass <sjg@chromium.org>
* dm: Avoid using #ifdef for CONFIG_OF_LIVESimon Glass2020-10-291-11/+5
| | | | | | | | | | At present this option results in a number of #ifdefs due to the presence or absence of the global_data of_root member. Add a few macros to global_data.h to work around this. Update the code accordingly. Signed-off-by: Simon Glass <sjg@chromium.org>
* dm: Rename DM test flags to make them more genericSimon Glass2020-08-071-5/+5
| | | | | | | | | | 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>
* dm: core: Drop header files from dm/test.hSimon Glass2020-08-031-0/+2
| | | | | | | | 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>
* common: Drop log.h from common headerSimon Glass2020-05-181-0/+1
| | | | | | Move this header out of the common header. Signed-off-by: Simon Glass <sjg@chromium.org>
* command: Remove the cmd_tbl_t typedefSimon Glass2020-05-181-1/+1
| | | | | | | | | | | | | 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>
* test: Enable console recording in testsSimon Glass2020-02-051-2/+2
| | | | | | | | | | At present we reset the console buffer before each test but do not actually set the recording flag. Without this, the output is not recorded. Update the code to set the flag before the test and clear it afterwards. Signed-off-by: Simon Glass <sjg@chromium.org>
* dm: test: Correct a stray backslash in dm_test_destroy()Simon Glass2019-10-081-1/+1
| | | | | | | | | This should perhaps be a period. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> [bmeng: add the ending period and reword the commit message] Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
* dm: test: Don't fail when tests are skipped due to buildSimon Glass2019-10-081-4/+4
| | | | | | | | | | At present tests that are marked as only for livetree fail when executed on sandbox_flattree. They cannot actually be executed, but we should not resport them as 'not found', since this causes errors. Instead, they should be silently skipped. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
* dm: test: Fix running of multiple test from command lineSimon Glass2019-10-081-1/+5
| | | | | | | | | | | | | | | | | At present when multiple 'ut dm' commands are executed, all but the first is run with a flat tree, even if live tree is enabled. This is because the live tree node pointer is set to NULL and never restored. This does not affect normal test running, which just runs all the test in one go, but can be confusing when several individual tests are run during the same U-Boot run. Correct this by restoring the pointer. Fixes: c166c47ba3 (dm: test: Add support for running tests with livetree) Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Tested-by: Bin Meng <bmeng.cn@gmail.com>
* dm: test: Fix typo in test-main commentMichal Simek2018-08-241-1/+1
| | | | | | | Trivial fix. Signed-off-by: Michal Simek <michal.simek@xilinx.com> Reviewed-by: Simon Glass <sjg@chromium.org>
* SPDX: Convert all of our single license tags to Linux Kernel styleTom Rini2018-05-071-2/+1
| | | | | | | | | | | | | | | | | | | | 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>
* dm: test: replace dm_scan_dt() by of dm_extended_scan_fdt() in dm_do_testPatrice Chotard2017-09-111-1/+1
| | | | | | | | | | | | | | This allows to scan the DT including all "clocks" node's sub-nodes in which fixed-clock are defined. All fixed-clock should be defined inside a clocks node which collect all external oscillators. Until now, all clocks sub-nodes can't be binded except if the "simple-bus" compatible string is added which is a hack. Update test.dts by moving clk_fixed node inside clocks. Signed-off-by: Patrice Chotard <patrice.chotard@st.com> Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Simon Glass <sjg@chromium.org>
* dm: core: Run tests with both livetree and flat treeSimon Glass2017-06-011-2/+36
| | | | | | | | | | | 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>
* dm: test: Add support for running tests with livetreeSimon Glass2017-06-011-7/+16
| | | | | | | | It is useful to run the driver model tests with both livetree and flat tree in case something is different between the two. Add this feature to the test runner. Signed-off-by: Simon Glass <sjg@chromium.org>
* dm: test: Show the test filename when runningSimon Glass2017-06-011-1/+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>
* dm: test: Move test running code into a separate functionSimon Glass2017-06-011-24/+32
| | | | | | | We want to run the same test on flat and live trees. In preparation for this, create a new function which handles running a test. Signed-off-by: Simon Glass <sjg@chromium.org>
* sandbox: Add a way to reset sandbox state for testsSimon Glass2017-06-011-0/+1
| | | | | | | | | | | Running a new test should reset the sandbox state to avoid tests interferring with each other. Move the existing state-reset code into a function so it can be used from tests. Also update the code to reset the SPI devices and adjust the test code to call it. Signed-off-by: Simon Glass <sjg@chromium.org>
* dm: core: Scan the live tree when setting up driver modelSimon Glass2017-06-011-2/+2
| | | | | | | When starting up driver model with a live tree we need to scan the tree for devices. Add code to handle this. Signed-off-by: Simon Glass <sjg@chromium.org>
* test/dm: clear unit test failure count each runStephen Warren2016-01-281-0/+2
| | | | | | | | | | The ut command prints a test failure count each time it is executed. This is stored in a global variable which is never reset. Consequently, the printed failure count accumulates across runs. Fix this by clearing the counter each time "ut" is invoked. Signed-off-by: Stephen Warren <swarren@nvidia.com> Acked-by: Simon Glass <sjg@chromium.org>
* test: Record and silence console in testsSimon Glass2015-11-191-0/+9
| | | | | | | | | When running sandbox tests, silence the console to avoid unwanted output. Also, record the console in case tests want to check it. The -v option can be used to enable stdout during tests. Signed-off-by: Simon Glass <sjg@chromium.org>
* Move console definitions into a new console.h fileSimon Glass2015-11-191-0/+1
| | | | | | | | The console includes a global variable and several functions that are only used by a small subset of U-Boot files. Before adding more functions, move the definitions into their own header file. Signed-off-by: Simon Glass <sjg@chromium.org>
* dm: usb: Avoid time delays in sandbox testsSimon Glass2015-11-191-0/+2
| | | | | | | Currently the USB tests take around two seconds to run. Remove these unnecessary time delays so that the tests run quickly. Signed-off-by: Simon Glass <sjg@chromium.org>
* dm: test: Allow test names to leave out the dm_test_ prefixSimon Glass2015-07-211-2/+13
| | | | | | | | | | | | | | All driver model tests have a dm_test_ prefix. Ignore it when matching a test name. This makes it easier to run individual tests, like this: ./sandbox/u-boot -d ./sandbox/arch/sandbox/dts/test.dtb \ -c "ut dm clk_periph" We can use 'clk_periph' instead of 'dm_test_clk_periph'. Also print a message if the requested test is not found. Signed-off-by: Simon Glass <sjg@chromium.org>
* test: dm: Recover the driver model tree after testsJoe Hershberger2015-05-211-0/+5
| | | | | | | | Put the driver model for the system back into a good state after completing the DM testing. Signed-off-by: Joe Hershberger <joe.hershberger@ni.com> Acked-by: Simon Glass <sjg@chromium.org>
* test: dm: Don't bail on all tests if one test failsJoe Hershberger2015-05-211-5/+2
| | | | | | | | | | There's not much point in having a failure count if we always give up on the first failure. Also stop clearing the entire state between tests. Make sure that any failures are still passed out to the command line. Signed-off-by: Joe Hershberger <joe.hershberger@ni.com> Reviewed-by: Simon Glass <sjg@chromium.org>
* test: dm: Move the dm tests over to the ut commandJoe Hershberger2015-05-211-1/+12
| | | | | | | | 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>
* test: Generalize the unit test frameworkJoe Hershberger2015-05-211-15/+21
| | | | | | | | | 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>
* test: dm: test.dts - move to sandbox dts directoryPrzemyslaw Marczak2015-05-141-2/+1
| | | | | | | | | | | | | | | | | The file test.dts from driver model test directory, was compiled by call dtc in script: test/dm/test-dm.sh. This doesn't allow for including of dtsi files and using of C preprocessor routines in this dts file. Since the mentioned script builds U-Boot before tests, then moving the test.dts file into sandbox dts directory is reasonable. Signed-off-by: Przemyslaw Marczak <p.marczak@samsung.com> Acked-by: Simon Glass <sjg@chromium.org> Tested on sandbox: Tested-by: Simon Glass <sjg@chromium.org>
* dm: test: Allow 'dm test' to select a particular test to runSimon Glass2015-04-181-2/+5
| | | | | | | As well as running all tests, it is useful to be able to run a selected test. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Marek Vasut <marex@denx.de>
* test: dm: Support memory leak checking as a core featureSimon Glass2014-10-231-0/+2
| | | | | | | | Check the state of the malloc() heap before each test is run, so that tests can verify that all is well at the end. Provide helper functions to mark the heap and to check that it returns to its initial state. Signed-off-by: Simon Glass <sjg@chromium.org>
* dm: Allow drivers to be marked 'before relocation'Simon Glass2014-07-231-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | Driver model currently only operates after relocation is complete. In this state U-Boot typically has a small amount of memory available. In adding support for driver model prior to relocation we must try to use as little memory as possible. In addition, on some machines the memory has not be inited and/or the CPU is not running at full speed or the data cache is off. These can reduce execution performance, so the less initialisation that is done before relocation the better. An immediately-obvious improvement is to only initialise drivers which are actually going to be used before relocation. On many boards the only such driver is a serial UART, so this provides a very large potential benefit. Allow drivers to mark themselves as 'pre-reloc' which means that they will be initialised prior to relocation. This can be done either with a driver flag or with a 'dm,pre-reloc' device tree property. To support this, the various dm scanning function now take a 'pre_reloc_only' parameter which indicates that only drivers marked pre-reloc should be bound. Signed-off-by: Simon Glass <sjg@chromium.org>
* dm: rename device struct to udeviceHeiko Schocher2014-05-271-1/+1
| | | | | | | | | | | | using UBI and DM together leads in compiler error, as both define a "struct device", so rename "struct device" in include/dm/device.h to "struct udevice", as we use linux code (MTD/UBI/UBIFS some USB code,...) and cannot change the linux "struct device" Signed-off-by: Heiko Schocher <hs@denx.de> Cc: Simon Glass <sjg@chromium.org> Cc: Marek Vasut <marex@denx.de>
* dm: Add basic testsSimon Glass2014-03-041-0/+107
Add some tests of driver model functionality. Coverage includes: - basic init - binding of drivers to devices using platform_data - automatic probing of devices when referenced - availability of platform data to devices - lifecycle from bind to probe to remove to unbind - renumbering within a uclass when devices are probed/removed - calling driver-defined operations - deactivation of drivers when removed - memory leak across creation and destruction of drivers/uclasses - uclass init/destroy methods - automatic probe/remove of children/parents when needed This function is enabled for sandbox, using CONFIG_DM_TEST. Signed-off-by: Simon Glass <sjg@chromium.org>