SoW-2020-0002: Trace Hit Counters: trigger error reporting integration
[lttng-tools.git] / tests / unit / test_event_expr_to_bytecode.c
1 /*
2 * Copyright 2020 EfficiOS, Inc.
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 */
7
8 #include <lttng/event-expr.h>
9 #include <common/event-expr-to-bytecode.h>
10 #include <common/bytecode/bytecode.h>
11 #include <tap/tap.h>
12
13 #define NR_TESTS 4
14
15 static
16 void test_event_payload_field(void)
17 {
18 struct lttng_event_expr *event_expr;
19 struct lttng_bytecode *bytecode = NULL;
20 int ret;
21
22 event_expr = lttng_event_expr_event_payload_field_create("tourlou");
23 ret = lttng_event_expr_to_bytecode(event_expr, &bytecode);
24
25 ok(ret == 0, "event payload field");
26
27 lttng_event_expr_destroy(event_expr);
28 free(bytecode);
29 }
30
31 static
32 void test_channel_context_field(void)
33 {
34 struct lttng_event_expr *event_expr;
35 struct lttng_bytecode *bytecode = NULL;
36 int ret;
37
38 event_expr = lttng_event_expr_channel_context_field_create("tourlou");
39 ret = lttng_event_expr_to_bytecode(event_expr, &bytecode);
40
41 ok(ret == 0, "channel context field");
42
43 lttng_event_expr_destroy(event_expr);
44 free(bytecode);
45 }
46
47 static
48 void test_app_specific_context_field(void)
49 {
50 struct lttng_event_expr *event_expr;
51 struct lttng_bytecode *bytecode = NULL;
52 int ret;
53
54 event_expr = lttng_event_expr_app_specific_context_field_create("Bob", "Leponge");
55 ret = lttng_event_expr_to_bytecode(event_expr, &bytecode);
56
57 ok(ret == 0, "app-specific context field");
58
59 lttng_event_expr_destroy(event_expr);
60 free(bytecode);
61 }
62
63 static
64 void test_array_field_element(void)
65 {
66 struct lttng_event_expr *event_expr;
67 struct lttng_bytecode *bytecode = NULL;
68 int ret;
69
70 event_expr = lttng_event_expr_event_payload_field_create("allo");
71 event_expr = lttng_event_expr_array_field_element_create(event_expr, 168);
72 ret = lttng_event_expr_to_bytecode(event_expr, &bytecode);
73
74 ok(ret == 0, "array field element");
75
76 lttng_event_expr_destroy(event_expr);
77 free(bytecode);
78 }
79
80 int main(void)
81 {
82 plan_tests(NR_TESTS);
83
84 test_event_payload_field();
85 test_channel_context_field();
86 test_app_specific_context_field();
87 test_array_field_element();
88
89 return exit_status();
90 }
This page took 0.046881 seconds and 5 git commands to generate.