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 switch (trigger_status
) {
594 case LTTNG_TRIGGER_STATUS_OK
:
596 case LTTNG_TRIGGER_STATUS_UNSET
:
597 trigger_name
= "(anonymous)";
600 fail("Failed to get name from notification's trigger");
608 static int validator_notification_trigger_name(
609 struct lttng_notification
*notification
,
610 const char *trigger_name
)
616 assert(notification
);
617 assert(trigger_name
);
619 name
= get_notification_trigger_name(notification
);
625 name_is_equal
= (strcmp(trigger_name
, name
) == 0);
626 ok(name_is_equal
, "Expected trigger name: %s got %s", trigger_name
,
629 ret
= !name_is_equal
;
636 void wait_on_file(const char *path
, bool file_exist
)
645 ret
= stat(path
, &buf
);
646 if (ret
== -1 && errno
== ENOENT
) {
649 * The file does not exist. wait a bit and
650 * continue looping until it does.
652 (void) poll(NULL
, 0, 10);
657 * File does not exist and the exit condition we want.
658 * Break from the loop and return.
667 * stat() returned 0, so the file exists. break now only if
668 * that's the exit condition we want.
677 int write_pipe(const char *path
, uint8_t data
)
682 fd
= open(path
, O_WRONLY
| O_NONBLOCK
);
684 perror("Could not open consumer control named pipe");
688 ret
= write(fd
, &data
, sizeof(data
));
690 perror("Named pipe write failed");
692 perror("Named pipe close failed");
700 perror("Name pipe closing failed");
709 int stop_consumer(const char **argv
)
713 for (i
= named_pipe_args_start
; i
< nb_args
; i
++) {
714 ret
= write_pipe(argv
[i
], 49);
720 int resume_consumer(const char **argv
)
724 for (i
= named_pipe_args_start
; i
< nb_args
; i
++) {
725 ret
= write_pipe(argv
[i
], 0);
731 int suspend_application(void)
736 if (!stat(app_state_file
, &buf
)) {
737 fail("App is already in a suspended state.");
743 * Send SIGUSR1 to application instructing it to bypass tracepoint.
747 ret
= kill(app_pid
, SIGUSR1
);
749 fail("SIGUSR1 failed. errno %d", errno
);
754 wait_on_file(app_state_file
, true);
762 int resume_application(void)
767 ret
= stat(app_state_file
, &buf
);
768 if (ret
== -1 && errno
== ENOENT
) {
769 fail("State file does not exist");
779 ret
= kill(app_pid
, SIGUSR1
);
781 fail("SIGUSR1 failed. errno %d", errno
);
786 wait_on_file(app_state_file
, false);
795 void test_triggers_buffer_usage_condition(const char *session_name
,
796 const char *channel_name
,
797 enum lttng_domain_type domain_type
,
798 enum lttng_condition_type condition_type
)
800 unsigned int test_vector_size
= 5, i
;
801 enum lttng_condition_status condition_status
;
802 struct lttng_action
*action
;
805 action
= lttng_action_notify_create();
807 fail("Setup error on action creation");
811 /* Test lttng_register_trigger with null value */
812 ok(lttng_register_trigger(NULL
) == -LTTNG_ERR_INVALID
, "Registering a NULL trigger fails as expected");
814 /* Test: register a trigger */
816 for (i
= 0; i
< pow(2,test_vector_size
); i
++) {
818 char *test_tuple_string
= NULL
;
819 unsigned int mask_position
= 0;
820 bool session_name_set
= false;
821 bool channel_name_set
= false;
822 bool threshold_ratio_set
= false;
823 bool threshold_byte_set
= false;
824 bool domain_type_set
= false;
826 struct lttng_trigger
*trigger
= NULL
;
827 struct lttng_condition
*condition
= NULL
;
829 /* Create base condition */
830 switch (condition_type
) {
831 case LTTNG_CONDITION_TYPE_BUFFER_USAGE_LOW
:
832 condition
= lttng_condition_buffer_usage_low_create();
834 case LTTNG_CONDITION_TYPE_BUFFER_USAGE_HIGH
:
835 condition
= lttng_condition_buffer_usage_high_create();
848 /* Prepare the condition for trigger registration test */
850 /* Set session name */
851 if ((1 << mask_position
) & i
) {
852 condition_status
= lttng_condition_buffer_usage_set_session_name(
853 condition
, session_name
);
854 if (condition_status
!= LTTNG_CONDITION_STATUS_OK
) {
858 session_name_set
= true;
862 /* Set channel name */
863 if ((1 << mask_position
) & i
) {
864 condition_status
= lttng_condition_buffer_usage_set_channel_name(
865 condition
, channel_name
);
866 if (condition_status
!= LTTNG_CONDITION_STATUS_OK
) {
870 channel_name_set
= true;
874 /* Set threshold ratio */
875 if ((1 << mask_position
) & i
) {
876 condition_status
= lttng_condition_buffer_usage_set_threshold_ratio(
878 if (condition_status
!= LTTNG_CONDITION_STATUS_OK
) {
882 threshold_ratio_set
= true;
886 /* Set threshold byte */
887 if ((1 << mask_position
) & i
) {
888 condition_status
= lttng_condition_buffer_usage_set_threshold(
890 if (condition_status
!= LTTNG_CONDITION_STATUS_OK
) {
894 threshold_byte_set
= true;
898 /* Set domain type */
899 if ((1 << mask_position
) & i
) {
900 condition_status
= lttng_condition_buffer_usage_set_domain_type(
901 condition
, LTTNG_DOMAIN_UST
);
902 if (condition_status
!= LTTNG_CONDITION_STATUS_OK
) {
906 domain_type_set
= true;
910 if (mask_position
!= test_vector_size
-1) {
911 assert("Logic error for test vector generation");
914 loop_ret
= asprintf(&test_tuple_string
, "session name %s, channel name %s, threshold ratio %s, threshold byte %s, domain type %s",
915 session_name_set
? "set" : "unset",
916 channel_name_set
? "set" : "unset",
917 threshold_ratio_set
? "set" : "unset",
918 threshold_byte_set
? "set" : "unset",
919 domain_type_set
? "set" : "unset");
920 if (!test_tuple_string
|| loop_ret
< 0) {
926 trigger
= lttng_trigger_create(condition
, action
);
932 loop_ret
= lttng_register_trigger(trigger
);
936 fail("Setup error occurred for tuple: %s", test_tuple_string
);
940 /* This combination happens three times */
941 if (session_name_set
&& channel_name_set
942 && (threshold_ratio_set
|| threshold_byte_set
)
943 && domain_type_set
) {
944 ok(loop_ret
== 0, "Trigger is registered: %s", test_tuple_string
);
947 * Test that a trigger cannot be registered
950 loop_ret
= lttng_register_trigger(trigger
);
951 ok(loop_ret
== -LTTNG_ERR_TRIGGER_EXISTS
, "Re-register trigger fails as expected: %s", test_tuple_string
);
953 /* Test that a trigger can be unregistered */
954 loop_ret
= lttng_unregister_trigger(trigger
);
955 ok(loop_ret
== 0, "Unregister trigger: %s", test_tuple_string
);
958 * Test that unregistration of a non-previously
959 * registered trigger fail.
961 loop_ret
= lttng_unregister_trigger(trigger
);
962 ok(loop_ret
== -LTTNG_ERR_TRIGGER_NOT_FOUND
, "Unregister of a non-registered trigger fails as expected: %s", test_tuple_string
);
964 ok(loop_ret
== -LTTNG_ERR_INVALID_TRIGGER
, "Trigger is invalid as expected and cannot be registered: %s", test_tuple_string
);
968 free(test_tuple_string
);
969 lttng_trigger_destroy(trigger
);
970 lttng_condition_destroy(condition
);
974 lttng_action_destroy(action
);
978 void wait_data_pending(const char *session_name
)
983 ret
= lttng_data_pending(session_name
);
989 int setup_buffer_usage_condition(struct lttng_condition
*condition
,
990 const char *condition_name
,
991 const char *session_name
,
992 const char *channel_name
,
993 const enum lttng_domain_type domain_type
)
995 enum lttng_condition_status condition_status
;
998 condition_status
= lttng_condition_buffer_usage_set_session_name(
999 condition
, session_name
);
1000 if (condition_status
!= LTTNG_CONDITION_STATUS_OK
) {
1001 fail("Failed to set session name on creation of condition `%s`",
1007 condition_status
= lttng_condition_buffer_usage_set_channel_name(
1008 condition
, channel_name
);
1009 if (condition_status
!= LTTNG_CONDITION_STATUS_OK
) {
1010 fail("Failed to set channel name on creation of condition `%s`",
1016 condition_status
= lttng_condition_buffer_usage_set_domain_type(
1017 condition
, domain_type
);
1018 if (condition_status
!= LTTNG_CONDITION_STATUS_OK
) {
1019 fail("Failed to set domain type on creation of condition `%s`",
1030 void test_invalid_channel_subscription(
1031 const enum lttng_domain_type domain_type
)
1033 enum lttng_condition_status condition_status
;
1034 enum lttng_notification_channel_status nc_status
;
1035 struct lttng_condition
*dummy_condition
= NULL
;
1036 struct lttng_condition
*dummy_invalid_condition
= NULL
;
1037 struct lttng_notification_channel
*notification_channel
= NULL
;
1040 notification_channel
= lttng_notification_channel_create(
1041 lttng_session_daemon_notification_endpoint
);
1042 ok(notification_channel
, "Notification channel object creation");
1043 if (!notification_channel
) {
1048 * Create a dummy, empty (thus invalid) condition to test error paths.
1050 dummy_invalid_condition
= lttng_condition_buffer_usage_low_create();
1051 if (!dummy_invalid_condition
) {
1052 fail("Setup error on condition creation");
1057 * Test subscription and unsubscription of an invalid condition to/from
1060 nc_status
= lttng_notification_channel_subscribe(
1061 notification_channel
, dummy_invalid_condition
);
1062 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_INVALID
,
1063 "Subscribing to an invalid condition");
1065 nc_status
= lttng_notification_channel_unsubscribe(
1066 notification_channel
, dummy_invalid_condition
);
1067 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_INVALID
,
1068 "Unsubscribing from an invalid condition");
1070 /* Create a valid dummy condition with a ratio of 0.5 */
1071 dummy_condition
= lttng_condition_buffer_usage_low_create();
1072 if (!dummy_condition
) {
1073 fail("Setup error on dummy_condition creation");
1077 condition_status
= lttng_condition_buffer_usage_set_threshold_ratio(
1078 dummy_condition
, 0.5);
1079 if (condition_status
!= LTTNG_CONDITION_STATUS_OK
) {
1080 fail("Setup error on condition creation");
1084 ret
= setup_buffer_usage_condition(dummy_condition
, "dummy_condition",
1085 "dummy_session", "dummy_channel", domain_type
);
1087 fail("Setup error on dummy condition creation");
1092 * Test subscription and unsubscription to/from a channel with invalid
1095 nc_status
= lttng_notification_channel_subscribe(NULL
, NULL
);
1096 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_INVALID
,
1097 "Notification channel subscription is invalid: NULL, NULL");
1099 nc_status
= lttng_notification_channel_subscribe(
1100 notification_channel
, NULL
);
1101 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_INVALID
,
1102 "Notification channel subscription is invalid: NON-NULL, NULL");
1104 nc_status
= lttng_notification_channel_subscribe(NULL
, dummy_condition
);
1105 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_INVALID
,
1106 "Notification channel subscription is invalid: NULL, NON-NULL");
1108 nc_status
= lttng_notification_channel_unsubscribe(
1109 notification_channel
, dummy_condition
);
1110 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_UNKNOWN_CONDITION
,
1111 "Unsubscribing from a valid unknown condition");
1114 lttng_notification_channel_destroy(notification_channel
);
1115 lttng_condition_destroy(dummy_invalid_condition
);
1116 lttng_condition_destroy(dummy_condition
);
1120 enum buffer_usage_type
{
1121 BUFFER_USAGE_TYPE_LOW
,
1122 BUFFER_USAGE_TYPE_HIGH
,
1125 static int register_buffer_usage_notify_trigger(const char *session_name
,
1126 const char *channel_name
,
1127 const enum lttng_domain_type domain_type
,
1128 enum buffer_usage_type buffer_usage_type
,
1130 struct lttng_condition
**condition
,
1131 struct lttng_action
**action
,
1132 struct lttng_trigger
**trigger
)
1134 enum lttng_condition_status condition_status
;
1135 struct lttng_action
*tmp_action
= NULL
;
1136 struct lttng_condition
*tmp_condition
= NULL
;
1137 struct lttng_trigger
*tmp_trigger
= NULL
;
1141 tmp_action
= lttng_action_notify_create();
1143 fail("Setup error on action creation");
1148 if (buffer_usage_type
== BUFFER_USAGE_TYPE_LOW
) {
1149 tmp_condition
= lttng_condition_buffer_usage_low_create();
1151 tmp_condition
= lttng_condition_buffer_usage_high_create();
1154 if (!tmp_condition
) {
1155 fail("Setup error on condition creation");
1160 /* Set the buffer usage threashold */
1161 condition_status
= lttng_condition_buffer_usage_set_threshold_ratio(
1162 tmp_condition
, ratio
);
1163 if (condition_status
!= LTTNG_CONDITION_STATUS_OK
) {
1164 fail("Setup error on condition creation");
1169 ret
= setup_buffer_usage_condition(tmp_condition
, "condition_name",
1170 session_name
, channel_name
, domain_type
);
1172 fail("Setup error on condition creation");
1177 /* Register the trigger for condition. */
1178 tmp_trigger
= lttng_trigger_create(tmp_condition
, tmp_action
);
1180 fail("Setup error on trigger creation");
1185 ret
= lttng_register_trigger(tmp_trigger
);
1187 fail("Setup error on trigger registration");
1192 *condition
= tmp_condition
;
1193 *trigger
= tmp_trigger
;
1194 *action
= tmp_action
;
1198 lttng_action_destroy(tmp_action
);
1199 lttng_condition_destroy(tmp_condition
);
1200 lttng_trigger_destroy(tmp_trigger
);
1206 static void test_subscription_twice(const char *session_name
,
1207 const char *channel_name
,
1208 const enum lttng_domain_type domain_type
)
1211 enum lttng_notification_channel_status nc_status
;
1213 struct lttng_action
*action
= NULL
;
1214 struct lttng_notification_channel
*notification_channel
= NULL
;
1215 struct lttng_trigger
*trigger
= NULL
;
1217 struct lttng_condition
*condition
= NULL
;
1219 ret
= register_buffer_usage_notify_trigger(session_name
, channel_name
,
1220 domain_type
, BUFFER_USAGE_TYPE_LOW
, 0.99, &condition
,
1223 fail("Setup error on trigger registration");
1227 /* Begin testing. */
1228 notification_channel
= lttng_notification_channel_create(
1229 lttng_session_daemon_notification_endpoint
);
1230 ok(notification_channel
, "Notification channel object creation");
1231 if (!notification_channel
) {
1235 /* Subscribe a valid condition. */
1236 nc_status
= lttng_notification_channel_subscribe(
1237 notification_channel
, condition
);
1238 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
,
1239 "Subscribe to condition");
1241 /* Subscribing again should fail. */
1242 nc_status
= lttng_notification_channel_subscribe(
1243 notification_channel
, condition
);
1244 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_ALREADY_SUBSCRIBED
,
1245 "Subscribe to a condition for which subscription was already done");
1248 lttng_unregister_trigger(trigger
);
1249 lttng_trigger_destroy(trigger
);
1250 lttng_notification_channel_destroy(notification_channel
);
1251 lttng_action_destroy(action
);
1252 lttng_condition_destroy(condition
);
1255 static void test_buffer_usage_notification_channel(const char *session_name
,
1256 const char *channel_name
,
1257 const enum lttng_domain_type domain_type
,
1261 enum lttng_notification_channel_status nc_status
;
1263 struct lttng_action
*low_action
= NULL
;
1264 struct lttng_action
*high_action
= NULL
;
1265 struct lttng_notification
*notification
= NULL
;
1266 struct lttng_notification_channel
*notification_channel
= NULL
;
1267 struct lttng_trigger
*low_trigger
= NULL
;
1268 struct lttng_trigger
*high_trigger
= NULL
;
1270 struct lttng_condition
*low_condition
= NULL
;
1271 struct lttng_condition
*high_condition
= NULL
;
1273 const double low_ratio
= 0.0;
1274 const double high_ratio
= 0.90;
1276 ret
= register_buffer_usage_notify_trigger(session_name
, channel_name
,
1277 domain_type
, BUFFER_USAGE_TYPE_LOW
, low_ratio
,
1278 &low_condition
, &low_action
, &low_trigger
);
1280 fail("Setup error on low trigger registration");
1284 ret
= register_buffer_usage_notify_trigger(session_name
, channel_name
,
1285 domain_type
, BUFFER_USAGE_TYPE_HIGH
, high_ratio
,
1286 &high_condition
, &high_action
, &high_trigger
);
1288 fail("Setup error on high trigger registration");
1293 notification_channel
= lttng_notification_channel_create(
1294 lttng_session_daemon_notification_endpoint
);
1295 ok(notification_channel
, "Notification channel object creation");
1296 if (!notification_channel
) {
1300 /* Subscribe a valid low condition */
1301 nc_status
= lttng_notification_channel_subscribe(
1302 notification_channel
, low_condition
);
1303 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
,
1304 "Subscribe to low condition");
1306 /* Subscribe a valid high condition */
1307 nc_status
= lttng_notification_channel_subscribe(
1308 notification_channel
, high_condition
);
1309 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
,
1310 "Subscribe to high condition");
1312 resume_application();
1314 /* Wait for notification to happen */
1315 stop_consumer(argv
);
1316 lttng_start_tracing(session_name
);
1318 /* Wait for high notification */
1320 nc_status
= lttng_notification_channel_get_next_notification(
1321 notification_channel
, ¬ification
);
1322 } while (nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_INTERRUPTED
);
1323 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
&& notification
&&
1324 lttng_condition_get_type(lttng_notification_get_condition(
1326 LTTNG_CONDITION_TYPE_BUFFER_USAGE_HIGH
,
1327 "High notification received after intermediary communication");
1328 lttng_notification_destroy(notification
);
1329 notification
= NULL
;
1331 suspend_application();
1332 lttng_stop_tracing_no_wait(session_name
);
1333 resume_consumer(argv
);
1334 wait_data_pending(session_name
);
1337 * Test that communication still work even if there is notification
1338 * waiting for consumption.
1341 nc_status
= lttng_notification_channel_unsubscribe(
1342 notification_channel
, low_condition
);
1343 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
,
1344 "Unsubscribe with pending notification");
1346 nc_status
= lttng_notification_channel_subscribe(
1347 notification_channel
, low_condition
);
1348 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
,
1349 "Subscribe with pending notification");
1352 nc_status
= lttng_notification_channel_get_next_notification(
1353 notification_channel
, ¬ification
);
1354 } while (nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_INTERRUPTED
);
1355 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
&& notification
&&
1356 lttng_condition_get_type(lttng_notification_get_condition(
1358 LTTNG_CONDITION_TYPE_BUFFER_USAGE_LOW
,
1359 "Low notification received after intermediary communication");
1360 lttng_notification_destroy(notification
);
1361 notification
= NULL
;
1363 /* Stop consumer to force a high notification */
1364 stop_consumer(argv
);
1365 resume_application();
1366 lttng_start_tracing(session_name
);
1369 nc_status
= lttng_notification_channel_get_next_notification(
1370 notification_channel
, ¬ification
);
1371 } while (nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_INTERRUPTED
);
1372 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
&& notification
&&
1373 lttng_condition_get_type(lttng_notification_get_condition(
1375 LTTNG_CONDITION_TYPE_BUFFER_USAGE_HIGH
,
1376 "High notification received after intermediary communication");
1377 lttng_notification_destroy(notification
);
1378 notification
= NULL
;
1380 suspend_application();
1381 lttng_stop_tracing_no_wait(session_name
);
1382 resume_consumer(argv
);
1383 wait_data_pending(session_name
);
1386 nc_status
= lttng_notification_channel_get_next_notification(
1387 notification_channel
, ¬ification
);
1388 } while (nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_INTERRUPTED
);
1389 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
&& notification
&&
1390 lttng_condition_get_type(lttng_notification_get_condition(
1392 LTTNG_CONDITION_TYPE_BUFFER_USAGE_LOW
,
1393 "Low notification received after re-subscription");
1394 lttng_notification_destroy(notification
);
1395 notification
= NULL
;
1397 stop_consumer(argv
);
1398 resume_application();
1399 /* Stop consumer to force a high notification */
1400 lttng_start_tracing(session_name
);
1403 nc_status
= lttng_notification_channel_get_next_notification(
1404 notification_channel
, ¬ification
);
1405 } while (nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_INTERRUPTED
);
1406 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
&& notification
&&
1407 lttng_condition_get_type(lttng_notification_get_condition(
1409 LTTNG_CONDITION_TYPE_BUFFER_USAGE_HIGH
,
1410 "High notification");
1411 lttng_notification_destroy(notification
);
1412 notification
= NULL
;
1414 suspend_application();
1416 /* Resume consumer to allow event consumption */
1417 lttng_stop_tracing_no_wait(session_name
);
1418 resume_consumer(argv
);
1419 wait_data_pending(session_name
);
1421 nc_status
= lttng_notification_channel_unsubscribe(
1422 notification_channel
, low_condition
);
1423 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
,
1424 "Unsubscribe low condition with pending notification");
1426 nc_status
= lttng_notification_channel_unsubscribe(
1427 notification_channel
, high_condition
);
1428 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
,
1429 "Unsubscribe high condition with pending notification");
1432 lttng_notification_channel_destroy(notification_channel
);
1433 lttng_trigger_destroy(low_trigger
);
1434 lttng_trigger_destroy(high_trigger
);
1435 lttng_action_destroy(low_action
);
1436 lttng_action_destroy(high_action
);
1437 lttng_condition_destroy(low_condition
);
1438 lttng_condition_destroy(high_condition
);
1441 static void create_tracepoint_event_rule_trigger(const char *event_pattern
,
1442 const char *trigger_name
,
1444 unsigned int exclusion_count
,
1445 const char * const *exclusions
,
1446 enum lttng_domain_type domain_type
,
1447 condition_capture_desc_cb capture_desc_cb
,
1448 struct lttng_condition
**condition
,
1449 struct lttng_trigger
**trigger
)
1451 enum lttng_event_rule_status event_rule_status
;
1452 enum lttng_trigger_status trigger_status
;
1454 struct lttng_action
*tmp_action
= NULL
;
1455 struct lttng_event_rule
*event_rule
= NULL
;
1456 struct lttng_condition
*tmp_condition
= NULL
;
1457 struct lttng_trigger
*tmp_trigger
= NULL
;
1460 assert(event_pattern
);
1461 assert(trigger_name
);
1465 event_rule
= lttng_event_rule_tracepoint_create(domain_type
);
1466 ok(event_rule
, "Tracepoint event rule object creation");
1468 event_rule_status
= lttng_event_rule_tracepoint_set_pattern(
1469 event_rule
, event_pattern
);
1470 ok(event_rule_status
== LTTNG_EVENT_RULE_STATUS_OK
,
1471 "Setting tracepoint event rule pattern: '%s'",
1475 event_rule_status
= lttng_event_rule_tracepoint_set_filter(
1476 event_rule
, filter
);
1477 ok(event_rule_status
== LTTNG_EVENT_RULE_STATUS_OK
,
1478 "Setting tracepoint event rule filter: '%s'",
1484 bool success
= true;
1486 assert(domain_type
== LTTNG_DOMAIN_UST
);
1487 assert(exclusion_count
> 0);
1489 for (i
= 0; i
< exclusion_count
; i
++) {
1491 lttng_event_rule_tracepoint_add_exclusion(
1494 if (event_rule_status
!= LTTNG_EVENT_RULE_STATUS_OK
) {
1495 fail("Setting tracepoint event rule exclusion '%s'.",
1501 ok(success
, "Setting tracepoint event rule exclusions");
1504 tmp_condition
= lttng_condition_event_rule_matches_create(event_rule
);
1505 ok(tmp_condition
, "Condition event rule object creation");
1507 if (capture_desc_cb
) {
1508 ret
= capture_desc_cb(tmp_condition
);
1510 fail("Failed to generate the condition capture descriptor");
1515 tmp_action
= lttng_action_notify_create();
1516 ok(tmp_action
, "Action event rule object creation");
1518 tmp_trigger
= lttng_trigger_create(tmp_condition
, tmp_action
);
1519 ok(tmp_trigger
, "Trigger object creation %s", trigger_name
);
1521 trigger_status
= lttng_trigger_set_name(tmp_trigger
, trigger_name
);
1522 ok(trigger_status
== LTTNG_TRIGGER_STATUS_OK
,
1523 "Setting name to trigger %s", trigger_name
);
1525 ret
= lttng_register_trigger(tmp_trigger
);
1526 ok(ret
== 0, "Trigger registration %s", trigger_name
);
1528 lttng_event_rule_destroy(event_rule
);
1530 *condition
= tmp_condition
;
1531 *trigger
= tmp_trigger
;
1536 static struct lttng_notification
*get_next_notification(
1537 struct lttng_notification_channel
*notification_channel
)
1539 struct lttng_notification
*local_notification
= NULL
;
1540 enum lttng_notification_channel_status status
;
1542 /* Receive the next notification. */
1543 status
= lttng_notification_channel_get_next_notification(
1544 notification_channel
, &local_notification
);
1547 case LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
:
1549 case LTTNG_NOTIFICATION_CHANNEL_STATUS_NOTIFICATIONS_DROPPED
:
1550 fail("Notifications have been dropped");
1551 local_notification
= NULL
;
1554 /* Unhandled conditions / errors. */
1555 fail("Failed to get next notification (unknown notification channel status): status = %d",
1557 local_notification
= NULL
;
1561 return local_notification
;
1564 static void test_tracepoint_event_rule_notification(
1565 enum lttng_domain_type domain_type
)
1569 const int notification_count
= 3;
1570 enum lttng_notification_channel_status nc_status
;
1571 struct lttng_action
*action
= NULL
;
1572 struct lttng_condition
*condition
= NULL
;
1573 struct lttng_notification_channel
*notification_channel
= NULL
;
1574 struct lttng_trigger
*trigger
= NULL
;
1575 const char * const trigger_name
= "my_precious";
1576 const char *pattern
;
1578 if (domain_type
== LTTNG_DOMAIN_UST
) {
1579 pattern
= "tp:tptest";
1581 pattern
= "lttng_test_filter_event";
1584 create_tracepoint_event_rule_trigger(pattern
, trigger_name
, NULL
, 0,
1585 NULL
, domain_type
, NULL
, &condition
, &trigger
);
1587 notification_channel
= lttng_notification_channel_create(
1588 lttng_session_daemon_notification_endpoint
);
1589 ok(notification_channel
, "Notification channel object creation");
1591 nc_status
= lttng_notification_channel_subscribe(
1592 notification_channel
, condition
);
1593 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
,
1594 "Subscribe to tracepoint event rule condition");
1596 resume_application();
1598 /* Get notifications. */
1599 for (i
= 0; i
< notification_count
; i
++) {
1600 struct lttng_notification
*notification
= get_next_notification(
1601 notification_channel
);
1603 ok(notification
, "Received notification (%d/%d)", i
+ 1,
1604 notification_count
);
1607 if (notification
== NULL
) {
1611 ret
= validator_notification_trigger_name(notification
, trigger_name
);
1612 lttng_notification_destroy(notification
);
1619 suspend_application();
1620 lttng_notification_channel_destroy(notification_channel
);
1621 lttng_unregister_trigger(trigger
);
1622 lttng_trigger_destroy(trigger
);
1623 lttng_action_destroy(action
);
1624 lttng_condition_destroy(condition
);
1628 static void test_tracepoint_event_rule_notification_filter(
1629 enum lttng_domain_type domain_type
)
1632 const int notification_count
= 3;
1633 enum lttng_notification_channel_status nc_status
;
1634 struct lttng_condition
*ctrl_condition
= NULL
, *condition
= NULL
;
1635 struct lttng_notification_channel
*notification_channel
= NULL
;
1636 struct lttng_trigger
*ctrl_trigger
= NULL
, *trigger
= NULL
;
1637 const char * const ctrl_trigger_name
= "control_trigger";
1638 const char * const trigger_name
= "trigger";
1639 const char *pattern
;
1640 int ctrl_count
= 0, count
= 0;
1642 if (domain_type
== LTTNG_DOMAIN_UST
) {
1643 pattern
= "tp:tptest";
1645 pattern
= "lttng_test_filter_event";
1648 notification_channel
= lttng_notification_channel_create(
1649 lttng_session_daemon_notification_endpoint
);
1650 ok(notification_channel
, "Notification channel object creation");
1652 create_tracepoint_event_rule_trigger(pattern
, ctrl_trigger_name
, NULL
,
1653 0, NULL
, domain_type
, NULL
, &ctrl_condition
, &ctrl_trigger
);
1655 nc_status
= lttng_notification_channel_subscribe(
1656 notification_channel
, ctrl_condition
);
1657 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
,
1658 "Subscribe to tracepoint event rule condition");
1661 * Attach a filter expression to get notification only if the
1662 * `intfield` is even.
1664 create_tracepoint_event_rule_trigger(pattern
, trigger_name
,
1665 "(intfield & 1) == 0", 0, NULL
, domain_type
, NULL
, &condition
,
1668 nc_status
= lttng_notification_channel_subscribe(
1669 notification_channel
, condition
);
1670 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
,
1671 "Subscribe to tracepoint event rule condition");
1674 * We registered 2 notifications triggers, one with a filter and one
1675 * without (control). The one with a filter will only fired when the
1676 * `intfield` is a multiple of 2. We should get two times as many
1677 * control notifications as filter notifications.
1679 resume_application();
1682 * Get 3 notifications. We should get 1 for the regular trigger (with
1683 * the filter) and 2 from the control trigger. This works whatever
1684 * the order we receive the notifications.
1686 for (i
= 0; i
< notification_count
; i
++) {
1688 struct lttng_notification
*notification
= get_next_notification(
1689 notification_channel
);
1691 ok(notification
, "Received notification (%d/%d)", i
+ 1,
1692 notification_count
);
1695 if (notification
== NULL
) {
1699 name
= get_notification_trigger_name(notification
);
1701 lttng_notification_destroy(notification
);
1705 if (strcmp(ctrl_trigger_name
, name
) == 0) {
1707 } else if (strcmp(trigger_name
, name
) == 0) {
1711 lttng_notification_destroy(notification
);
1714 ok(ctrl_count
/ 2 == count
,
1715 "Get twice as many control notif as of regular notif");
1718 suspend_application();
1720 lttng_unregister_trigger(trigger
);
1721 lttng_unregister_trigger(ctrl_trigger
);
1722 lttng_notification_channel_destroy(notification_channel
);
1723 lttng_trigger_destroy(trigger
);
1724 lttng_trigger_destroy(ctrl_trigger
);
1725 lttng_condition_destroy(condition
);
1726 lttng_condition_destroy(ctrl_condition
);
1729 static void test_tracepoint_event_rule_notification_exclusion(
1730 enum lttng_domain_type domain_type
)
1732 enum lttng_notification_channel_status nc_status
;
1733 struct lttng_condition
*ctrl_condition
= NULL
, *condition
= NULL
;
1734 struct lttng_notification_channel
*notification_channel
= NULL
;
1735 struct lttng_trigger
*ctrl_trigger
= NULL
, *trigger
= NULL
;
1736 int ctrl_count
= 0, count
= 0, i
;
1737 const int notification_count
= 6;
1738 const char * const ctrl_trigger_name
= "control_exclusion_trigger";
1739 const char * const trigger_name
= "exclusion_trigger";
1740 const char * const pattern
= "tp:tptest*";
1741 const char * const exclusions
[] = {
1748 notification_channel
= lttng_notification_channel_create(
1749 lttng_session_daemon_notification_endpoint
);
1750 ok(notification_channel
, "Notification channel object creation");
1752 create_tracepoint_event_rule_trigger(pattern
, ctrl_trigger_name
, NULL
,
1753 0, NULL
, domain_type
, NULL
, &ctrl_condition
,
1756 nc_status
= lttng_notification_channel_subscribe(
1757 notification_channel
, ctrl_condition
);
1758 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
,
1759 "Subscribe to tracepoint event rule condition");
1761 create_tracepoint_event_rule_trigger(pattern
, trigger_name
, NULL
, 4,
1762 exclusions
, domain_type
, NULL
, &condition
,
1765 nc_status
= lttng_notification_channel_subscribe(
1766 notification_channel
, condition
);
1767 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
,
1768 "Subscribe to tracepoint event rule condition");
1771 * We registered 2 notifications triggers, one with an exclusion and
1772 * one without (control).
1773 * - The trigger with an exclusion will fire once every iteration.
1774 * - The trigger without an exclusion will fire 5 times every
1777 * We should get 5 times as many notifications from the control
1780 resume_application();
1783 * Get 6 notifications. We should get 1 for the regular trigger (with
1784 * the exclusion) and 5 from the control trigger. This works whatever
1785 * the order we receive the notifications.
1787 for (i
= 0; i
< notification_count
; i
++) {
1789 struct lttng_notification
*notification
= get_next_notification(
1790 notification_channel
);
1792 ok(notification
, "Received notification (%d/%d)", i
+ 1,
1793 notification_count
);
1796 if (notification
== NULL
) {
1800 name
= get_notification_trigger_name(notification
);
1802 lttng_notification_destroy(notification
);
1806 if (strcmp(ctrl_trigger_name
, name
) == 0) {
1808 } else if (strcmp(trigger_name
, name
) == 0) {
1812 lttng_notification_destroy(notification
);
1815 ok(ctrl_count
/ 5 == count
,
1816 "Got 5 times as many control notif as of regular notif");
1819 suspend_application();
1821 lttng_unregister_trigger(trigger
);
1822 lttng_unregister_trigger(ctrl_trigger
);
1823 lttng_notification_channel_destroy(notification_channel
);
1824 lttng_trigger_destroy(trigger
);
1825 lttng_trigger_destroy(ctrl_trigger
);
1826 lttng_condition_destroy(condition
);
1827 lttng_condition_destroy(ctrl_condition
);
1831 static void test_kprobe_event_rule_notification(
1832 enum lttng_domain_type domain_type
)
1835 const int notification_count
= 3;
1836 enum lttng_notification_channel_status nc_status
;
1837 enum lttng_event_rule_status event_rule_status
;
1838 enum lttng_trigger_status trigger_status
;
1839 struct lttng_notification_channel
*notification_channel
= NULL
;
1840 struct lttng_condition
*condition
= NULL
;
1841 struct lttng_kernel_probe_location
*location
= NULL
;
1842 struct lttng_event_rule
*event_rule
= NULL
;
1843 struct lttng_action
*action
= NULL
;
1844 struct lttng_trigger
*trigger
= NULL
;
1845 const char * const trigger_name
= "kprobe_trigger";
1846 const char * const symbol_name
= "lttng_test_filter_event_write";
1848 action
= lttng_action_notify_create();
1850 fail("Failed to create notify action");
1854 location
= lttng_kernel_probe_location_symbol_create(symbol_name
, 0);
1856 fail("Failed to create kernel probe location");
1860 notification_channel
= lttng_notification_channel_create(
1861 lttng_session_daemon_notification_endpoint
);
1862 ok(notification_channel
, "Notification channel object creation");
1864 event_rule
= lttng_event_rule_kernel_probe_create(location
);
1865 ok(event_rule
, "kprobe event rule object creation");
1867 event_rule_status
= lttng_event_rule_kernel_probe_set_event_name(
1868 event_rule
, trigger_name
);
1869 ok(event_rule_status
== LTTNG_EVENT_RULE_STATUS_OK
,
1870 "Setting kprobe event rule name: '%s'", trigger_name
);
1872 condition
= lttng_condition_event_rule_matches_create(event_rule
);
1873 ok(condition
, "Condition event rule object creation");
1875 /* Register the trigger for condition. */
1876 trigger
= lttng_trigger_create(condition
, action
);
1878 fail("Failed to create trigger with kernel probe event rule condition and notify action");
1882 trigger_status
= lttng_trigger_set_name(trigger
, trigger_name
);
1883 ok(trigger_status
== LTTNG_TRIGGER_STATUS_OK
,
1884 "Setting trigger name to '%s'", trigger_name
);
1886 ret
= lttng_register_trigger(trigger
);
1888 fail("Failed to register trigger with kernel probe event rule condition and notify action");
1892 nc_status
= lttng_notification_channel_subscribe(
1893 notification_channel
, condition
);
1894 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
,
1895 "Subscribe to tracepoint event rule condition");
1897 resume_application();
1899 for (i
= 0; i
< notification_count
; i
++) {
1900 struct lttng_notification
*notification
= get_next_notification(
1901 notification_channel
);
1903 ok(notification
, "Received notification (%d/%d)", i
+ 1,
1904 notification_count
);
1907 if (notification
== NULL
) {
1911 ret
= validator_notification_trigger_name(notification
, trigger_name
);
1912 lttng_notification_destroy(notification
);
1919 suspend_application();
1920 lttng_notification_channel_destroy(notification_channel
);
1921 lttng_unregister_trigger(trigger
);
1922 lttng_trigger_destroy(trigger
);
1923 lttng_action_destroy(action
);
1924 lttng_event_rule_destroy(event_rule
);
1925 lttng_condition_destroy(condition
);
1926 lttng_kernel_probe_location_destroy(location
);
1930 static void test_uprobe_event_rule_notification(
1931 enum lttng_domain_type domain_type
,
1932 const char *testapp_path
,
1933 const char *test_symbol_name
)
1936 const int notification_count
= 3;
1937 enum lttng_notification_channel_status nc_status
;
1938 enum lttng_event_rule_status event_rule_status
;
1939 enum lttng_trigger_status trigger_status
;
1940 struct lttng_notification_channel
*notification_channel
= NULL
;
1941 struct lttng_userspace_probe_location
*probe_location
= NULL
;
1942 struct lttng_userspace_probe_location_lookup_method
*lookup_method
=
1944 struct lttng_condition
*condition
= NULL
;
1945 struct lttng_event_rule
*event_rule
= NULL
;
1946 struct lttng_action
*action
= NULL
;
1947 struct lttng_trigger
*trigger
= NULL
;
1948 const char * const trigger_name
= "uprobe_trigger";
1950 action
= lttng_action_notify_create();
1952 fail("Failed to create notify action");
1956 lookup_method
= lttng_userspace_probe_location_lookup_method_function_elf_create();
1957 if (!lookup_method
) {
1958 fail("Setup error on userspace probe lookup method creation");
1962 probe_location
= lttng_userspace_probe_location_function_create(
1963 testapp_path
, test_symbol_name
, lookup_method
);
1964 if (!probe_location
) {
1965 fail("Failed to create userspace probe location");
1969 notification_channel
= lttng_notification_channel_create(
1970 lttng_session_daemon_notification_endpoint
);
1971 ok(notification_channel
, "Notification channel object creation");
1973 event_rule
= lttng_event_rule_userspace_probe_create(probe_location
);
1974 ok(event_rule
, "kprobe event rule object creation");
1976 event_rule_status
= lttng_event_rule_userspace_probe_set_event_name(
1977 event_rule
, trigger_name
);
1978 ok(event_rule_status
== LTTNG_EVENT_RULE_STATUS_OK
,
1979 "Setting uprobe event rule name: '%s'", trigger_name
);
1981 condition
= lttng_condition_event_rule_matches_create(event_rule
);
1982 ok(condition
, "Condition event rule object creation");
1984 /* Register the trigger for condition. */
1985 trigger
= lttng_trigger_create(condition
, action
);
1987 fail("Failed to create trigger with userspace probe event rule condition and notify action");
1991 trigger_status
= lttng_trigger_set_name(trigger
, trigger_name
);
1992 ok(trigger_status
== LTTNG_TRIGGER_STATUS_OK
,
1993 "Setting name to trigger '%s'", trigger_name
);
1995 ret
= lttng_register_trigger(trigger
);
1997 fail("Failed to register trigger with userspace probe event rule condition and notify action");
2001 nc_status
= lttng_notification_channel_subscribe(
2002 notification_channel
, condition
);
2003 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
,
2004 "Subscribe to tracepoint event rule condition");
2006 resume_application();
2008 for (i
= 0; i
< 3; i
++) {
2009 struct lttng_notification
*notification
= get_next_notification(
2010 notification_channel
);
2012 ok(notification
, "Received notification (%d/%d)", i
+ 1,
2013 notification_count
);
2016 if (notification
== NULL
) {
2020 ret
= validator_notification_trigger_name(notification
, trigger_name
);
2021 lttng_notification_destroy(notification
);
2027 suspend_application();
2029 lttng_notification_channel_destroy(notification_channel
);
2030 lttng_unregister_trigger(trigger
);
2031 lttng_trigger_destroy(trigger
);
2032 lttng_action_destroy(action
);
2033 lttng_userspace_probe_location_destroy(probe_location
);
2034 lttng_event_rule_destroy(event_rule
);
2035 lttng_condition_destroy(condition
);
2039 static void test_syscall_event_rule_notification(
2040 enum lttng_domain_type domain_type
)
2043 const int notification_count
= 3;
2044 enum lttng_notification_channel_status nc_status
;
2045 enum lttng_event_rule_status event_rule_status
;
2046 enum lttng_trigger_status trigger_status
;
2047 struct lttng_notification_channel
*notification_channel
= NULL
;
2048 struct lttng_condition
*condition
= NULL
;
2049 struct lttng_event_rule
*event_rule
= NULL
;
2050 struct lttng_action
*action
= NULL
;
2051 struct lttng_trigger
*trigger
= NULL
;
2052 const char * const trigger_name
= "syscall_trigger";
2053 const char * const syscall_name
= "openat";
2055 action
= lttng_action_notify_create();
2057 fail("Failed to create notify action");
2061 notification_channel
= lttng_notification_channel_create(
2062 lttng_session_daemon_notification_endpoint
);
2063 ok(notification_channel
, "Notification channel object creation");
2065 event_rule
= lttng_event_rule_syscall_create(LTTNG_EVENT_RULE_SYSCALL_EMISSION_SITE_ENTRY
);
2066 ok(event_rule
, "syscall event rule object creation");
2068 event_rule_status
= lttng_event_rule_syscall_set_pattern(
2069 event_rule
, syscall_name
);
2070 ok(event_rule_status
== LTTNG_EVENT_RULE_STATUS_OK
,
2071 "Setting syscall event rule pattern: '%s'", syscall_name
);
2073 condition
= lttng_condition_event_rule_matches_create(event_rule
);
2074 ok(condition
, "Condition syscall event rule object creation");
2076 /* Register the trigger for condition. */
2077 trigger
= lttng_trigger_create(condition
, action
);
2079 fail("Failed to create trigger with syscall event rule condition and notify action");
2083 trigger_status
= lttng_trigger_set_name(trigger
, trigger_name
);
2084 ok(trigger_status
== LTTNG_TRIGGER_STATUS_OK
,
2085 "Setting name to trigger '%s'", trigger_name
);
2087 ret
= lttng_register_trigger(trigger
);
2089 fail("Failed to register trigger with syscall event rule condition and notify action");
2093 nc_status
= lttng_notification_channel_subscribe(
2094 notification_channel
, condition
);
2095 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
,
2096 "Subscribe to tracepoint event rule condition");
2098 resume_application();
2100 for (i
= 0; i
< notification_count
; i
++) {
2101 struct lttng_notification
*notification
= get_next_notification(
2102 notification_channel
);
2104 ok(notification
, "Received notification (%d/%d)", i
+ 1,
2105 notification_count
);
2108 if (notification
== NULL
) {
2112 ret
= validator_notification_trigger_name(notification
, trigger_name
);
2113 lttng_notification_destroy(notification
);
2119 suspend_application();
2120 lttng_notification_channel_destroy(notification_channel
);
2121 lttng_unregister_trigger(trigger
);
2122 lttng_trigger_destroy(trigger
);
2123 lttng_action_destroy(action
);
2124 lttng_condition_destroy(condition
);
2128 static void test_syscall_event_rule_notification_filter(
2129 enum lttng_domain_type domain_type
)
2132 const int notification_count
= 3;
2133 enum lttng_notification_channel_status nc_status
;
2134 enum lttng_event_rule_status event_rule_status
;
2135 enum lttng_trigger_status trigger_status
;
2136 struct lttng_notification_channel
*notification_channel
= NULL
;
2137 struct lttng_condition
*condition
= NULL
;
2138 struct lttng_event_rule
*event_rule
= NULL
;
2139 struct lttng_action
*action
= NULL
;
2140 struct lttng_trigger
*trigger
= NULL
;
2141 const char * const trigger_name
= "syscall_trigger";
2142 const char * const syscall_name
= "openat";
2143 const char * const filter_pattern
= "filename == \"/proc/cpuinfo\"";
2145 action
= lttng_action_notify_create();
2147 fail("Failed to create notify action");
2151 notification_channel
= lttng_notification_channel_create(
2152 lttng_session_daemon_notification_endpoint
);
2153 ok(notification_channel
, "Notification channel object creation");
2155 event_rule
= lttng_event_rule_syscall_create(LTTNG_EVENT_RULE_SYSCALL_EMISSION_SITE_ENTRY
);
2156 ok(event_rule
, "syscall event rule object creation");
2158 event_rule_status
= lttng_event_rule_syscall_set_pattern(
2159 event_rule
, syscall_name
);
2160 ok(event_rule_status
== LTTNG_EVENT_RULE_STATUS_OK
,
2161 "Setting syscall event rule pattern: '%s'", syscall_name
);
2163 event_rule_status
= lttng_event_rule_syscall_set_filter(
2164 event_rule
, filter_pattern
);
2165 ok(event_rule_status
== LTTNG_EVENT_RULE_STATUS_OK
,
2166 "Setting filter: '%s'", filter_pattern
);
2168 condition
= lttng_condition_event_rule_matches_create(event_rule
);
2169 ok(condition
, "Condition event rule object creation");
2171 /* Register the triggers for condition */
2172 trigger
= lttng_trigger_create(condition
, action
);
2174 fail("Failed to create trigger with syscall filtering event rule condition and notify action");
2178 trigger_status
= lttng_trigger_set_name(trigger
, trigger_name
);
2179 ok(trigger_status
== LTTNG_TRIGGER_STATUS_OK
,
2180 "Setting name to trigger '%s'", trigger_name
);
2182 ret
= lttng_register_trigger(trigger
);
2184 fail("Failed to register trigger with syscall filtering event rule condition and notify action");
2188 nc_status
= lttng_notification_channel_subscribe(
2189 notification_channel
, condition
);
2190 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
,
2191 "Subscribe to tracepoint event rule condition");
2193 resume_application();
2195 for (i
= 0; i
< notification_count
; i
++) {
2196 struct lttng_notification
*notification
= get_next_notification(
2197 notification_channel
);
2199 ok(notification
, "Received notification (%d/%d)", i
+ 1,
2200 notification_count
);
2203 if (notification
== NULL
) {
2207 ret
= validator_notification_trigger_name(notification
, trigger_name
);
2208 lttng_notification_destroy(notification
);
2215 suspend_application();
2217 lttng_unregister_trigger(trigger
);
2218 lttng_notification_channel_destroy(notification_channel
);
2219 lttng_trigger_destroy(trigger
);
2220 lttng_event_rule_destroy(event_rule
);
2221 lttng_condition_destroy(condition
);
2225 static int generate_capture_descr(struct lttng_condition
*condition
)
2228 struct lttng_event_expr
*expr
= NULL
;
2229 const unsigned int basic_field_count
= sizeof(test_capture_base_fields
) /
2230 sizeof(*test_capture_base_fields
);
2231 enum lttng_condition_status cond_status
;
2233 for (i
= 0; i
< basic_field_count
; i
++) {
2234 diag("Adding capture descriptor '%s'",
2235 test_capture_base_fields
[i
].field_name
);
2237 switch (test_capture_base_fields
[i
].field_type
) {
2238 case FIELD_TYPE_PAYLOAD
:
2239 expr
= lttng_event_expr_event_payload_field_create(
2240 test_capture_base_fields
[i
].field_name
);
2242 case FIELD_TYPE_CONTEXT
:
2243 expr
= lttng_event_expr_channel_context_field_create(
2244 test_capture_base_fields
[i
].field_name
);
2246 case FIELD_TYPE_ARRAY_FIELD
:
2250 char field_name
[FIELD_NAME_MAX_LEN
];
2251 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) {
2256 fail("Unexpected array field name format: field name = '%s'",
2257 test_capture_base_fields
[i
].field_name
);
2262 array_expr
= lttng_event_expr_event_payload_field_create(
2265 expr
= lttng_event_expr_array_field_element_create(
2269 case FIELD_TYPE_APP_CONTEXT
:
2270 fail("Application context tests are not implemented yet.");
2278 fail("Failed to create capture expression");
2283 cond_status
= lttng_condition_event_rule_matches_append_capture_descriptor(
2285 if (cond_status
!= LTTNG_CONDITION_STATUS_OK
) {
2286 fail("Failed to append capture descriptor");
2288 lttng_event_expr_destroy(expr
);
2299 static int validator_notification_trigger_capture(
2300 enum lttng_domain_type domain
,
2301 struct lttng_notification
*notification
,
2302 const int iteration
)
2305 unsigned int capture_count
, i
;
2306 enum lttng_evaluation_event_rule_matches_status
2307 event_rule_matches_evaluation_status
;
2308 enum lttng_event_field_value_status event_field_value_status
;
2309 const struct lttng_evaluation
*evaluation
;
2310 const struct lttng_event_field_value
*captured_fields
;
2311 bool at_least_one_error
= false;
2313 evaluation
= lttng_notification_get_evaluation(notification
);
2314 if (evaluation
== NULL
) {
2315 fail("Failed to get evaluation from notification during trigger capture test");
2320 event_rule_matches_evaluation_status
=
2321 lttng_evaluation_event_rule_matches_get_captured_values(
2322 evaluation
, &captured_fields
);
2323 if (event_rule_matches_evaluation_status
!=
2324 LTTNG_EVALUATION_EVENT_RULE_MATCHES_STATUS_OK
) {
2325 diag("Failed to get event rule evaluation captured values: status = %d",
2326 (int) event_rule_matches_evaluation_status
);
2331 event_field_value_status
=
2332 lttng_event_field_value_array_get_length(captured_fields
,
2334 if (event_field_value_status
!= LTTNG_EVENT_FIELD_VALUE_STATUS_OK
) {
2335 fail("Failed to get count of captured value field array");
2340 for (i
= 0; i
< capture_count
; i
++) {
2341 const struct lttng_event_field_value
*captured_field
= NULL
;
2342 validate_cb validate
;
2345 diag("Validating capture of field '%s'",
2346 test_capture_base_fields
[i
].field_name
);
2347 event_field_value_status
=
2348 lttng_event_field_value_array_get_element_at_index(
2353 case LTTNG_DOMAIN_UST
:
2354 expected
= test_capture_base_fields
[i
].expected_ust
;
2356 case LTTNG_DOMAIN_KERNEL
:
2357 expected
= test_capture_base_fields
[i
].expected_kernel
;
2360 fail("Unexpected domain encountered: domain = %d",
2366 if (domain
== LTTNG_DOMAIN_UST
) {
2367 validate
= test_capture_base_fields
[i
].validate_ust
;
2369 validate
= test_capture_base_fields
[i
].validate_kernel
;
2373 ok(event_field_value_status
== LTTNG_EVENT_FIELD_VALUE_STATUS_UNAVAILABLE
,
2374 "No payload captured");
2378 if (event_field_value_status
!= LTTNG_EVENT_FIELD_VALUE_STATUS_OK
) {
2379 if (event_field_value_status
==
2380 LTTNG_EVENT_FIELD_VALUE_STATUS_UNAVAILABLE
) {
2381 fail("Expected a capture but it is unavailable");
2383 fail("lttng_event_field_value_array_get_element_at_index returned an error: status = %d",
2384 (int) event_field_value_status
);
2391 diag("Captured field of type %s",
2392 field_value_type_to_str(
2393 lttng_event_field_value_get_type(captured_field
)));
2396 ret
= validate(captured_field
, iteration
);
2398 at_least_one_error
= true;
2402 ret
= at_least_one_error
;
2408 static void test_tracepoint_event_rule_notification_capture(
2409 enum lttng_domain_type domain_type
)
2411 enum lttng_notification_channel_status nc_status
;
2414 struct lttng_condition
*condition
= NULL
;
2415 struct lttng_notification_channel
*notification_channel
= NULL
;
2416 struct lttng_trigger
*trigger
= NULL
;
2417 const char *trigger_name
= "my_precious";
2418 const char *pattern
;
2420 if (domain_type
== LTTNG_DOMAIN_UST
) {
2421 pattern
= "tp:tptest";
2423 pattern
= "lttng_test_filter_event";
2426 create_tracepoint_event_rule_trigger(pattern
, trigger_name
, NULL
, 0,
2427 NULL
, domain_type
, generate_capture_descr
, &condition
,
2430 notification_channel
= lttng_notification_channel_create(
2431 lttng_session_daemon_notification_endpoint
);
2432 ok(notification_channel
, "Notification channel object creation");
2434 nc_status
= lttng_notification_channel_subscribe(
2435 notification_channel
, condition
);
2436 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
,
2437 "Subscribe to tracepoint event rule condition");
2439 resume_application();
2441 /* Get 3 notifications */
2442 for (i
= 0; i
< 3; i
++) {
2443 struct lttng_notification
*notification
= get_next_notification(
2444 notification_channel
);
2445 ok(notification
, "Received notification");
2448 if (notification
== NULL
) {
2452 ret
= validator_notification_trigger_name(notification
, trigger_name
);
2454 lttng_notification_destroy(notification
);
2458 ret
= validator_notification_trigger_capture(domain_type
, notification
, i
);
2460 lttng_notification_destroy(notification
);
2464 lttng_notification_destroy(notification
);
2468 suspend_application();
2469 lttng_notification_channel_destroy(notification_channel
);
2470 lttng_unregister_trigger(trigger
);
2471 lttng_trigger_destroy(trigger
);
2472 lttng_condition_destroy(condition
);
2476 int main(int argc
, const char *argv
[])
2479 const char *domain_type_string
= NULL
;
2480 enum lttng_domain_type domain_type
= LTTNG_DOMAIN_NONE
;
2483 fail("Missing test scenario, domain type, pid, or application state file argument(s)");
2487 test_scenario
= atoi(argv
[1]);
2488 domain_type_string
= argv
[2];
2489 app_pid
= (pid_t
) atoi(argv
[3]);
2490 app_state_file
= argv
[4];
2492 if (!strcmp("LTTNG_DOMAIN_UST", domain_type_string
)) {
2493 domain_type
= LTTNG_DOMAIN_UST
;
2495 if (!strcmp("LTTNG_DOMAIN_KERNEL", domain_type_string
)) {
2496 domain_type
= LTTNG_DOMAIN_KERNEL
;
2498 if (domain_type
== LTTNG_DOMAIN_NONE
) {
2499 fail("Unknown domain type");
2504 * Test cases are responsible for resuming the app when needed
2505 * and making sure it's suspended when returning.
2507 suspend_application();
2509 switch (test_scenario
) {
2514 /* Test cases that need gen-ust-event testapp. */
2515 diag("Test basic notification error paths for %s domain",
2516 domain_type_string
);
2517 test_invalid_channel_subscription(domain_type
);
2519 diag("Test tracepoint event rule notifications for domain %s",
2520 domain_type_string
);
2521 test_tracepoint_event_rule_notification(domain_type
);
2523 diag("Test tracepoint event rule notifications with filter for domain %s",
2524 domain_type_string
);
2525 test_tracepoint_event_rule_notification_filter(domain_type
);
2530 const char *session_name
, *channel_name
;
2532 /* Test cases that need a tracing session enabled. */
2536 * Argument 7 and upward are named pipe location for consumerd
2539 named_pipe_args_start
= 7;
2542 fail("Missing parameter for tests to run %d", argc
);
2548 session_name
= argv
[5];
2549 channel_name
= argv
[6];
2551 test_subscription_twice(session_name
, channel_name
,
2554 diag("Test trigger for domain %s with buffer_usage_low condition",
2555 domain_type_string
);
2556 test_triggers_buffer_usage_condition(session_name
, channel_name
,
2558 LTTNG_CONDITION_TYPE_BUFFER_USAGE_LOW
);
2560 diag("Test trigger for domain %s with buffer_usage_high condition",
2561 domain_type_string
);
2562 test_triggers_buffer_usage_condition(session_name
, channel_name
,
2564 LTTNG_CONDITION_TYPE_BUFFER_USAGE_HIGH
);
2566 diag("Test buffer usage notification channel api for domain %s",
2567 domain_type_string
);
2568 test_buffer_usage_notification_channel(session_name
, channel_name
,
2575 * Test cases that need a test app with more than one event
2581 * At the moment, the only test case of this scenario is
2582 * exclusion which is only supported by UST.
2584 assert(domain_type
== LTTNG_DOMAIN_UST
);
2585 diag("Test tracepoint event rule notifications with exclusion for domain %s",
2586 domain_type_string
);
2587 test_tracepoint_event_rule_notification_exclusion(domain_type
);
2594 /* Test cases that need the kernel tracer. */
2595 assert(domain_type
== LTTNG_DOMAIN_KERNEL
);
2597 diag("Test kprobe event rule notifications for domain %s",
2598 domain_type_string
);
2600 test_kprobe_event_rule_notification(domain_type
);
2607 /* Test cases that need the kernel tracer. */
2608 assert(domain_type
== LTTNG_DOMAIN_KERNEL
);
2610 diag("Test syscall event rule notifications for domain %s",
2611 domain_type_string
);
2613 test_syscall_event_rule_notification(domain_type
);
2615 diag("Test syscall filtering event rule notifications for domain %s",
2616 domain_type_string
);
2618 test_syscall_event_rule_notification_filter(domain_type
);
2624 const char *testapp_path
, *test_symbol_name
;
2629 fail("Missing parameter for tests to run %d", argc
);
2633 testapp_path
= argv
[5];
2634 test_symbol_name
= argv
[6];
2635 /* Test cases that need the kernel tracer. */
2636 assert(domain_type
== LTTNG_DOMAIN_KERNEL
);
2638 diag("Test userspace-probe event rule notifications for domain %s",
2639 domain_type_string
);
2641 test_uprobe_event_rule_notification(
2642 domain_type
, testapp_path
, test_symbol_name
);
2648 switch(domain_type
) {
2649 case LTTNG_DOMAIN_UST
:
2652 case LTTNG_DOMAIN_KERNEL
:
2659 diag("Test tracepoint event rule notification captures for domain %s",
2660 domain_type_string
);
2661 test_tracepoint_event_rule_notification_capture(domain_type
);
2671 return exit_status();