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