Zephyr API Documentation  3.5.0
A Scalable Open Source RTOS
3.5.0
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
ztest_test_deprecated.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#include <zephyr/init.h>
19#include <stdbool.h>
20
21#ifdef __cplusplus
22extern "C" {
23#endif
24
25struct unit_test {
26 const char *name;
27 void (*test)(void);
28 void (*setup)(void);
29 void (*teardown)(void);
31};
32
43};
44
51 const char *name;
61 bool (*predicate)(const void *state);
64};
65
66extern struct ztest_suite_node _ztest_suite_node_list_start[];
67extern struct ztest_suite_node _ztest_suite_node_list_end[];
68
80#define ztest_register_test_suite(SUITE_NAME, PREDICATE, args...) \
81 ztest_test_suite(SUITE_NAME, ##args); \
82 struct ztest_suite_stats UTIL_CAT(z_ztest_test_node_stats_, SUITE_NAME); \
83 static STRUCT_SECTION_ITERABLE(ztest_suite_node, z_ztest_test_node_##SUITE_NAME) = { \
84 .name = #SUITE_NAME, \
85 .suite = _##SUITE_NAME, \
86 .predicate = PREDICATE, \
87 .stats = &UTIL_CAT(z_ztest_test_node_stats_, SUITE_NAME), \
88 };
89
96__deprecated
98
108__deprecated
110
121int z_ztest_run_test_suite(const char *name, struct unit_test *suite);
122
140
150
155
163static inline void unit_test_noop(void)
164{
165}
166
177#define ztest_unit_test_setup_teardown(fn, setup, teardown) \
178 { \
179 STRINGIFY(fn), fn, setup, teardown, 0 \
180 }
181
194#define ztest_user_unit_test_setup_teardown(fn, setup, teardown) \
195 { \
196 STRINGIFY(fn), fn, setup, teardown, K_USER \
197 }
198
206#define ztest_unit_test(fn) \
207 ztest_unit_test_setup_teardown(fn, unit_test_noop, unit_test_noop)
208
218#define ztest_user_unit_test(fn) \
219 ztest_user_unit_test_setup_teardown(fn, unit_test_noop, unit_test_noop)
220
229#ifdef CONFIG_SMP
230#define ztest_1cpu_unit_test(fn) \
231 ztest_unit_test_setup_teardown(fn, z_test_1cpu_start, z_test_1cpu_stop)
232#else
233#define ztest_1cpu_unit_test(fn) ztest_unit_test(fn)
234#endif
235
244#ifdef CONFIG_SMP
245#define ztest_1cpu_user_unit_test(fn) \
246 ztest_user_unit_test_setup_teardown(fn, z_test_1cpu_start, z_test_1cpu_stop)
247#else
248#define ztest_1cpu_user_unit_test(fn) ztest_user_unit_test(fn)
249#endif
250
251/* definitions for use with testing application shared memory */
252#ifdef CONFIG_USERSPACE
253#define ZTEST_DMEM K_APP_DMEM(ztest_mem_partition)
254#define ZTEST_BMEM K_APP_BMEM(ztest_mem_partition)
255#define ZTEST_SECTION K_APP_DMEM_SECTION(ztest_mem_partition)
257#else
258#define ZTEST_DMEM
259#define ZTEST_BMEM
260#define ZTEST_SECTION .data
261#endif
262
278#define ztest_test_suite(suite, ...) __DEPRECATED_MACRO \
279 static ZTEST_DMEM struct unit_test _##suite[] = { __VA_ARGS__, { 0 } }
285#define ztest_run_test_suite(suite) __DEPRECATED_MACRO \
286 z_ztest_run_test_suite(#suite, _##suite)
287
292#ifdef __cplusplus
293}
294#endif
295
296#endif /* ZEPHYR_TESTSUITE_ZTEST_TEST_H_ */
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_deprecated.h:163
state
Definition: parser_state.h:29
#define bool
Definition: stdbool.h:13
__UINT32_TYPE__ uint32_t
Definition: stdint.h:90
Memory Partition.
Definition: mem_domain.h:55
Definition: ztest_test_deprecated.h:25
void(* setup)(void)
Definition: ztest_test_deprecated.h:28
void(* teardown)(void)
Definition: ztest_test_deprecated.h:29
uint32_t thread_options
Definition: ztest_test_deprecated.h:30
void(* test)(void)
Definition: ztest_test_deprecated.h:27
const char * name
Definition: ztest_test_deprecated.h:26
A single node of test suite.
Definition: ztest_test_deprecated.h:49
struct unit_test * suite
Pointer to the test suite.
Definition: ztest_test_deprecated.h:53
const char * name
The name of the test suite.
Definition: ztest_test_deprecated.h:51
struct ztest_suite_stats * stats
Stats.
Definition: ztest_test_deprecated.h:63
bool(* predicate)(const void *state)
An optional predicate function to determine if the test should run.
Definition: ztest_test_deprecated.h:61
Stats about a ztest suite.
Definition: ztest_test_deprecated.h:36
uint32_t skip_count
The number of times that the suite was skipped.
Definition: ztest_test_deprecated.h:40
uint32_t fail_count
The number of times that the suite failed.
Definition: ztest_test_deprecated.h:42
uint32_t run_count
The number of times that the suite ran.
Definition: ztest_test_deprecated.h:38
int ztest_run_registered_test_suites(const void *state)
Run the registered unit tests which return true from their pragma function.
void ztest_verify_all_registered_test_suites_ran(void)
Fails the test if any of the registered tests did not run.