Commit | Line | Data |
---|---|---|
748b5f7b SM |
1 | /* |
2 | * Copyright 2020 EfficiOS, Inc. | |
3 | * | |
4 | * SPDX-License-Identifier: GPL-2.0-only | |
5 | * | |
6 | */ | |
7 | ||
c9e313bc | 8 | #include <common/bytecode/bytecode.hpp> |
28ab034a | 9 | |
c9e313bc | 10 | #include <lttng/event-expr-internal.hpp> |
1aa9c49c | 11 | #include <lttng/event-expr.h> |
28ab034a | 12 | |
748b5f7b SM |
13 | #include <tap/tap.h> |
14 | ||
15 | #define NR_TESTS 4 | |
16 | ||
28ab034a | 17 | static void test_event_payload_field(void) |
748b5f7b SM |
18 | { |
19 | struct lttng_event_expr *event_expr; | |
20 | struct lttng_bytecode *bytecode = NULL; | |
21 | int ret; | |
22 | ||
23 | event_expr = lttng_event_expr_event_payload_field_create("tourlou"); | |
24 | ret = lttng_event_expr_to_bytecode(event_expr, &bytecode); | |
25 | ||
26 | ok(ret == 0, "event payload field"); | |
27 | ||
28 | lttng_event_expr_destroy(event_expr); | |
29 | free(bytecode); | |
30 | } | |
31 | ||
28ab034a | 32 | static void test_channel_context_field(void) |
748b5f7b SM |
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 | ||
28ab034a | 47 | static void test_app_specific_context_field(void) |
748b5f7b SM |
48 | { |
49 | struct lttng_event_expr *event_expr; | |
50 | struct lttng_bytecode *bytecode = NULL; | |
51 | int ret; | |
52 | ||
53 | event_expr = lttng_event_expr_app_specific_context_field_create("Bob", "Leponge"); | |
54 | ret = lttng_event_expr_to_bytecode(event_expr, &bytecode); | |
55 | ||
56 | ok(ret == 0, "app-specific context field"); | |
57 | ||
58 | lttng_event_expr_destroy(event_expr); | |
59 | free(bytecode); | |
60 | } | |
61 | ||
28ab034a | 62 | static void test_array_field_element(void) |
748b5f7b SM |
63 | { |
64 | struct lttng_event_expr *event_expr; | |
65 | struct lttng_bytecode *bytecode = NULL; | |
66 | int ret; | |
67 | ||
68 | event_expr = lttng_event_expr_event_payload_field_create("allo"); | |
69 | event_expr = lttng_event_expr_array_field_element_create(event_expr, 168); | |
70 | ret = lttng_event_expr_to_bytecode(event_expr, &bytecode); | |
71 | ||
72 | ok(ret == 0, "array field element"); | |
73 | ||
74 | lttng_event_expr_destroy(event_expr); | |
75 | free(bytecode); | |
76 | } | |
77 | ||
78 | int main(void) | |
79 | { | |
80 | plan_tests(NR_TESTS); | |
81 | ||
82 | test_event_payload_field(); | |
83 | test_channel_context_field(); | |
84 | test_app_specific_context_field(); | |
85 | test_array_field_element(); | |
86 | ||
87 | return exit_status(); | |
88 | } |