aboutsummaryrefslogtreecommitdiffstats
path: root/test/lib
Commit message (Collapse)AuthorAgeFilesLines
* test: lmb: Add test for coalescing and overlap rangeUdit Kumar2023-10-091-1/+12
| | | | | | | | | Add test case for an address range which is coalescing with one of range and overlapping with next range Cc: Simon Glass <sjg@google.com> Signed-off-by: Udit Kumar <u-kumar1@ti.com> Reviewed-by: Simon Glass <sjg@chromium.org>
* sandbox: Move the bloblist down a little in memorySimon Glass2023-10-061-2/+2
| | | | | | | | Move this down by 4KB so that it is large enough to hold the devicetree. Also fix up the devicetree address in the documetation while we are here. Signed-off-by: Simon Glass <sjg@chromium.org>
* abuf: Allow incrementing the sizeSimon Glass2023-08-251-0/+25
| | | | | | Provide a convenience function to increment the size of the abuf. Signed-off-by: Simon Glass <sjg@chromium.org>
* Merge tag 'v2023.10-rc3' into nextTom Rini2023-08-212-0/+42
|\ | | | | | | | | | | Prepare v2023.10-rc3 Signed-off-by: Tom Rini <trini@konsulko.com>
| * lib: uuid: introduce testcase for uuid_str_to_le_binAbdellatif El Khlifi2023-08-082-0/+42
| | | | | | | | | | | | | | | | provide a test case Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> Reviewed-by: Simon Glass <sjg@chromium.org> Cc: Tom Rini <trini@konsulko.com>
* | test: fix a couple NULL vs IS_ERR() checksDan Carpenter2023-08-081-2/+2
| | | | | | | | | | | | | | | | The x509_cert_parse() and pkcs7_parse_message() functions return error pointers. They don't return NULL. Update the checks accordingly. Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org> Reviewed-by: Simon Glass <sjg@chromium.org>
* | Revert "lib: string: Fix strlcpy return value", fix callersMatthias Schiffer2023-08-081-2/+2
|/ | | | | | | | | | | | | | | | | | | Both the Linux kernel and libbsd agree that strlcpy() should always return strlen(src) and not include the NUL termination. The incorrect U-Boot implementation makes it impossible to check the return value for truncation, and breaks code written with the usual implementation in mind (for example, fdtdec_add_reserved_memory() was subtly broken). I reviewed all callers of strlcpy() and strlcat() and fixed them according to my understanding of the intended function. This reverts commit d3358ecc54be0bc3b4dd11f7a63eab0a2842f772 and adds related fixes. Fixes: d3358ecc54be ("lib: string: Fix strlcpy return value") Signed-off-by: Matthias Schiffer <matthias.schiffer@ew.tq-group.com> Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Sean Anderson <sean.anderson@seco.com>
* Revert "Merge branch '2023-07-24-introduce-FF-A-suppport'"Tom Rini2023-07-242-42/+0
| | | | | | | | | This reverts commit d927d1a80843e1c3e2a3f0b8f6150790bef83da1, reversing changes made to c07ad9520c6190070513016fdb495d4703a4a853. These changes do not pass CI currently. Signed-off-by: Tom Rini <trini@konsulko.com>
* lib: uuid: introduce testcase for uuid_str_to_le_binAbdellatif El Khlifi2023-07-242-0/+42
| | | | | | | | provide a test case Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> Reviewed-by: Simon Glass <sjg@chromium.org> Cc: Tom Rini <trini@konsulko.com>
* test: improve configuration for Kconfig test optionsHeinrich Schuchardt2023-04-251-7/+8
| | | | | | | | | | | * Fix dependencies * Provide labels that are easier to grasp. * Fix typo %s/whgch/which/ * Fix type %s/Is/is/ Fixes: 29784d62eded ("test: Add some tests for kconfig.h") Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Simon Glass <sjg@chromium.org>
* Merge tag 'dm-next-12mar23a' of git://git.denx.de/u-boot-dm into nextTom Rini2023-03-162-8/+8
|\ | | | | | | | | | | | | | | More tests and fixes for fdt command binman signing feature fix buildman -A bug introduced recently Signed-off-by: Tom Rini <trini@konsulko.com>
| * test: Wrap assert macros in ({ ... }) and fix missing semicolonsMarek Vasut2023-03-142-8/+8
| | | | | | | | | | | | | | | | | | | | Wrap the assert macros in ({ ... }) so they can be safely used both as right side argument as well as in conditionals without curly brackets around them. In the process, find a bunch of missing semicolons, fix them. Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
* | test: unit test for crc8Heinrich Schuchardt2023-03-132-0/+30
|/ | | | | | | Add a unit test for the crc8() function. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Simon Glass <sjg@chromium.org>
* test: lmb: Rework lib_test_lmb_max_regions test to scaleTom Rini2023-02-081-18/+26
| | | | | | | | | | | | | | First, this test depends on CONFIG_LMB_USE_MAX_REGIONS, so add that as a test before building. Second, instead of using a hard-coded value of 8, which is the default of CONFIG_LMB_USE_MAX_REGIONS previously, use that directly and update the comments. The only trick here is that one part of the test itself also was written with the value of 8 itself in mind. Rework the size of the lmb region we allocate to scale with the value of CONFIG_LMB_USE_MAX_REGIONS. Cc: Simon Glass <sjg@chromium.org> Signed-off-by: Tom Rini <trini@konsulko.com> Reviewed-by: Simon Glass <sjg@chromium.org>
* display_options: print_size: Fix order overflowPali Rohár2022-09-231-0/+3
| | | | | | | | | | | | | | Function print_size() round size to the nearst value with one decimal fraction number. But in special cases also unit order may overflow. For example value 1073689396 is printed as "1024 MiB" and value 1073741824 as "1 GiB". Fix this issue by detecting order overflow and increasing unit order. With this change also value 1073689396 is printed as "1 GiB". Signed-off-by: Pali Rohár <pali@kernel.org> Reviewed-by: Simon Glass <sjg@chromium.org>
* test: Add some tests for kconfig.hSimon Glass2022-08-104-0/+130
| | | | | | | | | | | The macros in this file are a little confusing and we currently have no tests to check that they work as expected. Add some tests which check the macros in C code. Add a few tests which check that the build errors are generated correctly too, using buildman's -a option. Signed-off-by: Simon Glass <sjg@chromium.org>
* abuf: Correct a corner case with abuf_realloc()Simon Glass2022-04-061-0/+29
| | | | | | | | If the buffer is empty and not allocated, then abuf_realloc() tries to copy invalid data. This happens because an incorrect change to use memdup() was added after the original code was written. Signed-off-by: Simon Glass <sjg@chromium.org>
* lmb: remove lmb_is_nomap() from includeHeinrich Schuchardt2021-11-201-0/+5
| | | | | | | | | Defining static functions in includes should be avoided. Function lmb_is_nomap() is only used in the unit test. So move it to the unit test. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Acked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
* Add support for an owned bufferSimon Glass2021-10-082-0/+345
| | | | | | | | | | | | | | | | | | | | | | | | | When passing a data buffer back from a function, it is not always clear who owns the buffer, i.e. who is responsible for freeing the memory used. An example of this is where multiple files are decompressed from the firmware image, using a temporary buffer for reading (since the compressed data has to live somewhere) and producing a temporary or permanent buffer with the resuilts. Where the firmware image can be memory-mapped, as on x86, the compressed data does not need to be buffered, but the complexity of having a buffer which is either allocated or not, makes the code hard to understand. Introduce a new 'abuf' which supports simple buffer operations: - encapsulating a buffer and its size - either allocated with malloc() or not - able to be reliably freed if necessary - able to be converted to an allocated buffer if needed This simple API makes it easier to deal with allocated and memory-mapped buffers. Signed-off-by: Simon Glass <sjg@chromium.org>
* lib: Add memdup()Simon Glass2021-10-081-0/+32
| | | | | | Add a function to duplicate a memory region, a little like strdup(). Signed-off-by: Simon Glass <sjg@chromium.org>
* test: Fix size_t formats in strlcat testSimon Glass2021-07-271-2/+2
| | | | | | | | Some of the printf() formats do not match their types. Fix this. Reported-by: Minkyu Kang <mk7.kang@samsung.com> Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: Minkyu Kang <mk7.kang@samsung.com>
* lib: wrap crypt API to hide errno usageSteffen Jaeckel2021-07-231-2/+22
| | | | | | | | | In order to prevent using the global errno, replace it with a static version and create a wrapper function which returns the error value. Signed-off-by: Steffen Jaeckel <jaeckel-floss@eyet-services.de> Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Heiko Schocher <hs@denx.de>
* lib: add crypt subsystemSteffen Jaeckel2021-07-232-0/+45
| | | | | | | | | | | | | | | | | Add the basic functionality required to support the standard crypt format. The files crypt-sha256.c and crypt-sha512.c originate from libxcrypt and their formatting is therefor retained. The integration is done via a crypt_compare() function in crypt.c. ``` libxcrypt $ git describe --long --always --all tags/v4.4.17-0-g6b110bc ``` Signed-off-by: Steffen Jaeckel <jaeckel-floss@eyet-services.de> Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Heiko Schocher <hs@denx.de>
* test: lmb: add test for lmb_reserve_flagsPatrick Delaunay2021-06-071-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>
* test: lmb: add test for overflow protection in lmb_add_regionPatrick Delaunay2021-04-221-0/+64
| | | | | | Add test for max number of memory regions and in reserved regions. Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
* test: Add test for strlcatSean Anderson2021-04-122-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>
* test: unit test for longjmpHeinrich Schuchardt2021-04-082-0/+74
| | | | | | | Provide a unit test for the longjmp() library function Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Acked-by: Sean Anderson <seanga2@gmail.com>
* test: Silenece the echo and print testsSimon Glass2021-03-271-2/+6
| | | | | | | These tests current produce unwanted output on sandbox. Use the correct functions to controller console output, to avoid this. Signed-off-by: Simon Glass <sjg@chromium.org>
* test: Add a macros for finding tests in linker_listsSimon Glass2021-03-121-2/+2
| | | | | | | | At present we use the linker list directly. This is not very friendly, so add a helpful macro instead. This will also allow us to change the naming later without updating this code. Signed-off-by: Simon Glass <sjg@chromium.org>
* 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>
* test: test/lib/test_print.c depends on CONSOLE_RECORDHeinrich Schuchardt2021-01-161-1/+1
| | | | | | | | | The tests in test/lib/test_print.c fail without CONFIG_CONSOLE_RECORD=y. Add a build dependency. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> 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: unit tests for print_freq(), print_size()Heinrich Schuchardt2020-10-232-0/+72
| | | | | | Provide unit tests for functions print_freq() and print_size(). Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* test: undefined reference to 'sscanf'Heinrich Schuchardt2020-08-271-1/+1
| | | | | | | | | | | | Compiling with CONFIG_UNIT_TEST=y leads to: aarch64-linux-gnu-ld.bfd: test/lib/sscanf.c:50: undefined reference to `sscanf' Add missing build dependency. Fixes:e87dfb0526be ("lib: sscanf: add sscanf implementation") Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* test: unit test for efi_dp_check_length()Heinrich Schuchardt2020-08-242-0/+51
| | | | | | Provide a unit test for function efi_dp_check_length(). Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* lib: sscanf: add sscanf implementationAndrii Anisov2020-08-142-0/+175
| | | | | | | | | Port sscanf implementation from mini-os and introduce new Kconfig option to enable it: CONFIG_SSCANF. Disable by default. Signed-off-by: Andrii Anisov <andrii_anisov@epam.com> Signed-off-by: Anastasiia Lukianenko <anastasiia_lukianenko@epam.com> Signed-off-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
* dm: Rename DM test flags to make them more genericSimon Glass2020-08-071-9/+9
| | | | | | | | | | 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>
* test: provide tests for efi_image_region_add()Heinrich Schuchardt2020-07-032-0/+164
| | | | | | Provide unit tests for efi_image_region_add(). Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* common: Drop log.h from common headerSimon Glass2020-05-182-0/+2
| | | | | | 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>
* common: Drop net.h from common headerSimon Glass2020-05-181-0/+1
| | | | | | | | | | | Move this header out of the common header. Network support is used in quite a few places but it still does not warrant blanket inclusion. Note that this net.h header itself has quite a lot in it. It could be split into the driver-mode support, functions, structures, checksumming, etc. Signed-off-by: Simon Glass <sjg@chromium.org>
* lib/crypto, efi_loader: move some headers to include/cryptoAKASHI Takahiro2020-05-041-2/+2
| | | | | | | | | | Pkcs7_parse.h and x509_parser.h are used in UEFI subsystem, in particular, secure boot. So move them to include/crypto to avoid relative paths. Suggested-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Don't include include x509_parser.h twice. Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* test: add rsa_verify() unit testAKASHI Takahiro2020-03-122-0/+207
| | | | | | | | | | In this patch, a very simple test is added to verify that rsa_verify() using rsa_verify_with_pkey() work correctly. To keep the code simple, all the test data, either public key and verified binary data, are embedded in the source. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
* test: aes: fix memleakPhilippe Reynes2020-02-131-6/+7
| | | | | | | | | | | | | | | | | In the first version, the result of malloc is checked with ut_assertnonnull. But on a fail, this macro exit the function, so previously malloc are not freed. So to avoid a memleak, we don't use ut_assertnonnull, but simply check the return of malloc. If one has failed, we freed all the allocated memory and quit the function. Reported-by: Coverity (CID: 284403) Reported-by: Coverity (CID: 284404) Reported-by: Coverity (CID: 284405) Reported-by: Coverity (CID: 284406) Reported-by: Coverity (CID: 284407) Signed-off-by: Philippe Reynes <philippe.reynes@softathome.com>
* dm: core: Create a new header file for 'compat' featuresSimon Glass2020-02-051-0/+1
| | | | | | | | | | | | At present dm/device.h includes the linux-compatible features. This requires including linux/compat.h which in turn includes a lot of headers. One of these is malloc.h which we thus end up including in every file in U-Boot. Apart from the inefficiency of this, it is problematic for sandbox which needs to use the system malloc() in some files. Move the compatibility features into a separate header file. Signed-off-by: Simon Glass <sjg@chromium.org>
* aes: add test unit for aes196 and aes256Philippe Reynes2020-01-171-0/+4
| | | | | | | This commit add test unit for aes196 and aes256. Signed-off-by: Philippe Reynes <philippe.reynes@softathome.com> Reviewed-by: Simon Glass <sjg@chromium.org>
* aes: add test unit for aes128Philippe Reynes2020-01-172-0/+163
| | | | | | | This commit add test unit for aes128. Signed-off-by: Philippe Reynes <philippe.reynes@softathome.com> Reviewed-by: Simon Glass <sjg@chromium.org>
* cmd_ut: add a parameter prefix to the function cmd_ut_categoryPhilippe Reynes2020-01-071-1/+1
| | | | | | | | | | | | | | | | | | | | There is black magic in the file conftest.py that list all the test unit. Then, all those test unit are called in pytest. This call is done with the end of the name (for example checksum if the full name is bloblist_test_checksum). The result is that only test for dm are really executed. by pytest, all others tests are listed but never executed. This behaviour happens because the dm test unit only check the end of the name and others tests checks the full name. To fix this issue, I've added a prefix to the function cmd_ut_category, and this prefix is removed when looking for the unit test. Signed-off-by: Philippe Reynes <philippe.reynes@softathome.com> Tested-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* test: add asn1 unit testAKASHI Takahiro2019-12-062-0/+393
| | | | | | | This test will exercise asn1 compiler as well as asn1 decoder functions via various parsers. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>