de8734603fd309ba8d42db1cffac97015b5cd3e9
[lttng-tools.git] / tests / regression / tools / notification / notification.c
1 /*
2 * notification.c
3 *
4 * Tests suite for LTTng notification API
5 *
6 * Copyright (C) 2017 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
7 *
8 * Permission is hereby granted, free of charge, to any person obtaining a copy
9 * of this software and associated documentation files (the "Software"), to deal
10 * in the Software without restriction, including without limitation the rights
11 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 * copies of the Software, and to permit persons to whom the Software is
13 * furnished to do so, subject to the following conditions:
14 *
15 * The above copyright notice and this permission notice shall be included in
16 * all copies or substantial portions of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 * SOFTWARE.
25 */
26
27 #include <assert.h>
28 #include <math.h>
29 #include <stdbool.h>
30 #include <stdio.h>
31 #include <stdlib.h>
32 #include <string.h>
33 #include <unistd.h>
34 #include <inttypes.h>
35 #include <sys/types.h>
36 #include <sys/stat.h>
37 #include <fcntl.h>
38 #include <signal.h>
39 #include <errno.h>
40 #include <poll.h>
41
42 #include <lttng/action/action.h>
43 #include <lttng/action/notify.h>
44 #include <lttng/condition/buffer-usage.h>
45 #include <lttng/condition/condition.h>
46 #include <lttng/condition/evaluation.h>
47 #include <lttng/domain.h>
48 #include <lttng/endpoint.h>
49 #include <lttng/lttng-error.h>
50 #include <lttng/notification/channel.h>
51 #include <lttng/notification/notification.h>
52 #include <lttng/trigger/trigger.h>
53
54 #include <tap/tap.h>
55
56 #define NUM_TESTS 104
57
58 int nb_args = 0;
59 int named_pipe_args_start = 0;
60 pid_t app_pid = -1;
61 const char *app_state_file = NULL;
62
63 static
64 void wait_on_file(const char *path, bool file_exist)
65 {
66 if (!path) {
67 return;
68 }
69 for (;;) {
70 int ret;
71 struct stat buf;
72
73 ret = stat(path, &buf);
74 if (ret == -1 && errno == ENOENT) {
75 if (file_exist) {
76 (void) poll(NULL, 0, 10); /* 10 ms delay */
77 continue; /* retry */
78 }
79 break; /* File does not exist */
80 }
81 if (ret) {
82 perror("stat");
83 exit(EXIT_FAILURE);
84 }
85 break; /* found */
86 }
87 }
88
89 int write_pipe(const char *path, uint8_t data)
90 {
91 int ret = 0;
92 int fd = 0;
93
94 fd = open(path, O_WRONLY | O_NONBLOCK);
95 if (fd < 0) {
96 perror("Could not open consumer control named pipe");
97 goto end;
98 }
99
100 ret = write(fd, &data , sizeof(data));
101 if (ret < 1) {
102 perror("Named pipe write failed");
103 if (close(fd)) {
104 perror("Named pipe close failed");
105 }
106 ret = -1;
107 goto end;
108 }
109
110 ret = close(fd);
111 if (ret < 0) {
112 perror("Name pipe closing failed");
113 ret = -1;
114 goto end;
115 }
116 end:
117 return ret;
118 }
119
120 int stop_consumer(const char **argv)
121 {
122 int ret = 0;
123 for (int i = named_pipe_args_start; i < nb_args; i++) {
124 ret = write_pipe(argv[i], 49);
125 }
126 return ret;
127 }
128
129 int resume_consumer(const char **argv)
130 {
131 int ret = 0;
132 for (int i = named_pipe_args_start; i < nb_args; i++) {
133 ret = write_pipe(argv[i], 0);
134 }
135 return ret;
136 }
137
138 int suspend_application()
139 {
140 int ret;
141 struct stat buf;
142
143 if (!stat(app_state_file, &buf)) {
144 fail("App is already in a suspended state.");
145 ret = -1;
146 goto error;
147 }
148
149 /*
150 * Send SIGUSR1 to application instructing it to bypass tracepoint.
151 */
152 ret = kill(app_pid, SIGUSR1);
153 if (ret) {
154 fail("SIGUSR1 failed. errno %d", errno);
155 ret = -1;
156 goto error;
157 }
158
159 wait_on_file(app_state_file, true);
160
161 error:
162 return ret;
163
164 }
165
166 int resume_application()
167 {
168 int ret;
169 struct stat buf;
170
171 ret = stat(app_state_file, &buf);
172 if (ret == -1 && errno == ENOENT) {
173 fail("State file does not exist");
174 goto error;
175 }
176 if (ret) {
177 perror("stat");
178 goto error;
179 }
180
181 ret = kill(app_pid, SIGUSR1);
182 if (ret) {
183 fail("SIGUSR1 failed. errno %d", errno);
184 ret = -1;
185 goto error;
186 }
187
188 wait_on_file(app_state_file, false);
189
190 error:
191 return ret;
192
193 }
194
195
196 void test_triggers_buffer_usage_condition(const char *session_name,
197 const char *channel_name,
198 enum lttng_domain_type domain_type,
199 enum lttng_condition_type condition_type)
200 {
201 enum lttng_condition_status condition_status;
202 struct lttng_action *action;
203
204 /* Set-up */
205 action = lttng_action_notify_create();
206 if (!action) {
207 fail("Setup error on action creation");
208 goto end;
209 }
210
211 /* Test lttng_register_trigger with null value */
212 ok(lttng_register_trigger(NULL) == -LTTNG_ERR_INVALID, "Registering a NULL trigger fails as expected");
213
214 /* Test: register a trigger */
215 unsigned int test_vector_size = 5;
216 for (unsigned int i = 0; i < pow(2,test_vector_size); i++) {
217 int loop_ret = 0;
218 char *test_tuple_string = NULL;
219 unsigned int mask_position = 0;
220 bool session_name_set = false;
221 bool channel_name_set = false;
222 bool threshold_ratio_set = false;
223 bool threshold_byte_set = false;
224 bool domain_type_set = false;
225
226 struct lttng_trigger *trigger = NULL;
227 struct lttng_condition *condition = NULL;
228
229 /* Create base condition */
230 switch (condition_type) {
231 case LTTNG_CONDITION_TYPE_BUFFER_USAGE_LOW:
232 condition = lttng_condition_buffer_usage_low_create();
233 break;
234 case LTTNG_CONDITION_TYPE_BUFFER_USAGE_HIGH:
235 condition = lttng_condition_buffer_usage_high_create();
236 break;
237 default:
238 loop_ret = 1;
239 goto loop_end;
240 }
241
242 if (!condition) {
243 loop_ret = 1;
244 goto loop_end;
245
246 }
247
248 /* Prepare the condition for trigger registration test */
249
250 /* Set session name */
251 if ((1 << mask_position) & i) {
252 condition_status = lttng_condition_buffer_usage_set_session_name(
253 condition, session_name);
254 if (condition_status != LTTNG_CONDITION_STATUS_OK) {
255 loop_ret = 1;
256 goto loop_end;
257 }
258 session_name_set = true;
259 }
260 mask_position++;
261
262 /* Set channel name */
263 if ((1 << mask_position) & i) {
264 condition_status = lttng_condition_buffer_usage_set_channel_name(
265 condition, channel_name);
266 if (condition_status != LTTNG_CONDITION_STATUS_OK) {
267 loop_ret = 1;
268 goto loop_end;
269 }
270 channel_name_set = true;
271 }
272 mask_position++;
273
274 /* Set threshold ratio */
275 if ((1 << mask_position) & i) {
276 condition_status = lttng_condition_buffer_usage_set_threshold_ratio(
277 condition, 0.0);
278 if (condition_status != LTTNG_CONDITION_STATUS_OK) {
279 loop_ret = 1;
280 goto loop_end;
281 }
282 threshold_ratio_set = true;
283 }
284 mask_position++;
285
286 /* Set threshold byte */
287 if ((1 << mask_position) & i) {
288 condition_status = lttng_condition_buffer_usage_set_threshold(
289 condition, 0);
290 if (condition_status != LTTNG_CONDITION_STATUS_OK) {
291 loop_ret = 1;
292 goto loop_end;
293 }
294 threshold_byte_set = true;
295 }
296 mask_position++;
297
298 /* Set domain type */
299 if ((1 << mask_position) & i) {
300 condition_status = lttng_condition_buffer_usage_set_domain_type(
301 condition, LTTNG_DOMAIN_UST);
302 if (condition_status != LTTNG_CONDITION_STATUS_OK) {
303 loop_ret = 1;
304 goto loop_end;
305 }
306 domain_type_set = true;
307 }
308
309 /* Safety check */
310 if (mask_position != test_vector_size -1) {
311 assert("Logic error for test vector generation");
312 }
313
314 loop_ret = asprintf(&test_tuple_string, "session name %s, channel name %s, threshold ratio %s, threshold byte %s, domain type %s",
315 session_name_set ? "set" : "unset",
316 channel_name_set ? "set" : "unset",
317 threshold_ratio_set ? "set" : "unset",
318 threshold_byte_set ? "set" : "unset",
319 domain_type_set? "set" : "unset");
320 if (!test_tuple_string || loop_ret < 0) {
321 loop_ret = 1;
322 goto loop_end;
323 }
324
325 /* Create trigger */
326 trigger = lttng_trigger_create(condition, action);
327 if (!trigger) {
328 loop_ret = 1;
329 goto loop_end;
330 }
331
332 loop_ret = lttng_register_trigger(trigger);
333
334 loop_end:
335 if (loop_ret == 1) {
336 fail("Setup error occurred for tuple: %s", test_tuple_string);
337 goto loop_cleanup;
338 }
339
340 /* This combination happens three times */
341 if (session_name_set && channel_name_set
342 && (threshold_ratio_set || threshold_byte_set)
343 && domain_type_set) {
344 ok(loop_ret == 0, "Trigger is registered: %s", test_tuple_string);
345
346 /*
347 * Test that a trigger cannot be registered
348 * multiple time.
349 */
350 loop_ret = lttng_register_trigger(trigger);
351 ok(loop_ret == -LTTNG_ERR_TRIGGER_EXISTS, "Re-register trigger fails as expected: %s", test_tuple_string);
352
353 /* Test that a trigger can be unregistered */
354 loop_ret = lttng_unregister_trigger(trigger);
355 ok(loop_ret == 0, "Unregister trigger: %s", test_tuple_string);
356
357 /*
358 * Test that unregistration of a non-previously
359 * registered trigger fail.
360 */
361 loop_ret = lttng_unregister_trigger(trigger);
362 ok(loop_ret == -LTTNG_ERR_TRIGGER_NOT_FOUND, "Unregister of a non-registerd trigger fails as expected: %s", test_tuple_string);
363 } else {
364 ok(loop_ret == -LTTNG_ERR_INVALID_TRIGGER, "Trigger is invalid as expected and cannot be registered: %s", test_tuple_string);
365 }
366
367 loop_cleanup:
368 free(test_tuple_string);
369 lttng_trigger_destroy(trigger);
370 lttng_condition_destroy(condition);
371 }
372
373 end:
374 lttng_action_destroy(action);
375 }
376
377 static
378 void wait_data_pending(const char *session_name)
379 {
380 int ret;
381
382 do {
383 ret = lttng_data_pending(session_name);
384 assert(ret >= 0);
385 } while (ret != 0);
386 }
387
388 void test_notification_channel(const char *session_name, const char *channel_name, const enum lttng_domain_type domain_type, const char **argv)
389 {
390 int ret = 0;
391 enum lttng_condition_status condition_status;
392 enum lttng_notification_channel_status nc_status;
393
394 struct lttng_action *action = NULL;
395 struct lttng_notification *notification = NULL;
396 struct lttng_notification_channel *notification_channel = NULL;
397 struct lttng_trigger *trigger = NULL;
398
399 struct lttng_condition *low_condition = NULL;
400 struct lttng_condition *high_condition = NULL;
401 struct lttng_condition *dummy_invalid_condition = NULL;
402 struct lttng_condition *dummy_condition = NULL;
403
404 double low_ratio = 0.0;
405 double high_ratio = 0.99;
406
407 /* Set-up */
408 action = lttng_action_notify_create();
409 if (!action) {
410 fail("Setup error on action creation");
411 goto end;
412 }
413
414 /* Create a dummy, empty condition for later test */
415 dummy_invalid_condition = lttng_condition_buffer_usage_low_create();
416 if (!dummy_invalid_condition) {
417 fail("Setup error on condition creation");
418 goto end;
419 }
420
421 /* Create a valid dummy condition with a ratio of 0.5 */
422 dummy_condition = lttng_condition_buffer_usage_low_create();
423 if (!dummy_condition) {
424 fail("Setup error on dummy_condition creation");
425 goto end;
426
427 }
428 condition_status = lttng_condition_buffer_usage_set_threshold_ratio(
429 dummy_condition, 0.5);
430 if (condition_status != LTTNG_CONDITION_STATUS_OK) {
431 fail("Setup error on condition creation");
432 goto end;
433 }
434
435 condition_status = lttng_condition_buffer_usage_set_session_name(
436 dummy_condition, session_name);
437 if (condition_status != LTTNG_CONDITION_STATUS_OK) {
438 fail("Setup error on dummy_condition creation");
439 goto end;
440 }
441 condition_status = lttng_condition_buffer_usage_set_channel_name(
442 dummy_condition, channel_name);
443 if (condition_status != LTTNG_CONDITION_STATUS_OK) {
444 fail("Setup error on dummy_condition creation");
445 goto end;
446 }
447 condition_status = lttng_condition_buffer_usage_set_domain_type(
448 dummy_condition, domain_type);
449 if (condition_status != LTTNG_CONDITION_STATUS_OK) {
450 fail("Setup error on dummy_condition creation");
451 goto end;
452 }
453
454 /* Register a low condition with a ratio */
455 low_condition = lttng_condition_buffer_usage_low_create();
456 if (!low_condition) {
457 fail("Setup error on low_condition creation");
458 goto end;
459 }
460 condition_status = lttng_condition_buffer_usage_set_threshold_ratio(
461 low_condition, low_ratio);
462 if (condition_status != LTTNG_CONDITION_STATUS_OK) {
463 fail("Setup error on low_condition creation");
464 goto end;
465 }
466
467 condition_status = lttng_condition_buffer_usage_set_session_name(
468 low_condition, session_name);
469 if (condition_status != LTTNG_CONDITION_STATUS_OK) {
470 fail("Setup error on low_condition creation");
471 goto end;
472 }
473 condition_status = lttng_condition_buffer_usage_set_channel_name(
474 low_condition, channel_name);
475 if (condition_status != LTTNG_CONDITION_STATUS_OK) {
476 fail("Setup error on low_condition creation");
477 goto end;
478 }
479 condition_status = lttng_condition_buffer_usage_set_domain_type(
480 low_condition, domain_type);
481 if (condition_status != LTTNG_CONDITION_STATUS_OK) {
482 fail("Setup error on low_condition creation");
483 goto end;
484
485 }
486
487 /* Register a high condition with a ratio */
488 high_condition = lttng_condition_buffer_usage_high_create();
489 if (!high_condition) {
490 fail("Setup error on high_condition creation");
491 goto end;
492 }
493
494 condition_status = lttng_condition_buffer_usage_set_threshold_ratio(
495 high_condition, high_ratio);
496 if (condition_status != LTTNG_CONDITION_STATUS_OK) {
497 fail("Setup error on high_condition creation");
498 goto end;
499 }
500
501 condition_status = lttng_condition_buffer_usage_set_session_name(
502 high_condition, session_name);
503 if (condition_status != LTTNG_CONDITION_STATUS_OK) {
504 fail("Setup error on high_condition creation");
505 goto end;
506 }
507 condition_status = lttng_condition_buffer_usage_set_channel_name(
508 high_condition, channel_name);
509 if (condition_status != LTTNG_CONDITION_STATUS_OK) {
510 fail("Setup error on high_condition creation");
511 goto end;
512 }
513 condition_status = lttng_condition_buffer_usage_set_domain_type(
514 high_condition, domain_type);
515 if (condition_status != LTTNG_CONDITION_STATUS_OK) {
516 fail("Setup error on high_condition creation");
517 goto end;
518 }
519
520 /* Register the triggers for low and high condition */
521 trigger = lttng_trigger_create(low_condition, action);
522 if (!trigger) {
523 fail("Setup error on low trigger creation");
524 goto end;
525 }
526
527 ret = lttng_register_trigger(trigger);
528 if (ret) {
529 fail("Setup error on low trigger registration");
530 goto end;
531 }
532
533 lttng_trigger_destroy(trigger);
534 trigger = NULL;
535
536 trigger = lttng_trigger_create(high_condition, action);
537 if (!trigger) {
538 fail("Setup error on high trigger creation");
539 goto end;
540 }
541
542 ret = lttng_register_trigger(trigger);
543 if (ret) {
544 fail("Setup error on high trigger registration");
545 goto end;
546 }
547
548 /* Begin testing */
549 notification_channel = lttng_notification_channel_create(lttng_session_daemon_notification_endpoint);
550 ok(notification_channel, "Notification channel object creation");
551 if (!notification_channel) {
552 goto end;
553 }
554
555 /* Basic error path check */
556 nc_status = lttng_notification_channel_subscribe(NULL, NULL);
557 ok(nc_status == LTTNG_NOTIFICATION_CHANNEL_STATUS_INVALID, "Notification channel subscription is invalid: NULL, NULL");
558
559 nc_status = lttng_notification_channel_subscribe(notification_channel, NULL);
560 ok(nc_status == LTTNG_NOTIFICATION_CHANNEL_STATUS_INVALID, "Notification channel subscription is invalid: NON-NULL, NULL");
561
562 nc_status = lttng_notification_channel_subscribe(NULL, low_condition);
563 ok(nc_status == LTTNG_NOTIFICATION_CHANNEL_STATUS_INVALID, "Notification channel subscription is invalid: NULL, NON-NULL");
564
565 nc_status = lttng_notification_channel_subscribe(notification_channel, dummy_invalid_condition);
566 ok(nc_status == LTTNG_NOTIFICATION_CHANNEL_STATUS_INVALID, "Subscribing to an invalid condition");
567
568 nc_status = lttng_notification_channel_unsubscribe(notification_channel, dummy_invalid_condition);
569 ok(nc_status == LTTNG_NOTIFICATION_CHANNEL_STATUS_INVALID, "Unsubscribing to an invalid condition");
570
571 nc_status = lttng_notification_channel_unsubscribe(notification_channel, dummy_condition);
572 ok(nc_status == LTTNG_NOTIFICATION_CHANNEL_STATUS_UNKNOWN_CONDITION, "Unsubscribing to an valid unknown condition");
573
574 /* Subscribe a valid low condition */
575 nc_status = lttng_notification_channel_subscribe(notification_channel, low_condition);
576 ok(nc_status == LTTNG_NOTIFICATION_CHANNEL_STATUS_OK, "Subscribe to condition");
577
578 /* Subscribe a valid high condition */
579 nc_status = lttng_notification_channel_subscribe(notification_channel, high_condition);
580 ok(nc_status == LTTNG_NOTIFICATION_CHANNEL_STATUS_OK, "Subscribe to condition");
581
582 nc_status = lttng_notification_channel_subscribe(notification_channel, low_condition);
583 ok(nc_status == LTTNG_NOTIFICATION_CHANNEL_STATUS_ALREADY_SUBSCRIBED, "Subscribe to a condition for which subscription was already done");
584
585 nc_status = lttng_notification_channel_subscribe(notification_channel, high_condition);
586 ok(nc_status == LTTNG_NOTIFICATION_CHANNEL_STATUS_ALREADY_SUBSCRIBED, "Subscribe to a condition for which subscription was already done");
587
588 /* Wait for notification to happen */
589 stop_consumer(argv);
590 lttng_start_tracing(session_name);
591
592 /* Wait for high notification */
593 nc_status = lttng_notification_channel_get_next_notification(notification_channel, &notification);
594 ok(nc_status == LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
595 && notification
596 && lttng_condition_get_type(lttng_notification_get_condition(notification)) == LTTNG_CONDITION_TYPE_BUFFER_USAGE_HIGH,
597 "High notification received after intermediary communication");
598 lttng_notification_destroy(notification);
599 notification = NULL;
600
601 suspend_application();
602 lttng_stop_tracing_no_wait(session_name);
603 resume_consumer(argv);
604 wait_data_pending(session_name);
605
606 /*
607 * Test that communication still work even if there is notification
608 * waiting for consumption.
609 */
610
611 nc_status = lttng_notification_channel_unsubscribe(notification_channel, low_condition);
612 ok(nc_status == LTTNG_NOTIFICATION_CHANNEL_STATUS_OK, "Unsubscribe with pending notification");
613
614 nc_status = lttng_notification_channel_subscribe(notification_channel, low_condition);
615 ok(nc_status == LTTNG_NOTIFICATION_CHANNEL_STATUS_OK, "subscribe with pending notification");
616
617 nc_status = lttng_notification_channel_get_next_notification(notification_channel, &notification);
618 ok(nc_status == LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
619 && notification
620 && lttng_condition_get_type(lttng_notification_get_condition(notification)) == LTTNG_CONDITION_TYPE_BUFFER_USAGE_LOW,
621 "Low notification received after intermediary communication");
622 lttng_notification_destroy(notification);
623 notification = NULL;
624
625 /* Stop consumer to force a high notification */
626 stop_consumer(argv);
627 resume_application();
628 lttng_start_tracing(session_name);
629
630 nc_status = lttng_notification_channel_get_next_notification(notification_channel, &notification);
631 ok(nc_status == LTTNG_NOTIFICATION_CHANNEL_STATUS_OK && notification &&
632 lttng_condition_get_type(lttng_notification_get_condition(notification)) == LTTNG_CONDITION_TYPE_BUFFER_USAGE_HIGH,
633 "High notification received after intermediary communication");
634 lttng_notification_destroy(notification);
635 notification = NULL;
636
637 suspend_application();
638 lttng_stop_tracing_no_wait(session_name);
639 resume_consumer(argv);
640 wait_data_pending(session_name);
641
642 nc_status = lttng_notification_channel_get_next_notification(notification_channel, &notification);
643 ok(nc_status == LTTNG_NOTIFICATION_CHANNEL_STATUS_OK && notification &&
644 lttng_condition_get_type(lttng_notification_get_condition(notification)) == LTTNG_CONDITION_TYPE_BUFFER_USAGE_LOW,
645 "Low notification received after re-subscription");
646 lttng_notification_destroy(notification);
647 notification = NULL;
648
649 stop_consumer(argv);
650 resume_application();
651 /* Stop consumer to force a high notification */
652 lttng_start_tracing(session_name);
653
654 nc_status = lttng_notification_channel_get_next_notification(notification_channel, &notification);
655 ok(nc_status == LTTNG_NOTIFICATION_CHANNEL_STATUS_OK && notification &&
656 lttng_condition_get_type(lttng_notification_get_condition(notification)) == LTTNG_CONDITION_TYPE_BUFFER_USAGE_HIGH,
657 "High notification");
658 lttng_notification_destroy(notification);
659 notification = NULL;
660
661 /* Resume consumer to allow event consumption */
662 suspend_application();
663 lttng_stop_tracing_no_wait(session_name);
664 resume_consumer(argv);
665 wait_data_pending(session_name);
666
667 nc_status = lttng_notification_channel_unsubscribe(notification_channel, low_condition);
668 ok(nc_status == LTTNG_NOTIFICATION_CHANNEL_STATUS_OK, "Unsubscribe low condition with pending notification");
669 nc_status = lttng_notification_channel_unsubscribe(notification_channel, high_condition);
670 ok(nc_status == LTTNG_NOTIFICATION_CHANNEL_STATUS_OK, "Unsubscribe high condition with pending notification");
671
672 end:
673 lttng_notification_channel_destroy(notification_channel);
674 lttng_trigger_destroy(trigger);
675 lttng_action_destroy(action);
676 lttng_condition_destroy(low_condition);
677 lttng_condition_destroy(high_condition);
678 lttng_condition_destroy(dummy_invalid_condition);
679 lttng_condition_destroy(dummy_condition);
680 }
681
682 int main(int argc, const char *argv[])
683 {
684 const char *session_name = NULL;
685 const char *channel_name = NULL;
686 const char *domain_type_string = NULL;
687 enum lttng_domain_type domain_type = LTTNG_DOMAIN_NONE;
688
689 plan_tests(NUM_TESTS);
690
691 /* Argument 6 and upward are named pipe location for consumerd control */
692 named_pipe_args_start = 6;
693
694 if (argc < 7) {
695 fail("Missing parameter for tests to run %d", argc);
696 goto error;
697 }
698
699 nb_args = argc;
700
701 domain_type_string = argv[1];
702 session_name = argv[2];
703 channel_name = argv[3];
704 app_pid = (pid_t) atoi(argv[4]);
705 app_state_file = argv[5];
706
707 if (!strcmp("LTTNG_DOMAIN_UST", domain_type_string)) {
708 domain_type = LTTNG_DOMAIN_UST;
709 }
710 if (!strcmp("LTTNG_DOMAIN_KERNEL", domain_type_string)) {
711 domain_type = LTTNG_DOMAIN_KERNEL;
712 }
713 if (domain_type == LTTNG_DOMAIN_NONE) {
714 fail("Unknown domain type");
715 goto error;
716 }
717
718 diag("Test trigger for domain %s with buffer_usage_low condition", domain_type_string);
719 test_triggers_buffer_usage_condition(session_name, channel_name, domain_type, LTTNG_CONDITION_TYPE_BUFFER_USAGE_LOW);
720 diag("Test trigger for domain %s with buffer_usage_high condition", domain_type_string);
721 test_triggers_buffer_usage_condition(session_name, channel_name, domain_type, LTTNG_CONDITION_TYPE_BUFFER_USAGE_HIGH);
722
723 diag("Test notification channel api for domain %s", domain_type_string);
724 test_notification_channel(session_name, channel_name, domain_type, argv);
725 error:
726 return exit_status();
727 }
728
This page took 0.044 seconds and 4 git commands to generate.