提交 0cc4643b 编写于 作者: J John Snow 提交者: Max Reitz

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: NJohn Snow <jsnow@redhat.com>
Reviewed-by: NMax Reitz <mreitz@redhat.com>
Message-id: 20180906130225.5118-9-jsnow@redhat.com
Reviewed-by: NJeff Cody <jcody@redhat.com>
Signed-off-by: NMax Reitz <mreitz@redhat.com>
上级 1b57488a
......@@ -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);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册