ae23c9
From 3c31c95203eefe5c58eb53bed04c804c8a2984ce Mon Sep 17 00:00:00 2001
ae23c9
From: John Snow <jsnow@redhat.com>
ae23c9
Date: Tue, 25 Sep 2018 22:34:23 +0100
ae23c9
Subject: [PATCH 20/28] tests/blockjob: replace Blockjob with Job
ae23c9
ae23c9
RH-Author: John Snow <jsnow@redhat.com>
ae23c9
Message-id: <20180925223431.24791-18-jsnow@redhat.com>
ae23c9
Patchwork-id: 82281
ae23c9
O-Subject: [RHEL8/rhel qemu-kvm PATCH 17/25] tests/blockjob: replace Blockjob with Job
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
These tests don't actually test blockjobs anymore, they test
ae23c9
generic Job lifetimes. Change the types accordingly.
ae23c9
ae23c9
Signed-off-by: John Snow <jsnow@redhat.com>
ae23c9
Reviewed-by: Max Reitz <mreitz@redhat.com>
ae23c9
Message-id: 20180906130225.5118-9-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 0cc4643b01a0138543e886db8e3bf8a3f74ff8f9)
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 | 98 ++++++++++++++++++++++++++-------------------------
ae23c9
 1 file changed, 50 insertions(+), 48 deletions(-)
ae23c9
ae23c9
diff --git a/tests/test-blockjob.c b/tests/test-blockjob.c
ae23c9
index ad4a65b..8e8b680 100644
ae23c9
--- a/tests/test-blockjob.c
ae23c9
+++ b/tests/test-blockjob.c
ae23c9
@@ -206,18 +206,20 @@ static const BlockJobDriver test_cancel_driver = {
ae23c9
     },
ae23c9
 };
ae23c9
 
ae23c9
-static CancelJob *create_common(BlockJob **pjob)
ae23c9
+static CancelJob *create_common(Job **pjob)
ae23c9
 {
ae23c9
     BlockBackend *blk;
ae23c9
-    BlockJob *job;
ae23c9
+    Job *job;
ae23c9
+    BlockJob *bjob;
ae23c9
     CancelJob *s;
ae23c9
 
ae23c9
     blk = create_blk(NULL);
ae23c9
-    job = mk_job(blk, "Steve", &test_cancel_driver, true,
ae23c9
-                 JOB_MANUAL_FINALIZE | JOB_MANUAL_DISMISS);
ae23c9
-    job_ref(&job->job);
ae23c9
-    assert(job->job.status == JOB_STATUS_CREATED);
ae23c9
-    s = container_of(job, CancelJob, common);
ae23c9
+    bjob = mk_job(blk, "Steve", &test_cancel_driver, true,
ae23c9
+                  JOB_MANUAL_FINALIZE | JOB_MANUAL_DISMISS);
ae23c9
+    job = &bjob->job;
ae23c9
+    job_ref(job);
ae23c9
+    assert(job->status == JOB_STATUS_CREATED);
ae23c9
+    s = container_of(bjob, CancelJob, common);
ae23c9
     s->blk = blk;
ae23c9
 
ae23c9
     *pjob = job;
ae23c9
@@ -242,7 +244,7 @@ static void cancel_common(CancelJob *s)
ae23c9
 
ae23c9
 static void test_cancel_created(void)
ae23c9
 {
ae23c9
-    BlockJob *job;
ae23c9
+    Job *job;
ae23c9
     CancelJob *s;
ae23c9
 
ae23c9
     s = create_common(&job;;
ae23c9
@@ -251,119 +253,119 @@ static void test_cancel_created(void)
ae23c9
 
ae23c9
 static void test_cancel_running(void)
ae23c9
 {
ae23c9
-    BlockJob *job;
ae23c9
+    Job *job;
ae23c9
     CancelJob *s;
ae23c9
 
ae23c9
     s = create_common(&job;;
ae23c9
 
ae23c9
-    job_start(&job->job);
ae23c9
-    assert(job->job.status == JOB_STATUS_RUNNING);
ae23c9
+    job_start(job);
ae23c9
+    assert(job->status == JOB_STATUS_RUNNING);
ae23c9
 
ae23c9
     cancel_common(s);
ae23c9
 }
ae23c9
 
ae23c9
 static void test_cancel_paused(void)
ae23c9
 {
ae23c9
-    BlockJob *job;
ae23c9
+    Job *job;
ae23c9
     CancelJob *s;
ae23c9
 
ae23c9
     s = create_common(&job;;
ae23c9
 
ae23c9
-    job_start(&job->job);
ae23c9
-    assert(job->job.status == JOB_STATUS_RUNNING);
ae23c9
+    job_start(job);
ae23c9
+    assert(job->status == JOB_STATUS_RUNNING);
ae23c9
 
ae23c9
-    job_user_pause(&job->job, &error_abort);
ae23c9
-    job_enter(&job->job);
ae23c9
-    assert(job->job.status == JOB_STATUS_PAUSED);
ae23c9
+    job_user_pause(job, &error_abort);
ae23c9
+    job_enter(job);
ae23c9
+    assert(job->status == JOB_STATUS_PAUSED);
ae23c9
 
ae23c9
     cancel_common(s);
ae23c9
 }
ae23c9
 
ae23c9
 static void test_cancel_ready(void)
ae23c9
 {
ae23c9
-    BlockJob *job;
ae23c9
+    Job *job;
ae23c9
     CancelJob *s;
ae23c9
 
ae23c9
     s = create_common(&job;;
ae23c9
 
ae23c9
-    job_start(&job->job);
ae23c9
-    assert(job->job.status == JOB_STATUS_RUNNING);
ae23c9
+    job_start(job);
ae23c9
+    assert(job->status == JOB_STATUS_RUNNING);
ae23c9
 
ae23c9
     s->should_converge = true;
ae23c9
-    job_enter(&job->job);
ae23c9
-    assert(job->job.status == JOB_STATUS_READY);
ae23c9
+    job_enter(job);
ae23c9
+    assert(job->status == JOB_STATUS_READY);
ae23c9
 
ae23c9
     cancel_common(s);
ae23c9
 }
ae23c9
 
ae23c9
 static void test_cancel_standby(void)
ae23c9
 {
ae23c9
-    BlockJob *job;
ae23c9
+    Job *job;
ae23c9
     CancelJob *s;
ae23c9
 
ae23c9
     s = create_common(&job;;
ae23c9
 
ae23c9
-    job_start(&job->job);
ae23c9
-    assert(job->job.status == JOB_STATUS_RUNNING);
ae23c9
+    job_start(job);
ae23c9
+    assert(job->status == JOB_STATUS_RUNNING);
ae23c9
 
ae23c9
     s->should_converge = true;
ae23c9
-    job_enter(&job->job);
ae23c9
-    assert(job->job.status == JOB_STATUS_READY);
ae23c9
+    job_enter(job);
ae23c9
+    assert(job->status == JOB_STATUS_READY);
ae23c9
 
ae23c9
-    job_user_pause(&job->job, &error_abort);
ae23c9
-    job_enter(&job->job);
ae23c9
-    assert(job->job.status == JOB_STATUS_STANDBY);
ae23c9
+    job_user_pause(job, &error_abort);
ae23c9
+    job_enter(job);
ae23c9
+    assert(job->status == JOB_STATUS_STANDBY);
ae23c9
 
ae23c9
     cancel_common(s);
ae23c9
 }
ae23c9
 
ae23c9
 static void test_cancel_pending(void)
ae23c9
 {
ae23c9
-    BlockJob *job;
ae23c9
+    Job *job;
ae23c9
     CancelJob *s;
ae23c9
 
ae23c9
     s = create_common(&job;;
ae23c9
 
ae23c9
-    job_start(&job->job);
ae23c9
-    assert(job->job.status == JOB_STATUS_RUNNING);
ae23c9
+    job_start(job);
ae23c9
+    assert(job->status == JOB_STATUS_RUNNING);
ae23c9
 
ae23c9
     s->should_converge = true;
ae23c9
-    job_enter(&job->job);
ae23c9
-    assert(job->job.status == JOB_STATUS_READY);
ae23c9
+    job_enter(job);
ae23c9
+    assert(job->status == JOB_STATUS_READY);
ae23c9
 
ae23c9
-    job_complete(&job->job, &error_abort);
ae23c9
-    job_enter(&job->job);
ae23c9
+    job_complete(job, &error_abort);
ae23c9
+    job_enter(job);
ae23c9
     while (!s->completed) {
ae23c9
         aio_poll(qemu_get_aio_context(), true);
ae23c9
     }
ae23c9
-    assert(job->job.status == JOB_STATUS_PENDING);
ae23c9
+    assert(job->status == JOB_STATUS_PENDING);
ae23c9
 
ae23c9
     cancel_common(s);
ae23c9
 }
ae23c9
 
ae23c9
 static void test_cancel_concluded(void)
ae23c9
 {
ae23c9
-    BlockJob *job;
ae23c9
+    Job *job;
ae23c9
     CancelJob *s;
ae23c9
 
ae23c9
     s = create_common(&job;;
ae23c9
 
ae23c9
-    job_start(&job->job);
ae23c9
-    assert(job->job.status == JOB_STATUS_RUNNING);
ae23c9
+    job_start(job);
ae23c9
+    assert(job->status == JOB_STATUS_RUNNING);
ae23c9
 
ae23c9
     s->should_converge = true;
ae23c9
-    job_enter(&job->job);
ae23c9
-    assert(job->job.status == JOB_STATUS_READY);
ae23c9
+    job_enter(job);
ae23c9
+    assert(job->status == JOB_STATUS_READY);
ae23c9
 
ae23c9
-    job_complete(&job->job, &error_abort);
ae23c9
-    job_enter(&job->job);
ae23c9
+    job_complete(job, &error_abort);
ae23c9
+    job_enter(job);
ae23c9
     while (!s->completed) {
ae23c9
         aio_poll(qemu_get_aio_context(), true);
ae23c9
     }
ae23c9
-    assert(job->job.status == JOB_STATUS_PENDING);
ae23c9
+    assert(job->status == JOB_STATUS_PENDING);
ae23c9
 
ae23c9
-    job_finalize(&job->job, &error_abort);
ae23c9
-    assert(job->job.status == JOB_STATUS_CONCLUDED);
ae23c9
+    job_finalize(job, &error_abort);
ae23c9
+    assert(job->status == JOB_STATUS_CONCLUDED);
ae23c9
 
ae23c9
     cancel_common(s);
ae23c9
 }
ae23c9
-- 
ae23c9
1.8.3.1
ae23c9