summaryrefslogtreecommitdiffstats
path: root/test
Commit message (Collapse)AuthorAgeFilesLines
...
* dm: Rename DM_GET_DRIVER() to DM_DRIVER_GET()Simon Glass2021-01-052-4/+4
| | | | | | | | In the spirit of using the same base name for all of these related macros, rename this to have the operation at the end. This is not widely used so the impact is fairly small. Signed-off-by: Simon Glass <sjg@chromium.org>
* dm: Rename U_BOOT_DEVICE() to U_BOOT_DRVINFO()Simon Glass2021-01-051-3/+3
| | | | | | | | | | | | | | | | | | | | The current macro is a misnomer since it does not declare a device directly. Instead, it declares driver_info record which U-Boot uses at runtime to create a device. The distinction seems somewhat minor most of the time, but is becomes quite confusing when we actually want to declare a device, with of-platdata. We are left trying to distinguish between a device which isn't actually device, and a device that is (perhaps an 'instance'?) It seems better to rename this macro to describe what it actually is. The macros is not widely used, since boards should use devicetree to declare devices. Rename it to U_BOOT_DRVINFO(), which indicates clearly that this is declaring a new driver_info record, not a device. Signed-off-by: Simon Glass <sjg@chromium.org>
* dm: core: Allow the uclass list to moveSimon Glass2021-01-051-3/+3
| | | | | | | | | | | At present the uclass list head is in global_data. This is convenient but with the new of-platdata we need the list head to be declared by the generated code. Change this over to be a pointer. Provide a 'static' version in global_data to retain the current behaviour. Signed-off-by: Simon Glass <sjg@chromium.org>
* dm: core: Use dev_has_ofnode() instead of dev_of_valid()Simon Glass2021-01-051-3/+3
| | | | | | | | | | | We have two functions which do the same thing. Standardise on dev_has_ofnode() since there is no such thing as an 'invalid' ofnode in normal operation: it is either null or missing. Also move the functions into one place. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
* dm: core: Access device flags through functionsSimon Glass2021-01-055-24/+24
| | | | | | | At present flags are stored as part of the device. In preparation for storing them separately, change the access to go through inline functions. Signed-off-by: Simon Glass <sjg@chromium.org>
* dm: core: Rename sqq to seq_Simon Glass2021-01-051-3/+3
| | | | | | | | | Now that the sequence-numbering migration is complete, rename this member back to seq_, adding an underscore to indicate it is internal to driver model. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
* test: Move some test drivers into their own fileSimon Glass2021-01-052-221/+4
| | | | | | | | | | | At present several test drivers are part of the test file itself. Some of these are useful for of-platdata tests. Separate them out so we can use them for other things also. A few adjustments are needed so this driver can build for sandbox_spl as well. Signed-off-by: Simon Glass <sjg@chromium.org>
* test: Use a simple variable to record removed deviceSimon Glass2021-01-051-8/+6
| | | | | | | | | | | | At present the entire test state is effective passed into a test driver just to record which device was removed. This is unnecessary and makes it harder to track what is going on. Use a simple boolean instead. Also drop the unused 'removed' member while we are here. Signed-off-by: Simon Glass <sjg@chromium.org>
* dm: Use access methods for dev/uclass private dataSimon Glass2021-01-054-19/+20
| | | | | | | | | | | Most drivers use these access methods but a few do not. Update them. In some cases the access is not permitted, so mark those with a FIXME tag for the maintainer to check. Signed-off-by: Simon Glass <sjg@chromium.org> Acked-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Acked-by: Pratyush Yadav <p.yadav@ti.com>
* sandbox: Drop unnecessary test nodeSimon Glass2021-01-051-1/+0
| | | | | | | | The spl-test4 node deliberately has an invalid compatible string. This causes a warning from dtoc and the check it does is not really necessary. Drop it, to avoid the warning and associated confusion. Signed-off-by: Simon Glass <sjg@chromium.org>
* efi_loader: Add size checks to efi_create_indexed_name()Ilias Apalodimas2020-12-311-1/+1
| | | | | | | | | | | | Although the function description states the caller must provide a sufficient buffer, it's better to have in function checks that the destination buffer can hold the intended value. So let's add an extra argument with the buffer size and check that before doing any copying. Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* test: dm: spi: Add testcase for spi_claim_bus()Ovidiu Panait2020-12-221-0/+82
| | | | | | | | | | | | | | | | Add testcase for spi_claim_bus(), which checks that sandbox spi bus speed/mode settings are updated correctly when multiple slaves use the bus consecutively. The following configurations are used for the two spi slaves involved: * different max_hz / different modes * different max_hz / same modes * different modes / same max_hz asm/test.h header is added in order to be able to retrieve the current speed/mode of the sandbox spi bus, via sandbox_spi_get_{speed, mode}. Signed-off-by: Ovidiu Panait <ovidiu.panait@windriver.com> Reviewed-by: Simon Glass <sjg@chromium.org>
* sandbox: test: Add a second SPI slave on sandbox_spi busOvidiu Panait2020-12-221-1/+1
| | | | | | | | | | | | | | Place a second spi slave on the sandbox_spi bus, to be used by the spi_claim_bus() testcase we are about to introduce. We need to make sure that jumping between slaves calling spi_claim_bus() sets the bus speed and mode appropriately. Use different max-hz and mode properties for this new slave. Also, update sandbox_spi cs_info call to allow activity on CS0/CS1 and adapt dm_test_spi_find() testcase for this new setup. Signed-off-by: Ovidiu Panait <ovidiu.panait@windriver.com> Reviewed-by: Simon Glass <sjg@chromium.org>
* dm: core: Drop seq and req_seqSimon Glass2020-12-181-0/+39
| | | | | | | | | | Now that migration to the new sequence numbers is complete, drop the old fields. Add a test that covers the new behaviour. Also drop the check for OF_PRIOR_STAGE since we always assign sequence numbers now. Signed-off-by: Simon Glass <sjg@chromium.org>
* dm: Drop the unused arg in uclass_find_device_by_seq()Simon Glass2020-12-182-34/+34
| | | | | | | | Now that there is only one sequence number (rather than both requested and assigned ones) we can simplify this function. Also update its caller to simplify the logic. Signed-off-by: Simon Glass <sjg@chromium.org>
* dm: test: Add a test for DM_UC_FLAG_NO_AUTO_SEQSimon Glass2020-12-181-0/+42
| | | | | | | Check that this flag operates as expected. This patch is not earlier in this series since is uses the new behaviour of dev_seq(). Signed-off-by: Simon Glass <sjg@chromium.org>
* dm: Switch over to use new sequence number for dev_seq()Simon Glass2020-12-181-29/+36
| | | | | | | Update this function to use the new sequence number and fix up the test that deals with this. Signed-off-by: Simon Glass <sjg@chromium.org>
* x86: Simplify acpi_device_infer_name()Simon Glass2020-12-181-5/+1
| | | | | | | There is no-longer any need to check if sequence numbers are valid, since this is ensured by driver model. Drop the unwanted logic. Signed-off-by: Simon Glass <sjg@chromium.org>
* dm: test: Drop assumptions of no sequence numbersSimon Glass2020-12-183-9/+0
| | | | | | | Drop code in a few tests which assumes that sequence numbers are only valid when a device is probed. Signed-off-by: Simon Glass <sjg@chromium.org>
* dm: core: Switch binding to use new sequence numbersSimon Glass2020-12-181-1/+2
| | | | | | | Update the core logic to use the new approach. For now the old code is left as is. Update one test so it still passes. Signed-off-by: Simon Glass <sjg@chromium.org>
* dm: test: Check all devices have a sequence numbersSimon Glass2020-12-181-0/+19
| | | | | | | Add a test that the new sequence numbers work as expected. Every device should get one. Signed-off-by: Simon Glass <sjg@chromium.org>
* dm: treewide: Rename ..._platdata variables to just ..._platSimon Glass2020-12-134-21/+21
| | | | | | | 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: treewide: Update 'auto' declarations to be on one lineSimon Glass2020-12-132-4/+2
| | | | | | | | | Fix up the code style for those declarations that should now fit onto one line, which is all of them that currently do not. This is needed for dtoc to detect the structs correctly, at present. Signed-off-by: Simon Glass <sjg@chromium.org>
* dm: treewide: Rename ofdata_to_platdata() to of_to_plat()Simon Glass2020-12-132-8/+8
| | | | | | | This name is far too long. Rename it to remove the 'data' bits. This makes it consistent with the platdata->plat rename. Signed-off-by: Simon Glass <sjg@chromium.org>
* dm: treewide: Rename dev_get_platdata() to dev_get_plat()Simon Glass2020-12-135-22/+22
| | | | | | Rename this to be consistent with the change from 'platdata'. Signed-off-by: Simon Glass <sjg@chromium.org>
* dm: treewide: Rename 'platdata' variables to just 'plat'Simon Glass2020-12-1311-72/+72
| | | | | | | | | | We use 'priv' for private data but often use 'platdata' for platform data. We can't really use 'pdata' since that is ambiguous (it could mean private or platform data). Rename some of the latter variables to end with 'plat' for consistency. Signed-off-by: Simon Glass <sjg@chromium.org>
* dm: treewide: Rename auto_alloc_size members to be shorterSimon Glass2020-12-138-30/+30
| | | | | | | | | | | | This construct is quite long-winded. In earlier days it made some sense since auto-allocation was a strange concept. But with driver model now used pretty universally, we can shorten this to 'auto'. This reduces verbosity and makes it easier to read. Coincidentally it also ensures that every declaration is on one line, thus making dtoc's job easier. Signed-off-by: Simon Glass <sjg@chromium.org>
* dm: core: Drop unused parameter from dm_extended_scan_fdt()Simon Glass2020-12-132-2/+2
| | | | | | | 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-133-3/+3
| | | | | | This doesn't need to be passed the devicetree anymore. Drop it. Signed-off-by: Simon Glass <sjg@chromium.org>
* dm: core: Add a livetree function to check node statusSimon Glass2020-12-131-0/+12
| | | | | | | Add a way to find out if a node is enabled or not, based on its 'status' property. Signed-off-by: Simon Glass <sjg@chromium.org>
* dm: core: Rename device_bind_ofnode() to device_bind()Simon Glass2020-12-131-2/+2
| | | | | | | This is the standard function to use when binding devices. Drop the '_ofnode' suffix to make this clear. Signed-off-by: Simon Glass <sjg@chromium.org>
* test: unit test for exception commandHeinrich Schuchardt2020-12-131-0/+24
| | | | | | | | Test that an exception SIGILL is answered by a reset on the sandbox if CONFIG_SANDBOX_CRASH_RESET=y or by exiting to the OS otherwise. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Simon Glass <sjg@chromium.org>
* bootm: Support string substitution in bootargsSimon Glass2020-12-041-5/+109
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In some cases it is necessary to pass parameters to Linux so that it will boot correctly. For example, the rootdev parameter is often used to specify the root device. However the root device may change depending on whence U-Boot loads the kernel. At present it is necessary to build up the command line by adding device strings to it one by one. It is often more convenient to provide a template for bootargs, with U-Boot doing the substitution from other environment variables. Add a way to substitute strings in the bootargs variable. This allows things like "rootdev=${rootdev}" to be used in bootargs, with the ${rootdev} substitution providing the UUID of the root device. For example, to substitute the GUID of the kernel partition: setenv bootargs "console=/dev/ttyS0 rootdev=${uuid}/PARTNROFF=1 kern_guid=${uuid}" part uuid mmc 2:2 uuid bootm This is particularly useful when the command line from another place. For example, Chrome OS stores the command line next to the kernel itself. It depends on the kernel version being used as well as the hardware features, so it is extremely difficult to devise a U-Boot script that works on all boards and kernel versions. With this feature, the command line can be read from disk and used directly, with a few substitutions set up. Signed-off-by: Simon Glass <sjg@chromium.org>
* bootm: Allow updating the bootargs in a bufferSimon Glass2020-12-041-15/+99
| | | | | | | | | | At present we only support updating the 'bootargs' environment variable. Add another function to update a buffer instead. This will allow zimage to use this feature. Also add a lot more tests to cover various cases. Signed-off-by: Simon Glass <sjg@chromium.org>
* bootm: Update bootm_process_cmdline_env() to use flagsSimon Glass2020-12-041-5/+5
| | | | | | | | At present only one transformation is supported: making the Linux console silent. To prepare for adding more, convert the boolean parameter into a flag value. Signed-off-by: Simon Glass <sjg@chromium.org>
* bootm: Add a bool parameter to bootm_process_cmdline_env()Simon Glass2020-12-041-5/+5
| | | | | | | | This function will soon do more than just handle the 'silent linux' feature. As a first step, update it to take a boolean parameter, indicating whether or not the processing is required. Signed-off-by: Simon Glass <sjg@chromium.org>
* bootm: Rename fixup_silent_linux()Simon Glass2020-12-041-5/+5
| | | | | | | We want to add more processing to this function. Before doing so, rename it to bootm_process_cmdline_env(), which is more generic. Signed-off-by: Simon Glass <sjg@chromium.org>
* bootm: Update fixup_silent_linux() to return an errorSimon Glass2020-12-041-5/+5
| | | | | | | | | | | At present this function fails silently on error. Update it to produce an error code. Report this error to the user and abort the boot, since it likely will prevent a successful start. No tests are added at this stage, since additional refactoring is taking place in subsequent patches. Signed-off-by: Simon Glass <sjg@chromium.org>
* bootm: Add tests for fixup_silent_linux()Simon Glass2020-12-043-0/+61
| | | | | | | | This function currently has no tests. Export it so that we can implement a simple test on sandbox. Use IS_ENABLED() to remove the unused code, instead #ifdef. Signed-off-by: Simon Glass <sjg@chromium.org>
* env: Allow returning errors from hdelete_r()Simon Glass2020-12-041-1/+1
| | | | | | | | | | | | | | | | | | | | At present this function returns 1 on success and 0 on failure. But in the latter case it provides no indication of what went wrong. If an attempt is made to delete a non-existent variable, the caller may want to ignore this error. This happens when setting a non-existent variable to "", for example. Update the function to return 0 on success and a useful error code on failure. Add a function comment too. Make sure that env_set() does not return an error if it is deleting a variable that doesn't exist. We could update env_set() to return useful error numbers also, but that is beyond the scope of this change. Signed-off-by: Simon Glass <sjg@chromium.org> wip
* test/py: efi_capsule: test for raw image capsuleAKASHI Takahiro2020-12-032-0/+66
| | | | | | | | | | | | The test can run on sandbox build and it attempts to execute a firmware update via a capsule-on-disk, using a raw image capsule, CONFIG_EFI_CAPSULE_RAW. To run this test successfully, you need configure U-Boot specifically; See test_capsule_firmware.py for requirements, and hence it won't run on Travis CI, at least, for now. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
* test/py: efi_capsule: test for FIT image capsuleAKASHI Takahiro2020-12-034-0/+290
| | | | | | | | | | | | The test can run on sandbox build and it attempts to execute a firmware update via a capsule-on-disk, using a FIT image capsule, CONFIG_EFI_CAPSULE_FIT. To run this test successfully, you need configure U-Boot specifically; See test_capsule_firmware.py for requirements, and hence it won't run on Travis CI, at least, for now. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
* setexpr: Add support for stringsSimon Glass2020-12-011-0/+86
| | | | | | | | Add support for dealing with string operands, including reading a string from memory into an environment variable and concatenating two strings. Signed-off-by: Simon Glass <sjg@chromium.org> Acked-by: Marek Behún <marek.behun@nic.cz>
* setexpr: Correct buffer overflow bug and enable testsSimon Glass2020-12-011-17/+7
| | | | | | | | | | | | At present when more than one substitution is made this function overwrites its buffers. Fix this bug and update the tests now that they can pass. Also update the debug code to show all substrings, since at present it omits the final one. Fixes: 855f18ea0e6 ("setexpr: add regex substring matching and substitution") Signed-off-by: Simon Glass <sjg@chromium.org>
* setexpr: Correct dropping of final unmatched stringSimon Glass2020-12-011-3/+2
| | | | | | | | | | | | | | | | | At present the 'nlen' variable increases with each loop. If the previous loop had back references, then subsequent loops without back references use the wrong value of nlen. The value is larger, meaning that the string terminator from nbuf is copied along to the main buffer, thus terminating the string prematurely. This leads to the final result being truncated, e.g. missing the last (unmatched) part of the string. So "match match tail" become "replaced replaced" instead of "replaced replaced tail". Fix this by resetting nlen to the correct value each time around the lop. Fixes: 855f18ea0e6 ("setexpr: add regex substring matching and substitution") Signed-off-by: Simon Glass <sjg@chromium.org>
* setexpr: Add some tests for buffer overflow and backrefSimon Glass2020-12-011-0/+89
| | | | | | | Add tests to check for buffer overflow using simple replacement as well as back references. At present these don't fully pass. Signed-off-by: Simon Glass <sjg@chromium.org>
* test: Add some setexpr regex testsSimon Glass2020-12-011-0/+58
| | | | | | | | | Add tests for the setexpr regex commands. Note that these tests currently crash on sandbox due to an existing bug in the setexpr implementation, so two of the tests are commented out. Signed-off-by: Simon Glass <sjg@chromium.org>
* setexpr: Add explicit support for 32- and 64-bit intsSimon Glass2020-12-011-9/+9
| | | | | | | | | | | | | | | | | | | At present this function assumes that a size of 4 refers to a ulong. This is true on 32-bit machines but not commonly on 64-bit machines. This means that the 'l' specify does not work correctly with setexpr. Add an explicit case for 32-bit values so that 64-bit machines can still use the 'l' specifier. On 32-bit machines, 64-bit is still not supported. This corrects the operation of the default size (which is 4 for setexpr), so update the tests accordingly. The original code for reading from memory was included in 47ab5ad1457 ("cmd_setexpr: allow memory addresses in expressions") but I am not adding a Fixes: tag since that code was not written with 64-bit machines in mind. Signed-off-by: Simon Glass <sjg@chromium.org>
* test: Add some tests for setexprSimon Glass2020-12-013-0/+166
| | | | | | | | | | | This command currently has no tests. Add some for basic assignment and the integer operations. Note that the default size for setexpr is ulong, which varies depending on the build machine. So for sandbox on a 64-bit host, this means that the default size is 64 bits. Signed-off-by: Simon Glass <sjg@chromium.org>
* Nokia RX-51: Update test scriptPali Rohár2020-11-151-12/+15
| | | | | | | | Include emmc/nand suffix into bootmenu script names and fix leaking sleep processes when asynchronously waiting for them. 'wait -n' is not provided by /bin/sh, so run script under bash. Signed-off-by: Pali Rohár <pali@kernel.org>