Commit Graph

75 Commits

Author SHA1 Message Date
Jakub Czapiga ab0bcaf732 src/console/init.c: Make get_log_level static inline again
CB:55356 removed static inline declarations from get_log_level(). This
commit puts them back. It also changes the method of accessing static
symbols in tests/console/routing-test to source file inclusion like
in CB:46458 to avoid changing tested source file.

Signed-off-by: Jakub Czapiga <jacz@semihalf.com>
Change-Id: Iaa5dcbccb327f819374967be51ef642b1fb25e7b
Reviewed-on: https://review.coreboot.org/c/coreboot/+/55473
Reviewed-by: Patrick Georgi <pgeorgi@google.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2021-06-15 16:12:52 +00:00
Patrick Georgi ae41dd3344 tests/console: Add tests for log message routing behavior
Change-Id: Id978cfe4fa45fef9edbc3d3b55606ff6973521c5
Signed-off-by: Patrick Georgi <pgeorgi@google.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/55356
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Jakub Czapiga <jacz@semihalf.com>
2021-06-10 19:27:44 +00:00
Patrick Georgi ce55ca2fca tests: Rework mocking facility
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>
2021-06-10 19:26:46 +00:00
Jakub Czapiga db4b21a1d0 tests: Add lib/cbmem_stage_cache-test test case
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>
2021-06-01 16:10:42 +00:00
Jakub Czapiga 203698a4cb tests/Makefile.inc: Move generated headers to corresponding build dir
Test-local config override headers were generated to paths missing
/tests/ infix, thus creating divergent tree in build output directory.
This patch fixes it moving generated config headers to the test-local
build directory.

Signed-off-by: Jakub Czapiga <jacz@semihalf.com>
Change-Id: Ic5f3ba287ba3e9f5897cbaac64e88c2809f52d73
Reviewed-on: https://review.coreboot.org/c/coreboot/+/54917
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org>
2021-05-30 20:28:30 +00:00
Jakub Czapiga 5ab67f9ef8 tests/lib/memset-test: Add missing malloc check and free on error
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>
2021-05-26 12:33:25 +00:00
Paul Fagerburg de6cbac3c4 tests: improve code coverage support
Fix the exclusion path for lcov; it should exclude the directory
with source code, not object files.

Use the COV environment variable to
* control whether we build for coverage or not
* select the output directory

Add a separate target for generating the report, so we can get a
report for all of the tests together or just a single test.

Add documentation.

Signed-off-by: Paul Fagerburg <pfagerburg@google.com>
Change-Id: I2bd2bfdedfab291aabeaa968c10b17e9b61c9c0a
Reviewed-on: https://review.coreboot.org/c/coreboot/+/54072
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Jakub Czapiga <jacz@semihalf.com>
2021-05-19 19:56:02 +00:00
Jakub Czapiga d5433afb28 tests/lib/spd_cache-test: Initialize spd_block.addr_map
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>
2021-05-18 10:08:39 +00:00
Jakub Czapiga 2b8d7216ef tests: Add lib/spd_cache-test test case
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>
2021-05-14 08:59:29 +00:00
Jakub Czapiga 5c3b05ecf4 tests: Enable config override for tests
Some tests require to change kconfig symbols values to cover the code.
This patch enables one to set these vaues using <test-name>-config
variable.

Example for integer values.
timestamp-test-config += CONFIG_HAVE_MONOTONIC_TIMER=1

Example for string values. Notice escaped quotes.
spd_cache-test-config += CONFIG_SPD_CACHE_FMAP_NAME=\"SPD_CACHE_FMAP_NAME\"

Signed-off-by: Jakub Czapiga <jacz@semihalf.com>
Change-Id: I1aeb78362c2609fbefbfd91c0f58ec19ed258ee1
Reviewed-on: https://review.coreboot.org/c/coreboot/+/52937
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org>
Reviewed-by: Julius Werner <jwerner@chromium.org>
2021-05-13 00:15:54 +00:00
Jakub Czapiga ce38084db6 tests/lib/crc_byte-test: Fix incorrect variable types
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>
2021-05-05 11:45:45 +00:00
Paul Fagerburg 045fbf138a tests: enable code coverage for unit tests
Add a new `coverage-unit-tests` make target that builds the unit
tests for code coverage, runs the tests, and generates a coverage
report.

Signed-off-by: Paul Fagerburg <pfagerburg@google.com>
Change-Id: I6ea780ee9e246c0bb8c35b8e0de4252431dabbff
Reviewed-on: https://review.coreboot.org/c/coreboot/+/52444
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Jakub Czapiga <jacz@semihalf.com>
2021-05-05 11:45:19 +00:00
Raul E Rangel 66e35fb341 Makefile,tests: Move cmocka checkout into top level Makefile
cmocka is currently ignoring the UPDATED_SUBMODULES flag. Move the
cmocka checkout with the other submodule checkouts.

BUG=none
TEST=Make sure cmocka is not checked out if UPDATED_SUBMODULES=1

Signed-off-by: Raul E Rangel <rrangel@chromium.org>
Change-Id: I2a1db809368a77d2c0f9c9a796d62555ec476dc7
Reviewed-on: https://review.coreboot.org/c/coreboot/+/52578
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Jakub Czapiga <jacz@semihalf.com>
2021-04-30 12:43:44 +00:00
Jakub Czapiga a37c8021a6 tests: Add lib/rtc-test test case
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>
2021-04-21 09:18:56 +00:00
Julius Werner c893197352 commonlib/region: Turn addrspace_32bit into a more official API
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>
2021-04-21 02:06:26 +00:00
Jakub Czapiga 5d884837f4 tests: Add lib/coreboot_table-test test case
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>
2021-04-18 20:43:05 +00:00
Jakub Czapiga a4819b3c31 Makefile: Add unit-tests help and targets list
Add unit-tests targets to help output. Add list-unit-tests target
that lists all available unit-tests.

Signed-off-by: Jakub Czapiga <jacz@semihalf.com>
Change-Id: I464a76cbea1f4afbc3fc772960787952e61b95b9
Reviewed-on: https://review.coreboot.org/c/coreboot/+/52293
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Patrick Georgi <pgeorgi@google.com>
Reviewed-by: Julius Werner <jwerner@chromium.org>
2021-04-15 07:38:48 +00:00
Jakub Czapiga dadcae63c6 tests: Add lib/dimm_info_util-test test case
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>
2021-04-15 07:38:05 +00:00
Nico Huber 7cc14ac25d Rename do_printk() to printk()
The indirection seems unnecessary. The macros throw features like
`-Wmisleading-indentation` off, though.

Default build for QEMU/Q35 is unchanged.

Change-Id: Ie4eab935a367b5ad6b38225c4973d41d9f70ef10
Signed-off-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/51887
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
2021-04-14 10:38:09 +00:00
Jakub Czapiga ec8eef0a6b tests/lib/bootmem-test: Add initialization of lb_mem fields
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>
2021-04-13 16:03:27 +00:00
Jakub Czapiga 13145e5d18 tests/lib/malloc-test: Fix possible memory overrun
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>
2021-04-11 21:05:25 +00:00
Jan Dabros 935769398a tests: Add lib/bootmem-test test case
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>
2021-04-09 06:20:50 +00:00
Jakub Czapiga 45d37d5cb8 include/assert.h: Use mock_assert() for ENV_TEST targets
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>
2021-04-09 06:20:04 +00:00
Jakub Czapiga 084ad93663 include/rules.h: Add ENV_TEST definition
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>
2021-04-06 06:58:05 +00:00
Jakub Czapiga f5c0021e05 tests: Add lib/uuid-test test case
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>
2021-04-06 06:56:47 +00:00
Tim Wawrzynczak c556dffe98 lib: Add obvious definition for `calloc`
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>
2021-04-06 06:50:38 +00:00
Jakub Czapiga caebcb7014 tests/include/tests/test.h: Add TEST_REGION_UNALLOCATED
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>
2021-03-28 16:00:01 +00:00
Julius Werner d4863a5ca0 tests: memset-test: Parenthesize zero size argument for clang
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>
2021-03-18 15:02:13 +00:00
Jan Dabros 9e16ca9dec tests: Add lib/memrange-test test case
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>
2021-03-15 06:10:24 +00:00
Jakub Czapiga 1add483819 tests/Makefile.inc: Enable support for multiple test groups
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>
2021-03-10 20:23:19 +00:00
Jakub Czapiga 9f13cb72c5 tests: Add lib/compute_ip_checksum-test test case
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>
2021-03-02 17:04:44 +00:00
Jakub Czapiga 0b6b968f9e tests: Add lib/crc_byte-test test case
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>
2021-03-02 17:04:28 +00:00
Jakub Czapiga f5e636ccdb tests: Add lib/memmove-test test case
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>
2021-03-01 08:31:11 +00:00
Jakub Czapiga 68220b5c42 tests/lib/memchr-test: Fix possible memory overrun, add non-null checks
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>
2021-02-26 07:30:00 +00:00
Jakub Czapiga 7a18721cc7 tests: Add lib/malloc-test test case
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>
2021-02-26 07:29:57 +00:00
Jakub Czapiga eb4bb6f563 tests: Add lib/memcpy-test test case
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>
2021-02-23 17:12:52 +00:00
Jakub Czapiga 168b38bbb3 tests: Add acpi/acpigen-test test case
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>
2021-02-23 17:10:10 +00:00
Jakub Czapiga cc7acb82c0 tests: Add lib/memchr-test test case
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>
2021-02-22 07:31:06 +00:00
Julius Werner 82d16b150c memlayout: Store region sizes as separate symbols
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>
2021-02-19 08:39:26 +00:00
Jakub Czapiga c4ca8c3556 tests: Add lib/memcmp-test test case
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>
2021-02-18 19:12:46 +00:00
Jakub Czapiga 7a940dfb22 tests: Add lib/memset-test test case
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>
2021-02-18 10:14:21 +00:00
Julius Werner 84446e6e54 rmodtool: Make memlayout symbols absolute and do not relocate them
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>
2021-02-18 02:32:06 +00:00
Julius Werner e54d784d02 tests: Build tests with -Wno-inline-asm
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>
2021-02-17 23:10:15 +00:00
Jakub Czapiga b3a7c84b43 tests: Add lib/stack-test test case
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>
2021-02-12 07:48:24 +00:00
Jakub Czapiga eb6f80d049 tests: Add lib/region_file-test test case
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>
2021-02-02 18:05:26 +00:00
Jakub Czapiga a2b21c23d5 tests: Add lib/imd_cbmem-test test case
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>
2021-01-18 07:27:16 +00:00
Furquan Shaikh 28e61f1634 device: Use __pci_0_00_0_config in config_of_soc()
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>
2021-01-12 05:22:40 +00:00
Jakub Czapiga dd85c82962 tests: Add lib/fmap-test test case
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>
2021-01-08 08:26:26 +00:00
Daniel Gröber 2aa15872d2 edist-test: Fix _Static_assert missing message string
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>
2020-12-02 10:38:25 +00:00
Jakub Czapiga ea378ccc8f tests: Add lib/list-test test case
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>
2020-11-25 09:14:07 +00:00