From 3f25bfcb275d112b4db51c2ce916226fa4a1bf7f Mon Sep 17 00:00:00 2001 From: Julien Duponchelle Date: Thu, 23 Jul 2015 10:46:43 +0200 Subject: [PATCH] Fix qemu tests --- gns3server/modules/qemu/qemu_vm.py | 1 - tests/modules/qemu/test_qemu_vm.py | 9 +++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/gns3server/modules/qemu/qemu_vm.py b/gns3server/modules/qemu/qemu_vm.py index 54e54297..561e521c 100644 --- a/gns3server/modules/qemu/qemu_vm.py +++ b/gns3server/modules/qemu/qemu_vm.py @@ -1004,7 +1004,6 @@ class QemuVM(BaseVM): @asyncio.coroutine def _disk_options(self): - options = [] qemu_img_path = "" qemu_path_dir = os.path.dirname(self.qemu_path) diff --git a/tests/modules/qemu/test_qemu_vm.py b/tests/modules/qemu/test_qemu_vm.py index 246a3d8c..70b22c8d 100644 --- a/tests/modules/qemu/test_qemu_vm.py +++ b/tests/modules/qemu/test_qemu_vm.py @@ -269,13 +269,16 @@ def test_set_platform(project, manager): assert vm.qemu_path == "/bin/qemu-system-x86_64" -def test_disk_options(vm, loop, fake_qemu_img_binary): +def test_disk_options(vm, tmpdir, loop, fake_qemu_img_binary): + + vm._hda_disk_image = str(tmpdir / "test.qcow2") + open(vm._hda_disk_image, "w+").close() with asyncio_patch("asyncio.create_subprocess_exec", return_value=MagicMock()) as process: loop.run_until_complete(asyncio.async(vm._disk_options())) assert process.called args, kwargs = process.call_args - assert args == (fake_qemu_img_binary, "create", "-f", "qcow2", os.path.join(vm.working_dir, "flash.qcow2"), "256M") + assert args == (fake_qemu_img_binary, "create", "-o", "backing_file={}".format(vm._hda_disk_image), "-f", "qcow2", os.path.join(vm.working_dir, "hda_disk.qcow2")) @pytest.mark.skipif(sys.platform.startswith("win"), reason="Not supported on Windows") @@ -337,8 +340,6 @@ def test_build_command(vm, loop, fake_qemu_binary, port_manager): "test", "-m", "256", - "-hda", - os.path.join(vm.working_dir, "flash.qcow2"), "-serial", "telnet:127.0.0.1:{},server,nowait".format(vm.console), "-net",