tests/blockjob: replace Blockjob with Job
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>
This commit is contained in:
parent
1b57488acf
commit
0cc4643b01
|
@ -206,18 +206,20 @@ static const BlockJobDriver test_cancel_driver = {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
static CancelJob *create_common(BlockJob **pjob)
|
static CancelJob *create_common(Job **pjob)
|
||||||
{
|
{
|
||||||
BlockBackend *blk;
|
BlockBackend *blk;
|
||||||
BlockJob *job;
|
Job *job;
|
||||||
|
BlockJob *bjob;
|
||||||
CancelJob *s;
|
CancelJob *s;
|
||||||
|
|
||||||
blk = create_blk(NULL);
|
blk = create_blk(NULL);
|
||||||
job = mk_job(blk, "Steve", &test_cancel_driver, true,
|
bjob = mk_job(blk, "Steve", &test_cancel_driver, true,
|
||||||
JOB_MANUAL_FINALIZE | JOB_MANUAL_DISMISS);
|
JOB_MANUAL_FINALIZE | JOB_MANUAL_DISMISS);
|
||||||
job_ref(&job->job);
|
job = &bjob->job;
|
||||||
assert(job->job.status == JOB_STATUS_CREATED);
|
job_ref(job);
|
||||||
s = container_of(job, CancelJob, common);
|
assert(job->status == JOB_STATUS_CREATED);
|
||||||
|
s = container_of(bjob, CancelJob, common);
|
||||||
s->blk = blk;
|
s->blk = blk;
|
||||||
|
|
||||||
*pjob = job;
|
*pjob = job;
|
||||||
|
@ -242,7 +244,7 @@ static void cancel_common(CancelJob *s)
|
||||||
|
|
||||||
static void test_cancel_created(void)
|
static void test_cancel_created(void)
|
||||||
{
|
{
|
||||||
BlockJob *job;
|
Job *job;
|
||||||
CancelJob *s;
|
CancelJob *s;
|
||||||
|
|
||||||
s = create_common(&job);
|
s = create_common(&job);
|
||||||
|
@ -251,119 +253,119 @@ static void test_cancel_created(void)
|
||||||
|
|
||||||
static void test_cancel_running(void)
|
static void test_cancel_running(void)
|
||||||
{
|
{
|
||||||
BlockJob *job;
|
Job *job;
|
||||||
CancelJob *s;
|
CancelJob *s;
|
||||||
|
|
||||||
s = create_common(&job);
|
s = create_common(&job);
|
||||||
|
|
||||||
job_start(&job->job);
|
job_start(job);
|
||||||
assert(job->job.status == JOB_STATUS_RUNNING);
|
assert(job->status == JOB_STATUS_RUNNING);
|
||||||
|
|
||||||
cancel_common(s);
|
cancel_common(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_cancel_paused(void)
|
static void test_cancel_paused(void)
|
||||||
{
|
{
|
||||||
BlockJob *job;
|
Job *job;
|
||||||
CancelJob *s;
|
CancelJob *s;
|
||||||
|
|
||||||
s = create_common(&job);
|
s = create_common(&job);
|
||||||
|
|
||||||
job_start(&job->job);
|
job_start(job);
|
||||||
assert(job->job.status == JOB_STATUS_RUNNING);
|
assert(job->status == JOB_STATUS_RUNNING);
|
||||||
|
|
||||||
job_user_pause(&job->job, &error_abort);
|
job_user_pause(job, &error_abort);
|
||||||
job_enter(&job->job);
|
job_enter(job);
|
||||||
assert(job->job.status == JOB_STATUS_PAUSED);
|
assert(job->status == JOB_STATUS_PAUSED);
|
||||||
|
|
||||||
cancel_common(s);
|
cancel_common(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_cancel_ready(void)
|
static void test_cancel_ready(void)
|
||||||
{
|
{
|
||||||
BlockJob *job;
|
Job *job;
|
||||||
CancelJob *s;
|
CancelJob *s;
|
||||||
|
|
||||||
s = create_common(&job);
|
s = create_common(&job);
|
||||||
|
|
||||||
job_start(&job->job);
|
job_start(job);
|
||||||
assert(job->job.status == JOB_STATUS_RUNNING);
|
assert(job->status == JOB_STATUS_RUNNING);
|
||||||
|
|
||||||
s->should_converge = true;
|
s->should_converge = true;
|
||||||
job_enter(&job->job);
|
job_enter(job);
|
||||||
assert(job->job.status == JOB_STATUS_READY);
|
assert(job->status == JOB_STATUS_READY);
|
||||||
|
|
||||||
cancel_common(s);
|
cancel_common(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_cancel_standby(void)
|
static void test_cancel_standby(void)
|
||||||
{
|
{
|
||||||
BlockJob *job;
|
Job *job;
|
||||||
CancelJob *s;
|
CancelJob *s;
|
||||||
|
|
||||||
s = create_common(&job);
|
s = create_common(&job);
|
||||||
|
|
||||||
job_start(&job->job);
|
job_start(job);
|
||||||
assert(job->job.status == JOB_STATUS_RUNNING);
|
assert(job->status == JOB_STATUS_RUNNING);
|
||||||
|
|
||||||
s->should_converge = true;
|
s->should_converge = true;
|
||||||
job_enter(&job->job);
|
job_enter(job);
|
||||||
assert(job->job.status == JOB_STATUS_READY);
|
assert(job->status == JOB_STATUS_READY);
|
||||||
|
|
||||||
job_user_pause(&job->job, &error_abort);
|
job_user_pause(job, &error_abort);
|
||||||
job_enter(&job->job);
|
job_enter(job);
|
||||||
assert(job->job.status == JOB_STATUS_STANDBY);
|
assert(job->status == JOB_STATUS_STANDBY);
|
||||||
|
|
||||||
cancel_common(s);
|
cancel_common(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_cancel_pending(void)
|
static void test_cancel_pending(void)
|
||||||
{
|
{
|
||||||
BlockJob *job;
|
Job *job;
|
||||||
CancelJob *s;
|
CancelJob *s;
|
||||||
|
|
||||||
s = create_common(&job);
|
s = create_common(&job);
|
||||||
|
|
||||||
job_start(&job->job);
|
job_start(job);
|
||||||
assert(job->job.status == JOB_STATUS_RUNNING);
|
assert(job->status == JOB_STATUS_RUNNING);
|
||||||
|
|
||||||
s->should_converge = true;
|
s->should_converge = true;
|
||||||
job_enter(&job->job);
|
job_enter(job);
|
||||||
assert(job->job.status == JOB_STATUS_READY);
|
assert(job->status == JOB_STATUS_READY);
|
||||||
|
|
||||||
job_complete(&job->job, &error_abort);
|
job_complete(job, &error_abort);
|
||||||
job_enter(&job->job);
|
job_enter(job);
|
||||||
while (!s->completed) {
|
while (!s->completed) {
|
||||||
aio_poll(qemu_get_aio_context(), true);
|
aio_poll(qemu_get_aio_context(), true);
|
||||||
}
|
}
|
||||||
assert(job->job.status == JOB_STATUS_PENDING);
|
assert(job->status == JOB_STATUS_PENDING);
|
||||||
|
|
||||||
cancel_common(s);
|
cancel_common(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_cancel_concluded(void)
|
static void test_cancel_concluded(void)
|
||||||
{
|
{
|
||||||
BlockJob *job;
|
Job *job;
|
||||||
CancelJob *s;
|
CancelJob *s;
|
||||||
|
|
||||||
s = create_common(&job);
|
s = create_common(&job);
|
||||||
|
|
||||||
job_start(&job->job);
|
job_start(job);
|
||||||
assert(job->job.status == JOB_STATUS_RUNNING);
|
assert(job->status == JOB_STATUS_RUNNING);
|
||||||
|
|
||||||
s->should_converge = true;
|
s->should_converge = true;
|
||||||
job_enter(&job->job);
|
job_enter(job);
|
||||||
assert(job->job.status == JOB_STATUS_READY);
|
assert(job->status == JOB_STATUS_READY);
|
||||||
|
|
||||||
job_complete(&job->job, &error_abort);
|
job_complete(job, &error_abort);
|
||||||
job_enter(&job->job);
|
job_enter(job);
|
||||||
while (!s->completed) {
|
while (!s->completed) {
|
||||||
aio_poll(qemu_get_aio_context(), true);
|
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);
|
job_finalize(job, &error_abort);
|
||||||
assert(job->job.status == JOB_STATUS_CONCLUDED);
|
assert(job->status == JOB_STATUS_CONCLUDED);
|
||||||
|
|
||||||
cancel_common(s);
|
cancel_common(s);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue