Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
tests: remove aio_context_acquire() tests
The aio_context_acquire() API is being removed. Drop the test case that
calls the API.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Message-ID: <20231205182011.1976568-4-stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
  • Loading branch information
Stefan Hajnoczi authored and Kevin Wolf committed Dec 21, 2023
1 parent 10bcb0d commit b3496d1
Showing 1 changed file with 1 addition and 66 deletions.
67 changes: 1 addition & 66 deletions tests/unit/test-aio.c
Expand Up @@ -100,76 +100,12 @@ static void event_ready_cb(EventNotifier *e)

/* Tests using aio_*. */

typedef struct {
QemuMutex start_lock;
EventNotifier notifier;
bool thread_acquired;
} AcquireTestData;

static void *test_acquire_thread(void *opaque)
{
AcquireTestData *data = opaque;

/* Wait for other thread to let us start */
qemu_mutex_lock(&data->start_lock);
qemu_mutex_unlock(&data->start_lock);

/* event_notifier_set might be called either before or after
* the main thread's call to poll(). The test case's outcome
* should be the same in either case.
*/
event_notifier_set(&data->notifier);
aio_context_acquire(ctx);
aio_context_release(ctx);

data->thread_acquired = true; /* success, we got here */

return NULL;
}

static void set_event_notifier(AioContext *nctx, EventNotifier *notifier,
EventNotifierHandler *handler)
{
aio_set_event_notifier(nctx, notifier, handler, NULL, NULL);
}

static void dummy_notifier_read(EventNotifier *n)
{
event_notifier_test_and_clear(n);
}

static void test_acquire(void)
{
QemuThread thread;
AcquireTestData data;

/* Dummy event notifier ensures aio_poll() will block */
event_notifier_init(&data.notifier, false);
set_event_notifier(ctx, &data.notifier, dummy_notifier_read);
g_assert(!aio_poll(ctx, false)); /* consume aio_notify() */

qemu_mutex_init(&data.start_lock);
qemu_mutex_lock(&data.start_lock);
data.thread_acquired = false;

qemu_thread_create(&thread, "test_acquire_thread",
test_acquire_thread,
&data, QEMU_THREAD_JOINABLE);

/* Block in aio_poll(), let other thread kick us and acquire context */
aio_context_acquire(ctx);
qemu_mutex_unlock(&data.start_lock); /* let the thread run */
g_assert(aio_poll(ctx, true));
g_assert(!data.thread_acquired);
aio_context_release(ctx);

qemu_thread_join(&thread);
set_event_notifier(ctx, &data.notifier, NULL);
event_notifier_cleanup(&data.notifier);

g_assert(data.thread_acquired);
}

static void test_bh_schedule(void)
{
BHTestData data = { .n = 0 };
Expand Down Expand Up @@ -879,7 +815,7 @@ static void test_worker_thread_co_enter(void)
qemu_thread_get_self(&this_thread);
co = qemu_coroutine_create(co_check_current_thread, &this_thread);

qemu_thread_create(&worker_thread, "test_acquire_thread",
qemu_thread_create(&worker_thread, "test_aio_co_enter",
test_aio_co_enter,
co, QEMU_THREAD_JOINABLE);

Expand All @@ -899,7 +835,6 @@ int main(int argc, char **argv)
while (g_main_context_iteration(NULL, false));

g_test_init(&argc, &argv, NULL);
g_test_add_func("/aio/acquire", test_acquire);
g_test_add_func("/aio/bh/schedule", test_bh_schedule);
g_test_add_func("/aio/bh/schedule10", test_bh_schedule10);
g_test_add_func("/aio/bh/cancel", test_bh_cancel);
Expand Down

0 comments on commit b3496d1

Please sign in to comment.