diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/include/test.h | 18 | ||||
-rw-r--r-- | tests/meson.build | 28 | ||||
-rw-r--r-- | tests/tests.c | 25 | ||||
-rw-r--r-- | tests/tests.h | 4 |
4 files changed, 75 insertions, 0 deletions
diff --git a/tests/include/test.h b/tests/include/test.h new file mode 100644 index 00000000..b4e0dd2b --- /dev/null +++ b/tests/include/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/meson.build b/tests/meson.build new file mode 100644 index 00000000..0c21cb9c --- /dev/null +++ b/tests/meson.build @@ -0,0 +1,28 @@ +root_includes = include_directories('../subprojects') + +srcs = [ + 'tests.c', +] + +mocks = [ + '-Wl,--wrap=physunmap', + '-Wl,--wrap=physmap', + '-Wl,--gc-sections', +] + +flashrom_tests = executable('flashrom_unit_tests', + srcs, + include_directories : root_includes, + c_args : [ + cargs, + '-ffunction-sections', + '-fdata-sections', + # '-DSTANDALONE', + '-DCONFIG_DEFAULT_PROGRAMMER=PROGRAMMER_DUMMY', + '-DCONFIG_DEFAULT_PROGRAMMER_ARGS=""', + ], + export_dynamic : true, + link_args : mocks, + dependencies : [cmocka_dep, flashrom_test_dep], +) +test('cmocka test flashrom', flashrom_tests) diff --git a/tests/tests.c b/tests/tests.c new file mode 100644 index 00000000..32353fa6 --- /dev/null +++ b/tests/tests.c @@ -0,0 +1,25 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* This file is part of the coreboot project. */ + +#include <include/test.h> +#include "tests.h" + +#include <stdio.h> + +/* redefinitions/wrapping */ +void __wrap_physunmap(void *virt_addr, size_t len) +{ + fprintf(stderr, "%s\n", __func__); +} +void *__wrap_physmap(const char *descr, uintptr_t phys_addr, size_t len) +{ + fprintf(stderr, "%s\n", __func__); + return NULL; +} + +int main(void) +{ + int ret = 0; + + return ret; +} diff --git a/tests/tests.h b/tests/tests.h new file mode 100644 index 00000000..b088e24e --- /dev/null +++ b/tests/tests.h @@ -0,0 +1,4 @@ +#ifndef TESTS_H +#define TESTS_H + +#endif /* TESTS_H */ |