1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(C) 2020 Marvell International Ltd.
5 #include <rte_eal_trace.h>
10 #include "test_trace.h"
13 test_trace_point_globbing(void)
17 rc = rte_trace_pattern("app.dpdk.test*", false);
21 if (rte_trace_point_is_enabled(&__app_dpdk_test_tp))
24 rc = rte_trace_pattern("app.dpdk.test*", true);
28 if (!rte_trace_point_is_enabled(&__app_dpdk_test_tp))
31 rc = rte_trace_pattern("invalid_testpoint.*", true);
42 test_trace_point_regex(void)
46 rc = rte_trace_regexp("app.dpdk.test*", false);
50 if (rte_trace_point_is_enabled(&__app_dpdk_test_tp))
53 rc = rte_trace_regexp("app.dpdk.test*", true);
57 if (!rte_trace_point_is_enabled(&__app_dpdk_test_tp))
60 rc = rte_trace_regexp("invalid_testpoint.*", true);
71 test_trace_point_disable_enable(void)
75 rc = rte_trace_point_disable(&__app_dpdk_test_tp);
79 if (rte_trace_point_is_enabled(&__app_dpdk_test_tp))
82 rc = rte_trace_point_enable(&__app_dpdk_test_tp);
86 if (!rte_trace_point_is_enabled(&__app_dpdk_test_tp))
90 app_dpdk_test_tp("app.dpdk.test.tp");
100 enum rte_trace_mode current;
102 current = rte_trace_mode_get();
104 if (!rte_trace_is_enabled())
107 rte_trace_mode_set(RTE_TRACE_MODE_DISCARD);
108 if (rte_trace_mode_get() != RTE_TRACE_MODE_DISCARD)
111 rte_trace_mode_set(RTE_TRACE_MODE_OVERWRITE);
112 if (rte_trace_mode_get() != RTE_TRACE_MODE_OVERWRITE)
115 rte_trace_mode_set(current);
124 test_trace_points_lookup(void)
126 rte_trace_point_t *trace;
128 trace = rte_trace_point_lookup("app.dpdk.test.tp");
131 trace = rte_trace_point_lookup("this_trace_point_does_not_exist");
141 test_fp_trace_points(void)
143 /* Emit the FP trace */
150 test_generic_trace_points(void)
154 rte_eal_trace_generic_void();
155 rte_eal_trace_generic_u64(0x10000000000000);
156 rte_eal_trace_generic_u32(0x10000000);
157 rte_eal_trace_generic_u16(0xffee);
158 rte_eal_trace_generic_u8(0xc);
159 rte_eal_trace_generic_i64(-1234);
160 rte_eal_trace_generic_i32(-1234567);
161 rte_eal_trace_generic_i16(12);
162 rte_eal_trace_generic_i8(-3);
163 rte_eal_trace_generic_int(3333333);
164 rte_eal_trace_generic_long(333);
165 rte_eal_trace_generic_float(20.45);
166 rte_eal_trace_generic_double(20000.5000004);
167 rte_eal_trace_generic_ptr(&tmp);
168 rte_eal_trace_generic_str("my string");
169 RTE_EAL_TRACE_GENERIC_FUNC;
174 static struct unit_test_suite trace_tests = {
175 .suite_name = "trace autotest",
179 TEST_CASE(test_trace_mode),
180 TEST_CASE(test_generic_trace_points),
181 TEST_CASE(test_fp_trace_points),
182 TEST_CASE(test_trace_point_disable_enable),
183 TEST_CASE(test_trace_point_globbing),
184 TEST_CASE(test_trace_point_regex),
185 TEST_CASE(test_trace_points_lookup),
193 return unit_test_suite_runner(&trace_tests);
196 REGISTER_TEST_COMMAND(trace_autotest, test_trace);
199 test_trace_dump(void)
201 rte_trace_dump(stdout);
205 REGISTER_TEST_COMMAND(trace_dump, test_trace_dump);
208 test_trace_metadata_dump(void)
210 return rte_trace_metadata_dump(stdout);
213 REGISTER_TEST_COMMAND(trace_metadata_dump, test_trace_metadata_dump);