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;
|
||||
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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user