-static
-void test_auto_stream_begin_from_packet_begin(void)
-{
- const struct test_event expected_test_events[] = {
- { .type = TEST_EV_TYPE_NOTIF_STREAM_BEGIN, .stream = src_stream1, .packet = NULL, },
- { .type = TEST_EV_TYPE_NOTIF_PACKET_BEGIN, .stream = src_stream1, .packet = src_stream1_packet1, },
- { .type = TEST_EV_TYPE_NOTIF_PACKET_END, .stream = src_stream1, .packet = src_stream1_packet1, },
- { .type = TEST_EV_TYPE_NOTIF_STREAM_END, .stream = src_stream1, .packet = NULL, },
- { .type = TEST_EV_TYPE_END, },
- { .type = TEST_EV_TYPE_SENTINEL, },
- };
-
- do_std_test(TEST_AUTO_STREAM_BEGIN_FROM_PACKET_BEGIN,
- "automatic \"stream begin\" notif. caused by \"packet begin\" notif.",
- expected_test_events);
-}
-
-static
-void test_auto_stream_begin_from_stream_end(void)
-{
- const struct test_event expected_test_events[] = {
- { .type = TEST_EV_TYPE_NOTIF_STREAM_BEGIN, .stream = src_stream1, .packet = NULL, },
- { .type = TEST_EV_TYPE_NOTIF_STREAM_END, .stream = src_stream1, .packet = NULL, },
- { .type = TEST_EV_TYPE_END, },
- { .type = TEST_EV_TYPE_SENTINEL, },
- };
-
- do_std_test(TEST_AUTO_STREAM_BEGIN_FROM_STREAM_END,
- "automatic \"stream begin\" notif. caused by \"stream end\" notif.",
- expected_test_events);
-}
-
-static
-void test_auto_stream_end_from_end(void)
-{
- const struct test_event expected_test_events[] = {
- { .type = TEST_EV_TYPE_NOTIF_STREAM_BEGIN, .stream = src_stream1, .packet = NULL, },
- { .type = TEST_EV_TYPE_NOTIF_STREAM_END, .stream = src_stream1, .packet = NULL, },
- { .type = TEST_EV_TYPE_END, },
- { .type = TEST_EV_TYPE_SENTINEL, },
- };
-
- do_std_test(TEST_AUTO_STREAM_END_FROM_END,
- "automatic \"stream end\" notif. caused by BT_NOTIFICATION_ITERATOR_STATUS_END",
- expected_test_events);
-}
-
-static
-void test_auto_packet_begin_from_packet_end(void)
-{
- const struct test_event expected_test_events[] = {
- { .type = TEST_EV_TYPE_NOTIF_STREAM_BEGIN, .stream = src_stream1, .packet = NULL, },
- { .type = TEST_EV_TYPE_NOTIF_PACKET_BEGIN, .stream = src_stream1, .packet = src_stream1_packet1, },
- { .type = TEST_EV_TYPE_NOTIF_PACKET_END, .stream = src_stream1, .packet = src_stream1_packet1, },
- { .type = TEST_EV_TYPE_NOTIF_STREAM_END, .stream = src_stream1, .packet = NULL, },
- { .type = TEST_EV_TYPE_END, },
- { .type = TEST_EV_TYPE_SENTINEL, },
- };
-
- do_std_test(TEST_AUTO_PACKET_BEGIN_FROM_PACKET_END,
- "automatic \"packet begin\" notif. caused by \"packet end\" notif.",
- expected_test_events);
-}
-
-static
-void test_auto_packet_begin_from_event(void)
-{
- const struct test_event expected_test_events[] = {
- { .type = TEST_EV_TYPE_NOTIF_STREAM_BEGIN, .stream = src_stream1, .packet = NULL, },
- { .type = TEST_EV_TYPE_NOTIF_PACKET_BEGIN, .stream = src_stream1, .packet = src_stream1_packet1, },
- { .type = TEST_EV_TYPE_NOTIF_EVENT, .stream = src_stream1, .packet = src_stream1_packet1, },
- { .type = TEST_EV_TYPE_NOTIF_PACKET_END, .stream = src_stream1, .packet = src_stream1_packet1, },
- { .type = TEST_EV_TYPE_NOTIF_STREAM_END, .stream = src_stream1, .packet = NULL, },
- { .type = TEST_EV_TYPE_END, },
- { .type = TEST_EV_TYPE_SENTINEL, },
- };
-
- do_std_test(TEST_AUTO_PACKET_BEGIN_FROM_EVENT,
- "automatic \"packet begin\" notif. caused by event notif.",
- expected_test_events);
-}
-
-static
-void test_auto_packet_end_from_packet_begin(void)
-{
- const struct test_event expected_test_events[] = {
- { .type = TEST_EV_TYPE_NOTIF_STREAM_BEGIN, .stream = src_stream1, .packet = NULL, },
- { .type = TEST_EV_TYPE_NOTIF_PACKET_BEGIN, .stream = src_stream1, .packet = src_stream1_packet1, },
- { .type = TEST_EV_TYPE_NOTIF_PACKET_END, .stream = src_stream1, .packet = src_stream1_packet1, },
- { .type = TEST_EV_TYPE_NOTIF_PACKET_BEGIN, .stream = src_stream1, .packet = src_stream1_packet2, },
- { .type = TEST_EV_TYPE_NOTIF_PACKET_END, .stream = src_stream1, .packet = src_stream1_packet2, },
- { .type = TEST_EV_TYPE_NOTIF_STREAM_END, .stream = src_stream1, .packet = NULL, },
- { .type = TEST_EV_TYPE_END, },
- { .type = TEST_EV_TYPE_SENTINEL, },
- };
-
- do_std_test(TEST_AUTO_PACKET_END_FROM_PACKET_BEGIN,
- "automatic \"packet end\" notif. caused by \"packet begin\" notif.",
- expected_test_events);
-}
-
-static
-void test_auto_packet_end_packet_begin_from_event(void)
-{
- const struct test_event expected_test_events[] = {
- { .type = TEST_EV_TYPE_NOTIF_STREAM_BEGIN, .stream = src_stream1, .packet = NULL, },
- { .type = TEST_EV_TYPE_NOTIF_PACKET_BEGIN, .stream = src_stream1, .packet = src_stream1_packet1, },
- { .type = TEST_EV_TYPE_NOTIF_PACKET_END, .stream = src_stream1, .packet = src_stream1_packet1, },
- { .type = TEST_EV_TYPE_NOTIF_PACKET_BEGIN, .stream = src_stream1, .packet = src_stream1_packet2, },
- { .type = TEST_EV_TYPE_NOTIF_EVENT, .stream = src_stream1, .packet = src_stream1_packet2, },
- { .type = TEST_EV_TYPE_NOTIF_PACKET_END, .stream = src_stream1, .packet = src_stream1_packet2, },
- { .type = TEST_EV_TYPE_NOTIF_STREAM_END, .stream = src_stream1, .packet = NULL, },
- { .type = TEST_EV_TYPE_END, },
- { .type = TEST_EV_TYPE_SENTINEL, },
- };
-
- do_std_test(TEST_AUTO_PACKET_END_PACKET_BEGIN_FROM_EVENT,
- "automatic \"packet end\" and \"packet begin\" notifs. caused by event notif.",
- expected_test_events);
-}
-
-static
-void test_auto_packet_end_from_stream_end(void)
-{
- const struct test_event expected_test_events[] = {
- { .type = TEST_EV_TYPE_NOTIF_STREAM_BEGIN, .stream = src_stream1, .packet = NULL, },
- { .type = TEST_EV_TYPE_NOTIF_PACKET_BEGIN, .stream = src_stream1, .packet = src_stream1_packet1, },
- { .type = TEST_EV_TYPE_NOTIF_PACKET_END, .stream = src_stream1, .packet = src_stream1_packet1, },
- { .type = TEST_EV_TYPE_NOTIF_STREAM_END, .stream = src_stream1, .packet = NULL, },
- { .type = TEST_EV_TYPE_END, },
- { .type = TEST_EV_TYPE_SENTINEL, },
- };
-
- do_std_test(TEST_AUTO_PACKET_END_FROM_STREAM_END,
- "automatic \"packet end\" notif. caused by \"stream end\" notif.",
- expected_test_events);
-}
-
-static
-void test_auto_packet_end_stream_end_from_end(void)
-{
- const struct test_event expected_test_events[] = {
- { .type = TEST_EV_TYPE_NOTIF_STREAM_BEGIN, .stream = src_stream1, .packet = NULL, },
- { .type = TEST_EV_TYPE_NOTIF_PACKET_BEGIN, .stream = src_stream1, .packet = src_stream1_packet1, },
- { .type = TEST_EV_TYPE_NOTIF_PACKET_END, .stream = src_stream1, .packet = src_stream1_packet1, },
- { .type = TEST_EV_TYPE_NOTIF_STREAM_END, .stream = src_stream1, .packet = NULL, },
- { .type = TEST_EV_TYPE_END, },
- { .type = TEST_EV_TYPE_SENTINEL, },
- };
-
- do_std_test(TEST_AUTO_PACKET_END_STREAM_END_FROM_END,
- "automatic \"packet end\" and \"stream end\" notifs. caused by BT_NOTIFICATION_ITERATOR_STATUS_END",
- expected_test_events);
-}
-
-static
-void test_multiple_auto_stream_end_from_end(void)
-{
- bool expected = true;
- struct test_event expected_event;
- struct test_event expected_event2;
- struct test_event *event;
- struct test_event *event2;
-
- do_std_test(TEST_MULTIPLE_AUTO_STREAM_END_FROM_END,
- "multiple automatic \"stream end\" notifs. caused by BT_NOTIFICATION_ITERATOR_STATUS_END",
- NULL);
-
- if (test_events->len != 5) {
- expected = false;
- goto end;
- }
-
- expected_event.type = TEST_EV_TYPE_NOTIF_STREAM_BEGIN;
- expected_event.stream = src_stream1;
- expected_event.packet = NULL;
- event = &g_array_index(test_events, struct test_event, 0);
- if (!compare_single_test_events(event, &expected_event)) {
- expected = false;
- goto end;
- }
-
- expected_event.type = TEST_EV_TYPE_NOTIF_STREAM_BEGIN;
- expected_event.stream = src_stream2;
- expected_event.packet = NULL;
- event = &g_array_index(test_events, struct test_event, 1);
- if (!compare_single_test_events(event, &expected_event)) {
- expected = false;
- goto end;
- }
-
- expected_event.type = TEST_EV_TYPE_NOTIF_STREAM_END;
- expected_event.stream = src_stream1;
- expected_event.packet = NULL;
- expected_event2.type = TEST_EV_TYPE_NOTIF_STREAM_END;
- expected_event2.stream = src_stream2;
- expected_event2.packet = NULL;
- event = &g_array_index(test_events, struct test_event, 2);
- event2 = &g_array_index(test_events, struct test_event, 3);
- if (!(compare_single_test_events(event, &expected_event) &&
- compare_single_test_events(event2, &expected_event2)) &&
- !(compare_single_test_events(event2, &expected_event) &&
- compare_single_test_events(event, &expected_event2))) {
- expected = false;
- goto end;
- }
-
- expected_event.type = TEST_EV_TYPE_END;
- expected_event.stream = NULL;
- expected_event.packet = NULL;
- event = &g_array_index(test_events, struct test_event, 4);
- if (!compare_single_test_events(event, &expected_event)) {
- expected = false;
- goto end;
- }
-
-end:
- ok(expected,
- "the produced sequence of test events is the expected one");
-}
-
-static
-void test_multiple_auto_packet_end_stream_end_from_end(void)
-{
- bool expected = true;
- struct test_event expected_event;
- struct test_event expected_event2;
- struct test_event *event;
- struct test_event *event2;
-
- do_std_test(TEST_MULTIPLE_AUTO_PACKET_END_STREAM_END_FROM_END,
- "multiple automatic \"packet end\" and \"stream end\" notifs. caused by BT_NOTIFICATION_ITERATOR_STATUS_END",
- NULL);
-
- if (test_events->len != 9) {
- expected = false;
- goto end;
- }
-
- expected_event.type = TEST_EV_TYPE_NOTIF_STREAM_BEGIN;
- expected_event.stream = src_stream1;
- expected_event.packet = NULL;
- event = &g_array_index(test_events, struct test_event, 0);
- if (!compare_single_test_events(event, &expected_event)) {
- expected = false;
- goto end;
- }
-
- expected_event.type = TEST_EV_TYPE_NOTIF_STREAM_BEGIN;
- expected_event.stream = src_stream2;
- expected_event.packet = NULL;
- event = &g_array_index(test_events, struct test_event, 1);
- if (!compare_single_test_events(event, &expected_event)) {
- expected = false;
- goto end;
- }
-
- expected_event.type = TEST_EV_TYPE_NOTIF_PACKET_BEGIN;
- expected_event.stream = src_stream1;
- expected_event.packet = src_stream1_packet1;
- event = &g_array_index(test_events, struct test_event, 2);
- if (!compare_single_test_events(event, &expected_event)) {
- expected = false;
- goto end;
- }
-
- expected_event.type = TEST_EV_TYPE_NOTIF_PACKET_BEGIN;
- expected_event.stream = src_stream2;
- expected_event.packet = src_stream2_packet1;
- event = &g_array_index(test_events, struct test_event, 3);
- if (!compare_single_test_events(event, &expected_event)) {
- expected = false;
- goto end;
- }
-
- expected_event.type = TEST_EV_TYPE_NOTIF_PACKET_END;
- expected_event.stream = src_stream1;
- expected_event.packet = src_stream1_packet1;
- expected_event2.type = TEST_EV_TYPE_NOTIF_PACKET_END;
- expected_event2.stream = src_stream2;
- expected_event2.packet = src_stream2_packet1;
- event = &g_array_index(test_events, struct test_event, 4);
- event2 = &g_array_index(test_events, struct test_event, 6);
- if (!(compare_single_test_events(event, &expected_event) &&
- compare_single_test_events(event2, &expected_event2)) &&
- !(compare_single_test_events(event2, &expected_event) &&
- compare_single_test_events(event, &expected_event2))) {
- expected = false;
- goto end;
- }
-
- expected_event.type = TEST_EV_TYPE_NOTIF_STREAM_END;
- expected_event.stream = src_stream1;
- expected_event.packet = NULL;
- expected_event2.type = TEST_EV_TYPE_NOTIF_STREAM_END;
- expected_event2.stream = src_stream2;
- expected_event2.packet = NULL;
- event = &g_array_index(test_events, struct test_event, 5);
- event2 = &g_array_index(test_events, struct test_event, 7);
- if (!(compare_single_test_events(event, &expected_event) &&
- compare_single_test_events(event2, &expected_event2)) &&
- !(compare_single_test_events(event2, &expected_event) &&
- compare_single_test_events(event, &expected_event2))) {
- expected = false;
- goto end;
- }
-
- expected_event.type = TEST_EV_TYPE_END;
- expected_event.stream = NULL;
- expected_event.packet = NULL;
- event = &g_array_index(test_events, struct test_event, 8);
- if (!compare_single_test_events(event, &expected_event)) {
- expected = false;
- goto end;
- }
-
-end:
- ok(expected,
- "the produced sequence of test events is the expected one");
-}
-