*
*/
-#include <assert.h>
#include <math.h>
#include <stdbool.h>
#include <stdio.h>
#include <poll.h>
#include <common/compat/errno.h>
+#include <common/macros.h>
#include <lttng/lttng.h>
#include <tap/tap.h>
static const char *get_notification_trigger_name(
struct lttng_notification *notification)
{
- const char *name = NULL;
- enum lttng_evaluation_status status;
- const struct lttng_evaluation *evaluation;
- evaluation = lttng_notification_get_evaluation(notification);
- if (evaluation == NULL) {
- fail("lttng_notification_get_evaluation");
+ const char *trigger_name = NULL;
+ enum lttng_trigger_status trigger_status;
+ const struct lttng_trigger *trigger;
+
+ trigger = lttng_notification_get_trigger(notification);
+ if (!trigger) {
+ fail("Failed to get trigger from notification");
goto end;
}
- switch (lttng_evaluation_get_type(evaluation)) {
- case LTTNG_CONDITION_TYPE_EVENT_RULE_HIT:
- {
- status = lttng_evaluation_event_rule_get_trigger_name(
- evaluation, &name);
- if (status != LTTNG_EVALUATION_STATUS_OK) {
- fail("lttng_evaluation_event_rule_get_trigger_name");
- name = NULL;
- goto end;
- }
+ trigger_status = lttng_trigger_get_name(trigger, &trigger_name);
+ switch (trigger_status) {
+ case LTTNG_TRIGGER_STATUS_OK:
+ break;
+ case LTTNG_TRIGGER_STATUS_UNSET:
+ trigger_name = "(anonymous)";
break;
- }
default:
- fail("Wrong notification evaluation type \n");
+ fail("Failed to get name from notification's trigger");
goto end;
}
+
end:
- return name;
+ return trigger_name;
}
static int validator_notification_trigger_name(
bool name_is_equal;
const char *name;
- assert(notification);
- assert(trigger_name);
+ LTTNG_ASSERT(notification);
+ LTTNG_ASSERT(trigger_name);
name = get_notification_trigger_name(notification);
if (name == NULL) {
/*
* Send SIGUSR1 to application instructing it to bypass tracepoint.
*/
- assert(app_pid > 1);
+ LTTNG_ASSERT(app_pid > 1);
ret = kill(app_pid, SIGUSR1);
if (ret) {
goto error;
}
- assert(app_pid > 1);
+ LTTNG_ASSERT(app_pid > 1);
ret = kill(app_pid, SIGUSR1);
if (ret) {
/* Safety check */
if (mask_position != test_vector_size -1) {
- assert("Logic error for test vector generation");
+ LTTNG_ASSERT("Logic error for test vector generation");
}
loop_ret = asprintf(&test_tuple_string, "session name %s, channel name %s, threshold ratio %s, threshold byte %s, domain type %s",
do {
ret = lttng_data_pending(session_name);
- assert(ret >= 0);
+ LTTNG_ASSERT(ret >= 0);
} while (ret != 0);
}
domain_type, BUFFER_USAGE_TYPE_LOW, 0.99, &condition,
&action, &trigger);
if (ret) {
- fail("Setup error on trigger registration");
+ fail("Setup error on trigger registration in %s()",
+ __FUNCTION__);
goto end;
}
"Subscribe to a condition for which subscription was already done");
end:
- lttng_unregister_trigger(trigger);
+ ret = lttng_unregister_trigger(trigger);
+ if (ret) {
+ fail("Failed to unregister trigger in %s()", __FUNCTION__);
+ }
+
lttng_trigger_destroy(trigger);
lttng_notification_channel_destroy(notification_channel);
lttng_action_destroy(action);
struct lttng_condition **condition,
struct lttng_trigger **trigger)
{
- enum lttng_event_rule_status event_rule_status;
- enum lttng_trigger_status trigger_status;
+ typedef struct lttng_event_rule *(*event_rule_create)(void);
+ typedef enum lttng_event_rule_status (
+ *event_rule_set_name_pattern)(
+ struct lttng_event_rule *rule,
+ const char *pattern);
+ typedef enum lttng_event_rule_status (*event_rule_set_filter)(
+ struct lttng_event_rule *rule,
+ const char *expression);
+ typedef enum lttng_event_rule_status (
+ *event_rule_add_name_pattern_exclusion)(
+ struct lttng_event_rule * rule, const char *exclusion);
+ enum lttng_event_rule_status event_rule_status;
struct lttng_action *tmp_action = NULL;
struct lttng_event_rule *event_rule = NULL;
struct lttng_condition *tmp_condition = NULL;
struct lttng_trigger *tmp_trigger = NULL;
int ret;
+ enum lttng_error_code ret_code;
+ event_rule_create create;
+ event_rule_set_name_pattern set_name_pattern;
+ event_rule_set_filter set_filter;
+ event_rule_add_name_pattern_exclusion add_name_pattern_exclusion;
+
+ LTTNG_ASSERT(event_pattern);
+ LTTNG_ASSERT(trigger_name);
+ LTTNG_ASSERT(condition);
+ LTTNG_ASSERT(trigger);
+
+ /* Set the function pointers based on the domain type. */
+ switch (domain_type) {
+ case LTTNG_DOMAIN_UST:
+ create = lttng_event_rule_user_tracepoint_create;
+ set_name_pattern = lttng_event_rule_user_tracepoint_set_name_pattern;
+ set_filter = lttng_event_rule_user_tracepoint_set_filter;
+ add_name_pattern_exclusion = lttng_event_rule_user_tracepoint_add_name_pattern_exclusion;
+ break;
+ case LTTNG_DOMAIN_KERNEL:
+ create = lttng_event_rule_kernel_tracepoint_create;
+ set_name_pattern = lttng_event_rule_kernel_tracepoint_set_name_pattern;
+ set_filter = lttng_event_rule_kernel_tracepoint_set_filter;
+ add_name_pattern_exclusion = NULL;
+ break;
+ default:
+ abort();
+ break;
+ }
- assert(event_pattern);
- assert(trigger_name);
- assert(condition);
- assert(trigger);
-
- event_rule = lttng_event_rule_tracepoint_create(domain_type);
+ event_rule = create();
ok(event_rule, "Tracepoint event rule object creation");
- event_rule_status = lttng_event_rule_tracepoint_set_pattern(
- event_rule, event_pattern);
+ event_rule_status = set_name_pattern(event_rule, event_pattern);
ok(event_rule_status == LTTNG_EVENT_RULE_STATUS_OK,
"Setting tracepoint event rule pattern: '%s'",
event_pattern);
if (filter) {
- event_rule_status = lttng_event_rule_tracepoint_set_filter(
- event_rule, filter);
+ event_rule_status = set_filter(event_rule, filter);
ok(event_rule_status == LTTNG_EVENT_RULE_STATUS_OK,
"Setting tracepoint event rule filter: '%s'",
filter);
int i;
bool success = true;
- assert(domain_type == LTTNG_DOMAIN_UST);
- assert(exclusion_count > 0);
+ LTTNG_ASSERT(domain_type == LTTNG_DOMAIN_UST);
+ LTTNG_ASSERT(add_name_pattern_exclusion != NULL);
+ LTTNG_ASSERT(exclusion_count > 0);
for (i = 0; i < exclusion_count; i++) {
- event_rule_status =
- lttng_event_rule_tracepoint_add_exclusion(
- event_rule,
- exclusions[i]);
+ event_rule_status = add_name_pattern_exclusion(
+ event_rule, exclusions[i]);
if (event_rule_status != LTTNG_EVENT_RULE_STATUS_OK) {
fail("Setting tracepoint event rule exclusion '%s'.",
exclusions[i]);
ok(success, "Setting tracepoint event rule exclusions");
}
- tmp_condition = lttng_condition_event_rule_create(event_rule);
+ tmp_condition = lttng_condition_event_rule_matches_create(event_rule);
ok(tmp_condition, "Condition event rule object creation");
if (capture_desc_cb) {
tmp_trigger = lttng_trigger_create(tmp_condition, tmp_action);
ok(tmp_trigger, "Trigger object creation %s", trigger_name);
- trigger_status = lttng_trigger_set_name(tmp_trigger, trigger_name);
- ok(trigger_status == LTTNG_TRIGGER_STATUS_OK,
- "Setting name to trigger %s", trigger_name);
-
- ret = lttng_register_trigger(tmp_trigger);
- ok(ret == 0, "Trigger registration %s", trigger_name);
+ ret_code = lttng_register_trigger_with_name(tmp_trigger, trigger_name);
+ ok(ret_code == LTTNG_OK, "Trigger registration %s", trigger_name);
lttng_event_rule_destroy(event_rule);
enum lttng_domain_type domain_type)
{
int i, ret;
+ enum lttng_error_code ret_code;
const int notification_count = 3;
enum lttng_notification_channel_status nc_status;
enum lttng_event_rule_status event_rule_status;
- enum lttng_trigger_status trigger_status;
struct lttng_notification_channel *notification_channel = NULL;
struct lttng_condition *condition = NULL;
struct lttng_kernel_probe_location *location = NULL;
lttng_session_daemon_notification_endpoint);
ok(notification_channel, "Notification channel object creation");
- event_rule = lttng_event_rule_kernel_probe_create();
+ event_rule = lttng_event_rule_kernel_kprobe_create(location);
ok(event_rule, "kprobe event rule object creation");
- event_rule_status = lttng_event_rule_kernel_probe_set_location(
- event_rule, location);
- ok(event_rule_status == LTTNG_EVENT_RULE_STATUS_OK,
- "Setting kprobe event rule location: '%s'", symbol_name);
-
- event_rule_status = lttng_event_rule_kernel_probe_set_name(
+ event_rule_status = lttng_event_rule_kernel_kprobe_set_event_name(
event_rule, trigger_name);
ok(event_rule_status == LTTNG_EVENT_RULE_STATUS_OK,
"Setting kprobe event rule name: '%s'", trigger_name);
- condition = lttng_condition_event_rule_create(event_rule);
+ condition = lttng_condition_event_rule_matches_create(event_rule);
ok(condition, "Condition event rule object creation");
/* Register the trigger for condition. */
goto end;
}
- trigger_status = lttng_trigger_set_name(trigger, trigger_name);
- ok(trigger_status == LTTNG_TRIGGER_STATUS_OK,
- "Setting trigger name to '%s'", trigger_name);
-
- ret = lttng_register_trigger(trigger);
- if (ret) {
+ ret_code = lttng_register_trigger_with_name(trigger, trigger_name);
+ if (ret_code != LTTNG_OK) {
fail("Failed to register trigger with kernel probe event rule condition and notify action");
goto end;
}
const char *test_symbol_name)
{
int i, ret;
+ enum lttng_error_code ret_code;
const int notification_count = 3;
enum lttng_notification_channel_status nc_status;
enum lttng_event_rule_status event_rule_status;
- enum lttng_trigger_status trigger_status;
struct lttng_notification_channel *notification_channel = NULL;
struct lttng_userspace_probe_location *probe_location = NULL;
struct lttng_userspace_probe_location_lookup_method *lookup_method =
lttng_session_daemon_notification_endpoint);
ok(notification_channel, "Notification channel object creation");
- event_rule = lttng_event_rule_userspace_probe_create();
+ event_rule = lttng_event_rule_kernel_uprobe_create(probe_location);
ok(event_rule, "kprobe event rule object creation");
- event_rule_status = lttng_event_rule_userspace_probe_set_location(
- event_rule, probe_location);
- ok(event_rule_status == LTTNG_EVENT_RULE_STATUS_OK,
- "Setting uprobe event rule location");
-
- event_rule_status = lttng_event_rule_userspace_probe_set_name(
+ event_rule_status = lttng_event_rule_kernel_uprobe_set_event_name(
event_rule, trigger_name);
ok(event_rule_status == LTTNG_EVENT_RULE_STATUS_OK,
"Setting uprobe event rule name: '%s'", trigger_name);
- condition = lttng_condition_event_rule_create(event_rule);
+ condition = lttng_condition_event_rule_matches_create(event_rule);
ok(condition, "Condition event rule object creation");
/* Register the trigger for condition. */
goto end;
}
- trigger_status = lttng_trigger_set_name(trigger, trigger_name);
- ok(trigger_status == LTTNG_TRIGGER_STATUS_OK,
- "Setting name to trigger '%s'", trigger_name);
-
- ret = lttng_register_trigger(trigger);
- if (ret) {
+ ret_code = lttng_register_trigger_with_name(trigger, trigger_name);
+ if (ret_code != LTTNG_OK) {
fail("Failed to register trigger with userspace probe event rule condition and notify action");
goto end;
}
enum lttng_domain_type domain_type)
{
int i, ret;
+ enum lttng_error_code ret_code;
const int notification_count = 3;
enum lttng_notification_channel_status nc_status;
enum lttng_event_rule_status event_rule_status;
- enum lttng_trigger_status trigger_status;
struct lttng_notification_channel *notification_channel = NULL;
struct lttng_condition *condition = NULL;
struct lttng_event_rule *event_rule = NULL;
lttng_session_daemon_notification_endpoint);
ok(notification_channel, "Notification channel object creation");
- event_rule = lttng_event_rule_syscall_create();
+ event_rule = lttng_event_rule_kernel_syscall_create(LTTNG_EVENT_RULE_KERNEL_SYSCALL_EMISSION_SITE_ENTRY);
ok(event_rule, "syscall event rule object creation");
- event_rule_status = lttng_event_rule_syscall_set_pattern(
+ event_rule_status = lttng_event_rule_kernel_syscall_set_name_pattern(
event_rule, syscall_name);
ok(event_rule_status == LTTNG_EVENT_RULE_STATUS_OK,
"Setting syscall event rule pattern: '%s'", syscall_name);
- condition = lttng_condition_event_rule_create(event_rule);
+ condition = lttng_condition_event_rule_matches_create(event_rule);
ok(condition, "Condition syscall event rule object creation");
/* Register the trigger for condition. */
goto end;
}
- trigger_status = lttng_trigger_set_name(trigger, trigger_name);
- ok(trigger_status == LTTNG_TRIGGER_STATUS_OK,
- "Setting name to trigger '%s'", trigger_name);
-
- ret = lttng_register_trigger(trigger);
- if (ret) {
+ ret_code = lttng_register_trigger_with_name(trigger, trigger_name);
+ if (ret_code != LTTNG_OK) {
fail("Failed to register trigger with syscall event rule condition and notify action");
goto end;
}
enum lttng_domain_type domain_type)
{
int i, ret;
+ enum lttng_error_code ret_code;
const int notification_count = 3;
enum lttng_notification_channel_status nc_status;
enum lttng_event_rule_status event_rule_status;
- enum lttng_trigger_status trigger_status;
struct lttng_notification_channel *notification_channel = NULL;
struct lttng_condition *condition = NULL;
struct lttng_event_rule *event_rule = NULL;
lttng_session_daemon_notification_endpoint);
ok(notification_channel, "Notification channel object creation");
- event_rule = lttng_event_rule_syscall_create();
+ event_rule = lttng_event_rule_kernel_syscall_create(LTTNG_EVENT_RULE_KERNEL_SYSCALL_EMISSION_SITE_ENTRY);
ok(event_rule, "syscall event rule object creation");
- event_rule_status = lttng_event_rule_syscall_set_pattern(
+ event_rule_status = lttng_event_rule_kernel_syscall_set_name_pattern(
event_rule, syscall_name);
ok(event_rule_status == LTTNG_EVENT_RULE_STATUS_OK,
"Setting syscall event rule pattern: '%s'", syscall_name);
- event_rule_status = lttng_event_rule_syscall_set_filter(
+ event_rule_status = lttng_event_rule_kernel_syscall_set_filter(
event_rule, filter_pattern);
ok(event_rule_status == LTTNG_EVENT_RULE_STATUS_OK,
"Setting filter: '%s'", filter_pattern);
- condition = lttng_condition_event_rule_create(event_rule);
+ condition = lttng_condition_event_rule_matches_create(event_rule);
ok(condition, "Condition event rule object creation");
/* Register the triggers for condition */
goto end;
}
- trigger_status = lttng_trigger_set_name(trigger, trigger_name);
- ok(trigger_status == LTTNG_TRIGGER_STATUS_OK,
- "Setting name to trigger '%s'", trigger_name);
-
- ret = lttng_register_trigger(trigger);
- if (ret) {
+ ret_code = lttng_register_trigger_with_name(trigger, trigger_name);
+ if (ret_code != LTTNG_OK) {
fail("Failed to register trigger with syscall filtering event rule condition and notify action");
goto end;
}
goto end;
}
- cond_status = lttng_condition_event_rule_append_capture_descriptor(
+ cond_status = lttng_condition_event_rule_matches_append_capture_descriptor(
condition, expr);
if (cond_status != LTTNG_CONDITION_STATUS_OK) {
fail("Failed to append capture descriptor");
{
int ret;
unsigned int capture_count, i;
- enum lttng_evaluation_status evaluation_status;
+ enum lttng_evaluation_event_rule_matches_status
+ event_rule_matches_evaluation_status;
enum lttng_event_field_value_status event_field_value_status;
const struct lttng_evaluation *evaluation;
const struct lttng_event_field_value *captured_fields;
goto end;
}
- evaluation_status = lttng_evaluation_event_rule_get_captured_values(
- evaluation, &captured_fields);
- if (evaluation_status != LTTNG_EVALUATION_STATUS_OK) {
+ event_rule_matches_evaluation_status =
+ lttng_evaluation_event_rule_matches_get_captured_values(
+ evaluation, &captured_fields);
+ if (event_rule_matches_evaluation_status !=
+ LTTNG_EVALUATION_EVENT_RULE_MATCHES_STATUS_OK) {
diag("Failed to get event rule evaluation captured values: status = %d",
- (int) evaluation_status);
+ (int) event_rule_matches_evaluation_status);
ret = 1;
goto end;
}
field_value_type_to_str(
lttng_event_field_value_get_type(captured_field)));
- assert(validate);
+ LTTNG_ASSERT(validate);
ret = validate(captured_field, iteration);
if (ret) {
at_least_one_error = true;
switch (test_scenario) {
case 1:
{
- plan_tests(44);
+ plan_tests(41);
/* Test cases that need gen-ust-event testapp. */
diag("Test basic notification error paths for %s domain",
* Test cases that need a test app with more than one event
* type.
*/
- plan_tests(25);
+ plan_tests(23);
/*
* At the moment, the only test case of this scenario is
* exclusion which is only supported by UST.
*/
- assert(domain_type == LTTNG_DOMAIN_UST);
+ LTTNG_ASSERT(domain_type == LTTNG_DOMAIN_UST);
diag("Test tracepoint event rule notifications with exclusion for domain %s",
domain_type_string);
test_tracepoint_event_rule_notification_exclusion(domain_type);
}
case 4:
{
- plan_tests(13);
+ plan_tests(11);
/* Test cases that need the kernel tracer. */
- assert(domain_type == LTTNG_DOMAIN_KERNEL);
+ LTTNG_ASSERT(domain_type == LTTNG_DOMAIN_KERNEL);
diag("Test kprobe event rule notifications for domain %s",
domain_type_string);
}
case 5:
{
- plan_tests(25);
+ plan_tests(23);
/* Test cases that need the kernel tracer. */
- assert(domain_type == LTTNG_DOMAIN_KERNEL);
+ LTTNG_ASSERT(domain_type == LTTNG_DOMAIN_KERNEL);
diag("Test syscall event rule notifications for domain %s",
domain_type_string);
{
const char *testapp_path, *test_symbol_name;
- plan_tests(13);
+ plan_tests(11);
if (argc < 7) {
fail("Missing parameter for tests to run %d", argc);
testapp_path = argv[5];
test_symbol_name = argv[6];
/* Test cases that need the kernel tracer. */
- assert(domain_type == LTTNG_DOMAIN_KERNEL);
+ LTTNG_ASSERT(domain_type == LTTNG_DOMAIN_KERNEL);
diag("Test userspace-probe event rule notifications for domain %s",
domain_type_string);
{
switch(domain_type) {
case LTTNG_DOMAIN_UST:
- plan_tests(222);
+ plan_tests(221);
break;
case LTTNG_DOMAIN_KERNEL:
- plan_tests(216);
+ plan_tests(215);
break;
default:
- assert(0);
+ abort();
}
diag("Test tracepoint event rule notification captures for domain %s",