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