From 1e14de8bda93fda4c0ace8b6421d67e8605758bb Mon Sep 17 00:00:00 2001 From: Julius Werner Date: Wed, 10 Jun 2020 15:35:08 -0700 Subject: 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 Change-Id: I4d9801f52a8551f55f419f4141dc21ccb835d676 Reviewed-on: https://review.coreboot.org/c/coreboot/+/42259 Tested-by: build bot (Jenkins) Reviewed-by: Jan Dabros Reviewed-by: Paul Fagerburg --- tests/commonlib/region-test.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'tests/commonlib') diff --git a/tests/commonlib/region-test.c b/tests/commonlib/region-test.c index 219ed31f79..545463e1dd 100644 --- a/tests/commonlib/region-test.c +++ b/tests/commonlib/region-test.c @@ -69,6 +69,8 @@ static ssize_t mock_readat(const struct region_device *rdev, void *buffer, ssize_t ret = mock(); if (!ret) return size; + else + return ret; } static ssize_t mock_writeat(const struct region_device *rdev, const void *buffer, @@ -82,6 +84,8 @@ static ssize_t mock_writeat(const struct region_device *rdev, const void *buffer ssize_t ret = mock(); if (!ret) return size; + else + return ret; } static ssize_t mock_eraseat(const struct region_device *rdev, size_t offset, size_t size) @@ -93,6 +97,8 @@ static ssize_t mock_eraseat(const struct region_device *rdev, size_t offset, siz ssize_t ret = mock(); if (!ret) return size; + else + return ret; } struct region_device_ops mock_rdev_ops = { @@ -155,8 +161,6 @@ static void rdev_mock_defaults(void) static void test_rdev_success(void **state) { - struct region_device child; - expect_value(mock_mmap, size, region_device_sz(&mock_rdev)); rdev_mock_defaults(); -- cgit v1.2.3