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 *name
= NULL
;
583 enum lttng_evaluation_status status
;
584 const struct lttng_evaluation
*evaluation
;
585 evaluation
= lttng_notification_get_evaluation(notification
);
586 if (evaluation
== NULL
) {
587 fail("lttng_notification_get_evaluation");
591 switch (lttng_evaluation_get_type(evaluation
)) {
592 case LTTNG_CONDITION_TYPE_EVENT_RULE_HIT
:
594 status
= lttng_evaluation_event_rule_get_trigger_name(
596 if (status
!= LTTNG_EVALUATION_STATUS_OK
) {
597 fail("lttng_evaluation_event_rule_get_trigger_name");
604 fail("Wrong notification evaluation type \n");
611 static int validator_notification_trigger_name(
612 struct lttng_notification
*notification
,
613 const char *trigger_name
)
619 assert(notification
);
620 assert(trigger_name
);
622 name
= get_notification_trigger_name(notification
);
628 name_is_equal
= (strcmp(trigger_name
, name
) == 0);
629 ok(name_is_equal
, "Expected trigger name: %s got %s", trigger_name
,
632 ret
= !name_is_equal
;
639 void wait_on_file(const char *path
, bool file_exist
)
648 ret
= stat(path
, &buf
);
649 if (ret
== -1 && errno
== ENOENT
) {
652 * The file does not exist. wait a bit and
653 * continue looping until it does.
655 (void) poll(NULL
, 0, 10);
660 * File does not exist and the exit condition we want.
661 * Break from the loop and return.
670 * stat() returned 0, so the file exists. break now only if
671 * that's the exit condition we want.
680 int write_pipe(const char *path
, uint8_t data
)
685 fd
= open(path
, O_WRONLY
| O_NONBLOCK
);
687 perror("Could not open consumer control named pipe");
691 ret
= write(fd
, &data
, sizeof(data
));
693 perror("Named pipe write failed");
695 perror("Named pipe close failed");
703 perror("Name pipe closing failed");
712 int stop_consumer(const char **argv
)
716 for (i
= named_pipe_args_start
; i
< nb_args
; i
++) {
717 ret
= write_pipe(argv
[i
], 49);
723 int resume_consumer(const char **argv
)
727 for (i
= named_pipe_args_start
; i
< nb_args
; i
++) {
728 ret
= write_pipe(argv
[i
], 0);
734 int suspend_application(void)
739 if (!stat(app_state_file
, &buf
)) {
740 fail("App is already in a suspended state.");
746 * Send SIGUSR1 to application instructing it to bypass tracepoint.
750 ret
= kill(app_pid
, SIGUSR1
);
752 fail("SIGUSR1 failed. errno %d", errno
);
757 wait_on_file(app_state_file
, true);
765 int resume_application(void)
770 ret
= stat(app_state_file
, &buf
);
771 if (ret
== -1 && errno
== ENOENT
) {
772 fail("State file does not exist");
782 ret
= kill(app_pid
, SIGUSR1
);
784 fail("SIGUSR1 failed. errno %d", errno
);
789 wait_on_file(app_state_file
, false);
798 void test_triggers_buffer_usage_condition(const char *session_name
,
799 const char *channel_name
,
800 enum lttng_domain_type domain_type
,
801 enum lttng_condition_type condition_type
)
803 unsigned int test_vector_size
= 5, i
;
804 enum lttng_condition_status condition_status
;
805 struct lttng_action
*action
;
808 action
= lttng_action_notify_create();
810 fail("Setup error on action creation");
814 /* Test lttng_register_trigger with null value */
815 ok(lttng_register_trigger(NULL
) == -LTTNG_ERR_INVALID
, "Registering a NULL trigger fails as expected");
817 /* Test: register a trigger */
819 for (i
= 0; i
< pow(2,test_vector_size
); i
++) {
821 char *test_tuple_string
= NULL
;
822 unsigned int mask_position
= 0;
823 bool session_name_set
= false;
824 bool channel_name_set
= false;
825 bool threshold_ratio_set
= false;
826 bool threshold_byte_set
= false;
827 bool domain_type_set
= false;
829 struct lttng_trigger
*trigger
= NULL
;
830 struct lttng_condition
*condition
= NULL
;
832 /* Create base condition */
833 switch (condition_type
) {
834 case LTTNG_CONDITION_TYPE_BUFFER_USAGE_LOW
:
835 condition
= lttng_condition_buffer_usage_low_create();
837 case LTTNG_CONDITION_TYPE_BUFFER_USAGE_HIGH
:
838 condition
= lttng_condition_buffer_usage_high_create();
851 /* Prepare the condition for trigger registration test */
853 /* Set session name */
854 if ((1 << mask_position
) & i
) {
855 condition_status
= lttng_condition_buffer_usage_set_session_name(
856 condition
, session_name
);
857 if (condition_status
!= LTTNG_CONDITION_STATUS_OK
) {
861 session_name_set
= true;
865 /* Set channel name */
866 if ((1 << mask_position
) & i
) {
867 condition_status
= lttng_condition_buffer_usage_set_channel_name(
868 condition
, channel_name
);
869 if (condition_status
!= LTTNG_CONDITION_STATUS_OK
) {
873 channel_name_set
= true;
877 /* Set threshold ratio */
878 if ((1 << mask_position
) & i
) {
879 condition_status
= lttng_condition_buffer_usage_set_threshold_ratio(
881 if (condition_status
!= LTTNG_CONDITION_STATUS_OK
) {
885 threshold_ratio_set
= true;
889 /* Set threshold byte */
890 if ((1 << mask_position
) & i
) {
891 condition_status
= lttng_condition_buffer_usage_set_threshold(
893 if (condition_status
!= LTTNG_CONDITION_STATUS_OK
) {
897 threshold_byte_set
= true;
901 /* Set domain type */
902 if ((1 << mask_position
) & i
) {
903 condition_status
= lttng_condition_buffer_usage_set_domain_type(
904 condition
, LTTNG_DOMAIN_UST
);
905 if (condition_status
!= LTTNG_CONDITION_STATUS_OK
) {
909 domain_type_set
= true;
913 if (mask_position
!= test_vector_size
-1) {
914 assert("Logic error for test vector generation");
917 loop_ret
= asprintf(&test_tuple_string
, "session name %s, channel name %s, threshold ratio %s, threshold byte %s, domain type %s",
918 session_name_set
? "set" : "unset",
919 channel_name_set
? "set" : "unset",
920 threshold_ratio_set
? "set" : "unset",
921 threshold_byte_set
? "set" : "unset",
922 domain_type_set
? "set" : "unset");
923 if (!test_tuple_string
|| loop_ret
< 0) {
929 trigger
= lttng_trigger_create(condition
, action
);
935 loop_ret
= lttng_register_trigger(trigger
);
939 fail("Setup error occurred for tuple: %s", test_tuple_string
);
943 /* This combination happens three times */
944 if (session_name_set
&& channel_name_set
945 && (threshold_ratio_set
|| threshold_byte_set
)
946 && domain_type_set
) {
947 ok(loop_ret
== 0, "Trigger is registered: %s", test_tuple_string
);
950 * Test that a trigger cannot be registered
953 loop_ret
= lttng_register_trigger(trigger
);
954 ok(loop_ret
== -LTTNG_ERR_TRIGGER_EXISTS
, "Re-register trigger fails as expected: %s", test_tuple_string
);
956 /* Test that a trigger can be unregistered */
957 loop_ret
= lttng_unregister_trigger(trigger
);
958 ok(loop_ret
== 0, "Unregister trigger: %s", test_tuple_string
);
961 * Test that unregistration of a non-previously
962 * registered trigger fail.
964 loop_ret
= lttng_unregister_trigger(trigger
);
965 ok(loop_ret
== -LTTNG_ERR_TRIGGER_NOT_FOUND
, "Unregister of a non-registered trigger fails as expected: %s", test_tuple_string
);
967 ok(loop_ret
== -LTTNG_ERR_INVALID_TRIGGER
, "Trigger is invalid as expected and cannot be registered: %s", test_tuple_string
);
971 free(test_tuple_string
);
972 lttng_trigger_destroy(trigger
);
973 lttng_condition_destroy(condition
);
977 lttng_action_destroy(action
);
981 void wait_data_pending(const char *session_name
)
986 ret
= lttng_data_pending(session_name
);
992 int setup_buffer_usage_condition(struct lttng_condition
*condition
,
993 const char *condition_name
,
994 const char *session_name
,
995 const char *channel_name
,
996 const enum lttng_domain_type domain_type
)
998 enum lttng_condition_status condition_status
;
1001 condition_status
= lttng_condition_buffer_usage_set_session_name(
1002 condition
, session_name
);
1003 if (condition_status
!= LTTNG_CONDITION_STATUS_OK
) {
1004 fail("Failed to set session name on creation of condition `%s`",
1010 condition_status
= lttng_condition_buffer_usage_set_channel_name(
1011 condition
, channel_name
);
1012 if (condition_status
!= LTTNG_CONDITION_STATUS_OK
) {
1013 fail("Failed to set channel name on creation of condition `%s`",
1019 condition_status
= lttng_condition_buffer_usage_set_domain_type(
1020 condition
, domain_type
);
1021 if (condition_status
!= LTTNG_CONDITION_STATUS_OK
) {
1022 fail("Failed to set domain type on creation of condition `%s`",
1033 void test_invalid_channel_subscription(
1034 const enum lttng_domain_type domain_type
)
1036 enum lttng_condition_status condition_status
;
1037 enum lttng_notification_channel_status nc_status
;
1038 struct lttng_condition
*dummy_condition
= NULL
;
1039 struct lttng_condition
*dummy_invalid_condition
= NULL
;
1040 struct lttng_notification_channel
*notification_channel
= NULL
;
1043 notification_channel
= lttng_notification_channel_create(
1044 lttng_session_daemon_notification_endpoint
);
1045 ok(notification_channel
, "Notification channel object creation");
1046 if (!notification_channel
) {
1051 * Create a dummy, empty (thus invalid) condition to test error paths.
1053 dummy_invalid_condition
= lttng_condition_buffer_usage_low_create();
1054 if (!dummy_invalid_condition
) {
1055 fail("Setup error on condition creation");
1060 * Test subscription and unsubscription of an invalid condition to/from
1063 nc_status
= lttng_notification_channel_subscribe(
1064 notification_channel
, dummy_invalid_condition
);
1065 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_INVALID
,
1066 "Subscribing to an invalid condition");
1068 nc_status
= lttng_notification_channel_unsubscribe(
1069 notification_channel
, dummy_invalid_condition
);
1070 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_INVALID
,
1071 "Unsubscribing from an invalid condition");
1073 /* Create a valid dummy condition with a ratio of 0.5 */
1074 dummy_condition
= lttng_condition_buffer_usage_low_create();
1075 if (!dummy_condition
) {
1076 fail("Setup error on dummy_condition creation");
1080 condition_status
= lttng_condition_buffer_usage_set_threshold_ratio(
1081 dummy_condition
, 0.5);
1082 if (condition_status
!= LTTNG_CONDITION_STATUS_OK
) {
1083 fail("Setup error on condition creation");
1087 ret
= setup_buffer_usage_condition(dummy_condition
, "dummy_condition",
1088 "dummy_session", "dummy_channel", domain_type
);
1090 fail("Setup error on dummy condition creation");
1095 * Test subscription and unsubscription to/from a channel with invalid
1098 nc_status
= lttng_notification_channel_subscribe(NULL
, NULL
);
1099 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_INVALID
,
1100 "Notification channel subscription is invalid: NULL, NULL");
1102 nc_status
= lttng_notification_channel_subscribe(
1103 notification_channel
, NULL
);
1104 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_INVALID
,
1105 "Notification channel subscription is invalid: NON-NULL, NULL");
1107 nc_status
= lttng_notification_channel_subscribe(NULL
, dummy_condition
);
1108 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_INVALID
,
1109 "Notification channel subscription is invalid: NULL, NON-NULL");
1111 nc_status
= lttng_notification_channel_unsubscribe(
1112 notification_channel
, dummy_condition
);
1113 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_UNKNOWN_CONDITION
,
1114 "Unsubscribing from a valid unknown condition");
1117 lttng_notification_channel_destroy(notification_channel
);
1118 lttng_condition_destroy(dummy_invalid_condition
);
1119 lttng_condition_destroy(dummy_condition
);
1123 enum buffer_usage_type
{
1124 BUFFER_USAGE_TYPE_LOW
,
1125 BUFFER_USAGE_TYPE_HIGH
,
1128 static int register_buffer_usage_notify_trigger(const char *session_name
,
1129 const char *channel_name
,
1130 const enum lttng_domain_type domain_type
,
1131 enum buffer_usage_type buffer_usage_type
,
1133 struct lttng_condition
**condition
,
1134 struct lttng_action
**action
,
1135 struct lttng_trigger
**trigger
)
1137 enum lttng_condition_status condition_status
;
1138 struct lttng_action
*tmp_action
= NULL
;
1139 struct lttng_condition
*tmp_condition
= NULL
;
1140 struct lttng_trigger
*tmp_trigger
= NULL
;
1144 tmp_action
= lttng_action_notify_create();
1146 fail("Setup error on action creation");
1151 if (buffer_usage_type
== BUFFER_USAGE_TYPE_LOW
) {
1152 tmp_condition
= lttng_condition_buffer_usage_low_create();
1154 tmp_condition
= lttng_condition_buffer_usage_high_create();
1157 if (!tmp_condition
) {
1158 fail("Setup error on condition creation");
1163 /* Set the buffer usage threashold */
1164 condition_status
= lttng_condition_buffer_usage_set_threshold_ratio(
1165 tmp_condition
, ratio
);
1166 if (condition_status
!= LTTNG_CONDITION_STATUS_OK
) {
1167 fail("Setup error on condition creation");
1172 ret
= setup_buffer_usage_condition(tmp_condition
, "condition_name",
1173 session_name
, channel_name
, domain_type
);
1175 fail("Setup error on condition creation");
1180 /* Register the trigger for condition. */
1181 tmp_trigger
= lttng_trigger_create(tmp_condition
, tmp_action
);
1183 fail("Setup error on trigger creation");
1188 ret
= lttng_register_trigger(tmp_trigger
);
1190 fail("Setup error on trigger registration");
1195 *condition
= tmp_condition
;
1196 *trigger
= tmp_trigger
;
1197 *action
= tmp_action
;
1201 lttng_action_destroy(tmp_action
);
1202 lttng_condition_destroy(tmp_condition
);
1203 lttng_trigger_destroy(tmp_trigger
);
1209 static void test_subscription_twice(const char *session_name
,
1210 const char *channel_name
,
1211 const enum lttng_domain_type domain_type
)
1214 enum lttng_notification_channel_status nc_status
;
1216 struct lttng_action
*action
= NULL
;
1217 struct lttng_notification_channel
*notification_channel
= NULL
;
1218 struct lttng_trigger
*trigger
= NULL
;
1220 struct lttng_condition
*condition
= NULL
;
1222 ret
= register_buffer_usage_notify_trigger(session_name
, channel_name
,
1223 domain_type
, BUFFER_USAGE_TYPE_LOW
, 0.99, &condition
,
1226 fail("Setup error on trigger registration");
1230 /* Begin testing. */
1231 notification_channel
= lttng_notification_channel_create(
1232 lttng_session_daemon_notification_endpoint
);
1233 ok(notification_channel
, "Notification channel object creation");
1234 if (!notification_channel
) {
1238 /* Subscribe a valid condition. */
1239 nc_status
= lttng_notification_channel_subscribe(
1240 notification_channel
, condition
);
1241 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
,
1242 "Subscribe to condition");
1244 /* Subscribing again should fail. */
1245 nc_status
= lttng_notification_channel_subscribe(
1246 notification_channel
, condition
);
1247 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_ALREADY_SUBSCRIBED
,
1248 "Subscribe to a condition for which subscription was already done");
1251 lttng_unregister_trigger(trigger
);
1252 lttng_trigger_destroy(trigger
);
1253 lttng_notification_channel_destroy(notification_channel
);
1254 lttng_action_destroy(action
);
1255 lttng_condition_destroy(condition
);
1258 static void test_buffer_usage_notification_channel(const char *session_name
,
1259 const char *channel_name
,
1260 const enum lttng_domain_type domain_type
,
1264 enum lttng_notification_channel_status nc_status
;
1266 struct lttng_action
*low_action
= NULL
;
1267 struct lttng_action
*high_action
= NULL
;
1268 struct lttng_notification
*notification
= NULL
;
1269 struct lttng_notification_channel
*notification_channel
= NULL
;
1270 struct lttng_trigger
*low_trigger
= NULL
;
1271 struct lttng_trigger
*high_trigger
= NULL
;
1273 struct lttng_condition
*low_condition
= NULL
;
1274 struct lttng_condition
*high_condition
= NULL
;
1276 const double low_ratio
= 0.0;
1277 const double high_ratio
= 0.90;
1279 ret
= register_buffer_usage_notify_trigger(session_name
, channel_name
,
1280 domain_type
, BUFFER_USAGE_TYPE_LOW
, low_ratio
,
1281 &low_condition
, &low_action
, &low_trigger
);
1283 fail("Setup error on low trigger registration");
1287 ret
= register_buffer_usage_notify_trigger(session_name
, channel_name
,
1288 domain_type
, BUFFER_USAGE_TYPE_HIGH
, high_ratio
,
1289 &high_condition
, &high_action
, &high_trigger
);
1291 fail("Setup error on high trigger registration");
1296 notification_channel
= lttng_notification_channel_create(
1297 lttng_session_daemon_notification_endpoint
);
1298 ok(notification_channel
, "Notification channel object creation");
1299 if (!notification_channel
) {
1303 /* Subscribe a valid low condition */
1304 nc_status
= lttng_notification_channel_subscribe(
1305 notification_channel
, low_condition
);
1306 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
,
1307 "Subscribe to low condition");
1309 /* Subscribe a valid high condition */
1310 nc_status
= lttng_notification_channel_subscribe(
1311 notification_channel
, high_condition
);
1312 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
,
1313 "Subscribe to high condition");
1315 resume_application();
1317 /* Wait for notification to happen */
1318 stop_consumer(argv
);
1319 lttng_start_tracing(session_name
);
1321 /* Wait for high notification */
1323 nc_status
= lttng_notification_channel_get_next_notification(
1324 notification_channel
, ¬ification
);
1325 } while (nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_INTERRUPTED
);
1326 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
&& notification
&&
1327 lttng_condition_get_type(lttng_notification_get_condition(
1329 LTTNG_CONDITION_TYPE_BUFFER_USAGE_HIGH
,
1330 "High notification received after intermediary communication");
1331 lttng_notification_destroy(notification
);
1332 notification
= NULL
;
1334 suspend_application();
1335 lttng_stop_tracing_no_wait(session_name
);
1336 resume_consumer(argv
);
1337 wait_data_pending(session_name
);
1340 * Test that communication still work even if there is notification
1341 * waiting for consumption.
1344 nc_status
= lttng_notification_channel_unsubscribe(
1345 notification_channel
, low_condition
);
1346 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
,
1347 "Unsubscribe with pending notification");
1349 nc_status
= lttng_notification_channel_subscribe(
1350 notification_channel
, low_condition
);
1351 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
,
1352 "Subscribe with pending notification");
1355 nc_status
= lttng_notification_channel_get_next_notification(
1356 notification_channel
, ¬ification
);
1357 } while (nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_INTERRUPTED
);
1358 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
&& notification
&&
1359 lttng_condition_get_type(lttng_notification_get_condition(
1361 LTTNG_CONDITION_TYPE_BUFFER_USAGE_LOW
,
1362 "Low notification received after intermediary communication");
1363 lttng_notification_destroy(notification
);
1364 notification
= NULL
;
1366 /* Stop consumer to force a high notification */
1367 stop_consumer(argv
);
1368 resume_application();
1369 lttng_start_tracing(session_name
);
1372 nc_status
= lttng_notification_channel_get_next_notification(
1373 notification_channel
, ¬ification
);
1374 } while (nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_INTERRUPTED
);
1375 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
&& notification
&&
1376 lttng_condition_get_type(lttng_notification_get_condition(
1378 LTTNG_CONDITION_TYPE_BUFFER_USAGE_HIGH
,
1379 "High notification received after intermediary communication");
1380 lttng_notification_destroy(notification
);
1381 notification
= NULL
;
1383 suspend_application();
1384 lttng_stop_tracing_no_wait(session_name
);
1385 resume_consumer(argv
);
1386 wait_data_pending(session_name
);
1389 nc_status
= lttng_notification_channel_get_next_notification(
1390 notification_channel
, ¬ification
);
1391 } while (nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_INTERRUPTED
);
1392 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
&& notification
&&
1393 lttng_condition_get_type(lttng_notification_get_condition(
1395 LTTNG_CONDITION_TYPE_BUFFER_USAGE_LOW
,
1396 "Low notification received after re-subscription");
1397 lttng_notification_destroy(notification
);
1398 notification
= NULL
;
1400 stop_consumer(argv
);
1401 resume_application();
1402 /* Stop consumer to force a high notification */
1403 lttng_start_tracing(session_name
);
1406 nc_status
= lttng_notification_channel_get_next_notification(
1407 notification_channel
, ¬ification
);
1408 } while (nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_INTERRUPTED
);
1409 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
&& notification
&&
1410 lttng_condition_get_type(lttng_notification_get_condition(
1412 LTTNG_CONDITION_TYPE_BUFFER_USAGE_HIGH
,
1413 "High notification");
1414 lttng_notification_destroy(notification
);
1415 notification
= NULL
;
1417 suspend_application();
1419 /* Resume consumer to allow event consumption */
1420 lttng_stop_tracing_no_wait(session_name
);
1421 resume_consumer(argv
);
1422 wait_data_pending(session_name
);
1424 nc_status
= lttng_notification_channel_unsubscribe(
1425 notification_channel
, low_condition
);
1426 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
,
1427 "Unsubscribe low condition with pending notification");
1429 nc_status
= lttng_notification_channel_unsubscribe(
1430 notification_channel
, high_condition
);
1431 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
,
1432 "Unsubscribe high condition with pending notification");
1435 lttng_notification_channel_destroy(notification_channel
);
1436 lttng_trigger_destroy(low_trigger
);
1437 lttng_trigger_destroy(high_trigger
);
1438 lttng_action_destroy(low_action
);
1439 lttng_action_destroy(high_action
);
1440 lttng_condition_destroy(low_condition
);
1441 lttng_condition_destroy(high_condition
);
1444 static void create_tracepoint_event_rule_trigger(const char *event_pattern
,
1445 const char *trigger_name
,
1447 unsigned int exclusion_count
,
1448 const char * const *exclusions
,
1449 enum lttng_domain_type domain_type
,
1450 condition_capture_desc_cb capture_desc_cb
,
1451 struct lttng_condition
**condition
,
1452 struct lttng_trigger
**trigger
)
1454 enum lttng_event_rule_status event_rule_status
;
1455 enum lttng_trigger_status trigger_status
;
1457 struct lttng_action
*tmp_action
= NULL
;
1458 struct lttng_event_rule
*event_rule
= NULL
;
1459 struct lttng_condition
*tmp_condition
= NULL
;
1460 struct lttng_trigger
*tmp_trigger
= NULL
;
1463 assert(event_pattern
);
1464 assert(trigger_name
);
1468 event_rule
= lttng_event_rule_tracepoint_create(domain_type
);
1469 ok(event_rule
, "Tracepoint event rule object creation");
1471 event_rule_status
= lttng_event_rule_tracepoint_set_pattern(
1472 event_rule
, event_pattern
);
1473 ok(event_rule_status
== LTTNG_EVENT_RULE_STATUS_OK
,
1474 "Setting tracepoint event rule pattern: '%s'",
1478 event_rule_status
= lttng_event_rule_tracepoint_set_filter(
1479 event_rule
, filter
);
1480 ok(event_rule_status
== LTTNG_EVENT_RULE_STATUS_OK
,
1481 "Setting tracepoint event rule filter: '%s'",
1487 bool success
= true;
1489 assert(domain_type
== LTTNG_DOMAIN_UST
);
1490 assert(exclusion_count
> 0);
1492 for (i
= 0; i
< exclusion_count
; i
++) {
1494 lttng_event_rule_tracepoint_add_exclusion(
1497 if (event_rule_status
!= LTTNG_EVENT_RULE_STATUS_OK
) {
1498 fail("Setting tracepoint event rule exclusion '%s'.",
1504 ok(success
, "Setting tracepoint event rule exclusions");
1507 tmp_condition
= lttng_condition_event_rule_create(event_rule
);
1508 ok(tmp_condition
, "Condition event rule object creation");
1510 if (capture_desc_cb
) {
1511 ret
= capture_desc_cb(tmp_condition
);
1513 fail("Failed to generate the condition capture descriptor");
1518 tmp_action
= lttng_action_notify_create();
1519 ok(tmp_action
, "Action event rule object creation");
1521 tmp_trigger
= lttng_trigger_create(tmp_condition
, tmp_action
);
1522 ok(tmp_trigger
, "Trigger object creation %s", trigger_name
);
1524 trigger_status
= lttng_trigger_set_name(tmp_trigger
, trigger_name
);
1525 ok(trigger_status
== LTTNG_TRIGGER_STATUS_OK
,
1526 "Setting name to trigger %s", trigger_name
);
1528 ret
= lttng_register_trigger(tmp_trigger
);
1529 ok(ret
== 0, "Trigger registration %s", trigger_name
);
1531 lttng_event_rule_destroy(event_rule
);
1533 *condition
= tmp_condition
;
1534 *trigger
= tmp_trigger
;
1539 static struct lttng_notification
*get_next_notification(
1540 struct lttng_notification_channel
*notification_channel
)
1542 struct lttng_notification
*local_notification
= NULL
;
1543 enum lttng_notification_channel_status status
;
1545 /* Receive the next notification. */
1546 status
= lttng_notification_channel_get_next_notification(
1547 notification_channel
, &local_notification
);
1550 case LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
:
1552 case LTTNG_NOTIFICATION_CHANNEL_STATUS_NOTIFICATIONS_DROPPED
:
1553 fail("Notifications have been dropped");
1554 local_notification
= NULL
;
1557 /* Unhandled conditions / errors. */
1558 fail("Failed to get next notification (unknown notification channel status): status = %d",
1560 local_notification
= NULL
;
1564 return local_notification
;
1567 static void test_tracepoint_event_rule_notification(
1568 enum lttng_domain_type domain_type
)
1572 const int notification_count
= 3;
1573 enum lttng_notification_channel_status nc_status
;
1574 struct lttng_action
*action
= NULL
;
1575 struct lttng_condition
*condition
= NULL
;
1576 struct lttng_notification_channel
*notification_channel
= NULL
;
1577 struct lttng_trigger
*trigger
= NULL
;
1578 const char * const trigger_name
= "my_precious";
1579 const char *pattern
;
1581 if (domain_type
== LTTNG_DOMAIN_UST
) {
1582 pattern
= "tp:tptest";
1584 pattern
= "lttng_test_filter_event";
1587 create_tracepoint_event_rule_trigger(pattern
, trigger_name
, NULL
, 0,
1588 NULL
, domain_type
, NULL
, &condition
, &trigger
);
1590 notification_channel
= lttng_notification_channel_create(
1591 lttng_session_daemon_notification_endpoint
);
1592 ok(notification_channel
, "Notification channel object creation");
1594 nc_status
= lttng_notification_channel_subscribe(
1595 notification_channel
, condition
);
1596 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
,
1597 "Subscribe to tracepoint event rule condition");
1599 resume_application();
1601 /* Get notifications. */
1602 for (i
= 0; i
< notification_count
; i
++) {
1603 struct lttng_notification
*notification
= get_next_notification(
1604 notification_channel
);
1606 ok(notification
, "Received notification (%d/%d)", i
+ 1,
1607 notification_count
);
1610 if (notification
== NULL
) {
1614 ret
= validator_notification_trigger_name(notification
, trigger_name
);
1615 lttng_notification_destroy(notification
);
1622 suspend_application();
1623 lttng_notification_channel_destroy(notification_channel
);
1624 lttng_unregister_trigger(trigger
);
1625 lttng_trigger_destroy(trigger
);
1626 lttng_action_destroy(action
);
1627 lttng_condition_destroy(condition
);
1631 static void test_tracepoint_event_rule_notification_filter(
1632 enum lttng_domain_type domain_type
)
1635 const int notification_count
= 3;
1636 enum lttng_notification_channel_status nc_status
;
1637 struct lttng_condition
*ctrl_condition
= NULL
, *condition
= NULL
;
1638 struct lttng_notification_channel
*notification_channel
= NULL
;
1639 struct lttng_trigger
*ctrl_trigger
= NULL
, *trigger
= NULL
;
1640 const char * const ctrl_trigger_name
= "control_trigger";
1641 const char * const trigger_name
= "trigger";
1642 const char *pattern
;
1643 int ctrl_count
= 0, count
= 0;
1645 if (domain_type
== LTTNG_DOMAIN_UST
) {
1646 pattern
= "tp:tptest";
1648 pattern
= "lttng_test_filter_event";
1651 notification_channel
= lttng_notification_channel_create(
1652 lttng_session_daemon_notification_endpoint
);
1653 ok(notification_channel
, "Notification channel object creation");
1655 create_tracepoint_event_rule_trigger(pattern
, ctrl_trigger_name
, NULL
,
1656 0, NULL
, domain_type
, NULL
, &ctrl_condition
, &ctrl_trigger
);
1658 nc_status
= lttng_notification_channel_subscribe(
1659 notification_channel
, ctrl_condition
);
1660 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
,
1661 "Subscribe to tracepoint event rule condition");
1664 * Attach a filter expression to get notification only if the
1665 * `intfield` is even.
1667 create_tracepoint_event_rule_trigger(pattern
, trigger_name
,
1668 "(intfield & 1) == 0", 0, NULL
, domain_type
, NULL
, &condition
,
1671 nc_status
= lttng_notification_channel_subscribe(
1672 notification_channel
, condition
);
1673 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
,
1674 "Subscribe to tracepoint event rule condition");
1677 * We registered 2 notifications triggers, one with a filter and one
1678 * without (control). The one with a filter will only fired when the
1679 * `intfield` is a multiple of 2. We should get two times as many
1680 * control notifications as filter notifications.
1682 resume_application();
1685 * Get 3 notifications. We should get 1 for the regular trigger (with
1686 * the filter) and 2 from the control trigger. This works whatever
1687 * the order we receive the notifications.
1689 for (i
= 0; i
< notification_count
; i
++) {
1691 struct lttng_notification
*notification
= get_next_notification(
1692 notification_channel
);
1694 ok(notification
, "Received notification (%d/%d)", i
+ 1,
1695 notification_count
);
1698 if (notification
== NULL
) {
1702 name
= get_notification_trigger_name(notification
);
1704 lttng_notification_destroy(notification
);
1708 if (strcmp(ctrl_trigger_name
, name
) == 0) {
1710 } else if (strcmp(trigger_name
, name
) == 0) {
1714 lttng_notification_destroy(notification
);
1717 ok(ctrl_count
/ 2 == count
,
1718 "Get twice as many control notif as of regular notif");
1721 suspend_application();
1723 lttng_unregister_trigger(trigger
);
1724 lttng_unregister_trigger(ctrl_trigger
);
1725 lttng_notification_channel_destroy(notification_channel
);
1726 lttng_trigger_destroy(trigger
);
1727 lttng_trigger_destroy(ctrl_trigger
);
1728 lttng_condition_destroy(condition
);
1729 lttng_condition_destroy(ctrl_condition
);
1732 static void test_tracepoint_event_rule_notification_exclusion(
1733 enum lttng_domain_type domain_type
)
1735 enum lttng_notification_channel_status nc_status
;
1736 struct lttng_condition
*ctrl_condition
= NULL
, *condition
= NULL
;
1737 struct lttng_notification_channel
*notification_channel
= NULL
;
1738 struct lttng_trigger
*ctrl_trigger
= NULL
, *trigger
= NULL
;
1739 int ctrl_count
= 0, count
= 0, i
;
1740 const int notification_count
= 6;
1741 const char * const ctrl_trigger_name
= "control_exclusion_trigger";
1742 const char * const trigger_name
= "exclusion_trigger";
1743 const char * const pattern
= "tp:tptest*";
1744 const char * const exclusions
[] = {
1751 notification_channel
= lttng_notification_channel_create(
1752 lttng_session_daemon_notification_endpoint
);
1753 ok(notification_channel
, "Notification channel object creation");
1755 create_tracepoint_event_rule_trigger(pattern
, ctrl_trigger_name
, NULL
,
1756 0, NULL
, domain_type
, NULL
, &ctrl_condition
,
1759 nc_status
= lttng_notification_channel_subscribe(
1760 notification_channel
, ctrl_condition
);
1761 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
,
1762 "Subscribe to tracepoint event rule condition");
1764 create_tracepoint_event_rule_trigger(pattern
, trigger_name
, NULL
, 4,
1765 exclusions
, domain_type
, NULL
, &condition
,
1768 nc_status
= lttng_notification_channel_subscribe(
1769 notification_channel
, condition
);
1770 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
,
1771 "Subscribe to tracepoint event rule condition");
1774 * We registered 2 notifications triggers, one with an exclusion and
1775 * one without (control).
1776 * - The trigger with an exclusion will fire once every iteration.
1777 * - The trigger without an exclusion will fire 5 times every
1780 * We should get 5 times as many notifications from the control
1783 resume_application();
1786 * Get 6 notifications. We should get 1 for the regular trigger (with
1787 * the exclusion) and 5 from the control trigger. This works whatever
1788 * the order we receive the notifications.
1790 for (i
= 0; i
< notification_count
; i
++) {
1792 struct lttng_notification
*notification
= get_next_notification(
1793 notification_channel
);
1795 ok(notification
, "Received notification (%d/%d)", i
+ 1,
1796 notification_count
);
1799 if (notification
== NULL
) {
1803 name
= get_notification_trigger_name(notification
);
1805 lttng_notification_destroy(notification
);
1809 if (strcmp(ctrl_trigger_name
, name
) == 0) {
1811 } else if (strcmp(trigger_name
, name
) == 0) {
1815 lttng_notification_destroy(notification
);
1818 ok(ctrl_count
/ 5 == count
,
1819 "Got 5 times as many control notif as of regular notif");
1822 suspend_application();
1824 lttng_unregister_trigger(trigger
);
1825 lttng_unregister_trigger(ctrl_trigger
);
1826 lttng_notification_channel_destroy(notification_channel
);
1827 lttng_trigger_destroy(trigger
);
1828 lttng_trigger_destroy(ctrl_trigger
);
1829 lttng_condition_destroy(condition
);
1830 lttng_condition_destroy(ctrl_condition
);
1834 static void test_kprobe_event_rule_notification(
1835 enum lttng_domain_type domain_type
)
1838 const int notification_count
= 3;
1839 enum lttng_notification_channel_status nc_status
;
1840 enum lttng_event_rule_status event_rule_status
;
1841 enum lttng_trigger_status trigger_status
;
1842 struct lttng_notification_channel
*notification_channel
= NULL
;
1843 struct lttng_condition
*condition
= NULL
;
1844 struct lttng_kernel_probe_location
*location
= NULL
;
1845 struct lttng_event_rule
*event_rule
= NULL
;
1846 struct lttng_action
*action
= NULL
;
1847 struct lttng_trigger
*trigger
= NULL
;
1848 const char * const trigger_name
= "kprobe_trigger";
1849 const char * const symbol_name
= "lttng_test_filter_event_write";
1851 action
= lttng_action_notify_create();
1853 fail("Failed to create notify action");
1857 location
= lttng_kernel_probe_location_symbol_create(symbol_name
, 0);
1859 fail("Failed to create kernel probe location");
1863 notification_channel
= lttng_notification_channel_create(
1864 lttng_session_daemon_notification_endpoint
);
1865 ok(notification_channel
, "Notification channel object creation");
1867 event_rule
= lttng_event_rule_kernel_probe_create();
1868 ok(event_rule
, "kprobe event rule object creation");
1870 event_rule_status
= lttng_event_rule_kernel_probe_set_location(
1871 event_rule
, location
);
1872 ok(event_rule_status
== LTTNG_EVENT_RULE_STATUS_OK
,
1873 "Setting kprobe event rule location: '%s'", symbol_name
);
1875 event_rule_status
= lttng_event_rule_kernel_probe_set_name(
1876 event_rule
, trigger_name
);
1877 ok(event_rule_status
== LTTNG_EVENT_RULE_STATUS_OK
,
1878 "Setting kprobe event rule name: '%s'", trigger_name
);
1880 condition
= lttng_condition_event_rule_create(event_rule
);
1881 ok(condition
, "Condition event rule object creation");
1883 /* Register the trigger for condition. */
1884 trigger
= lttng_trigger_create(condition
, action
);
1886 fail("Failed to create trigger with kernel probe event rule condition and notify action");
1890 trigger_status
= lttng_trigger_set_name(trigger
, trigger_name
);
1891 ok(trigger_status
== LTTNG_TRIGGER_STATUS_OK
,
1892 "Setting trigger name to '%s'", trigger_name
);
1894 ret
= lttng_register_trigger(trigger
);
1896 fail("Failed to register trigger with kernel probe event rule condition and notify action");
1900 nc_status
= lttng_notification_channel_subscribe(
1901 notification_channel
, condition
);
1902 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
,
1903 "Subscribe to tracepoint event rule condition");
1905 resume_application();
1907 for (i
= 0; i
< notification_count
; i
++) {
1908 struct lttng_notification
*notification
= get_next_notification(
1909 notification_channel
);
1911 ok(notification
, "Received notification (%d/%d)", i
+ 1,
1912 notification_count
);
1915 if (notification
== NULL
) {
1919 ret
= validator_notification_trigger_name(notification
, trigger_name
);
1920 lttng_notification_destroy(notification
);
1927 suspend_application();
1928 lttng_notification_channel_destroy(notification_channel
);
1929 lttng_unregister_trigger(trigger
);
1930 lttng_trigger_destroy(trigger
);
1931 lttng_action_destroy(action
);
1932 lttng_event_rule_destroy(event_rule
);
1933 lttng_condition_destroy(condition
);
1934 lttng_kernel_probe_location_destroy(location
);
1938 static void test_uprobe_event_rule_notification(
1939 enum lttng_domain_type domain_type
,
1940 const char *testapp_path
,
1941 const char *test_symbol_name
)
1944 const int notification_count
= 3;
1945 enum lttng_notification_channel_status nc_status
;
1946 enum lttng_event_rule_status event_rule_status
;
1947 enum lttng_trigger_status trigger_status
;
1948 struct lttng_notification_channel
*notification_channel
= NULL
;
1949 struct lttng_userspace_probe_location
*probe_location
= NULL
;
1950 struct lttng_userspace_probe_location_lookup_method
*lookup_method
=
1952 struct lttng_condition
*condition
= NULL
;
1953 struct lttng_event_rule
*event_rule
= NULL
;
1954 struct lttng_action
*action
= NULL
;
1955 struct lttng_trigger
*trigger
= NULL
;
1956 const char * const trigger_name
= "uprobe_trigger";
1958 action
= lttng_action_notify_create();
1960 fail("Failed to create notify action");
1964 lookup_method
= lttng_userspace_probe_location_lookup_method_function_elf_create();
1965 if (!lookup_method
) {
1966 fail("Setup error on userspace probe lookup method creation");
1970 probe_location
= lttng_userspace_probe_location_function_create(
1971 testapp_path
, test_symbol_name
, lookup_method
);
1972 if (!probe_location
) {
1973 fail("Failed to create userspace probe location");
1977 notification_channel
= lttng_notification_channel_create(
1978 lttng_session_daemon_notification_endpoint
);
1979 ok(notification_channel
, "Notification channel object creation");
1981 event_rule
= lttng_event_rule_uprobe_create();
1982 ok(event_rule
, "kprobe event rule object creation");
1984 event_rule_status
= lttng_event_rule_uprobe_set_location(
1985 event_rule
, probe_location
);
1986 ok(event_rule_status
== LTTNG_EVENT_RULE_STATUS_OK
,
1987 "Setting uprobe event rule location");
1989 event_rule_status
= lttng_event_rule_uprobe_set_name(
1990 event_rule
, trigger_name
);
1991 ok(event_rule_status
== LTTNG_EVENT_RULE_STATUS_OK
,
1992 "Setting uprobe event rule name: '%s'", trigger_name
);
1994 condition
= lttng_condition_event_rule_create(event_rule
);
1995 ok(condition
, "Condition event rule object creation");
1997 /* Register the trigger for condition. */
1998 trigger
= lttng_trigger_create(condition
, action
);
2000 fail("Failed to create trigger with userspace probe event rule condition and notify action");
2004 trigger_status
= lttng_trigger_set_name(trigger
, trigger_name
);
2005 ok(trigger_status
== LTTNG_TRIGGER_STATUS_OK
,
2006 "Setting name to trigger '%s'", trigger_name
);
2008 ret
= lttng_register_trigger(trigger
);
2010 fail("Failed to register trigger with userspace probe event rule condition and notify action");
2014 nc_status
= lttng_notification_channel_subscribe(
2015 notification_channel
, condition
);
2016 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
,
2017 "Subscribe to tracepoint event rule condition");
2019 resume_application();
2021 for (i
= 0; i
< 3; i
++) {
2022 struct lttng_notification
*notification
= get_next_notification(
2023 notification_channel
);
2025 ok(notification
, "Received notification (%d/%d)", i
+ 1,
2026 notification_count
);
2029 if (notification
== NULL
) {
2033 ret
= validator_notification_trigger_name(notification
, trigger_name
);
2034 lttng_notification_destroy(notification
);
2040 suspend_application();
2042 lttng_notification_channel_destroy(notification_channel
);
2043 lttng_unregister_trigger(trigger
);
2044 lttng_trigger_destroy(trigger
);
2045 lttng_action_destroy(action
);
2046 lttng_userspace_probe_location_destroy(probe_location
);
2047 lttng_event_rule_destroy(event_rule
);
2048 lttng_condition_destroy(condition
);
2052 static void test_syscall_event_rule_notification(
2053 enum lttng_domain_type domain_type
)
2056 const int notification_count
= 3;
2057 enum lttng_notification_channel_status nc_status
;
2058 enum lttng_event_rule_status event_rule_status
;
2059 enum lttng_trigger_status trigger_status
;
2060 struct lttng_notification_channel
*notification_channel
= NULL
;
2061 struct lttng_condition
*condition
= NULL
;
2062 struct lttng_event_rule
*event_rule
= NULL
;
2063 struct lttng_action
*action
= NULL
;
2064 struct lttng_trigger
*trigger
= NULL
;
2065 const char * const trigger_name
= "syscall_trigger";
2066 const char * const syscall_name
= "openat";
2068 action
= lttng_action_notify_create();
2070 fail("Failed to create notify action");
2074 notification_channel
= lttng_notification_channel_create(
2075 lttng_session_daemon_notification_endpoint
);
2076 ok(notification_channel
, "Notification channel object creation");
2078 event_rule
= lttng_event_rule_syscall_create();
2079 ok(event_rule
, "syscall event rule object creation");
2081 event_rule_status
= lttng_event_rule_syscall_set_pattern(
2082 event_rule
, syscall_name
);
2083 ok(event_rule_status
== LTTNG_EVENT_RULE_STATUS_OK
,
2084 "Setting syscall event rule pattern: '%s'", syscall_name
);
2086 condition
= lttng_condition_event_rule_create(event_rule
);
2087 ok(condition
, "Condition syscall event rule object creation");
2089 /* Register the trigger for condition. */
2090 trigger
= lttng_trigger_create(condition
, action
);
2092 fail("Failed to create trigger with syscall event rule condition and notify action");
2096 trigger_status
= lttng_trigger_set_name(trigger
, trigger_name
);
2097 ok(trigger_status
== LTTNG_TRIGGER_STATUS_OK
,
2098 "Setting name to trigger '%s'", trigger_name
);
2100 ret
= lttng_register_trigger(trigger
);
2102 fail("Failed to register trigger with syscall event rule condition and notify action");
2106 nc_status
= lttng_notification_channel_subscribe(
2107 notification_channel
, condition
);
2108 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
,
2109 "Subscribe to tracepoint event rule condition");
2111 resume_application();
2113 for (i
= 0; i
< notification_count
; i
++) {
2114 struct lttng_notification
*notification
= get_next_notification(
2115 notification_channel
);
2117 ok(notification
, "Received notification (%d/%d)", i
+ 1,
2118 notification_count
);
2121 if (notification
== NULL
) {
2125 ret
= validator_notification_trigger_name(notification
, trigger_name
);
2126 lttng_notification_destroy(notification
);
2132 suspend_application();
2133 lttng_notification_channel_destroy(notification_channel
);
2134 lttng_unregister_trigger(trigger
);
2135 lttng_trigger_destroy(trigger
);
2136 lttng_action_destroy(action
);
2137 lttng_condition_destroy(condition
);
2141 static void test_syscall_event_rule_notification_filter(
2142 enum lttng_domain_type domain_type
)
2145 const int notification_count
= 3;
2146 enum lttng_notification_channel_status nc_status
;
2147 enum lttng_event_rule_status event_rule_status
;
2148 enum lttng_trigger_status trigger_status
;
2149 struct lttng_notification_channel
*notification_channel
= NULL
;
2150 struct lttng_condition
*condition
= NULL
;
2151 struct lttng_event_rule
*event_rule
= NULL
;
2152 struct lttng_action
*action
= NULL
;
2153 struct lttng_trigger
*trigger
= NULL
;
2154 const char * const trigger_name
= "syscall_trigger";
2155 const char * const syscall_name
= "openat";
2156 const char * const filter_pattern
= "filename == \"/proc/cpuinfo\"";
2158 action
= lttng_action_notify_create();
2160 fail("Failed to create notify action");
2164 notification_channel
= lttng_notification_channel_create(
2165 lttng_session_daemon_notification_endpoint
);
2166 ok(notification_channel
, "Notification channel object creation");
2168 event_rule
= lttng_event_rule_syscall_create();
2169 ok(event_rule
, "syscall event rule object creation");
2171 event_rule_status
= lttng_event_rule_syscall_set_pattern(
2172 event_rule
, syscall_name
);
2173 ok(event_rule_status
== LTTNG_EVENT_RULE_STATUS_OK
,
2174 "Setting syscall event rule pattern: '%s'", syscall_name
);
2176 event_rule_status
= lttng_event_rule_syscall_set_filter(
2177 event_rule
, filter_pattern
);
2178 ok(event_rule_status
== LTTNG_EVENT_RULE_STATUS_OK
,
2179 "Setting filter: '%s'", filter_pattern
);
2181 condition
= lttng_condition_event_rule_create(event_rule
);
2182 ok(condition
, "Condition event rule object creation");
2184 /* Register the triggers for condition */
2185 trigger
= lttng_trigger_create(condition
, action
);
2187 fail("Failed to create trigger with syscall filtering event rule condition and notify action");
2191 trigger_status
= lttng_trigger_set_name(trigger
, trigger_name
);
2192 ok(trigger_status
== LTTNG_TRIGGER_STATUS_OK
,
2193 "Setting name to trigger '%s'", trigger_name
);
2195 ret
= lttng_register_trigger(trigger
);
2197 fail("Failed to register trigger with syscall filtering event rule condition and notify action");
2201 nc_status
= lttng_notification_channel_subscribe(
2202 notification_channel
, condition
);
2203 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
,
2204 "Subscribe to tracepoint event rule condition");
2206 resume_application();
2208 for (i
= 0; i
< notification_count
; i
++) {
2209 struct lttng_notification
*notification
= get_next_notification(
2210 notification_channel
);
2212 ok(notification
, "Received notification (%d/%d)", i
+ 1,
2213 notification_count
);
2216 if (notification
== NULL
) {
2220 ret
= validator_notification_trigger_name(notification
, trigger_name
);
2221 lttng_notification_destroy(notification
);
2228 suspend_application();
2230 lttng_unregister_trigger(trigger
);
2231 lttng_notification_channel_destroy(notification_channel
);
2232 lttng_trigger_destroy(trigger
);
2233 lttng_event_rule_destroy(event_rule
);
2234 lttng_condition_destroy(condition
);
2238 static int generate_capture_descr(struct lttng_condition
*condition
)
2241 struct lttng_event_expr
*expr
= NULL
;
2242 const unsigned int basic_field_count
= sizeof(test_capture_base_fields
) /
2243 sizeof(*test_capture_base_fields
);
2244 enum lttng_condition_status cond_status
;
2246 for (i
= 0; i
< basic_field_count
; i
++) {
2247 diag("Adding capture descriptor '%s'",
2248 test_capture_base_fields
[i
].field_name
);
2250 switch (test_capture_base_fields
[i
].field_type
) {
2251 case FIELD_TYPE_PAYLOAD
:
2252 expr
= lttng_event_expr_event_payload_field_create(
2253 test_capture_base_fields
[i
].field_name
);
2255 case FIELD_TYPE_CONTEXT
:
2256 expr
= lttng_event_expr_channel_context_field_create(
2257 test_capture_base_fields
[i
].field_name
);
2259 case FIELD_TYPE_ARRAY_FIELD
:
2263 char field_name
[FIELD_NAME_MAX_LEN
];
2264 struct lttng_event_expr
*array_expr
= NULL
;
2266 nb_matches
= sscanf(test_capture_base_fields
[i
].field_name
,
2267 "%[^[][%u]", field_name
, &index
);
2268 if (nb_matches
!= 2) {
2269 fail("Unexpected array field name format: field name = '%s'",
2270 test_capture_base_fields
[i
].field_name
);
2275 array_expr
= lttng_event_expr_event_payload_field_create(
2278 expr
= lttng_event_expr_array_field_element_create(
2282 case FIELD_TYPE_APP_CONTEXT
:
2283 fail("Application context tests are not implemented yet.");
2291 fail("Failed to create capture expression");
2296 cond_status
= lttng_condition_event_rule_append_capture_descriptor(
2298 if (cond_status
!= LTTNG_CONDITION_STATUS_OK
) {
2299 fail("Failed to append capture descriptor");
2301 lttng_event_expr_destroy(expr
);
2312 static int validator_notification_trigger_capture(
2313 enum lttng_domain_type domain
,
2314 struct lttng_notification
*notification
,
2315 const int iteration
)
2318 unsigned int capture_count
, i
;
2319 enum lttng_evaluation_status evaluation_status
;
2320 enum lttng_event_field_value_status event_field_value_status
;
2321 const struct lttng_evaluation
*evaluation
;
2322 const struct lttng_event_field_value
*captured_fields
;
2323 bool at_least_one_error
= false;
2325 evaluation
= lttng_notification_get_evaluation(notification
);
2326 if (evaluation
== NULL
) {
2327 fail("Failed to get evaluation from notification during trigger capture test");
2332 evaluation_status
= lttng_evaluation_event_rule_get_captured_values(
2333 evaluation
, &captured_fields
);
2334 if (evaluation_status
!= LTTNG_EVALUATION_STATUS_OK
) {
2335 diag("Failed to get event rule evaluation captured values: status = %d",
2336 (int) evaluation_status
);
2341 event_field_value_status
=
2342 lttng_event_field_value_array_get_length(captured_fields
,
2344 if (event_field_value_status
!= LTTNG_EVENT_FIELD_VALUE_STATUS_OK
) {
2345 fail("Failed to get count of captured value field array");
2350 for (i
= 0; i
< capture_count
; i
++) {
2351 const struct lttng_event_field_value
*captured_field
= NULL
;
2352 validate_cb validate
;
2355 diag("Validating capture of field '%s'",
2356 test_capture_base_fields
[i
].field_name
);
2357 event_field_value_status
=
2358 lttng_event_field_value_array_get_element_at_index(
2363 case LTTNG_DOMAIN_UST
:
2364 expected
= test_capture_base_fields
[i
].expected_ust
;
2366 case LTTNG_DOMAIN_KERNEL
:
2367 expected
= test_capture_base_fields
[i
].expected_kernel
;
2370 fail("Unexpected domain encountered: domain = %d",
2376 if (domain
== LTTNG_DOMAIN_UST
) {
2377 validate
= test_capture_base_fields
[i
].validate_ust
;
2379 validate
= test_capture_base_fields
[i
].validate_kernel
;
2383 ok(event_field_value_status
== LTTNG_EVENT_FIELD_VALUE_STATUS_UNAVAILABLE
,
2384 "No payload captured");
2388 if (event_field_value_status
!= LTTNG_EVENT_FIELD_VALUE_STATUS_OK
) {
2389 if (event_field_value_status
==
2390 LTTNG_EVENT_FIELD_VALUE_STATUS_UNAVAILABLE
) {
2391 fail("Expected a capture but it is unavailable");
2393 fail("lttng_event_field_value_array_get_element_at_index returned an error: status = %d",
2394 (int) event_field_value_status
);
2401 diag("Captured field of type %s",
2402 field_value_type_to_str(
2403 lttng_event_field_value_get_type(captured_field
)));
2406 ret
= validate(captured_field
, iteration
);
2408 at_least_one_error
= true;
2412 ret
= at_least_one_error
;
2418 static void test_tracepoint_event_rule_notification_capture(
2419 enum lttng_domain_type domain_type
)
2421 enum lttng_notification_channel_status nc_status
;
2424 struct lttng_condition
*condition
= NULL
;
2425 struct lttng_notification_channel
*notification_channel
= NULL
;
2426 struct lttng_trigger
*trigger
= NULL
;
2427 const char *trigger_name
= "my_precious";
2428 const char *pattern
;
2430 if (domain_type
== LTTNG_DOMAIN_UST
) {
2431 pattern
= "tp:tptest";
2433 pattern
= "lttng_test_filter_event";
2436 create_tracepoint_event_rule_trigger(pattern
, trigger_name
, NULL
, 0,
2437 NULL
, domain_type
, generate_capture_descr
, &condition
,
2440 notification_channel
= lttng_notification_channel_create(
2441 lttng_session_daemon_notification_endpoint
);
2442 ok(notification_channel
, "Notification channel object creation");
2444 nc_status
= lttng_notification_channel_subscribe(
2445 notification_channel
, condition
);
2446 ok(nc_status
== LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
,
2447 "Subscribe to tracepoint event rule condition");
2449 resume_application();
2451 /* Get 3 notifications */
2452 for (i
= 0; i
< 3; i
++) {
2453 struct lttng_notification
*notification
= get_next_notification(
2454 notification_channel
);
2455 ok(notification
, "Received notification");
2458 if (notification
== NULL
) {
2462 ret
= validator_notification_trigger_name(notification
, trigger_name
);
2464 lttng_notification_destroy(notification
);
2468 ret
= validator_notification_trigger_capture(domain_type
, notification
, i
);
2470 lttng_notification_destroy(notification
);
2474 lttng_notification_destroy(notification
);
2478 suspend_application();
2479 lttng_notification_channel_destroy(notification_channel
);
2480 lttng_unregister_trigger(trigger
);
2481 lttng_trigger_destroy(trigger
);
2482 lttng_condition_destroy(condition
);
2486 int main(int argc
, const char *argv
[])
2489 const char *domain_type_string
= NULL
;
2490 enum lttng_domain_type domain_type
= LTTNG_DOMAIN_NONE
;
2493 fail("Missing test scenario, domain type, pid, or application state file argument(s)");
2497 test_scenario
= atoi(argv
[1]);
2498 domain_type_string
= argv
[2];
2499 app_pid
= (pid_t
) atoi(argv
[3]);
2500 app_state_file
= argv
[4];
2502 if (!strcmp("LTTNG_DOMAIN_UST", domain_type_string
)) {
2503 domain_type
= LTTNG_DOMAIN_UST
;
2505 if (!strcmp("LTTNG_DOMAIN_KERNEL", domain_type_string
)) {
2506 domain_type
= LTTNG_DOMAIN_KERNEL
;
2508 if (domain_type
== LTTNG_DOMAIN_NONE
) {
2509 fail("Unknown domain type");
2514 * Test cases are responsible for resuming the app when needed
2515 * and making sure it's suspended when returning.
2517 suspend_application();
2519 switch (test_scenario
) {
2524 /* Test cases that need gen-ust-event testapp. */
2525 diag("Test basic notification error paths for %s domain",
2526 domain_type_string
);
2527 test_invalid_channel_subscription(domain_type
);
2529 diag("Test tracepoint event rule notifications for domain %s",
2530 domain_type_string
);
2531 test_tracepoint_event_rule_notification(domain_type
);
2533 diag("Test tracepoint event rule notifications with filter for domain %s",
2534 domain_type_string
);
2535 test_tracepoint_event_rule_notification_filter(domain_type
);
2540 const char *session_name
, *channel_name
;
2542 /* Test cases that need a tracing session enabled. */
2546 * Argument 7 and upward are named pipe location for consumerd
2549 named_pipe_args_start
= 7;
2552 fail("Missing parameter for tests to run %d", argc
);
2558 session_name
= argv
[5];
2559 channel_name
= argv
[6];
2561 test_subscription_twice(session_name
, channel_name
,
2564 diag("Test trigger for domain %s with buffer_usage_low condition",
2565 domain_type_string
);
2566 test_triggers_buffer_usage_condition(session_name
, channel_name
,
2568 LTTNG_CONDITION_TYPE_BUFFER_USAGE_LOW
);
2570 diag("Test trigger for domain %s with buffer_usage_high condition",
2571 domain_type_string
);
2572 test_triggers_buffer_usage_condition(session_name
, channel_name
,
2574 LTTNG_CONDITION_TYPE_BUFFER_USAGE_HIGH
);
2576 diag("Test buffer usage notification channel api for domain %s",
2577 domain_type_string
);
2578 test_buffer_usage_notification_channel(session_name
, channel_name
,
2585 * Test cases that need a test app with more than one event
2591 * At the moment, the only test case of this scenario is
2592 * exclusion which is only supported by UST.
2594 assert(domain_type
== LTTNG_DOMAIN_UST
);
2595 diag("Test tracepoint event rule notifications with exclusion for domain %s",
2596 domain_type_string
);
2597 test_tracepoint_event_rule_notification_exclusion(domain_type
);
2604 /* Test cases that need the kernel tracer. */
2605 assert(domain_type
== LTTNG_DOMAIN_KERNEL
);
2607 diag("Test kprobe event rule notifications for domain %s",
2608 domain_type_string
);
2610 test_kprobe_event_rule_notification(domain_type
);
2617 /* Test cases that need the kernel tracer. */
2618 assert(domain_type
== LTTNG_DOMAIN_KERNEL
);
2620 diag("Test syscall event rule notifications for domain %s",
2621 domain_type_string
);
2623 test_syscall_event_rule_notification(domain_type
);
2625 diag("Test syscall filtering event rule notifications for domain %s",
2626 domain_type_string
);
2628 test_syscall_event_rule_notification_filter(domain_type
);
2634 const char *testapp_path
, *test_symbol_name
;
2639 fail("Missing parameter for tests to run %d", argc
);
2643 testapp_path
= argv
[5];
2644 test_symbol_name
= argv
[6];
2645 /* Test cases that need the kernel tracer. */
2646 assert(domain_type
== LTTNG_DOMAIN_KERNEL
);
2648 diag("Test userspace-probe event rule notifications for domain %s",
2649 domain_type_string
);
2651 test_uprobe_event_rule_notification(
2652 domain_type
, testapp_path
, test_symbol_name
);
2658 switch(domain_type
) {
2659 case LTTNG_DOMAIN_UST
:
2662 case LTTNG_DOMAIN_KERNEL
:
2669 diag("Test tracepoint event rule notification captures for domain %s",
2670 domain_type_string
);
2671 test_tracepoint_event_rule_notification_capture(domain_type
);
2681 return exit_status();