summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.inc13
-rw-r--r--tests/device/i2c-test.c8
-rw-r--r--tests/include/tests/test.h18
-rw-r--r--tests/lib/string-test.c6
4 files changed, 28 insertions, 17 deletions
diff --git a/tests/Makefile.inc b/tests/Makefile.inc
index debb2f9868..9ee27cd831 100644
--- a/tests/Makefile.inc
+++ b/tests/Makefile.inc
@@ -1,5 +1,6 @@
# SPDX-License-Identifier: GPL-2.0-only
+testsrc = $(top)/tests
testobj = $(obj)/tests
TEST_DEFAULT_CONFIG = $(top)/configs/config.emulation_qemu_x86_i440fx
@@ -10,12 +11,12 @@ TEST_KCONFIG_DEPENDENCIES := $(testobj)/auto.conf.cmd
TEST_KCONFIG_SPLITCONFIG := $(testobj)/config
TEST_KCONFIG_TRISTATE := $(testobj)/tristate.conf
-TEST_CFLAGS = -include$(src)/include/kconfig.h \
- -include$(src)/commonlib/bsd/include/commonlib/bsd/compiler.h \
- -include $(src)/include/rules.h \
+TEST_CFLAGS = -include $(src)/include/kconfig.h \
+ -include $(src)/commonlib/bsd/include/commonlib/bsd/compiler.h \
+ -include $(src)/include/rules.h
# Include generic test mock headers, before original ones
-TEST_CFLAGS += -Itests/include/mocks
+TEST_CFLAGS += -I$(testsrc)/include/mocks -I$(testsrc)/include
TEST_CFLAGS += -I$(src)/include -I$(src)/commonlib/include \
-I$(src)/commonlib/bsd/include -I$(src)/arch/x86/include \
@@ -24,10 +25,10 @@ TEST_CFLAGS += -I$(src)/include -I$(src)/commonlib/include \
TEST_CFLAGS += -I$(dir $(TEST_KCONFIG_AUTOHEADER))
TEST_CFLAGS += -std=gnu11 -Os -ffunction-sections -fdata-sections \
- -Wl,--gc-sections -fno-builtin
+ -fno-builtin
# Link against Cmocka
-TEST_LDFLAGS = -lcmocka
+TEST_LDFLAGS = -lcmocka -Wl,--gc-sections
# Extra attributes for unit tests, declared per test
attributes:= srcs cflags mocks stage
diff --git a/tests/device/i2c-test.c b/tests/device/i2c-test.c
index 9303456261..acf7b0741d 100644
--- a/tests/device/i2c-test.c
+++ b/tests/device/i2c-test.c
@@ -1,12 +1,8 @@
/* SPDX-License-Identifier: GPL-2.0-only */
-#include <stdarg.h>
-#include <stddef.h>
-#include <setjmp.h>
-#include <limits.h>
-#include <cmocka.h>
-
#include <device/i2c_simple.h>
+#include <limits.h>
+#include <tests/test.h>
/* Simulate two i2c devices, both on bus 0, each with three uint8_t regs
implemented. */
diff --git a/tests/include/tests/test.h b/tests/include/tests/test.h
new file mode 100644
index 0000000000..b4e0dd2b5e
--- /dev/null
+++ b/tests/include/tests/test.h
@@ -0,0 +1,18 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/* This file is part of the coreboot project. */
+
+#ifndef _TESTS_TEST_H
+#define _TESTS_TEST_H
+
+/*
+ * Standard test header that should be included in all tests. For now it just encapsulates the
+ * include dependencies for Cmocka. Test-specific APIs that are so generic we would want them
+ * available everywhere could also be added here.
+ */
+
+#include <stdarg.h>
+#include <stddef.h>
+#include <setjmp.h>
+#include <cmocka.h>
+
+#endif /* _TESTS_TEST_H */
diff --git a/tests/lib/string-test.c b/tests/lib/string-test.c
index 513b395283..08f4177ef6 100644
--- a/tests/lib/string-test.c
+++ b/tests/lib/string-test.c
@@ -1,11 +1,7 @@
/* SPDX-License-Identifier: GPL-2.0-only */
-#include <stdarg.h>
-#include <stddef.h>
-#include <setjmp.h>
-#include <cmocka.h>
-
#include <string.h>
+#include <tests/test.h>
/*
* Important note: In every particular test, don't use any string-related