File: test_kprobe_event_rule_event_name.cpp

package info (click to toggle)
ltt-control 2.14.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 22,400 kB
  • sloc: cpp: 192,720; sh: 29,271; ansic: 10,960; python: 7,419; makefile: 3,534; java: 109; xml: 46
file content (45 lines) | stat: -rw-r--r-- 1,418 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
/*
 * SPDX-FileCopyrightText: 2025 Philippe Proulx <pproulx@efficios.com>
 * SPDX-License-Identifier: GPL-2.0-only
 */

#include <common/macros.hpp>
#include <common/make-unique-wrapper.hpp>
#include <common/string-utils/c-string-view.hpp>

#include <lttng/lttng.h>

#include <tap/tap.h>

namespace {

void check_event_name(lttng_kernel_probe_location& raw_loc, const char *const name)
{
	auto loc = lttng::make_unique_wrapper<lttng_kernel_probe_location,
					      lttng_kernel_probe_location_destroy>(&raw_loc);
	auto rule = lttng::make_unique_wrapper<lttng_event_rule, lttng_event_rule_destroy>(
		lttng_event_rule_kernel_kprobe_create(loc.get()));
	const char *actual_name;
	const auto ret = lttng_event_rule_kernel_kprobe_get_event_name(rule.get(), &actual_name);

	LTTNG_ASSERT(ret == LTTNG_EVENT_RULE_STATUS_OK);
	LTTNG_ASSERT(actual_name);

	if (!ok(lttng::c_string_view(actual_name) == name,
		"lttng_event_rule_kernel_kprobe_create - The event name `%s` is expected",
		name)) {
		diag("Expecting `%s`; got `%s`", name, actual_name);
	}
}

} /* namespace */

int main()
{
	plan_tests(3);
	check_event_name(*lttng_kernel_probe_location_symbol_create("meow_mix", 0), "meow_mix");
	check_event_name(*lttng_kernel_probe_location_symbol_create("meow_mix", 0xabcd1234),
			 "meow_mix+0xabcd1234");
	check_event_name(*lttng_kernel_probe_location_address_create(0xdeadbeef), "0xdeadbeef");
	return exit_status();
}