summaryrefslogtreecommitdiff
path: root/tests
AgeCommit message (Collapse)Author
2021-01-08tests: Add lib/fmap-test test caseJakub Czapiga
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>
2020-12-02edist-test: Fix _Static_assert missing message stringDaniel Gröber
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-11-25tests: Add lib/list-test test caseJakub Czapiga
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-22tests: Add lib/cbmem_console-test test caseJakub Czapiga
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>
2020-11-10tests: Add lib/edid-test test caseJakub Czapiga
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>
2020-11-09tests: Add lib/timestamp-test test caseJakub Czapiga
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>
2020-10-26tests: Add lib/imd-test test caseJakub Czapiga
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>
2020-10-26tests: Add test region and symbol macros to <tests/test.h>Jakub Czapiga
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>
2020-09-16device/dram: Add method for converting MHz to MT/sRob Barnes
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>
2020-07-12tests: Improve test_skip_atoi() in /lib/string-test test caseAnna Karas
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>
2020-07-12tests: Move the console stubs to a dedicated directoryAnna Karas
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>
2020-07-07tests: Add lib/hexstrtobin-test test caseAnna Karas
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>
2020-07-06tests: Add lib/b64_decode-test test caseAnna Karas
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>
2020-07-06tests: Complete lib/string-test test caseAnna Karas
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>
2020-07-01tests/lib/Makefile.inc: remove a commentAnna Karas
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>
2020-06-12tests: Add some basic warnings and fix resulting issuesJulius Werner
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>
2020-05-28tests: Always run all unit testsPatrick Georgi
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>
2020-05-28tests: Allow emitting junit output for unit testsPatrick Georgi
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>
2020-05-28tests: Move cmocka binary into $(obj)Patrick Georgi
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>
2020-05-28Remove new additions of "this file is part of" linesElyes HAOUAS
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>
2020-05-26tests: Build Cmocka from sourceJan Dabros
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>
2020-05-19tests: Add region-test for rdev APIJulius Werner
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>
2020-05-19tests: Add <tests/test.h> wrapper header and fix --gc-sectionsJulius Werner
<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>
2020-05-11treewide: Remove "this file is part of" linesPatrick Georgi
Stefan thinks they don't add value. Command used: sed -i -e '/file is part of /d' $(git grep "file is part of " |egrep ":( */\*.*\*/\$|#|;#|-- | *\* )" | cut -d: -f1 |grep -v crossgcc |grep -v gcov | grep -v /elf.h |grep -v nvramtool) The exceptions are for: - crossgcc (patch file) - gcov (imported from gcc) - elf.h (imported from GNU's libc) - nvramtool (more complicated header) The removed lines are: - fmt.Fprintln(f, "/* This file is part of the coreboot project. */") -# This file is part of a set of unofficial pre-commit hooks available -/* This file is part of coreboot */ -# This file is part of msrtool. -/* This file is part of msrtool. */ - * This file is part of ncurses, designed to be appended after curses.h.in -/* This file is part of pgtblgen. */ - * This file is part of the coreboot project. - /* This file is part of the coreboot project. */ -# This file is part of the coreboot project. -# This file is part of the coreboot project. -## This file is part of the coreboot project. --- This file is part of the coreboot project. -/* This file is part of the coreboot project */ -/* This file is part of the coreboot project. */ -;## This file is part of the coreboot project. -# This file is part of the coreboot project. It originated in the - * This file is part of the coreinfo project. -## This file is part of the coreinfo project. - * This file is part of the depthcharge project. -/* This file is part of the depthcharge project. */ -/* This file is part of the ectool project. */ - * This file is part of the GNU C Library. - * This file is part of the libpayload project. -## This file is part of the libpayload project. -/* This file is part of the Linux kernel. */ -## This file is part of the superiotool project. -/* This file is part of the superiotool project */ -/* This file is part of uio_usbdebug */ Change-Id: I82d872b3b337388c93d5f5bf704e9ee9e53ab3a9 Signed-off-by: Patrick Georgi <pgeorgi@google.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/41194 Reviewed-by: HAOUAS Elyes <ehaouas@noos.fr> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2020-05-08tests: Add proper license headersJan Dabros
Signed-off-by: Jan Dabros <jsd@semihalf.com> Change-Id: Id8ca7c53122632c674e6bf952046ea22c0408e55 Reviewed-on: https://review.coreboot.org/c/coreboot/+/41088 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
2020-05-01tests: Add device/i2c-test test caseJan Dabros
Add unit test for src/device/i2c.c module. This patch is also used as an example for incorporating Cmocka mocking feature (-wrap linker flag). Signed-off-by: Jan Dabros <jsd@semihalf.com> Change-Id: I2eeb565aacc724ae3b9f5c76ef4b98ef695416d6 Reviewed-on: https://review.coreboot.org/c/coreboot/+/40539 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Julius Werner <jwerner@chromium.org> Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org>
2020-05-01tests: Add lib/string-test test caseJan Dabros
Show a basic example of how unit testing can be applied for the coreboot project. Add a test harness for lib/string.c module. TEST=Install cmocka via appropriate command: sudo apt-get install -y libcmocka-dev sudo emerge dev-util/cmocka yum install libcmocka-devel * Build and run unit tests via `make unit-tests` * Check the output to see that tests passed. Signed-off-by: Jan Dabros <jsd@semihalf.com> Change-Id: Ibf5554d1e99a393721a66bdd35af0122c2e412c4 Reviewed-on: https://review.coreboot.org/c/coreboot/+/40538 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Julius Werner <jwerner@chromium.org> Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org>
2020-05-01tests: Add build subsystem for unit testing corebootJan Dabros
Add a subsystem which will be used for writing, building and running unit tests for different coreboot's modules. This work is built using Cmocka unit testing framework. Description of what unit testing means (for the author) and how unit testing framework evaluation was performed may be found in Documentation/technotes/2020-03-unit-testing-coreboot.md Makefiles structure is very similar to this used for building coreboot images. Every directory has its own Makefile.inc were tests' names, sources, subdirs and multiple other test-related attributes are defined in form of variables. Signed-off-by: Jan Dabros <jsd@semihalf.com> Change-Id: I9b0220b84b9a6e448476ca3eb3ccccc5fb829ad1 Reviewed-on: https://review.coreboot.org/c/coreboot/+/39894 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org>