4 * Tests suite for LTTng notification API
6 * Copyright (C) 2017 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
8 * SPDX-License-Identifier: MIT
20 #include <sys/types.h>
27 #include <lttng/action/action.h>
28 #include <lttng/action/notify.h>
29 #include <lttng/condition/buffer-usage.h>
30 #include <lttng/condition/condition.h>
31 #include <lttng/condition/evaluation.h>
32 #include <lttng/condition/event-rule.h>
33 #include <lttng/domain.h>
34 #include <lttng/endpoint.h>
35 #include <lttng/event-field-value.h>
36 #include <lttng/event-rule/kprobe.h>
37 #include <lttng/event-rule/syscall.h>
38 #include <lttng/event-rule/tracepoint.h>
39 #include <lttng/event-rule/uprobe.h>
40 #include <lttng/kernel-probe.h>
41 #include <lttng/lttng-error.h>
42 #include <lttng/lttng.h>
43 #include <lttng/notification/channel.h>
44 #include <lttng/notification/notification.h>
45 #include <lttng/condition/evaluation.h>
46 #include <lttng/trigger/trigger.h>
47 #include <lttng/userspace-probe.h>
51 /* A callback to populate the condition capture descriptor */
52 typedef int (*condition_capture_desc_cb
)(struct lttng_condition
*condition
);
54 /* A callback for captured field validation */
55 typedef int (*validate_cb
)(const struct lttng_event_field_value
*event_field
, unsigned iteration
);
58 int named_pipe_args_start
= 0;
60 const char *app_state_file
= NULL
;
65 FIELD_TYPE_APP_CONTEXT
,
66 FIELD_TYPE_ARRAY_FIELD
,
69 struct capture_base_field_tuple
{
71 enum field_type field_type
;
72 bool expected_ust
; // Do we expect a capture?
73 bool expected_kernel
; // Do we expect a capture?
74 validate_cb validate_ust
;
75 validate_cb validate_kernel
;
79 const char *field_value_type_to_str(enum lttng_event_field_value_type type
)
82 case LTTNG_EVENT_FIELD_VALUE_TYPE_UNKNOWN
:
84 case LTTNG_EVENT_FIELD_VALUE_TYPE_INVALID
:
86 case LTTNG_EVENT_FIELD_VALUE_TYPE_UNSIGNED_INT
:
87 return "UNSIGNED INT";
88 case LTTNG_EVENT_FIELD_VALUE_TYPE_SIGNED_INT
:
90 case LTTNG_EVENT_FIELD_VALUE_TYPE_UNSIGNED_ENUM
:
91 return "UNSIGNED ENUM";
92 case LTTNG_EVENT_FIELD_VALUE_TYPE_SIGNED_ENUM
:
94 case LTTNG_EVENT_FIELD_VALUE_TYPE_REAL
:
96 case LTTNG_EVENT_FIELD_VALUE_TYPE_STRING
:
98 case LTTNG_EVENT_FIELD_VALUE_TYPE_ARRAY
:
105 static int validate_type(
106 const struct lttng_event_field_value
*event_field
,
107 enum lttng_event_field_value_type expect
)
110 enum lttng_event_field_value_type value
;
112 value
= lttng_event_field_value_get_type(event_field
);
113 if (value
== LTTNG_EVENT_FIELD_VALUE_TYPE_INVALID
) {
118 ret
= (expect
== value
);
119 ok(ret
, "Expected field type: %s got %s",
120 field_value_type_to_str(expect
),
121 field_value_type_to_str(value
));
130 * Validate unsigned captured field against the iteration number.
131 * The iteration number is always unsigned and will always be compared to value
134 static int validate_unsigned_int_field(
135 const struct lttng_event_field_value
*event_field
,
136 unsigned int iteration
)
140 enum lttng_event_field_value_status status
;
142 ret
= validate_type(event_field
, LTTNG_EVENT_FIELD_VALUE_TYPE_UNSIGNED_INT
);
147 status
= lttng_event_field_value_unsigned_int_get_value(
148 event_field
, &value
);
149 if (status
!= LTTNG_EVENT_FIELD_VALUE_STATUS_OK
) {
150 fail("lttng_event_field_value_unsigned_int_get_value");
155 ret
= (value
== (uint64_t) iteration
);
156 ok (ret
, "Expected unsigned int of value: %u got %" PRIu64
, iteration
, value
);
166 * Validate signed captured field.
167 * Value should be -1.
169 static int validate_signed_int_field(
170 const struct lttng_event_field_value
*event_field
,
171 unsigned int iteration
)
174 int64_t expected
= -1;
176 enum lttng_event_field_value_status status
;
181 ret
= validate_type(event_field
, LTTNG_EVENT_FIELD_VALUE_TYPE_SIGNED_INT
);
186 status
= lttng_event_field_value_signed_int_get_value(
187 event_field
, &value
);
188 if (status
!= LTTNG_EVENT_FIELD_VALUE_STATUS_OK
) {
189 fail("lttng_event_field_value_signed_int_get_value");
194 ret
= (value
== expected
);
195 ok(ret
, "Expected signed int of value: %" PRId64
" got %" PRId64
, expected
, value
);
205 * Validate array of unsigned int.
207 static int validate_array_unsigned_int_field(
208 const struct lttng_event_field_value
*event_field
,
209 unsigned int iteration
)
212 enum lttng_event_field_value_status status
;
213 unsigned int expected
= 3;
219 ret
= validate_type(event_field
, LTTNG_EVENT_FIELD_VALUE_TYPE_ARRAY
);
224 status
= lttng_event_field_value_array_get_length(event_field
, &count
);
225 if (status
!= LTTNG_EVENT_FIELD_VALUE_STATUS_OK
) {
226 fail("lttng_event_field_value_array_get_length");
231 ret
= (count
== expected
);
232 ok(ret
, "Expected %d subelements got %d", expected
, count
);
238 for (unsigned int i
= 1; i
< count
+ 1; i
++) {
239 const struct lttng_event_field_value
*value
;
240 status
= lttng_event_field_value_array_get_element_at_index(
241 event_field
, i
- 1, &value
);
242 if (status
!= LTTNG_EVENT_FIELD_VALUE_STATUS_OK
) {
243 fail("lttng_event_field_value_array_get_element_at_index");
247 ret
= validate_unsigned_int_field(value
, i
);
258 static int validate_array_unsigned_int_field_at_index(
259 const struct lttng_event_field_value
*event_field
,
260 unsigned int iteration
)
263 uint64_t expected_value
= 2;
264 enum lttng_event_field_value_status status
;
270 ret
= validate_type(event_field
, LTTNG_EVENT_FIELD_VALUE_TYPE_UNSIGNED_INT
);
275 status
= lttng_event_field_value_unsigned_int_get_value(
276 event_field
, &value
);
277 if (status
!= LTTNG_EVENT_FIELD_VALUE_STATUS_OK
) {
278 fail("lttng_event_field_value_unsigned_int_get_value");
283 ret
= (value
== expected_value
);
284 ok (ret
, "Expected unsigned int of value: %u got %" PRIu64
,
285 expected_value
, value
);
293 * Validate sequence for a string (seqfield1):
295 * Value: "test" in utf8 [116, 101, 115, 116]
297 static int validate_seqfield1(
298 const struct lttng_event_field_value
*event_field
,
299 unsigned int iteration
)
302 enum lttng_event_field_value_status status
;
304 unsigned int expect
[4] = {116, 101, 115, 116};
309 ret
= validate_type(event_field
, LTTNG_EVENT_FIELD_VALUE_TYPE_ARRAY
);
314 status
= lttng_event_field_value_array_get_length(event_field
, &count
);
315 if (status
!= LTTNG_EVENT_FIELD_VALUE_STATUS_OK
) {
316 fail("lttng_event_field_value_array_get_length");
322 ok(ret
, "Expected 4 subelement got %d", count
);
328 for (unsigned int i
= 0; i
< count
; i
++) {
329 const struct lttng_event_field_value
*value
;
330 status
= lttng_event_field_value_array_get_element_at_index(
331 event_field
, i
, &value
);
332 if (status
!= LTTNG_EVENT_FIELD_VALUE_STATUS_OK
) {
333 fail("lttng_event_field_value_array_get_element_at_index");
337 ret
= validate_unsigned_int_field(value
, expect
[i
]);
349 static int validate_string(
350 const struct lttng_event_field_value
*event_field
,
354 const char *value
= NULL
;
356 ret
= validate_type(event_field
, LTTNG_EVENT_FIELD_VALUE_TYPE_STRING
);
361 value
= lttng_event_field_value_string_get_value(event_field
);
363 fail("lttng_event_field_value_array_get_length");
368 ok(!strcmp(value
, expect
), "Expected string: \"%s\" got \"%s\"", expect
, value
);
377 * Validate string. Expected value is "test".
379 static int validate_string_test(
380 const struct lttng_event_field_value
*event_field
,
381 unsigned int iteration
)
384 const char *expect
= "test";
389 ret
= validate_string(event_field
, expect
);
394 * Validate escaped string. Expected value is "\*".
396 static int validate_string_escaped(
397 const struct lttng_event_field_value
*event_field
,
398 unsigned int iteration
)
401 const char *expect
= "\\*";
406 ret
= validate_string(event_field
, expect
);
411 * Validate real field.
413 static int validate_real(
414 const struct lttng_event_field_value
*event_field
,
419 enum lttng_event_field_value_status status
;
421 ret
= validate_type(event_field
, LTTNG_EVENT_FIELD_VALUE_TYPE_REAL
);
426 status
= lttng_event_field_value_real_get_value(event_field
, &value
);
427 if (status
!= LTTNG_EVENT_FIELD_VALUE_STATUS_OK
) {
428 fail("lttng_event_field_value_real_get_value");
433 ret
= (value
== expect
);
434 ok(ret
, "Real expected: %f got: %f", expect
, value
);
442 * Validate floatfield.
444 static int validate_floatfield(
445 const struct lttng_event_field_value
*event_field
,
446 unsigned int iteration
)
449 double expect
= 2222.0;
454 ret
= validate_real(event_field
, expect
);
459 * Validate doublefield.
461 static int validate_doublefield(
462 const struct lttng_event_field_value
*event_field
,
463 unsigned int iteration
)
471 ret
= validate_real(event_field
, expect
);
476 * Validate enum0: enum0 = ( "AUTO: EXPECT 0" : container = 0 )
478 static int validate_enum0(const struct lttng_event_field_value
*event_field
,
479 unsigned int iteration
)
482 enum lttng_event_field_value_status status
;
484 uint64_t expected_value
= 0;
489 ret
= validate_type(event_field
,
490 LTTNG_EVENT_FIELD_VALUE_TYPE_UNSIGNED_ENUM
);
495 status
= lttng_event_field_value_unsigned_int_get_value(
496 event_field
, &value
);
497 if (status
!= LTTNG_EVENT_FIELD_VALUE_STATUS_OK
) {
498 fail("lttng_event_field_value_unsigned_int_get_value");
503 ok(value
== expected_value
,
504 "Enum value expected: %" PRIu64
" got %" PRIu64
,
505 expected_value
, value
);
512 * Validate enumnegative: enumnegative = ( "AUTO: EXPECT 0" : container = 0 )
514 * We expect 2 labels here.
516 static int validate_enumnegative(
517 const struct lttng_event_field_value
*event_field
,
518 unsigned int iteration
)
521 enum lttng_event_field_value_status status
;
523 int64_t expected_value
= -1;
529 event_field
, LTTNG_EVENT_FIELD_VALUE_TYPE_SIGNED_ENUM
);
534 status
= lttng_event_field_value_signed_int_get_value(
535 event_field
, &value
);
536 if (status
!= LTTNG_EVENT_FIELD_VALUE_STATUS_OK
) {
537 fail("lttng_event_field_value_unsigned_int_get_value");
542 ok(value
== expected_value
,
543 "Enum value expected: %" PRId64
" got %" PRId64
,
544 expected_value
, value
);
550 static int validate_context_procname_ust(
551 const struct lttng_event_field_value
*event_field
,
552 unsigned int iteration
)
559 ret
= validate_string(event_field
, "gen-ust-events");
563 static int validate_context_procname_kernel(
564 const struct lttng_event_field_value
*event_field
,
565 unsigned int iteration
)
572 ret
= validate_string(event_field
, "echo");
576 struct capture_base_field_tuple test_capture_base_fields
[] = {
577 {"DOESNOTEXIST", FIELD_TYPE_PAYLOAD
, false, false, NULL
, NULL
},
578 {"intfield", FIELD_TYPE_PAYLOAD
, true, true, validate_unsigned_int_field
, validate_unsigned_int_field
},
579 {"longfield", FIELD_TYPE_PAYLOAD
, true, true, validate_unsigned_int_field
, validate_unsigned_int_field
},
580 {"signedfield", FIELD_TYPE_PAYLOAD
, true, true, validate_signed_int_field
, validate_signed_int_field
},
581 {"arrfield1", FIELD_TYPE_PAYLOAD
, true, true, validate_array_unsigned_int_field
, validate_array_unsigned_int_field
},
582 {"arrfield2", FIELD_TYPE_PAYLOAD
, true, true, validate_string_test
, validate_string_test
},
583 {"arrfield3", FIELD_TYPE_PAYLOAD
, true, true, validate_array_unsigned_int_field
, validate_array_unsigned_int_field
},
584 {"seqfield1", FIELD_TYPE_PAYLOAD
, true, true, validate_seqfield1
, validate_seqfield1
},
585 {"seqfield2", FIELD_TYPE_PAYLOAD
, true, true, validate_string_test
, validate_string_test
},
586 {"seqfield3", FIELD_TYPE_PAYLOAD
, true, true, validate_array_unsigned_int_field
, validate_array_unsigned_int_field
},
587 {"seqfield4", FIELD_TYPE_PAYLOAD
, true, true, validate_array_unsigned_int_field
, validate_array_unsigned_int_field
},
588 {"arrfield1[1]", FIELD_TYPE_ARRAY_FIELD
, true, true, validate_array_unsigned_int_field_at_index
, validate_array_unsigned_int_field_at_index
},
589 {"stringfield", FIELD_TYPE_PAYLOAD
, true, true, validate_string_test
, validate_string_test
},
590 {"stringfield2", FIELD_TYPE_PAYLOAD
, true, true, validate_string_escaped
, validate_string_escaped
},
591 {"floatfield", FIELD_TYPE_PAYLOAD
, true, false, validate_floatfield
, validate_floatfield
},
592 {"doublefield", FIELD_TYPE_PAYLOAD
, true, false, validate_doublefield
, validate_doublefield
},
593 {"enum0", FIELD_TYPE_PAYLOAD
, true, true, validate_enum0
, validate_enum0
},
594 {"enumnegative", FIELD_TYPE_PAYLOAD
, true, true, validate_enumnegative
, validate_enumnegative
},
595 {"$ctx.procname", FIELD_TYPE_CONTEXT
, true, true, validate_context_procname_ust
, validate_context_procname_kernel
},
598 static const char *get_notification_trigger_name(
599 struct lttng_notification
*notification
)
601 const char *name
= NULL
;
602 enum lttng_evaluation_status status
;
603 const struct lttng_evaluation
*evaluation
;
604 evaluation
= lttng_notification_get_evaluation(notification
);
605 if (evaluation
== NULL
) {
606 fail("lttng_notification_get_evaluation");
610 switch (lttng_evaluation_get_type(evaluation
)) {
611 case LTTNG_CONDITION_TYPE_EVENT_RULE_HIT
:
613 status
= lttng_evaluation_event_rule_get_trigger_name(
615 if (status
!= LTTNG_EVALUATION_STATUS_OK
) {
616 fail("lttng_evaluation_event_rule_get_trigger_name");
623 fail("Wrong notification evaluation type \n");
630 static int validator_notification_trigger_name(
631 struct lttng_notification
*notification
,
632 const char *trigger_name
)
638 assert(notification
);
639 assert(trigger_name
);
641 name
= get_notification_trigger_name(notification
);
647 name_is_equal
= (strcmp(trigger_name
, name
) == 0);
648 ok(name_is_equal
, "Expected trigger name: %s got %s", trigger_name
,
651 ret
= !name_is_equal
;
658 void wait_on_file(const char *path
, bool file_exist
)
667 ret
= stat(path
, &buf
);
668 if (ret
== -1 && errno
== ENOENT
) {
671 * The file does not exist. wait a bit and
672 * continue looping until it does.
674 (void) poll(NULL
, 0, 10);
679 * File does not exist and the exit condition we want.
680 * Break from the loop and return.
689 * stat() returned 0, so the file exists. break now only if
690 * that's the exit condition we want.
699 int write_pipe(const char *path
, uint8_t data
)
704 fd
= open(path
, O_WRONLY
| O_NONBLOCK
);
706 perror("Could not open consumer control named pipe");
710 ret
= write(fd
, &data
, sizeof(data
));
712 perror("Named pipe write failed");
714 perror("Named pipe close failed");
722 perror("Name pipe closing failed");
731 int stop_consumer(const char **argv
)
735 for (i
= named_pipe_args_start
; i
< nb_args
; i
++) {
736 ret
= write_pipe(argv
[i
], 49);
742 int resume_consumer(const char **argv
)
746 for (i
= named_pipe_args_start
; i
< nb_args
; i
++) {
747 ret
= write_pipe(argv
[i
], 0);
753 int suspend_application(void)
758 if (!stat(app_state_file
, &buf
)) {
759 fail("App is already in a suspended state.");
765 * Send SIGUSR1 to application instructing it to bypass tracepoint.
769 ret
= kill(app_pid
, SIGUSR1
);
771 fail("SIGUSR1 failed. errno %d", errno
);
776 wait_on_file(app_state_file
, true);
784 int resume_application()
789 ret
= stat(app_state_file
, &buf
);
790 if (ret
== -1 && errno
== ENOENT
) {
791 fail("State file does not exist");
801 ret
= kill(app_pid
, SIGUSR1
);
803 fail("SIGUSR1 failed. errno %d", errno
);
808 wait_on_file(app_state_file
, false);
817 void test_triggers_buffer_usage_condition(const char *session_name
,
818 const char *channel_name
,
819 enum lttng_domain_type domain_type
,
820 enum lttng_condition_type condition_type
)
822 unsigned int test_vector_size
= 5, i
;
823 enum lttng_condition_status condition_status
;
824 struct lttng_action
*action
;
827 action
= lttng_action_notify_create();
829 fail("Setup error on action creation");
833 /* Test lttng_register_trigger with null value */
834 ok(lttng_register_trigger(NULL
) == -LTTNG_ERR_INVALID
, "Registering a NULL trigger fails as expected");
836 /* Test: register a trigger */
838 for (i
= 0; i
< pow(2,test_vector_size
); i
++) {
840 char *test_tuple_string
= NULL
;
841 unsigned int mask_position
= 0;
842 bool session_name_set
= false;
843 bool channel_name_set
= false;
844 bool threshold_ratio_set
= false;
845 bool threshold_byte_set
= false;
846 bool domain_type_set
= false;
848 struct lttng_trigger
*trigger
= NULL
;
849 struct lttng_condition
*condition
= NULL
;
851 /* Create base condition */
852 switch (condition_type
) {
853 case LTTNG_CONDITION_TYPE_BUFFER_USAGE_LOW
:
854 condition
= lttng_condition_buffer_usage_low_create();
856 case LTTNG_CONDITION_TYPE_BUFFER_USAGE_HIGH
:
857 condition
= lttng_condition_buffer_usage_high_create();
870 /* Prepare the condition for trigger registration test */
872 /* Set session name */
873 if ((1 << mask_position
) & i
) {
874 condition_status
= lttng_condition_buffer_usage_set_session_name(
875 condition
, session_name
);
876 if (condition_status
!= LTTNG_CONDITION_STATUS_OK
) {
880 session_name_set
= true;
884 /* Set channel name */
885 if ((1 << mask_position
) & i
) {
886 condition_status
= lttng_condition_buffer_usage_set_channel_name(
887 condition
, channel_name
);
888 if (condition_status
!= LTTNG_CONDITION_STATUS_OK
) {
892 channel_name_set
= true;
896 /* Set threshold ratio */
897 if ((1 << mask_position
) & i
) {
898 condition_status
= lttng_condition_buffer_usage_set_threshold_ratio(
900 if (condition_status
!= LTTNG_CONDITION_STATUS_OK
) {
904 threshold_ratio_set
= true;
908 /* Set threshold byte */
909 if ((1 << mask_position
) & i
) {
910 condition_status
= lttng_condition_buffer_usage_set_threshold(
912 if (condition_status
!= LTTNG_CONDITION_STATUS_OK
) {
916 threshold_byte_set
= true;
920 /* Set domain type */
921 if ((1 << mask_position
) & i
) {
922 condition_status
= lttng_condition_buffer_usage_set_domain_type(
923 condition
, LTTNG_DOMAIN_UST
);
924 if (condition_status
!= LTTNG_CONDITION_STATUS_OK
) {
928 domain_type_set
= true;
932 if (mask_position
!= test_vector_size
-1) {
933 assert("Logic error for test vector generation");
936 loop_ret
= asprintf(&test_tuple_string
, "session name %s, channel name %s, threshold ratio %s, threshold byte %s, domain type %s",
937 session_name_set
? "set" : "unset",
938 channel_name_set
? "set" : "unset",
939 threshold_ratio_set
? "set" : "unset",
940 threshold_byte_set
? "set" : "unset",
941 domain_type_set
? "set" : "unset");
942 if (!test_tuple_string
|| loop_ret
< 0) {
948 trigger
= lttng_trigger_create(condition
, action
);
954 loop_ret
= lttng_register_trigger(trigger
);
958 fail("Setup error occurred for tuple: %s", test_tuple_string
);
962 /* This combination happens three times */
963 if (session_name_set
&& channel_name_set
964 && (threshold_ratio_set
|| threshold_byte_set
)
965 && domain_type_set
) {
966 ok(loop_ret
== 0, "Trigger is registered: %s", test_tuple_string
);
969 * Test that a trigger cannot be registered
972 loop_ret
= lttng_register_trigger(trigger
);
973 ok(loop_ret
== -LTTNG_ERR_TRIGGER_EXISTS
, "Re-register trigger fails as expected: %s", test_tuple_string
);
975 /* Test that a trigger can be unregistered */
976 loop_ret
= lttng_unregister_trigger(trigger
);
977 ok(loop_ret
== 0, "Unregister trigger: %s", test_tuple_string
);
980 * Test that unregistration of a non-previously
981 * registered trigger fail.
983 loop_ret
= lttng_unregister_trigger(trigger
);
984 ok(loop_ret
== -LTTNG_ERR_TRIGGER_NOT_FOUND
, "Unregister of a non-registered trigger fails as expected: %s", test_tuple_string
);
986 ok(loop_ret
== -LTTNG_ERR_INVALID_TRIGGER
, "Trigger is invalid as expected and cannot be registered: %s", test_tuple_string
);
990 free(test_tuple_string
);
991 lttng_trigger_destroy(trigger
);
992 lttng_condition_destroy(condition
);
996 lttng_action_destroy(action
);
1000 void wait_data_pending(const char *session_name
)
1005 ret
= lttng_data_pending(session_name
);
1011 int setup_buffer_usage_condition(struct lttng_condition
*condition
,
1012 const char *condition_name
,
1013 const char *session_name
,
1014 const char *channel_name
,
1015 const enum lttng_domain_type domain_type
)
1017 enum lttng_condition_status condition_status
;
1020 condition_status
= lttng_condition_buffer_usage_set_session_name(
1021 condition
, session_name
);
1022 if (condition_status
!= LTTNG_CONDITION_STATUS_OK
) {
1023 fail("Error setting session name on %s creation", condition_name
);
1028 condition_status
= lttng_condition_buffer_usage_set_channel_name(
1029 condition
, channel_name
);
1030 if (condition_status
!= LTTNG_CONDITION_STATUS_OK
) {
1031 fail("Error setting channel name on %s creation", condition_name
);
1036 condition_status
= lttng_condition_buffer_usage_set_domain_type(
1037 condition
, domain_type
);
1038 if (condition_status
!= LTTNG_CONDITION_STATUS_OK
) {
1039 fail("Error setting domain type on %s creation", condition_name
);
1049 void test_invalid_channel_subscription(
1050 const enum lttng_domain_type domain_type
)
1052 enum lttng_condition_status condition_status
;
1053 enum lttng_notification_channel_status nc_status
;
1054 struct lttng_condition
*dummy_condition
= NULL
;
1055 struct lttng_condition
*dummy_invalid_condition
= NULL
;
1056 struct lttng_notification_channel
*notification_channel
= NULL
;
1059 notification_channel
= lttng_notification_channel_create(
1060 lttng_session_daemon_notification_endpoint
);
1061 ok(notification_channel
, "Notification channel object creation");
1062 if (!notification_channel
) {
1067 * Create a dummy, empty (thus invalid) condition to test error paths.
1069 dummy_invalid_condition
= lttng_condition_buffer_usage_low_create();
1070 if (!dummy_invalid_condition
) {
1071 fail("Setup error on condition creation");
1076 * Test subscription and unsubscription of an invalid condition to/from
1079 nc_status
= lttng_notification_channel_subscribe(
1080 notification_channel
, dummy_invalid_condition
);
1081 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_INVALID
,
1082 "Subscribing to an invalid condition");
1084 nc_status
= lttng_notification_channel_unsubscribe(
1085 notification_channel
, dummy_invalid_condition
);
1086 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_INVALID
,
1087 "Unsubscribing from an invalid condition");
1089 /* Create a valid dummy condition with a ratio of 0.5 */
1090 dummy_condition
= lttng_condition_buffer_usage_low_create();
1091 if (!dummy_condition
) {
1092 fail("Setup error on dummy_condition creation");
1096 condition_status
= lttng_condition_buffer_usage_set_threshold_ratio(
1097 dummy_condition
, 0.5);
1098 if (condition_status
!= LTTNG_CONDITION_STATUS_OK
) {
1099 fail("Setup error on condition creation");
1103 ret
= setup_buffer_usage_condition(dummy_condition
, "dummy_condition",
1104 "dummy_session", "dummy_channel", domain_type
);
1106 fail("Setup error on dummy condition creation");
1111 * Test subscription and unsubscription to/from a channel with invalid
1114 nc_status
= lttng_notification_channel_subscribe(NULL
, NULL
);
1115 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_INVALID
,
1116 "Notification channel subscription is invalid: NULL, NULL");
1118 nc_status
= lttng_notification_channel_subscribe(
1119 notification_channel
, NULL
);
1120 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_INVALID
,
1121 "Notification channel subscription is invalid: NON-NULL, NULL");
1123 nc_status
= lttng_notification_channel_subscribe(NULL
, dummy_condition
);
1124 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_INVALID
,
1125 "Notification channel subscription is invalid: NULL, NON-NULL");
1127 nc_status
= lttng_notification_channel_unsubscribe(
1128 notification_channel
, dummy_condition
);
1129 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_UNKNOWN_CONDITION
,
1130 "Unsubscribing from a valid unknown condition");
1133 lttng_notification_channel_destroy(notification_channel
);
1134 lttng_condition_destroy(dummy_invalid_condition
);
1135 lttng_condition_destroy(dummy_condition
);
1139 enum buffer_usage_type
{
1140 BUFFER_USAGE_TYPE_LOW
,
1141 BUFFER_USAGE_TYPE_HIGH
,
1144 static int register_buffer_usage_notify_trigger(const char *session_name
,
1145 const char *channel_name
,
1146 const enum lttng_domain_type domain_type
,
1147 enum buffer_usage_type buffer_usage_type
,
1149 struct lttng_condition
**condition
,
1150 struct lttng_action
**action
,
1151 struct lttng_trigger
**trigger
)
1153 enum lttng_condition_status condition_status
;
1154 struct lttng_action
*tmp_action
= NULL
;
1155 struct lttng_condition
*tmp_condition
= NULL
;
1156 struct lttng_trigger
*tmp_trigger
= NULL
;
1160 tmp_action
= lttng_action_notify_create();
1162 fail("Setup error on action creation");
1167 if (buffer_usage_type
== BUFFER_USAGE_TYPE_LOW
) {
1168 tmp_condition
= lttng_condition_buffer_usage_low_create();
1170 tmp_condition
= lttng_condition_buffer_usage_high_create();
1173 if (!tmp_condition
) {
1174 fail("Setup error on condition creation");
1179 /* Set the buffer usage threashold */
1180 condition_status
= lttng_condition_buffer_usage_set_threshold_ratio(
1181 tmp_condition
, ratio
);
1182 if (condition_status
!= LTTNG_CONDITION_STATUS_OK
) {
1183 fail("Setup error on condition creation");
1188 ret
= setup_buffer_usage_condition(tmp_condition
, "condition_name",
1189 session_name
, channel_name
, domain_type
);
1191 fail("Setup error on condition creation");
1196 /* Register the triggers for condition */
1197 tmp_trigger
= lttng_trigger_create(tmp_condition
, tmp_action
);
1199 fail("Setup error on trigger creation");
1204 ret
= lttng_register_trigger(tmp_trigger
);
1206 fail("Setup error on trigger registration");
1211 *condition
= tmp_condition
;
1212 *trigger
= tmp_trigger
;
1213 *action
= tmp_action
;
1217 lttng_action_destroy(tmp_action
);
1218 lttng_condition_destroy(tmp_condition
);
1219 lttng_trigger_destroy(tmp_trigger
);
1225 static void test_subscription_twice(const char *session_name
,
1226 const char *channel_name
,
1227 const enum lttng_domain_type domain_type
)
1230 enum lttng_notification_channel_status nc_status
;
1232 struct lttng_action
*action
= NULL
;
1233 struct lttng_notification_channel
*notification_channel
= NULL
;
1234 struct lttng_trigger
*trigger
= NULL
;
1236 struct lttng_condition
*condition
= NULL
;
1238 ret
= register_buffer_usage_notify_trigger(session_name
, channel_name
,
1239 domain_type
, BUFFER_USAGE_TYPE_LOW
, 0.99, &condition
,
1242 fail("Setup error on trigger registration");
1246 /* Begin testing. */
1247 notification_channel
= lttng_notification_channel_create(
1248 lttng_session_daemon_notification_endpoint
);
1249 ok(notification_channel
, "Notification channel object creation");
1250 if (!notification_channel
) {
1254 /* Subscribe a valid condition. */
1255 nc_status
= lttng_notification_channel_subscribe(
1256 notification_channel
, condition
);
1257 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
,
1258 "Subscribe to condition");
1260 /* Subscribing again should fail. */
1261 nc_status
= lttng_notification_channel_subscribe(
1262 notification_channel
, condition
);
1263 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_ALREADY_SUBSCRIBED
,
1264 "Subscribe to a condition for which subscription was already done");
1267 lttng_unregister_trigger(trigger
);
1268 lttng_trigger_destroy(trigger
);
1269 lttng_notification_channel_destroy(notification_channel
);
1270 lttng_action_destroy(action
);
1271 lttng_condition_destroy(condition
);
1274 static void test_buffer_usage_notification_channel(const char *session_name
,
1275 const char *channel_name
,
1276 const enum lttng_domain_type domain_type
,
1280 enum lttng_notification_channel_status nc_status
;
1282 struct lttng_action
*low_action
= NULL
;
1283 struct lttng_action
*high_action
= NULL
;
1284 struct lttng_notification
*notification
= NULL
;
1285 struct lttng_notification_channel
*notification_channel
= NULL
;
1286 struct lttng_trigger
*low_trigger
= NULL
;
1287 struct lttng_trigger
*high_trigger
= NULL
;
1289 struct lttng_condition
*low_condition
= NULL
;
1290 struct lttng_condition
*high_condition
= NULL
;
1292 double low_ratio
= 0.0;
1293 /* This is not 99 since we can end up in scenario where an event is
1294 * bigger than 1% of the buffer and hence the buffer ratio will never
1295 * trigger since the event will always be discarder by the tracer.
1298 double high_ratio
= 0.90;
1300 ret
= register_buffer_usage_notify_trigger(session_name
, channel_name
,
1301 domain_type
, BUFFER_USAGE_TYPE_LOW
, low_ratio
,
1302 &low_condition
, &low_action
, &low_trigger
);
1304 fail("Setup error on low trigger registration");
1308 ret
= register_buffer_usage_notify_trigger(session_name
, channel_name
,
1309 domain_type
, BUFFER_USAGE_TYPE_HIGH
, high_ratio
,
1310 &high_condition
, &high_action
, &high_trigger
);
1312 fail("Setup error on high trigger registration");
1317 notification_channel
= lttng_notification_channel_create(
1318 lttng_session_daemon_notification_endpoint
);
1319 ok(notification_channel
, "Notification channel object creation");
1320 if (!notification_channel
) {
1324 /* Subscribe a valid low condition */
1325 nc_status
= lttng_notification_channel_subscribe(
1326 notification_channel
, low_condition
);
1327 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
,
1328 "Subscribe to low condition");
1330 /* Subscribe a valid high condition */
1331 nc_status
= lttng_notification_channel_subscribe(
1332 notification_channel
, high_condition
);
1333 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
,
1334 "Subscribe to high condition");
1336 resume_application();
1338 /* Wait for notification to happen */
1339 stop_consumer(argv
);
1340 lttng_start_tracing(session_name
);
1342 /* Wait for high notification */
1344 nc_status
= lttng_notification_channel_get_next_notification(
1345 notification_channel
, ¬ification
);
1346 } while (nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_INTERRUPTED
);
1347 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
&& notification
&&
1348 lttng_condition_get_type(lttng_notification_get_condition(
1350 LTTNG_CONDITION_TYPE_BUFFER_USAGE_HIGH
,
1351 "High notification received after intermediary communication");
1352 lttng_notification_destroy(notification
);
1353 notification
= NULL
;
1355 suspend_application();
1356 lttng_stop_tracing_no_wait(session_name
);
1357 resume_consumer(argv
);
1358 wait_data_pending(session_name
);
1361 * Test that communication still work even if there is notification
1362 * waiting for consumption.
1365 nc_status
= lttng_notification_channel_unsubscribe(
1366 notification_channel
, low_condition
);
1367 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
,
1368 "Unsubscribe with pending notification");
1370 nc_status
= lttng_notification_channel_subscribe(
1371 notification_channel
, low_condition
);
1372 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
,
1373 "Subscribe with pending notification");
1376 nc_status
= lttng_notification_channel_get_next_notification(
1377 notification_channel
, ¬ification
);
1378 } while (nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_INTERRUPTED
);
1379 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
&& notification
&&
1380 lttng_condition_get_type(lttng_notification_get_condition(
1382 LTTNG_CONDITION_TYPE_BUFFER_USAGE_LOW
,
1383 "Low notification received after intermediary communication");
1384 lttng_notification_destroy(notification
);
1385 notification
= NULL
;
1387 /* Stop consumer to force a high notification */
1388 stop_consumer(argv
);
1389 resume_application();
1390 lttng_start_tracing(session_name
);
1393 nc_status
= lttng_notification_channel_get_next_notification(
1394 notification_channel
, ¬ification
);
1395 } while (nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_INTERRUPTED
);
1396 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
&& notification
&&
1397 lttng_condition_get_type(lttng_notification_get_condition(
1399 LTTNG_CONDITION_TYPE_BUFFER_USAGE_HIGH
,
1400 "High notification received after intermediary communication");
1401 lttng_notification_destroy(notification
);
1402 notification
= NULL
;
1404 suspend_application();
1405 lttng_stop_tracing_no_wait(session_name
);
1406 resume_consumer(argv
);
1407 wait_data_pending(session_name
);
1410 nc_status
= lttng_notification_channel_get_next_notification(
1411 notification_channel
, ¬ification
);
1412 } while (nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_INTERRUPTED
);
1413 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
&& notification
&&
1414 lttng_condition_get_type(lttng_notification_get_condition(
1416 LTTNG_CONDITION_TYPE_BUFFER_USAGE_LOW
,
1417 "Low notification received after re-subscription");
1418 lttng_notification_destroy(notification
);
1419 notification
= NULL
;
1421 stop_consumer(argv
);
1422 resume_application();
1423 /* Stop consumer to force a high notification */
1424 lttng_start_tracing(session_name
);
1427 nc_status
= lttng_notification_channel_get_next_notification(
1428 notification_channel
, ¬ification
);
1429 } while (nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_INTERRUPTED
);
1430 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
&& notification
&&
1431 lttng_condition_get_type(lttng_notification_get_condition(
1433 LTTNG_CONDITION_TYPE_BUFFER_USAGE_HIGH
,
1434 "High notification");
1435 lttng_notification_destroy(notification
);
1436 notification
= NULL
;
1438 suspend_application();
1440 /* Resume consumer to allow event consumption */
1441 lttng_stop_tracing_no_wait(session_name
);
1442 resume_consumer(argv
);
1443 wait_data_pending(session_name
);
1445 nc_status
= lttng_notification_channel_unsubscribe(
1446 notification_channel
, low_condition
);
1447 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
,
1448 "Unsubscribe low condition with pending notification");
1450 nc_status
= lttng_notification_channel_unsubscribe(
1451 notification_channel
, high_condition
);
1452 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
,
1453 "Unsubscribe high condition with pending notification");
1456 lttng_notification_channel_destroy(notification_channel
);
1457 lttng_trigger_destroy(low_trigger
);
1458 lttng_trigger_destroy(high_trigger
);
1459 lttng_action_destroy(low_action
);
1460 lttng_action_destroy(high_action
);
1461 lttng_condition_destroy(low_condition
);
1462 lttng_condition_destroy(high_condition
);
1465 static void create_tracepoint_event_rule_trigger(const char *event_pattern
,
1466 const char *trigger_name
,
1468 unsigned int exclusion_count
,
1469 const char **exclusions
,
1470 enum lttng_domain_type domain_type
,
1471 condition_capture_desc_cb capture_desc_cb
,
1472 struct lttng_condition
**condition
,
1473 struct lttng_action
**action
,
1474 struct lttng_trigger
**trigger
)
1476 enum lttng_event_rule_status event_rule_status
;
1477 enum lttng_trigger_status trigger_status
;
1479 struct lttng_action
*tmp_action
= NULL
;
1480 struct lttng_event_rule
*event_rule
= NULL
;
1481 struct lttng_condition
*tmp_condition
= NULL
;
1482 struct lttng_trigger
*tmp_trigger
= NULL
;
1485 assert(event_pattern
);
1486 assert(trigger_name
);
1490 event_rule
= lttng_event_rule_tracepoint_create(domain_type
);
1491 ok(event_rule
, "Tracepoint event rule object creation");
1493 event_rule_status
= lttng_event_rule_tracepoint_set_pattern(
1494 event_rule
, event_pattern
);
1495 ok(event_rule_status
== LTTNG_EVENT_RULE_STATUS_OK
,
1496 "Setting tracepoint event rule pattern: %s",
1500 event_rule_status
= lttng_event_rule_tracepoint_set_filter(
1501 event_rule
, filter
);
1502 ok(event_rule_status
== LTTNG_EVENT_RULE_STATUS_OK
,
1503 "Setting tracepoint event rule filter: %s",
1509 bool success
= true;
1510 assert(domain_type
== LTTNG_DOMAIN_UST
);
1511 assert(exclusion_count
> 0);
1513 for (i
= 0; i
< exclusion_count
; i
++) {
1515 lttng_event_rule_tracepoint_add_exclusion(
1518 if (event_rule_status
!= LTTNG_EVENT_RULE_STATUS_OK
) {
1519 fail("Setting tracepoint event rule exclusion \"%s\".",
1524 ok(success
, "Setting tracepoint event rule exclusions");
1527 tmp_condition
= lttng_condition_event_rule_create(event_rule
);
1528 ok(tmp_condition
, "Condition event rule object creation");
1530 if (capture_desc_cb
) {
1531 ret
= capture_desc_cb(tmp_condition
);
1533 assert("Generating the condition capture descriptor");
1537 tmp_action
= lttng_action_notify_create();
1538 ok(tmp_action
, "Action event rule object creation");
1540 tmp_trigger
= lttng_trigger_create(tmp_condition
, tmp_action
);
1541 ok(tmp_trigger
, "Trigger object creation %s", trigger_name
);
1543 trigger_status
= lttng_trigger_set_name(tmp_trigger
, trigger_name
);
1544 ok(trigger_status
== LTTNG_TRIGGER_STATUS_OK
,
1545 "Setting name to trigger %s", trigger_name
);
1547 ret
= lttng_register_trigger(tmp_trigger
);
1548 ok(ret
== 0, "Trigger registration %s", trigger_name
);
1550 lttng_event_rule_destroy(event_rule
);
1552 *condition
= tmp_condition
;
1553 *action
= tmp_action
;
1554 *trigger
= tmp_trigger
;
1559 static struct lttng_notification
*get_next_notification(
1560 struct lttng_notification_channel
*notification_channel
)
1562 struct lttng_notification
*local_notification
= NULL
;
1563 enum lttng_notification_channel_status status
;
1565 /* Receive the next notification. */
1566 status
= lttng_notification_channel_get_next_notification(
1567 notification_channel
, &local_notification
);
1570 case LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
:
1572 case LTTNG_NOTIFICATION_CHANNEL_STATUS_NOTIFICATIONS_DROPPED
:
1573 fail("Notifications have been dropped");
1574 local_notification
= NULL
;
1577 /* Unhandled conditions / errors. */
1578 fail("error: Unknown notification channel status\n");
1579 local_notification
= NULL
;
1583 return local_notification
;
1586 static void test_tracepoint_event_rule_notification(
1587 enum lttng_domain_type domain_type
)
1591 enum lttng_notification_channel_status nc_status
;
1593 struct lttng_action
*action
= NULL
;
1594 struct lttng_condition
*condition
= NULL
;
1595 struct lttng_notification_channel
*notification_channel
= NULL
;
1596 struct lttng_trigger
*trigger
= NULL
;
1597 const char *trigger_name
= "my_precious";
1598 const char *pattern
;
1600 if (domain_type
== LTTNG_DOMAIN_UST
) {
1601 pattern
= "tp:tptest";
1603 pattern
= "lttng_test_filter_event";
1606 create_tracepoint_event_rule_trigger(pattern
, trigger_name
, NULL
, 0,
1607 NULL
, domain_type
, NULL
, &condition
, &action
, &trigger
);
1609 notification_channel
= lttng_notification_channel_create(
1610 lttng_session_daemon_notification_endpoint
);
1611 ok(notification_channel
, "Notification channel object creation");
1613 nc_status
= lttng_notification_channel_subscribe(
1614 notification_channel
, condition
);
1615 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
,
1616 "Subscribe to tracepoint event rule condition");
1618 resume_application();
1620 /* Get 3 notifications */
1621 for (i
= 0; i
< 3; i
++) {
1622 struct lttng_notification
*notification
= get_next_notification(
1623 notification_channel
);
1624 ok(notification
, "Received notification");
1627 if (notification
== NULL
) {
1631 ret
= validator_notification_trigger_name(notification
, trigger_name
);
1632 lttng_notification_destroy(notification
);
1639 suspend_application();
1640 lttng_notification_channel_destroy(notification_channel
);
1641 lttng_unregister_trigger(trigger
);
1642 lttng_trigger_destroy(trigger
);
1643 lttng_action_destroy(action
);
1644 lttng_condition_destroy(condition
);
1648 static void test_tracepoint_event_rule_notification_filter(
1649 enum lttng_domain_type domain_type
)
1652 enum lttng_notification_channel_status nc_status
;
1654 struct lttng_condition
*ctrl_condition
= NULL
, *condition
= NULL
;
1655 struct lttng_action
*ctrl_action
= NULL
, *action
= NULL
;
1656 struct lttng_notification_channel
*notification_channel
= NULL
;
1657 struct lttng_trigger
*ctrl_trigger
= NULL
, *trigger
= NULL
;
1658 const char *ctrl_trigger_name
= "control_trigger";
1659 const char *trigger_name
= "trigger";
1660 const char *pattern
;
1661 int ctrl_count
= 0, count
= 0;
1663 if (domain_type
== LTTNG_DOMAIN_UST
) {
1664 pattern
= "tp:tptest";
1666 pattern
= "lttng_test_filter_event";
1669 notification_channel
= lttng_notification_channel_create(
1670 lttng_session_daemon_notification_endpoint
);
1671 ok(notification_channel
, "Notification channel object creation");
1673 create_tracepoint_event_rule_trigger(pattern
, ctrl_trigger_name
, NULL
,
1674 0, NULL
, domain_type
, NULL
, &ctrl_condition
,
1675 &ctrl_action
, &ctrl_trigger
);
1677 nc_status
= lttng_notification_channel_subscribe(
1678 notification_channel
, ctrl_condition
);
1679 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
,
1680 "Subscribe to tracepoint event rule condition");
1683 * Attach a filter expression to get notification only if the
1684 * `intfield` is even.
1686 create_tracepoint_event_rule_trigger(pattern
, trigger_name
,
1687 "(intfield & 1) == 0", 0, NULL
, domain_type
, NULL
,
1688 &condition
, &action
, &trigger
);
1690 nc_status
= lttng_notification_channel_subscribe(
1691 notification_channel
, condition
);
1692 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
,
1693 "Subscribe to tracepoint event rule condition");
1696 * We registered 2 notifications triggers, one with a filter and one
1697 * without (control). The one with a filter will only fired when the
1698 * `intfield` is a multiple of 2. We should get two times as many
1699 * control notifications as filter notifications.
1701 resume_application();
1704 * Get 3 notifications. We should get 1 for the regular trigger (with
1705 * the filter) and 2 from the control trigger. This works whatever
1706 * the order we receive the notifications.
1708 for (i
= 0; i
< 3; i
++) {
1710 struct lttng_notification
*notification
= get_next_notification(
1711 notification_channel
);
1712 ok(notification
, "Received notification");
1715 if (notification
== NULL
) {
1719 name
= get_notification_trigger_name(notification
);
1721 lttng_notification_destroy(notification
);
1725 if (strcmp(ctrl_trigger_name
, name
) == 0) {
1727 } else if (strcmp(trigger_name
, name
) == 0) {
1730 lttng_notification_destroy(notification
);
1732 ok(ctrl_count
/ 2 == count
,
1733 "Get twice as many control notif as of regular notif");
1736 suspend_application();
1737 lttng_unregister_trigger(trigger
);
1738 lttng_unregister_trigger(ctrl_trigger
);
1739 lttng_notification_channel_destroy(notification_channel
);
1740 lttng_trigger_destroy(trigger
);
1741 lttng_trigger_destroy(ctrl_trigger
);
1742 lttng_condition_destroy(condition
);
1743 lttng_condition_destroy(ctrl_condition
);
1744 lttng_action_destroy(action
);
1745 lttng_action_destroy(ctrl_action
);
1749 static void test_tracepoint_event_rule_notification_exclusion(
1750 enum lttng_domain_type domain_type
)
1752 enum lttng_notification_channel_status nc_status
;
1753 struct lttng_condition
*ctrl_condition
= NULL
, *condition
= NULL
;
1754 struct lttng_action
*ctrl_action
= NULL
, *action
= NULL
;
1755 struct lttng_notification_channel
*notification_channel
= NULL
;
1756 struct lttng_trigger
*ctrl_trigger
= NULL
, *trigger
= NULL
;
1757 const char *ctrl_trigger_name
= "control_exclusion_trigger";
1758 const char *trigger_name
= "exclusion_trigger";
1759 const char *pattern
= "tp:tptest*";
1760 const char *exclusions
[4] = {
1761 "tp:tptest2", "tp:tptest3", "tp:tptest4", "tp:tptest5"};
1762 int ctrl_count
= 0, count
= 0;
1765 notification_channel
= lttng_notification_channel_create(
1766 lttng_session_daemon_notification_endpoint
);
1767 ok(notification_channel
, "Notification channel object creation");
1769 create_tracepoint_event_rule_trigger(pattern
, ctrl_trigger_name
, NULL
,
1770 0, NULL
, domain_type
, NULL
, &ctrl_condition
,
1771 &ctrl_action
, &ctrl_trigger
);
1773 nc_status
= lttng_notification_channel_subscribe(
1774 notification_channel
, ctrl_condition
);
1775 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
,
1776 "Subscribe to tracepoint event rule condition");
1778 create_tracepoint_event_rule_trigger(pattern
, trigger_name
, NULL
, 4,
1779 exclusions
, domain_type
, NULL
, &condition
, &action
,
1782 nc_status
= lttng_notification_channel_subscribe(
1783 notification_channel
, condition
);
1784 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
,
1785 "Subscribe to tracepoint event rule condition");
1788 * We registered 2 notifications triggers, one with an exclusion and
1789 * one without (control).
1790 * - The trigger with an exclusion will fire once every iteration.
1791 * - The trigger without an exclusion will fire 5 times every
1794 * We should get 5 times as many notifications from the control
1797 resume_application();
1800 * Get 6 notifications. We should get 1 for the regular trigger (with
1801 * the exclusion) and 5 from the control trigger. This works whatever
1802 * the order we receive the notifications.
1804 for (i
= 0; i
< 6; i
++) {
1806 struct lttng_notification
*notification
= get_next_notification(
1807 notification_channel
);
1808 ok(notification
, "Received notification");
1811 if (notification
== NULL
) {
1815 name
= get_notification_trigger_name(notification
);
1817 lttng_notification_destroy(notification
);
1821 if (strcmp(ctrl_trigger_name
, name
) == 0) {
1823 } else if (strcmp(trigger_name
, name
) == 0) {
1826 lttng_notification_destroy(notification
);
1828 ok(ctrl_count
/ 5 == count
,
1829 "Got 5 times as many control notif as of regular notif");
1832 suspend_application();
1833 lttng_unregister_trigger(trigger
);
1834 lttng_unregister_trigger(ctrl_trigger
);
1835 lttng_notification_channel_destroy(notification_channel
);
1836 lttng_trigger_destroy(trigger
);
1837 lttng_trigger_destroy(ctrl_trigger
);
1838 lttng_condition_destroy(condition
);
1839 lttng_condition_destroy(ctrl_condition
);
1840 lttng_action_destroy(action
);
1841 lttng_action_destroy(ctrl_action
);
1845 static void test_kprobe_event_rule_notification(
1846 enum lttng_domain_type domain_type
)
1848 enum lttng_notification_channel_status nc_status
;
1849 enum lttng_event_rule_status event_rule_status
;
1850 enum lttng_trigger_status trigger_status
;
1852 struct lttng_notification_channel
*notification_channel
= NULL
;
1853 struct lttng_condition
*condition
= NULL
;
1854 struct lttng_kernel_probe_location
*location
= NULL
;
1855 struct lttng_event_rule
*event_rule
= NULL
;
1856 struct lttng_action
*action
= NULL
;
1857 struct lttng_trigger
*trigger
= NULL
;
1858 const char *trigger_name
= "kprobe_trigger";
1859 const char *symbol_name
= "_do_fork";
1862 action
= lttng_action_notify_create();
1864 fail("Setup error on action creation");
1868 location
= lttng_kernel_probe_location_symbol_create(symbol_name
, 0);
1870 fail("Could not create kernel probe location.");
1874 notification_channel
= lttng_notification_channel_create(
1875 lttng_session_daemon_notification_endpoint
);
1876 ok(notification_channel
, "Notification channel object creation");
1878 event_rule
= lttng_event_rule_kprobe_create();
1879 ok(event_rule
, "kprobe event rule object creation");
1881 event_rule_status
= lttng_event_rule_kprobe_set_location(
1882 event_rule
, location
);
1883 ok(event_rule_status
== LTTNG_EVENT_RULE_STATUS_OK
,
1884 "Setting kprobe event rule location: %s", symbol_name
);
1886 event_rule_status
= lttng_event_rule_kprobe_set_name(
1887 event_rule
, trigger_name
);
1888 ok(event_rule_status
== LTTNG_EVENT_RULE_STATUS_OK
,
1889 "Setting kprobe event rule name: %s", trigger_name
);
1891 condition
= lttng_condition_event_rule_create(event_rule
);
1892 ok(condition
, "Condition event rule object creation");
1894 /* Register the triggers for condition */
1895 trigger
= lttng_trigger_create(condition
, action
);
1897 fail("Setup error on trigger creation");
1901 trigger_status
= lttng_trigger_set_name(trigger
, trigger_name
);
1902 ok(trigger_status
== LTTNG_TRIGGER_STATUS_OK
,
1903 "Setting name to trigger %s", trigger_name
);
1905 ret
= lttng_register_trigger(trigger
);
1907 fail("Setup error on trigger registration");
1911 nc_status
= lttng_notification_channel_subscribe(
1912 notification_channel
, condition
);
1913 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
,
1914 "Subscribe to tracepoint event rule condition");
1916 resume_application();
1918 for (i
= 0; i
< 3; i
++) {
1919 struct lttng_notification
*notification
= get_next_notification(
1920 notification_channel
);
1921 ok(notification
, "Received notification");
1924 if (notification
== NULL
) {
1928 ret
= validator_notification_trigger_name(notification
, trigger_name
);
1929 lttng_notification_destroy(notification
);
1936 suspend_application();
1937 lttng_notification_channel_destroy(notification_channel
);
1938 lttng_unregister_trigger(trigger
);
1939 lttng_trigger_destroy(trigger
);
1940 lttng_action_destroy(action
);
1941 lttng_event_rule_destroy(event_rule
);
1942 lttng_condition_destroy(condition
);
1943 lttng_kernel_probe_location_destroy(location
);
1947 static void test_uprobe_event_rule_notification(
1948 enum lttng_domain_type domain_type
,
1949 const char *testapp_path
,
1950 const char *test_symbol_name
)
1952 enum lttng_notification_channel_status nc_status
;
1953 enum lttng_event_rule_status event_rule_status
;
1954 enum lttng_trigger_status trigger_status
;
1956 struct lttng_notification_channel
*notification_channel
= NULL
;
1957 struct lttng_userspace_probe_location
*probe_location
= NULL
;
1958 struct lttng_userspace_probe_location_lookup_method
*lookup_method
=
1960 struct lttng_condition
*condition
= NULL
;
1961 struct lttng_event_rule
*event_rule
= NULL
;
1962 struct lttng_action
*action
= NULL
;
1963 struct lttng_trigger
*trigger
= NULL
;
1964 const char *trigger_name
= "uprobe_trigger";
1967 action
= lttng_action_notify_create();
1969 fail("Setup error on action creation");
1973 lookup_method
= lttng_userspace_probe_location_lookup_method_function_elf_create();
1974 if (!lookup_method
) {
1975 fail("Setup error on userspace probe lookup method creation");
1979 probe_location
= lttng_userspace_probe_location_function_create(
1980 testapp_path
, test_symbol_name
, lookup_method
);
1981 if (!probe_location
) {
1982 fail("Setup error on userspace probe location creation");
1986 notification_channel
= lttng_notification_channel_create(
1987 lttng_session_daemon_notification_endpoint
);
1988 ok(notification_channel
, "Notification channel object creation");
1990 event_rule
= lttng_event_rule_uprobe_create();
1991 ok(event_rule
, "kprobe event rule object creation");
1993 event_rule_status
= lttng_event_rule_uprobe_set_location(
1994 event_rule
, probe_location
);
1995 ok(event_rule_status
== LTTNG_EVENT_RULE_STATUS_OK
,
1996 "Setting uprobe event rule location");
1998 event_rule_status
= lttng_event_rule_uprobe_set_name(
1999 event_rule
, trigger_name
);
2000 ok(event_rule_status
== LTTNG_EVENT_RULE_STATUS_OK
,
2001 "Setting uprobe event rule name: %s", trigger_name
);
2003 condition
= lttng_condition_event_rule_create(event_rule
);
2004 ok(condition
, "Condition event rule object creation");
2006 /* Register the triggers for condition */
2007 trigger
= lttng_trigger_create(condition
, action
);
2009 fail("Setup error on trigger creation");
2013 trigger_status
= lttng_trigger_set_name(trigger
, trigger_name
);
2014 ok(trigger_status
== LTTNG_TRIGGER_STATUS_OK
,
2015 "Setting name to trigger %s", trigger_name
);
2017 ret
= lttng_register_trigger(trigger
);
2019 fail("Setup error on trigger registration");
2023 nc_status
= lttng_notification_channel_subscribe(
2024 notification_channel
, condition
);
2025 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
,
2026 "Subscribe to tracepoint event rule condition");
2028 resume_application();
2030 for (i
= 0; i
< 3; i
++) {
2031 struct lttng_notification
*notification
= get_next_notification(
2032 notification_channel
);
2033 ok(notification
, "Received notification");
2036 if (notification
== NULL
) {
2040 ret
= validator_notification_trigger_name(notification
, trigger_name
);
2041 lttng_notification_destroy(notification
);
2047 suspend_application();
2048 lttng_notification_channel_destroy(notification_channel
);
2049 lttng_unregister_trigger(trigger
);
2050 lttng_trigger_destroy(trigger
);
2051 lttng_action_destroy(action
);
2052 lttng_event_rule_destroy(event_rule
);
2053 lttng_condition_destroy(condition
);
2057 static void test_syscall_event_rule_notification(
2058 enum lttng_domain_type domain_type
)
2060 enum lttng_notification_channel_status nc_status
;
2061 enum lttng_event_rule_status event_rule_status
;
2062 enum lttng_trigger_status trigger_status
;
2064 struct lttng_notification_channel
*notification_channel
= NULL
;
2065 struct lttng_condition
*condition
= NULL
;
2066 struct lttng_event_rule
*event_rule
= NULL
;
2067 struct lttng_action
*action
= NULL
;
2068 struct lttng_trigger
*trigger
= NULL
;
2069 const char *trigger_name
= "syscall_trigger";
2070 const char *syscall_name
= "openat";
2073 action
= lttng_action_notify_create();
2075 fail("Setup error on action creation");
2079 notification_channel
= lttng_notification_channel_create(
2080 lttng_session_daemon_notification_endpoint
);
2081 ok(notification_channel
, "Notification channel object creation");
2083 event_rule
= lttng_event_rule_syscall_create();
2084 ok(event_rule
, "syscall event rule object creation");
2086 event_rule_status
= lttng_event_rule_syscall_set_pattern(
2087 event_rule
, syscall_name
);
2088 ok(event_rule_status
== LTTNG_EVENT_RULE_STATUS_OK
,
2089 "Setting syscall event rule pattern: %s", syscall_name
);
2091 condition
= lttng_condition_event_rule_create(event_rule
);
2092 ok(condition
, "Condition event rule object creation");
2094 /* Register the triggers for condition */
2095 trigger
= lttng_trigger_create(condition
, action
);
2097 fail("Setup error on trigger creation");
2101 trigger_status
= lttng_trigger_set_name(trigger
, trigger_name
);
2102 ok(trigger_status
== LTTNG_TRIGGER_STATUS_OK
,
2103 "Setting name to trigger %s", trigger_name
);
2105 ret
= lttng_register_trigger(trigger
);
2107 fail("Setup error on trigger registration");
2111 nc_status
= lttng_notification_channel_subscribe(
2112 notification_channel
, condition
);
2113 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
,
2114 "Subscribe to tracepoint event rule condition");
2116 resume_application();
2118 for (i
= 0; i
< 3; i
++) {
2119 struct lttng_notification
*notification
= get_next_notification(
2120 notification_channel
);
2121 ok(notification
, "Received notification");
2124 if (notification
== NULL
) {
2128 ret
= validator_notification_trigger_name(notification
, trigger_name
);
2129 lttng_notification_destroy(notification
);
2135 suspend_application();
2136 lttng_notification_channel_destroy(notification_channel
);
2137 lttng_unregister_trigger(trigger
);
2138 lttng_trigger_destroy(trigger
);
2139 lttng_action_destroy(action
);
2140 lttng_condition_destroy(condition
);
2144 static void test_syscall_event_rule_notification_filter(
2145 enum lttng_domain_type domain_type
)
2147 enum lttng_notification_channel_status nc_status
;
2148 enum lttng_event_rule_status event_rule_status
;
2149 enum lttng_trigger_status trigger_status
;
2151 struct lttng_notification_channel
*notification_channel
= NULL
;
2152 struct lttng_condition
*condition
= NULL
;
2153 struct lttng_event_rule
*event_rule
= NULL
;
2154 struct lttng_action
*action
= NULL
;
2155 struct lttng_trigger
*trigger
= NULL
;
2156 const char *trigger_name
= "syscall_trigger";
2157 const char *syscall_name
= "openat";
2160 action
= lttng_action_notify_create();
2162 fail("Setup error on action creation");
2166 notification_channel
= lttng_notification_channel_create(
2167 lttng_session_daemon_notification_endpoint
);
2168 ok(notification_channel
, "Notification channel object creation");
2170 event_rule
= lttng_event_rule_syscall_create();
2171 ok(event_rule
, "syscall event rule object creation");
2173 event_rule_status
= lttng_event_rule_syscall_set_pattern(
2174 event_rule
, syscall_name
);
2175 ok(event_rule_status
== LTTNG_EVENT_RULE_STATUS_OK
,
2176 "Setting syscall event rule pattern: %s", syscall_name
);
2178 event_rule_status
= lttng_event_rule_syscall_set_filter(
2179 event_rule
, "filename==\"/proc/cpuinfo\"");
2180 ok(event_rule_status
== LTTNG_EVENT_RULE_STATUS_OK
,
2181 "Setting syscall event rule pattern: %s", syscall_name
);
2183 condition
= lttng_condition_event_rule_create(event_rule
);
2184 ok(condition
, "Condition event rule object creation");
2186 /* Register the triggers for condition */
2187 trigger
= lttng_trigger_create(condition
, action
);
2189 fail("Setup error on trigger creation");
2193 trigger_status
= lttng_trigger_set_name(trigger
, trigger_name
);
2194 ok(trigger_status
== LTTNG_TRIGGER_STATUS_OK
,
2195 "Setting name to trigger %s", trigger_name
);
2197 ret
= lttng_register_trigger(trigger
);
2199 fail("Setup error on trigger registration");
2203 nc_status
= lttng_notification_channel_subscribe(
2204 notification_channel
, condition
);
2205 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
,
2206 "Subscribe to tracepoint event rule condition");
2208 resume_application();
2210 for (i
= 0; i
< 3; i
++) {
2211 struct lttng_notification
*notification
= get_next_notification(
2212 notification_channel
);
2213 ok(notification
, "Received notification");
2216 if (notification
== NULL
) {
2220 ret
= validator_notification_trigger_name(notification
, trigger_name
);
2221 lttng_notification_destroy(notification
);
2228 suspend_application();
2229 lttng_unregister_trigger(trigger
);
2230 lttng_notification_channel_destroy(notification_channel
);
2231 lttng_trigger_destroy(trigger
);
2232 lttng_event_rule_destroy(event_rule
);
2233 lttng_condition_destroy(condition
);
2237 static int generate_capture_descr(struct lttng_condition
*condition
)
2240 struct lttng_event_expr
*expr
= NULL
;
2241 unsigned int basic_field_size
;
2242 enum lttng_condition_status cond_status
;
2244 basic_field_size
= sizeof(test_capture_base_fields
) / sizeof(*test_capture_base_fields
);
2245 for (int i
= 0; i
< basic_field_size
; i
++) {
2247 diag("Adding capture descriptor \"%s\"", test_capture_base_fields
[i
].field_name
);
2249 switch (test_capture_base_fields
[i
].field_type
) {
2250 case FIELD_TYPE_PAYLOAD
:
2251 expr
= lttng_event_expr_event_payload_field_create(
2252 test_capture_base_fields
[i
].field_name
);
2254 case FIELD_TYPE_CONTEXT
:
2255 expr
= lttng_event_expr_channel_context_field_create(
2256 test_capture_base_fields
[i
].field_name
);
2258 case FIELD_TYPE_ARRAY_FIELD
:
2262 char field_name
[256];
2263 struct lttng_event_expr
*array_expr
= NULL
;
2264 nb_matches
= sscanf(test_capture_base_fields
[i
].field_name
,
2265 "%[^[][%u]", field_name
, &index
);
2266 if (nb_matches
!= 2) {
2270 array_expr
= lttng_event_expr_event_payload_field_create(
2273 expr
= lttng_event_expr_array_field_element_create(
2277 case FIELD_TYPE_APP_CONTEXT
:
2278 fail("Application context not tested yet.");
2284 fail("Creating capture expression");
2288 cond_status
= lttng_condition_event_rule_append_capture_descriptor(
2290 if (cond_status
!= LTTNG_CONDITION_STATUS_OK
) {
2291 fail("Appending capture_descriptor");
2293 lttng_event_expr_destroy(expr
);
2304 static int validator_notification_trigger_capture(
2305 enum lttng_domain_type domain
,
2306 struct lttng_notification
*notification
,
2307 const int iteration
)
2310 unsigned int capture_count
, i
;
2311 enum lttng_evaluation_status evaluation_status
;
2312 enum lttng_event_field_value_status event_field_value_status
;
2313 const struct lttng_evaluation
*evaluation
;
2314 const struct lttng_event_field_value
*captured_fields
;
2315 bool at_least_one_error
= false;
2317 evaluation
= lttng_notification_get_evaluation(notification
);
2318 if (evaluation
== NULL
) {
2319 fail("lttng_notification_get_evaluation");
2324 /* TODO: it seems weird that lttng_evaluation_get_captured_values return
2325 * INVALID if no capture were present. might be better to return
2326 * something with more meaning. Another question is how we link the
2327 * notion of capture and the descriptor from the perspective of a
2328 * client. Is it really invalid to ask for captured value when there might
2331 evaluation_status
= lttng_evaluation_get_captured_values(evaluation
, &captured_fields
);
2332 if (evaluation_status
!= LTTNG_EVALUATION_STATUS_OK
) {
2333 diag("lttng_evaluation_get_captured_values");
2338 event_field_value_status
=
2339 lttng_event_field_value_array_get_length(captured_fields
,
2341 if (event_field_value_status
!= LTTNG_EVENT_FIELD_VALUE_STATUS_OK
) {
2342 assert(0 && "get count of captured field");
2345 for (i
= 0; i
< capture_count
; i
++) {
2346 const struct lttng_event_field_value
*captured_field
= NULL
;
2347 validate_cb validate
;
2350 diag("Validating capture \"%s\"", test_capture_base_fields
[i
].field_name
);
2351 event_field_value_status
= lttng_event_field_value_array_get_element_at_index(captured_fields
, i
, &captured_field
);
2354 case LTTNG_DOMAIN_UST
:
2355 expected
= test_capture_base_fields
[i
].expected_ust
;
2357 case LTTNG_DOMAIN_KERNEL
:
2358 expected
= test_capture_base_fields
[i
].expected_kernel
;
2361 assert(0 && "Domain invalid for this test");
2365 ok(event_field_value_status
== LTTNG_EVENT_FIELD_VALUE_STATUS_UNAVAILABLE
, "No payload captured");
2369 if (domain
== LTTNG_DOMAIN_UST
) {
2370 validate
= test_capture_base_fields
[i
].validate_ust
;
2372 validate
= test_capture_base_fields
[i
].validate_kernel
;
2375 if (event_field_value_status
!= LTTNG_EVENT_FIELD_VALUE_STATUS_OK
) {
2377 if (event_field_value_status
==
2378 LTTNG_EVENT_FIELD_VALUE_STATUS_UNAVAILABLE
) {
2379 reason
= "Expected a capture but it is unavailable";
2381 reason
= "lttng_event_field_value_array_get_element_at_index";
2387 diag("Captured field of type %s",
2388 field_value_type_to_str(
2389 lttng_event_field_value_get_type(captured_field
)));
2392 ret
= validate(captured_field
, iteration
);
2394 at_least_one_error
= true;
2398 ret
= at_least_one_error
;
2404 static void test_tracepoint_event_rule_notification_capture(
2405 enum lttng_domain_type domain_type
)
2407 enum lttng_notification_channel_status nc_status
;
2410 struct lttng_action
*action
= NULL
;
2411 struct lttng_condition
*condition
= NULL
;
2412 struct lttng_notification_channel
*notification_channel
= NULL
;
2413 struct lttng_trigger
*trigger
= NULL
;
2414 const char *trigger_name
= "my_precious";
2415 const char *pattern
;
2417 if (domain_type
== LTTNG_DOMAIN_UST
) {
2418 pattern
= "tp:tptest";
2420 pattern
= "lttng_test_filter_event";
2423 create_tracepoint_event_rule_trigger(pattern
, trigger_name
, NULL
, 0,
2424 NULL
, domain_type
, generate_capture_descr
, &condition
,
2427 notification_channel
= lttng_notification_channel_create(
2428 lttng_session_daemon_notification_endpoint
);
2429 ok(notification_channel
, "Notification channel object creation");
2431 nc_status
= lttng_notification_channel_subscribe(
2432 notification_channel
, condition
);
2433 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
,
2434 "Subscribe to tracepoint event rule condition");
2436 resume_application();
2438 /* Get 3 notifications */
2439 for (i
= 0; i
< 3; i
++) {
2440 struct lttng_notification
*notification
= get_next_notification(
2441 notification_channel
);
2442 ok(notification
, "Received notification");
2445 if (notification
== NULL
) {
2449 ret
= validator_notification_trigger_name(notification
, trigger_name
);
2451 lttng_notification_destroy(notification
);
2455 ret
= validator_notification_trigger_capture(domain_type
, notification
, i
);
2457 lttng_notification_destroy(notification
);
2461 lttng_notification_destroy(notification
);
2465 suspend_application();
2466 lttng_notification_channel_destroy(notification_channel
);
2467 lttng_unregister_trigger(trigger
);
2468 lttng_trigger_destroy(trigger
);
2469 lttng_action_destroy(action
);
2470 lttng_condition_destroy(condition
);
2474 int main(int argc
, const char *argv
[])
2477 const char *domain_type_string
= NULL
;
2478 enum lttng_domain_type domain_type
= LTTNG_DOMAIN_NONE
;
2481 fail("Missing test scenario, domain type, pid, or application state file argument(s)");
2485 test_scenario
= atoi(argv
[1]);
2486 domain_type_string
= argv
[2];
2487 app_pid
= (pid_t
) atoi(argv
[3]);
2488 app_state_file
= argv
[4];
2490 if (!strcmp("LTTNG_DOMAIN_UST", domain_type_string
)) {
2491 domain_type
= LTTNG_DOMAIN_UST
;
2493 if (!strcmp("LTTNG_DOMAIN_KERNEL", domain_type_string
)) {
2494 domain_type
= LTTNG_DOMAIN_KERNEL
;
2496 if (domain_type
== LTTNG_DOMAIN_NONE
) {
2497 fail("Unknown domain type");
2502 * Test cases are responsible for resuming the app when needed
2503 * and making sure it's suspended when returning.
2505 suspend_application();
2507 switch (test_scenario
) {
2512 /* Test cases that need gen-ust-event testapp. */
2513 diag("Test basic notification error paths for domain %s",
2514 domain_type_string
);
2515 test_invalid_channel_subscription(domain_type
);
2517 diag("Test tracepoint event rule notifications for domain %s",
2518 domain_type_string
);
2519 test_tracepoint_event_rule_notification(domain_type
);
2521 diag("Test tracepoint event rule notifications with filter for domain %s",
2522 domain_type_string
);
2523 test_tracepoint_event_rule_notification_filter(domain_type
);
2528 const char *session_name
, *channel_name
;
2529 /* Test cases that need a tracing session enabled. */
2533 * Argument 7 and upward are named pipe location for consumerd
2536 named_pipe_args_start
= 7;
2539 fail("Missing parameter for tests to run %d", argc
);
2545 session_name
= argv
[5];
2546 channel_name
= argv
[6];
2548 test_subscription_twice(session_name
, channel_name
,
2551 diag("Test trigger for domain %s with buffer_usage_low condition",
2552 domain_type_string
);
2553 test_triggers_buffer_usage_condition(session_name
, channel_name
,
2555 LTTNG_CONDITION_TYPE_BUFFER_USAGE_LOW
);
2557 diag("Test trigger for domain %s with buffer_usage_high condition",
2558 domain_type_string
);
2559 test_triggers_buffer_usage_condition(session_name
, channel_name
,
2561 LTTNG_CONDITION_TYPE_BUFFER_USAGE_HIGH
);
2563 diag("Test buffer usage notification channel api for domain %s",
2564 domain_type_string
);
2565 test_buffer_usage_notification_channel(session_name
, channel_name
,
2572 * Test cases that need a test app with more than one event
2578 * At the moment, the only test case of this scenario is
2579 * exclusion which is only supported by UST
2581 assert(domain_type
== LTTNG_DOMAIN_UST
);
2582 diag("Test tracepoint event rule notifications with exclusion for domain %s",
2583 domain_type_string
);
2584 test_tracepoint_event_rule_notification_exclusion(domain_type
);
2591 /* Test cases that need the kernel tracer. */
2592 assert(domain_type
== LTTNG_DOMAIN_KERNEL
);
2594 diag("Test kprobe event rule notifications for domain %s",
2595 domain_type_string
);
2597 test_kprobe_event_rule_notification(domain_type
);
2604 /* Test cases that need the kernel tracer. */
2605 assert(domain_type
== LTTNG_DOMAIN_KERNEL
);
2607 diag("Test syscall event rule notifications for domain %s",
2608 domain_type_string
);
2610 test_syscall_event_rule_notification(domain_type
);
2612 diag("Test syscall filtering event rule notifications for domain %s",
2613 domain_type_string
);
2615 test_syscall_event_rule_notification_filter(domain_type
);
2621 const char *testapp_path
, *test_symbol_name
;
2626 fail("Missing parameter for tests to run %d", argc
);
2630 testapp_path
= argv
[5];
2631 test_symbol_name
= argv
[6];
2632 /* Test cases that need the kernel tracer. */
2633 assert(domain_type
== LTTNG_DOMAIN_KERNEL
);
2635 diag("Test userspace-probe event rule notifications for domain %s",
2636 domain_type_string
);
2638 test_uprobe_event_rule_notification(
2639 domain_type
, testapp_path
, test_symbol_name
);
2645 switch(domain_type
) {
2646 case LTTNG_DOMAIN_UST
:
2649 case LTTNG_DOMAIN_KERNEL
:
2656 diag("Test tracepoint event rule notification captures for domain %s",
2657 domain_type_string
);
2658 test_tracepoint_event_rule_notification_capture(domain_type
);
2668 return exit_status();