Tests: Cleanup: extract duplicated code to `setup_buffer_usage_condition()`
[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 <poll.h>
25
26 #include <common/compat/errno.h>
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(void)
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 int setup_buffer_usage_condition(struct lttng_condition *condition,
400 const char *condition_name,
401 const char *session_name,
402 const char *channel_name,
403 const enum lttng_domain_type domain_type)
404 {
405 enum lttng_condition_status condition_status;
406 int ret = 0;
407
408 condition_status = lttng_condition_buffer_usage_set_session_name(
409 condition, session_name);
410 if (condition_status != LTTNG_CONDITION_STATUS_OK) {
411 fail("Failed to set session name on creation of condition `%s`",
412 condition_name);
413 ret = -1;
414 goto end;
415 }
416
417 condition_status = lttng_condition_buffer_usage_set_channel_name(
418 condition, channel_name);
419 if (condition_status != LTTNG_CONDITION_STATUS_OK) {
420 fail("Failed to set channel name on creation of condition `%s`",
421 condition_name);
422 ret = -1;
423 goto end;
424 }
425
426 condition_status = lttng_condition_buffer_usage_set_domain_type(
427 condition, domain_type);
428 if (condition_status != LTTNG_CONDITION_STATUS_OK) {
429 fail("Failed to set domain type on creation of condition `%s`",
430 condition_name);
431 ret = -1;
432 goto end;
433 }
434
435 end:
436 return ret;
437 }
438
439 static
440 void test_notification_channel(const char *session_name,
441 const char *channel_name,
442 const enum lttng_domain_type domain_type,
443 const char **argv)
444 {
445 int ret = 0;
446 enum lttng_condition_status condition_status;
447 enum lttng_notification_channel_status nc_status;
448
449 struct lttng_action *action = NULL;
450 struct lttng_notification *notification = NULL;
451 struct lttng_notification_channel *notification_channel = NULL;
452 struct lttng_trigger *trigger = NULL;
453
454 struct lttng_condition *low_condition = NULL;
455 struct lttng_condition *high_condition = NULL;
456 struct lttng_condition *dummy_invalid_condition = NULL;
457 struct lttng_condition *dummy_condition = NULL;
458
459 double low_ratio = 0.0;
460 double high_ratio = 0.90;
461
462 /* Set-up */
463 action = lttng_action_notify_create();
464 if (!action) {
465 fail("Setup error on action creation");
466 goto end;
467 }
468
469 /* Create a dummy, empty condition for later test */
470 dummy_invalid_condition = lttng_condition_buffer_usage_low_create();
471 if (!dummy_invalid_condition) {
472 fail("Setup error on condition creation");
473 goto end;
474 }
475
476 /* Create a valid dummy condition with a ratio of 0.5 */
477 dummy_condition = lttng_condition_buffer_usage_low_create();
478 if (!dummy_condition) {
479 fail("Setup error on dummy_condition creation");
480 goto end;
481
482 }
483 condition_status = lttng_condition_buffer_usage_set_threshold_ratio(
484 dummy_condition, 0.5);
485 if (condition_status != LTTNG_CONDITION_STATUS_OK) {
486 fail("Setup error on condition creation");
487 goto end;
488 }
489
490 ret = setup_buffer_usage_condition(dummy_condition, "dummy_condition",
491 session_name, channel_name, domain_type);
492 if (ret) {
493 fail("Setup error on dummy condition creation");
494 goto end;
495 }
496
497 /* Register a low condition with a ratio */
498 low_condition = lttng_condition_buffer_usage_low_create();
499 if (!low_condition) {
500 fail("Setup error on low_condition creation");
501 goto end;
502 }
503 condition_status = lttng_condition_buffer_usage_set_threshold_ratio(
504 low_condition, low_ratio);
505 if (condition_status != LTTNG_CONDITION_STATUS_OK) {
506 fail("Setup error on low_condition creation");
507 goto end;
508 }
509
510 ret = setup_buffer_usage_condition(low_condition, "low_condition",
511 session_name, channel_name, domain_type);
512 if (ret) {
513 fail("Setup error on low condition creation");
514 goto end;
515 }
516
517 /* Register a high condition with a ratio */
518 high_condition = lttng_condition_buffer_usage_high_create();
519 if (!high_condition) {
520 fail("Setup error on high_condition creation");
521 goto end;
522 }
523
524 condition_status = lttng_condition_buffer_usage_set_threshold_ratio(
525 high_condition, high_ratio);
526 if (condition_status != LTTNG_CONDITION_STATUS_OK) {
527 fail("Setup error on high_condition creation");
528 goto end;
529 }
530
531 ret = setup_buffer_usage_condition(high_condition, "high_condition",
532 session_name, channel_name, domain_type);
533 if (ret) {
534 fail("Setup error on high condition creation");
535 goto end;
536 }
537
538 /* Register the triggers for low and high condition */
539 trigger = lttng_trigger_create(low_condition, action);
540 if (!trigger) {
541 fail("Setup error on low trigger creation");
542 goto end;
543 }
544
545 ret = lttng_register_trigger(trigger);
546 if (ret) {
547 fail("Setup error on low trigger registration");
548 goto end;
549 }
550
551 lttng_trigger_destroy(trigger);
552 trigger = NULL;
553
554 trigger = lttng_trigger_create(high_condition, action);
555 if (!trigger) {
556 fail("Setup error on high trigger creation");
557 goto end;
558 }
559
560 ret = lttng_register_trigger(trigger);
561 if (ret) {
562 fail("Setup error on high trigger registration");
563 goto end;
564 }
565
566 /* Begin testing */
567 notification_channel = lttng_notification_channel_create(lttng_session_daemon_notification_endpoint);
568 ok(notification_channel, "Notification channel object creation");
569 if (!notification_channel) {
570 goto end;
571 }
572
573 /* Basic error path check */
574 nc_status = lttng_notification_channel_subscribe(NULL, NULL);
575 ok(nc_status == LTTNG_NOTIFICATION_CHANNEL_STATUS_INVALID, "Notification channel subscription is invalid: NULL, NULL");
576
577 nc_status = lttng_notification_channel_subscribe(notification_channel, NULL);
578 ok(nc_status == LTTNG_NOTIFICATION_CHANNEL_STATUS_INVALID, "Notification channel subscription is invalid: NON-NULL, NULL");
579
580 nc_status = lttng_notification_channel_subscribe(NULL, low_condition);
581 ok(nc_status == LTTNG_NOTIFICATION_CHANNEL_STATUS_INVALID, "Notification channel subscription is invalid: NULL, NON-NULL");
582
583 nc_status = lttng_notification_channel_subscribe(notification_channel, dummy_invalid_condition);
584 ok(nc_status == LTTNG_NOTIFICATION_CHANNEL_STATUS_INVALID, "Subscribing to an invalid condition");
585
586 nc_status = lttng_notification_channel_unsubscribe(notification_channel, dummy_invalid_condition);
587 ok(nc_status == LTTNG_NOTIFICATION_CHANNEL_STATUS_INVALID, "Unsubscribing from an invalid condition");
588
589 nc_status = lttng_notification_channel_unsubscribe(notification_channel, dummy_condition);
590 ok(nc_status == LTTNG_NOTIFICATION_CHANNEL_STATUS_UNKNOWN_CONDITION, "Unsubscribing from a valid unknown condition");
591
592 /* Subscribe a valid low condition */
593 nc_status = lttng_notification_channel_subscribe(notification_channel, low_condition);
594 ok(nc_status == LTTNG_NOTIFICATION_CHANNEL_STATUS_OK, "Subscribe to condition");
595
596 /* Subscribe a valid high condition */
597 nc_status = lttng_notification_channel_subscribe(notification_channel, high_condition);
598 ok(nc_status == LTTNG_NOTIFICATION_CHANNEL_STATUS_OK, "Subscribe to condition");
599
600 nc_status = lttng_notification_channel_subscribe(notification_channel, low_condition);
601 ok(nc_status == LTTNG_NOTIFICATION_CHANNEL_STATUS_ALREADY_SUBSCRIBED, "Subscribe to a condition for which subscription was already done");
602
603 nc_status = lttng_notification_channel_subscribe(notification_channel, high_condition);
604 ok(nc_status == LTTNG_NOTIFICATION_CHANNEL_STATUS_ALREADY_SUBSCRIBED, "Subscribe to a condition for which subscription was already done");
605
606 /* Wait for notification to happen */
607 stop_consumer(argv);
608 lttng_start_tracing(session_name);
609
610 /* Wait for high notification */
611 do {
612 nc_status = lttng_notification_channel_get_next_notification(notification_channel, &notification);
613 } while (nc_status == LTTNG_NOTIFICATION_CHANNEL_STATUS_INTERRUPTED);
614 ok(nc_status == LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
615 && notification
616 && lttng_condition_get_type(lttng_notification_get_condition(notification)) == LTTNG_CONDITION_TYPE_BUFFER_USAGE_HIGH,
617 "High notification received after intermediary communication");
618 lttng_notification_destroy(notification);
619 notification = NULL;
620
621 suspend_application();
622 lttng_stop_tracing_no_wait(session_name);
623 resume_consumer(argv);
624 wait_data_pending(session_name);
625
626 /*
627 * Test that communication still work even if there is notification
628 * waiting for consumption.
629 */
630
631 nc_status = lttng_notification_channel_unsubscribe(notification_channel, low_condition);
632 ok(nc_status == LTTNG_NOTIFICATION_CHANNEL_STATUS_OK, "Unsubscribe with pending notification");
633
634 nc_status = lttng_notification_channel_subscribe(notification_channel, low_condition);
635 ok(nc_status == LTTNG_NOTIFICATION_CHANNEL_STATUS_OK, "subscribe with pending notification");
636
637 do {
638 nc_status = lttng_notification_channel_get_next_notification(notification_channel, &notification);
639 } while (nc_status == LTTNG_NOTIFICATION_CHANNEL_STATUS_INTERRUPTED);
640 ok(nc_status == LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
641 && notification
642 && lttng_condition_get_type(lttng_notification_get_condition(notification)) == LTTNG_CONDITION_TYPE_BUFFER_USAGE_LOW,
643 "Low notification received after intermediary communication");
644 lttng_notification_destroy(notification);
645 notification = NULL;
646
647 /* Stop consumer to force a high notification */
648 stop_consumer(argv);
649 resume_application();
650 lttng_start_tracing(session_name);
651
652 do {
653 nc_status = lttng_notification_channel_get_next_notification(notification_channel, &notification);
654 } while (nc_status == LTTNG_NOTIFICATION_CHANNEL_STATUS_INTERRUPTED);
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 received after intermediary communication");
658 lttng_notification_destroy(notification);
659 notification = NULL;
660
661 suspend_application();
662 lttng_stop_tracing_no_wait(session_name);
663 resume_consumer(argv);
664 wait_data_pending(session_name);
665
666 do {
667 nc_status = lttng_notification_channel_get_next_notification(notification_channel, &notification);
668 } while (nc_status == LTTNG_NOTIFICATION_CHANNEL_STATUS_INTERRUPTED);
669 ok(nc_status == LTTNG_NOTIFICATION_CHANNEL_STATUS_OK && notification &&
670 lttng_condition_get_type(lttng_notification_get_condition(notification)) == LTTNG_CONDITION_TYPE_BUFFER_USAGE_LOW,
671 "Low notification received after re-subscription");
672 lttng_notification_destroy(notification);
673 notification = NULL;
674
675 stop_consumer(argv);
676 resume_application();
677 /* Stop consumer to force a high notification */
678 lttng_start_tracing(session_name);
679
680 do {
681 nc_status = lttng_notification_channel_get_next_notification(notification_channel, &notification);
682 } while (nc_status == LTTNG_NOTIFICATION_CHANNEL_STATUS_INTERRUPTED);
683 ok(nc_status == LTTNG_NOTIFICATION_CHANNEL_STATUS_OK && notification &&
684 lttng_condition_get_type(lttng_notification_get_condition(notification)) == LTTNG_CONDITION_TYPE_BUFFER_USAGE_HIGH,
685 "High notification");
686 lttng_notification_destroy(notification);
687 notification = NULL;
688
689 /* Resume consumer to allow event consumption */
690 suspend_application();
691 lttng_stop_tracing_no_wait(session_name);
692 resume_consumer(argv);
693 wait_data_pending(session_name);
694
695 nc_status = lttng_notification_channel_unsubscribe(notification_channel, low_condition);
696 ok(nc_status == LTTNG_NOTIFICATION_CHANNEL_STATUS_OK, "Unsubscribe low condition with pending notification");
697 nc_status = lttng_notification_channel_unsubscribe(notification_channel, high_condition);
698 ok(nc_status == LTTNG_NOTIFICATION_CHANNEL_STATUS_OK, "Unsubscribe high condition with pending notification");
699
700 end:
701 lttng_notification_channel_destroy(notification_channel);
702 lttng_trigger_destroy(trigger);
703 lttng_action_destroy(action);
704 lttng_condition_destroy(low_condition);
705 lttng_condition_destroy(high_condition);
706 lttng_condition_destroy(dummy_invalid_condition);
707 lttng_condition_destroy(dummy_condition);
708 }
709
710 int main(int argc, const char *argv[])
711 {
712 const char *session_name = NULL;
713 const char *channel_name = NULL;
714 const char *domain_type_string = NULL;
715 enum lttng_domain_type domain_type = LTTNG_DOMAIN_NONE;
716
717 plan_tests(NUM_TESTS);
718
719 /* Argument 6 and upward are named pipe location for consumerd control */
720 named_pipe_args_start = 6;
721
722 if (argc < 7) {
723 fail("Missing parameter for tests to run %d", argc);
724 goto error;
725 }
726
727 nb_args = argc;
728
729 domain_type_string = argv[1];
730 session_name = argv[2];
731 channel_name = argv[3];
732 app_pid = (pid_t) atoi(argv[4]);
733 app_state_file = argv[5];
734
735 if (!strcmp("LTTNG_DOMAIN_UST", domain_type_string)) {
736 domain_type = LTTNG_DOMAIN_UST;
737 }
738 if (!strcmp("LTTNG_DOMAIN_KERNEL", domain_type_string)) {
739 domain_type = LTTNG_DOMAIN_KERNEL;
740 }
741 if (domain_type == LTTNG_DOMAIN_NONE) {
742 fail("Unknown domain type");
743 goto error;
744 }
745
746 diag("Test trigger for domain %s with buffer_usage_low condition", domain_type_string);
747 test_triggers_buffer_usage_condition(session_name, channel_name, domain_type, LTTNG_CONDITION_TYPE_BUFFER_USAGE_LOW);
748 diag("Test trigger for domain %s with buffer_usage_high condition", domain_type_string);
749 test_triggers_buffer_usage_condition(session_name, channel_name, domain_type, LTTNG_CONDITION_TYPE_BUFFER_USAGE_HIGH);
750
751 diag("Test notification channel api for domain %s", domain_type_string);
752 test_notification_channel(session_name, channel_name, domain_type, argv);
753 error:
754 return exit_status();
755 }
756
This page took 0.04489 seconds and 4 git commands to generate.