File: test_event_expr_to_bytecode.cpp

package info (click to toggle)
ltt-control 2.14.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 21,860 kB
  • sloc: cpp: 192,012; sh: 28,777; ansic: 10,960; python: 7,108; makefile: 3,520; java: 109; xml: 46
file content (88 lines) | stat: -rw-r--r-- 2,004 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/*
 * SPDX-FileCopyrightText: 2020 EfficiOS, Inc.
 *
 * SPDX-License-Identifier: GPL-2.0-only
 *
 */

#include <common/bytecode/bytecode.hpp>

#include <lttng/event-expr-internal.hpp>
#include <lttng/event-expr.h>

#include <tap/tap.h>

#define NR_TESTS 4

static void test_event_payload_field()
{
	struct lttng_event_expr *event_expr;
	struct lttng_bytecode *bytecode = nullptr;
	int ret;

	event_expr = lttng_event_expr_event_payload_field_create("tourlou");
	ret = lttng_event_expr_to_bytecode(event_expr, &bytecode);

	ok(ret == 0, "event payload field");

	lttng_event_expr_destroy(event_expr);
	free(bytecode);
}

static void test_channel_context_field()
{
	struct lttng_event_expr *event_expr;
	struct lttng_bytecode *bytecode = nullptr;
	int ret;

	event_expr = lttng_event_expr_channel_context_field_create("tourlou");
	ret = lttng_event_expr_to_bytecode(event_expr, &bytecode);

	ok(ret == 0, "channel context field");

	lttng_event_expr_destroy(event_expr);
	free(bytecode);
}

static void test_app_specific_context_field()
{
	struct lttng_event_expr *event_expr;
	struct lttng_bytecode *bytecode = nullptr;
	int ret;

	event_expr = lttng_event_expr_app_specific_context_field_create("Bob", "Leponge");
	ret = lttng_event_expr_to_bytecode(event_expr, &bytecode);

	ok(ret == 0, "app-specific context field");

	lttng_event_expr_destroy(event_expr);
	free(bytecode);
}

static void test_array_field_element()
{
	struct lttng_event_expr *event_expr;
	struct lttng_bytecode *bytecode = nullptr;
	int ret;

	event_expr = lttng_event_expr_event_payload_field_create("allo");
	event_expr = lttng_event_expr_array_field_element_create(event_expr, 168);
	ret = lttng_event_expr_to_bytecode(event_expr, &bytecode);

	ok(ret == 0, "array field element");

	lttng_event_expr_destroy(event_expr);
	free(bytecode);
}

int main()
{
	plan_tests(NR_TESTS);

	test_event_payload_field();
	test_channel_context_field();
	test_app_specific_context_field();
	test_array_field_element();

	return exit_status();
}