zephyr/modules/fff/include/c_test_framework.h
Yuval Peress f6f24a2a79 modules: Add fff mocking framework
Issue #38643

Introduce a more powerful and well established mocking framework
into Zephyr. It also allows running the actual FFF tests using the
zephyr SDK and ztest framework to ensure compatibility.

As per TSC meeting, the fff.h header was directly added to
subsys/testsuite/include/. As per the guidelines, the file is exactly
the same as it is in FFF's library, but re-styled with clang-format.

The west.yml entry was added using the "ci" group and filtered by
default. (note that the tests will break until the CI actually
specifies that the group is needed).

Signed-off-by: Yuval Peress <peress@google.com>
2021-10-22 09:43:13 -04:00

27 lines
1.1 KiB
C

/* Copyright (c) 2021 Google LLC
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef MODULES_FFF_TEST_INCLUDE_C_TEST_FRAMEWORK_H_
#define MODULES_FFF_TEST_INCLUDE_C_TEST_FRAMEWORK_H_
#include <ztest.h>
#include <sys/printk.h>
void setup(void);
void fff_test_suite(void);
#define PRINTF(FMT, args...)
#define TEST_F(SUITE, NAME) __attribute__((unused)) static void test_##NAME(void)
#define RUN_TEST(SUITE, NAME) \
do { \
ztest_test_suite( \
SUITE##_##NAME, \
ztest_unit_test_setup_teardown(test_##NAME, setup, unit_test_noop)); \
ztest_run_test_suite(SUITE##_##NAME); \
} while (0)
#define ASSERT_EQ(A, B) zassert_equal((A), (B), NULL)
#define ASSERT_TRUE(A) zassert_true((A), NULL)
#endif /* MODULES_FFF_TEST_INCLUDE_C_TEST_FRAMEWORK_H_ */