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 #define FIELD_NAME_MAX_LEN 256
33 /* A callback to populate the condition capture descriptor. */
34 typedef int (*condition_capture_desc_cb
)(struct lttng_condition
*condition
);
36 /* A callback for captured field validation. */
37 typedef int (*validate_cb
)(const struct lttng_event_field_value
*event_field
, unsigned iteration
);
40 int named_pipe_args_start
= 0;
42 const char *app_state_file
= NULL
;
47 FIELD_TYPE_APP_CONTEXT
,
48 FIELD_TYPE_ARRAY_FIELD
,
51 struct capture_base_field_tuple
{
53 enum field_type field_type
;
54 /* Do we expect a userspace capture? */
56 /* Do we expect a kernel capture? */
58 validate_cb validate_ust
;
59 validate_cb validate_kernel
;
63 const char *field_value_type_to_str(enum lttng_event_field_value_type type
)
66 case LTTNG_EVENT_FIELD_VALUE_TYPE_UNKNOWN
:
68 case LTTNG_EVENT_FIELD_VALUE_TYPE_INVALID
:
70 case LTTNG_EVENT_FIELD_VALUE_TYPE_UNSIGNED_INT
:
71 return "UNSIGNED INT";
72 case LTTNG_EVENT_FIELD_VALUE_TYPE_SIGNED_INT
:
74 case LTTNG_EVENT_FIELD_VALUE_TYPE_UNSIGNED_ENUM
:
75 return "UNSIGNED ENUM";
76 case LTTNG_EVENT_FIELD_VALUE_TYPE_SIGNED_ENUM
:
78 case LTTNG_EVENT_FIELD_VALUE_TYPE_REAL
:
80 case LTTNG_EVENT_FIELD_VALUE_TYPE_STRING
:
82 case LTTNG_EVENT_FIELD_VALUE_TYPE_ARRAY
:
89 static int validate_type(const struct lttng_event_field_value
*event_field
,
90 enum lttng_event_field_value_type expect
)
93 enum lttng_event_field_value_type value
;
95 value
= lttng_event_field_value_get_type(event_field
);
96 if (value
== LTTNG_EVENT_FIELD_VALUE_TYPE_INVALID
) {
101 ok(expect
== value
, "Expected field type %s, got %s",
102 field_value_type_to_str(expect
),
103 field_value_type_to_str(value
));
105 ret
= expect
!= value
;
112 * Validate unsigned captured field against the iteration number.
114 static int validate_unsigned_int_field(
115 const struct lttng_event_field_value
*event_field
,
116 unsigned int expected_value
)
120 enum lttng_event_field_value_status status
;
123 event_field
, LTTNG_EVENT_FIELD_VALUE_TYPE_UNSIGNED_INT
);
128 status
= lttng_event_field_value_unsigned_int_get_value(
129 event_field
, &value
);
130 if (status
!= LTTNG_EVENT_FIELD_VALUE_STATUS_OK
) {
131 fail("lttng_event_field_value_unsigned_int_get_value returned an error: status = %d",
137 ok(value
== (uint64_t) expected_value
,
138 "Expected unsigned integer value %u, got %" PRIu64
,
139 expected_value
, value
);
141 ret
= value
!= (uint64_t) expected_value
;
148 * Validate signed captured field.
150 static int validate_signed_int_field(
151 const struct lttng_event_field_value
*event_field
,
152 unsigned int iteration
)
155 const int64_t expected
= -1;
157 enum lttng_event_field_value_status status
;
163 event_field
, LTTNG_EVENT_FIELD_VALUE_TYPE_SIGNED_INT
);
168 status
= lttng_event_field_value_signed_int_get_value(
169 event_field
, &value
);
170 if (status
!= LTTNG_EVENT_FIELD_VALUE_STATUS_OK
) {
171 fail("lttng_event_field_value_signed_int_get_value returned an error: status = %d",
177 ok(value
== expected
,
178 "Expected signed integer value %" PRId64
182 ret
= value
!= expected
;
190 * Validate array of unsigned int.
192 static int validate_array_unsigned_int_field(
193 const struct lttng_event_field_value
*event_field
,
194 unsigned int iteration
)
197 enum lttng_event_field_value_status status
;
198 const unsigned int expected
= 3;
199 unsigned int i
, count
;
204 ret
= validate_type(event_field
, LTTNG_EVENT_FIELD_VALUE_TYPE_ARRAY
);
209 status
= lttng_event_field_value_array_get_length(event_field
, &count
);
210 if (status
!= LTTNG_EVENT_FIELD_VALUE_STATUS_OK
) {
211 fail("lttng_event_field_value_array_get_length");
216 ok(count
== expected
, "Expected %d subelements, got %d", expected
,
218 if (count
!= expected
) {
223 for (i
= 1; i
< count
+ 1; i
++) {
224 const struct lttng_event_field_value
*value
;
226 status
= lttng_event_field_value_array_get_element_at_index(
227 event_field
, i
- 1, &value
);
228 if (status
!= LTTNG_EVENT_FIELD_VALUE_STATUS_OK
) {
229 fail("lttng_event_field_value_array_get_element_at_index returned an error: status = %d",
235 ret
= validate_unsigned_int_field(value
, i
);
247 static int validate_array_unsigned_int_field_at_index(
248 const struct lttng_event_field_value
*event_field
,
249 unsigned int iteration
)
252 const uint64_t expected_value
= 2;
253 enum lttng_event_field_value_status status
;
260 event_field
, LTTNG_EVENT_FIELD_VALUE_TYPE_UNSIGNED_INT
);
265 status
= lttng_event_field_value_unsigned_int_get_value(
266 event_field
, &value
);
267 if (status
!= LTTNG_EVENT_FIELD_VALUE_STATUS_OK
) {
268 fail("lttng_event_field_value_unsigned_int_get_value returned an error: status = %d",
274 ok(value
== expected_value
,
275 "Expected unsigned integer value %u, got %" PRIu64
,
276 expected_value
, value
);
284 * Validate sequence for a string (seqfield1):
286 * Value: "test" encoded in UTF-8: [116, 101, 115, 116]
288 static int validate_seqfield1(const struct lttng_event_field_value
*event_field
,
289 unsigned int iteration
)
292 enum lttng_event_field_value_status status
;
293 unsigned int i
, count
;
294 const unsigned int expect
[] = {116, 101, 115, 116};
295 const size_t array_count
= sizeof(expect
) / sizeof(*expect
);
300 ret
= validate_type(event_field
, LTTNG_EVENT_FIELD_VALUE_TYPE_ARRAY
);
305 status
= lttng_event_field_value_array_get_length(event_field
, &count
);
306 if (status
!= LTTNG_EVENT_FIELD_VALUE_STATUS_OK
) {
307 fail("lttng_event_field_value_array_get_length returned an error: status = %d",
313 ok(count
== array_count
, "Expected %zu array sub-elements, got %d",
315 if (count
!= array_count
) {
320 for (i
= 0; i
< count
; i
++) {
321 const struct lttng_event_field_value
*value
;
323 status
= lttng_event_field_value_array_get_element_at_index(
324 event_field
, i
, &value
);
325 if (status
!= LTTNG_EVENT_FIELD_VALUE_STATUS_OK
) {
326 fail("lttng_event_field_value_array_get_element_at_index returned an error: status = %d",
332 ret
= validate_unsigned_int_field(value
, expect
[i
]);
343 static int validate_string(
344 const struct lttng_event_field_value
*event_field
,
348 const char *value
= NULL
;
349 enum lttng_event_field_value_status status
;
351 ret
= validate_type(event_field
, LTTNG_EVENT_FIELD_VALUE_TYPE_STRING
);
356 status
= lttng_event_field_value_string_get_value(event_field
, &value
);
358 fail("lttng_event_field_value_array_get_length returned an error: status = %d",
364 ok(!strcmp(value
, expect
), "Expected string value \"%s\", got \"%s\"",
374 * Validate string. Expected value is "test".
376 static int validate_string_test(
377 const struct lttng_event_field_value
*event_field
,
378 unsigned int iteration
)
380 const char * const expect
= "test";
385 return validate_string(event_field
, expect
);
389 * Validate escaped string. Expected value is "\*".
391 static int validate_string_escaped(
392 const struct lttng_event_field_value
*event_field
,
393 unsigned int iteration
)
395 const char * const expect
= "\\*";
400 return validate_string(event_field
, expect
);
404 * Validate real field.
406 static int validate_real(
407 const struct lttng_event_field_value
*event_field
,
412 enum lttng_event_field_value_status status
;
414 ret
= validate_type(event_field
, LTTNG_EVENT_FIELD_VALUE_TYPE_REAL
);
419 status
= lttng_event_field_value_real_get_value(event_field
, &value
);
420 if (status
!= LTTNG_EVENT_FIELD_VALUE_STATUS_OK
) {
421 fail("lttng_event_field_value_real_get_value returned an error: status = %d",
427 ok(value
== expect
, "Expected real value %f, got %f", expect
, value
);
428 ret
= value
!= expect
;
434 * Validate floatfield.
436 static int validate_floatfield(
437 const struct lttng_event_field_value
*event_field
,
438 unsigned int iteration
)
440 const double expect
= 2222.0;
445 return validate_real(event_field
, expect
);
449 * Validate doublefield.
451 static int validate_doublefield(
452 const struct lttng_event_field_value
*event_field
,
453 unsigned int iteration
)
455 const double expect
= 2.0;
460 return validate_real(event_field
, expect
);
464 * Validate enum0: enum0 = ( "AUTO: EXPECT 0" : container = 0 )
466 static int validate_enum0(const struct lttng_event_field_value
*event_field
,
467 unsigned int iteration
)
470 enum lttng_event_field_value_status status
;
472 const uint64_t expected_value
= 0;
477 ret
= validate_type(event_field
,
478 LTTNG_EVENT_FIELD_VALUE_TYPE_UNSIGNED_ENUM
);
483 status
= lttng_event_field_value_unsigned_int_get_value(
484 event_field
, &value
);
485 if (status
!= LTTNG_EVENT_FIELD_VALUE_STATUS_OK
) {
486 fail("lttng_event_field_value_unsigned_int_get_value returned an error: status = %d",
492 ok(value
== expected_value
,
493 "Expected enum value %" PRIu64
", got %" PRIu64
,
494 expected_value
, value
);
501 * Validate enumnegative: enumnegative = ( "AUTO: EXPECT 0" : container = 0 )
503 * We expect 2 labels here.
505 static int validate_enumnegative(
506 const struct lttng_event_field_value
*event_field
,
507 unsigned int iteration
)
510 enum lttng_event_field_value_status status
;
512 const int64_t expected_value
= -1;
517 ret
= validate_type(event_field
,
518 LTTNG_EVENT_FIELD_VALUE_TYPE_SIGNED_ENUM
);
523 status
= lttng_event_field_value_signed_int_get_value(
524 event_field
, &value
);
525 if (status
!= LTTNG_EVENT_FIELD_VALUE_STATUS_OK
) {
526 fail("lttng_event_field_value_unsigned_int_get_value");
531 ok(value
== expected_value
,
532 "Expected enum value %" PRId64
", got %" PRId64
,
533 expected_value
, value
);
539 static int validate_context_procname_ust(
540 const struct lttng_event_field_value
*event_field
,
541 unsigned int iteration
)
545 return validate_string(event_field
, "gen-ust-events");
548 static int validate_context_procname_kernel(
549 const struct lttng_event_field_value
*event_field
,
550 unsigned int iteration
)
554 return validate_string(event_field
, "echo");
557 struct capture_base_field_tuple test_capture_base_fields
[] = {
558 { "DOESNOTEXIST", FIELD_TYPE_PAYLOAD
, false, false, NULL
, NULL
},
559 { "intfield", FIELD_TYPE_PAYLOAD
, true, true, validate_unsigned_int_field
, validate_unsigned_int_field
},
560 { "longfield", FIELD_TYPE_PAYLOAD
, true, true, validate_unsigned_int_field
, validate_unsigned_int_field
},
561 { "signedfield", FIELD_TYPE_PAYLOAD
, true, true, validate_signed_int_field
, validate_signed_int_field
},
562 { "arrfield1", FIELD_TYPE_PAYLOAD
, true, true, validate_array_unsigned_int_field
, validate_array_unsigned_int_field
},
563 { "arrfield2", FIELD_TYPE_PAYLOAD
, true, true, validate_string_test
, validate_string_test
},
564 { "arrfield3", FIELD_TYPE_PAYLOAD
, true, true, validate_array_unsigned_int_field
, validate_array_unsigned_int_field
},
565 { "seqfield1", FIELD_TYPE_PAYLOAD
, true, true, validate_seqfield1
, validate_seqfield1
},
566 { "seqfield2", FIELD_TYPE_PAYLOAD
, true, true, validate_string_test
, validate_string_test
},
567 { "seqfield3", FIELD_TYPE_PAYLOAD
, true, true, validate_array_unsigned_int_field
, validate_array_unsigned_int_field
},
568 { "seqfield4", FIELD_TYPE_PAYLOAD
, true, true, validate_array_unsigned_int_field
, validate_array_unsigned_int_field
},
569 { "arrfield1[1]", FIELD_TYPE_ARRAY_FIELD
, true, true, validate_array_unsigned_int_field_at_index
, validate_array_unsigned_int_field_at_index
},
570 { "stringfield", FIELD_TYPE_PAYLOAD
, true, true, validate_string_test
, validate_string_test
},
571 { "stringfield2", FIELD_TYPE_PAYLOAD
, true, true, validate_string_escaped
, validate_string_escaped
},
572 { "floatfield", FIELD_TYPE_PAYLOAD
, true, false, validate_floatfield
, validate_floatfield
},
573 { "doublefield", FIELD_TYPE_PAYLOAD
, true, false, validate_doublefield
, validate_doublefield
},
574 { "enum0", FIELD_TYPE_PAYLOAD
, true, true, validate_enum0
, validate_enum0
},
575 { "enumnegative", FIELD_TYPE_PAYLOAD
, true, true, validate_enumnegative
, validate_enumnegative
},
576 { "$ctx.procname", FIELD_TYPE_CONTEXT
, true, true, validate_context_procname_ust
, validate_context_procname_kernel
},
579 static const char *get_notification_trigger_name(
580 struct lttng_notification
*notification
)
582 const char *trigger_name
= NULL
;
583 enum lttng_trigger_status trigger_status
;
584 const struct lttng_trigger
*trigger
;
586 trigger
= lttng_notification_get_trigger(notification
);
588 fail("Failed to get trigger from notification");
592 trigger_status
= lttng_trigger_get_name(trigger
, &trigger_name
);
593 if (trigger_status
!= LTTNG_TRIGGER_STATUS_OK
) {
594 fail("Failed to get name from notification's trigger");
602 static int validator_notification_trigger_name(
603 struct lttng_notification
*notification
,
604 const char *trigger_name
)
610 assert(notification
);
611 assert(trigger_name
);
613 name
= get_notification_trigger_name(notification
);
619 name_is_equal
= (strcmp(trigger_name
, name
) == 0);
620 ok(name_is_equal
, "Expected trigger name: %s got %s", trigger_name
,
623 ret
= !name_is_equal
;
630 void wait_on_file(const char *path
, bool file_exist
)
639 ret
= stat(path
, &buf
);
640 if (ret
== -1 && errno
== ENOENT
) {
643 * The file does not exist. wait a bit and
644 * continue looping until it does.
646 (void) poll(NULL
, 0, 10);
651 * File does not exist and the exit condition we want.
652 * Break from the loop and return.
661 * stat() returned 0, so the file exists. break now only if
662 * that's the exit condition we want.
671 int write_pipe(const char *path
, uint8_t data
)
676 fd
= open(path
, O_WRONLY
| O_NONBLOCK
);
678 perror("Could not open consumer control named pipe");
682 ret
= write(fd
, &data
, sizeof(data
));
684 perror("Named pipe write failed");
686 perror("Named pipe close failed");
694 perror("Name pipe closing failed");
703 int stop_consumer(const char **argv
)
707 for (i
= named_pipe_args_start
; i
< nb_args
; i
++) {
708 ret
= write_pipe(argv
[i
], 49);
714 int resume_consumer(const char **argv
)
718 for (i
= named_pipe_args_start
; i
< nb_args
; i
++) {
719 ret
= write_pipe(argv
[i
], 0);
725 int suspend_application(void)
730 if (!stat(app_state_file
, &buf
)) {
731 fail("App is already in a suspended state.");
737 * Send SIGUSR1 to application instructing it to bypass tracepoint.
741 ret
= kill(app_pid
, SIGUSR1
);
743 fail("SIGUSR1 failed. errno %d", errno
);
748 wait_on_file(app_state_file
, true);
756 int resume_application(void)
761 ret
= stat(app_state_file
, &buf
);
762 if (ret
== -1 && errno
== ENOENT
) {
763 fail("State file does not exist");
773 ret
= kill(app_pid
, SIGUSR1
);
775 fail("SIGUSR1 failed. errno %d", errno
);
780 wait_on_file(app_state_file
, false);
789 void test_triggers_buffer_usage_condition(const char *session_name
,
790 const char *channel_name
,
791 enum lttng_domain_type domain_type
,
792 enum lttng_condition_type condition_type
)
794 unsigned int test_vector_size
= 5, i
;
795 enum lttng_condition_status condition_status
;
796 struct lttng_action
*action
;
799 action
= lttng_action_notify_create();
801 fail("Setup error on action creation");
805 /* Test lttng_register_trigger with null value */
806 ok(lttng_register_trigger(NULL
) == -LTTNG_ERR_INVALID
, "Registering a NULL trigger fails as expected");
808 /* Test: register a trigger */
810 for (i
= 0; i
< pow(2,test_vector_size
); i
++) {
812 char *test_tuple_string
= NULL
;
813 unsigned int mask_position
= 0;
814 bool session_name_set
= false;
815 bool channel_name_set
= false;
816 bool threshold_ratio_set
= false;
817 bool threshold_byte_set
= false;
818 bool domain_type_set
= false;
820 struct lttng_trigger
*trigger
= NULL
;
821 struct lttng_condition
*condition
= NULL
;
823 /* Create base condition */
824 switch (condition_type
) {
825 case LTTNG_CONDITION_TYPE_BUFFER_USAGE_LOW
:
826 condition
= lttng_condition_buffer_usage_low_create();
828 case LTTNG_CONDITION_TYPE_BUFFER_USAGE_HIGH
:
829 condition
= lttng_condition_buffer_usage_high_create();
842 /* Prepare the condition for trigger registration test */
844 /* Set session name */
845 if ((1 << mask_position
) & i
) {
846 condition_status
= lttng_condition_buffer_usage_set_session_name(
847 condition
, session_name
);
848 if (condition_status
!= LTTNG_CONDITION_STATUS_OK
) {
852 session_name_set
= true;
856 /* Set channel name */
857 if ((1 << mask_position
) & i
) {
858 condition_status
= lttng_condition_buffer_usage_set_channel_name(
859 condition
, channel_name
);
860 if (condition_status
!= LTTNG_CONDITION_STATUS_OK
) {
864 channel_name_set
= true;
868 /* Set threshold ratio */
869 if ((1 << mask_position
) & i
) {
870 condition_status
= lttng_condition_buffer_usage_set_threshold_ratio(
872 if (condition_status
!= LTTNG_CONDITION_STATUS_OK
) {
876 threshold_ratio_set
= true;
880 /* Set threshold byte */
881 if ((1 << mask_position
) & i
) {
882 condition_status
= lttng_condition_buffer_usage_set_threshold(
884 if (condition_status
!= LTTNG_CONDITION_STATUS_OK
) {
888 threshold_byte_set
= true;
892 /* Set domain type */
893 if ((1 << mask_position
) & i
) {
894 condition_status
= lttng_condition_buffer_usage_set_domain_type(
895 condition
, LTTNG_DOMAIN_UST
);
896 if (condition_status
!= LTTNG_CONDITION_STATUS_OK
) {
900 domain_type_set
= true;
904 if (mask_position
!= test_vector_size
-1) {
905 assert("Logic error for test vector generation");
908 loop_ret
= asprintf(&test_tuple_string
, "session name %s, channel name %s, threshold ratio %s, threshold byte %s, domain type %s",
909 session_name_set
? "set" : "unset",
910 channel_name_set
? "set" : "unset",
911 threshold_ratio_set
? "set" : "unset",
912 threshold_byte_set
? "set" : "unset",
913 domain_type_set
? "set" : "unset");
914 if (!test_tuple_string
|| loop_ret
< 0) {
920 trigger
= lttng_trigger_create(condition
, action
);
926 loop_ret
= lttng_register_trigger(trigger
);
930 fail("Setup error occurred for tuple: %s", test_tuple_string
);
934 /* This combination happens three times */
935 if (session_name_set
&& channel_name_set
936 && (threshold_ratio_set
|| threshold_byte_set
)
937 && domain_type_set
) {
938 ok(loop_ret
== 0, "Trigger is registered: %s", test_tuple_string
);
941 * Test that a trigger cannot be registered
944 loop_ret
= lttng_register_trigger(trigger
);
945 ok(loop_ret
== -LTTNG_ERR_TRIGGER_EXISTS
, "Re-register trigger fails as expected: %s", test_tuple_string
);
947 /* Test that a trigger can be unregistered */
948 loop_ret
= lttng_unregister_trigger(trigger
);
949 ok(loop_ret
== 0, "Unregister trigger: %s", test_tuple_string
);
952 * Test that unregistration of a non-previously
953 * registered trigger fail.
955 loop_ret
= lttng_unregister_trigger(trigger
);
956 ok(loop_ret
== -LTTNG_ERR_TRIGGER_NOT_FOUND
, "Unregister of a non-registered trigger fails as expected: %s", test_tuple_string
);
958 ok(loop_ret
== -LTTNG_ERR_INVALID_TRIGGER
, "Trigger is invalid as expected and cannot be registered: %s", test_tuple_string
);
962 free(test_tuple_string
);
963 lttng_trigger_destroy(trigger
);
964 lttng_condition_destroy(condition
);
968 lttng_action_destroy(action
);
972 void wait_data_pending(const char *session_name
)
977 ret
= lttng_data_pending(session_name
);
983 int setup_buffer_usage_condition(struct lttng_condition
*condition
,
984 const char *condition_name
,
985 const char *session_name
,
986 const char *channel_name
,
987 const enum lttng_domain_type domain_type
)
989 enum lttng_condition_status condition_status
;
992 condition_status
= lttng_condition_buffer_usage_set_session_name(
993 condition
, session_name
);
994 if (condition_status
!= LTTNG_CONDITION_STATUS_OK
) {
995 fail("Failed to set session name on creation of condition `%s`",
1001 condition_status
= lttng_condition_buffer_usage_set_channel_name(
1002 condition
, channel_name
);
1003 if (condition_status
!= LTTNG_CONDITION_STATUS_OK
) {
1004 fail("Failed to set channel name on creation of condition `%s`",
1010 condition_status
= lttng_condition_buffer_usage_set_domain_type(
1011 condition
, domain_type
);
1012 if (condition_status
!= LTTNG_CONDITION_STATUS_OK
) {
1013 fail("Failed to set domain type on creation of condition `%s`",
1024 void test_invalid_channel_subscription(
1025 const enum lttng_domain_type domain_type
)
1027 enum lttng_condition_status condition_status
;
1028 enum lttng_notification_channel_status nc_status
;
1029 struct lttng_condition
*dummy_condition
= NULL
;
1030 struct lttng_condition
*dummy_invalid_condition
= NULL
;
1031 struct lttng_notification_channel
*notification_channel
= NULL
;
1034 notification_channel
= lttng_notification_channel_create(
1035 lttng_session_daemon_notification_endpoint
);
1036 ok(notification_channel
, "Notification channel object creation");
1037 if (!notification_channel
) {
1042 * Create a dummy, empty (thus invalid) condition to test error paths.
1044 dummy_invalid_condition
= lttng_condition_buffer_usage_low_create();
1045 if (!dummy_invalid_condition
) {
1046 fail("Setup error on condition creation");
1051 * Test subscription and unsubscription of an invalid condition to/from
1054 nc_status
= lttng_notification_channel_subscribe(
1055 notification_channel
, dummy_invalid_condition
);
1056 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_INVALID
,
1057 "Subscribing to an invalid condition");
1059 nc_status
= lttng_notification_channel_unsubscribe(
1060 notification_channel
, dummy_invalid_condition
);
1061 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_INVALID
,
1062 "Unsubscribing from an invalid condition");
1064 /* Create a valid dummy condition with a ratio of 0.5 */
1065 dummy_condition
= lttng_condition_buffer_usage_low_create();
1066 if (!dummy_condition
) {
1067 fail("Setup error on dummy_condition creation");
1071 condition_status
= lttng_condition_buffer_usage_set_threshold_ratio(
1072 dummy_condition
, 0.5);
1073 if (condition_status
!= LTTNG_CONDITION_STATUS_OK
) {
1074 fail("Setup error on condition creation");
1078 ret
= setup_buffer_usage_condition(dummy_condition
, "dummy_condition",
1079 "dummy_session", "dummy_channel", domain_type
);
1081 fail("Setup error on dummy condition creation");
1086 * Test subscription and unsubscription to/from a channel with invalid
1089 nc_status
= lttng_notification_channel_subscribe(NULL
, NULL
);
1090 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_INVALID
,
1091 "Notification channel subscription is invalid: NULL, NULL");
1093 nc_status
= lttng_notification_channel_subscribe(
1094 notification_channel
, NULL
);
1095 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_INVALID
,
1096 "Notification channel subscription is invalid: NON-NULL, NULL");
1098 nc_status
= lttng_notification_channel_subscribe(NULL
, dummy_condition
);
1099 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_INVALID
,
1100 "Notification channel subscription is invalid: NULL, NON-NULL");
1102 nc_status
= lttng_notification_channel_unsubscribe(
1103 notification_channel
, dummy_condition
);
1104 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_UNKNOWN_CONDITION
,
1105 "Unsubscribing from a valid unknown condition");
1108 lttng_notification_channel_destroy(notification_channel
);
1109 lttng_condition_destroy(dummy_invalid_condition
);
1110 lttng_condition_destroy(dummy_condition
);
1114 enum buffer_usage_type
{
1115 BUFFER_USAGE_TYPE_LOW
,
1116 BUFFER_USAGE_TYPE_HIGH
,
1119 static int register_buffer_usage_notify_trigger(const char *session_name
,
1120 const char *channel_name
,
1121 const enum lttng_domain_type domain_type
,
1122 enum buffer_usage_type buffer_usage_type
,
1124 struct lttng_condition
**condition
,
1125 struct lttng_action
**action
,
1126 struct lttng_trigger
**trigger
)
1128 enum lttng_condition_status condition_status
;
1129 struct lttng_action
*tmp_action
= NULL
;
1130 struct lttng_condition
*tmp_condition
= NULL
;
1131 struct lttng_trigger
*tmp_trigger
= NULL
;
1135 tmp_action
= lttng_action_notify_create();
1137 fail("Setup error on action creation");
1142 if (buffer_usage_type
== BUFFER_USAGE_TYPE_LOW
) {
1143 tmp_condition
= lttng_condition_buffer_usage_low_create();
1145 tmp_condition
= lttng_condition_buffer_usage_high_create();
1148 if (!tmp_condition
) {
1149 fail("Setup error on condition creation");
1154 /* Set the buffer usage threashold */
1155 condition_status
= lttng_condition_buffer_usage_set_threshold_ratio(
1156 tmp_condition
, ratio
);
1157 if (condition_status
!= LTTNG_CONDITION_STATUS_OK
) {
1158 fail("Setup error on condition creation");
1163 ret
= setup_buffer_usage_condition(tmp_condition
, "condition_name",
1164 session_name
, channel_name
, domain_type
);
1166 fail("Setup error on condition creation");
1171 /* Register the trigger for condition. */
1172 tmp_trigger
= lttng_trigger_create(tmp_condition
, tmp_action
);
1174 fail("Setup error on trigger creation");
1179 ret
= lttng_register_trigger(tmp_trigger
);
1181 fail("Setup error on trigger registration");
1186 *condition
= tmp_condition
;
1187 *trigger
= tmp_trigger
;
1188 *action
= tmp_action
;
1192 lttng_action_destroy(tmp_action
);
1193 lttng_condition_destroy(tmp_condition
);
1194 lttng_trigger_destroy(tmp_trigger
);
1200 static void test_subscription_twice(const char *session_name
,
1201 const char *channel_name
,
1202 const enum lttng_domain_type domain_type
)
1205 enum lttng_notification_channel_status nc_status
;
1207 struct lttng_action
*action
= NULL
;
1208 struct lttng_notification_channel
*notification_channel
= NULL
;
1209 struct lttng_trigger
*trigger
= NULL
;
1211 struct lttng_condition
*condition
= NULL
;
1213 ret
= register_buffer_usage_notify_trigger(session_name
, channel_name
,
1214 domain_type
, BUFFER_USAGE_TYPE_LOW
, 0.99, &condition
,
1217 fail("Setup error on trigger registration");
1221 /* Begin testing. */
1222 notification_channel
= lttng_notification_channel_create(
1223 lttng_session_daemon_notification_endpoint
);
1224 ok(notification_channel
, "Notification channel object creation");
1225 if (!notification_channel
) {
1229 /* Subscribe a valid condition. */
1230 nc_status
= lttng_notification_channel_subscribe(
1231 notification_channel
, condition
);
1232 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
,
1233 "Subscribe to condition");
1235 /* Subscribing again should fail. */
1236 nc_status
= lttng_notification_channel_subscribe(
1237 notification_channel
, condition
);
1238 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_ALREADY_SUBSCRIBED
,
1239 "Subscribe to a condition for which subscription was already done");
1242 lttng_unregister_trigger(trigger
);
1243 lttng_trigger_destroy(trigger
);
1244 lttng_notification_channel_destroy(notification_channel
);
1245 lttng_action_destroy(action
);
1246 lttng_condition_destroy(condition
);
1249 static void test_buffer_usage_notification_channel(const char *session_name
,
1250 const char *channel_name
,
1251 const enum lttng_domain_type domain_type
,
1255 enum lttng_notification_channel_status nc_status
;
1257 struct lttng_action
*low_action
= NULL
;
1258 struct lttng_action
*high_action
= NULL
;
1259 struct lttng_notification
*notification
= NULL
;
1260 struct lttng_notification_channel
*notification_channel
= NULL
;
1261 struct lttng_trigger
*low_trigger
= NULL
;
1262 struct lttng_trigger
*high_trigger
= NULL
;
1264 struct lttng_condition
*low_condition
= NULL
;
1265 struct lttng_condition
*high_condition
= NULL
;
1267 const double low_ratio
= 0.0;
1268 const double high_ratio
= 0.90;
1270 ret
= register_buffer_usage_notify_trigger(session_name
, channel_name
,
1271 domain_type
, BUFFER_USAGE_TYPE_LOW
, low_ratio
,
1272 &low_condition
, &low_action
, &low_trigger
);
1274 fail("Setup error on low trigger registration");
1278 ret
= register_buffer_usage_notify_trigger(session_name
, channel_name
,
1279 domain_type
, BUFFER_USAGE_TYPE_HIGH
, high_ratio
,
1280 &high_condition
, &high_action
, &high_trigger
);
1282 fail("Setup error on high trigger registration");
1287 notification_channel
= lttng_notification_channel_create(
1288 lttng_session_daemon_notification_endpoint
);
1289 ok(notification_channel
, "Notification channel object creation");
1290 if (!notification_channel
) {
1294 /* Subscribe a valid low condition */
1295 nc_status
= lttng_notification_channel_subscribe(
1296 notification_channel
, low_condition
);
1297 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
,
1298 "Subscribe to low condition");
1300 /* Subscribe a valid high condition */
1301 nc_status
= lttng_notification_channel_subscribe(
1302 notification_channel
, high_condition
);
1303 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
,
1304 "Subscribe to high condition");
1306 resume_application();
1308 /* Wait for notification to happen */
1309 stop_consumer(argv
);
1310 lttng_start_tracing(session_name
);
1312 /* Wait for high notification */
1314 nc_status
= lttng_notification_channel_get_next_notification(
1315 notification_channel
, ¬ification
);
1316 } while (nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_INTERRUPTED
);
1317 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
&& notification
&&
1318 lttng_condition_get_type(lttng_notification_get_condition(
1320 LTTNG_CONDITION_TYPE_BUFFER_USAGE_HIGH
,
1321 "High notification received after intermediary communication");
1322 lttng_notification_destroy(notification
);
1323 notification
= NULL
;
1325 suspend_application();
1326 lttng_stop_tracing_no_wait(session_name
);
1327 resume_consumer(argv
);
1328 wait_data_pending(session_name
);
1331 * Test that communication still work even if there is notification
1332 * waiting for consumption.
1335 nc_status
= lttng_notification_channel_unsubscribe(
1336 notification_channel
, low_condition
);
1337 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
,
1338 "Unsubscribe with pending notification");
1340 nc_status
= lttng_notification_channel_subscribe(
1341 notification_channel
, low_condition
);
1342 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
,
1343 "Subscribe with pending notification");
1346 nc_status
= lttng_notification_channel_get_next_notification(
1347 notification_channel
, ¬ification
);
1348 } while (nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_INTERRUPTED
);
1349 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
&& notification
&&
1350 lttng_condition_get_type(lttng_notification_get_condition(
1352 LTTNG_CONDITION_TYPE_BUFFER_USAGE_LOW
,
1353 "Low notification received after intermediary communication");
1354 lttng_notification_destroy(notification
);
1355 notification
= NULL
;
1357 /* Stop consumer to force a high notification */
1358 stop_consumer(argv
);
1359 resume_application();
1360 lttng_start_tracing(session_name
);
1363 nc_status
= lttng_notification_channel_get_next_notification(
1364 notification_channel
, ¬ification
);
1365 } while (nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_INTERRUPTED
);
1366 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
&& notification
&&
1367 lttng_condition_get_type(lttng_notification_get_condition(
1369 LTTNG_CONDITION_TYPE_BUFFER_USAGE_HIGH
,
1370 "High notification received after intermediary communication");
1371 lttng_notification_destroy(notification
);
1372 notification
= NULL
;
1374 suspend_application();
1375 lttng_stop_tracing_no_wait(session_name
);
1376 resume_consumer(argv
);
1377 wait_data_pending(session_name
);
1380 nc_status
= lttng_notification_channel_get_next_notification(
1381 notification_channel
, ¬ification
);
1382 } while (nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_INTERRUPTED
);
1383 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
&& notification
&&
1384 lttng_condition_get_type(lttng_notification_get_condition(
1386 LTTNG_CONDITION_TYPE_BUFFER_USAGE_LOW
,
1387 "Low notification received after re-subscription");
1388 lttng_notification_destroy(notification
);
1389 notification
= NULL
;
1391 stop_consumer(argv
);
1392 resume_application();
1393 /* Stop consumer to force a high notification */
1394 lttng_start_tracing(session_name
);
1397 nc_status
= lttng_notification_channel_get_next_notification(
1398 notification_channel
, ¬ification
);
1399 } while (nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_INTERRUPTED
);
1400 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
&& notification
&&
1401 lttng_condition_get_type(lttng_notification_get_condition(
1403 LTTNG_CONDITION_TYPE_BUFFER_USAGE_HIGH
,
1404 "High notification");
1405 lttng_notification_destroy(notification
);
1406 notification
= NULL
;
1408 suspend_application();
1410 /* Resume consumer to allow event consumption */
1411 lttng_stop_tracing_no_wait(session_name
);
1412 resume_consumer(argv
);
1413 wait_data_pending(session_name
);
1415 nc_status
= lttng_notification_channel_unsubscribe(
1416 notification_channel
, low_condition
);
1417 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
,
1418 "Unsubscribe low condition with pending notification");
1420 nc_status
= lttng_notification_channel_unsubscribe(
1421 notification_channel
, high_condition
);
1422 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
,
1423 "Unsubscribe high condition with pending notification");
1426 lttng_notification_channel_destroy(notification_channel
);
1427 lttng_trigger_destroy(low_trigger
);
1428 lttng_trigger_destroy(high_trigger
);
1429 lttng_action_destroy(low_action
);
1430 lttng_action_destroy(high_action
);
1431 lttng_condition_destroy(low_condition
);
1432 lttng_condition_destroy(high_condition
);
1435 static void create_tracepoint_event_rule_trigger(const char *event_pattern
,
1436 const char *trigger_name
,
1438 unsigned int exclusion_count
,
1439 const char * const *exclusions
,
1440 enum lttng_domain_type domain_type
,
1441 condition_capture_desc_cb capture_desc_cb
,
1442 struct lttng_condition
**condition
,
1443 struct lttng_trigger
**trigger
)
1445 enum lttng_event_rule_status event_rule_status
;
1446 enum lttng_trigger_status trigger_status
;
1448 struct lttng_action
*tmp_action
= NULL
;
1449 struct lttng_event_rule
*event_rule
= NULL
;
1450 struct lttng_condition
*tmp_condition
= NULL
;
1451 struct lttng_trigger
*tmp_trigger
= NULL
;
1454 assert(event_pattern
);
1455 assert(trigger_name
);
1459 event_rule
= lttng_event_rule_tracepoint_create(domain_type
);
1460 ok(event_rule
, "Tracepoint event rule object creation");
1462 event_rule_status
= lttng_event_rule_tracepoint_set_pattern(
1463 event_rule
, event_pattern
);
1464 ok(event_rule_status
== LTTNG_EVENT_RULE_STATUS_OK
,
1465 "Setting tracepoint event rule pattern: '%s'",
1469 event_rule_status
= lttng_event_rule_tracepoint_set_filter(
1470 event_rule
, filter
);
1471 ok(event_rule_status
== LTTNG_EVENT_RULE_STATUS_OK
,
1472 "Setting tracepoint event rule filter: '%s'",
1478 bool success
= true;
1480 assert(domain_type
== LTTNG_DOMAIN_UST
);
1481 assert(exclusion_count
> 0);
1483 for (i
= 0; i
< exclusion_count
; i
++) {
1485 lttng_event_rule_tracepoint_add_exclusion(
1488 if (event_rule_status
!= LTTNG_EVENT_RULE_STATUS_OK
) {
1489 fail("Setting tracepoint event rule exclusion '%s'.",
1495 ok(success
, "Setting tracepoint event rule exclusions");
1498 tmp_condition
= lttng_condition_on_event_create(event_rule
);
1499 ok(tmp_condition
, "Condition event rule object creation");
1501 if (capture_desc_cb
) {
1502 ret
= capture_desc_cb(tmp_condition
);
1504 fail("Failed to generate the condition capture descriptor");
1509 tmp_action
= lttng_action_notify_create();
1510 ok(tmp_action
, "Action event rule object creation");
1512 tmp_trigger
= lttng_trigger_create(tmp_condition
, tmp_action
);
1513 ok(tmp_trigger
, "Trigger object creation %s", trigger_name
);
1515 trigger_status
= lttng_trigger_set_name(tmp_trigger
, trigger_name
);
1516 ok(trigger_status
== LTTNG_TRIGGER_STATUS_OK
,
1517 "Setting name to trigger %s", trigger_name
);
1519 ret
= lttng_register_trigger(tmp_trigger
);
1520 ok(ret
== 0, "Trigger registration %s", trigger_name
);
1522 lttng_event_rule_destroy(event_rule
);
1524 *condition
= tmp_condition
;
1525 *trigger
= tmp_trigger
;
1530 static struct lttng_notification
*get_next_notification(
1531 struct lttng_notification_channel
*notification_channel
)
1533 struct lttng_notification
*local_notification
= NULL
;
1534 enum lttng_notification_channel_status status
;
1536 /* Receive the next notification. */
1537 status
= lttng_notification_channel_get_next_notification(
1538 notification_channel
, &local_notification
);
1541 case LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
:
1543 case LTTNG_NOTIFICATION_CHANNEL_STATUS_NOTIFICATIONS_DROPPED
:
1544 fail("Notifications have been dropped");
1545 local_notification
= NULL
;
1548 /* Unhandled conditions / errors. */
1549 fail("Failed to get next notification (unknown notification channel status): status = %d",
1551 local_notification
= NULL
;
1555 return local_notification
;
1558 static void test_tracepoint_event_rule_notification(
1559 enum lttng_domain_type domain_type
)
1563 const int notification_count
= 3;
1564 enum lttng_notification_channel_status nc_status
;
1565 struct lttng_action
*action
= NULL
;
1566 struct lttng_condition
*condition
= NULL
;
1567 struct lttng_notification_channel
*notification_channel
= NULL
;
1568 struct lttng_trigger
*trigger
= NULL
;
1569 const char * const trigger_name
= "my_precious";
1570 const char *pattern
;
1572 if (domain_type
== LTTNG_DOMAIN_UST
) {
1573 pattern
= "tp:tptest";
1575 pattern
= "lttng_test_filter_event";
1578 create_tracepoint_event_rule_trigger(pattern
, trigger_name
, NULL
, 0,
1579 NULL
, domain_type
, NULL
, &condition
, &trigger
);
1581 notification_channel
= lttng_notification_channel_create(
1582 lttng_session_daemon_notification_endpoint
);
1583 ok(notification_channel
, "Notification channel object creation");
1585 nc_status
= lttng_notification_channel_subscribe(
1586 notification_channel
, condition
);
1587 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
,
1588 "Subscribe to tracepoint event rule condition");
1590 resume_application();
1592 /* Get notifications. */
1593 for (i
= 0; i
< notification_count
; i
++) {
1594 struct lttng_notification
*notification
= get_next_notification(
1595 notification_channel
);
1597 ok(notification
, "Received notification (%d/%d)", i
+ 1,
1598 notification_count
);
1601 if (notification
== NULL
) {
1605 ret
= validator_notification_trigger_name(notification
, trigger_name
);
1606 lttng_notification_destroy(notification
);
1613 suspend_application();
1614 lttng_notification_channel_destroy(notification_channel
);
1615 lttng_unregister_trigger(trigger
);
1616 lttng_trigger_destroy(trigger
);
1617 lttng_action_destroy(action
);
1618 lttng_condition_destroy(condition
);
1622 static void test_tracepoint_event_rule_notification_filter(
1623 enum lttng_domain_type domain_type
)
1626 const int notification_count
= 3;
1627 enum lttng_notification_channel_status nc_status
;
1628 struct lttng_condition
*ctrl_condition
= NULL
, *condition
= NULL
;
1629 struct lttng_notification_channel
*notification_channel
= NULL
;
1630 struct lttng_trigger
*ctrl_trigger
= NULL
, *trigger
= NULL
;
1631 const char * const ctrl_trigger_name
= "control_trigger";
1632 const char * const trigger_name
= "trigger";
1633 const char *pattern
;
1634 int ctrl_count
= 0, count
= 0;
1636 if (domain_type
== LTTNG_DOMAIN_UST
) {
1637 pattern
= "tp:tptest";
1639 pattern
= "lttng_test_filter_event";
1642 notification_channel
= lttng_notification_channel_create(
1643 lttng_session_daemon_notification_endpoint
);
1644 ok(notification_channel
, "Notification channel object creation");
1646 create_tracepoint_event_rule_trigger(pattern
, ctrl_trigger_name
, NULL
,
1647 0, NULL
, domain_type
, NULL
, &ctrl_condition
, &ctrl_trigger
);
1649 nc_status
= lttng_notification_channel_subscribe(
1650 notification_channel
, ctrl_condition
);
1651 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
,
1652 "Subscribe to tracepoint event rule condition");
1655 * Attach a filter expression to get notification only if the
1656 * `intfield` is even.
1658 create_tracepoint_event_rule_trigger(pattern
, trigger_name
,
1659 "(intfield & 1) == 0", 0, NULL
, domain_type
, NULL
, &condition
,
1662 nc_status
= lttng_notification_channel_subscribe(
1663 notification_channel
, condition
);
1664 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
,
1665 "Subscribe to tracepoint event rule condition");
1668 * We registered 2 notifications triggers, one with a filter and one
1669 * without (control). The one with a filter will only fired when the
1670 * `intfield` is a multiple of 2. We should get two times as many
1671 * control notifications as filter notifications.
1673 resume_application();
1676 * Get 3 notifications. We should get 1 for the regular trigger (with
1677 * the filter) and 2 from the control trigger. This works whatever
1678 * the order we receive the notifications.
1680 for (i
= 0; i
< notification_count
; i
++) {
1682 struct lttng_notification
*notification
= get_next_notification(
1683 notification_channel
);
1685 ok(notification
, "Received notification (%d/%d)", i
+ 1,
1686 notification_count
);
1689 if (notification
== NULL
) {
1693 name
= get_notification_trigger_name(notification
);
1695 lttng_notification_destroy(notification
);
1699 if (strcmp(ctrl_trigger_name
, name
) == 0) {
1701 } else if (strcmp(trigger_name
, name
) == 0) {
1705 lttng_notification_destroy(notification
);
1708 ok(ctrl_count
/ 2 == count
,
1709 "Get twice as many control notif as of regular notif");
1712 suspend_application();
1714 lttng_unregister_trigger(trigger
);
1715 lttng_unregister_trigger(ctrl_trigger
);
1716 lttng_notification_channel_destroy(notification_channel
);
1717 lttng_trigger_destroy(trigger
);
1718 lttng_trigger_destroy(ctrl_trigger
);
1719 lttng_condition_destroy(condition
);
1720 lttng_condition_destroy(ctrl_condition
);
1723 static void test_tracepoint_event_rule_notification_exclusion(
1724 enum lttng_domain_type domain_type
)
1726 enum lttng_notification_channel_status nc_status
;
1727 struct lttng_condition
*ctrl_condition
= NULL
, *condition
= NULL
;
1728 struct lttng_notification_channel
*notification_channel
= NULL
;
1729 struct lttng_trigger
*ctrl_trigger
= NULL
, *trigger
= NULL
;
1730 int ctrl_count
= 0, count
= 0, i
;
1731 const int notification_count
= 6;
1732 const char * const ctrl_trigger_name
= "control_exclusion_trigger";
1733 const char * const trigger_name
= "exclusion_trigger";
1734 const char * const pattern
= "tp:tptest*";
1735 const char * const exclusions
[] = {
1742 notification_channel
= lttng_notification_channel_create(
1743 lttng_session_daemon_notification_endpoint
);
1744 ok(notification_channel
, "Notification channel object creation");
1746 create_tracepoint_event_rule_trigger(pattern
, ctrl_trigger_name
, NULL
,
1747 0, NULL
, domain_type
, NULL
, &ctrl_condition
,
1750 nc_status
= lttng_notification_channel_subscribe(
1751 notification_channel
, ctrl_condition
);
1752 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
,
1753 "Subscribe to tracepoint event rule condition");
1755 create_tracepoint_event_rule_trigger(pattern
, trigger_name
, NULL
, 4,
1756 exclusions
, domain_type
, NULL
, &condition
,
1759 nc_status
= lttng_notification_channel_subscribe(
1760 notification_channel
, condition
);
1761 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
,
1762 "Subscribe to tracepoint event rule condition");
1765 * We registered 2 notifications triggers, one with an exclusion and
1766 * one without (control).
1767 * - The trigger with an exclusion will fire once every iteration.
1768 * - The trigger without an exclusion will fire 5 times every
1771 * We should get 5 times as many notifications from the control
1774 resume_application();
1777 * Get 6 notifications. We should get 1 for the regular trigger (with
1778 * the exclusion) and 5 from the control trigger. This works whatever
1779 * the order we receive the notifications.
1781 for (i
= 0; i
< notification_count
; i
++) {
1783 struct lttng_notification
*notification
= get_next_notification(
1784 notification_channel
);
1786 ok(notification
, "Received notification (%d/%d)", i
+ 1,
1787 notification_count
);
1790 if (notification
== NULL
) {
1794 name
= get_notification_trigger_name(notification
);
1796 lttng_notification_destroy(notification
);
1800 if (strcmp(ctrl_trigger_name
, name
) == 0) {
1802 } else if (strcmp(trigger_name
, name
) == 0) {
1806 lttng_notification_destroy(notification
);
1809 ok(ctrl_count
/ 5 == count
,
1810 "Got 5 times as many control notif as of regular notif");
1813 suspend_application();
1815 lttng_unregister_trigger(trigger
);
1816 lttng_unregister_trigger(ctrl_trigger
);
1817 lttng_notification_channel_destroy(notification_channel
);
1818 lttng_trigger_destroy(trigger
);
1819 lttng_trigger_destroy(ctrl_trigger
);
1820 lttng_condition_destroy(condition
);
1821 lttng_condition_destroy(ctrl_condition
);
1825 static void test_kprobe_event_rule_notification(
1826 enum lttng_domain_type domain_type
)
1829 const int notification_count
= 3;
1830 enum lttng_notification_channel_status nc_status
;
1831 enum lttng_event_rule_status event_rule_status
;
1832 enum lttng_trigger_status trigger_status
;
1833 struct lttng_notification_channel
*notification_channel
= NULL
;
1834 struct lttng_condition
*condition
= NULL
;
1835 struct lttng_kernel_probe_location
*location
= NULL
;
1836 struct lttng_event_rule
*event_rule
= NULL
;
1837 struct lttng_action
*action
= NULL
;
1838 struct lttng_trigger
*trigger
= NULL
;
1839 const char * const trigger_name
= "kprobe_trigger";
1840 const char * const symbol_name
= "lttng_test_filter_event_write";
1842 action
= lttng_action_notify_create();
1844 fail("Failed to create notify action");
1848 location
= lttng_kernel_probe_location_symbol_create(symbol_name
, 0);
1850 fail("Failed to create kernel probe location");
1854 notification_channel
= lttng_notification_channel_create(
1855 lttng_session_daemon_notification_endpoint
);
1856 ok(notification_channel
, "Notification channel object creation");
1858 event_rule
= lttng_event_rule_kernel_probe_create(location
);
1859 ok(event_rule
, "kprobe event rule object creation");
1861 event_rule_status
= lttng_event_rule_kernel_probe_set_event_name(
1862 event_rule
, trigger_name
);
1863 ok(event_rule_status
== LTTNG_EVENT_RULE_STATUS_OK
,
1864 "Setting kprobe event rule name: '%s'", trigger_name
);
1866 condition
= lttng_condition_on_event_create(event_rule
);
1867 ok(condition
, "Condition event rule object creation");
1869 /* Register the trigger for condition. */
1870 trigger
= lttng_trigger_create(condition
, action
);
1872 fail("Failed to create trigger with kernel probe event rule condition and notify action");
1876 trigger_status
= lttng_trigger_set_name(trigger
, trigger_name
);
1877 ok(trigger_status
== LTTNG_TRIGGER_STATUS_OK
,
1878 "Setting trigger name to '%s'", trigger_name
);
1880 ret
= lttng_register_trigger(trigger
);
1882 fail("Failed to register trigger with kernel probe event rule condition and notify action");
1886 nc_status
= lttng_notification_channel_subscribe(
1887 notification_channel
, condition
);
1888 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
,
1889 "Subscribe to tracepoint event rule condition");
1891 resume_application();
1893 for (i
= 0; i
< notification_count
; i
++) {
1894 struct lttng_notification
*notification
= get_next_notification(
1895 notification_channel
);
1897 ok(notification
, "Received notification (%d/%d)", i
+ 1,
1898 notification_count
);
1901 if (notification
== NULL
) {
1905 ret
= validator_notification_trigger_name(notification
, trigger_name
);
1906 lttng_notification_destroy(notification
);
1913 suspend_application();
1914 lttng_notification_channel_destroy(notification_channel
);
1915 lttng_unregister_trigger(trigger
);
1916 lttng_trigger_destroy(trigger
);
1917 lttng_action_destroy(action
);
1918 lttng_event_rule_destroy(event_rule
);
1919 lttng_condition_destroy(condition
);
1920 lttng_kernel_probe_location_destroy(location
);
1924 static void test_uprobe_event_rule_notification(
1925 enum lttng_domain_type domain_type
,
1926 const char *testapp_path
,
1927 const char *test_symbol_name
)
1930 const int notification_count
= 3;
1931 enum lttng_notification_channel_status nc_status
;
1932 enum lttng_event_rule_status event_rule_status
;
1933 enum lttng_trigger_status trigger_status
;
1934 struct lttng_notification_channel
*notification_channel
= NULL
;
1935 struct lttng_userspace_probe_location
*probe_location
= NULL
;
1936 struct lttng_userspace_probe_location_lookup_method
*lookup_method
=
1938 struct lttng_condition
*condition
= NULL
;
1939 struct lttng_event_rule
*event_rule
= NULL
;
1940 struct lttng_action
*action
= NULL
;
1941 struct lttng_trigger
*trigger
= NULL
;
1942 const char * const trigger_name
= "uprobe_trigger";
1944 action
= lttng_action_notify_create();
1946 fail("Failed to create notify action");
1950 lookup_method
= lttng_userspace_probe_location_lookup_method_function_elf_create();
1951 if (!lookup_method
) {
1952 fail("Setup error on userspace probe lookup method creation");
1956 probe_location
= lttng_userspace_probe_location_function_create(
1957 testapp_path
, test_symbol_name
, lookup_method
);
1958 if (!probe_location
) {
1959 fail("Failed to create userspace probe location");
1963 notification_channel
= lttng_notification_channel_create(
1964 lttng_session_daemon_notification_endpoint
);
1965 ok(notification_channel
, "Notification channel object creation");
1967 event_rule
= lttng_event_rule_userspace_probe_create(probe_location
);
1968 ok(event_rule
, "kprobe event rule object creation");
1970 event_rule_status
= lttng_event_rule_userspace_probe_set_event_name(
1971 event_rule
, trigger_name
);
1972 ok(event_rule_status
== LTTNG_EVENT_RULE_STATUS_OK
,
1973 "Setting uprobe event rule name: '%s'", trigger_name
);
1975 condition
= lttng_condition_on_event_create(event_rule
);
1976 ok(condition
, "Condition event rule object creation");
1978 /* Register the trigger for condition. */
1979 trigger
= lttng_trigger_create(condition
, action
);
1981 fail("Failed to create trigger with userspace probe event rule condition and notify action");
1985 trigger_status
= lttng_trigger_set_name(trigger
, trigger_name
);
1986 ok(trigger_status
== LTTNG_TRIGGER_STATUS_OK
,
1987 "Setting name to trigger '%s'", trigger_name
);
1989 ret
= lttng_register_trigger(trigger
);
1991 fail("Failed to register trigger with userspace probe event rule condition and notify action");
1995 nc_status
= lttng_notification_channel_subscribe(
1996 notification_channel
, condition
);
1997 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
,
1998 "Subscribe to tracepoint event rule condition");
2000 resume_application();
2002 for (i
= 0; i
< 3; i
++) {
2003 struct lttng_notification
*notification
= get_next_notification(
2004 notification_channel
);
2006 ok(notification
, "Received notification (%d/%d)", i
+ 1,
2007 notification_count
);
2010 if (notification
== NULL
) {
2014 ret
= validator_notification_trigger_name(notification
, trigger_name
);
2015 lttng_notification_destroy(notification
);
2021 suspend_application();
2023 lttng_notification_channel_destroy(notification_channel
);
2024 lttng_unregister_trigger(trigger
);
2025 lttng_trigger_destroy(trigger
);
2026 lttng_action_destroy(action
);
2027 lttng_userspace_probe_location_destroy(probe_location
);
2028 lttng_event_rule_destroy(event_rule
);
2029 lttng_condition_destroy(condition
);
2033 static void test_syscall_event_rule_notification(
2034 enum lttng_domain_type domain_type
)
2037 const int notification_count
= 3;
2038 enum lttng_notification_channel_status nc_status
;
2039 enum lttng_event_rule_status event_rule_status
;
2040 enum lttng_trigger_status trigger_status
;
2041 struct lttng_notification_channel
*notification_channel
= NULL
;
2042 struct lttng_condition
*condition
= NULL
;
2043 struct lttng_event_rule
*event_rule
= NULL
;
2044 struct lttng_action
*action
= NULL
;
2045 struct lttng_trigger
*trigger
= NULL
;
2046 const char * const trigger_name
= "syscall_trigger";
2047 const char * const syscall_name
= "openat";
2049 action
= lttng_action_notify_create();
2051 fail("Failed to create notify action");
2055 notification_channel
= lttng_notification_channel_create(
2056 lttng_session_daemon_notification_endpoint
);
2057 ok(notification_channel
, "Notification channel object creation");
2059 event_rule
= lttng_event_rule_syscall_create();
2060 ok(event_rule
, "syscall event rule object creation");
2062 event_rule_status
= lttng_event_rule_syscall_set_pattern(
2063 event_rule
, syscall_name
);
2064 ok(event_rule_status
== LTTNG_EVENT_RULE_STATUS_OK
,
2065 "Setting syscall event rule pattern: '%s'", syscall_name
);
2067 condition
= lttng_condition_on_event_create(event_rule
);
2068 ok(condition
, "Condition syscall event rule object creation");
2070 /* Register the trigger for condition. */
2071 trigger
= lttng_trigger_create(condition
, action
);
2073 fail("Failed to create trigger with syscall event rule condition and notify action");
2077 trigger_status
= lttng_trigger_set_name(trigger
, trigger_name
);
2078 ok(trigger_status
== LTTNG_TRIGGER_STATUS_OK
,
2079 "Setting name to trigger '%s'", trigger_name
);
2081 ret
= lttng_register_trigger(trigger
);
2083 fail("Failed to register trigger with syscall event rule condition and notify action");
2087 nc_status
= lttng_notification_channel_subscribe(
2088 notification_channel
, condition
);
2089 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
,
2090 "Subscribe to tracepoint event rule condition");
2092 resume_application();
2094 for (i
= 0; i
< notification_count
; i
++) {
2095 struct lttng_notification
*notification
= get_next_notification(
2096 notification_channel
);
2098 ok(notification
, "Received notification (%d/%d)", i
+ 1,
2099 notification_count
);
2102 if (notification
== NULL
) {
2106 ret
= validator_notification_trigger_name(notification
, trigger_name
);
2107 lttng_notification_destroy(notification
);
2113 suspend_application();
2114 lttng_notification_channel_destroy(notification_channel
);
2115 lttng_unregister_trigger(trigger
);
2116 lttng_trigger_destroy(trigger
);
2117 lttng_action_destroy(action
);
2118 lttng_condition_destroy(condition
);
2122 static void test_syscall_event_rule_notification_filter(
2123 enum lttng_domain_type domain_type
)
2126 const int notification_count
= 3;
2127 enum lttng_notification_channel_status nc_status
;
2128 enum lttng_event_rule_status event_rule_status
;
2129 enum lttng_trigger_status trigger_status
;
2130 struct lttng_notification_channel
*notification_channel
= NULL
;
2131 struct lttng_condition
*condition
= NULL
;
2132 struct lttng_event_rule
*event_rule
= NULL
;
2133 struct lttng_action
*action
= NULL
;
2134 struct lttng_trigger
*trigger
= NULL
;
2135 const char * const trigger_name
= "syscall_trigger";
2136 const char * const syscall_name
= "openat";
2137 const char * const filter_pattern
= "filename == \"/proc/cpuinfo\"";
2139 action
= lttng_action_notify_create();
2141 fail("Failed to create notify action");
2145 notification_channel
= lttng_notification_channel_create(
2146 lttng_session_daemon_notification_endpoint
);
2147 ok(notification_channel
, "Notification channel object creation");
2149 event_rule
= lttng_event_rule_syscall_create();
2150 ok(event_rule
, "syscall event rule object creation");
2152 event_rule_status
= lttng_event_rule_syscall_set_pattern(
2153 event_rule
, syscall_name
);
2154 ok(event_rule_status
== LTTNG_EVENT_RULE_STATUS_OK
,
2155 "Setting syscall event rule pattern: '%s'", syscall_name
);
2157 event_rule_status
= lttng_event_rule_syscall_set_filter(
2158 event_rule
, filter_pattern
);
2159 ok(event_rule_status
== LTTNG_EVENT_RULE_STATUS_OK
,
2160 "Setting filter: '%s'", filter_pattern
);
2162 condition
= lttng_condition_on_event_create(event_rule
);
2163 ok(condition
, "Condition event rule object creation");
2165 /* Register the triggers for condition */
2166 trigger
= lttng_trigger_create(condition
, action
);
2168 fail("Failed to create trigger with syscall filtering event rule condition and notify action");
2172 trigger_status
= lttng_trigger_set_name(trigger
, trigger_name
);
2173 ok(trigger_status
== LTTNG_TRIGGER_STATUS_OK
,
2174 "Setting name to trigger '%s'", trigger_name
);
2176 ret
= lttng_register_trigger(trigger
);
2178 fail("Failed to register trigger with syscall filtering event rule condition and notify action");
2182 nc_status
= lttng_notification_channel_subscribe(
2183 notification_channel
, condition
);
2184 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
,
2185 "Subscribe to tracepoint event rule condition");
2187 resume_application();
2189 for (i
= 0; i
< notification_count
; i
++) {
2190 struct lttng_notification
*notification
= get_next_notification(
2191 notification_channel
);
2193 ok(notification
, "Received notification (%d/%d)", i
+ 1,
2194 notification_count
);
2197 if (notification
== NULL
) {
2201 ret
= validator_notification_trigger_name(notification
, trigger_name
);
2202 lttng_notification_destroy(notification
);
2209 suspend_application();
2211 lttng_unregister_trigger(trigger
);
2212 lttng_notification_channel_destroy(notification_channel
);
2213 lttng_trigger_destroy(trigger
);
2214 lttng_event_rule_destroy(event_rule
);
2215 lttng_condition_destroy(condition
);
2219 static int generate_capture_descr(struct lttng_condition
*condition
)
2222 struct lttng_event_expr
*expr
= NULL
;
2223 const unsigned int basic_field_count
= sizeof(test_capture_base_fields
) /
2224 sizeof(*test_capture_base_fields
);
2225 enum lttng_condition_status cond_status
;
2227 for (i
= 0; i
< basic_field_count
; i
++) {
2228 diag("Adding capture descriptor '%s'",
2229 test_capture_base_fields
[i
].field_name
);
2231 switch (test_capture_base_fields
[i
].field_type
) {
2232 case FIELD_TYPE_PAYLOAD
:
2233 expr
= lttng_event_expr_event_payload_field_create(
2234 test_capture_base_fields
[i
].field_name
);
2236 case FIELD_TYPE_CONTEXT
:
2237 expr
= lttng_event_expr_channel_context_field_create(
2238 test_capture_base_fields
[i
].field_name
);
2240 case FIELD_TYPE_ARRAY_FIELD
:
2244 char field_name
[FIELD_NAME_MAX_LEN
];
2245 struct lttng_event_expr
*array_expr
= NULL
;
2247 nb_matches
= sscanf(test_capture_base_fields
[i
].field_name
,
2248 "%[^[][%u]", field_name
, &index
);
2249 if (nb_matches
!= 2) {
2250 fail("Unexpected array field name format: field name = '%s'",
2251 test_capture_base_fields
[i
].field_name
);
2256 array_expr
= lttng_event_expr_event_payload_field_create(
2259 expr
= lttng_event_expr_array_field_element_create(
2263 case FIELD_TYPE_APP_CONTEXT
:
2264 fail("Application context tests are not implemented yet.");
2272 fail("Failed to create capture expression");
2277 cond_status
= lttng_condition_on_event_append_capture_descriptor(
2279 if (cond_status
!= LTTNG_CONDITION_STATUS_OK
) {
2280 fail("Failed to append 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_on_event_status on_event_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("Failed to get evaluation from notification during trigger capture test");
2313 on_event_evaluation_status
=
2314 lttng_evaluation_on_event_get_captured_values(
2315 evaluation
, &captured_fields
);
2316 if (on_event_evaluation_status
!= LTTNG_EVALUATION_ON_EVENT_STATUS_OK
) {
2317 diag("Failed to get event rule evaluation captured values: status = %d",
2318 (int) on_event_evaluation_status
);
2323 event_field_value_status
=
2324 lttng_event_field_value_array_get_length(captured_fields
,
2326 if (event_field_value_status
!= LTTNG_EVENT_FIELD_VALUE_STATUS_OK
) {
2327 fail("Failed to get count of captured value field array");
2332 for (i
= 0; i
< capture_count
; i
++) {
2333 const struct lttng_event_field_value
*captured_field
= NULL
;
2334 validate_cb validate
;
2337 diag("Validating capture of field '%s'",
2338 test_capture_base_fields
[i
].field_name
);
2339 event_field_value_status
=
2340 lttng_event_field_value_array_get_element_at_index(
2345 case LTTNG_DOMAIN_UST
:
2346 expected
= test_capture_base_fields
[i
].expected_ust
;
2348 case LTTNG_DOMAIN_KERNEL
:
2349 expected
= test_capture_base_fields
[i
].expected_kernel
;
2352 fail("Unexpected domain encountered: domain = %d",
2358 if (domain
== LTTNG_DOMAIN_UST
) {
2359 validate
= test_capture_base_fields
[i
].validate_ust
;
2361 validate
= test_capture_base_fields
[i
].validate_kernel
;
2365 ok(event_field_value_status
== LTTNG_EVENT_FIELD_VALUE_STATUS_UNAVAILABLE
,
2366 "No payload captured");
2370 if (event_field_value_status
!= LTTNG_EVENT_FIELD_VALUE_STATUS_OK
) {
2371 if (event_field_value_status
==
2372 LTTNG_EVENT_FIELD_VALUE_STATUS_UNAVAILABLE
) {
2373 fail("Expected a capture but it is unavailable");
2375 fail("lttng_event_field_value_array_get_element_at_index returned an error: status = %d",
2376 (int) event_field_value_status
);
2383 diag("Captured field of type %s",
2384 field_value_type_to_str(
2385 lttng_event_field_value_get_type(captured_field
)));
2388 ret
= validate(captured_field
, iteration
);
2390 at_least_one_error
= true;
2394 ret
= at_least_one_error
;
2400 static void test_tracepoint_event_rule_notification_capture(
2401 enum lttng_domain_type domain_type
)
2403 enum lttng_notification_channel_status nc_status
;
2406 struct lttng_condition
*condition
= NULL
;
2407 struct lttng_notification_channel
*notification_channel
= NULL
;
2408 struct lttng_trigger
*trigger
= NULL
;
2409 const char *trigger_name
= "my_precious";
2410 const char *pattern
;
2412 if (domain_type
== LTTNG_DOMAIN_UST
) {
2413 pattern
= "tp:tptest";
2415 pattern
= "lttng_test_filter_event";
2418 create_tracepoint_event_rule_trigger(pattern
, trigger_name
, NULL
, 0,
2419 NULL
, domain_type
, generate_capture_descr
, &condition
,
2422 notification_channel
= lttng_notification_channel_create(
2423 lttng_session_daemon_notification_endpoint
);
2424 ok(notification_channel
, "Notification channel object creation");
2426 nc_status
= lttng_notification_channel_subscribe(
2427 notification_channel
, condition
);
2428 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
,
2429 "Subscribe to tracepoint event rule condition");
2431 resume_application();
2433 /* Get 3 notifications */
2434 for (i
= 0; i
< 3; i
++) {
2435 struct lttng_notification
*notification
= get_next_notification(
2436 notification_channel
);
2437 ok(notification
, "Received notification");
2440 if (notification
== NULL
) {
2444 ret
= validator_notification_trigger_name(notification
, trigger_name
);
2446 lttng_notification_destroy(notification
);
2450 ret
= validator_notification_trigger_capture(domain_type
, notification
, i
);
2452 lttng_notification_destroy(notification
);
2456 lttng_notification_destroy(notification
);
2460 suspend_application();
2461 lttng_notification_channel_destroy(notification_channel
);
2462 lttng_unregister_trigger(trigger
);
2463 lttng_trigger_destroy(trigger
);
2464 lttng_condition_destroy(condition
);
2468 int main(int argc
, const char *argv
[])
2471 const char *domain_type_string
= NULL
;
2472 enum lttng_domain_type domain_type
= LTTNG_DOMAIN_NONE
;
2475 fail("Missing test scenario, domain type, pid, or application state file argument(s)");
2479 test_scenario
= atoi(argv
[1]);
2480 domain_type_string
= argv
[2];
2481 app_pid
= (pid_t
) atoi(argv
[3]);
2482 app_state_file
= argv
[4];
2484 if (!strcmp("LTTNG_DOMAIN_UST", domain_type_string
)) {
2485 domain_type
= LTTNG_DOMAIN_UST
;
2487 if (!strcmp("LTTNG_DOMAIN_KERNEL", domain_type_string
)) {
2488 domain_type
= LTTNG_DOMAIN_KERNEL
;
2490 if (domain_type
== LTTNG_DOMAIN_NONE
) {
2491 fail("Unknown domain type");
2496 * Test cases are responsible for resuming the app when needed
2497 * and making sure it's suspended when returning.
2499 suspend_application();
2501 switch (test_scenario
) {
2506 /* Test cases that need gen-ust-event testapp. */
2507 diag("Test basic notification error paths for %s domain",
2508 domain_type_string
);
2509 test_invalid_channel_subscription(domain_type
);
2511 diag("Test tracepoint event rule notifications for domain %s",
2512 domain_type_string
);
2513 test_tracepoint_event_rule_notification(domain_type
);
2515 diag("Test tracepoint event rule notifications with filter for domain %s",
2516 domain_type_string
);
2517 test_tracepoint_event_rule_notification_filter(domain_type
);
2522 const char *session_name
, *channel_name
;
2524 /* Test cases that need a tracing session enabled. */
2528 * Argument 7 and upward are named pipe location for consumerd
2531 named_pipe_args_start
= 7;
2534 fail("Missing parameter for tests to run %d", argc
);
2540 session_name
= argv
[5];
2541 channel_name
= argv
[6];
2543 test_subscription_twice(session_name
, channel_name
,
2546 diag("Test trigger for domain %s with buffer_usage_low condition",
2547 domain_type_string
);
2548 test_triggers_buffer_usage_condition(session_name
, channel_name
,
2550 LTTNG_CONDITION_TYPE_BUFFER_USAGE_LOW
);
2552 diag("Test trigger for domain %s with buffer_usage_high condition",
2553 domain_type_string
);
2554 test_triggers_buffer_usage_condition(session_name
, channel_name
,
2556 LTTNG_CONDITION_TYPE_BUFFER_USAGE_HIGH
);
2558 diag("Test buffer usage notification channel api for domain %s",
2559 domain_type_string
);
2560 test_buffer_usage_notification_channel(session_name
, channel_name
,
2567 * Test cases that need a test app with more than one event
2573 * At the moment, the only test case of this scenario is
2574 * exclusion which is only supported by UST.
2576 assert(domain_type
== LTTNG_DOMAIN_UST
);
2577 diag("Test tracepoint event rule notifications with exclusion for domain %s",
2578 domain_type_string
);
2579 test_tracepoint_event_rule_notification_exclusion(domain_type
);
2586 /* Test cases that need the kernel tracer. */
2587 assert(domain_type
== LTTNG_DOMAIN_KERNEL
);
2589 diag("Test kprobe event rule notifications for domain %s",
2590 domain_type_string
);
2592 test_kprobe_event_rule_notification(domain_type
);
2599 /* Test cases that need the kernel tracer. */
2600 assert(domain_type
== LTTNG_DOMAIN_KERNEL
);
2602 diag("Test syscall event rule notifications for domain %s",
2603 domain_type_string
);
2605 test_syscall_event_rule_notification(domain_type
);
2607 diag("Test syscall filtering event rule notifications for domain %s",
2608 domain_type_string
);
2610 test_syscall_event_rule_notification_filter(domain_type
);
2616 const char *testapp_path
, *test_symbol_name
;
2621 fail("Missing parameter for tests to run %d", argc
);
2625 testapp_path
= argv
[5];
2626 test_symbol_name
= argv
[6];
2627 /* Test cases that need the kernel tracer. */
2628 assert(domain_type
== LTTNG_DOMAIN_KERNEL
);
2630 diag("Test userspace-probe event rule notifications for domain %s",
2631 domain_type_string
);
2633 test_uprobe_event_rule_notification(
2634 domain_type
, testapp_path
, test_symbol_name
);
2640 switch(domain_type
) {
2641 case LTTNG_DOMAIN_UST
:
2644 case LTTNG_DOMAIN_KERNEL
:
2651 diag("Test tracepoint event rule notification captures for domain %s",
2652 domain_type_string
);
2653 test_tracepoint_event_rule_notification_capture(domain_type
);
2663 return exit_status();