summaryrefslogtreecommitdiffstats
path: root/tests
Commit message (Collapse)AuthorAgeFilesLines
* tests/lib/malloc-test: Fix possible memory overrunJakub Czapiga2021-04-111-1/+1
| | | | | | | | | | | | | | | Coverity reported false-positive possible memory overrun in setup_calloc_test(). Change memset address to use actual buffer instead of pointer stored in symbol value in order to silence Coverity. Signed-off-by: Jakub Czapiga <jacz@semihalf.com> Change-Id: I19f0718c657d565e515157e66367573e08f51254 Found-by: Coverity CID 1452005 Reviewed-on: https://review.coreboot.org/c/coreboot/+/52136 Reviewed-by: Julius Werner <jwerner@chromium.org> Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
* tests: Add lib/bootmem-test test caseJan Dabros2021-04-092-0/+418
| | | | | | | | | | Signed-off-by: Jan Dabros <jsd@semihalf.com> Signed-off-by: Jakub Czapiga <jacz@semihalf.com> Change-Id: Ic1e539061ee5051d4158712a8a981a475ea7458a Reviewed-on: https://review.coreboot.org/c/coreboot/+/43510 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
* include/assert.h: Use mock_assert() for ENV_TEST targetsJakub Czapiga2021-04-092-5/+6
| | | | | | | | | | | | | | | Some tests have to be able to catch assertion errors. Adding CMocka mock_assert() enables that. Additionally fix test_imd_create_tiered_empty(), test_full_stack() and test_incorrectly_initialized_stack() by adding missing expect_assert_failure(). Signed-off-by: Jakub Czapiga <jacz@semihalf.com> Change-Id: I5e8dd1b198ee6fab61e2be3f92baf1178f79bf18 Reviewed-on: https://review.coreboot.org/c/coreboot/+/51804 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org>
* include/rules.h: Add ENV_TEST definitionJakub Czapiga2021-04-061-0/+2
| | | | | | | | | | | | | | | Some functions/macros like assert() require redefinition for testing purposes. ENV_TEST is introduced to make it possible without using bypass hacks. This patch also adds a global __TEST__ define to TEST_CFLAGS for all test targets in order to enable ENV_TEST. Signed-off-by: Jakub Czapiga <jacz@semihalf.com> Change-Id: Ib8f2932902a73a7dbe181adc82cc18437abb48e8 Reviewed-on: https://review.coreboot.org/c/coreboot/+/51803 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
* tests: Add lib/uuid-test test caseJakub Czapiga2021-04-062-0/+99
| | | | | | | | Signed-off-by: Jakub Czapiga <jacz@semihalf.com> Change-Id: I7f8498ad3d9d0d68b34aa0b48daca60545ec3f4e Reviewed-on: https://review.coreboot.org/c/coreboot/+/51976 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org>
* lib: Add obvious definition for `calloc`Tim Wawrzynczak2021-04-061-0/+22
| | | | | | | | | | | The calloc() function is useful in addition to malloc and friends, so add the obvious definition. Change-Id: I57a568e323344a97b35014b7b8bec16adc2fd720 Signed-off-by: Tim Wawrzynczak <twawrzynczak@chromium.org> Reviewed-on: https://review.coreboot.org/c/coreboot/+/51949 Reviewed-by: Angel Pons <th3fanbus@gmail.com> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
* tests/include/tests/test.h: Add TEST_REGION_UNALLOCATEDJakub Czapiga2021-03-281-1/+8
| | | | | | | | | | | | | Some tested modules require regions to be defined but do not necessarily access them. TEST_REGION_UNALLOCATED() combined with DECLARE_REGION() are sufficient for most cases that require symbols only. Signed-off-by: Jakub Czapiga <jacz@semihalf.com> Change-Id: I51c5f6ce56575021c6e4277a9ed17263cd2e3bb2 Reviewed-on: https://review.coreboot.org/c/coreboot/+/51769 Reviewed-by: Julius Werner <jwerner@chromium.org> Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
* tests: memset-test: Parenthesize zero size argument for clangJulius Werner2021-03-181-1/+1
| | | | | | | | | | | | | | | | | | When running coreboot unit tests on a recent clang version, it helpfully throws an error on memset(..., 0xAA, 0) because it thinks you probably made a typo and meant to write memset(..., 0, 0xAA) instead. I mean, who would ever memset() a buffer of zero bytes, right? Unfortunately, unit tests for memset() want to do exactly that. Wrapping the argument in parenthesis silences the warning. Signed-off-by: Julius Werner <jwerner@chromium.org> Change-Id: I21aeb5ec4d6ce74d5df2d21e2f9084b17b3ac6e3 Reviewed-on: https://review.coreboot.org/c/coreboot/+/51617 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Jakub Czapiga <jacz@semihalf.com> Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net> Reviewed-by: Angel Pons <th3fanbus@gmail.com> Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org>
* tests: Add lib/memrange-test test caseJan Dabros2021-03-152-0/+644
| | | | | | | | | Signed-off-by: Jan Dabros <jsd@semihalf.com> Signed-off-by: Jakub Czapiga <jacz@semihalf.com> Change-Id: If30a238d32326ffd1d6719470deedc77f176ac72 Reviewed-on: https://review.coreboot.org/c/coreboot/+/43305 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org>
* tests/Makefile.inc: Enable support for multiple test groupsJakub Czapiga2021-03-101-1/+1
| | | | | | | | | | | | | | Until now output of all test groups run in single unit test were saved in the same file which caused Jenkins to fail because of existence of multiple root XML elements. Now each test group is saved to its own file containing its name at the end of the filename. Signed-off-by: Jakub Czapiga <jacz@semihalf.com> Change-Id: I21ba512073bc8d8693daad8a9b86d5b076bea03f Reviewed-on: https://review.coreboot.org/c/coreboot/+/51281 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org>
* tests: Add lib/compute_ip_checksum-test test caseJakub Czapiga2021-03-022-0/+106
| | | | | | | | Signed-off-by: Jakub Czapiga <jacz@semihalf.com> Change-Id: I61c578ec93837cb2581a1ab9e2f3db2a0dd69f3d Reviewed-on: https://review.coreboot.org/c/coreboot/+/51089 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org>
* tests: Add lib/crc_byte-test test caseJakub Czapiga2021-03-022-0/+301
| | | | | | | | Signed-off-by: Jakub Czapiga <jacz@semihalf.com> Change-Id: I9016cd7825cb681fd200b23dd362ca24acf69192 Reviewed-on: https://review.coreboot.org/c/coreboot/+/51088 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org>
* tests: Add lib/memmove-test test caseJakub Czapiga2021-03-012-0/+253
| | | | | | | | Signed-off-by: Jakub Czapiga <jacz@semihalf.com> Change-Id: Ic9b68eb0fa85bbc3f66d57cdcb329073b26bea57 Reviewed-on: https://review.coreboot.org/c/coreboot/+/50902 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org>
* tests/lib/memchr-test: Fix possible memory overrun, add non-null checksJakub Czapiga2021-02-261-3/+7
| | | | | | | | | | | | Three calls to memchr() had incorrect length values which could lead to memory overrun. Add non-null checks to ensure correct return values from memchr() Signed-off-by: Jakub Czapiga <jacz@semihalf.com> Change-Id: Ief7b7e2ecb9b5d2e05e6983d92d02fa00935b392 Reviewed-on: https://review.coreboot.org/c/coreboot/+/51054 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org>
* tests: Add lib/malloc-test test caseJakub Czapiga2021-02-262-0/+150
| | | | | | | | Signed-off-by: Jakub Czapiga <jacz@semihalf.com> Change-Id: Ic6b10ec382cc807772689e852bad300c75da1fe2 Reviewed-on: https://review.coreboot.org/c/coreboot/+/50715 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org>
* tests: Add lib/memcpy-test test caseJakub Czapiga2021-02-232-0/+199
| | | | | | | | Signed-off-by: Jakub Czapiga <jacz@semihalf.com> Change-Id: I00464ec2db23867712cd2efd7f6cad92e3ee361a Reviewed-on: https://review.coreboot.org/c/coreboot/+/50799 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org>
* tests: Add acpi/acpigen-test test caseJakub Czapiga2021-02-233-2/+226
| | | | | | | | Signed-off-by: Jakub Czapiga <jacz@semihalf.com> Change-Id: Icc128212c1f72beb50caca671b4bada3507d3a1f Reviewed-on: https://review.coreboot.org/c/coreboot/+/50520 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Patrick Georgi <pgeorgi@google.com>
* tests: Add lib/memchr-test test caseJakub Czapiga2021-02-222-0/+105
| | | | | | | | Signed-off-by: Jakub Czapiga <jacz@semihalf.com> Change-Id: Idcc824bfd9ca950f377c8f6a5916ffaba450fe73 Reviewed-on: https://review.coreboot.org/c/coreboot/+/50721 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org>
* memlayout: Store region sizes as separate symbolsJulius Werner2021-02-191-1/+2
| | | | | | | | | | | | | | | | This patch changes the memlayout macro infrastructure so that the size of a region "xxx" (i.e. the distance between the symbols _xxx and _exxx) is stored in a separate _xxx_size symbol. This has the advantage that region sizes can be used inside static initializers, and also saves an extra subtraction at runtime. Since linker symbols can only be treated as addresses (not as raw integers) by C, retain the REGION_SIZE() accessor macro to hide the necessary typecast. Signed-off-by: Julius Werner <jwerner@chromium.org> Change-Id: Ifd89708ca9bd3937d0db7308959231106a6aa373 Reviewed-on: https://review.coreboot.org/c/coreboot/+/49332 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Aaron Durbin <adurbin@chromium.org>
* tests: Add lib/memcmp-test test caseJakub Czapiga2021-02-182-0/+77
| | | | | | | | Signed-off-by: Jakub Czapiga <jacz@semihalf.com> Change-Id: Ib63123a36179127af4e3720ed01ca2611daa607e Reviewed-on: https://review.coreboot.org/c/coreboot/+/50785 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org>
* tests: Add lib/memset-test test caseJakub Czapiga2021-02-182-0/+124
| | | | | | | | Signed-off-by: Jakub Czapiga <jacz@semihalf.com> Change-Id: I6750caa8ccdc442f78b782407ebfb3af78f476ce Reviewed-on: https://review.coreboot.org/c/coreboot/+/50716 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org>
* rmodtool: Make memlayout symbols absolute and do not relocate themJulius Werner2021-02-181-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Memlayout is a mechanism to define memory areas outside the normal program segment constructed by the linker. Therefore, it generally doesn't make sense to relocate memlayout symbols when the program is relocated. They tend to refer to things that are always in one specific spot, independent of where the program is loaded. This hasn't really hurt us in the past because the use case we have for rmodules (ramstage on x86) just happens to not really need to refer to any memlayout-defined areas at the moment. But that use case may come up in the future so it's still worth fixing. This patch declares all memlayout-defined symbols as ABSOLUTE() in the linker, which is then reflected in the symbol table of the generated ELF. We can then use that distinction to have rmodtool skip them when generating the relocation table for an rmodule. (Also rearrange rmodtool a little to make the primary string table more easily accessible to the rest of the code, so we can refer to symbol names in debug output.) A similar problem can come up with userspace unit tests, but we cannot modify the userspace relocation toolchain (and for unfortunate historical reasons, it tries to relocate even absolute symbols). We'll just disable PIC and make those binaries fully static to avoid that issue. Signed-off-by: Julius Werner <jwerner@chromium.org> Change-Id: Ic51d9add3dc463495282b365c1b6d4a9bf11dbf2 Reviewed-on: https://review.coreboot.org/c/coreboot/+/50629 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Aaron Durbin <adurbin@chromium.org>
* tests: Build tests with -Wno-inline-asmJulius Werner2021-02-171-1/+1
| | | | | | | | | | | | | | Clang doesn't seem to get along with some of the symbol magic we use for memlayout and throws -Winline-asm warnings. Since we want to be compatible with as many host compilers as possible (within reason), let's disable that warning. Signed-off-by: Julius Werner <jwerner@chromium.org> Change-Id: If1d88ed0bb2d10acfadcf8dec74fa3d227e0f790 Reviewed-on: https://review.coreboot.org/c/coreboot/+/50825 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Jan Dabros <jsd@semihalf.com> Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org>
* tests: Add lib/stack-test test caseJakub Czapiga2021-02-122-0/+138
| | | | | | | | Signed-off-by: Jakub Czapiga <jacz@semihalf.com> Change-Id: Icf0cceac290618a50ecc4e65f1f9551dbf31bd32 Reviewed-on: https://review.coreboot.org/c/coreboot/+/50305 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org>
* tests: Add lib/region_file-test test caseJakub Czapiga2021-02-023-0/+1424
| | | | | | | | Signed-off-by: Jakub Czapiga <jacz@semihalf.com> Change-Id: Ic48e52a97b18d55fd983315f25dc972f472cc473 Reviewed-on: https://review.coreboot.org/c/coreboot/+/49669 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Patrick Georgi <pgeorgi@google.com>
* tests: Add lib/imd_cbmem-test test caseJakub Czapiga2021-01-183-0/+4764
| | | | | | | | Signed-off-by: Jakub Czapiga <jacz@semihalf.com> Change-Id: Ie893b5e8fc91c230ff96a14146085de16d78b1c1 Reviewed-on: https://review.coreboot.org/c/coreboot/+/46458 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
* device: Use __pci_0_00_0_config in config_of_soc()Furquan Shaikh2021-01-121-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This change updates the definition of config_of_soc() to a macro that expands to __pci_0_00_0_config instead of accessing the config structure by referencing the struct device. This allows linker to optimize out unused portions of the device tree from early stages. With this change, bootblock .text section size drops as follows: Platform | Size without change | Size with change | Reduction | ---------------|---------------------|------------------|-------------| GLK (ampton) | 27112 bytes | 9832 bytes | 17280 bytes | APL (reef) | 26488 bytes | 17528 bytes | 8960 bytes | TGL (volteer2) | 47760 bytes | 21648 bytes | 26112 bytes | CML (hatch) | 40616 bytes | 22792 bytes | 17824 bytes | JSL (waddledee)| 37872 bytes | 19408 bytes | 18464 bytes | KBL (soraka) | 31840 bytes | 21568 bytes | 10272 bytes | As static.h is now included in device.h which gets pulled in during the unit tests, a dummy static.h is added under tests/include. Change-Id: I1fbf5b9817065e967e46188739978a1cc96c2c7e Signed-off-by: Furquan Shaikh <furquan@google.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/49215 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Angel Pons <th3fanbus@gmail.com> Reviewed-by: Tim Wawrzynczak <twawrzynczak@chromium.org> Reviewed-by: Arthur Heymans <arthur@aheymans.xyz> Reviewed-by: Nico Huber <nico.h@gmx.de>
* tests: Add lib/fmap-test test caseJakub Czapiga2021-01-084-0/+567
| | | | | | | | Signed-off-by: Jakub Czapiga <jacz@semihalf.com> Change-Id: I885ea05d509d3b1330de7a18531f310d290c6965 Reviewed-on: https://review.coreboot.org/c/coreboot/+/48557 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
* edist-test: Fix _Static_assert missing message stringDaniel Gröber2020-12-021-1/+2
| | | | | | | | | | | | | | | Older GCCs don't support _Static_assert without a message string as the second argument. AFAICT _Static_assert with two arguments is in C11 but omitting the message argument is an extension. The tests appear to be built with the system gcc rather than our crossgcc so that's probably why this was not cought by CI. Change-Id: I41fd0ffc42ded8b6d145c3ec30cc7407a78b9a43 Signed-off-by: Daniel Gröber <dxld@darkboxed.org> Reviewed-on: https://review.coreboot.org/c/coreboot/+/48151 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Patrick Georgi <pgeorgi@google.com>
* tests: Add lib/list-test test caseJakub Czapiga2020-11-252-1/+135
| | | | | | | | Change-Id: If74f241b2bb788b3e2fd1b9062fc74819f7be31e Signed-off-by: Jakub Czapiga <jacz@semihalf.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/47507 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org>
* tests: Add lib/cbmem_console-test test caseJakub Czapiga2020-11-222-0/+145
| | | | | | | | | | | Add test case executed twice, once for ROMSTAGE and once RAMSTAGE. Each test is named and visible in cmocka output with stage in its name. Signed-off-by: Jakub Czapiga <jacz@semihalf.com> Change-Id: I464eee61f538188427bec730d2e004c7b76cca67 Reviewed-on: https://review.coreboot.org/c/coreboot/+/47642 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org>
* tests: Add lib/edid-test test caseJakub Czapiga2020-11-104-0/+1481
| | | | | | | | Signed-off-by: Jakub Czapiga <jacz@semihalf.com> Change-Id: I796e660eebc4d2c3c32207bd3a6ee44aaffeb325 Reviewed-on: https://review.coreboot.org/c/coreboot/+/46817 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org>
* tests: Add lib/timestamp-test test caseJakub Czapiga2020-11-094-1/+180
| | | | | | | | Signed-off-by: Jakub Czapiga <jacz@semihalf.com> Change-Id: I39abfc644fef085cef2175086a0e45a040b244de Reviewed-on: https://review.coreboot.org/c/coreboot/+/46968 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org>
* tests: Add lib/imd-test test caseJakub Czapiga2020-10-262-0/+768
| | | | | | | | | | | | | Implement unit tests for src/lib/imd.c module. Signed-off-by: Jakub Czapiga <jacz@semihalf.com> Signed-off-by: Anna Karas <aka@semihalf.com> Signed-off-by: Jan Dabros <jsd@semihalf.com> Change-Id: I3902f8638669440144064ce0e3756918338f4068 Reviewed-on: https://review.coreboot.org/c/coreboot/+/46457 Reviewed-by: Angel Pons <th3fanbus@gmail.com> Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
* tests: Add test region and symbol macros to <tests/test.h>Jakub Czapiga2020-10-261-0/+14
| | | | | | | | | | | | | Some modules require and operate on memory regions and symbols. This macros systematize how they are defined in testing code. Signed-off-by: Jakub Czapiga <jacz@semihalf.com> Change-Id: I314028c201732416bb3d5446a4c8585e055073e3 Reviewed-on: https://review.coreboot.org/c/coreboot/+/46684 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Julius Werner <jwerner@chromium.org> Reviewed-by: Angel Pons <th3fanbus@gmail.com> Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org>
* device/dram: Add method for converting MHz to MT/sRob Barnes2020-09-162-0/+46
| | | | | | | | | | | | | | | | Add method for converting DDR4 speed in MHz to MT/s. Checks that MHz is within a speed grade range. BUG=b:167155849 TEST=ddr4-test unit test BRANCH=Zork Change-Id: I1433f028afb794fe3e397b03f5bd0565494c8130 Signed-off-by: Rob Barnes <robbarnes@google.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/45343 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org> Reviewed-by: Furquan Shaikh <furquan@google.com>
* tests: Improve test_skip_atoi() in /lib/string-test test caseAnna Karas2020-07-121-5/+8
| | | | | | | | | | | Confirm that the pointer is updated to point behind the parsed number. Signed-off-by: Anna Karas <aka@semihalf.com> Change-Id: If75a51056229904612c6a9ea20db4182d1935009 Reviewed-on: https://review.coreboot.org/c/coreboot/+/43288 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Julius Werner <jwerner@chromium.org> Reviewed-by: Angel Pons <th3fanbus@gmail.com>
* tests: Move the console stubs to a dedicated directoryAnna Karas2020-07-123-6/+14
| | | | | | | | | | | | Move the console functions definitions out from lib/b64_decode code to a dedicated directory. Signed-off-by: Anna Karas <aka@semihalf.com> Change-Id: I22a6a592f0d4d509f19920f4ad2b18e8ed83a03e Reviewed-on: https://review.coreboot.org/c/coreboot/+/43285 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
* tests: Add lib/hexstrtobin-test test caseAnna Karas2020-07-072-0/+52
| | | | | | | | | | Implement unit tests for lib/hexstrtobin module. Signed-off-by: Anna Karas <aka@semihalf.com> Change-Id: Id929b07936ea180a798309e5acb1dacf1b396e32 Reviewed-on: https://review.coreboot.org/c/coreboot/+/43088 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org>
* tests: Add lib/b64_decode-test test caseAnna Karas2020-07-062-0/+71
| | | | | | | | | | Implement unit tests for lib/b64_decode module. Signed-off-by: Anna Karas <aka@semihalf.com> Change-Id: Id5fe9272e30eaff3d086a95241b3819101089c2b Reviewed-on: https://review.coreboot.org/c/coreboot/+/42313 Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
* tests: Complete lib/string-test test caseAnna Karas2020-07-061-18/+235
| | | | | | | | | | | | Implement unit tests for remaining string library functions. Fix memory leak in test_strdup(). Signed-off-by: Anna Karas <aka@semihalf.com> Change-Id: I8ac6a6b2413d9077dc9ea81f638a2b0acd5c8862 Reviewed-on: https://review.coreboot.org/c/coreboot/+/42311 Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
* tests/lib/Makefile.inc: remove a commentAnna Karas2020-07-011-3/+0
| | | | | | | | | | | Remove a comment since is not useful anymore. Signed-off-by: Anna Karas <aka@semihalf.com> Change-Id: I236b040a83700bcd34d99db61e5dad0ff7abb28c Reviewed-on: https://review.coreboot.org/c/coreboot/+/42312 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
* tests: Add some basic warnings and fix resulting issuesJulius Werner2020-06-123-6/+17
| | | | | | | | | | | | | | | | | | | The current test framework builds the test code without any warnings at all, which isn't great -- we have already slipped in some cases of non-void functions not returning a defined value, for example. It would likely be overkill to try to use all the same warnings we use for normal coreboot code (e.g. some stuff like -Wmissing-prototypes makes cmocka's __wrap_xxx() mock functions unnecessarily cumbersome to work with, and other things like -Wvla may be appropriate for firmware but is probably too aggressive for some simple test code). Therefore, let's just add some of the stuff that points out the most obvious errors. Signed-off-by: Julius Werner <jwerner@chromium.org> Change-Id: I4d9801f52a8551f55f419f4141dc21ccb835d676 Reviewed-on: https://review.coreboot.org/c/coreboot/+/42259 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Jan Dabros <jsd@semihalf.com> Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org>
* tests: Always run all unit testsPatrick Georgi2020-05-281-5/+13
| | | | | | | | | | | | | | So far, the semantics have been that run-unit-tests stopped at the first test suite that failed. This hides useful signal in later tests, so always run all tests and collect the result. Change-Id: I407715f85513c2c95a1cf89cfb427317dff9fbab Signed-off-by: Patrick Georgi <pgeorgi@google.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/41773 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Jan Dabros <jsd@semihalf.com> Reviewed-by: Martin Roth <martinroth@google.com> Reviewed-by: Angel Pons <th3fanbus@gmail.com>
* tests: Allow emitting junit output for unit testsPatrick Georgi2020-05-281-0/+6
| | | | | | | | | | Change-Id: Iab0c4250b1baa77d4eab7538ec1fd3310f9e63e4 Signed-off-by: Patrick Georgi <pgeorgi@google.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/41771 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Martin Roth <martinroth@google.com> Reviewed-by: Angel Pons <th3fanbus@gmail.com> Reviewed-by: Jan Dabros <jsd@semihalf.com>
* tests: Move cmocka binary into $(obj)Patrick Georgi2020-05-281-1/+1
| | | | | | | | | | | | | Put it in $(objutil) so that it's shared between board builds with abuild even if that doesn't matter right now. Change-Id: I5670d9b661891262ad936980f63fa93b07c27e95 Signed-off-by: Patrick Georgi <pgeorgi@google.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/41770 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Jan Dabros <jsd@semihalf.com> Reviewed-by: Martin Roth <martinroth@google.com> Reviewed-by: Angel Pons <th3fanbus@gmail.com>
* Remove new additions of "this file is part of" linesElyes HAOUAS2020-05-283-3/+0
| | | | | | | | | Change-Id: I6c69dcad82ee217ed4760dea1792dd1a6612cd8b Signed-off-by: Elyes HAOUAS <ehaouas@noos.fr> Reviewed-on: https://review.coreboot.org/c/coreboot/+/41606 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Angel Pons <th3fanbus@gmail.com> Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net>
* tests: Build Cmocka from sourceJan Dabros2020-05-261-2/+21
| | | | | | | | | | | | | | | | | | Relying on Cmocka packages, which are provided with different OS distributions, may introduce some problems with setup environments across developers (e.g. library version mismatch). Instead, let's build Cmocka from source code, which is now added to git submodules as 3rdparty/cmocka. Please note, that cmake tool is required for building Cmocka (thus also coreboot unit tests). Signed-off-by: Jan Dabros <jsd@semihalf.com> Change-Id: Ia947c5c60d5c58b76acebe4b614dd427ef995950 Reviewed-on: https://review.coreboot.org/c/coreboot/+/41653 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org> Reviewed-by: Patrick Georgi <pgeorgi@google.com>
* tests: Add region-test for rdev APIJulius Werner2020-05-193-2/+412
| | | | | | | | | | | | | | This patch adds a basic test for the common region and region_device APIs, sanity checking the basic functions and things like overflow-handling. There is certainly more that could be added here, but it's a start. Signed-off-by: Julius Werner <jwerner@chromium.org> Change-Id: I4932402f54768557e5b22b16e66220bd90ddebfd Reviewed-on: https://review.coreboot.org/c/coreboot/+/41046 Reviewed-by: Aaron Durbin <adurbin@chromium.org> Reviewed-by: Jan Dabros Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
* tests: Add <tests/test.h> wrapper header and fix --gc-sectionsJulius Werner2020-05-194-17/+28
| | | | | | | | | | | | | | | | | | <cmocka.h> requires a few standard headers to be explicitly included before itself or it will throw compilation errors. Having to always include these headers in the right order in every test is cumbersome. Instead, this patch encapsulates the problem in a new <tests/test.h> header that all tests should include (instead of <cmocka.h> directly). Also fix --gc-sections in the test framework which needs to be passed for linking, not for compiling. Signed-off-by: Julius Werner <jwerner@chromium.org> Change-Id: I4284d74c8673708e21a5266eb42f7b9ae19a1b12 Reviewed-on: https://review.coreboot.org/c/coreboot/+/41045 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Jan Dabros Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org>