ae23c9
From 811f1e5213c0d9cc05ecfe033f6409f261355d56 Mon Sep 17 00:00:00 2001
ae23c9
From: John Snow <jsnow@redhat.com>
ae23c9
Date: Tue, 25 Sep 2018 22:34:24 +0100
ae23c9
Subject: [PATCH 21/28] tests/test-blockjob: remove exit callback
ae23c9
ae23c9
RH-Author: John Snow <jsnow@redhat.com>
ae23c9
Message-id: <20180925223431.24791-19-jsnow@redhat.com>
ae23c9
Patchwork-id: 82276
ae23c9
O-Subject: [RHEL8/rhel qemu-kvm PATCH 18/25] tests/test-blockjob: remove exit callback
ae23c9
Bugzilla: 1632939
ae23c9
RH-Acked-by: Jeffrey Cody <jcody@redhat.com>
ae23c9
RH-Acked-by: Max Reitz <mreitz@redhat.com>
ae23c9
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
ae23c9
ae23c9
We remove the exit callback and the completed boolean along with it.
ae23c9
We can simulate it just fine by waiting for the job to defer to the
ae23c9
main loop, and then giving it one final kick to get the main loop
ae23c9
portion to run.
ae23c9
ae23c9
Signed-off-by: John Snow <jsnow@redhat.com>
ae23c9
Reviewed-by: Max Reitz <mreitz@redhat.com>
ae23c9
Message-id: 20180906130225.5118-10-jsnow@redhat.com
ae23c9
Reviewed-by: Jeff Cody <jcody@redhat.com>
ae23c9
Signed-off-by: Max Reitz <mreitz@redhat.com>
ae23c9
(cherry picked from commit 977d26fdbeb35d8d2d0f203f9556d44a353e0dfd)
ae23c9
Signed-off-by: John Snow <jsnow@redhat.com>
ae23c9
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
ae23c9
---
ae23c9
 tests/test-blockjob.c | 16 ++++++----------
ae23c9
 1 file changed, 6 insertions(+), 10 deletions(-)
ae23c9
ae23c9
diff --git a/tests/test-blockjob.c b/tests/test-blockjob.c
ae23c9
index 8e8b680..de4c1c2 100644
ae23c9
--- a/tests/test-blockjob.c
ae23c9
+++ b/tests/test-blockjob.c
ae23c9
@@ -160,15 +160,8 @@ typedef struct CancelJob {
ae23c9
     BlockBackend *blk;
ae23c9
     bool should_converge;
ae23c9
     bool should_complete;
ae23c9
-    bool completed;
ae23c9
 } CancelJob;
ae23c9
 
ae23c9
-static void cancel_job_exit(Job *job)
ae23c9
-{
ae23c9
-    CancelJob *s = container_of(job, CancelJob, common.job);
ae23c9
-    s->completed = true;
ae23c9
-}
ae23c9
-
ae23c9
 static void cancel_job_complete(Job *job, Error **errp)
ae23c9
 {
ae23c9
     CancelJob *s = container_of(job, CancelJob, common.job);
ae23c9
@@ -201,7 +194,6 @@ static const BlockJobDriver test_cancel_driver = {
ae23c9
         .user_resume   = block_job_user_resume,
ae23c9
         .drain         = block_job_drain,
ae23c9
         .run           = cancel_job_run,
ae23c9
-        .exit          = cancel_job_exit,
ae23c9
         .complete      = cancel_job_complete,
ae23c9
     },
ae23c9
 };
ae23c9
@@ -335,9 +327,11 @@ static void test_cancel_pending(void)
ae23c9
 
ae23c9
     job_complete(job, &error_abort);
ae23c9
     job_enter(job);
ae23c9
-    while (!s->completed) {
ae23c9
+    while (!job->deferred_to_main_loop) {
ae23c9
         aio_poll(qemu_get_aio_context(), true);
ae23c9
     }
ae23c9
+    assert(job->status == JOB_STATUS_READY);
ae23c9
+    aio_poll(qemu_get_aio_context(), true);
ae23c9
     assert(job->status == JOB_STATUS_PENDING);
ae23c9
 
ae23c9
     cancel_common(s);
ae23c9
@@ -359,9 +353,11 @@ static void test_cancel_concluded(void)
ae23c9
 
ae23c9
     job_complete(job, &error_abort);
ae23c9
     job_enter(job);
ae23c9
-    while (!s->completed) {
ae23c9
+    while (!job->deferred_to_main_loop) {
ae23c9
         aio_poll(qemu_get_aio_context(), true);
ae23c9
     }
ae23c9
+    assert(job->status == JOB_STATUS_READY);
ae23c9
+    aio_poll(qemu_get_aio_context(), true);
ae23c9
     assert(job->status == JOB_STATUS_PENDING);
ae23c9
 
ae23c9
     job_finalize(job, &error_abort);
ae23c9
-- 
ae23c9
1.8.3.1
ae23c9