xref: /linux/tools/tracing/rtla/tests/unit/cli_params_assert.h (revision 244d0cbff2efa13931115784e5dc4d1270a04ec7)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #pragma once
3 
4 #include "../../src/timerlat.h"
5 
6 /* Tracing Options */
7 
8 #define CLI_ASSERT_SINGLE_EVENT(_system, _event) do {\
9 	ck_assert_ptr_nonnull(params->events);\
10 	ck_assert_str_eq(params->events->system, _system);\
11 	ck_assert_str_eq(params->events->event, _event);\
12 	ck_assert_ptr_null(params->events->next);\
13 } while (0)
14 
15 #define CLI_ASSERT_SINGLE_FILTER(_filter) do {\
16 	ck_assert_ptr_nonnull(params->events);\
17 	ck_assert_str_eq(params->events->filter, _filter);\
18 	ck_assert_ptr_null(params->events->next);\
19 } while (0)
20 
21 #define CLI_ASSERT_SINGLE_TRIGGER(_trigger) do {\
22 	ck_assert_ptr_nonnull(params->events);\
23 	ck_assert_str_eq(params->events->trigger, _trigger);\
24 	ck_assert_ptr_null(params->events->next);\
25 } while (0)
26 
27 /* CPU Configuration */
28 
29 #define CLI_ASSERT_CPUSET(_field, ...) do {\
30 	int n;\
31 	int cpus[] = { __VA_ARGS__ };\
32 	for (n = 0; n < sizeof(cpus) / sizeof(int); n++)\
33 		ck_assert(CPU_ISSET(cpus[n], &params->_field));\
34 	ck_assert_int_eq(CPU_COUNT(&params->_field), n);\
35 } while (0)
36 
37 /* Auto Analysis and Actions */
38 
39 #define CLI_OSNOISE_ASSERT_AUTO(_stop) do {\
40 	ck_assert_int_eq(params->stop_us, _stop);\
41 	ck_assert_int_eq(osn_params->threshold, 1);\
42 	ck_assert_int_eq(params->threshold_actions.len, 1);\
43 	ck_assert_int_eq(params->threshold_actions.list[0].type, ACTION_TRACE_OUTPUT);\
44 	ck_assert_str_eq(params->threshold_actions.list[0].trace_output, "osnoise_trace.txt");\
45 } while (0)
46 
47 #define CLI_TIMERLAT_ASSERT_AUTO(_threshold) do {\
48 	ck_assert_int_eq(params->stop_us, _threshold);\
49 	ck_assert_int_eq(params->stop_total_us, _threshold);\
50 	ck_assert_int_eq(tlat_params->print_stack, _threshold);\
51 	ck_assert_int_eq(params->threshold_actions.len, 1);\
52 	ck_assert_int_eq(params->threshold_actions.list[0].type, ACTION_TRACE_OUTPUT);\
53 	ck_assert_str_eq(params->threshold_actions.list[0].trace_output, "timerlat_trace.txt");\
54 } while (0)
55 
56 #define CLI_TIMERLAT_ASSERT_AA_ONLY(_threshold) do {\
57 	ck_assert_int_eq(params->stop_us, _threshold);\
58 	ck_assert_int_eq(params->stop_total_us, _threshold);\
59 	ck_assert_int_eq(tlat_params->print_stack, _threshold);\
60 	ck_assert_int_eq(params->threshold_actions.len, 0);\
61 	ck_assert(params->aa_only);\
62 } while (0)
63 
64 #define CLI_ASSERT_SINGLE_ACTION(_actions, _type, _arg, _valtype, _value) do {\
65 	ck_assert_int_eq(params->_actions.len, 1);\
66 	ck_assert_int_eq(params->_actions.list[0].type, _type);\
67 	ck_assert_##_valtype##_eq(params->_actions.list[0]._arg, _value);\
68 } while (0)
69