diff options
author | Kevin Wolf <kwolf@redhat.com> | 2018-04-13 17:31:02 +0200 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2018-05-23 14:30:50 +0200 |
commit | da01ff7f38f52791f93fc3ca59afcfbb220f15af (patch) | |
tree | 74010498c6229085ce3f2cc2184168aec5fb99f8 /tests | |
parent | 1908a5590c7d214b1b6886bc19b81076fb65cec9 (diff) |
job: Move coroutine and related code to Job
This commit moves some core functions for dealing with the job coroutine
from BlockJob to Job. This includes primarily entering the coroutine
(both for the first and reentering) and yielding explicitly and at pause
points.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: John Snow <jsnow@redhat.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test-bdrv-drain.c | 38 | ||||
-rw-r--r-- | tests/test-blockjob-txn.c | 12 | ||||
-rw-r--r-- | tests/test-blockjob.c | 14 |
3 files changed, 32 insertions, 32 deletions
diff --git a/tests/test-bdrv-drain.c b/tests/test-bdrv-drain.c index 4f8cba8377..c9f2f9b183 100644 --- a/tests/test-bdrv-drain.c +++ b/tests/test-bdrv-drain.c @@ -524,8 +524,8 @@ BlockJobDriver test_job_driver = { .job_driver = { .instance_size = sizeof(TestBlockJob), .free = block_job_free, + .start = test_job_start, }, - .start = test_job_start, .complete = test_job_complete, }; @@ -549,47 +549,47 @@ static void test_blockjob_common(enum drain_type drain_type) job = block_job_create("job0", &test_job_driver, NULL, src, 0, BLK_PERM_ALL, 0, 0, NULL, NULL, &error_abort); block_job_add_bdrv(job, "target", target, 0, BLK_PERM_ALL, &error_abort); - block_job_start(job); + job_start(&job->job); - g_assert_cmpint(job->pause_count, ==, 0); - g_assert_false(job->paused); - g_assert_false(job->busy); /* We're in block_job_sleep_ns() */ + g_assert_cmpint(job->job.pause_count, ==, 0); + g_assert_false(job->job.paused); + g_assert_false(job->job.busy); /* We're in block_job_sleep_ns() */ do_drain_begin(drain_type, src); if (drain_type == BDRV_DRAIN_ALL) { /* bdrv_drain_all() drains both src and target */ - g_assert_cmpint(job->pause_count, ==, 2); + g_assert_cmpint(job->job.pause_count, ==, 2); } else { - g_assert_cmpint(job->pause_count, ==, 1); + g_assert_cmpint(job->job.pause_count, ==, 1); } /* XXX We don't wait until the job is actually paused. Is this okay? */ - /* g_assert_true(job->paused); */ - g_assert_false(job->busy); /* The job is paused */ + /* g_assert_true(job->job.paused); */ + g_assert_false(job->job.busy); /* The job is paused */ do_drain_end(drain_type, src); - g_assert_cmpint(job->pause_count, ==, 0); - g_assert_false(job->paused); - g_assert_false(job->busy); /* We're in block_job_sleep_ns() */ + g_assert_cmpint(job->job.pause_count, ==, 0); + g_assert_false(job->job.paused); + g_assert_false(job->job.busy); /* We're in block_job_sleep_ns() */ do_drain_begin(drain_type, target); if (drain_type == BDRV_DRAIN_ALL) { /* bdrv_drain_all() drains both src and target */ - g_assert_cmpint(job->pause_count, ==, 2); + g_assert_cmpint(job->job.pause_count, ==, 2); } else { - g_assert_cmpint(job->pause_count, ==, 1); + g_assert_cmpint(job->job.pause_count, ==, 1); } /* XXX We don't wait until the job is actually paused. Is this okay? */ - /* g_assert_true(job->paused); */ - g_assert_false(job->busy); /* The job is paused */ + /* g_assert_true(job->job.paused); */ + g_assert_false(job->job.busy); /* The job is paused */ do_drain_end(drain_type, target); - g_assert_cmpint(job->pause_count, ==, 0); - g_assert_false(job->paused); - g_assert_false(job->busy); /* We're in block_job_sleep_ns() */ + g_assert_cmpint(job->job.pause_count, ==, 0); + g_assert_false(job->job.paused); + g_assert_false(job->job.busy); /* We're in block_job_sleep_ns() */ ret = block_job_complete_sync(job, &error_abort); g_assert_cmpint(ret, ==, 0); diff --git a/tests/test-blockjob-txn.c b/tests/test-blockjob-txn.c index c03f9662d8..323e154a00 100644 --- a/tests/test-blockjob-txn.c +++ b/tests/test-blockjob-txn.c @@ -78,8 +78,8 @@ static const BlockJobDriver test_block_job_driver = { .job_driver = { .instance_size = sizeof(TestBlockJob), .free = block_job_free, + .start = test_block_job_run, }, - .start = test_block_job_run, }; /* Create a block job that completes with a given return code after a given @@ -125,7 +125,7 @@ static void test_single_job(int expected) txn = block_job_txn_new(); job = test_block_job_start(1, true, expected, &result, txn); - block_job_start(job); + job_start(&job->job); if (expected == -ECANCELED) { block_job_cancel(job, false); @@ -165,8 +165,8 @@ static void test_pair_jobs(int expected1, int expected2) txn = block_job_txn_new(); job1 = test_block_job_start(1, true, expected1, &result1, txn); job2 = test_block_job_start(2, true, expected2, &result2, txn); - block_job_start(job1); - block_job_start(job2); + job_start(&job1->job); + job_start(&job2->job); /* Release our reference now to trigger as many nice * use-after-free bugs as possible. @@ -227,8 +227,8 @@ static void test_pair_jobs_fail_cancel_race(void) txn = block_job_txn_new(); job1 = test_block_job_start(1, true, -ECANCELED, &result1, txn); job2 = test_block_job_start(2, false, 0, &result2, txn); - block_job_start(job1); - block_job_start(job2); + job_start(&job1->job); + job_start(&job2->job); block_job_cancel(job1, false); diff --git a/tests/test-blockjob.c b/tests/test-blockjob.c index 5f43bd72a4..1d18325feb 100644 --- a/tests/test-blockjob.c +++ b/tests/test-blockjob.c @@ -199,8 +199,8 @@ static const BlockJobDriver test_cancel_driver = { .job_driver = { .instance_size = sizeof(CancelJob), .free = block_job_free, + .start = cancel_job_start, }, - .start = cancel_job_start, .complete = cancel_job_complete, }; @@ -254,7 +254,7 @@ static void test_cancel_running(void) s = create_common(&job); - block_job_start(job); + job_start(&job->job); assert(job->job.status == JOB_STATUS_RUNNING); cancel_common(s); @@ -267,7 +267,7 @@ static void test_cancel_paused(void) s = create_common(&job); - block_job_start(job); + job_start(&job->job); assert(job->job.status == JOB_STATUS_RUNNING); block_job_user_pause(job, &error_abort); @@ -284,7 +284,7 @@ static void test_cancel_ready(void) s = create_common(&job); - block_job_start(job); + job_start(&job->job); assert(job->job.status == JOB_STATUS_RUNNING); s->should_converge = true; @@ -301,7 +301,7 @@ static void test_cancel_standby(void) s = create_common(&job); - block_job_start(job); + job_start(&job->job); assert(job->job.status == JOB_STATUS_RUNNING); s->should_converge = true; @@ -322,7 +322,7 @@ static void test_cancel_pending(void) s = create_common(&job); - block_job_start(job); + job_start(&job->job); assert(job->job.status == JOB_STATUS_RUNNING); s->should_converge = true; @@ -346,7 +346,7 @@ static void test_cancel_concluded(void) s = create_common(&job); - block_job_start(job); + job_start(&job->job); assert(job->job.status == JOB_STATUS_RUNNING); s->should_converge = true; |