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>
26 #include <common/compat/errno.h>
27 #include <lttng/lttng.h>
31 /* A callback to populate the condition capture descriptor */
32 typedef int (*condition_capture_desc_cb
)(struct lttng_condition
*condition
);
34 /* A callback for captured field validation */
35 typedef int (*validate_cb
)(const struct lttng_event_field_value
*event_field
, unsigned iteration
);
38 int named_pipe_args_start
= 0;
40 const char *app_state_file
= NULL
;
45 FIELD_TYPE_APP_CONTEXT
,
46 FIELD_TYPE_ARRAY_FIELD
,
49 struct capture_base_field_tuple
{
51 enum field_type field_type
;
52 bool expected_ust
; // Do we expect a capture?
53 bool expected_kernel
; // Do we expect a capture?
54 validate_cb validate_ust
;
55 validate_cb validate_kernel
;
59 const char *field_value_type_to_str(enum lttng_event_field_value_type type
)
62 case LTTNG_EVENT_FIELD_VALUE_TYPE_UNKNOWN
:
64 case LTTNG_EVENT_FIELD_VALUE_TYPE_INVALID
:
66 case LTTNG_EVENT_FIELD_VALUE_TYPE_UNSIGNED_INT
:
67 return "UNSIGNED INT";
68 case LTTNG_EVENT_FIELD_VALUE_TYPE_SIGNED_INT
:
70 case LTTNG_EVENT_FIELD_VALUE_TYPE_UNSIGNED_ENUM
:
71 return "UNSIGNED ENUM";
72 case LTTNG_EVENT_FIELD_VALUE_TYPE_SIGNED_ENUM
:
74 case LTTNG_EVENT_FIELD_VALUE_TYPE_REAL
:
76 case LTTNG_EVENT_FIELD_VALUE_TYPE_STRING
:
78 case LTTNG_EVENT_FIELD_VALUE_TYPE_ARRAY
:
85 static int validate_type(
86 const struct lttng_event_field_value
*event_field
,
87 enum lttng_event_field_value_type expect
)
90 enum lttng_event_field_value_type value
;
92 value
= lttng_event_field_value_get_type(event_field
);
93 if (value
== LTTNG_EVENT_FIELD_VALUE_TYPE_INVALID
) {
98 ret
= (expect
== value
);
99 ok(ret
, "Expected field type: %s got %s",
100 field_value_type_to_str(expect
),
101 field_value_type_to_str(value
));
110 * Validate unsigned captured field against the iteration number.
111 * The iteration number is always unsigned and will always be compared to value
114 static int validate_unsigned_int_field(
115 const struct lttng_event_field_value
*event_field
,
116 unsigned int iteration
)
120 enum lttng_event_field_value_status status
;
122 ret
= validate_type(event_field
, LTTNG_EVENT_FIELD_VALUE_TYPE_UNSIGNED_INT
);
127 status
= lttng_event_field_value_unsigned_int_get_value(
128 event_field
, &value
);
129 if (status
!= LTTNG_EVENT_FIELD_VALUE_STATUS_OK
) {
130 fail("lttng_event_field_value_unsigned_int_get_value");
135 ret
= (value
== (uint64_t) iteration
);
136 ok (ret
, "Expected unsigned int of value: %u got %" PRIu64
, iteration
, value
);
146 * Validate signed captured field.
147 * Value should be -1.
149 static int validate_signed_int_field(
150 const struct lttng_event_field_value
*event_field
,
151 unsigned int iteration
)
154 int64_t expected
= -1;
156 enum lttng_event_field_value_status status
;
161 ret
= validate_type(event_field
, LTTNG_EVENT_FIELD_VALUE_TYPE_SIGNED_INT
);
166 status
= lttng_event_field_value_signed_int_get_value(
167 event_field
, &value
);
168 if (status
!= LTTNG_EVENT_FIELD_VALUE_STATUS_OK
) {
169 fail("lttng_event_field_value_signed_int_get_value");
174 ret
= (value
== expected
);
175 ok(ret
, "Expected signed int of value: %" PRId64
" got %" PRId64
, expected
, value
);
185 * Validate array of unsigned int.
187 static int validate_array_unsigned_int_field(
188 const struct lttng_event_field_value
*event_field
,
189 unsigned int iteration
)
192 enum lttng_event_field_value_status status
;
193 unsigned int expected
= 3;
199 ret
= validate_type(event_field
, LTTNG_EVENT_FIELD_VALUE_TYPE_ARRAY
);
204 status
= lttng_event_field_value_array_get_length(event_field
, &count
);
205 if (status
!= LTTNG_EVENT_FIELD_VALUE_STATUS_OK
) {
206 fail("lttng_event_field_value_array_get_length");
211 ret
= (count
== expected
);
212 ok(ret
, "Expected %d subelements got %d", expected
, count
);
218 for (unsigned int i
= 1; i
< count
+ 1; i
++) {
219 const struct lttng_event_field_value
*value
;
220 status
= lttng_event_field_value_array_get_element_at_index(
221 event_field
, i
- 1, &value
);
222 if (status
!= LTTNG_EVENT_FIELD_VALUE_STATUS_OK
) {
223 fail("lttng_event_field_value_array_get_element_at_index");
227 ret
= validate_unsigned_int_field(value
, i
);
238 static int validate_array_unsigned_int_field_at_index(
239 const struct lttng_event_field_value
*event_field
,
240 unsigned int iteration
)
243 uint64_t expected_value
= 2;
244 enum lttng_event_field_value_status status
;
250 ret
= validate_type(event_field
, LTTNG_EVENT_FIELD_VALUE_TYPE_UNSIGNED_INT
);
255 status
= lttng_event_field_value_unsigned_int_get_value(
256 event_field
, &value
);
257 if (status
!= LTTNG_EVENT_FIELD_VALUE_STATUS_OK
) {
258 fail("lttng_event_field_value_unsigned_int_get_value");
263 ret
= (value
== expected_value
);
264 ok (ret
, "Expected unsigned int of value: %u got %" PRIu64
,
265 expected_value
, value
);
273 * Validate sequence for a string (seqfield1):
275 * Value: "test" in utf8 [116, 101, 115, 116]
277 static int validate_seqfield1(
278 const struct lttng_event_field_value
*event_field
,
279 unsigned int iteration
)
282 enum lttng_event_field_value_status status
;
284 unsigned int expect
[4] = {116, 101, 115, 116};
289 ret
= validate_type(event_field
, LTTNG_EVENT_FIELD_VALUE_TYPE_ARRAY
);
294 status
= lttng_event_field_value_array_get_length(event_field
, &count
);
295 if (status
!= LTTNG_EVENT_FIELD_VALUE_STATUS_OK
) {
296 fail("lttng_event_field_value_array_get_length");
302 ok(ret
, "Expected 4 subelement got %d", count
);
308 for (unsigned int i
= 0; i
< count
; i
++) {
309 const struct lttng_event_field_value
*value
;
310 status
= lttng_event_field_value_array_get_element_at_index(
311 event_field
, i
, &value
);
312 if (status
!= LTTNG_EVENT_FIELD_VALUE_STATUS_OK
) {
313 fail("lttng_event_field_value_array_get_element_at_index");
317 ret
= validate_unsigned_int_field(value
, expect
[i
]);
329 static int validate_string(
330 const struct lttng_event_field_value
*event_field
,
334 const char *value
= NULL
;
336 ret
= validate_type(event_field
, LTTNG_EVENT_FIELD_VALUE_TYPE_STRING
);
341 value
= lttng_event_field_value_string_get_value(event_field
);
343 fail("lttng_event_field_value_array_get_length");
348 ok(!strcmp(value
, expect
), "Expected string: \"%s\" got \"%s\"", expect
, value
);
357 * Validate string. Expected value is "test".
359 static int validate_string_test(
360 const struct lttng_event_field_value
*event_field
,
361 unsigned int iteration
)
364 const char *expect
= "test";
369 ret
= validate_string(event_field
, expect
);
374 * Validate escaped string. Expected value is "\*".
376 static int validate_string_escaped(
377 const struct lttng_event_field_value
*event_field
,
378 unsigned int iteration
)
381 const char *expect
= "\\*";
386 ret
= validate_string(event_field
, expect
);
391 * Validate real field.
393 static int validate_real(
394 const struct lttng_event_field_value
*event_field
,
399 enum lttng_event_field_value_status status
;
401 ret
= validate_type(event_field
, LTTNG_EVENT_FIELD_VALUE_TYPE_REAL
);
406 status
= lttng_event_field_value_real_get_value(event_field
, &value
);
407 if (status
!= LTTNG_EVENT_FIELD_VALUE_STATUS_OK
) {
408 fail("lttng_event_field_value_real_get_value");
413 ret
= (value
== expect
);
414 ok(ret
, "Real expected: %f got: %f", expect
, value
);
422 * Validate floatfield.
424 static int validate_floatfield(
425 const struct lttng_event_field_value
*event_field
,
426 unsigned int iteration
)
429 double expect
= 2222.0;
434 ret
= validate_real(event_field
, expect
);
439 * Validate doublefield.
441 static int validate_doublefield(
442 const struct lttng_event_field_value
*event_field
,
443 unsigned int iteration
)
451 ret
= validate_real(event_field
, expect
);
456 * Validate enum0: enum0 = ( "AUTO: EXPECT 0" : container = 0 )
458 static int validate_enum0(const struct lttng_event_field_value
*event_field
,
459 unsigned int iteration
)
462 enum lttng_event_field_value_status status
;
464 uint64_t expected_value
= 0;
469 ret
= validate_type(event_field
,
470 LTTNG_EVENT_FIELD_VALUE_TYPE_UNSIGNED_ENUM
);
475 status
= lttng_event_field_value_unsigned_int_get_value(
476 event_field
, &value
);
477 if (status
!= LTTNG_EVENT_FIELD_VALUE_STATUS_OK
) {
478 fail("lttng_event_field_value_unsigned_int_get_value");
483 ok(value
== expected_value
,
484 "Enum value expected: %" PRIu64
" got %" PRIu64
,
485 expected_value
, value
);
492 * Validate enumnegative: enumnegative = ( "AUTO: EXPECT 0" : container = 0 )
494 * We expect 2 labels here.
496 static int validate_enumnegative(
497 const struct lttng_event_field_value
*event_field
,
498 unsigned int iteration
)
501 enum lttng_event_field_value_status status
;
503 int64_t expected_value
= -1;
509 event_field
, LTTNG_EVENT_FIELD_VALUE_TYPE_SIGNED_ENUM
);
514 status
= lttng_event_field_value_signed_int_get_value(
515 event_field
, &value
);
516 if (status
!= LTTNG_EVENT_FIELD_VALUE_STATUS_OK
) {
517 fail("lttng_event_field_value_unsigned_int_get_value");
522 ok(value
== expected_value
,
523 "Enum value expected: %" PRId64
" got %" PRId64
,
524 expected_value
, value
);
530 static int validate_context_procname_ust(
531 const struct lttng_event_field_value
*event_field
,
532 unsigned int iteration
)
539 ret
= validate_string(event_field
, "gen-ust-events");
543 static int validate_context_procname_kernel(
544 const struct lttng_event_field_value
*event_field
,
545 unsigned int iteration
)
552 ret
= validate_string(event_field
, "echo");
556 struct capture_base_field_tuple test_capture_base_fields
[] = {
557 {"DOESNOTEXIST", FIELD_TYPE_PAYLOAD
, false, false, NULL
, NULL
},
558 {"intfield", FIELD_TYPE_PAYLOAD
, true, true, validate_unsigned_int_field
, validate_unsigned_int_field
},
559 {"longfield", FIELD_TYPE_PAYLOAD
, true, true, validate_unsigned_int_field
, validate_unsigned_int_field
},
560 {"signedfield", FIELD_TYPE_PAYLOAD
, true, true, validate_signed_int_field
, validate_signed_int_field
},
561 {"arrfield1", FIELD_TYPE_PAYLOAD
, true, true, validate_array_unsigned_int_field
, validate_array_unsigned_int_field
},
562 {"arrfield2", FIELD_TYPE_PAYLOAD
, true, true, validate_string_test
, validate_string_test
},
563 {"arrfield3", FIELD_TYPE_PAYLOAD
, true, true, validate_array_unsigned_int_field
, validate_array_unsigned_int_field
},
564 {"seqfield1", FIELD_TYPE_PAYLOAD
, true, true, validate_seqfield1
, validate_seqfield1
},
565 {"seqfield2", FIELD_TYPE_PAYLOAD
, true, true, validate_string_test
, validate_string_test
},
566 {"seqfield3", FIELD_TYPE_PAYLOAD
, true, true, validate_array_unsigned_int_field
, validate_array_unsigned_int_field
},
567 {"seqfield4", FIELD_TYPE_PAYLOAD
, true, true, validate_array_unsigned_int_field
, validate_array_unsigned_int_field
},
568 {"arrfield1[1]", FIELD_TYPE_ARRAY_FIELD
, true, true, validate_array_unsigned_int_field_at_index
, validate_array_unsigned_int_field_at_index
},
569 {"stringfield", FIELD_TYPE_PAYLOAD
, true, true, validate_string_test
, validate_string_test
},
570 {"stringfield2", FIELD_TYPE_PAYLOAD
, true, true, validate_string_escaped
, validate_string_escaped
},
571 {"floatfield", FIELD_TYPE_PAYLOAD
, true, false, validate_floatfield
, validate_floatfield
},
572 {"doublefield", FIELD_TYPE_PAYLOAD
, true, false, validate_doublefield
, validate_doublefield
},
573 {"enum0", FIELD_TYPE_PAYLOAD
, true, true, validate_enum0
, validate_enum0
},
574 {"enumnegative", FIELD_TYPE_PAYLOAD
, true, true, validate_enumnegative
, validate_enumnegative
},
575 {"$ctx.procname", FIELD_TYPE_CONTEXT
, true, true, validate_context_procname_ust
, validate_context_procname_kernel
},
578 static const char *get_notification_trigger_name(
579 struct lttng_notification
*notification
)
581 const char *name
= NULL
;
582 enum lttng_evaluation_status status
;
583 const struct lttng_evaluation
*evaluation
;
584 evaluation
= lttng_notification_get_evaluation(notification
);
585 if (evaluation
== NULL
) {
586 fail("lttng_notification_get_evaluation");
590 switch (lttng_evaluation_get_type(evaluation
)) {
591 case LTTNG_CONDITION_TYPE_ON_EVENT
:
593 status
= lttng_evaluation_event_rule_get_trigger_name(
595 if (status
!= LTTNG_EVALUATION_STATUS_OK
) {
596 fail("lttng_evaluation_event_rule_get_trigger_name");
603 fail("Wrong notification evaluation type \n");
610 static int validator_notification_trigger_name(
611 struct lttng_notification
*notification
,
612 const char *trigger_name
)
618 assert(notification
);
619 assert(trigger_name
);
621 name
= get_notification_trigger_name(notification
);
627 name_is_equal
= (strcmp(trigger_name
, name
) == 0);
628 ok(name_is_equal
, "Expected trigger name: %s got %s", trigger_name
,
631 ret
= !name_is_equal
;
638 void wait_on_file(const char *path
, bool file_exist
)
647 ret
= stat(path
, &buf
);
648 if (ret
== -1 && errno
== ENOENT
) {
651 * The file does not exist. wait a bit and
652 * continue looping until it does.
654 (void) poll(NULL
, 0, 10);
659 * File does not exist and the exit condition we want.
660 * Break from the loop and return.
669 * stat() returned 0, so the file exists. break now only if
670 * that's the exit condition we want.
679 int write_pipe(const char *path
, uint8_t data
)
684 fd
= open(path
, O_WRONLY
| O_NONBLOCK
);
686 perror("Could not open consumer control named pipe");
690 ret
= write(fd
, &data
, sizeof(data
));
692 perror("Named pipe write failed");
694 perror("Named pipe close failed");
702 perror("Name pipe closing failed");
711 int stop_consumer(const char **argv
)
715 for (i
= named_pipe_args_start
; i
< nb_args
; i
++) {
716 ret
= write_pipe(argv
[i
], 49);
722 int resume_consumer(const char **argv
)
726 for (i
= named_pipe_args_start
; i
< nb_args
; i
++) {
727 ret
= write_pipe(argv
[i
], 0);
733 int suspend_application(void)
738 if (!stat(app_state_file
, &buf
)) {
739 fail("App is already in a suspended state.");
745 * Send SIGUSR1 to application instructing it to bypass tracepoint.
749 ret
= kill(app_pid
, SIGUSR1
);
751 fail("SIGUSR1 failed. errno %d", errno
);
756 wait_on_file(app_state_file
, true);
764 int resume_application(void)
769 ret
= stat(app_state_file
, &buf
);
770 if (ret
== -1 && errno
== ENOENT
) {
771 fail("State file does not exist");
781 ret
= kill(app_pid
, SIGUSR1
);
783 fail("SIGUSR1 failed. errno %d", errno
);
788 wait_on_file(app_state_file
, false);
797 void test_triggers_buffer_usage_condition(const char *session_name
,
798 const char *channel_name
,
799 enum lttng_domain_type domain_type
,
800 enum lttng_condition_type condition_type
)
802 unsigned int test_vector_size
= 5, i
;
803 enum lttng_condition_status condition_status
;
804 struct lttng_action
*action
;
807 action
= lttng_action_notify_create();
809 fail("Setup error on action creation");
813 /* Test lttng_register_trigger with null value */
814 ok(lttng_register_trigger(NULL
) == -LTTNG_ERR_INVALID
, "Registering a NULL trigger fails as expected");
816 /* Test: register a trigger */
818 for (i
= 0; i
< pow(2,test_vector_size
); i
++) {
820 char *test_tuple_string
= NULL
;
821 unsigned int mask_position
= 0;
822 bool session_name_set
= false;
823 bool channel_name_set
= false;
824 bool threshold_ratio_set
= false;
825 bool threshold_byte_set
= false;
826 bool domain_type_set
= false;
828 struct lttng_trigger
*trigger
= NULL
;
829 struct lttng_condition
*condition
= NULL
;
831 /* Create base condition */
832 switch (condition_type
) {
833 case LTTNG_CONDITION_TYPE_BUFFER_USAGE_LOW
:
834 condition
= lttng_condition_buffer_usage_low_create();
836 case LTTNG_CONDITION_TYPE_BUFFER_USAGE_HIGH
:
837 condition
= lttng_condition_buffer_usage_high_create();
850 /* Prepare the condition for trigger registration test */
852 /* Set session name */
853 if ((1 << mask_position
) & i
) {
854 condition_status
= lttng_condition_buffer_usage_set_session_name(
855 condition
, session_name
);
856 if (condition_status
!= LTTNG_CONDITION_STATUS_OK
) {
860 session_name_set
= true;
864 /* Set channel name */
865 if ((1 << mask_position
) & i
) {
866 condition_status
= lttng_condition_buffer_usage_set_channel_name(
867 condition
, channel_name
);
868 if (condition_status
!= LTTNG_CONDITION_STATUS_OK
) {
872 channel_name_set
= true;
876 /* Set threshold ratio */
877 if ((1 << mask_position
) & i
) {
878 condition_status
= lttng_condition_buffer_usage_set_threshold_ratio(
880 if (condition_status
!= LTTNG_CONDITION_STATUS_OK
) {
884 threshold_ratio_set
= true;
888 /* Set threshold byte */
889 if ((1 << mask_position
) & i
) {
890 condition_status
= lttng_condition_buffer_usage_set_threshold(
892 if (condition_status
!= LTTNG_CONDITION_STATUS_OK
) {
896 threshold_byte_set
= true;
900 /* Set domain type */
901 if ((1 << mask_position
) & i
) {
902 condition_status
= lttng_condition_buffer_usage_set_domain_type(
903 condition
, LTTNG_DOMAIN_UST
);
904 if (condition_status
!= LTTNG_CONDITION_STATUS_OK
) {
908 domain_type_set
= true;
912 if (mask_position
!= test_vector_size
-1) {
913 assert("Logic error for test vector generation");
916 loop_ret
= asprintf(&test_tuple_string
, "session name %s, channel name %s, threshold ratio %s, threshold byte %s, domain type %s",
917 session_name_set
? "set" : "unset",
918 channel_name_set
? "set" : "unset",
919 threshold_ratio_set
? "set" : "unset",
920 threshold_byte_set
? "set" : "unset",
921 domain_type_set
? "set" : "unset");
922 if (!test_tuple_string
|| loop_ret
< 0) {
928 trigger
= lttng_trigger_create(condition
, action
);
934 loop_ret
= lttng_register_trigger(trigger
);
938 fail("Setup error occurred for tuple: %s", test_tuple_string
);
942 /* This combination happens three times */
943 if (session_name_set
&& channel_name_set
944 && (threshold_ratio_set
|| threshold_byte_set
)
945 && domain_type_set
) {
946 ok(loop_ret
== 0, "Trigger is registered: %s", test_tuple_string
);
949 * Test that a trigger cannot be registered
952 loop_ret
= lttng_register_trigger(trigger
);
953 ok(loop_ret
== -LTTNG_ERR_TRIGGER_EXISTS
, "Re-register trigger fails as expected: %s", test_tuple_string
);
955 /* Test that a trigger can be unregistered */
956 loop_ret
= lttng_unregister_trigger(trigger
);
957 ok(loop_ret
== 0, "Unregister trigger: %s", test_tuple_string
);
960 * Test that unregistration of a non-previously
961 * registered trigger fail.
963 loop_ret
= lttng_unregister_trigger(trigger
);
964 ok(loop_ret
== -LTTNG_ERR_TRIGGER_NOT_FOUND
, "Unregister of a non-registered trigger fails as expected: %s", test_tuple_string
);
966 ok(loop_ret
== -LTTNG_ERR_INVALID_TRIGGER
, "Trigger is invalid as expected and cannot be registered: %s", test_tuple_string
);
970 free(test_tuple_string
);
971 lttng_trigger_destroy(trigger
);
972 lttng_condition_destroy(condition
);
976 lttng_action_destroy(action
);
980 void wait_data_pending(const char *session_name
)
985 ret
= lttng_data_pending(session_name
);
991 int setup_buffer_usage_condition(struct lttng_condition
*condition
,
992 const char *condition_name
,
993 const char *session_name
,
994 const char *channel_name
,
995 const enum lttng_domain_type domain_type
)
997 enum lttng_condition_status condition_status
;
1000 condition_status
= lttng_condition_buffer_usage_set_session_name(
1001 condition
, session_name
);
1002 if (condition_status
!= LTTNG_CONDITION_STATUS_OK
) {
1003 fail("Failed to set session name on creation of condition `%s`",
1009 condition_status
= lttng_condition_buffer_usage_set_channel_name(
1010 condition
, channel_name
);
1011 if (condition_status
!= LTTNG_CONDITION_STATUS_OK
) {
1012 fail("Failed to set channel name on creation of condition `%s`",
1018 condition_status
= lttng_condition_buffer_usage_set_domain_type(
1019 condition
, domain_type
);
1020 if (condition_status
!= LTTNG_CONDITION_STATUS_OK
) {
1021 fail("Failed to set domain type on creation of condition `%s`",
1032 void test_invalid_channel_subscription(
1033 const enum lttng_domain_type domain_type
)
1035 enum lttng_condition_status condition_status
;
1036 enum lttng_notification_channel_status nc_status
;
1037 struct lttng_condition
*dummy_condition
= NULL
;
1038 struct lttng_condition
*dummy_invalid_condition
= NULL
;
1039 struct lttng_notification_channel
*notification_channel
= NULL
;
1042 notification_channel
= lttng_notification_channel_create(
1043 lttng_session_daemon_notification_endpoint
);
1044 ok(notification_channel
, "Notification channel object creation");
1045 if (!notification_channel
) {
1050 * Create a dummy, empty (thus invalid) condition to test error paths.
1052 dummy_invalid_condition
= lttng_condition_buffer_usage_low_create();
1053 if (!dummy_invalid_condition
) {
1054 fail("Setup error on condition creation");
1059 * Test subscription and unsubscription of an invalid condition to/from
1062 nc_status
= lttng_notification_channel_subscribe(
1063 notification_channel
, dummy_invalid_condition
);
1064 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_INVALID
,
1065 "Subscribing to an invalid condition");
1067 nc_status
= lttng_notification_channel_unsubscribe(
1068 notification_channel
, dummy_invalid_condition
);
1069 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_INVALID
,
1070 "Unsubscribing from an invalid condition");
1072 /* Create a valid dummy condition with a ratio of 0.5 */
1073 dummy_condition
= lttng_condition_buffer_usage_low_create();
1074 if (!dummy_condition
) {
1075 fail("Setup error on dummy_condition creation");
1079 condition_status
= lttng_condition_buffer_usage_set_threshold_ratio(
1080 dummy_condition
, 0.5);
1081 if (condition_status
!= LTTNG_CONDITION_STATUS_OK
) {
1082 fail("Setup error on condition creation");
1086 ret
= setup_buffer_usage_condition(dummy_condition
, "dummy_condition",
1087 "dummy_session", "dummy_channel", domain_type
);
1089 fail("Setup error on dummy condition creation");
1094 * Test subscription and unsubscription to/from a channel with invalid
1097 nc_status
= lttng_notification_channel_subscribe(NULL
, NULL
);
1098 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_INVALID
,
1099 "Notification channel subscription is invalid: NULL, NULL");
1101 nc_status
= lttng_notification_channel_subscribe(
1102 notification_channel
, NULL
);
1103 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_INVALID
,
1104 "Notification channel subscription is invalid: NON-NULL, NULL");
1106 nc_status
= lttng_notification_channel_subscribe(NULL
, dummy_condition
);
1107 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_INVALID
,
1108 "Notification channel subscription is invalid: NULL, NON-NULL");
1110 nc_status
= lttng_notification_channel_unsubscribe(
1111 notification_channel
, dummy_condition
);
1112 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_UNKNOWN_CONDITION
,
1113 "Unsubscribing from a valid unknown condition");
1116 lttng_notification_channel_destroy(notification_channel
);
1117 lttng_condition_destroy(dummy_invalid_condition
);
1118 lttng_condition_destroy(dummy_condition
);
1122 enum buffer_usage_type
{
1123 BUFFER_USAGE_TYPE_LOW
,
1124 BUFFER_USAGE_TYPE_HIGH
,
1127 static int register_buffer_usage_notify_trigger(const char *session_name
,
1128 const char *channel_name
,
1129 const enum lttng_domain_type domain_type
,
1130 enum buffer_usage_type buffer_usage_type
,
1132 struct lttng_condition
**condition
,
1133 struct lttng_action
**action
,
1134 struct lttng_trigger
**trigger
)
1136 enum lttng_condition_status condition_status
;
1137 struct lttng_action
*tmp_action
= NULL
;
1138 struct lttng_condition
*tmp_condition
= NULL
;
1139 struct lttng_trigger
*tmp_trigger
= NULL
;
1143 tmp_action
= lttng_action_notify_create();
1145 fail("Setup error on action creation");
1150 if (buffer_usage_type
== BUFFER_USAGE_TYPE_LOW
) {
1151 tmp_condition
= lttng_condition_buffer_usage_low_create();
1153 tmp_condition
= lttng_condition_buffer_usage_high_create();
1156 if (!tmp_condition
) {
1157 fail("Setup error on condition creation");
1162 /* Set the buffer usage threashold */
1163 condition_status
= lttng_condition_buffer_usage_set_threshold_ratio(
1164 tmp_condition
, ratio
);
1165 if (condition_status
!= LTTNG_CONDITION_STATUS_OK
) {
1166 fail("Setup error on condition creation");
1171 ret
= setup_buffer_usage_condition(tmp_condition
, "condition_name",
1172 session_name
, channel_name
, domain_type
);
1174 fail("Setup error on condition creation");
1179 /* Register the trigger for condition. */
1180 tmp_trigger
= lttng_trigger_create(tmp_condition
, tmp_action
);
1182 fail("Setup error on trigger creation");
1187 ret
= lttng_register_trigger(tmp_trigger
);
1189 fail("Setup error on trigger registration");
1194 *condition
= tmp_condition
;
1195 *trigger
= tmp_trigger
;
1196 *action
= tmp_action
;
1200 lttng_action_destroy(tmp_action
);
1201 lttng_condition_destroy(tmp_condition
);
1202 lttng_trigger_destroy(tmp_trigger
);
1208 static void test_subscription_twice(const char *session_name
,
1209 const char *channel_name
,
1210 const enum lttng_domain_type domain_type
)
1213 enum lttng_notification_channel_status nc_status
;
1215 struct lttng_action
*action
= NULL
;
1216 struct lttng_notification_channel
*notification_channel
= NULL
;
1217 struct lttng_trigger
*trigger
= NULL
;
1219 struct lttng_condition
*condition
= NULL
;
1221 ret
= register_buffer_usage_notify_trigger(session_name
, channel_name
,
1222 domain_type
, BUFFER_USAGE_TYPE_LOW
, 0.99, &condition
,
1225 fail("Setup error on trigger registration");
1229 /* Begin testing. */
1230 notification_channel
= lttng_notification_channel_create(
1231 lttng_session_daemon_notification_endpoint
);
1232 ok(notification_channel
, "Notification channel object creation");
1233 if (!notification_channel
) {
1237 /* Subscribe a valid condition. */
1238 nc_status
= lttng_notification_channel_subscribe(
1239 notification_channel
, condition
);
1240 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
,
1241 "Subscribe to condition");
1243 /* Subscribing again should fail. */
1244 nc_status
= lttng_notification_channel_subscribe(
1245 notification_channel
, condition
);
1246 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_ALREADY_SUBSCRIBED
,
1247 "Subscribe to a condition for which subscription was already done");
1250 lttng_unregister_trigger(trigger
);
1251 lttng_trigger_destroy(trigger
);
1252 lttng_notification_channel_destroy(notification_channel
);
1253 lttng_action_destroy(action
);
1254 lttng_condition_destroy(condition
);
1257 static void test_buffer_usage_notification_channel(const char *session_name
,
1258 const char *channel_name
,
1259 const enum lttng_domain_type domain_type
,
1263 enum lttng_notification_channel_status nc_status
;
1265 struct lttng_action
*low_action
= NULL
;
1266 struct lttng_action
*high_action
= NULL
;
1267 struct lttng_notification
*notification
= NULL
;
1268 struct lttng_notification_channel
*notification_channel
= NULL
;
1269 struct lttng_trigger
*low_trigger
= NULL
;
1270 struct lttng_trigger
*high_trigger
= NULL
;
1272 struct lttng_condition
*low_condition
= NULL
;
1273 struct lttng_condition
*high_condition
= NULL
;
1275 const double low_ratio
= 0.0;
1276 const double high_ratio
= 0.90;
1278 ret
= register_buffer_usage_notify_trigger(session_name
, channel_name
,
1279 domain_type
, BUFFER_USAGE_TYPE_LOW
, low_ratio
,
1280 &low_condition
, &low_action
, &low_trigger
);
1282 fail("Setup error on low trigger registration");
1286 ret
= register_buffer_usage_notify_trigger(session_name
, channel_name
,
1287 domain_type
, BUFFER_USAGE_TYPE_HIGH
, high_ratio
,
1288 &high_condition
, &high_action
, &high_trigger
);
1290 fail("Setup error on high trigger registration");
1295 notification_channel
= lttng_notification_channel_create(
1296 lttng_session_daemon_notification_endpoint
);
1297 ok(notification_channel
, "Notification channel object creation");
1298 if (!notification_channel
) {
1302 /* Subscribe a valid low condition */
1303 nc_status
= lttng_notification_channel_subscribe(
1304 notification_channel
, low_condition
);
1305 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
,
1306 "Subscribe to low condition");
1308 /* Subscribe a valid high condition */
1309 nc_status
= lttng_notification_channel_subscribe(
1310 notification_channel
, high_condition
);
1311 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
,
1312 "Subscribe to high condition");
1314 resume_application();
1316 /* Wait for notification to happen */
1317 stop_consumer(argv
);
1318 lttng_start_tracing(session_name
);
1320 /* Wait for high notification */
1322 nc_status
= lttng_notification_channel_get_next_notification(
1323 notification_channel
, ¬ification
);
1324 } while (nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_INTERRUPTED
);
1325 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
&& notification
&&
1326 lttng_condition_get_type(lttng_notification_get_condition(
1328 LTTNG_CONDITION_TYPE_BUFFER_USAGE_HIGH
,
1329 "High notification received after intermediary communication");
1330 lttng_notification_destroy(notification
);
1331 notification
= NULL
;
1333 suspend_application();
1334 lttng_stop_tracing_no_wait(session_name
);
1335 resume_consumer(argv
);
1336 wait_data_pending(session_name
);
1339 * Test that communication still work even if there is notification
1340 * waiting for consumption.
1343 nc_status
= lttng_notification_channel_unsubscribe(
1344 notification_channel
, low_condition
);
1345 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
,
1346 "Unsubscribe with pending notification");
1348 nc_status
= lttng_notification_channel_subscribe(
1349 notification_channel
, low_condition
);
1350 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
,
1351 "Subscribe with pending notification");
1354 nc_status
= lttng_notification_channel_get_next_notification(
1355 notification_channel
, ¬ification
);
1356 } while (nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_INTERRUPTED
);
1357 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
&& notification
&&
1358 lttng_condition_get_type(lttng_notification_get_condition(
1360 LTTNG_CONDITION_TYPE_BUFFER_USAGE_LOW
,
1361 "Low notification received after intermediary communication");
1362 lttng_notification_destroy(notification
);
1363 notification
= NULL
;
1365 /* Stop consumer to force a high notification */
1366 stop_consumer(argv
);
1367 resume_application();
1368 lttng_start_tracing(session_name
);
1371 nc_status
= lttng_notification_channel_get_next_notification(
1372 notification_channel
, ¬ification
);
1373 } while (nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_INTERRUPTED
);
1374 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
&& notification
&&
1375 lttng_condition_get_type(lttng_notification_get_condition(
1377 LTTNG_CONDITION_TYPE_BUFFER_USAGE_HIGH
,
1378 "High notification received after intermediary communication");
1379 lttng_notification_destroy(notification
);
1380 notification
= NULL
;
1382 suspend_application();
1383 lttng_stop_tracing_no_wait(session_name
);
1384 resume_consumer(argv
);
1385 wait_data_pending(session_name
);
1388 nc_status
= lttng_notification_channel_get_next_notification(
1389 notification_channel
, ¬ification
);
1390 } while (nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_INTERRUPTED
);
1391 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
&& notification
&&
1392 lttng_condition_get_type(lttng_notification_get_condition(
1394 LTTNG_CONDITION_TYPE_BUFFER_USAGE_LOW
,
1395 "Low notification received after re-subscription");
1396 lttng_notification_destroy(notification
);
1397 notification
= NULL
;
1399 stop_consumer(argv
);
1400 resume_application();
1401 /* Stop consumer to force a high notification */
1402 lttng_start_tracing(session_name
);
1405 nc_status
= lttng_notification_channel_get_next_notification(
1406 notification_channel
, ¬ification
);
1407 } while (nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_INTERRUPTED
);
1408 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
&& notification
&&
1409 lttng_condition_get_type(lttng_notification_get_condition(
1411 LTTNG_CONDITION_TYPE_BUFFER_USAGE_HIGH
,
1412 "High notification");
1413 lttng_notification_destroy(notification
);
1414 notification
= NULL
;
1416 suspend_application();
1418 /* Resume consumer to allow event consumption */
1419 lttng_stop_tracing_no_wait(session_name
);
1420 resume_consumer(argv
);
1421 wait_data_pending(session_name
);
1423 nc_status
= lttng_notification_channel_unsubscribe(
1424 notification_channel
, low_condition
);
1425 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
,
1426 "Unsubscribe low condition with pending notification");
1428 nc_status
= lttng_notification_channel_unsubscribe(
1429 notification_channel
, high_condition
);
1430 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
,
1431 "Unsubscribe high condition with pending notification");
1434 lttng_notification_channel_destroy(notification_channel
);
1435 lttng_trigger_destroy(low_trigger
);
1436 lttng_trigger_destroy(high_trigger
);
1437 lttng_action_destroy(low_action
);
1438 lttng_action_destroy(high_action
);
1439 lttng_condition_destroy(low_condition
);
1440 lttng_condition_destroy(high_condition
);
1443 static void create_tracepoint_event_rule_trigger(const char *event_pattern
,
1444 const char *trigger_name
,
1446 unsigned int exclusion_count
,
1447 const char * const *exclusions
,
1448 enum lttng_domain_type domain_type
,
1449 condition_capture_desc_cb capture_desc_cb
,
1450 struct lttng_condition
**condition
,
1451 struct lttng_trigger
**trigger
)
1453 enum lttng_event_rule_status event_rule_status
;
1454 enum lttng_trigger_status trigger_status
;
1456 struct lttng_action
*tmp_action
= NULL
;
1457 struct lttng_event_rule
*event_rule
= NULL
;
1458 struct lttng_condition
*tmp_condition
= NULL
;
1459 struct lttng_trigger
*tmp_trigger
= NULL
;
1462 assert(event_pattern
);
1463 assert(trigger_name
);
1467 event_rule
= lttng_event_rule_tracepoint_create(domain_type
);
1468 ok(event_rule
, "Tracepoint event rule object creation");
1470 event_rule_status
= lttng_event_rule_tracepoint_set_pattern(
1471 event_rule
, event_pattern
);
1472 ok(event_rule_status
== LTTNG_EVENT_RULE_STATUS_OK
,
1473 "Setting tracepoint event rule pattern: '%s'",
1477 event_rule_status
= lttng_event_rule_tracepoint_set_filter(
1478 event_rule
, filter
);
1479 ok(event_rule_status
== LTTNG_EVENT_RULE_STATUS_OK
,
1480 "Setting tracepoint event rule filter: '%s'",
1486 bool success
= true;
1488 assert(domain_type
== LTTNG_DOMAIN_UST
);
1489 assert(exclusion_count
> 0);
1491 for (i
= 0; i
< exclusion_count
; i
++) {
1493 lttng_event_rule_tracepoint_add_exclusion(
1496 if (event_rule_status
!= LTTNG_EVENT_RULE_STATUS_OK
) {
1497 fail("Setting tracepoint event rule exclusion '%s'.",
1503 ok(success
, "Setting tracepoint event rule exclusions");
1506 tmp_condition
= lttng_condition_on_event_create(event_rule
);
1507 ok(tmp_condition
, "Condition event rule object creation");
1509 if (capture_desc_cb
) {
1510 ret
= capture_desc_cb(tmp_condition
);
1512 assert("Generating the condition capture descriptor");
1516 tmp_action
= lttng_action_notify_create();
1517 ok(tmp_action
, "Action event rule object creation");
1519 tmp_trigger
= lttng_trigger_create(tmp_condition
, tmp_action
);
1520 ok(tmp_trigger
, "Trigger object creation %s", trigger_name
);
1522 trigger_status
= lttng_trigger_set_name(tmp_trigger
, trigger_name
);
1523 ok(trigger_status
== LTTNG_TRIGGER_STATUS_OK
,
1524 "Setting name to trigger %s", trigger_name
);
1526 ret
= lttng_register_trigger(tmp_trigger
);
1527 ok(ret
== 0, "Trigger registration %s", trigger_name
);
1529 lttng_event_rule_destroy(event_rule
);
1531 *condition
= tmp_condition
;
1532 *trigger
= tmp_trigger
;
1537 static struct lttng_notification
*get_next_notification(
1538 struct lttng_notification_channel
*notification_channel
)
1540 struct lttng_notification
*local_notification
= NULL
;
1541 enum lttng_notification_channel_status status
;
1543 /* Receive the next notification. */
1544 status
= lttng_notification_channel_get_next_notification(
1545 notification_channel
, &local_notification
);
1548 case LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
:
1550 case LTTNG_NOTIFICATION_CHANNEL_STATUS_NOTIFICATIONS_DROPPED
:
1551 fail("Notifications have been dropped");
1552 local_notification
= NULL
;
1555 /* Unhandled conditions / errors. */
1556 fail("Failed to get next notification (unknown notification channel status): status = %d",
1558 local_notification
= NULL
;
1562 return local_notification
;
1565 static void test_tracepoint_event_rule_notification(
1566 enum lttng_domain_type domain_type
)
1570 const int notification_count
= 3;
1571 enum lttng_notification_channel_status nc_status
;
1572 struct lttng_action
*action
= NULL
;
1573 struct lttng_condition
*condition
= NULL
;
1574 struct lttng_notification_channel
*notification_channel
= NULL
;
1575 struct lttng_trigger
*trigger
= NULL
;
1576 const char * const trigger_name
= "my_precious";
1577 const char *pattern
;
1579 if (domain_type
== LTTNG_DOMAIN_UST
) {
1580 pattern
= "tp:tptest";
1582 pattern
= "lttng_test_filter_event";
1585 create_tracepoint_event_rule_trigger(pattern
, trigger_name
, NULL
, 0,
1586 NULL
, domain_type
, NULL
, &condition
, &trigger
);
1588 notification_channel
= lttng_notification_channel_create(
1589 lttng_session_daemon_notification_endpoint
);
1590 ok(notification_channel
, "Notification channel object creation");
1592 nc_status
= lttng_notification_channel_subscribe(
1593 notification_channel
, condition
);
1594 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
,
1595 "Subscribe to tracepoint event rule condition");
1597 resume_application();
1599 /* Get notifications. */
1600 for (i
= 0; i
< notification_count
; i
++) {
1601 struct lttng_notification
*notification
= get_next_notification(
1602 notification_channel
);
1604 ok(notification
, "Received notification (%d/%d)", i
+ 1,
1605 notification_count
);
1608 if (notification
== NULL
) {
1612 ret
= validator_notification_trigger_name(notification
, trigger_name
);
1613 lttng_notification_destroy(notification
);
1620 suspend_application();
1621 lttng_notification_channel_destroy(notification_channel
);
1622 lttng_unregister_trigger(trigger
);
1623 lttng_trigger_destroy(trigger
);
1624 lttng_action_destroy(action
);
1625 lttng_condition_destroy(condition
);
1629 static void test_tracepoint_event_rule_notification_filter(
1630 enum lttng_domain_type domain_type
)
1633 const int notification_count
= 3;
1634 enum lttng_notification_channel_status nc_status
;
1635 struct lttng_condition
*ctrl_condition
= NULL
, *condition
= NULL
;
1636 struct lttng_notification_channel
*notification_channel
= NULL
;
1637 struct lttng_trigger
*ctrl_trigger
= NULL
, *trigger
= NULL
;
1638 const char * const ctrl_trigger_name
= "control_trigger";
1639 const char * const trigger_name
= "trigger";
1640 const char *pattern
;
1641 int ctrl_count
= 0, count
= 0;
1643 if (domain_type
== LTTNG_DOMAIN_UST
) {
1644 pattern
= "tp:tptest";
1646 pattern
= "lttng_test_filter_event";
1649 notification_channel
= lttng_notification_channel_create(
1650 lttng_session_daemon_notification_endpoint
);
1651 ok(notification_channel
, "Notification channel object creation");
1653 create_tracepoint_event_rule_trigger(pattern
, ctrl_trigger_name
, NULL
,
1654 0, NULL
, domain_type
, NULL
, &ctrl_condition
, &ctrl_trigger
);
1656 nc_status
= lttng_notification_channel_subscribe(
1657 notification_channel
, ctrl_condition
);
1658 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
,
1659 "Subscribe to tracepoint event rule condition");
1662 * Attach a filter expression to get notification only if the
1663 * `intfield` is even.
1665 create_tracepoint_event_rule_trigger(pattern
, trigger_name
,
1666 "(intfield & 1) == 0", 0, NULL
, domain_type
, NULL
, &condition
,
1669 nc_status
= lttng_notification_channel_subscribe(
1670 notification_channel
, condition
);
1671 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
,
1672 "Subscribe to tracepoint event rule condition");
1675 * We registered 2 notifications triggers, one with a filter and one
1676 * without (control). The one with a filter will only fired when the
1677 * `intfield` is a multiple of 2. We should get two times as many
1678 * control notifications as filter notifications.
1680 resume_application();
1683 * Get 3 notifications. We should get 1 for the regular trigger (with
1684 * the filter) and 2 from the control trigger. This works whatever
1685 * the order we receive the notifications.
1687 for (i
= 0; i
< notification_count
; i
++) {
1689 struct lttng_notification
*notification
= get_next_notification(
1690 notification_channel
);
1692 ok(notification
, "Received notification (%d/%d)", i
+ 1,
1693 notification_count
);
1696 if (notification
== NULL
) {
1700 name
= get_notification_trigger_name(notification
);
1702 lttng_notification_destroy(notification
);
1706 if (strcmp(ctrl_trigger_name
, name
) == 0) {
1708 } else if (strcmp(trigger_name
, name
) == 0) {
1712 lttng_notification_destroy(notification
);
1715 ok(ctrl_count
/ 2 == count
,
1716 "Get twice as many control notif as of regular notif");
1719 suspend_application();
1721 lttng_unregister_trigger(trigger
);
1722 lttng_unregister_trigger(ctrl_trigger
);
1723 lttng_notification_channel_destroy(notification_channel
);
1724 lttng_trigger_destroy(trigger
);
1725 lttng_trigger_destroy(ctrl_trigger
);
1726 lttng_condition_destroy(condition
);
1727 lttng_condition_destroy(ctrl_condition
);
1730 static void test_tracepoint_event_rule_notification_exclusion(
1731 enum lttng_domain_type domain_type
)
1733 enum lttng_notification_channel_status nc_status
;
1734 struct lttng_condition
*ctrl_condition
= NULL
, *condition
= NULL
;
1735 struct lttng_notification_channel
*notification_channel
= NULL
;
1736 struct lttng_trigger
*ctrl_trigger
= NULL
, *trigger
= NULL
;
1737 int ctrl_count
= 0, count
= 0, i
;
1738 const int notification_count
= 6;
1739 const char * const ctrl_trigger_name
= "control_exclusion_trigger";
1740 const char * const trigger_name
= "exclusion_trigger";
1741 const char * const pattern
= "tp:tptest*";
1742 const char * const exclusions
[] = {
1749 notification_channel
= lttng_notification_channel_create(
1750 lttng_session_daemon_notification_endpoint
);
1751 ok(notification_channel
, "Notification channel object creation");
1753 create_tracepoint_event_rule_trigger(pattern
, ctrl_trigger_name
, NULL
,
1754 0, NULL
, domain_type
, NULL
, &ctrl_condition
,
1757 nc_status
= lttng_notification_channel_subscribe(
1758 notification_channel
, ctrl_condition
);
1759 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
,
1760 "Subscribe to tracepoint event rule condition");
1762 create_tracepoint_event_rule_trigger(pattern
, trigger_name
, NULL
, 4,
1763 exclusions
, domain_type
, NULL
, &condition
,
1766 nc_status
= lttng_notification_channel_subscribe(
1767 notification_channel
, condition
);
1768 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
,
1769 "Subscribe to tracepoint event rule condition");
1772 * We registered 2 notifications triggers, one with an exclusion and
1773 * one without (control).
1774 * - The trigger with an exclusion will fire once every iteration.
1775 * - The trigger without an exclusion will fire 5 times every
1778 * We should get 5 times as many notifications from the control
1781 resume_application();
1784 * Get 6 notifications. We should get 1 for the regular trigger (with
1785 * the exclusion) and 5 from the control trigger. This works whatever
1786 * the order we receive the notifications.
1788 for (i
= 0; i
< notification_count
; i
++) {
1790 struct lttng_notification
*notification
= get_next_notification(
1791 notification_channel
);
1793 ok(notification
, "Received notification (%d/%d)", i
+ 1,
1794 notification_count
);
1797 if (notification
== NULL
) {
1801 name
= get_notification_trigger_name(notification
);
1803 lttng_notification_destroy(notification
);
1807 if (strcmp(ctrl_trigger_name
, name
) == 0) {
1809 } else if (strcmp(trigger_name
, name
) == 0) {
1813 lttng_notification_destroy(notification
);
1816 ok(ctrl_count
/ 5 == count
,
1817 "Got 5 times as many control notif as of regular notif");
1820 suspend_application();
1822 lttng_unregister_trigger(trigger
);
1823 lttng_unregister_trigger(ctrl_trigger
);
1824 lttng_notification_channel_destroy(notification_channel
);
1825 lttng_trigger_destroy(trigger
);
1826 lttng_trigger_destroy(ctrl_trigger
);
1827 lttng_condition_destroy(condition
);
1828 lttng_condition_destroy(ctrl_condition
);
1832 static void test_kprobe_event_rule_notification(
1833 enum lttng_domain_type domain_type
)
1836 const int notification_count
= 3;
1837 enum lttng_notification_channel_status nc_status
;
1838 enum lttng_event_rule_status event_rule_status
;
1839 enum lttng_trigger_status trigger_status
;
1840 struct lttng_notification_channel
*notification_channel
= NULL
;
1841 struct lttng_condition
*condition
= NULL
;
1842 struct lttng_kernel_probe_location
*location
= NULL
;
1843 struct lttng_event_rule
*event_rule
= NULL
;
1844 struct lttng_action
*action
= NULL
;
1845 struct lttng_trigger
*trigger
= NULL
;
1846 const char * const trigger_name
= "kprobe_trigger";
1847 const char * const symbol_name
= "lttng_test_filter_event_write";
1849 action
= lttng_action_notify_create();
1851 fail("Failed to create notify action");
1855 location
= lttng_kernel_probe_location_symbol_create(symbol_name
, 0);
1857 fail("Failed to create kernel probe location");
1861 notification_channel
= lttng_notification_channel_create(
1862 lttng_session_daemon_notification_endpoint
);
1863 ok(notification_channel
, "Notification channel object creation");
1865 event_rule
= lttng_event_rule_kernel_probe_create(location
);
1866 ok(event_rule
, "kprobe event rule object creation");
1868 event_rule_status
= lttng_event_rule_kernel_probe_set_event_name(
1869 event_rule
, trigger_name
);
1870 ok(event_rule_status
== LTTNG_EVENT_RULE_STATUS_OK
,
1871 "Setting kprobe event rule name: '%s'", trigger_name
);
1873 condition
= lttng_condition_on_event_create(event_rule
);
1874 ok(condition
, "Condition event rule object creation");
1876 /* Register the trigger for condition. */
1877 trigger
= lttng_trigger_create(condition
, action
);
1879 fail("Failed to create trigger with kernel probe event rule condition and notify action");
1883 trigger_status
= lttng_trigger_set_name(trigger
, trigger_name
);
1884 ok(trigger_status
== LTTNG_TRIGGER_STATUS_OK
,
1885 "Setting trigger name to '%s'", trigger_name
);
1887 ret
= lttng_register_trigger(trigger
);
1889 fail("Failed to register trigger with kernel probe event rule condition and notify action");
1893 nc_status
= lttng_notification_channel_subscribe(
1894 notification_channel
, condition
);
1895 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
,
1896 "Subscribe to tracepoint event rule condition");
1898 resume_application();
1900 for (i
= 0; i
< notification_count
; i
++) {
1901 struct lttng_notification
*notification
= get_next_notification(
1902 notification_channel
);
1904 ok(notification
, "Received notification (%d/%d)", i
+ 1,
1905 notification_count
);
1908 if (notification
== NULL
) {
1912 ret
= validator_notification_trigger_name(notification
, trigger_name
);
1913 lttng_notification_destroy(notification
);
1920 suspend_application();
1921 lttng_notification_channel_destroy(notification_channel
);
1922 lttng_unregister_trigger(trigger
);
1923 lttng_trigger_destroy(trigger
);
1924 lttng_action_destroy(action
);
1925 lttng_event_rule_destroy(event_rule
);
1926 lttng_condition_destroy(condition
);
1927 lttng_kernel_probe_location_destroy(location
);
1931 static void test_uprobe_event_rule_notification(
1932 enum lttng_domain_type domain_type
,
1933 const char *testapp_path
,
1934 const char *test_symbol_name
)
1937 const int notification_count
= 3;
1938 enum lttng_notification_channel_status nc_status
;
1939 enum lttng_event_rule_status event_rule_status
;
1940 enum lttng_trigger_status trigger_status
;
1941 struct lttng_notification_channel
*notification_channel
= NULL
;
1942 struct lttng_userspace_probe_location
*probe_location
= NULL
;
1943 struct lttng_userspace_probe_location_lookup_method
*lookup_method
=
1945 struct lttng_condition
*condition
= NULL
;
1946 struct lttng_event_rule
*event_rule
= NULL
;
1947 struct lttng_action
*action
= NULL
;
1948 struct lttng_trigger
*trigger
= NULL
;
1949 const char * const trigger_name
= "uprobe_trigger";
1951 action
= lttng_action_notify_create();
1953 fail("Failed to create notify action");
1957 lookup_method
= lttng_userspace_probe_location_lookup_method_function_elf_create();
1958 if (!lookup_method
) {
1959 fail("Setup error on userspace probe lookup method creation");
1963 probe_location
= lttng_userspace_probe_location_function_create(
1964 testapp_path
, test_symbol_name
, lookup_method
);
1965 if (!probe_location
) {
1966 fail("Failed to create userspace probe location");
1970 notification_channel
= lttng_notification_channel_create(
1971 lttng_session_daemon_notification_endpoint
);
1972 ok(notification_channel
, "Notification channel object creation");
1974 event_rule
= lttng_event_rule_userspace_probe_create(probe_location
);
1975 ok(event_rule
, "kprobe event rule object creation");
1977 event_rule_status
= lttng_event_rule_userspace_probe_set_event_name(
1978 event_rule
, trigger_name
);
1979 ok(event_rule_status
== LTTNG_EVENT_RULE_STATUS_OK
,
1980 "Setting uprobe event rule name: '%s'", trigger_name
);
1982 condition
= lttng_condition_on_event_create(event_rule
);
1983 ok(condition
, "Condition event rule object creation");
1985 /* Register the trigger for condition. */
1986 trigger
= lttng_trigger_create(condition
, action
);
1988 fail("Failed to create trigger with userspace probe event rule condition and notify action");
1992 trigger_status
= lttng_trigger_set_name(trigger
, trigger_name
);
1993 ok(trigger_status
== LTTNG_TRIGGER_STATUS_OK
,
1994 "Setting name to trigger '%s'", trigger_name
);
1996 ret
= lttng_register_trigger(trigger
);
1998 fail("Failed to register trigger with userspace probe event rule condition and notify action");
2002 nc_status
= lttng_notification_channel_subscribe(
2003 notification_channel
, condition
);
2004 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
,
2005 "Subscribe to tracepoint event rule condition");
2007 resume_application();
2009 for (i
= 0; i
< 3; i
++) {
2010 struct lttng_notification
*notification
= get_next_notification(
2011 notification_channel
);
2013 ok(notification
, "Received notification (%d/%d)", i
+ 1,
2014 notification_count
);
2017 if (notification
== NULL
) {
2021 ret
= validator_notification_trigger_name(notification
, trigger_name
);
2022 lttng_notification_destroy(notification
);
2028 suspend_application();
2030 lttng_notification_channel_destroy(notification_channel
);
2031 lttng_unregister_trigger(trigger
);
2032 lttng_trigger_destroy(trigger
);
2033 lttng_action_destroy(action
);
2034 lttng_userspace_probe_location_destroy(probe_location
);
2035 lttng_event_rule_destroy(event_rule
);
2036 lttng_condition_destroy(condition
);
2040 static void test_syscall_event_rule_notification(
2041 enum lttng_domain_type domain_type
)
2044 const int notification_count
= 3;
2045 enum lttng_notification_channel_status nc_status
;
2046 enum lttng_event_rule_status event_rule_status
;
2047 enum lttng_trigger_status trigger_status
;
2048 struct lttng_notification_channel
*notification_channel
= NULL
;
2049 struct lttng_condition
*condition
= NULL
;
2050 struct lttng_event_rule
*event_rule
= NULL
;
2051 struct lttng_action
*action
= NULL
;
2052 struct lttng_trigger
*trigger
= NULL
;
2053 const char * const trigger_name
= "syscall_trigger";
2054 const char * const syscall_name
= "openat";
2056 action
= lttng_action_notify_create();
2058 fail("Failed to create notify action");
2062 notification_channel
= lttng_notification_channel_create(
2063 lttng_session_daemon_notification_endpoint
);
2064 ok(notification_channel
, "Notification channel object creation");
2066 event_rule
= lttng_event_rule_syscall_create();
2067 ok(event_rule
, "syscall event rule object creation");
2069 event_rule_status
= lttng_event_rule_syscall_set_pattern(
2070 event_rule
, syscall_name
);
2071 ok(event_rule_status
== LTTNG_EVENT_RULE_STATUS_OK
,
2072 "Setting syscall event rule pattern: '%s'", syscall_name
);
2074 condition
= lttng_condition_on_event_create(event_rule
);
2075 ok(condition
, "Condition syscall event rule object creation");
2077 /* Register the trigger for condition. */
2078 trigger
= lttng_trigger_create(condition
, action
);
2080 fail("Failed to create trigger with syscall event rule condition and notify action");
2084 trigger_status
= lttng_trigger_set_name(trigger
, trigger_name
);
2085 ok(trigger_status
== LTTNG_TRIGGER_STATUS_OK
,
2086 "Setting name to trigger '%s'", trigger_name
);
2088 ret
= lttng_register_trigger(trigger
);
2090 fail("Failed to register trigger with syscall event rule condition and notify action");
2094 nc_status
= lttng_notification_channel_subscribe(
2095 notification_channel
, condition
);
2096 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
,
2097 "Subscribe to tracepoint event rule condition");
2099 resume_application();
2101 for (i
= 0; i
< notification_count
; i
++) {
2102 struct lttng_notification
*notification
= get_next_notification(
2103 notification_channel
);
2105 ok(notification
, "Received notification (%d/%d)", i
+ 1,
2106 notification_count
);
2109 if (notification
== NULL
) {
2113 ret
= validator_notification_trigger_name(notification
, trigger_name
);
2114 lttng_notification_destroy(notification
);
2120 suspend_application();
2121 lttng_notification_channel_destroy(notification_channel
);
2122 lttng_unregister_trigger(trigger
);
2123 lttng_trigger_destroy(trigger
);
2124 lttng_action_destroy(action
);
2125 lttng_condition_destroy(condition
);
2129 static void test_syscall_event_rule_notification_filter(
2130 enum lttng_domain_type domain_type
)
2133 const int notification_count
= 3;
2134 enum lttng_notification_channel_status nc_status
;
2135 enum lttng_event_rule_status event_rule_status
;
2136 enum lttng_trigger_status trigger_status
;
2137 struct lttng_notification_channel
*notification_channel
= NULL
;
2138 struct lttng_condition
*condition
= NULL
;
2139 struct lttng_event_rule
*event_rule
= NULL
;
2140 struct lttng_action
*action
= NULL
;
2141 struct lttng_trigger
*trigger
= NULL
;
2142 const char * const trigger_name
= "syscall_trigger";
2143 const char * const syscall_name
= "openat";
2144 const char * const filter_pattern
= "filename == \"/proc/cpuinfo\"";
2146 action
= lttng_action_notify_create();
2148 fail("Failed to create notify action");
2152 notification_channel
= lttng_notification_channel_create(
2153 lttng_session_daemon_notification_endpoint
);
2154 ok(notification_channel
, "Notification channel object creation");
2156 event_rule
= lttng_event_rule_syscall_create();
2157 ok(event_rule
, "syscall event rule object creation");
2159 event_rule_status
= lttng_event_rule_syscall_set_pattern(
2160 event_rule
, syscall_name
);
2161 ok(event_rule_status
== LTTNG_EVENT_RULE_STATUS_OK
,
2162 "Setting syscall event rule pattern: '%s'", syscall_name
);
2164 event_rule_status
= lttng_event_rule_syscall_set_filter(
2165 event_rule
, filter_pattern
);
2166 ok(event_rule_status
== LTTNG_EVENT_RULE_STATUS_OK
,
2167 "Setting filter: '%s'", filter_pattern
);
2169 condition
= lttng_condition_on_event_create(event_rule
);
2170 ok(condition
, "Condition event rule object creation");
2172 /* Register the triggers for condition */
2173 trigger
= lttng_trigger_create(condition
, action
);
2175 fail("Failed to create trigger with syscall filtering event rule condition and notify action");
2179 trigger_status
= lttng_trigger_set_name(trigger
, trigger_name
);
2180 ok(trigger_status
== LTTNG_TRIGGER_STATUS_OK
,
2181 "Setting name to trigger '%s'", trigger_name
);
2183 ret
= lttng_register_trigger(trigger
);
2185 fail("Failed to register trigger with syscall filtering event rule condition and notify action");
2189 nc_status
= lttng_notification_channel_subscribe(
2190 notification_channel
, condition
);
2191 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
,
2192 "Subscribe to tracepoint event rule condition");
2194 resume_application();
2196 for (i
= 0; i
< notification_count
; i
++) {
2197 struct lttng_notification
*notification
= get_next_notification(
2198 notification_channel
);
2200 ok(notification
, "Received notification (%d/%d)", i
+ 1,
2201 notification_count
);
2204 if (notification
== NULL
) {
2208 ret
= validator_notification_trigger_name(notification
, trigger_name
);
2209 lttng_notification_destroy(notification
);
2216 suspend_application();
2218 lttng_unregister_trigger(trigger
);
2219 lttng_notification_channel_destroy(notification_channel
);
2220 lttng_trigger_destroy(trigger
);
2221 lttng_event_rule_destroy(event_rule
);
2222 lttng_condition_destroy(condition
);
2226 static int generate_capture_descr(struct lttng_condition
*condition
)
2229 struct lttng_event_expr
*expr
= NULL
;
2230 unsigned int basic_field_size
;
2231 enum lttng_condition_status cond_status
;
2233 basic_field_size
= sizeof(test_capture_base_fields
) / sizeof(*test_capture_base_fields
);
2234 for (int i
= 0; i
< basic_field_size
; i
++) {
2236 diag("Adding capture descriptor \"%s\"", test_capture_base_fields
[i
].field_name
);
2238 switch (test_capture_base_fields
[i
].field_type
) {
2239 case FIELD_TYPE_PAYLOAD
:
2240 expr
= lttng_event_expr_event_payload_field_create(
2241 test_capture_base_fields
[i
].field_name
);
2243 case FIELD_TYPE_CONTEXT
:
2244 expr
= lttng_event_expr_channel_context_field_create(
2245 test_capture_base_fields
[i
].field_name
);
2247 case FIELD_TYPE_ARRAY_FIELD
:
2251 char field_name
[256];
2252 struct lttng_event_expr
*array_expr
= NULL
;
2253 nb_matches
= sscanf(test_capture_base_fields
[i
].field_name
,
2254 "%[^[][%u]", field_name
, &index
);
2255 if (nb_matches
!= 2) {
2259 array_expr
= lttng_event_expr_event_payload_field_create(
2262 expr
= lttng_event_expr_array_field_element_create(
2266 case FIELD_TYPE_APP_CONTEXT
:
2267 fail("Application context not tested yet.");
2273 fail("Creating capture expression");
2277 cond_status
= lttng_condition_on_event_append_capture_descriptor(
2279 if (cond_status
!= LTTNG_CONDITION_STATUS_OK
) {
2280 fail("Appending capture_descriptor");
2282 lttng_event_expr_destroy(expr
);
2293 static int validator_notification_trigger_capture(
2294 enum lttng_domain_type domain
,
2295 struct lttng_notification
*notification
,
2296 const int iteration
)
2299 unsigned int capture_count
, i
;
2300 enum lttng_evaluation_status evaluation_status
;
2301 enum lttng_event_field_value_status event_field_value_status
;
2302 const struct lttng_evaluation
*evaluation
;
2303 const struct lttng_event_field_value
*captured_fields
;
2304 bool at_least_one_error
= false;
2306 evaluation
= lttng_notification_get_evaluation(notification
);
2307 if (evaluation
== NULL
) {
2308 fail("lttng_notification_get_evaluation");
2313 /* TODO: it seems weird that lttng_evaluation_get_captured_values return
2314 * INVALID if no capture were present. might be better to return
2315 * something with more meaning. Another question is how we link the
2316 * notion of capture and the descriptor from the perspective of a
2317 * client. Is it really invalid to ask for captured value when there might
2320 evaluation_status
= lttng_evaluation_get_captured_values(evaluation
, &captured_fields
);
2321 if (evaluation_status
!= LTTNG_EVALUATION_STATUS_OK
) {
2322 diag("lttng_evaluation_get_captured_values");
2327 event_field_value_status
=
2328 lttng_event_field_value_array_get_length(captured_fields
,
2330 if (event_field_value_status
!= LTTNG_EVENT_FIELD_VALUE_STATUS_OK
) {
2331 assert(0 && "get count of captured field");
2334 for (i
= 0; i
< capture_count
; i
++) {
2335 const struct lttng_event_field_value
*captured_field
= NULL
;
2336 validate_cb validate
;
2339 diag("Validating capture \"%s\"", test_capture_base_fields
[i
].field_name
);
2340 event_field_value_status
= lttng_event_field_value_array_get_element_at_index(captured_fields
, i
, &captured_field
);
2343 case LTTNG_DOMAIN_UST
:
2344 expected
= test_capture_base_fields
[i
].expected_ust
;
2346 case LTTNG_DOMAIN_KERNEL
:
2347 expected
= test_capture_base_fields
[i
].expected_kernel
;
2350 assert(0 && "Domain invalid for this test");
2354 ok(event_field_value_status
== LTTNG_EVENT_FIELD_VALUE_STATUS_UNAVAILABLE
, "No payload captured");
2358 if (domain
== LTTNG_DOMAIN_UST
) {
2359 validate
= test_capture_base_fields
[i
].validate_ust
;
2361 validate
= test_capture_base_fields
[i
].validate_kernel
;
2364 if (event_field_value_status
!= LTTNG_EVENT_FIELD_VALUE_STATUS_OK
) {
2366 if (event_field_value_status
==
2367 LTTNG_EVENT_FIELD_VALUE_STATUS_UNAVAILABLE
) {
2368 reason
= "Expected a capture but it is unavailable";
2370 reason
= "lttng_event_field_value_array_get_element_at_index";
2376 diag("Captured field of type %s",
2377 field_value_type_to_str(
2378 lttng_event_field_value_get_type(captured_field
)));
2381 ret
= validate(captured_field
, iteration
);
2383 at_least_one_error
= true;
2387 ret
= at_least_one_error
;
2393 static void test_tracepoint_event_rule_notification_capture(
2394 enum lttng_domain_type domain_type
)
2396 enum lttng_notification_channel_status nc_status
;
2399 struct lttng_condition
*condition
= NULL
;
2400 struct lttng_notification_channel
*notification_channel
= NULL
;
2401 struct lttng_trigger
*trigger
= NULL
;
2402 const char *trigger_name
= "my_precious";
2403 const char *pattern
;
2405 if (domain_type
== LTTNG_DOMAIN_UST
) {
2406 pattern
= "tp:tptest";
2408 pattern
= "lttng_test_filter_event";
2411 create_tracepoint_event_rule_trigger(pattern
, trigger_name
, NULL
, 0,
2412 NULL
, domain_type
, generate_capture_descr
, &condition
,
2415 notification_channel
= lttng_notification_channel_create(
2416 lttng_session_daemon_notification_endpoint
);
2417 ok(notification_channel
, "Notification channel object creation");
2419 nc_status
= lttng_notification_channel_subscribe(
2420 notification_channel
, condition
);
2421 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
,
2422 "Subscribe to tracepoint event rule condition");
2424 resume_application();
2426 /* Get 3 notifications */
2427 for (i
= 0; i
< 3; i
++) {
2428 struct lttng_notification
*notification
= get_next_notification(
2429 notification_channel
);
2430 ok(notification
, "Received notification");
2433 if (notification
== NULL
) {
2437 ret
= validator_notification_trigger_name(notification
, trigger_name
);
2439 lttng_notification_destroy(notification
);
2443 ret
= validator_notification_trigger_capture(domain_type
, notification
, i
);
2445 lttng_notification_destroy(notification
);
2449 lttng_notification_destroy(notification
);
2453 suspend_application();
2454 lttng_notification_channel_destroy(notification_channel
);
2455 lttng_unregister_trigger(trigger
);
2456 lttng_trigger_destroy(trigger
);
2457 lttng_condition_destroy(condition
);
2461 int main(int argc
, const char *argv
[])
2464 const char *domain_type_string
= NULL
;
2465 enum lttng_domain_type domain_type
= LTTNG_DOMAIN_NONE
;
2468 fail("Missing test scenario, domain type, pid, or application state file argument(s)");
2472 test_scenario
= atoi(argv
[1]);
2473 domain_type_string
= argv
[2];
2474 app_pid
= (pid_t
) atoi(argv
[3]);
2475 app_state_file
= argv
[4];
2477 if (!strcmp("LTTNG_DOMAIN_UST", domain_type_string
)) {
2478 domain_type
= LTTNG_DOMAIN_UST
;
2480 if (!strcmp("LTTNG_DOMAIN_KERNEL", domain_type_string
)) {
2481 domain_type
= LTTNG_DOMAIN_KERNEL
;
2483 if (domain_type
== LTTNG_DOMAIN_NONE
) {
2484 fail("Unknown domain type");
2489 * Test cases are responsible for resuming the app when needed
2490 * and making sure it's suspended when returning.
2492 suspend_application();
2494 switch (test_scenario
) {
2499 /* Test cases that need gen-ust-event testapp. */
2500 diag("Test basic notification error paths for %s domain",
2501 domain_type_string
);
2502 test_invalid_channel_subscription(domain_type
);
2504 diag("Test tracepoint event rule notifications for domain %s",
2505 domain_type_string
);
2506 test_tracepoint_event_rule_notification(domain_type
);
2508 diag("Test tracepoint event rule notifications with filter for domain %s",
2509 domain_type_string
);
2510 test_tracepoint_event_rule_notification_filter(domain_type
);
2515 const char *session_name
, *channel_name
;
2517 /* Test cases that need a tracing session enabled. */
2521 * Argument 7 and upward are named pipe location for consumerd
2524 named_pipe_args_start
= 7;
2527 fail("Missing parameter for tests to run %d", argc
);
2533 session_name
= argv
[5];
2534 channel_name
= argv
[6];
2536 test_subscription_twice(session_name
, channel_name
,
2539 diag("Test trigger for domain %s with buffer_usage_low condition",
2540 domain_type_string
);
2541 test_triggers_buffer_usage_condition(session_name
, channel_name
,
2543 LTTNG_CONDITION_TYPE_BUFFER_USAGE_LOW
);
2545 diag("Test trigger for domain %s with buffer_usage_high condition",
2546 domain_type_string
);
2547 test_triggers_buffer_usage_condition(session_name
, channel_name
,
2549 LTTNG_CONDITION_TYPE_BUFFER_USAGE_HIGH
);
2551 diag("Test buffer usage notification channel api for domain %s",
2552 domain_type_string
);
2553 test_buffer_usage_notification_channel(session_name
, channel_name
,
2560 * Test cases that need a test app with more than one event
2566 * At the moment, the only test case of this scenario is
2567 * exclusion which is only supported by UST.
2569 assert(domain_type
== LTTNG_DOMAIN_UST
);
2570 diag("Test tracepoint event rule notifications with exclusion for domain %s",
2571 domain_type_string
);
2572 test_tracepoint_event_rule_notification_exclusion(domain_type
);
2579 /* Test cases that need the kernel tracer. */
2580 assert(domain_type
== LTTNG_DOMAIN_KERNEL
);
2582 diag("Test kprobe event rule notifications for domain %s",
2583 domain_type_string
);
2585 test_kprobe_event_rule_notification(domain_type
);
2592 /* Test cases that need the kernel tracer. */
2593 assert(domain_type
== LTTNG_DOMAIN_KERNEL
);
2595 diag("Test syscall event rule notifications for domain %s",
2596 domain_type_string
);
2598 test_syscall_event_rule_notification(domain_type
);
2600 diag("Test syscall filtering event rule notifications for domain %s",
2601 domain_type_string
);
2603 test_syscall_event_rule_notification_filter(domain_type
);
2609 const char *testapp_path
, *test_symbol_name
;
2614 fail("Missing parameter for tests to run %d", argc
);
2618 testapp_path
= argv
[5];
2619 test_symbol_name
= argv
[6];
2620 /* Test cases that need the kernel tracer. */
2621 assert(domain_type
== LTTNG_DOMAIN_KERNEL
);
2623 diag("Test userspace-probe event rule notifications for domain %s",
2624 domain_type_string
);
2626 test_uprobe_event_rule_notification(
2627 domain_type
, testapp_path
, test_symbol_name
);
2633 switch(domain_type
) {
2634 case LTTNG_DOMAIN_UST
:
2637 case LTTNG_DOMAIN_KERNEL
:
2644 diag("Test tracepoint event rule notification captures for domain %s",
2645 domain_type_string
);
2646 test_tracepoint_event_rule_notification_capture(domain_type
);
2656 return exit_status();