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