On 7/25/22 10:38, Emanuele Giuseppe Esposito wrote:
Add missing job synchronization in the unit tests, with
explicit locks.
We are deliberately using _locked functions wrapped by a guard
instead of a normal call because the normal call will be removed
in future, as the only usage is limited to the tests.
In other words, if a function like job_pause() is/will be only used
in tests to avoid:
WITH_JOB_LOCK_GUARD(){
job_pause_locked();
}
then it is not worth keeping job_pause(), and just use the guard.
Note: at this stage, job_{lock/unlock} and job lock guard macros
are *nop*.
Signed-off-by: Emanuele Giuseppe Esposito <eespo...@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefa...@redhat.com>
actually, patch is modified enough to drop r-b.
---
tests/unit/test-bdrv-drain.c | 76 +++++++++++++-------
tests/unit/test-block-iothread.c | 8 ++-
tests/unit/test-blockjob-txn.c | 24 ++++---
tests/unit/test-blockjob.c | 116 +++++++++++++++++++------------
4 files changed, 141 insertions(+), 83 deletions(-)
[..]
@@ -459,36 +477,44 @@ static void test_complete_in_standby(void)
bjob = mk_job(blk, "job", &test_yielding_driver, true,
JOB_MANUAL_FINALIZE | JOB_MANUAL_DISMISS);
job = &bjob->job;
- assert(job->status == JOB_STATUS_CREATED);
+ /* Job did not start, so status is safe to read*/
comment is not needed now, let's drop it.
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsement...@yandex-team.ru>
--
Best regards,
Vladimir