summaryrefslogtreecommitdiffstats
path: root/tests/lib
Commit message (Collapse)AuthorAgeFilesLines
* lib: Check for non-existent DIMMs in check_if_dimm_changedEric Lai2022-04-201-5/+10
| | | | | | | | | | | | | | | | | | | | Treat dimm addr_map 0 non-existent. addr_map default is 0, we don't set it if Hw is not present. Also change the test case default to avoid 0. SODIMM SMbus address 0x50 to 0x53 is commonly used. BUG=b:213964936 BRANCH=firmware-brya-14505.B TEST=emerge-brya coreboot chromeos-bootimage The MRC training does not be performed again after rebooting. Signed-off-by: Eric Lai <eric_lai@quanta.corp-partner.google.com> Change-Id: I2ada0109eb0805174cb85d4ce373e2a3ab7dbcac Reviewed-on: https://review.coreboot.org/c/coreboot/+/63628 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Frank Wu <frank_wu@compal.corp-partner.google.com> Reviewed-by: Lean Sheng Tan <sheng.tan@9elements.com> Reviewed-by: Subrata Banik <subratabanik@google.com> Reviewed-by: Tim Wawrzynczak <twawrzynczak@chromium.org>
* tests: update CMocka to stable-1.1Jakub Czapiga2022-04-191-1/+1
| | | | | | | | | | | | CMocka stable-1.1 has some convenience bugfixes like vprint buffer increase or leftover values log fix (funtion names display correctly now. Signed-off-by: Jakub Czapiga <jacz@semihalf.com> Change-Id: I20ebd15324a21c17cccd2976ae9c3f86b040426d Reviewed-on: https://review.coreboot.org/c/coreboot/+/63636 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Arthur Heymans <arthur@aheymans.xyz>
* coreboot_tables: Replace 'struct lb_uint64' with lb_uint64_tJianjun Wang2022-04-142-12/+12
| | | | | | | | | | | | | | | Replace 'struct lb_uint64' with 'typedef __aligned(4) uint64_t lb_uint64_t', and remove unpack_lb64/pack_lb64 functions since it's no longer needed. Also replace 'struct cbuint64' with 'cb_uint64_t' and remove 'cb_unpack64' in libpayload for compatible with lb_uint64_t. Signed-off-by: Jianjun Wang <jianjun.wang@mediatek.com> Change-Id: If6b037e4403a8000625f4a5fb8d20311fe76200a Reviewed-on: https://review.coreboot.org/c/coreboot/+/63494 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
* tests/lib: Add space before single line comment terminationPaul Menzel2022-03-272-2/+2
| | | | | | | | Change-Id: I9321391cc06afddff94fbba79f93851b553c74b1 Signed-off-by: Paul Menzel <pmenzel@molgen.mpg.de> Reviewed-on: https://review.coreboot.org/c/coreboot/+/62935 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Jakub Czapiga <jacz@semihalf.com>
* coreboot_tables.c: Expose the ACPI RSDPArthur Heymans2022-03-091-0/+12
| | | | | | | | | | | | | | | | | | | | | The ACPI RSDP can only be found in: - legacy BIOS region - via UEFI service On some systems like ARM that legacy BIOS region is not an option, so to avoid needing UEFI it makes sense to expose the RSDP via a coreboot table entry. This also adds the respective unit test. Change-Id: I591312a2c48f0cbbb03b2787e4b365e9c932afff Signed-off-by: Arthur Heymans <arthur@aheymans.xyz> Reviewed-on: https://review.coreboot.org/c/coreboot/+/62573 Reviewed-by: Lance Zhao Reviewed-by: Angel Pons <th3fanbus@gmail.com> Reviewed-by: Nico Huber <nico.h@gmx.de> Reviewed-by: Tim Wawrzynczak <twawrzynczak@chromium.org> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
* commonlib/bsd: Remove cb_err_tJulius Werner2022-03-092-20/+20
| | | | | | | | | | | | | | | | | cb_err_t was meant to be used in place of `enum cb_err` in all situations, but the choice to use a typedef here seems to be controversial. We should not be arbitrarily using two different identifiers for the same thing across the codebase, so since there are no use cases for serializing enum cb_err at the moment (which would be the primary reason to typedef a fixed-width integer instead), remove cb_err_t again for now. Signed-off-by: Julius Werner <jwerner@chromium.org> Change-Id: Iaec36210d129db26d51f0a105d3de070c03b686b Reviewed-on: https://review.coreboot.org/c/coreboot/+/62600 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Yu-Ping Wu <yupingso@google.com> Reviewed-by: Tim Wawrzynczak <twawrzynczak@chromium.org>
* timestamps: Rename timestamps to make names more consistentJakub Czapiga2022-03-081-2/+2
| | | | | | | | | | | | | | | | | | This patch aims to make timestamps more consistent in naming, to follow one pattern. Until now there were many naming patterns: - TS_START_*/TS_END_* - TS_BEFORE_*/TS_AFTER_* - TS_*_START/TS_*_END This change also aims to indicate, that these timestamps can be used to create time-ranges, e.g. from TS_BOOTBLOCK_START to TS_BOOTBLOCK_END. Signed-off-by: Jakub Czapiga <jacz@semihalf.com> Change-Id: I533e32392224d9b67c37e6a67987b09bf1cf51c6 Reviewed-on: https://review.coreboot.org/c/coreboot/+/62019 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Tim Wawrzynczak <twawrzynczak@chromium.org> Reviewed-by: Yu-Ping Wu <yupingso@google.com> Reviewed-by: Raul Rangel <rrangel@chromium.org>
* tests: Fix tests code and comments styleJakub Czapiga2022-01-1424-1055/+1068
| | | | | | | | | | | | | | This patch applies clang-format settings to most of tests files. Some files were fixed "by-hand" to exclude some lines, which whould be less readable after automatic style fixing. Moreover, some comments (mostly in tests/lib/edid-test.c) were adjusted to match coreboot coding style guidelines. Change-Id: I69f25a7b6d8265800c731754e2fbb2255f482134 Signed-off-by: Jakub Czapiga <jacz@semihalf.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/60970 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org>
* tests: Move EDID test header to include/tests/libJakub Czapiga2022-01-121-1/+1
| | | | | | | | | | | Move header to path with all other test headers to make include paths unambigous. Change-Id: Ie2dbb055df658272424df95f58d84caaeba3fc8f Signed-off-by: Jakub Czapiga <jacz@semihalf.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/60969 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
* tests/lib/lzma-test: Fix uninitialized array errorJakub Czapiga2021-12-151-1/+1
| | | | | | | | | Change-Id: I5b10eef3dd82068f97d4d875f3da813a5aca07a7 Signed-off-by: Jakub Czapiga <jacz@semihalf.com> Reported-by: Paul Fagerburg <pfagerburg@chromium.org> Reviewed-on: https://review.coreboot.org/c/coreboot/+/60112 Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
* lib: Add __fls() (Find Last Set)Jianjun Wang2021-12-131-0/+10
| | | | | | | | | | | | Implement __fls() as an alias for log2(), and remove the duplicate definitions in commonlib/storage/sdhci.c. Signed-off-by: Jianjun Wang <jianjun.wang@mediatek.com> Change-Id: Ib458abfec7e03b2979569a8440a6e69b0285ac32 Reviewed-on: https://review.coreboot.org/c/coreboot/+/59738 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Julius Werner <jwerner@chromium.org> Reviewed-by: Yu-Ping Wu <yupingso@google.com>
* lib: Fix log2_ceil() for 0xffffffffYu-Ping Wu2021-12-082-0/+63
| | | | | | | | | | | | | | | | | | Current log2_ceil(x) is defined as log2(x * 2 - 1). When x is larger than (1 << 31), (x * 2 - 1) won't fit in u32, leading to incorrect result. Therefore, correct it as (log2(x - 1) + 1). Also add unit tests for inline functions in lib.h. BUG=none TEST=make tests/lib/lib-test BRANCH=none Change-Id: If868f793b909a6ad7fc48a7affac15e2c714fa2e Signed-off-by: Yu-Ping Wu <yupingso@chromium.org> Reviewed-on: https://review.coreboot.org/c/coreboot/+/59834 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Julius Werner <jwerner@chromium.org> Reviewed-by: Paul Menzel <paulepanter@mailbox.org>
* cbfs: Remove deprecated APIsJulius Werner2021-12-062-0/+2
| | | | | | | | | | | | | | This patch removes all remaining pieces of the old CBFS API, now that the last straggling use cases of it have been ported to the new one (meaning cbfs_map()/cbfs_load()/etc... see CB:39304 and CB:38421). Signed-off-by: Julius Werner <jwerner@chromium.org> Change-Id: I1cec0ca2d9d311626a087318d1d78163243bfc3c Reviewed-on: https://review.coreboot.org/c/coreboot/+/59682 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Raul Rangel <rrangel@chromium.org> Reviewed-by: Yu-Ping Wu <yupingso@google.com> Reviewed-by: Werner Zeh <werner.zeh@siemens.com>
* commonlib: Move commonlib/cbmem_id.h to commonlib/bsd/Jakub Czapiga2021-11-301-1/+1
| | | | | | | | | | | | | Libpayload requires cbmem_id.h file to support extracting values from CBMEM IMD entries of coreboot tables. Libpayload use BSD-3-Clause license, and all of its files used to compile a static library have to use it too. Change-Id: I97c080e34ebdbcdf14fe3a3c9515b1dea8ede179 Signed-off-by: Jakub Czapiga <jacz@semihalf.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/59696 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Patrick Georgi <patrick@coreboot.org>
* arch/x86: Refactor the SMBIOS type 17 write functionSubrata Banik2021-11-112-16/+87
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | List of changes: 1. Create Module Type macros as per Memory Type (i.e. DDR2/DDR3/DDR4/DDR5/LPDDR4/LPDDR5) and fix compilation issue due to renaming of existing macros due to scoping the Memory Type. 2. Use dedicated Memory Type and Module type for `Form Factor` and `TypeDetail` conversion using `get_spd_info()` function. 3. Create a new API (convert_form_factor_to_module_type()) for `Form Factor` to 'Module type' conversion as per `Memory Type`. 4. Add new argument as `Memory Type` to smbios_form_factor_to_spd_mod_type() so that it can internally call convert_form_factor_to_module_type() for `Module Type` conversion. 5. Update `test_smbios_form_factor_to_spd_mod_type()` to accommodate different memory types. 6. Skip fixed module type to form factor conversion using DDR2 SPD4 specification (inside dimm_info_fill()). Refer to datasheet SPD4.1.2.M-1 for LPDDRx and SPD4.1.2.L-3 for DDRx. BUG=b:194659789 TEST=Refer to dmidecode -t 17 output as below: Without this code change: Handle 0x0012, DMI type 17, 40 bytes Memory Device Array Handle: 0x000A Error Information Handle: Not Provided Total Width: 16 bits Data Width: 16 bits Size: 2048 MB Form Factor: Unknown .... With this code change: Handle 0x0012, DMI type 17, 40 bytes Memory Device Array Handle: 0x000A Error Information Handle: Not Provided Total Width: 16 bits Data Width: 16 bits Size: 2048 MB Form Factor: Row Of Chips .... Change-Id: Ia337ac8f50b61ae78d86a07c7a86aa9c248bad50 Signed-off-by: Subrata Banik <subrata.banik@intel.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/56628 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Jakub Czapiga <jacz@semihalf.com> Reviewed-by: Tim Wawrzynczak <twawrzynczak@chromium.org>
* lib/list: Add list_appendRaul E Rangel2021-11-031-0/+20
| | | | | | | | | | | | | This method will add a node to the end of the list. BUG=b:179699789 TEST=Boot guybrush to the OS Signed-off-by: Raul E Rangel <rrangel@chromium.org> Change-Id: I1792e40f789e3ef16ceca65ce4cae946e08583d1 Reviewed-on: https://review.coreboot.org/c/coreboot/+/58805 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
* lib: Add new argument as `ddr_type` to smbios_bus_width_to_spd_width()Subrata Banik2021-11-021-16/+39
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add DDR5 and LPDDR5 memory type checks while calculating bus width extension (in bits). Additionally, update all caller functions of smbios_bus_width_to_spd_width() to pass `MemoryType` as argument. Update `test_smbios_bus_width_to_spd_width()` to accommodate different memory types. Create new macro to fix incorrect bus width reporting on platform with DDR5 and LPDDR5 memory. With this code changes, on DDR5 system with 2 Ch per DIMM, 32 bit primary bus width per Ch showed the Total width as: Handle 0x000F, DMI type 17, 40 bytes Memory Device Array Handle: 0x0009 Error Information Handle: Not Provided Total Width: 80 bits Data Width: 64 bits Size: 16 GB ... BUG=b:194659789 Tested=On Alder Lake DDR5 RVP, SMBIOS type 17 shows expected `Total Width`. Change-Id: I79ec64c9d522a34cb44b3f575725571823048380 Signed-off-by: Subrata Banik <subrata.banik@intel.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/58601 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Tim Wawrzynczak <twawrzynczak@chromium.org> Reviewed-by: Rob Barnes <robbarnes@google.com>
* tests: Add lib/lzma-test test caseJakub Czapiga2021-10-142-0/+196
| | | | | | | | | | | | | | | | | Files used by this test are in: tests/data/lib/lzma-test/ file.bin - files with uncompressed data file.lzma.bin - files with LZMA-compressed data from file.bin How to prepare compressed file: util/cbfs-compression-tool compress file.bin /tmp/file.lzma.bin lzma dd if=/tmp/file.lzma.bin of=file.lzma.bin skip=8 ibs=1 Signed-off-by: Jakub Czapiga <jacz@semihalf.com> Change-Id: Id75e0b41991382d4c391b031862106de58eacdf7 Reviewed-on: https://review.coreboot.org/c/coreboot/+/57555 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/cbfs-lookup-test test caseJakub Czapiga2021-09-142-0/+1085
| | | | | | | | Signed-off-by: Jakub Czapiga <jacz@semihalf.com> Change-Id: I2ebebba1468c19661741de8a8456605b1c5f56b6 Reviewed-on: https://review.coreboot.org/c/coreboot/+/56813 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
* tests: Add lib/cbfs-verification-test test caseJakub Czapiga2021-09-022-0/+228
| | | | | | | | | | | This commit adds test case for lib/cbfs verification mechanisms. Signed-off-by: Jakub Czapiga <jacz@semihalf.com> Change-Id: I1d8cbb1c2d0a9db3236de065428b70a9c2a66330 Reviewed-on: https://review.coreboot.org/c/coreboot/+/56601 Reviewed-by: Julius Werner <jwerner@chromium.org> Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
* tests: Improve test output readabilityJakub Czapiga2021-09-0129-39/+32
| | | | | | | | | | | | | | | | | | | | | | When running multiple tests, e.g. by using unit-tests target, it is hard to differentiate, which output comes from which file and/or configuration. This patch makes the output easier to analyze and understand by using new wrapper macro cb_run_group_tests(). This macro uses __TEST_NAME__ value (containing test path and Makefile test name) as a group name when calling cmocka group runner. Example: Test path: tests/lib/ Makefile test name: cbmem_stage_cache-test Test group array name: tests Result: tests/lib/cbmem_stage_cache-test(tests) Signed-off-by: Jakub Czapiga <jacz@semihalf.com> Change-Id: I4fd936d00d77cbe2637b857ba03b4a208428ea0d Reviewed-on: https://review.coreboot.org/c/coreboot/+/57144 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
* tests/Makefile.inc: Add missing include paths to TEST_CFLAGSJakub Czapiga2021-08-131-4/+0
| | | | | | | | | | | Add missing paths to common tests cflags and remove these paths from individual tests configuration. Signed-off-by: Jakub Czapiga <jacz@semihalf.com> Change-Id: I13cb336195bfb06b861d7f403822f06bec8a40aa Reviewed-on: https://review.coreboot.org/c/coreboot/+/56933 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org>
* tests: Add lib/libgcc-test test caseJakub Czapiga2021-07-262-0/+135
| | | | | | | | | | | | Add tests for src/lib/libgcc.c __clzsi2() implementation. Unlike GCC implementation, coreboot one can handle zero input. Signed-off-by: Jakub Czapiga <jacz@semihalf.com> Change-Id: I3f46071d0921e8c5edc5df3c296d11c77de01c88 Reviewed-on: https://review.coreboot.org/c/coreboot/+/56257 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
* tests: Rework mocking facilityPatrick Georgi2021-06-103-5/+5
| | | | | | | | | | | | | | | | | | | | Using the linker's --wrap feature has the downside that it only covers references across object files: If foo.c defines a() and b(), with b calling a, --wrap=a does nothing to that call. Instead, use objcopy to mark a weak and global so it can be overridden by another implementation, but only for files originating in src/. That way mocks - implemented in tests/ - become the source of truth. TEST=Had such an issue with get_log_level() in a follow-up commit, and the mock now takes over. Also, all existing unit tests still pass. Change-Id: I99c6d6e44ecfc73366bf464d9c51c7da3f8db388 Signed-off-by: Patrick Georgi <pgeorgi@google.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/55360 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Jakub Czapiga <jacz@semihalf.com>
* tests: Add lib/cbmem_stage_cache-test test caseJakub Czapiga2021-06-012-0/+204
| | | | | | | | Signed-off-by: Jakub Czapiga <jacz@semihalf.com> Change-Id: Ie6851b9473b225beb5ba51e26f44e21ea5919a64 Reviewed-on: https://review.coreboot.org/c/coreboot/+/54916 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org>
* tests/lib/memset-test: Add missing malloc check and free on errorJakub Czapiga2021-05-261-2/+2
| | | | | | | | | | | | Coverity found resource leak in test setup function in error block. Add malloc result check and free in error handling to silence Coverity. Signed-off-by: Jakub Czapiga <jacz@semihalf.com> Found-by: Coverity CID 1446760 Change-Id: Icf746df27167047fa3cf8f5df09fced20863f76d Reviewed-on: https://review.coreboot.org/c/coreboot/+/54874 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org>
* tests/lib/spd_cache-test: Initialize spd_block.addr_mapJakub Czapiga2021-05-181-5/+5
| | | | | | | | | | | | | | Coverity reported unitialized array spd_block.addr_map which values are not used. Add initialization to silence Coverity and avoid errors in the future. Signed-off-by: Jakub Czapiga <jacz@semihalf.com> Found-by: Coverity CID 1453145 1453146 1453147 1453148 1453149 Change-Id: If301f9e5d9e06ad26769bd0717f1f906e620d82d Reviewed-on: https://review.coreboot.org/c/coreboot/+/54355 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Martin Roth <martinroth@google.com> Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org>
* tests: Add lib/spd_cache-test test caseJakub Czapiga2021-05-142-0/+280
| | | | | | | | Signed-off-by: Jakub Czapiga <jacz@semihalf.com> Change-Id: Ic9a1420e49e1e80d180117c931e630e54c90cd75 Reviewed-on: https://review.coreboot.org/c/coreboot/+/52938 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org>
* tests/lib/crc_byte-test: Fix incorrect variable typesJakub Czapiga2021-05-051-20/+23
| | | | | | | | | | | | | | Some crc16_byte() and crc32_byte() tests had uint8_t instead of uint16_t or uint32_t. That caused CRC values to be truncated and made tests incorrect. Also fix incorrect pre-calculated CRC values and change test buffer name to more the accurate. Signed-off-by: Jakub Czapiga <jacz@semihalf.com> Change-Id: I61ee029a6950a8dfeb54520b634eaf4ed6bac576 Reviewed-on: https://review.coreboot.org/c/coreboot/+/52708 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org>
* tests: Add lib/rtc-test test caseJakub Czapiga2021-04-212-0/+317
| | | | | | | | Signed-off-by: Jakub Czapiga <jacz@semihalf.com> Change-Id: I2062e0d9dc2018bd6d8a210c8d26f2091e8c03fe Reviewed-on: https://review.coreboot.org/c/coreboot/+/52414 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org>
* commonlib/region: Turn addrspace_32bit into a more official APIJulius Werner2021-04-212-83/+55
| | | | | | | | | | | | | | | | | | | We had the addrspace_32bit rdev in prog_loaders.c for a while to help represent memory ranges as an rdev, and we've found it useful for a couple of things that have nothing to do with program loading. This patch moves the concept straight into commonlib/region.c so it is no longer anchored in such a weird place, and easier to use in unit tests. Also expand the concept to the whole address space (there's no real need to restrict it to 32 bits in 64-bit environments) and introduce an rdev_chain_mem() helper function to make it a bit easier to use. Replace some direct uses of struct mem_region_device with this new API where it seems to make sense. Signed-off-by: Julius Werner <jwerner@chromium.org> Change-Id: Ie4c763b77f77d227768556a9528681d771a08dca Reviewed-on: https://review.coreboot.org/c/coreboot/+/52533 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Aaron Durbin <adurbin@chromium.org>
* tests: Add lib/coreboot_table-test test caseJakub Czapiga2021-04-182-0/+507
| | | | | | | | Signed-off-by: Jakub Czapiga <jacz@semihalf.com> Change-Id: I4d7d9ca43316bf514bb5ebd8909f441bcfa20eba Reviewed-on: https://review.coreboot.org/c/coreboot/+/52159 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org>
* tests: Add lib/dimm_info_util-test test caseJakub Czapiga2021-04-152-0/+117
| | | | | | | | | Signed-off-by: Jakub Czapiga <jacz@semihalf.com> Change-Id: I536566ba883bbeb558587a8d71e3d86152fb5e14 Reviewed-on: https://review.coreboot.org/c/coreboot/+/52192 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org> Reviewed-by: Patrick Georgi <pgeorgi@google.com>
* tests/lib/bootmem-test: Add initialization of lb_mem fieldsJakub Czapiga2021-04-131-1/+6
| | | | | | | | | | | | | Add missing initialization of tag and size fields. Include initial size value in assertion in test_bootmem_write_mem_table(). Found-by: Coverity CID 1452250 Signed-off-by: Jakub Czapiga <jacz@semihalf.com> Change-Id: I27678a4eb01a0e6bedd0ba8c4b22a1b01afeaf12 Reviewed-on: https://review.coreboot.org/c/coreboot/+/52263 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Julius Werner <jwerner@chromium.org> Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org>
* 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>
* 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: 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: 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 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>
* 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>