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