DPDK
22.11.7
lib
eal
include
rte_test.h
1
/* SPDX-License-Identifier: BSD-3-Clause
2
* Copyright(c) 2015 Cavium, Inc
3
*/
4
5
#ifndef _RTE_TEST_H_
6
#define _RTE_TEST_H_
7
8
#include <
rte_log.h
>
9
10
/* Before including rte_test.h file you can define
11
* RTE_TEST_TRACE_FAILURE(_file, _line, _func) macro to better trace/debug test
12
* failures. Mostly useful in development phase.
13
*/
14
#ifndef RTE_TEST_TRACE_FAILURE
15
#define RTE_TEST_TRACE_FAILURE(_file, _line, _func)
16
#endif
17
18
19
#define RTE_TEST_ASSERT(cond, msg, ...) do { \
20
if (!(cond)) { \
21
RTE_LOG(ERR, EAL, "Test assert %s line %d failed: "
\
22
msg "\n", __func__, __LINE__, ##__VA_ARGS__); \
23
RTE_TEST_TRACE_FAILURE(__FILE__, __LINE__, __func__); \
24
return -1; \
25
} \
26
} while (0)
27
28
#define RTE_TEST_ASSERT_EQUAL(a, b, msg, ...) \
29
RTE_TEST_ASSERT(a == b, msg, ##__VA_ARGS__)
30
31
#define RTE_TEST_ASSERT_NOT_EQUAL(a, b, msg, ...) \
32
RTE_TEST_ASSERT(a != b, msg, ##__VA_ARGS__)
33
34
#define RTE_TEST_ASSERT_SUCCESS(val, msg, ...) \
35
RTE_TEST_ASSERT(val == 0, msg, ##__VA_ARGS__)
36
37
#define RTE_TEST_ASSERT_FAIL(val, msg, ...) \
38
RTE_TEST_ASSERT(val != 0, msg, ##__VA_ARGS__)
39
40
#define RTE_TEST_ASSERT_NULL(val, msg, ...) \
41
RTE_TEST_ASSERT(val == NULL, msg, ##__VA_ARGS__)
42
43
#define RTE_TEST_ASSERT_NOT_NULL(val, msg, ...) \
44
RTE_TEST_ASSERT(val != NULL, msg, ##__VA_ARGS__)
45
46
#endif
/* _RTE_TEST_H_ */
rte_log.h
Generated by
1.9.4