aboutsummaryrefslogtreecommitdiff
path: root/test
AgeCommit message (Collapse)AuthorFilesLines
2021-03-07efi_loader: correct uboot_bin_env.its file formatHeinrich Schuchardt1-2/+2
Up to now the EFI capsule Python tests were always skipped. The reason is that mkimage fails with: uboot_bin_env.its:13.21-23.5: Warning (unit_address_vs_reg): /images/u-boot-bin@100000: node has a unit name, but no reg property uboot_bin_env.its:24.21-34.5: Warning (unit_address_vs_reg): /images/u-boot-env@150000: node has a unit name, but no reg property If a unit in a device-tree has an address, a reg property must be provided. But adding a reg property is not the solution here. Since 2017 unit addresses are disallowed for FIT, cf. common/image-fit.c:1624. So remove the unit addresses in uboot_bin_env.its. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-03-07lib/charset: UTF-8 stream conversionHeinrich Schuchardt1-0/+78
Provide functions to convert an UTF-8 stream to code page 437 or UTF-32. Add unit tests. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-03-07lib/charset: utf8_get() should return errorHeinrich Schuchardt1-0/+7
utf8_get() should return an error if hitting an illegal UTF-8 sequence and not silently convert the input to a question mark. Correct utf_8() and the its unit test. console_read_unicode() now will ignore illegal UTF-8 sequences. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-03-07efi_loader: carve out utf_to_cp()Heinrich Schuchardt1-0/+29
Carve out a function to translate a Unicode code point to an 8bit codepage. Provide a unit test for the new function. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-03-05test: cmd: Add a basic test for 'addrmap' commandBin Meng3-0/+45
This adds a basic test for the newly introduced 'addrmap' command. Signed-off-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org> [Rebase] Signed-off-by: Priyanka Jain <priyanka.jain@nxp.com>
2021-02-26fastboot: Allow u-boot-style partitionsSean Anderson1-3/+34
This adds support for partitions of the form "dev.hwpart:part" and "dev#partname". This allows one to flash to eMMC boot partitions without having to use CONFIG_FASTBOOT_MMC_BOOT1_SUPPORT. It also allows one to flash to an entire device without needing CONFIG_FASTBOOT_MMC_USER_NAME. Lastly, one can also flash MMC devices other than CONFIG_FASTBOOT_FLASH_MMC_DEV. Because devices can be specified explicitly, CONFIG_FASTBOOT_FLASH_MMC_DEV is used only when necessary for existing functionality. For those cases, fastboot_mmc_get_dev has been added as a helper function. This allows There should be no conflicts with the existing system, but just in case, I have ordered detection of these names after all existing names. The fastboot_mmc_part test has been updated for these new names. Signed-off-by: Sean Anderson <sean.anderson@seco.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-02-26test: dm: Add test for fastboot mmc partition namingSean Anderson2-0/+67
This test verifies the mapping between fastboot partitions and partitions as understood by U-Boot. It also tests the creation of GPT partitions, though that is not the primary goal. Signed-off-by: Sean Anderson <sean.anderson@seco.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-02-26mmc: sandbox: Add support for writingSean Anderson1-5/+14
This adds support writing to the sandbox mmc backed by an in-memory buffer. The unit test has been updated to test reading, writing, and erasing. I'm not sure what MMCs erase to; I picked 0, but if it's 0xFF then that can be easily changed. Signed-off-by: Sean Anderson <sean.anderson@seco.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-02-24test: missing dependency for test/cmd/setexpr.cHeinrich Schuchardt2-1/+3
test/cmd/setexpr.c cannot be linked with CONFIG_CMD_SETEXPR=n: ld.bfd: test/built-in.o: in function `setexpr_test_sub': test/cmd/setexpr.c:227: undefined reference to `setexpr_regex_sub' ld.bfd: test/built-in.o: in function `setexpr_test_backref': test/cmd/setexpr.c:267: undefined reference to `setexpr_regex_sub' Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-02-22Merge tag 'u-boot-amlogic-20210222' of ↵Tom Rini1-2/+48
https://gitlab.denx.de/u-boot/custodians/u-boot-amlogic - adds adc-keys button driver - fix meson-saradc driver to get reference voltage - add adc-keys test for sandbox - enable adc-keys for VIM3 & VIM3L boards - fix button.h build
2021-02-18dm: test: Add test case for dev_phys_to_bus()/dev_bus_to_phys()Nicolas Saenz Julienne2-0/+38
By reusing DT nodes already available in sandbox's test DT introduce a test to validate dev_phys_to_bus()/dev_bus_to_phys(). Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de> Reviewed-by: Simon Glass <sjg@chromium.org> Tested-by: Peter Robinson <pbrobinson@gmail.com> Signed-off-by: Matthias Brugger <mbrugger@suse.com>
2021-02-18dm: test: Add test case for dev->dma_offsetNicolas Saenz Julienne1-0/+30
Add test to validate dev->dma_offset is properly set on devices. Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de> Reviewed-by: Simon Glass <sjg@chromium.org> Tested-by: Peter Robinson <pbrobinson@gmail.com> Signed-off-by: Matthias Brugger <mbrugger@suse.com>
2021-02-18dm: test: Add test case for dev_get_dma_ranges()Nicolas Saenz Julienne2-0/+50
Introduce some new nodes in sandbox's test device-tree and dm tests in order to validate dev_get_dma_range(). Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de> Reviewed-by: Simon Glass <sjg@chromium.org> Tested-by: Peter Robinson <pbrobinson@gmail.com> Signed-off-by: Matthias Brugger <mbrugger@suse.com>
2021-02-18test: add a simple test for the adc-keys button driverMarek Szyprowski1-2/+48
Add adc-keys device to the sandbox/test.dts and connect it to the channel #3 of the sandbox_adc driver. The default values sampled by sandbox_adc driver determines that button3 and button4 are released and button5 is pressed. Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com> Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
2021-02-16test: dm: tee: extend with RPC testIgor Opaniuk1-7/+109
Extend existing DM tee tests adding test coverage for reverse RPC calls. Currently this commit only adds tests for I2C requests from TEE driver to TEE supplicant, for instance reading/writing data to emulated i2c eeprom defines in standard sandbox test device tree (arch/sandbox/dts/test.dtb): => i2c bus Bus 0: i2c@0 (active 0) 2c: eeprom@2c, offset len 1, flags 0 ... Running TEE tests: => ut dm tee Test: dm_test_tee: tee.c Test: dm_test_tee: tee.c (flat tree) Failures: 0 Signed-off-by: Igor Opaniuk <igor.opaniuk@foundries.io> Reviewed-by: Simon Glass <sjg@chromium.org> Acked-by: Etienne Carriere <etienne.carriere@linaro.org>
2021-02-16test: py: add pygit2 and pyelftools to requirements.txtIgor Opaniuk1-0/+2
Add pygit2 and pyelftools to the list of packages for virtualenv needed to run all sets of pytests.This fixes warnings like: binman.elf_test.TestElf.testDecodeElf (subunit.RemotedTestCase): Python elftools not available Signed-off-by: Igor Opaniuk <igor.opaniuk@foundries.io> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-02-15image: Check for unit addresses in FITsSimon Glass1-4/+5
Using unit addresses in a FIT is a security risk. Add a check for this and disallow it. CVE-2021-27138 Signed-off-by: Simon Glass <sjg@chromium.org> Reported-by: Bruce Monroe <bruce.monroe@intel.com> Reported-by: Arie Haenel <arie.haenel@intel.com> Reported-by: Julien Lenoir <julien.lenoir@intel.com>
2021-02-15libfdt: Check for multiple/invalid root nodesSimon Glass1-1/+2
It is possible to construct a devicetree blob with multiple root nodes. Update fdt_check_full() to check for this, along with a root node with an invalid name. CVE-2021-27097 Signed-off-by: Simon Glass <sjg@chromium.org> Reported-by: Bruce Monroe <bruce.monroe@intel.com> Reported-by: Arie Haenel <arie.haenel@intel.com> Reported-by: Julien Lenoir <julien.lenoir@intel.com>
2021-02-15test: Add tests for the 'evil' vboot attacksSimon Glass1-28/+65
Add tests to check that these two attacks are mitigated by recent patches. Signed-off-by: Simon Glass <sjg@chromium.org> Reported-by: Bruce Monroe <bruce.monroe@intel.com> Reported-by: Arie Haenel <arie.haenel@intel.com> Reported-by: Julien Lenoir <julien.lenoir@intel.com>
2021-02-15test: Add vboot_evil implementationSimon Glass1-0/+485
Add a library which performs two different attacks on a FIT. Signed-off-by: Julien Lenoir <julien.lenoir@intel.com> Signed-off-by: Bruce Monroe <bruce.monroe@intel.com> Signed-off-by: Arie Haenel <arie.haenel@intel.com> Signed-off-by: Simon Glass <sjg@chromium.org>
2021-02-15fit: Don't allow verification of images with @ nodesSimon Glass2-18/+18
When searching for a node called 'fred', any unit address appended to the name is ignored by libfdt, meaning that 'fred' can match 'fred@1'. This means that we cannot be sure that the node originally intended is the one that is used. Disallow use of nodes with unit addresses. Update the forge test also, since it uses @ addresses. CVE-2021-27138 Signed-off-by: Simon Glass <sjg@chromium.org> Reported-by: Bruce Monroe <bruce.monroe@intel.com> Reported-by: Arie Haenel <arie.haenel@intel.com> Reported-by: Julien Lenoir <julien.lenoir@intel.com>
2021-02-15Merge branch '2021-02-02-drop-asm_global_data-when-unused'Tom Rini22-0/+22
- Merge the patch to take <asm/global_data.h> out of <common.h>
2021-02-03dm: core: Add late driver remove optionMarek Vasut2-0/+116
Add another flag to the DM core which could be assigned to drivers and which makes those drivers call their remove callbacks last, just before booting OS and after all the other drivers finished with their remove callbacks. This is necessary for things like clock drivers, where the other drivers might depend on the clock driver in their remove callbacks. Prime example is the mmc subsystem, which can reconfigure a card from HS mode to slower modes in the remove callback and for that it needs to reconfigure the controller clock. Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com> Signed-off-by: Simon Glass <sjg@chromium.org>
2021-02-03dm: core: Avoid partially removing devicesSimon Glass1-1/+3
At present if device_remove() decides that the device should not actually be removed, it still calls the uclass pre_remove() method and powers the device down. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-02-02common: Drop asm/global_data.h from common headerSimon Glass22-0/+22
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>
2021-02-01test/py: fix runtest wrapper for pytest 6Stephen Warren1-1/+4
The implementation of pytest_runtest_protocol() must call pytest_runtest_logstart() and pytest_runtest_logfinish(). This appears to be necessary even in pytest 5.2.1 judging by the default version of pytest_runtest_protocol(), but evidently some form of code reorganization in pytest only made this have a practical effect in the newer version. I'd previously been under the impression that 100% of the required work of pytest_runtest_protocol() was handled by the fact it called runtestprotocol() as its implementation. However, it appears that custom implementations do need to do a little more than this. Reported-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Stephen Warren <swarren@wwwdotorg.org> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-01-30dm: core: Update ofnode_read_fmap_entry() to read hashesSimon Glass2-0/+39
At present this function uses the old format for reading hashes. Add support for the current format. Add a test while we are here. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-01-30sandbox: Disable I2C emulators in SPLSimon Glass1-4/+4
These cannot work with of-platdata since they currently need the devicetree at runtime. Disable the emulators and the sandbox I2C driver that needs them. We can enable these later, if needed for testing. Switch the of_plat_parent test over to use a simple bus instead. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Heiko Schocher <hs@denx.de>
2021-01-30cros_ec: Add vstore supportSimon Glass1-0/+38
The EC can store small amounts of data for the benefit of the verified boot process. Since the EC is seldom reset, this can allow the AP to store data that survives a reboot or a suspend/resume cycle. Add support for this. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-01-30cros_ec: Show events in human-readable formSimon Glass1-0/+37
Add a command to show the current events as a list of names. This is easier to decipher than a bit mask. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-01-30cros_ec: Add support for switchesSimon Glass1-0/+26
On x86 platforms the EC provides a way to read 'switches', which are on/off values determined by the EC. Add a new driver method for this and implement it for LPC. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-01-30cros_ec: Support reading EC featuresSimon Glass1-0/+28
The EC can support a variety of features and provides a way to find out what is available. Add support for this. Also update the feature list to the lastest available while we are here. This is at: https://chromium.googlesource.com/chromiumos/platform/ec/+/refs/heads/master/include/ec_commands.h Signed-off-by: Simon Glass <sjg@chromium.org>
2021-01-30cros_ec: Add support for reading the SKU IDSimon Glass1-0/+17
This allows reading strapping pins attached to the EC. Add an implementation for this. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-01-30cros_ec: Add a function for the hello messageSimon Glass2-0/+33
This is used several times in this file. Put it in a function to avoid code duplication. Also add a test for this function. There are no cros_ec tests at present, so it is time to update the code. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-01-29test: inconsistent string testsHeinrich Schuchardt1-2/+1
Excluding ut str in test/cmd_ut.c but compiling test/str_ut.c results in failure of the Python test invoking the C unit tests as observed on sipeed_riscv_smode_defconfig: FAILED test/py/tests/test_ut.py::test_ut[ut_str_upper] Allow to compile test/str_ut.c on all boards. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-01-29test: inconsistent bootm testsHeinrich Schuchardt1-1/+1
Excluding ut bootm in test/cmd_ut.c but compiling test/bootm.c results in failure of the Python test invoking the C unit tests as observed on sipeed_riscv_smode_defconfig: FAILED test/py/tests/test_ut.py::test_ut[ut_bootm_nop] FAILED test/py/tests/test_ut.py::test_ut[ut_bootm_nospace] FAILED test/py/tests/test_ut.py::test_ut[ut_bootm_silent] FAILED test/py/tests/test_ut.py::test_ut[ut_bootm_silent_var] FAILED test/py/tests/test_ut.py::test_ut[ut_bootm_subst] FAILED test/py/tests/test_ut.py::test_ut[ut_bootm_subst_both] FAILED test/py/tests/test_ut.py::test_ut[ut_bootm_subst_var] Only compile test/bootm.c on the sandbox. Fixes: f158ba15ee0f ("bootm: Add tests for fixup_silent_linux()") Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-01-29test: Update test_fs to not use deprecated pytest.yield_fixture()Tom Rini1-10/+5
As noted in comments, yield_fixture has been deprecated for longer than our minimum required version of pytest. Newer versions of pytest cause this to be a louder warning, and as the migration is trivial, perform it now. Signed-off-by: Tom Rini <trini@konsulko.com>
2021-01-29test: correct entry point to pytestHeinrich Schuchardt1-5/+5
With Pytest 6.0.2 'make tests' fails: sandbox: Traceback (most recent call last): File "./test/py/test.py", line 20, in <module> sys.exit(load_entry_point('pytest', 'console_scripts', 'pytest')(args)) TypeError: console_main() takes 0 positional arguments but 1 was given The definition of console_scripts has changed as follows: Pytest 4.6.1: [options.entry_points] console_scripts =         pytest=pytest:main         py.test=pytest:main          Pytest 6.0.2:          [options.entry_points] console_scripts = pytest=pytest:console_main py.test=pytest:console_main The new function console_main() has a comment: "This function is not meant for programmable use; use `main()`" Hence let's call pytest.main() directly. Move args processing into the __main__ paragraph. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Tested-by: Andy Shevchenko <andy.shevchenko@gmail.com> Tested-by: Tom Rini <trini@konsulko.com>
2021-01-29test: pr_cont_test.o depends on CONFIG_LOG=yHeinrich Schuchardt1-1/+1
Compiling wandboard_defconfig with CONFIG_UT_LOG=y leads to a build error: test/log/pr_cont_test.c: In function ‘log_test_pr_cont’: test/log/pr_cont_test.c:28:14: error: ‘gd_t’ {aka ‘volatile struct global_data’} has no member named ‘log_fmt’  log_fmt = gd->log_fmt; We do not want to let CONFIG_UT_LOG depend on CONFIG_LOG=y because we have tests for logging functions called with CONFIG_LOG=n. Fix the build dependency. Reported-by: Kever Yang <kever.yang@rock-chips.com> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-01-29test: test_ofplatdata: Mark as sandbox specificTom Rini1-0/+1
This test checks for output specific to the sandbox device tree, mark it as sandbox specific. Signed-off-by: Tom Rini <trini@konsulko.com>
2021-01-27bloblist: Support relocating to a larger spaceSimon Glass1-0/+36
Typically in TPL/SPL the bloblist is quite small. But U-Boot proper may want to add a lot more to it, such as ACPI tables. Add a way to expand the bloblist by relocating it in U-Boot proper, along with the other relocation activities. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-01-25test: unit test for echo commandHeinrich Schuchardt2-0/+60
Provide a unit test for the unit command Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-01-23doc: move test/py/README.md to HTML documentationHeinrich Schuchardt1-389/+0
Convert test/py/README.md to restructured text and add it to the generated HTML documentation. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-01-23doc: move test/README to HTML documentationHeinrich Schuchardt1-96/+0
Move test/README to the 'Develop U-Boot' chapter of the HTML documentation. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-01-18cmd: Add a pwm commandPragnesh Patel2-0/+48
Add the command "pwm" for controlling the pwm channels. This command provides pwm invert/config/enable/disable functionalities via PWM uclass drivers Signed-off-by: Pragnesh Patel <pragnesh.patel@sifive.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-01-16test: unit test for pr_err(), pr_cont()Heinrich Schuchardt2-0/+46
Provide a unit test for printing via pr_err() and pr_cont(). Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-01-16test: correct the test prefix in ut strPatrick Delaunay1-2/+2
Align the prefix used in cmd_ut_category function and name of tests for ut str. This patch solves the issues detected by "make qcheck" after previous patch. Fixes: fdc79a6b125d ("lib: Add a function to convert a string to upper case") Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-01-16test: correct the test prefix in ut cmd_memPatrick Delaunay1-1/+1
Align the prefix used in cmd_ut_category function and name of tests for ut mem. This patch solves the issues detected by "make qcheck" after previous patch. Fixes: 550a9e7902ce ("cmd: Update the memory-search command") Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-01-16test: Only enable bloblist test when supportedSimon Glass1-1/+1
This test cannot work unless CONFIG_BLOBLIST is enabled. Update it to add that condition. Reported-by: Kever Yang <kever.yang@rock-chips.com> Signed-off-by: Simon Glass <sjg@chromium.org>
2021-01-16test: Avoid assuming sandbox board for bloblist testSimon Glass2-9/+22
This tests assumes it is running on sandbox. Add a few functions to handle silencing the console on any board and use those instead. Reported-by: Kever Yang <kever.yang@rock-chips.com> Signed-off-by: Simon Glass <sjg@chromium.org>