summaryrefslogtreecommitdiffstats
path: root/test
Commit message (Collapse)AuthorAgeFilesLines
...
* 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>
* Merge tag 'dm-pull5nov20' of git://git.denx.de/u-boot-dmTom Rini2020-11-064-8/+24
|\ | | | | | | | | | | | | patman status subcommand to collect tags from Patchwork patman showing email replies from Patchwork sandbox poweroff command minor fixes in binman, tests
| * test: linking test/compression.c failsHeinrich Schuchardt2020-11-052-1/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Building U-Boot with unit tests on a non-sandbox systems fails: ld.bfd: test/built-in.o: in function `compress_using_gzip': test/compression.c:138: undefined reference to `gzip' ld.bfd: test/built-in.o: in function `uncompress_using_bzip2': test/compression.c:187: undefined reference to `BZ2_bzBuffToBuffDecompress' ld.bfd: test/built-in.o: in function `uncompress_using_lzma': test/compression.c:222: undefined reference to `lzmaBuffToBuffDecompress' ld.bfd: test/built-in.o: in function `uncompress_using_lzo': test/compression.c:257: undefined reference to `lzop_decompress' ld.bfd: test/built-in.o: in function `uncompress_using_lz4': test/compression.c:292: undefined reference to `ulz4fn Add the missing dependencies. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Simon Glass <sjg@chromium.org>
| * test: test/bloblist.c depends on asm/state.hHeinrich Schuchardt2020-11-051-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | Building test/bloblist.c fails for non sandbox devices: test/bloblist.c:10:10: fatal error: asm/state.h: No such file or directory #include <asm/state.h> ^~~~~~~~~~~~~ Build the test only on the sandbox. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Simon Glass <sjg@chromium.org>
| * test: adjust sysreset testsHeinrich Schuchardt2020-11-051-3/+8
| | | | | | | | | | | | | | | | As we have a working COLD_RESET on the sandbox the sysreset test has to be adjusted. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Simon Glass <sjg@chromium.org>
| * test/py: test poweroffHeinrich Schuchardt2020-11-051-4/+4
| | | | | | | | | | | | | | | | | | | | It is the 'poweroff' and not the 'reset' command that should shut down the sandbox. Adjust the unit test accordingly Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Simon Glass <sjg@chromium.org>
* | board: Rename uclass to sysinfoSimon Glass2020-11-063-60/+60
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This uclass is intended to provide a way to obtain information about a U-Boot board. But the concept of a U-Boot 'board' is the whole system, not just one circuit board, meaning that 'board' is something of a misnomer for this uclass. In addition, the name 'board' is a bit overused in U-Boot and we want to use the same uclass to provide SMBIOS information. The obvious name is 'system' but that is so vague as to be meaningless. Use 'sysinfo' instead, since this uclass is aimed at providing information on the system. Rename everything accordingly. Note: Due to the patch delta caused by the symbol renames, this patch shows some renamed files as being deleted in one place and created in another. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
* | acpi: Don't reset the tables with every new generationSimon Glass2020-11-061-0/+4
|/ | | | | | | | | At present if SSDT and DSDT code is created, only the latter is retained for examination by the 'acpi items' command. Fix this by only resetting the list when explicitly requested. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
* Merge tag 'efi-2020-01-rc2-2' of ↵Tom Rini2020-11-011-0/+19
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | https://gitlab.denx.de/u-boot/custodians/u-boot-efi Pull request for UEFI sub-system for efi-2021-01-rc2 (2) The series contains the following enhancements * preparatory patches for UEFI capsule updates * initialization of the emulated RTC using an environment variable and a bug fix * If DisconnectController() is called for a child controller that is the only child of the driver, the driver must be disconnected.
| * test: unit test for efi_create_indexed_name()Heinrich Schuchardt2020-10-301-0/+19
| | | | | | | | | | | | Provide a unit test for function efi_create_indexed_name(). Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* | Merge tag 'dm-pull-30oct20' of ↵Tom Rini2020-10-309-94/+340
|\ \ | | | | | | | | | | | | | | | | | | | | | https://gitlab.denx.de/u-boot/custodians/u-boot-dm of-platdata and dtoc improvements sandbox SPL tests binman support for compressed sections
| * | dm: Use driver_info index instead of pointerSimon Glass2020-10-292-9/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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: Add a test for of-platdata parent informationSimon Glass2020-10-291-0/+15
| | | | | | | | | | | | | | | | | | | | | | | | Add a simple test that we can obtain the correct parent for an I2C device. This requires updating the driver names to match the compatible strings, adding them to the devicetree and enabling a few options. Signed-off-by: Simon Glass <sjg@chromium.org>
| * | dm: Use an allocated array for run-time device infoSimon Glass2020-10-291-9/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | At present we update the driver_info struct with a pointer to the device that it created (i.e. caused to be bound). This works fine when U-Boot SPL is stored in read-write memory. But on some platforms, such as Intel Apollo Lake, it is not possible to update the data memory. In any case, it is bad form to put this information in a structure that is in the data region, since it expands the size of the binary. Create a new driver_rt structure which holds runtime information about drivers. Update the code to store the device pointer in this instead. Also update the test check that this works. Signed-off-by: Simon Glass <sjg@chromium.org>
| * | dm: test: Add a test for of-platdata phandlesSimon Glass2020-10-291-0/+37
| | | | | | | | | | | | | | | | | | | | | | | | We have a test in dtoc for this feature, but not one in U-Boot itself. Add a simple test that checks that the information comes through correctly. Signed-off-by: Simon Glass <sjg@chromium.org>
| * | dm: test: Add a check that all devices have a dev valueSimon Glass2020-10-291-0/+81
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | With of-platdata, the driver_info struct is updated with the device pointer when it is bound. This makes it easy for a device to be found by its driver info with the device_get_by_driver_info() function. Add a test that all devices (except the root device) have such an entry. Fix a bug that the function does not set *devp to NULL on failure, which the documentation asserts. Signed-off-by: Simon Glass <sjg@chromium.org>
| * | dm: Add a C test for of-platdata propertiesSimon Glass2020-10-291-0/+69
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | At present properties are tested in a roundabout way. The driver's probe() method writes out the values of the properties and the Python test checks the output from U-Boot SPL. Add a C test which checks these values more directly. Signed-off-by: Simon Glass <sjg@chromium.org>
| * | dm: test: Drop of-platdata pytestSimon Glass2020-10-291-47/+0
| | | | | | | | | | | | | | | | | | Now that we have a C version of this test, drop the Python implementation. Signed-off-by: Simon Glass <sjg@chromium.org>
| * | test: Run only the selected SPL testSimon Glass2020-10-291-1/+1
| | | | | | | | | | | | | | | | | | Use the new -k option to select the test to run. Signed-off-by: Simon Glass <sjg@chromium.org>
| * | test: Run SPL unit testsSimon Glass2020-10-291-1/+1
| | | | | | | | | | | | | | | | | | Update the 'run' script to include SPL unit tests. Signed-off-by: Simon Glass <sjg@chromium.org>
| * | pytest: Collect SPL unit testsSimon Glass2020-10-292-5/+42
| | | | | | | | | | | | | | | | | | Add a new test_spl fixture to handle running SPL unit tests. Signed-off-by: Simon Glass <sjg@chromium.org>
| * | dm: test: Add a very simple of-platadata testSimon Glass2020-10-292-1/+22
| | | | | | | | | | | | | | | | | | | | | | | | At present we have a pytest that covers of-platadata. Add a very simple unit test that just checks that a device can be found. This shows the ability to write these tests in C. 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: test: Build tests for SPLSimon Glass2020-10-291-0/+10
| | | | | | | | | | | | | | | | | | | | | We want to run unit tests in SPL. Add a new Kconfig to control this and enable it for sandbox_spl Signed-off-by: Simon Glass <sjg@chromium.org>
| * | dtoc: Fix widening of int to bytesSimon Glass2020-10-291-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | At present an integer is converted to bytes incorrectly. The whole 32-bit integer is inserted as the first element of the byte array, and the other three bytes are skipped. This was not noticed because the unit test did not check it, and the functional test was checking for wrong values. Update the code to handle this as a special case. Add one more test to cover all code paths. Signed-off-by: Simon Glass <sjg@chromium.org>
| * | dm: test: Disable some tests that should not run in SPLSimon Glass2020-10-292-7/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Tests are easier to run in U-Boot proper. Running them in SPL does not add test coverage in most cases. Also some tests use features that are not available in SPL. Update the build rules to disable these tests in SPL. We still need test-main to be able to actually run SPL tests. Signed-off-by: Simon Glass <sjg@chromium.org>
| * | dm: test: Make use of CONFIG_UNIT_TESTSimon Glass2020-10-291-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | At present we always include test/dm from the main Makefile. We have a CONFIG_UNIT_TEST that should control whether the test/ directory is built, so rely on that instead. Signed-off-by: Simon Glass <sjg@chromium.org>
| * | dm: test: Update Makefile conditionsSimon Glass2020-10-291-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | At present most of the tests in test/Makefile are dependent on CONFIG_SANDBOX. But this is not ideal since they rely on commands being available and SPL does not support commands. Use CONFIG_COMMAND instead. This has the dual purpose of allowing these tests to be used on other boards and allowing SPL to skip them. Signed-off-by: Simon Glass <sjg@chromium.org>
| * | dm: test: Sort the MakefileSimon Glass2020-10-291-3/+3
| | | | | | | | | | | | | | | | | | Move everything into alphabetical order. 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>
* | test: Add a test for log filter-*Sean Anderson2020-10-302-0/+109
| | | | | | | | | | | | | | | | | | | | 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>
* | test: Add a test for getoptSean Anderson2020-10-302-0/+124
| | | | | | | | | | | | | | | | A few of these tests were inspired by those in glibc. The syntax for invoking test_getopt is a bit funky, but it's necessary so that the CPP can parse the arguments correctly. Signed-off-by: Sean Anderson <seanga2@gmail.com>
* | test: Add test for LOGFF_MINSean Anderson2020-10-301-0/+23
| | | | | | | | | | | | | | This tests log filters matching on a minimum level. Signed-off-by: Sean Anderson <seanga2@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
* | test: Add tests for LOGFF_DENYSean Anderson2020-10-301-0/+67
| | | | | | | | | | | | | | This adds some tests for log filters which deny if they match. Signed-off-by: Sean Anderson <seanga2@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
* | test: log: Give tests names instead of numbersSean Anderson2020-10-301-24/+24
| | | | | | | | | | | | | | Now that the log test command is no more, we can give the log tests proper names. Signed-off-by: Sean Anderson <seanga2@gmail.com>
* | test: log: Convert log_test from python to CSean Anderson2020-10-303-291/+255
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | Merge tag 'xilinx-for-v2021.01-v2' of ↵Tom Rini2020-10-291-0/+22
|\ \ | |/ |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | https://gitlab.denx.de/u-boot/custodians/u-boot-microblaze Xilinx changes for v2021.01-v2 common: - Add support for 64bit loadables from SPL xilinx: - Update documentation and record ownership - Enable eeprom board detection based legacy and fru formats - Add support for FRU format microblaze: - Optimize low level ASM code - Enable SPI/I2C - Enable distro boot zynq: - Add support for Zturn V5 zynqmp: - Improve silicon detection code - Enable several kconfig options - Align DT with the latest state - Enabling security commands - Enable and support FPGA loading from SPL - Optimize xilinx_pm_request() calling versal: - Some DTs/Kconfig/defconfig alignments - Add binding header for clock and power zynq-sdhci: - Add support for tap delay programming zynq-spi/zynq-qspi: - Use clock framework for getting clocks xilinx-spi: - Fix some code issues (unused variables) serial: - Check return value from clock functions in pl01x
| * dm: core: Add support for getting node from aliasesMichal Simek2020-10-271-0/+22
| | | | | | | | | | | | | | | | | | Add support for getting a node/property from aliases. The similar functionality is provided for chosen node and this implemenatation is copy of it. Signed-off-by: Michal Simek <michal.simek@xilinx.com> Reviewed-by: Simon Glass <sjg@chromium.org>
* | test: mux-cmd: Add tests for the 'mux' commandPratyush Yadav2020-10-282-0/+178
| | | | | | | | | | | | | | | | Tests tests run the three mux subcommands: list, select, and deselect, and verify that the commands do what we expect. Signed-off-by: Pratyush Yadav <p.yadav@ti.com> Reviewed-by: Simon Glass <sjg@chromium.org>