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