Unlike test-blockjob-txn, QMP releases the reference to the transaction before the jobs finish. Thus, while working on the next patch, qemu-iotest 124 showed a failure that the unit tests did not have. Make the unit test just a little nastier, so that it fails too.
Signed-off-by: Paolo Bonzini <[email protected]> --- tests/test-blockjob-txn.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/test-blockjob-txn.c b/tests/test-blockjob-txn.c index 4ccbda1..bfc2aaa 100644 --- a/tests/test-blockjob-txn.c +++ b/tests/test-blockjob-txn.c @@ -165,6 +165,11 @@ static void test_pair_jobs(int expected1, int expected2) job2 = test_block_job_start(2, true, expected2, &result2); block_job_txn_add_job(txn, job2); + /* Release our reference now to trigger as many nice + * use-after-free bugs as possible. + */ + block_job_txn_unref(txn); + if (expected1 == -ECANCELED) { block_job_cancel(job1); } @@ -185,8 +190,6 @@ static void test_pair_jobs(int expected1, int expected2) g_assert_cmpint(result1, ==, expected1); g_assert_cmpint(result2, ==, expected2); - - block_job_txn_unref(txn); } static void test_pair_jobs_success(void) -- 2.9.3
