Zephyr API Documentation  2.7.0-rc2
A Scalable Open Source RTOS
ztest_test.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_TEST_H_
14#define ZEPHYR_TESTSUITE_ZTEST_TEST_H_
15
17
18#ifdef __cplusplus
19extern "C" {
20#endif
21
22struct unit_test {
23 const char *name;
28};
29
30void z_ztest_run_test_suite(const char *name, struct unit_test *suite);
31
48void ztest_test_fail(void);
49
58void ztest_test_pass(void);
59
64void ztest_test_skip(void);
65
73static inline void unit_test_noop(void)
74{
75}
76
88#define ztest_unit_test_setup_teardown(fn, setup, teardown) { \
89 STRINGIFY(fn), fn, setup, teardown, 0 \
90}
91
105#define ztest_user_unit_test_setup_teardown(fn, setup, teardown) { \
106 STRINGIFY(fn), fn, setup, teardown, K_USER \
107}
108
117#define ztest_unit_test(fn) \
118 ztest_unit_test_setup_teardown(fn, unit_test_noop, unit_test_noop)
119
130#define ztest_user_unit_test(fn) \
131 ztest_user_unit_test_setup_teardown(fn, unit_test_noop, unit_test_noop)
132
133__syscall void z_test_1cpu_start(void);
134__syscall void z_test_1cpu_stop(void);
135
144#ifdef CONFIG_SMP
145#define ztest_1cpu_unit_test(fn) \
146 ztest_unit_test_setup_teardown(fn, z_test_1cpu_start, z_test_1cpu_stop)
147#else
148#define ztest_1cpu_unit_test(fn) ztest_unit_test(fn)
149#endif
150
159#ifdef CONFIG_SMP
160#define ztest_1cpu_user_unit_test(fn) \
161 ztest_user_unit_test_setup_teardown(fn, z_test_1cpu_start, z_test_1cpu_stop)
162#else
163#define ztest_1cpu_user_unit_test(fn) ztest_user_unit_test(fn)
164#endif
165
166/* definitions for use with testing application shared memory */
167#ifdef CONFIG_USERSPACE
168#define ZTEST_DMEM K_APP_DMEM(ztest_mem_partition)
169#define ZTEST_BMEM K_APP_BMEM(ztest_mem_partition)
170#define ZTEST_SECTION K_APP_DMEM_SECTION(ztest_mem_partition)
172#else
173#define ZTEST_DMEM
174#define ZTEST_BMEM
175#define ZTEST_SECTION .data
176#endif
177
193#define ztest_test_suite(suite, ...) \
194 static ZTEST_DMEM struct unit_test _##suite[] = { \
195 __VA_ARGS__, { 0 } \
196 }
202#define ztest_run_test_suite(suite) \
203 z_ztest_run_test_suite(#suite, _##suite)
204
208#ifndef ZTEST_UNITTEST
209#include <syscalls/ztest_test.h>
210#endif
211
212#ifdef __cplusplus
213}
214#endif
215
216#endif /* ZEPHYR_TESTSUITE_ZTEST_TEST_H_ */
void
Definition: eswifi_shell.c:15
void ztest_test_pass(void)
Pass the currently running test.
struct k_mem_partition ztest_mem_partition
void ztest_test_fail(void)
Fail the currently running test.
void ztest_test_skip(void)
Skip the current test.
static void unit_test_noop(void)
Do nothing, successfully.
Definition: ztest_test.h:73
__UINT32_TYPE__ uint32_t
Definition: stdint.h:60
Memory Partition.
Definition: mem_domain.h:55
Definition: ztest_test.h:22
void(* setup)(void)
Definition: ztest_test.h:25
void(* teardown)(void)
Definition: ztest_test.h:26
uint32_t thread_options
Definition: ztest_test.h:27
void(* test)(void)
Definition: ztest_test.h:24
const char * name
Definition: ztest_test.h:23