From abbab72cad2eafcaf3b0f4e970add813b4264e5f Mon Sep 17 00:00:00 2001 From: Kevin Wolf Date: Wed, 23 May 2018 18:19:00 +0200 Subject: [PATCH] qemu-iotests: Rewrite 211 for blockdev-create job This rewrites the test case 211 to work with the new x-blockdev-create job rather than the old synchronous version of the command. All of the test cases stay the same as before, but in order to be able to implement proper job handling, the test case is rewritten in Python. Signed-off-by: Kevin Wolf Reviewed-by: Max Reitz --- tests/qemu-iotests/211 | 319 ++++++++++++++----------------------- tests/qemu-iotests/211.out | 133 +++++++++------- tests/qemu-iotests/group | 2 +- 3 files changed, 198 insertions(+), 256 deletions(-) diff --git a/tests/qemu-iotests/211 b/tests/qemu-iotests/211 index 1edec26517..b45f886d23 100755 --- a/tests/qemu-iotests/211 +++ b/tests/qemu-iotests/211 @@ -1,9 +1,11 @@ -#!/bin/bash +#!/usr/bin/env python # # Test VDI and file image creation # # Copyright (C) 2018 Red Hat, Inc. # +# Creator/Owner: Kevin Wolf +# # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or @@ -18,229 +20,154 @@ # along with this program. If not, see . # -# creator -owner=kwolf@redhat.com +import iotests +from iotests import imgfmt -seq=`basename $0` -echo "QA output created by $seq" +iotests.verify_image_format(supported_fmts=['vdi']) +iotests.verify_protocol(supported=['file']) -here=`pwd` -status=1 # failure is the default! +def blockdev_create(vm, options): + result = vm.qmp_log('x-blockdev-create', job_id='job0', options=options) -# get standard environment, filters and checks -. ./common.rc -. ./common.filter + if 'return' in result: + assert result['return'] == {} + vm.run_job('job0') + iotests.log("") -_supported_fmt vdi -_supported_proto file -_supported_os Linux +with iotests.FilePath('t.vdi') as disk_path, \ + iotests.VM() as vm: -function do_run_qemu() -{ - echo Testing: "$@" - $QEMU -nographic -qmp stdio -serial none "$@" - echo -} + # + # Successful image creation (defaults) + # + iotests.log("=== Successful image creation (defaults) ===") + iotests.log("") -function run_qemu() -{ - do_run_qemu "$@" 2>&1 | _filter_testdir | _filter_qmp \ - | _filter_qemu | _filter_imgfmt \ - | _filter_actual_image_size -} + size = 128 * 1024 * 1024 -echo -echo "=== Successful image creation (defaults) ===" -echo + vm.launch() + blockdev_create(vm, { 'driver': 'file', + 'filename': disk_path, + 'size': 0 }) -size=$((128 * 1024 * 1024)) + vm.qmp_log('blockdev-add', driver='file', filename=disk_path, + node_name='imgfile') -run_qemu <