summaryrefslogtreecommitdiff
path: root/test
AgeCommit message (Collapse)AuthorFilesLines
2021-06-28Merge tag 'v2021.07-rc5' into nextTom Rini3-2/+6
Prepare v2021.07-rc5 # gpg: Signature made Mon 28 Jun 2021 03:39:36 PM EDT # gpg: using RSA key 1A3C7F70E08FAB1707809BBF147C39FF9634B72C # gpg: Good signature from "Thomas Rini <trini@konsulko.com>" [ultimate] # Conflicts: # configs/am64x_evm_r5_defconfig
2021-06-24dm: core: add ofnode_get_path()Marek Behún1-0/+21
Add function for retrieving full node path of a given ofnode. This uses np->full_name if OF is live, otherwise a call to fdt_get_path() is made. Signed-off-by: Marek Behún <marek.behun@nic.cz> Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com> Tested-by: Patrice Chotard <patrice.chotard@foss.st.com> Reviewed-by: Jagan Teki <jagan@amarulasolutions.com>
2021-06-24dm: core: add non-translating version of ofnode_get_addr_size_index()Marek Behún1-0/+5
Add functions ofnode_get_addr_size_index_notrans(), which is a non-translating version of ofnode_get_addr_size_index(). Some addresses are not meant to be translated, for example those of MTD fixed-partitions. Signed-off-by: Marek Behún <marek.behun@nic.cz> Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com> Tested-by: Patrice Chotard <patrice.chotard@foss.st.com> Reviewed-by: Jagan Teki <jagan@amarulasolutions.com>
2021-06-23test: Include /sbin to the PATH when creating file systemAndy Shevchenko1-0/+4
On some distributions the mkfs is under /sbin and /sbin is not set for mere users. Include /sbin to the PATH when creating file system, so that users won't get a scary traceback from Python. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
2021-06-18net: use the same alias stem for ethernet as linuxMichael Walle2-2/+2
Linux uses the prefix "ethernet" whereas u-boot uses "eth". This is from the linux tree: $ grep "eth[0-9].*=.*&" arch/**/*dts{,i}|wc -l 0 $ grep "ethernet[0-9].*=.*&" arch/**/*dts{,i}|wc -l 633 In u-boot device trees both prefixes are used. Until recently the only user of the ethernet alias was the sandbox test device tree. This changed with commit fc054d563bfb ("net: Introduce DSA class for Ethernet switches"). There, the MAC addresses are inherited based on the devices sequence IDs which is in turn given by the device tree. Before there are more users in u-boot and both worlds will differ even more, rename the alias prefix to "ethernet" to match the linux ones. Also adapt the test cases and rename any old aliases in the u-boot device trees. Cc: David Wu <david.wu@rock-chips.com> Signed-off-by: Michael Walle <michael@walle.cc> Reviewed-by: Fabio Estevam <festevam@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-06-08log: Convert log values to printf() if not enabledSimon Glass3-0/+43
At present if logging not enabled, log_info() becomes a nop. But we want log output at the 'info' level to be akin to printf(). Update the macro to pass the output straight to printf() in this case. This mimics the behaviour for the log_...() macros like log_debug() and log_info(), so we can drop the special case for these. Add new tests to cover this case. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-06-08sandbox: log: Avoid build error with !CONFIG_LOGSimon Glass1-0/+1
The pr_cont_test.c test requires CONFIG_LOG since it directly accesses fields in global_data that require it. Move the test into the CONFIG_LOG condition to avoid build errors. Enable CONFIG_LOG on sandbox (not sandbox_spl, etc.) so that we still run this test. This requires resyncing of the configs. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-06-08log: Add support for logging a bufferSimon Glass1-0/+27
The print_buffer() function is very useful for debugging. Add a version of this in the log system also. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-06-08display_options: Split print_buffer() into two functionsSimon Glass1-0/+26
At present print_buffer() outputs a hex dump but it is not possible to place this dump in a string. Refactor it into a top-level function which does the printing and a utility function that dumps a line into a string. This makes the code more generally useful. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-06-08hexdump: Support any rowsizeSimon Glass1-3/+20
At present print_hex_dump() only supports either 16- or 32-byte lines. With U-Boot we want to support any line length up to a maximum of 64. Update the function to support this, with 0 defaulting to 16, as with print_buffer(). Signed-off-by: Simon Glass <sjg@chromium.org>
2021-06-08hexdump: Add support for sandboxSimon Glass1-0/+58
The current implementation outputs an address as a pointer. Update the code to use an address instead, respecting the 32/64 nature of the CPU. Add some initial tests copied from print_test_display_buffer(), just the ones that can pass with the current implementation. Note that for this case print_hex_dump() and print_bufffer() produce the same result. For now the tests are duplicated sine we have separate functions. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-06-08display_options: Drop two spaces before the ASCII columnSimon Glass4-33/+33
At present with print_buffer() U-Boot shows four spaces between the hex and ASCII data. Two seems enough and matches print_hex_dump(). Change it. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-06-08test: Add a test for print_buffer()Simon Glass1-0/+82
Add a test for this function, to cover the various features. Expand the expect_str length to take acount of the ~300-bytes lines generated in one case. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-06-08test: Convert print tests to use ut frameworkSimon Glass2-51/+56
This test predates the test framework in U-Boot. It uses #define DEBUG and assert() to check the result. Update it to use the framework so it can report failure constitent with other tests. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-06-08test: Detect when expect_str is too smallSimon Glass1-2/+14
If a line of more than 256 bytes is generated, the test will fail but the reason is not clear. Add a check for this condition and print a helpful message. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-06-08console: Report an error when output buffer is exhaustedSimon Glass1-5/+32
If the console output buffer is exhausted, characters are silently dropped from the end. Detect this condition and report an error when reading back the characters. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-06-07test: lmb: add test for lmb_reserve_flagsPatrick Delaunay1-0/+89
Add a test to check the management of reserved region with flags. Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-06-05test: add dm_test_read_resourcePatrick Delaunay1-0/+33
Add a test of dev_read_resource with translation or without translation Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-05-27test: Fix filesystem tests always being skippedAlper Nebi Yasak1-12/+36
Commit 1ba21bb06b08 ("test: Don't unmount not (yet) mounted system") fixes an issue in the filesystem tests where the test setup may fail to mount an image and still attempt to unmount it. However, the commit unintentionally breaks the test setups in two ways. The newly created unmounted filesystem images are being immediately deleted due to some cleanup steps being misplaced into finally blocks, which makes them always run instead of only on failures. The mount calls always fail since the images never exist, causing the tests to be always skipped. This patch moves these cleanup calls into the except blocks to fix this and makes the tests run again. There are also unmount calls misplaced into finally blocks, making them run after the tests instead of before the tests. These unmount calls make the filesystem image file consistent with the changes made to it as part of the test setup, and this misplacement is making a number of tests fail unexpectedly. The unmount calls must be run before the tests use the image, meaning before the yield call and not in the finally block. They must also be run as a cleanup step when the filesystem setup fails, so they can't be placed as the final call in the try blocks since they would be skipped on such failures. For these reasons, this patch places the unmount calls both in the except blocks and the else blocks of the final setup step. This makes the unexpectedly failing tests to succeed again. Furthermore, this isolates the mount calls to their own try-except statement to avoid reintroducing the original issue of unmounting a not-mounted image while fixing the unmount misplacement. After these fixes, running "make tests" with guestmount available results in two test failures not related to the mentioned commit. If the guestmount executables are unavailable, the mounts fallback to using sudo and result in no failures. Fixes: 1ba21bb06b08 ("test: Don't unmount not (yet) mounted system") Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com> Acked-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
2021-05-27part: Add check for NULL dev_part_strSean Anderson1-7/+30
Some callers (e.g. cmd/fs.c) of fs_set_blk_dev may use a NULL dev_part_str. While blk_get_device_part_str handles this fine, part_get_info_by_dev_and_name does not. This fixes commands crashing when implicitly using bootdevice. The unit test has also been updated to set bootdevice to a known value and to restore it after we are done. Fixes: 7194527b6a ("cmd: fs: Use part_get_info_by_dev_and_name_or_num to parse partitions") Reported-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Sean Anderson <seanga2@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-05-24test/py: improve regular expression for ut subtest symbol matcherMarek Behún1-1/+1
Improve the regular expression that matches unittest symbols in u-boot.sym. Currently we do not enforce no prefix in symbol string, but with the soon to come change in linker lists declaring lists and entries with the __ADDRESSABLE macro (because of LTO), the symbol file will contain for every symbol of the form _u_boot_list_2_ut_X_2_Y also symbol __UNIQUE_ID___addressable__u_boot_list_2_ut_X_2_YN, (where N at the end is some number). In order to avoid matching these additional symbols, ensure that the character before "_u_boot_list_2_ut" is not a symbol name character. Signed-off-by: Marek Behún <marek.behun@nic.cz> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-05-24test: Avoid random numbers in dm_test_devm_regmap()Simon Glass1-2/+1
There is no good reason to use a sequence from rand() here. We may as well invent our own sequence. This should molify Coverity which does not use rand() being used. Signed-off-by: Simon Glass <sjg@chromium.org> Reported-by: Coverity (CID: 312949)
2021-05-13pytest: add sandbox test for "extension" commandKory Maincent1-0/+53
This commit extends the sandbox to implement a dummy extension_board_scan() function and enables the extension command in the sandbox configuration. It then adds a test that checks the proper functionality of the extension command by applying two Device Tree overlays to the sandbox Device Tree. Signed-off-by: Kory Maincent <kory.maincent@bootlin.com> [trini: Limit to running on sandbox] Signed-off-by: Tom Rini <trini@konsulko.com>
2021-05-12Revert "fdt: translate address if #size-cells = <0>"Dario Binacchi1-68/+0
This reverts commit d64b9cdcd475eb7f07b49741ded87e24dae4a5fc. As pointed by [1] and [2], the reverted patch made every DT 'reg' property translatable. What the patch was trying to fix was fixed in a different way from previously submitted patches which instead of correcting the generic address translation function fixed the issue with appropriate platform code. [1] https://patchwork.ozlabs.org/project/uboot/patch/1614324949-61314-1-git-send-email-bmeng.cn@gmail.com/ [2] https://lore.kernel.org/linux-clk/20210402192054.7934-1-dariobin@libero.it/T/ Signed-off-by: Dario Binacchi <dariobin@libero.it> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
2021-05-04sandbox: add test of CONFIG_ENV_IMPORT_FDTRasmus Villemoes2-0/+21
Check that a variable defined in /config/environment is found in the run-time environment, and that clearing fdt_env_path from within that node works. Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk> Acked-by: Joe Hershberger <joe.hershberger@ni.com> [trini: Conditionalize the test being linked in] Signed-off-by: Tom Rini <trini@konsulko.com>
2021-05-04test: Add gpio-sysinfo testSean Anderson2-0/+70
This adds a test for the gpio-sysinfo driver. Signed-off-by: Sean Anderson <sean.anderson@seco.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-05-04sysinfo: Require that sysinfo_detect be called before other methodsSean Anderson1-10/+15
This has the uclass enforce calling detect() before other methods. This allows drivers to cache information in detect() and perform (cheaper) retrieval in the other accessors. This also modifies the only instance where this sequencing was not followed. Signed-off-by: Sean Anderson <sean.anderson@seco.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-04-29test: dm: add test item for ofnode_get_addr() and ofnode_get_size()Chen Guanqiao1-0/+31
Add test item for getting address and size functions Test the following function: - ofnode_get_addr() - ofnode_get_size() Signed-off-by: Chen Guanqiao <chenguanqiao@kuaishou.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-04-29tests: patman: Add requests to the module listTom Rini1-0/+1
The patman tests require the requests module, add it. Cc: Simon Glass <sjg@chromium.org> Signed-off-by: Tom Rini <trini@konsulko.com>
2021-04-29test: Use positive conditional in test_matches()Andy Shevchenko1-6/+6
It is easier to read the positive conditional. While at it, convert hard coded length of "_test_" to strlen("_test_") which will be converted to a constant bu optimizing compiler. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-04-29test: Allow simple glob pattern in the test nameAndy Shevchenko1-2/+9
When run `ut dm [test name]` allow to use simple pattern to run all tests started with given prefix. For example, to run all ACPI test cases: ut dm acpi* Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-04-27test: reset: Extend base reset test to catch errorNeil Armstrong1-5/+34
With this extended test, we get the following failure : => ut dm reset_base Test: dm_test_reset_base: reset.c test/dm/reset.c:52, dm_test_reset_base(): reset_method3.id == reset_method3_1.id: Expected 0x14 (20), got 0x2 (2) Test: dm_test_reset_base: reset.c (flat tree) test/dm/reset.c:52, dm_test_reset_base(): reset_method3.id == reset_method3_1.id: Expected 0x14 (20), got 0x2 (2) Failures: 2 A fix is needed in reset_get_by_index_nodev() when introduced in [1]. [1] ea9dc35aab ("reset: Get the RESET by index without device") Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
2021-04-24test/py: Bump py to 1.10.0 for CVE-2020-29651Tom Rini1-1/+1
Bump our py version to 1.10.0 to address CVE-2020-29651. Reported-by: GitHub dependabot Reported-by: Ley Foon Tan <ley.foon.tan@intel.com> Signed-off-by: Tom Rini <trini@konsulko.com>
2021-04-24test/py: Fix efidebug related testsIlias Apalodimas4-19/+19
commit cbea241e935e("efidebug: add multiple device path instances on Boot####") slightly tweaked the efidebug syntax adding -b, -i and -s for the boot image, initrd and optional data. The pytests using this command were adapted as well. However I completely missed the last "" argument, which at the time indicated the optional data and needed conversion as well. This patch is adding the missing -s flag and the tests are back to normal. Fixes: cbea241e935e("efidebug: add multiple device path instances on Boot####") Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Reviwed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-04-22test: lmb: add test for overflow protection in lmb_add_regionPatrick Delaunay1-0/+64
Add test for max number of memory regions and in reserved regions. Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
2021-04-22test: Add test for partitionsSean Anderson2-0/+77
This is technically a library function, but we use MMCs for testing, so it is easier to do it with DM. At the moment, the only block devices in sandbox are MMCs (AFAIK) so we just test with those. Signed-off-by: Sean Anderson <sean.anderson@seco.com>
2021-04-22test: Alphabetize dm MakefileSean Anderson1-32/+32
Recently, tests have been added primarily to the end of the dm Makefile. This results in merge conflicts when two people add new tests at the same time. To reduce these conflicts, alphabetize the makefile. Signed-off-by: Sean Anderson <sean.anderson@seco.com>
2021-04-20Add support for stack-protectorJoel Peshkin1-0/+14
Add support for stack protector for UBOOT, SPL, and TPL as well as new pytest for stackprotector Signed-off-by: Joel Peshkin <joel.peshkin@broadcom.com> Adjust UEFI build flags. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-04-20test: fix test/dm/regmap.cHeinrich Schuchardt1-4/+5
regmap_read() only fills the first two bytes of val. The last two bytes are random data from the stack. This means the test will fail randomly. For low endian systems we could simply initialize val to 0 and get correct results. But tests should not depend on endianness. So let's use a pointer conversion instead. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-04-18Merge tag 'ti-v2021.07-rc1' of ↵Tom Rini1-5/+86
https://source.denx.de/u-boot/custodians/u-boot-ti - Support for pinmux status command on beaglebone - Updates for MMC speed modes for J721e-evm - Fix MMC booting on omap35_logic_somlv board
2021-04-16Merge branch '2021-04-14-assorted-vboot-improvements'Tom Rini2-0/+112
- Add ECDSA support to FIT images - Improve FIT image loadables (incl fpga) support - Further FIT improvements with SPL
2021-04-15test: dm: Add a test case for simple-bus <ranges>Bin Meng2-0/+34
This adds a test case to verify reading <ranges> of a simple-bus is working as expected. Signed-off-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
2021-04-15test: dm: Add a case to test ofnode_phy_is_fixed_link()Bin Meng1-0/+18
This adds a test case to test the new ofnode_phy_is_fixed_link() API. Both the new and old DT bindings are covered. Signed-off-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com> Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
2021-04-15sandbox: Add a DSA sandbox driver and unit testClaudiu Manoil3-5/+88
The DSA sandbox driver is used for unit testing the DSA class code. It implements a simple 2 port switch plus 1 CPU port, and uses a very simple tag to identify the ports. The DSA sandbox device is connected via CPU port to a regular Ethernet sandbox device, called 'dsa-test-eth, managed by the existing eth sandbox driver. The 'dsa-test-eth' is not intended for testing the eth class code however, but it is used to emulate traffic through the 'lan0' and 'lan1' front pannel switch ports. To achieve this the dsa sandbox driver registers a tx handler for the 'dsa-test-eth' device. The switch ports, labeled as 'lan0' and 'lan1', are also registered as eth devices by the dsa class code this time. So pinging through these switch ports is as easy as: => setenv ethact lan0 => ping 1.2.3.5 Unit tests for the dsa class code were also added. The 'dsa_probe' test exercises most API functions from dsa.h. The 'dsa' unit test simply exercises ARP/ICMP traffic through the two switch ports, including tag injection and extraction, with the help of the dsa sandbox driver. I took care to minimize the impact on the existing eth unit tests, though some adjustments needed to be made with the addition of extra eth interfaces used by the dsa unit tests. The additional eth interfaces also require MAC addresses, these have been added to the sandbox default environment. Signed-off-by: Alex Marginean <alexandru.marginean@nxp.com> Signed-off-by: Claudiu Manoil <claudiu.manoil@nxp.com> Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com> Message-Id: <20210216224804.3355044-5-olteanv@gmail.com> Signed-off-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
2021-04-14test/py: ecdsa: Use mkimage keyfile instead of keydir argumentAlexandru Gagniuc1-1/+1
Originally, the ECDSA code path used 'keydir' as the key filename. mkimage has since been updated to include a new 'keyfile' argument. Use the new argument for passing in the key. Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-04-14test/py: ecdsa: Add test for mkimage ECDSA signingAlexandru Gagniuc1-0/+111
Add a test to make sure that the ECDSA signatures generated by mkimage can be verified successfully. pyCryptodomex was chosen as the crypto library because it integrates much better with python code. Using openssl would have been unnecessarily painful. Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-04-14test/py: Add pycryptodomex to list of required pakagesAlexandru Gagniuc1-0/+1
We wish to use pycryptodomex to verify code paths involving ECDSA signatures. Add it to requirements.txt so that they get picked up automatically .gitlab and .azure tasks Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-04-13test: qemu: add qfw sandbox driver, dm tests, qemu testsAsherah Connor3-0/+69
A sandbox driver and test are added for the qfw uclass, and a test in QEMU added for qfw functionality to confirm it doesn't break in real world use. Signed-off-by: Asherah Connor <ashe@kivikakk.ee> Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
2021-04-13test: Add test for strlcatSean Anderson2-0/+127
This test is adapted from glibc, which is very concerned about alignment. It also tests strlcpy by dependency. Signed-off-by: Sean Anderson <seanga2@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-04-13test: scmi: add local variables for scmi agent referenceEtienne Carriere1-45/+55
Add local variables agent0/agent1 to refer to SCMI sandbox context agent and ease readability of the test. For consistency, rename regul_dev to regul0_dev and remove sandbox_voltd in dm_test_scmi_voltage_domains(). Signed-off-by: Etienne Carriere <etienne.carriere@linaro.org> Reviewed-by: Simon Glass <sjg@chromium.org>