yeahuh / rpms / qemu-kvm

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