Zephyr API Documentation 4.0.0
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
ztest_mock.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2016 Intel Corporation
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
13#ifndef ZEPHYR_TESTSUITE_ZTEST_MOCK_H_
14#define ZEPHYR_TESTSUITE_ZTEST_MOCK_H_
15
36#define ztest_expect_value(func, param, value) \
37 z_ztest_expect_value(STRINGIFY(func), STRINGIFY(param), \
38 (uintptr_t)(value))
39
51#define ztest_check_expected_value(param) \
52 z_ztest_check_expected_value(__func__, STRINGIFY(param), \
53 (uintptr_t)(param))
54
67#define ztest_expect_data(func, param, data) \
68 z_ztest_expect_data(STRINGIFY(func), STRINGIFY(param), (void *)(data))
69
82#define ztest_check_expected_data(param, length) \
83 z_ztest_check_expected_data(__func__, STRINGIFY(param), \
84 (void *)(param), (length))
85
97#define ztest_return_data(func, param, data) \
98 z_ztest_return_data(STRINGIFY(func), STRINGIFY(param), (void *)(data))
99
110#define ztest_copy_return_data(param, length) \
111 z_ztest_copy_return_data(__func__, STRINGIFY(param), \
112 (void *)(param), (length))
119#define ztest_returns_value(func, value) \
120 z_ztest_returns_value(STRINGIFY(func), (uintptr_t)(value))
121
130#define ztest_get_return_value() z_ztest_get_return_value(__func__)
131
140#define ztest_get_return_value_ptr() \
141 ((void *)z_ztest_get_return_value(__func__))
142
147#ifdef CONFIG_ZTEST_MOCKING
148
149#include <zephyr/types.h>
150
151#ifdef __cplusplus
152extern "C" {
153#endif
154
155void z_init_mock(void);
156int z_cleanup_mock(void);
157
158void z_ztest_expect_value(const char *fn, const char *name, uintptr_t value);
159void z_ztest_check_expected_value(const char *fn, const char *param,
160 uintptr_t value);
161
162void z_ztest_expect_data(const char *fn, const char *name, void *val);
163void z_ztest_check_expected_data(const char *fn, const char *name, void *data,
164 uint32_t length);
165
166void z_ztest_return_data(const char *fn, const char *name, void *val);
167void z_ztest_copy_return_data(const char *fn, const char *name, void *data,
168 uint32_t length);
169
170void z_ztest_returns_value(const char *fn, uintptr_t value);
171uintptr_t z_ztest_get_return_value(const char *fn);
172
173#ifdef __cplusplus
174}
175#endif
176
177#else /* !CONFIG_ZTEST_MOCKING */
178
179#define z_init_mock()
180#define z_cleanup_mock() 0
181
182#endif /* CONFIG_ZTEST_MOCKING */
183
184#endif /* ZEPHYR_TESTSUITE_ZTEST_MOCK_H_ */
__UINT32_TYPE__ uint32_t
Definition stdint.h:90
__UINTPTR_TYPE__ uintptr_t
Definition stdint.h:105