qemu-kvm/SOURCES/kvm-tests-blockjob-replace-Blockjob-with-Job.patch

234 lines
6.2 KiB
Diff

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