Commit c07bc2c1 authored by Fam Zheng's avatar Fam Zheng Committed by Kevin Wolf
Browse files

tests: Add test case for aio_disable_external



Signed-off-by: default avatarFam Zheng <famz@redhat.com>
Reviewed-by: default avatarKevin Wolf <kwolf@redhat.com>
Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
parent 507306cc
Loading
Loading
Loading
Loading
+24 −0
Original line number Diff line number Diff line
@@ -374,6 +374,29 @@ static void test_flush_event_notifier(void)
    event_notifier_cleanup(&data.e);
}

static void test_aio_external_client(void)
{
    int i, j;

    for (i = 1; i < 3; i++) {
        EventNotifierTestData data = { .n = 0, .active = 10, .auto_set = true };
        event_notifier_init(&data.e, false);
        aio_set_event_notifier(ctx, &data.e, true, event_ready_cb);
        event_notifier_set(&data.e);
        for (j = 0; j < i; j++) {
            aio_disable_external(ctx);
        }
        for (j = 0; j < i; j++) {
            assert(!aio_poll(ctx, false));
            assert(event_notifier_test_and_clear(&data.e));
            event_notifier_set(&data.e);
            aio_enable_external(ctx);
        }
        assert(aio_poll(ctx, false));
        event_notifier_cleanup(&data.e);
    }
}

static void test_wait_event_notifier_noflush(void)
{
    EventNotifierTestData data = { .n = 0 };
@@ -832,6 +855,7 @@ int main(int argc, char **argv)
    g_test_add_func("/aio/event/wait",              test_wait_event_notifier);
    g_test_add_func("/aio/event/wait/no-flush-cb",  test_wait_event_notifier_noflush);
    g_test_add_func("/aio/event/flush",             test_flush_event_notifier);
    g_test_add_func("/aio/external-client",         test_aio_external_client);
    g_test_add_func("/aio/timer/schedule",          test_timer_schedule);

    g_test_add_func("/aio-gsource/flush",                   test_source_flush);