Commit Graph

9 Commits

Author SHA1 Message Date
Julius Werner 1e14de8bda tests: Add some basic warnings and fix resulting issues
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-06-12 19:40:19 +00:00
Patrick Georgi 1b35ec97cc tests: Always run all unit tests
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-28 09:48:13 +00:00
Patrick Georgi a0a198f779 tests: Allow emitting junit output for unit tests
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-28 09:47:44 +00:00
Patrick Georgi a3402973ab tests: Move cmocka binary into $(obj)
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-28 09:47:36 +00:00
Jan Dabros 7f00dba33b tests: Build Cmocka from source
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-26 16:21:06 +00:00
Julius Werner 2540037406 tests: Add region-test for rdev API
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-19 03:22:04 +00:00
Julius Werner 21744811bb tests: Add <tests/test.h> wrapper header and fix --gc-sections
<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-19 03:21:44 +00:00
Patrick Georgi 6b5bc77c9b treewide: Remove "this file is part of" lines
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-11 17:11:40 +00:00
Jan Dabros ef1c968374 tests: Add build subsystem for unit testing coreboot
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>
2020-05-01 06:32:47 +00:00