| 1 | /* |
| 2 | * Copyright 2017 - Philippe Proulx <pproulx@efficios.com> |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or modify |
| 5 | * it under the terms of the GNU General Public License as published by |
| 6 | * the Free Software Foundation; under version 2 of the License. |
| 7 | * |
| 8 | * This program is distributed in the hope that it will be useful, |
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 | * GNU General Public License for more details. |
| 12 | * |
| 13 | * You should have received a copy of the GNU General Public License along |
| 14 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 15 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 16 | */ |
| 17 | |
| 18 | #include <stdio.h> |
| 19 | #include <stdlib.h> |
| 20 | #include <stdint.h> |
| 21 | #include <stdbool.h> |
| 22 | #include <inttypes.h> |
| 23 | #include <string.h> |
| 24 | #include <assert.h> |
| 25 | #include <babeltrace/babeltrace.h> |
| 26 | #include <glib.h> |
| 27 | |
| 28 | #include "tap/tap.h" |
| 29 | |
| 30 | #define NR_TESTS 12 |
| 31 | |
| 32 | enum test { |
| 33 | TEST_NO_TS, |
| 34 | TEST_NO_UPSTREAM_CONNECTION, |
| 35 | TEST_SIMPLE_4_PORTS, |
| 36 | TEST_4_PORTS_WITH_RETRIES, |
| 37 | TEST_SINGLE_END_THEN_MULTIPLE_FULL, |
| 38 | TEST_SINGLE_AGAIN_END_THEN_MULTIPLE_FULL, |
| 39 | }; |
| 40 | |
| 41 | enum test_event_type { |
| 42 | TEST_EV_TYPE_NOTIF_UNEXPECTED, |
| 43 | TEST_EV_TYPE_NOTIF_EVENT, |
| 44 | TEST_EV_TYPE_NOTIF_INACTIVITY, |
| 45 | TEST_EV_TYPE_NOTIF_PACKET_BEGIN, |
| 46 | TEST_EV_TYPE_NOTIF_PACKET_END, |
| 47 | TEST_EV_TYPE_NOTIF_STREAM_BEGIN, |
| 48 | TEST_EV_TYPE_NOTIF_STREAM_END, |
| 49 | TEST_EV_TYPE_AGAIN, |
| 50 | TEST_EV_TYPE_END, |
| 51 | TEST_EV_TYPE_SENTINEL, |
| 52 | }; |
| 53 | |
| 54 | struct test_event { |
| 55 | enum test_event_type type; |
| 56 | int64_t ts_ns; |
| 57 | }; |
| 58 | |
| 59 | struct source_muxer_sink { |
| 60 | struct bt_component *source; |
| 61 | struct bt_component *muxer; |
| 62 | struct bt_component *sink; |
| 63 | }; |
| 64 | |
| 65 | struct graph_listener_data { |
| 66 | struct bt_graph *graph; |
| 67 | struct bt_component *source; |
| 68 | struct bt_component *muxer; |
| 69 | struct bt_component *sink; |
| 70 | }; |
| 71 | |
| 72 | static bool debug = false; |
| 73 | static enum test current_test; |
| 74 | static GArray *test_events; |
| 75 | static struct bt_clock_class_priority_map *src_cc_prio_map; |
| 76 | static struct bt_clock_class_priority_map *src_empty_cc_prio_map; |
| 77 | static struct bt_clock_class *src_clock_class; |
| 78 | static struct bt_stream_class *src_stream_class; |
| 79 | static struct bt_event_class *src_event_class; |
| 80 | static struct bt_packet *src_packet0; |
| 81 | static struct bt_packet *src_packet1; |
| 82 | static struct bt_packet *src_packet2; |
| 83 | static struct bt_packet *src_packet3; |
| 84 | |
| 85 | enum { |
| 86 | SEQ_END = -1, |
| 87 | SEQ_AGAIN = -2, |
| 88 | SEQ_PACKET_BEGIN = -3, |
| 89 | SEQ_PACKET_END = -4, |
| 90 | SEQ_STREAM_BEGIN = -5, |
| 91 | SEQ_STREAM_END = -6, |
| 92 | }; |
| 93 | |
| 94 | struct src_iter_user_data { |
| 95 | size_t iter_index; |
| 96 | int64_t *seq; |
| 97 | size_t at; |
| 98 | struct bt_packet *packet; |
| 99 | }; |
| 100 | |
| 101 | struct sink_user_data { |
| 102 | struct bt_notification_iterator *notif_iter; |
| 103 | }; |
| 104 | |
| 105 | static int64_t seq1[] = { |
| 106 | SEQ_STREAM_BEGIN, SEQ_PACKET_BEGIN, 24, 53, 97, 105, 119, 210, |
| 107 | 222, 240, 292, 317, 353, 407, 433, 473, 487, 504, 572, 615, 708, |
| 108 | 766, 850, 852, 931, 951, 956, 996, SEQ_PACKET_END, |
| 109 | SEQ_STREAM_END, SEQ_END, |
| 110 | }; |
| 111 | |
| 112 | static int64_t seq2[] = { |
| 113 | SEQ_STREAM_BEGIN, SEQ_PACKET_BEGIN, 51, 59, 68, 77, 91, 121, |
| 114 | 139, 170, 179, 266, 352, 454, 478, 631, 644, 668, 714, 744, 750, |
| 115 | 778, 790, 836, SEQ_PACKET_END, SEQ_STREAM_END, SEQ_END, |
| 116 | }; |
| 117 | |
| 118 | static int64_t seq3[] = { |
| 119 | SEQ_STREAM_BEGIN, SEQ_PACKET_BEGIN, 8, 71, 209, 254, 298, 320, |
| 120 | 350, 393, 419, 624, 651, 678, 717, 731, 733, 788, 819, 820, 857, |
| 121 | 892, 903, 944, 998, SEQ_PACKET_END, SEQ_STREAM_END, SEQ_END, |
| 122 | }; |
| 123 | |
| 124 | static int64_t seq4[] = { |
| 125 | SEQ_STREAM_BEGIN, SEQ_PACKET_BEGIN, 41, 56, 120, 138, 154, 228, |
| 126 | 471, 479, 481, 525, 591, 605, 612, 618, 632, 670, 696, 825, 863, |
| 127 | 867, 871, 884, 953, 985, 999, SEQ_PACKET_END, SEQ_STREAM_END, |
| 128 | SEQ_END, |
| 129 | }; |
| 130 | |
| 131 | static int64_t seq1_with_again[] = { |
| 132 | SEQ_STREAM_BEGIN, SEQ_PACKET_BEGIN, 24, 53, 97, 105, 119, 210, |
| 133 | SEQ_AGAIN, 222, 240, 292, 317, 353, 407, 433, 473, 487, 504, |
| 134 | 572, 615, 708, 766, 850, 852, 931, 951, 956, 996, |
| 135 | SEQ_PACKET_END, SEQ_STREAM_END, SEQ_END, |
| 136 | }; |
| 137 | |
| 138 | static int64_t seq2_with_again[] = { |
| 139 | SEQ_STREAM_BEGIN, SEQ_PACKET_BEGIN, 51, 59, 68, 77, 91, 121, |
| 140 | 139, 170, 179, 266, 352, 454, 478, 631, 644, 668, 714, 744, 750, |
| 141 | 778, 790, 836, SEQ_AGAIN, SEQ_PACKET_END, SEQ_STREAM_END, |
| 142 | SEQ_END, |
| 143 | }; |
| 144 | |
| 145 | static int64_t seq3_with_again[] = { |
| 146 | SEQ_STREAM_BEGIN, SEQ_PACKET_BEGIN, 8, 71, 209, 254, 298, 320, |
| 147 | 350, 393, 419, 624, 651, SEQ_AGAIN, 678, 717, 731, 733, 788, |
| 148 | 819, 820, 857, 892, 903, 944, 998, SEQ_PACKET_END, |
| 149 | SEQ_STREAM_END, SEQ_END, |
| 150 | }; |
| 151 | |
| 152 | static int64_t seq4_with_again[] = { |
| 153 | SEQ_AGAIN, SEQ_STREAM_BEGIN, SEQ_PACKET_BEGIN, 41, 56, 120, 138, |
| 154 | 154, 228, 471, 479, 481, 525, 591, 605, 612, 618, 632, 670, 696, |
| 155 | 825, 863, 867, 871, 884, 953, 985, 999, SEQ_PACKET_END, |
| 156 | SEQ_STREAM_END, SEQ_END, |
| 157 | }; |
| 158 | |
| 159 | static int64_t seq5[] = { |
| 160 | SEQ_STREAM_BEGIN, SEQ_PACKET_BEGIN, 1, 4, 189, 1001, |
| 161 | SEQ_PACKET_END, SEQ_STREAM_END, SEQ_END, |
| 162 | }; |
| 163 | |
| 164 | static |
| 165 | void clear_test_events(void) |
| 166 | { |
| 167 | g_array_set_size(test_events, 0); |
| 168 | } |
| 169 | |
| 170 | static |
| 171 | void print_test_event(FILE *fp, const struct test_event *event) |
| 172 | { |
| 173 | fprintf(fp, "{ type = "); |
| 174 | |
| 175 | switch (event->type) { |
| 176 | case TEST_EV_TYPE_NOTIF_UNEXPECTED: |
| 177 | fprintf(fp, "TEST_EV_TYPE_NOTIF_UNEXPECTED"); |
| 178 | break; |
| 179 | case TEST_EV_TYPE_NOTIF_EVENT: |
| 180 | fprintf(fp, "TEST_EV_TYPE_NOTIF_EVENT"); |
| 181 | break; |
| 182 | case TEST_EV_TYPE_NOTIF_INACTIVITY: |
| 183 | fprintf(fp, "TEST_EV_TYPE_NOTIF_INACTIVITY"); |
| 184 | break; |
| 185 | case TEST_EV_TYPE_NOTIF_PACKET_BEGIN: |
| 186 | fprintf(fp, "TEST_EV_TYPE_NOTIF_PACKET_BEGIN"); |
| 187 | break; |
| 188 | case TEST_EV_TYPE_NOTIF_PACKET_END: |
| 189 | fprintf(fp, "TEST_EV_TYPE_NOTIF_PACKET_END"); |
| 190 | break; |
| 191 | case TEST_EV_TYPE_NOTIF_STREAM_BEGIN: |
| 192 | fprintf(fp, "TEST_EV_TYPE_NOTIF_STREAM_BEGIN"); |
| 193 | break; |
| 194 | case TEST_EV_TYPE_NOTIF_STREAM_END: |
| 195 | fprintf(fp, "TEST_EV_TYPE_NOTIF_STREAM_END"); |
| 196 | break; |
| 197 | case TEST_EV_TYPE_AGAIN: |
| 198 | fprintf(fp, "TEST_EV_TYPE_AGAIN"); |
| 199 | break; |
| 200 | case TEST_EV_TYPE_END: |
| 201 | fprintf(fp, "TEST_EV_TYPE_END"); |
| 202 | break; |
| 203 | case TEST_EV_TYPE_SENTINEL: |
| 204 | fprintf(fp, "TEST_EV_TYPE_SENTINEL"); |
| 205 | break; |
| 206 | default: |
| 207 | fprintf(fp, "(UNKNOWN)"); |
| 208 | break; |
| 209 | } |
| 210 | |
| 211 | switch (event->type) { |
| 212 | case TEST_EV_TYPE_NOTIF_EVENT: |
| 213 | case TEST_EV_TYPE_NOTIF_INACTIVITY: |
| 214 | fprintf(fp, ", ts-ns = %" PRId64, event->ts_ns); |
| 215 | default: |
| 216 | break; |
| 217 | } |
| 218 | |
| 219 | fprintf(fp, " }"); |
| 220 | } |
| 221 | |
| 222 | static |
| 223 | void append_test_event(struct test_event *event) |
| 224 | { |
| 225 | g_array_append_val(test_events, *event); |
| 226 | } |
| 227 | |
| 228 | static |
| 229 | bool compare_single_test_events(const struct test_event *ev_a, |
| 230 | const struct test_event *ev_b) |
| 231 | { |
| 232 | if (debug) { |
| 233 | fprintf(stderr, ":: Comparing test events: "); |
| 234 | print_test_event(stderr, ev_a); |
| 235 | fprintf(stderr, " vs. "); |
| 236 | print_test_event(stderr, ev_b); |
| 237 | fprintf(stderr, "\n"); |
| 238 | } |
| 239 | |
| 240 | if (ev_a->type != ev_b->type) { |
| 241 | return false; |
| 242 | } |
| 243 | |
| 244 | switch (ev_a->type) { |
| 245 | case TEST_EV_TYPE_NOTIF_EVENT: |
| 246 | case TEST_EV_TYPE_NOTIF_INACTIVITY: |
| 247 | if (ev_a->ts_ns != ev_b->ts_ns) { |
| 248 | return false; |
| 249 | } |
| 250 | break; |
| 251 | default: |
| 252 | break; |
| 253 | } |
| 254 | |
| 255 | return true; |
| 256 | } |
| 257 | |
| 258 | static |
| 259 | bool compare_test_events(const struct test_event *expected_events) |
| 260 | { |
| 261 | const struct test_event *expected_event = expected_events; |
| 262 | size_t i = 0; |
| 263 | |
| 264 | assert(expected_events); |
| 265 | |
| 266 | while (true) { |
| 267 | const struct test_event *event; |
| 268 | |
| 269 | if (expected_event->type == TEST_EV_TYPE_SENTINEL) { |
| 270 | break; |
| 271 | } |
| 272 | |
| 273 | if (i >= test_events->len) { |
| 274 | return false; |
| 275 | } |
| 276 | |
| 277 | event = &g_array_index(test_events, struct test_event, i); |
| 278 | |
| 279 | if (!compare_single_test_events(event, expected_event)) { |
| 280 | return false; |
| 281 | } |
| 282 | |
| 283 | i++; |
| 284 | expected_event++; |
| 285 | } |
| 286 | |
| 287 | if (i != test_events->len) { |
| 288 | if (debug) { |
| 289 | fprintf(stderr, ":: Length mismatch\n"); |
| 290 | } |
| 291 | |
| 292 | return false; |
| 293 | } |
| 294 | |
| 295 | return true; |
| 296 | } |
| 297 | |
| 298 | static |
| 299 | void init_static_data(void) |
| 300 | { |
| 301 | int ret; |
| 302 | struct bt_trace *trace; |
| 303 | struct bt_stream *stream; |
| 304 | struct bt_field_type *empty_struct_ft; |
| 305 | |
| 306 | /* Test events */ |
| 307 | test_events = g_array_new(FALSE, TRUE, sizeof(struct test_event)); |
| 308 | assert(test_events); |
| 309 | |
| 310 | /* Metadata */ |
| 311 | empty_struct_ft = bt_field_type_structure_create(); |
| 312 | assert(empty_struct_ft); |
| 313 | trace = bt_trace_create(); |
| 314 | assert(trace); |
| 315 | ret = bt_trace_set_native_byte_order(trace, |
| 316 | BT_BYTE_ORDER_LITTLE_ENDIAN); |
| 317 | assert(ret == 0); |
| 318 | ret = bt_trace_set_packet_header_type(trace, empty_struct_ft); |
| 319 | assert(ret == 0); |
| 320 | src_clock_class = bt_clock_class_create("my-clock", 1000000000); |
| 321 | assert(src_clock_class); |
| 322 | ret = bt_clock_class_set_is_absolute(src_clock_class, 1); |
| 323 | assert(ret == 0); |
| 324 | ret = bt_trace_add_clock_class(trace, src_clock_class); |
| 325 | assert(ret == 0); |
| 326 | src_empty_cc_prio_map = bt_clock_class_priority_map_create(); |
| 327 | assert(src_empty_cc_prio_map); |
| 328 | src_cc_prio_map = bt_clock_class_priority_map_create(); |
| 329 | assert(src_cc_prio_map); |
| 330 | ret = bt_clock_class_priority_map_add_clock_class(src_cc_prio_map, |
| 331 | src_clock_class, 0); |
| 332 | assert(ret == 0); |
| 333 | src_stream_class = bt_stream_class_create("my-stream-class"); |
| 334 | assert(src_stream_class); |
| 335 | ret = bt_stream_class_set_packet_context_type(src_stream_class, |
| 336 | empty_struct_ft); |
| 337 | assert(ret == 0); |
| 338 | ret = bt_stream_class_set_event_header_type(src_stream_class, |
| 339 | empty_struct_ft); |
| 340 | assert(ret == 0); |
| 341 | ret = bt_stream_class_set_event_context_type(src_stream_class, |
| 342 | empty_struct_ft); |
| 343 | assert(ret == 0); |
| 344 | src_event_class = bt_event_class_create("my-event-class"); |
| 345 | ret = bt_event_class_set_context_type(src_event_class, |
| 346 | empty_struct_ft); |
| 347 | assert(ret == 0); |
| 348 | ret = bt_event_class_set_context_type(src_event_class, |
| 349 | empty_struct_ft); |
| 350 | assert(ret == 0); |
| 351 | ret = bt_stream_class_add_event_class(src_stream_class, |
| 352 | src_event_class); |
| 353 | assert(ret == 0); |
| 354 | ret = bt_trace_add_stream_class(trace, src_stream_class); |
| 355 | assert(ret == 0); |
| 356 | stream = bt_stream_create(src_stream_class, "stream0"); |
| 357 | assert(stream); |
| 358 | src_packet0 = bt_packet_create(stream); |
| 359 | assert(src_packet0); |
| 360 | bt_put(stream); |
| 361 | stream = bt_stream_create(src_stream_class, "stream1"); |
| 362 | assert(stream); |
| 363 | src_packet1 = bt_packet_create(stream); |
| 364 | assert(src_packet0); |
| 365 | bt_put(stream); |
| 366 | stream = bt_stream_create(src_stream_class, "stream2"); |
| 367 | assert(stream); |
| 368 | src_packet2 = bt_packet_create(stream); |
| 369 | assert(src_packet0); |
| 370 | bt_put(stream); |
| 371 | stream = bt_stream_create(src_stream_class, "stream3"); |
| 372 | assert(stream); |
| 373 | src_packet3 = bt_packet_create(stream); |
| 374 | assert(src_packet0); |
| 375 | bt_put(stream); |
| 376 | |
| 377 | bt_put(trace); |
| 378 | bt_put(empty_struct_ft); |
| 379 | } |
| 380 | |
| 381 | static |
| 382 | void fini_static_data(void) |
| 383 | { |
| 384 | /* Test events */ |
| 385 | g_array_free(test_events, TRUE); |
| 386 | |
| 387 | /* Metadata */ |
| 388 | bt_put(src_empty_cc_prio_map); |
| 389 | bt_put(src_cc_prio_map); |
| 390 | bt_put(src_clock_class); |
| 391 | bt_put(src_stream_class); |
| 392 | bt_put(src_event_class); |
| 393 | bt_put(src_packet0); |
| 394 | bt_put(src_packet1); |
| 395 | bt_put(src_packet2); |
| 396 | bt_put(src_packet3); |
| 397 | } |
| 398 | |
| 399 | static |
| 400 | void src_iter_finalize( |
| 401 | struct bt_private_connection_private_notification_iterator *private_notification_iterator) |
| 402 | { |
| 403 | struct src_iter_user_data *user_data = |
| 404 | bt_private_connection_private_notification_iterator_get_user_data( |
| 405 | private_notification_iterator); |
| 406 | |
| 407 | if (user_data) { |
| 408 | g_free(user_data); |
| 409 | } |
| 410 | } |
| 411 | |
| 412 | static |
| 413 | enum bt_notification_iterator_status src_iter_init( |
| 414 | struct bt_private_connection_private_notification_iterator *priv_notif_iter, |
| 415 | struct bt_private_port *private_port) |
| 416 | { |
| 417 | struct src_iter_user_data *user_data = |
| 418 | g_new0(struct src_iter_user_data, 1); |
| 419 | struct bt_port *port = bt_port_from_private(private_port); |
| 420 | const char *port_name; |
| 421 | int ret; |
| 422 | |
| 423 | assert(user_data); |
| 424 | assert(port); |
| 425 | ret = bt_private_connection_private_notification_iterator_set_user_data(priv_notif_iter, |
| 426 | user_data); |
| 427 | assert(ret == 0); |
| 428 | port_name = bt_port_get_name(port); |
| 429 | assert(port_name); |
| 430 | user_data->iter_index = port_name[3] - '0'; |
| 431 | bt_put(port); |
| 432 | |
| 433 | switch (user_data->iter_index) { |
| 434 | case 0: |
| 435 | user_data->packet = src_packet0; |
| 436 | break; |
| 437 | case 1: |
| 438 | user_data->packet = src_packet1; |
| 439 | break; |
| 440 | case 2: |
| 441 | user_data->packet = src_packet2; |
| 442 | break; |
| 443 | case 3: |
| 444 | user_data->packet = src_packet3; |
| 445 | break; |
| 446 | default: |
| 447 | abort(); |
| 448 | } |
| 449 | |
| 450 | switch (current_test) { |
| 451 | case TEST_NO_TS: |
| 452 | if (user_data->iter_index == 1) { |
| 453 | user_data->seq = seq5; |
| 454 | } |
| 455 | break; |
| 456 | case TEST_SIMPLE_4_PORTS: |
| 457 | if (user_data->iter_index == 0) { |
| 458 | user_data->seq = seq1; |
| 459 | } else if (user_data->iter_index == 1) { |
| 460 | user_data->seq = seq2; |
| 461 | } else if (user_data->iter_index == 2) { |
| 462 | user_data->seq = seq3; |
| 463 | } else { |
| 464 | user_data->seq = seq4; |
| 465 | } |
| 466 | break; |
| 467 | case TEST_4_PORTS_WITH_RETRIES: |
| 468 | if (user_data->iter_index == 0) { |
| 469 | user_data->seq = seq1_with_again; |
| 470 | } else if (user_data->iter_index == 1) { |
| 471 | user_data->seq = seq2_with_again; |
| 472 | } else if (user_data->iter_index == 2) { |
| 473 | user_data->seq = seq3_with_again; |
| 474 | } else { |
| 475 | user_data->seq = seq4_with_again; |
| 476 | } |
| 477 | break; |
| 478 | case TEST_SINGLE_END_THEN_MULTIPLE_FULL: |
| 479 | case TEST_SINGLE_AGAIN_END_THEN_MULTIPLE_FULL: |
| 480 | if (user_data->iter_index == 0) { |
| 481 | /* Ignore: this iterator only returns END */ |
| 482 | } else if (user_data->iter_index == 1) { |
| 483 | user_data->seq = seq2; |
| 484 | } else { |
| 485 | user_data->seq = seq3; |
| 486 | } |
| 487 | break; |
| 488 | default: |
| 489 | abort(); |
| 490 | } |
| 491 | |
| 492 | return BT_NOTIFICATION_ITERATOR_STATUS_OK; |
| 493 | } |
| 494 | |
| 495 | static |
| 496 | struct bt_event *src_create_event(struct bt_packet *packet, |
| 497 | int64_t ts_ns) |
| 498 | { |
| 499 | struct bt_event *event = bt_event_create(src_event_class); |
| 500 | int ret; |
| 501 | |
| 502 | assert(event); |
| 503 | ret = bt_event_set_packet(event, packet); |
| 504 | assert(ret == 0); |
| 505 | |
| 506 | if (ts_ns != -1) { |
| 507 | struct bt_clock_value *clock_value; |
| 508 | |
| 509 | clock_value = bt_clock_value_create(src_clock_class, |
| 510 | (uint64_t) ts_ns); |
| 511 | assert(clock_value); |
| 512 | ret = bt_event_set_clock_value(event, clock_value); |
| 513 | assert(ret == 0); |
| 514 | bt_put(clock_value); |
| 515 | } |
| 516 | |
| 517 | return event; |
| 518 | } |
| 519 | |
| 520 | static |
| 521 | struct bt_notification_iterator_next_method_return src_iter_next_seq( |
| 522 | struct src_iter_user_data *user_data) |
| 523 | { |
| 524 | struct bt_notification_iterator_next_method_return next_return = { |
| 525 | .status = BT_NOTIFICATION_ITERATOR_STATUS_OK, |
| 526 | }; |
| 527 | int64_t cur_ts_ns; |
| 528 | struct bt_stream *stream; |
| 529 | |
| 530 | assert(user_data->seq); |
| 531 | cur_ts_ns = user_data->seq[user_data->at]; |
| 532 | |
| 533 | switch (cur_ts_ns) { |
| 534 | case SEQ_END: |
| 535 | next_return.status = |
| 536 | BT_NOTIFICATION_ITERATOR_STATUS_END; |
| 537 | break; |
| 538 | case SEQ_AGAIN: |
| 539 | next_return.status = |
| 540 | BT_NOTIFICATION_ITERATOR_STATUS_AGAIN; |
| 541 | break; |
| 542 | case SEQ_PACKET_BEGIN: |
| 543 | next_return.notification = |
| 544 | bt_notification_packet_begin_create(user_data->packet); |
| 545 | assert(next_return.notification); |
| 546 | break; |
| 547 | case SEQ_PACKET_END: |
| 548 | next_return.notification = |
| 549 | bt_notification_packet_end_create(user_data->packet); |
| 550 | assert(next_return.notification); |
| 551 | break; |
| 552 | case SEQ_STREAM_BEGIN: |
| 553 | stream = bt_packet_get_stream(user_data->packet); |
| 554 | next_return.notification = |
| 555 | bt_notification_stream_begin_create(stream); |
| 556 | assert(next_return.notification); |
| 557 | bt_put(stream); |
| 558 | break; |
| 559 | case SEQ_STREAM_END: |
| 560 | stream = bt_packet_get_stream(user_data->packet); |
| 561 | next_return.notification = |
| 562 | bt_notification_stream_end_create(stream); |
| 563 | assert(next_return.notification); |
| 564 | bt_put(stream); |
| 565 | break; |
| 566 | default: |
| 567 | { |
| 568 | struct bt_event *event = src_create_event( |
| 569 | user_data->packet, cur_ts_ns); |
| 570 | |
| 571 | assert(event); |
| 572 | next_return.notification = bt_notification_event_create(event, |
| 573 | src_cc_prio_map); |
| 574 | bt_put(event); |
| 575 | assert(next_return.notification); |
| 576 | break; |
| 577 | } |
| 578 | } |
| 579 | |
| 580 | if (next_return.status != BT_NOTIFICATION_ITERATOR_STATUS_END) { |
| 581 | user_data->at++; |
| 582 | } |
| 583 | |
| 584 | return next_return; |
| 585 | } |
| 586 | |
| 587 | static |
| 588 | struct bt_notification_iterator_next_method_return src_iter_next( |
| 589 | struct bt_private_connection_private_notification_iterator *priv_iterator) |
| 590 | { |
| 591 | struct bt_notification_iterator_next_method_return next_return = { |
| 592 | .notification = NULL, |
| 593 | .status = BT_NOTIFICATION_ITERATOR_STATUS_OK, |
| 594 | }; |
| 595 | struct src_iter_user_data *user_data = |
| 596 | bt_private_connection_private_notification_iterator_get_user_data(priv_iterator); |
| 597 | struct bt_private_component *private_component = |
| 598 | bt_private_connection_private_notification_iterator_get_private_component(priv_iterator); |
| 599 | struct bt_stream *stream; |
| 600 | int ret; |
| 601 | |
| 602 | assert(user_data); |
| 603 | assert(private_component); |
| 604 | |
| 605 | switch (current_test) { |
| 606 | case TEST_NO_TS: |
| 607 | if (user_data->iter_index == 0) { |
| 608 | if (user_data->at == 0) { |
| 609 | stream = bt_packet_get_stream(user_data->packet); |
| 610 | next_return.notification = |
| 611 | bt_notification_stream_begin_create( |
| 612 | stream); |
| 613 | bt_put(stream); |
| 614 | assert(next_return.notification); |
| 615 | } else if (user_data->at == 1) { |
| 616 | next_return.notification = |
| 617 | bt_notification_packet_begin_create( |
| 618 | user_data->packet); |
| 619 | assert(next_return.notification); |
| 620 | } else if (user_data->at < 7) { |
| 621 | struct bt_event *event = src_create_event( |
| 622 | user_data->packet, -1); |
| 623 | |
| 624 | assert(event); |
| 625 | next_return.notification = |
| 626 | bt_notification_event_create(event, |
| 627 | src_empty_cc_prio_map); |
| 628 | assert(next_return.notification); |
| 629 | bt_put(event); |
| 630 | } else if (user_data->at == 7) { |
| 631 | next_return.notification = |
| 632 | bt_notification_packet_end_create( |
| 633 | user_data->packet); |
| 634 | assert(next_return.notification); |
| 635 | } else if (user_data->at == 8) { |
| 636 | stream = bt_packet_get_stream(user_data->packet); |
| 637 | next_return.notification = |
| 638 | bt_notification_stream_end_create( |
| 639 | stream); |
| 640 | bt_put(stream); |
| 641 | assert(next_return.notification); |
| 642 | } else { |
| 643 | next_return.status = |
| 644 | BT_NOTIFICATION_ITERATOR_STATUS_END; |
| 645 | } |
| 646 | |
| 647 | user_data->at++; |
| 648 | } else { |
| 649 | next_return = src_iter_next_seq(user_data); |
| 650 | } |
| 651 | break; |
| 652 | case TEST_SIMPLE_4_PORTS: |
| 653 | case TEST_4_PORTS_WITH_RETRIES: |
| 654 | next_return = src_iter_next_seq(user_data); |
| 655 | break; |
| 656 | case TEST_SINGLE_END_THEN_MULTIPLE_FULL: |
| 657 | if (user_data->iter_index == 0) { |
| 658 | ret = bt_private_component_source_add_output_private_port( |
| 659 | private_component, "out1", NULL, NULL); |
| 660 | assert(ret == 0); |
| 661 | ret = bt_private_component_source_add_output_private_port( |
| 662 | private_component, "out2", NULL, NULL); |
| 663 | assert(ret == 0); |
| 664 | next_return.status = BT_NOTIFICATION_ITERATOR_STATUS_END; |
| 665 | } else { |
| 666 | next_return = src_iter_next_seq(user_data); |
| 667 | } |
| 668 | break; |
| 669 | case TEST_SINGLE_AGAIN_END_THEN_MULTIPLE_FULL: |
| 670 | if (user_data->iter_index == 0) { |
| 671 | if (user_data->at == 0) { |
| 672 | next_return.status = BT_NOTIFICATION_ITERATOR_STATUS_AGAIN; |
| 673 | user_data->at++; |
| 674 | } else { |
| 675 | ret = bt_private_component_source_add_output_private_port( |
| 676 | private_component, "out1", NULL, NULL); |
| 677 | assert(ret == 0); |
| 678 | ret = bt_private_component_source_add_output_private_port( |
| 679 | private_component, "out2", NULL, NULL); |
| 680 | assert(ret == 0); |
| 681 | next_return.status = BT_NOTIFICATION_ITERATOR_STATUS_END; |
| 682 | } |
| 683 | } else { |
| 684 | next_return = src_iter_next_seq(user_data); |
| 685 | } |
| 686 | break; |
| 687 | default: |
| 688 | abort(); |
| 689 | } |
| 690 | |
| 691 | bt_put(private_component); |
| 692 | return next_return; |
| 693 | } |
| 694 | |
| 695 | static |
| 696 | enum bt_component_status src_init( |
| 697 | struct bt_private_component *private_component, |
| 698 | struct bt_value *params, void *init_method_data) |
| 699 | { |
| 700 | int ret; |
| 701 | size_t nb_ports; |
| 702 | |
| 703 | switch (current_test) { |
| 704 | case TEST_NO_TS: |
| 705 | nb_ports = 2; |
| 706 | break; |
| 707 | case TEST_SINGLE_END_THEN_MULTIPLE_FULL: |
| 708 | case TEST_SINGLE_AGAIN_END_THEN_MULTIPLE_FULL: |
| 709 | nb_ports = 1; |
| 710 | break; |
| 711 | default: |
| 712 | nb_ports = 4; |
| 713 | break; |
| 714 | } |
| 715 | |
| 716 | if (nb_ports >= 1) { |
| 717 | ret = bt_private_component_source_add_output_private_port( |
| 718 | private_component, "out0", NULL, NULL); |
| 719 | assert(ret == 0); |
| 720 | } |
| 721 | |
| 722 | if (nb_ports >= 2) { |
| 723 | ret = bt_private_component_source_add_output_private_port( |
| 724 | private_component, "out1", NULL, NULL); |
| 725 | assert(ret == 0); |
| 726 | } |
| 727 | |
| 728 | if (nb_ports >= 3) { |
| 729 | ret = bt_private_component_source_add_output_private_port( |
| 730 | private_component, "out2", NULL, NULL); |
| 731 | assert(ret == 0); |
| 732 | } |
| 733 | |
| 734 | if (nb_ports >= 4) { |
| 735 | ret = bt_private_component_source_add_output_private_port( |
| 736 | private_component, "out3", NULL, NULL); |
| 737 | assert(ret == 0); |
| 738 | } |
| 739 | |
| 740 | return BT_COMPONENT_STATUS_OK; |
| 741 | } |
| 742 | |
| 743 | static |
| 744 | void src_finalize(struct bt_private_component *private_component) |
| 745 | { |
| 746 | } |
| 747 | |
| 748 | static |
| 749 | enum bt_component_status sink_consume( |
| 750 | struct bt_private_component *priv_component) |
| 751 | { |
| 752 | enum bt_component_status ret = BT_COMPONENT_STATUS_OK; |
| 753 | struct bt_notification *notification = NULL; |
| 754 | struct sink_user_data *user_data = |
| 755 | bt_private_component_get_user_data(priv_component); |
| 756 | enum bt_notification_iterator_status it_ret; |
| 757 | struct test_event test_event; |
| 758 | bool do_append_test_event = true; |
| 759 | |
| 760 | assert(user_data && user_data->notif_iter); |
| 761 | it_ret = bt_notification_iterator_next(user_data->notif_iter); |
| 762 | |
| 763 | if (it_ret < 0) { |
| 764 | ret = BT_COMPONENT_STATUS_ERROR; |
| 765 | do_append_test_event = false; |
| 766 | goto end; |
| 767 | } |
| 768 | |
| 769 | switch (it_ret) { |
| 770 | case BT_NOTIFICATION_ITERATOR_STATUS_END: |
| 771 | test_event.type = TEST_EV_TYPE_END; |
| 772 | ret = BT_COMPONENT_STATUS_END; |
| 773 | BT_PUT(user_data->notif_iter); |
| 774 | goto end; |
| 775 | case BT_NOTIFICATION_ITERATOR_STATUS_AGAIN: |
| 776 | test_event.type = TEST_EV_TYPE_AGAIN; |
| 777 | ret = BT_COMPONENT_STATUS_AGAIN; |
| 778 | goto end; |
| 779 | default: |
| 780 | break; |
| 781 | } |
| 782 | |
| 783 | notification = bt_notification_iterator_get_notification( |
| 784 | user_data->notif_iter); |
| 785 | assert(notification); |
| 786 | |
| 787 | switch (bt_notification_get_type(notification)) { |
| 788 | case BT_NOTIFICATION_TYPE_EVENT: |
| 789 | { |
| 790 | struct bt_event *event; |
| 791 | struct bt_clock_class_priority_map *cc_prio_map; |
| 792 | |
| 793 | test_event.type = TEST_EV_TYPE_NOTIF_EVENT; |
| 794 | cc_prio_map = |
| 795 | bt_notification_event_get_clock_class_priority_map( |
| 796 | notification); |
| 797 | assert(cc_prio_map); |
| 798 | event = bt_notification_event_get_event(notification); |
| 799 | assert(event); |
| 800 | |
| 801 | if (bt_clock_class_priority_map_get_clock_class_count(cc_prio_map) > 0) { |
| 802 | struct bt_clock_value *clock_value; |
| 803 | struct bt_clock_class *clock_class = |
| 804 | bt_clock_class_priority_map_get_highest_priority_clock_class( |
| 805 | cc_prio_map); |
| 806 | |
| 807 | assert(clock_class); |
| 808 | clock_value = bt_event_get_clock_value(event, |
| 809 | clock_class); |
| 810 | assert(clock_value); |
| 811 | ret = bt_clock_value_get_value_ns_from_epoch( |
| 812 | clock_value, &test_event.ts_ns); |
| 813 | assert(ret == 0); |
| 814 | bt_put(clock_value); |
| 815 | bt_put(clock_class); |
| 816 | } else { |
| 817 | test_event.ts_ns = -1; |
| 818 | } |
| 819 | |
| 820 | bt_put(cc_prio_map); |
| 821 | bt_put(event); |
| 822 | break; |
| 823 | } |
| 824 | case BT_NOTIFICATION_TYPE_INACTIVITY: |
| 825 | { |
| 826 | struct bt_clock_class_priority_map *cc_prio_map; |
| 827 | |
| 828 | test_event.type = TEST_EV_TYPE_NOTIF_INACTIVITY; |
| 829 | cc_prio_map = bt_notification_event_get_clock_class_priority_map( |
| 830 | notification); |
| 831 | assert(cc_prio_map); |
| 832 | |
| 833 | if (bt_clock_class_priority_map_get_clock_class_count(cc_prio_map) > 0) { |
| 834 | struct bt_clock_value *clock_value; |
| 835 | struct bt_clock_class *clock_class = |
| 836 | bt_clock_class_priority_map_get_highest_priority_clock_class( |
| 837 | cc_prio_map); |
| 838 | |
| 839 | assert(clock_class); |
| 840 | clock_value = |
| 841 | bt_notification_inactivity_get_clock_value( |
| 842 | notification, clock_class); |
| 843 | assert(clock_value); |
| 844 | ret = bt_clock_value_get_value_ns_from_epoch( |
| 845 | clock_value, &test_event.ts_ns); |
| 846 | assert(ret == 0); |
| 847 | bt_put(clock_value); |
| 848 | bt_put(clock_class); |
| 849 | } else { |
| 850 | test_event.ts_ns = -1; |
| 851 | } |
| 852 | |
| 853 | bt_put(cc_prio_map); |
| 854 | break; |
| 855 | } |
| 856 | case BT_NOTIFICATION_TYPE_PACKET_BEGIN: |
| 857 | test_event.type = TEST_EV_TYPE_NOTIF_PACKET_BEGIN; |
| 858 | break; |
| 859 | case BT_NOTIFICATION_TYPE_PACKET_END: |
| 860 | test_event.type = TEST_EV_TYPE_NOTIF_PACKET_END; |
| 861 | break; |
| 862 | case BT_NOTIFICATION_TYPE_STREAM_BEGIN: |
| 863 | test_event.type = TEST_EV_TYPE_NOTIF_STREAM_BEGIN; |
| 864 | break; |
| 865 | case BT_NOTIFICATION_TYPE_STREAM_END: |
| 866 | test_event.type = TEST_EV_TYPE_NOTIF_STREAM_END; |
| 867 | break; |
| 868 | default: |
| 869 | test_event.type = TEST_EV_TYPE_NOTIF_UNEXPECTED; |
| 870 | break; |
| 871 | } |
| 872 | |
| 873 | end: |
| 874 | if (do_append_test_event) { |
| 875 | append_test_event(&test_event); |
| 876 | } |
| 877 | |
| 878 | bt_put(notification); |
| 879 | return ret; |
| 880 | } |
| 881 | |
| 882 | static |
| 883 | void sink_port_connected(struct bt_private_component *private_component, |
| 884 | struct bt_private_port *self_private_port, |
| 885 | struct bt_port *other_port) |
| 886 | { |
| 887 | struct bt_private_connection *priv_conn = |
| 888 | bt_private_port_get_private_connection(self_private_port); |
| 889 | struct sink_user_data *user_data = bt_private_component_get_user_data( |
| 890 | private_component); |
| 891 | enum bt_connection_status conn_status; |
| 892 | |
| 893 | assert(user_data); |
| 894 | assert(priv_conn); |
| 895 | conn_status = bt_private_connection_create_notification_iterator( |
| 896 | priv_conn, &user_data->notif_iter); |
| 897 | assert(conn_status == 0); |
| 898 | bt_put(priv_conn); |
| 899 | } |
| 900 | |
| 901 | static |
| 902 | enum bt_component_status sink_init( |
| 903 | struct bt_private_component *private_component, |
| 904 | struct bt_value *params, void *init_method_data) |
| 905 | { |
| 906 | struct sink_user_data *user_data = g_new0(struct sink_user_data, 1); |
| 907 | int ret; |
| 908 | |
| 909 | assert(user_data); |
| 910 | ret = bt_private_component_set_user_data(private_component, |
| 911 | user_data); |
| 912 | assert(ret == 0); |
| 913 | ret = bt_private_component_sink_add_input_private_port( |
| 914 | private_component, "in", NULL, NULL); |
| 915 | assert(ret == 0); |
| 916 | return BT_COMPONENT_STATUS_OK; |
| 917 | } |
| 918 | |
| 919 | static |
| 920 | void sink_finalize(struct bt_private_component *private_component) |
| 921 | { |
| 922 | struct sink_user_data *user_data = bt_private_component_get_user_data( |
| 923 | private_component); |
| 924 | |
| 925 | if (user_data) { |
| 926 | bt_put(user_data->notif_iter); |
| 927 | g_free(user_data); |
| 928 | } |
| 929 | } |
| 930 | |
| 931 | static |
| 932 | void create_source_muxer_sink(struct bt_graph *graph, |
| 933 | struct bt_component **source, |
| 934 | struct bt_component **muxer, |
| 935 | struct bt_component **sink) |
| 936 | { |
| 937 | struct bt_component_class *src_comp_class; |
| 938 | struct bt_component_class *muxer_comp_class; |
| 939 | struct bt_component_class *sink_comp_class; |
| 940 | int ret; |
| 941 | |
| 942 | /* Create source component */ |
| 943 | src_comp_class = bt_component_class_source_create("src", src_iter_next); |
| 944 | assert(src_comp_class); |
| 945 | ret = bt_component_class_set_init_method(src_comp_class, src_init); |
| 946 | assert(ret == 0); |
| 947 | ret = bt_component_class_set_finalize_method(src_comp_class, |
| 948 | src_finalize); |
| 949 | assert(ret == 0); |
| 950 | ret = bt_component_class_source_set_notification_iterator_init_method( |
| 951 | src_comp_class, src_iter_init); |
| 952 | assert(ret == 0); |
| 953 | ret = bt_component_class_source_set_notification_iterator_finalize_method( |
| 954 | src_comp_class, src_iter_finalize); |
| 955 | assert(ret == 0); |
| 956 | ret = bt_graph_add_component(graph, src_comp_class, "source", NULL, source); |
| 957 | assert(ret == 0); |
| 958 | |
| 959 | /* Create muxer component */ |
| 960 | muxer_comp_class = bt_plugin_find_component_class("utils", "muxer", |
| 961 | BT_COMPONENT_CLASS_TYPE_FILTER); |
| 962 | assert(muxer_comp_class); |
| 963 | ret = bt_graph_add_component(graph, muxer_comp_class, "muxer", NULL, muxer); |
| 964 | assert(ret == 0); |
| 965 | |
| 966 | /* Create sink component */ |
| 967 | sink_comp_class = bt_component_class_sink_create("sink", sink_consume); |
| 968 | assert(sink_comp_class); |
| 969 | ret = bt_component_class_set_init_method(sink_comp_class, sink_init); |
| 970 | assert(ret == 0); |
| 971 | ret = bt_component_class_set_finalize_method(sink_comp_class, |
| 972 | sink_finalize); |
| 973 | ret = bt_component_class_set_port_connected_method(sink_comp_class, |
| 974 | sink_port_connected); |
| 975 | assert(ret == 0); |
| 976 | ret = bt_graph_add_component(graph, sink_comp_class, "sink", NULL, sink); |
| 977 | assert(ret == 0); |
| 978 | |
| 979 | bt_put(src_comp_class); |
| 980 | bt_put(muxer_comp_class); |
| 981 | bt_put(sink_comp_class); |
| 982 | } |
| 983 | |
| 984 | static |
| 985 | void do_std_test(enum test test, const char *name, |
| 986 | const struct test_event *expected_test_events, |
| 987 | bool with_upstream) |
| 988 | { |
| 989 | struct bt_component *src_comp; |
| 990 | struct bt_component *muxer_comp; |
| 991 | struct bt_component *sink_comp; |
| 992 | struct bt_port *upstream_port; |
| 993 | struct bt_port *downstream_port; |
| 994 | struct bt_graph *graph; |
| 995 | int64_t i; |
| 996 | int64_t count; |
| 997 | enum bt_graph_status graph_status = BT_GRAPH_STATUS_OK; |
| 998 | |
| 999 | clear_test_events(); |
| 1000 | current_test = test; |
| 1001 | diag("test: %s", name); |
| 1002 | graph = bt_graph_create(); |
| 1003 | assert(graph); |
| 1004 | create_source_muxer_sink(graph, &src_comp, &muxer_comp, &sink_comp); |
| 1005 | |
| 1006 | /* Connect source output ports to muxer input ports */ |
| 1007 | if (with_upstream) { |
| 1008 | count = bt_component_source_get_output_port_count(src_comp); |
| 1009 | assert(count >= 0); |
| 1010 | |
| 1011 | for (i = 0; i < count; i++) { |
| 1012 | upstream_port = bt_component_source_get_output_port_by_index( |
| 1013 | src_comp, i); |
| 1014 | assert(upstream_port); |
| 1015 | downstream_port = bt_component_filter_get_input_port_by_index( |
| 1016 | muxer_comp, i); |
| 1017 | assert(downstream_port); |
| 1018 | graph_status = bt_graph_connect_ports(graph, |
| 1019 | upstream_port, downstream_port, NULL); |
| 1020 | assert(graph_status == 0); |
| 1021 | bt_put(upstream_port); |
| 1022 | bt_put(downstream_port); |
| 1023 | } |
| 1024 | } |
| 1025 | |
| 1026 | /* Connect muxer output port to sink input port */ |
| 1027 | upstream_port = bt_component_filter_get_output_port_by_name(muxer_comp, |
| 1028 | "out"); |
| 1029 | assert(upstream_port); |
| 1030 | downstream_port = bt_component_sink_get_input_port_by_name(sink_comp, "in"); |
| 1031 | assert(downstream_port); |
| 1032 | graph_status = bt_graph_connect_ports(graph, upstream_port, |
| 1033 | downstream_port, NULL); |
| 1034 | assert(graph_status == 0); |
| 1035 | bt_put(upstream_port); |
| 1036 | bt_put(downstream_port); |
| 1037 | |
| 1038 | while (graph_status == BT_GRAPH_STATUS_OK || |
| 1039 | graph_status == BT_GRAPH_STATUS_AGAIN) { |
| 1040 | graph_status = bt_graph_run(graph); |
| 1041 | } |
| 1042 | |
| 1043 | ok(graph_status == BT_GRAPH_STATUS_END, "graph finishes without any error"); |
| 1044 | ok(compare_test_events(expected_test_events), |
| 1045 | "the produced sequence of test events is the expected one"); |
| 1046 | |
| 1047 | bt_put(src_comp); |
| 1048 | bt_put(muxer_comp); |
| 1049 | bt_put(sink_comp); |
| 1050 | bt_put(graph); |
| 1051 | } |
| 1052 | |
| 1053 | static |
| 1054 | void test_no_ts(void) |
| 1055 | { |
| 1056 | const struct test_event expected_test_events[] = { |
| 1057 | { .type = TEST_EV_TYPE_NOTIF_STREAM_BEGIN, }, |
| 1058 | { .type = TEST_EV_TYPE_NOTIF_PACKET_BEGIN, }, |
| 1059 | { .type = TEST_EV_TYPE_NOTIF_STREAM_BEGIN, }, |
| 1060 | { .type = TEST_EV_TYPE_NOTIF_PACKET_BEGIN, }, |
| 1061 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = -1, }, |
| 1062 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = -1, }, |
| 1063 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = -1, }, |
| 1064 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = -1, }, |
| 1065 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = -1, }, |
| 1066 | { .type = TEST_EV_TYPE_NOTIF_PACKET_END, }, |
| 1067 | { .type = TEST_EV_TYPE_NOTIF_STREAM_END, }, |
| 1068 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 1, }, |
| 1069 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 4, }, |
| 1070 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 189, }, |
| 1071 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 1001, }, |
| 1072 | { .type = TEST_EV_TYPE_NOTIF_PACKET_END, }, |
| 1073 | { .type = TEST_EV_TYPE_NOTIF_STREAM_END, }, |
| 1074 | { .type = TEST_EV_TYPE_END, }, |
| 1075 | { .type = TEST_EV_TYPE_SENTINEL, }, |
| 1076 | }; |
| 1077 | |
| 1078 | do_std_test(TEST_NO_TS, "event notifications with no time", |
| 1079 | expected_test_events, true); |
| 1080 | } |
| 1081 | |
| 1082 | static |
| 1083 | void test_no_upstream_connection(void) |
| 1084 | { |
| 1085 | const struct test_event expected_test_events[] = { |
| 1086 | { .type = TEST_EV_TYPE_END, }, |
| 1087 | { .type = TEST_EV_TYPE_SENTINEL, }, |
| 1088 | }; |
| 1089 | |
| 1090 | do_std_test(TEST_NO_UPSTREAM_CONNECTION, "no upstream connection", |
| 1091 | expected_test_events, false); |
| 1092 | } |
| 1093 | |
| 1094 | static |
| 1095 | void test_simple_4_ports(void) |
| 1096 | { |
| 1097 | const struct test_event expected_test_events[] = { |
| 1098 | { .type = TEST_EV_TYPE_NOTIF_STREAM_BEGIN, }, |
| 1099 | { .type = TEST_EV_TYPE_NOTIF_PACKET_BEGIN, }, |
| 1100 | { .type = TEST_EV_TYPE_NOTIF_STREAM_BEGIN, }, |
| 1101 | { .type = TEST_EV_TYPE_NOTIF_PACKET_BEGIN, }, |
| 1102 | { .type = TEST_EV_TYPE_NOTIF_STREAM_BEGIN, }, |
| 1103 | { .type = TEST_EV_TYPE_NOTIF_PACKET_BEGIN, }, |
| 1104 | { .type = TEST_EV_TYPE_NOTIF_STREAM_BEGIN, }, |
| 1105 | { .type = TEST_EV_TYPE_NOTIF_PACKET_BEGIN, }, |
| 1106 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 8 }, |
| 1107 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 24 }, |
| 1108 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 41 }, |
| 1109 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 51 }, |
| 1110 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 53 }, |
| 1111 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 56 }, |
| 1112 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 59 }, |
| 1113 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 68 }, |
| 1114 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 71 }, |
| 1115 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 77 }, |
| 1116 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 91 }, |
| 1117 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 97 }, |
| 1118 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 105 }, |
| 1119 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 119 }, |
| 1120 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 120 }, |
| 1121 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 121 }, |
| 1122 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 138 }, |
| 1123 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 139 }, |
| 1124 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 154 }, |
| 1125 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 170 }, |
| 1126 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 179 }, |
| 1127 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 209 }, |
| 1128 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 210 }, |
| 1129 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 222 }, |
| 1130 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 228 }, |
| 1131 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 240 }, |
| 1132 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 254 }, |
| 1133 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 266 }, |
| 1134 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 292 }, |
| 1135 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 298 }, |
| 1136 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 317 }, |
| 1137 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 320 }, |
| 1138 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 350 }, |
| 1139 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 352 }, |
| 1140 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 353 }, |
| 1141 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 393 }, |
| 1142 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 407 }, |
| 1143 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 419 }, |
| 1144 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 433 }, |
| 1145 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 454 }, |
| 1146 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 471 }, |
| 1147 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 473 }, |
| 1148 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 478 }, |
| 1149 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 479 }, |
| 1150 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 481 }, |
| 1151 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 487 }, |
| 1152 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 504 }, |
| 1153 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 525 }, |
| 1154 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 572 }, |
| 1155 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 591 }, |
| 1156 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 605 }, |
| 1157 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 612 }, |
| 1158 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 615 }, |
| 1159 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 618 }, |
| 1160 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 624 }, |
| 1161 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 631 }, |
| 1162 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 632 }, |
| 1163 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 644 }, |
| 1164 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 651 }, |
| 1165 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 668 }, |
| 1166 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 670 }, |
| 1167 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 678 }, |
| 1168 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 696 }, |
| 1169 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 708 }, |
| 1170 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 714 }, |
| 1171 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 717 }, |
| 1172 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 731 }, |
| 1173 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 733 }, |
| 1174 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 744 }, |
| 1175 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 750 }, |
| 1176 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 766 }, |
| 1177 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 778 }, |
| 1178 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 788 }, |
| 1179 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 790 }, |
| 1180 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 819 }, |
| 1181 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 820 }, |
| 1182 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 825 }, |
| 1183 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 836 }, |
| 1184 | { .type = TEST_EV_TYPE_NOTIF_PACKET_END, }, |
| 1185 | { .type = TEST_EV_TYPE_NOTIF_STREAM_END, }, |
| 1186 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 850 }, |
| 1187 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 852 }, |
| 1188 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 857 }, |
| 1189 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 863 }, |
| 1190 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 867 }, |
| 1191 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 871 }, |
| 1192 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 884 }, |
| 1193 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 892 }, |
| 1194 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 903 }, |
| 1195 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 931 }, |
| 1196 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 944 }, |
| 1197 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 951 }, |
| 1198 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 953 }, |
| 1199 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 956 }, |
| 1200 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 985 }, |
| 1201 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 996 }, |
| 1202 | { .type = TEST_EV_TYPE_NOTIF_PACKET_END, }, |
| 1203 | { .type = TEST_EV_TYPE_NOTIF_STREAM_END, }, |
| 1204 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 998 }, |
| 1205 | { .type = TEST_EV_TYPE_NOTIF_PACKET_END, }, |
| 1206 | { .type = TEST_EV_TYPE_NOTIF_STREAM_END, }, |
| 1207 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 999 }, |
| 1208 | { .type = TEST_EV_TYPE_NOTIF_PACKET_END, }, |
| 1209 | { .type = TEST_EV_TYPE_NOTIF_STREAM_END, }, |
| 1210 | { .type = TEST_EV_TYPE_END, }, |
| 1211 | { .type = TEST_EV_TYPE_SENTINEL, }, |
| 1212 | }; |
| 1213 | |
| 1214 | do_std_test(TEST_SIMPLE_4_PORTS, "simple: 4 ports without retries", |
| 1215 | expected_test_events, true); |
| 1216 | } |
| 1217 | |
| 1218 | static |
| 1219 | void test_4_ports_with_retries(void) |
| 1220 | { |
| 1221 | const struct test_event expected_test_events[] = { |
| 1222 | { .type = TEST_EV_TYPE_AGAIN, }, |
| 1223 | { .type = TEST_EV_TYPE_NOTIF_STREAM_BEGIN, }, |
| 1224 | { .type = TEST_EV_TYPE_NOTIF_PACKET_BEGIN, }, |
| 1225 | { .type = TEST_EV_TYPE_NOTIF_STREAM_BEGIN, }, |
| 1226 | { .type = TEST_EV_TYPE_NOTIF_PACKET_BEGIN, }, |
| 1227 | { .type = TEST_EV_TYPE_NOTIF_STREAM_BEGIN, }, |
| 1228 | { .type = TEST_EV_TYPE_NOTIF_PACKET_BEGIN, }, |
| 1229 | { .type = TEST_EV_TYPE_NOTIF_STREAM_BEGIN, }, |
| 1230 | { .type = TEST_EV_TYPE_NOTIF_PACKET_BEGIN, }, |
| 1231 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 8 }, |
| 1232 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 24 }, |
| 1233 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 41 }, |
| 1234 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 51 }, |
| 1235 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 53 }, |
| 1236 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 56 }, |
| 1237 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 59 }, |
| 1238 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 68 }, |
| 1239 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 71 }, |
| 1240 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 77 }, |
| 1241 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 91 }, |
| 1242 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 97 }, |
| 1243 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 105 }, |
| 1244 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 119 }, |
| 1245 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 120 }, |
| 1246 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 121 }, |
| 1247 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 138 }, |
| 1248 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 139 }, |
| 1249 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 154 }, |
| 1250 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 170 }, |
| 1251 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 179 }, |
| 1252 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 209 }, |
| 1253 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 210 }, |
| 1254 | { .type = TEST_EV_TYPE_AGAIN, }, |
| 1255 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 222 }, |
| 1256 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 228 }, |
| 1257 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 240 }, |
| 1258 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 254 }, |
| 1259 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 266 }, |
| 1260 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 292 }, |
| 1261 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 298 }, |
| 1262 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 317 }, |
| 1263 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 320 }, |
| 1264 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 350 }, |
| 1265 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 352 }, |
| 1266 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 353 }, |
| 1267 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 393 }, |
| 1268 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 407 }, |
| 1269 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 419 }, |
| 1270 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 433 }, |
| 1271 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 454 }, |
| 1272 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 471 }, |
| 1273 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 473 }, |
| 1274 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 478 }, |
| 1275 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 479 }, |
| 1276 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 481 }, |
| 1277 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 487 }, |
| 1278 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 504 }, |
| 1279 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 525 }, |
| 1280 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 572 }, |
| 1281 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 591 }, |
| 1282 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 605 }, |
| 1283 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 612 }, |
| 1284 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 615 }, |
| 1285 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 618 }, |
| 1286 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 624 }, |
| 1287 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 631 }, |
| 1288 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 632 }, |
| 1289 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 644 }, |
| 1290 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 651 }, |
| 1291 | { .type = TEST_EV_TYPE_AGAIN, }, |
| 1292 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 668 }, |
| 1293 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 670 }, |
| 1294 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 678 }, |
| 1295 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 696 }, |
| 1296 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 708 }, |
| 1297 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 714 }, |
| 1298 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 717 }, |
| 1299 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 731 }, |
| 1300 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 733 }, |
| 1301 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 744 }, |
| 1302 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 750 }, |
| 1303 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 766 }, |
| 1304 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 778 }, |
| 1305 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 788 }, |
| 1306 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 790 }, |
| 1307 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 819 }, |
| 1308 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 820 }, |
| 1309 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 825 }, |
| 1310 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 836 }, |
| 1311 | { .type = TEST_EV_TYPE_AGAIN, }, |
| 1312 | { .type = TEST_EV_TYPE_NOTIF_PACKET_END, }, |
| 1313 | { .type = TEST_EV_TYPE_NOTIF_STREAM_END, }, |
| 1314 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 850 }, |
| 1315 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 852 }, |
| 1316 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 857 }, |
| 1317 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 863 }, |
| 1318 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 867 }, |
| 1319 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 871 }, |
| 1320 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 884 }, |
| 1321 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 892 }, |
| 1322 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 903 }, |
| 1323 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 931 }, |
| 1324 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 944 }, |
| 1325 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 951 }, |
| 1326 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 953 }, |
| 1327 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 956 }, |
| 1328 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 985 }, |
| 1329 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 996 }, |
| 1330 | { .type = TEST_EV_TYPE_NOTIF_PACKET_END, }, |
| 1331 | { .type = TEST_EV_TYPE_NOTIF_STREAM_END, }, |
| 1332 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 998 }, |
| 1333 | { .type = TEST_EV_TYPE_NOTIF_PACKET_END, }, |
| 1334 | { .type = TEST_EV_TYPE_NOTIF_STREAM_END, }, |
| 1335 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 999 }, |
| 1336 | { .type = TEST_EV_TYPE_NOTIF_PACKET_END, }, |
| 1337 | { .type = TEST_EV_TYPE_NOTIF_STREAM_END, }, |
| 1338 | { .type = TEST_EV_TYPE_END, }, |
| 1339 | { .type = TEST_EV_TYPE_SENTINEL, }, |
| 1340 | }; |
| 1341 | |
| 1342 | do_std_test(TEST_4_PORTS_WITH_RETRIES, "4 ports with retries", |
| 1343 | expected_test_events, true); |
| 1344 | } |
| 1345 | |
| 1346 | static |
| 1347 | void connect_port_to_first_avail_muxer_port(struct bt_graph *graph, |
| 1348 | struct bt_port *source_port, |
| 1349 | struct bt_component *muxer_comp) |
| 1350 | { |
| 1351 | struct bt_port *avail_muxer_port = NULL; |
| 1352 | int64_t i; |
| 1353 | int64_t count; |
| 1354 | enum bt_graph_status graph_status; |
| 1355 | |
| 1356 | count = bt_component_filter_get_input_port_count(muxer_comp); |
| 1357 | assert(count >= 0); |
| 1358 | |
| 1359 | for (i = 0; i < count; i++) { |
| 1360 | struct bt_port *muxer_port = |
| 1361 | bt_component_filter_get_input_port_by_index( |
| 1362 | muxer_comp, i); |
| 1363 | |
| 1364 | assert(muxer_port); |
| 1365 | |
| 1366 | if (!bt_port_is_connected(muxer_port)) { |
| 1367 | BT_MOVE(avail_muxer_port, muxer_port); |
| 1368 | break; |
| 1369 | } else { |
| 1370 | bt_put(muxer_port); |
| 1371 | } |
| 1372 | } |
| 1373 | |
| 1374 | graph_status = bt_graph_connect_ports(graph, source_port, |
| 1375 | avail_muxer_port, NULL); |
| 1376 | assert(graph_status == 0); |
| 1377 | bt_put(avail_muxer_port); |
| 1378 | } |
| 1379 | |
| 1380 | static |
| 1381 | void graph_port_added_listener_connect_to_avail_muxer_port(struct bt_port *port, |
| 1382 | void *data) |
| 1383 | { |
| 1384 | struct graph_listener_data *graph_listener_data = data; |
| 1385 | struct bt_component *comp; |
| 1386 | |
| 1387 | comp = bt_port_get_component(port); |
| 1388 | assert(comp); |
| 1389 | |
| 1390 | if (comp != graph_listener_data->source) { |
| 1391 | goto end; |
| 1392 | } |
| 1393 | |
| 1394 | connect_port_to_first_avail_muxer_port(graph_listener_data->graph, |
| 1395 | port, graph_listener_data->muxer); |
| 1396 | |
| 1397 | end: |
| 1398 | bt_put(comp); |
| 1399 | } |
| 1400 | |
| 1401 | static |
| 1402 | void test_single_end_then_multiple_full(void) |
| 1403 | { |
| 1404 | struct bt_component *src_comp; |
| 1405 | struct bt_component *muxer_comp; |
| 1406 | struct bt_component *sink_comp; |
| 1407 | struct bt_port *upstream_port; |
| 1408 | struct bt_port *downstream_port; |
| 1409 | struct bt_graph *graph; |
| 1410 | int64_t i; |
| 1411 | int64_t count; |
| 1412 | int ret; |
| 1413 | enum bt_graph_status graph_status = BT_GRAPH_STATUS_OK; |
| 1414 | struct graph_listener_data graph_listener_data; |
| 1415 | const struct test_event expected_test_events[] = { |
| 1416 | { .type = TEST_EV_TYPE_NOTIF_STREAM_BEGIN, }, |
| 1417 | { .type = TEST_EV_TYPE_NOTIF_PACKET_BEGIN, }, |
| 1418 | { .type = TEST_EV_TYPE_NOTIF_STREAM_BEGIN, }, |
| 1419 | { .type = TEST_EV_TYPE_NOTIF_PACKET_BEGIN, }, |
| 1420 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 8 }, |
| 1421 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 51 }, |
| 1422 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 59 }, |
| 1423 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 68 }, |
| 1424 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 71 }, |
| 1425 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 77 }, |
| 1426 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 91 }, |
| 1427 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 121 }, |
| 1428 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 139 }, |
| 1429 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 170 }, |
| 1430 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 179 }, |
| 1431 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 209 }, |
| 1432 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 254 }, |
| 1433 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 266 }, |
| 1434 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 298 }, |
| 1435 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 320 }, |
| 1436 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 350 }, |
| 1437 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 352 }, |
| 1438 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 393 }, |
| 1439 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 419 }, |
| 1440 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 454 }, |
| 1441 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 478 }, |
| 1442 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 624 }, |
| 1443 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 631 }, |
| 1444 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 644 }, |
| 1445 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 651 }, |
| 1446 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 668 }, |
| 1447 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 678 }, |
| 1448 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 714 }, |
| 1449 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 717 }, |
| 1450 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 731 }, |
| 1451 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 733 }, |
| 1452 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 744 }, |
| 1453 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 750 }, |
| 1454 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 778 }, |
| 1455 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 788 }, |
| 1456 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 790 }, |
| 1457 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 819 }, |
| 1458 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 820 }, |
| 1459 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 836 }, |
| 1460 | { .type = TEST_EV_TYPE_NOTIF_PACKET_END, }, |
| 1461 | { .type = TEST_EV_TYPE_NOTIF_STREAM_END, }, |
| 1462 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 857 }, |
| 1463 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 892 }, |
| 1464 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 903 }, |
| 1465 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 944 }, |
| 1466 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 998 }, |
| 1467 | { .type = TEST_EV_TYPE_NOTIF_PACKET_END, }, |
| 1468 | { .type = TEST_EV_TYPE_NOTIF_STREAM_END, }, |
| 1469 | { .type = TEST_EV_TYPE_END, }, |
| 1470 | { .type = TEST_EV_TYPE_SENTINEL, }, |
| 1471 | }; |
| 1472 | |
| 1473 | clear_test_events(); |
| 1474 | current_test = TEST_SINGLE_END_THEN_MULTIPLE_FULL; |
| 1475 | diag("test: single end then multiple full"); |
| 1476 | graph = bt_graph_create(); |
| 1477 | assert(graph); |
| 1478 | create_source_muxer_sink(graph, &src_comp, &muxer_comp, &sink_comp); |
| 1479 | graph_listener_data.graph = graph; |
| 1480 | graph_listener_data.source = src_comp; |
| 1481 | graph_listener_data.muxer = muxer_comp; |
| 1482 | graph_listener_data.sink = sink_comp; |
| 1483 | ret = bt_graph_add_port_added_listener(graph, |
| 1484 | graph_port_added_listener_connect_to_avail_muxer_port, NULL, |
| 1485 | &graph_listener_data); |
| 1486 | assert(ret >= 0); |
| 1487 | |
| 1488 | /* Connect source output ports to muxer input ports */ |
| 1489 | count = bt_component_source_get_output_port_count(src_comp); |
| 1490 | assert(ret == 0); |
| 1491 | |
| 1492 | for (i = 0; i < count; i++) { |
| 1493 | upstream_port = bt_component_source_get_output_port_by_index( |
| 1494 | src_comp, i); |
| 1495 | assert(upstream_port); |
| 1496 | connect_port_to_first_avail_muxer_port(graph, |
| 1497 | upstream_port, muxer_comp); |
| 1498 | bt_put(upstream_port); |
| 1499 | } |
| 1500 | |
| 1501 | /* Connect muxer output port to sink input port */ |
| 1502 | upstream_port = bt_component_filter_get_output_port_by_name(muxer_comp, |
| 1503 | "out"); |
| 1504 | assert(upstream_port); |
| 1505 | downstream_port = bt_component_sink_get_input_port_by_name(sink_comp, "in"); |
| 1506 | assert(downstream_port); |
| 1507 | graph_status = bt_graph_connect_ports(graph, upstream_port, |
| 1508 | downstream_port, NULL); |
| 1509 | assert(graph_status == 0); |
| 1510 | bt_put(upstream_port); |
| 1511 | bt_put(downstream_port); |
| 1512 | |
| 1513 | while (graph_status == BT_GRAPH_STATUS_OK || |
| 1514 | graph_status == BT_GRAPH_STATUS_AGAIN) { |
| 1515 | graph_status = bt_graph_run(graph); |
| 1516 | } |
| 1517 | |
| 1518 | ok(graph_status == BT_GRAPH_STATUS_END, "graph finishes without any error"); |
| 1519 | ok(compare_test_events(expected_test_events), |
| 1520 | "the produced sequence of test events is the expected one"); |
| 1521 | |
| 1522 | bt_put(src_comp); |
| 1523 | bt_put(muxer_comp); |
| 1524 | bt_put(sink_comp); |
| 1525 | bt_put(graph); |
| 1526 | } |
| 1527 | |
| 1528 | static |
| 1529 | void test_single_again_end_then_multiple_full(void) |
| 1530 | { |
| 1531 | struct bt_component *src_comp; |
| 1532 | struct bt_component *muxer_comp; |
| 1533 | struct bt_component *sink_comp; |
| 1534 | struct bt_port *upstream_port; |
| 1535 | struct bt_port *downstream_port; |
| 1536 | struct bt_graph *graph; |
| 1537 | int64_t i; |
| 1538 | int64_t count; |
| 1539 | int ret; |
| 1540 | enum bt_graph_status graph_status = BT_GRAPH_STATUS_OK; |
| 1541 | struct graph_listener_data graph_listener_data; |
| 1542 | const struct test_event expected_test_events[] = { |
| 1543 | { .type = TEST_EV_TYPE_AGAIN, }, |
| 1544 | { .type = TEST_EV_TYPE_NOTIF_STREAM_BEGIN, }, |
| 1545 | { .type = TEST_EV_TYPE_NOTIF_PACKET_BEGIN, }, |
| 1546 | { .type = TEST_EV_TYPE_NOTIF_STREAM_BEGIN, }, |
| 1547 | { .type = TEST_EV_TYPE_NOTIF_PACKET_BEGIN, }, |
| 1548 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 8 }, |
| 1549 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 51 }, |
| 1550 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 59 }, |
| 1551 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 68 }, |
| 1552 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 71 }, |
| 1553 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 77 }, |
| 1554 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 91 }, |
| 1555 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 121 }, |
| 1556 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 139 }, |
| 1557 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 170 }, |
| 1558 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 179 }, |
| 1559 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 209 }, |
| 1560 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 254 }, |
| 1561 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 266 }, |
| 1562 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 298 }, |
| 1563 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 320 }, |
| 1564 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 350 }, |
| 1565 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 352 }, |
| 1566 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 393 }, |
| 1567 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 419 }, |
| 1568 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 454 }, |
| 1569 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 478 }, |
| 1570 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 624 }, |
| 1571 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 631 }, |
| 1572 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 644 }, |
| 1573 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 651 }, |
| 1574 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 668 }, |
| 1575 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 678 }, |
| 1576 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 714 }, |
| 1577 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 717 }, |
| 1578 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 731 }, |
| 1579 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 733 }, |
| 1580 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 744 }, |
| 1581 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 750 }, |
| 1582 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 778 }, |
| 1583 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 788 }, |
| 1584 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 790 }, |
| 1585 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 819 }, |
| 1586 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 820 }, |
| 1587 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 836 }, |
| 1588 | { .type = TEST_EV_TYPE_NOTIF_PACKET_END, }, |
| 1589 | { .type = TEST_EV_TYPE_NOTIF_STREAM_END, }, |
| 1590 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 857 }, |
| 1591 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 892 }, |
| 1592 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 903 }, |
| 1593 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 944 }, |
| 1594 | { .type = TEST_EV_TYPE_NOTIF_EVENT, .ts_ns = 998 }, |
| 1595 | { .type = TEST_EV_TYPE_NOTIF_PACKET_END, }, |
| 1596 | { .type = TEST_EV_TYPE_NOTIF_STREAM_END, }, |
| 1597 | { .type = TEST_EV_TYPE_END, }, |
| 1598 | { .type = TEST_EV_TYPE_SENTINEL, }, |
| 1599 | }; |
| 1600 | |
| 1601 | clear_test_events(); |
| 1602 | current_test = TEST_SINGLE_AGAIN_END_THEN_MULTIPLE_FULL; |
| 1603 | diag("test: single again then end then multiple full"); |
| 1604 | graph = bt_graph_create(); |
| 1605 | assert(graph); |
| 1606 | create_source_muxer_sink(graph, &src_comp, &muxer_comp, &sink_comp); |
| 1607 | graph_listener_data.graph = graph; |
| 1608 | graph_listener_data.source = src_comp; |
| 1609 | graph_listener_data.muxer = muxer_comp; |
| 1610 | graph_listener_data.sink = sink_comp; |
| 1611 | ret = bt_graph_add_port_added_listener(graph, |
| 1612 | graph_port_added_listener_connect_to_avail_muxer_port, NULL, |
| 1613 | &graph_listener_data); |
| 1614 | assert(ret >= 0); |
| 1615 | |
| 1616 | /* Connect source output ports to muxer input ports */ |
| 1617 | count = bt_component_source_get_output_port_count(src_comp); |
| 1618 | assert(ret == 0); |
| 1619 | |
| 1620 | for (i = 0; i < count; i++) { |
| 1621 | upstream_port = bt_component_source_get_output_port_by_index( |
| 1622 | src_comp, i); |
| 1623 | assert(upstream_port); |
| 1624 | connect_port_to_first_avail_muxer_port(graph, |
| 1625 | upstream_port, muxer_comp); |
| 1626 | bt_put(upstream_port); |
| 1627 | } |
| 1628 | |
| 1629 | /* Connect muxer output port to sink input port */ |
| 1630 | upstream_port = bt_component_filter_get_output_port_by_name(muxer_comp, |
| 1631 | "out"); |
| 1632 | assert(upstream_port); |
| 1633 | downstream_port = bt_component_sink_get_input_port_by_name(sink_comp, "in"); |
| 1634 | assert(downstream_port); |
| 1635 | graph_status = bt_graph_connect_ports(graph, upstream_port, |
| 1636 | downstream_port, NULL); |
| 1637 | assert(graph_status == 0); |
| 1638 | bt_put(upstream_port); |
| 1639 | bt_put(downstream_port); |
| 1640 | |
| 1641 | while (graph_status == BT_GRAPH_STATUS_OK || |
| 1642 | graph_status == BT_GRAPH_STATUS_AGAIN) { |
| 1643 | graph_status = bt_graph_run(graph); |
| 1644 | } |
| 1645 | |
| 1646 | ok(graph_status == BT_GRAPH_STATUS_END, "graph finishes without any error"); |
| 1647 | ok(compare_test_events(expected_test_events), |
| 1648 | "the produced sequence of test events is the expected one"); |
| 1649 | |
| 1650 | bt_put(src_comp); |
| 1651 | bt_put(muxer_comp); |
| 1652 | bt_put(sink_comp); |
| 1653 | bt_put(graph); |
| 1654 | } |
| 1655 | |
| 1656 | #define DEBUG_ENV_VAR "TEST_UTILS_MUXER_DEBUG" |
| 1657 | |
| 1658 | int main(int argc, char **argv) |
| 1659 | { |
| 1660 | if (getenv(DEBUG_ENV_VAR) && strcmp(getenv(DEBUG_ENV_VAR), "1") == 0) { |
| 1661 | debug = true; |
| 1662 | } |
| 1663 | |
| 1664 | plan_tests(NR_TESTS); |
| 1665 | init_static_data(); |
| 1666 | test_no_ts(); |
| 1667 | test_no_upstream_connection(); |
| 1668 | test_simple_4_ports(); |
| 1669 | test_4_ports_with_retries(); |
| 1670 | test_single_end_then_multiple_full(); |
| 1671 | test_single_again_end_then_multiple_full(); |
| 1672 | fini_static_data(); |
| 1673 | return exit_status(); |
| 1674 | } |