mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 22:11:14 +02:00
Merge branch 'master' into 1.5
This commit is contained in:
12 files changed
+143
-68
No files matched your search
@@ -177,19 +177,15 @@ def test_create_image_exist(loop, tmpdir, fake_qemu_img_binary):
|
||||
assert not process.called
|
||||
|
||||
|
||||
def test_get_kvm_archs_no_kvm(loop):
|
||||
with asyncio_patch("asyncio.create_subprocess_exec", side_effect=FileNotFoundError('kvm-ok')):
|
||||
archs = loop.run_until_complete(asyncio.async(Qemu.get_kvm_archs()))
|
||||
assert archs == []
|
||||
|
||||
|
||||
def test_get_kvm_archs_kvm_ok(loop):
|
||||
|
||||
process = MagicMock()
|
||||
with asyncio_patch("asyncio.create_subprocess_exec", return_value=process):
|
||||
process.returncode = 0
|
||||
with patch("os.path.exists", return_value=True):
|
||||
archs = loop.run_until_complete(asyncio.async(Qemu.get_kvm_archs()))
|
||||
if platform.machine() == 'x86_64':
|
||||
assert archs == ['x86_64', 'i386']
|
||||
else:
|
||||
assert archs == platform.machine()
|
||||
|
||||
with patch("os.path.exists", return_value=False):
|
||||
archs = loop.run_until_complete(asyncio.async(Qemu.get_kvm_archs()))
|
||||
assert archs == []
|
||||
@@ -85,6 +85,22 @@ def test_vm(project, manager, fake_qemu_binary):
|
||||
assert vm.id == "00010203-0405-0607-0809-0a0b0c0d0e0f"
|
||||
|
||||
|
||||
def test_vm_invalid_qemu_with_platform(project, manager, fake_qemu_binary):
|
||||
|
||||
vm = QemuVM("test", "00010203-0405-0607-0809-0a0b0c0d0e0f", project, manager, qemu_path="/usr/fake/bin/qemu-system-64", platform="x86_64")
|
||||
|
||||
assert vm.qemu_path == fake_qemu_binary
|
||||
assert vm.platform == "x86_64"
|
||||
|
||||
|
||||
def test_vm_invalid_qemu_without_platform(project, manager, fake_qemu_binary):
|
||||
|
||||
vm = QemuVM("test", "00010203-0405-0607-0809-0a0b0c0d0e0f", project, manager, qemu_path="/usr/fake/bin/qemu-system-x86_64")
|
||||
|
||||
assert vm.qemu_path == fake_qemu_binary
|
||||
assert vm.platform == "x86_64"
|
||||
|
||||
|
||||
def test_is_running(vm, running_subprocess_mock):
|
||||
|
||||
vm._process = None
|
||||
@@ -459,6 +475,30 @@ def test_hdd_disk_image(vm, tmpdir):
|
||||
assert vm.hdd_disk_image == force_unix_path(str(tmpdir / "QEMU" / "test"))
|
||||
|
||||
|
||||
def test_initrd(vm, tmpdir):
|
||||
|
||||
vm.manager.config.set("Server", "images_path", str(tmpdir))
|
||||
|
||||
with patch("gns3server.modules.project.Project.emit") as mock:
|
||||
vm.initrd = str(tmpdir / "test")
|
||||
assert vm.initrd == force_unix_path(str(tmpdir / "test"))
|
||||
vm.initrd = "test"
|
||||
assert vm.initrd == force_unix_path(str(tmpdir / "QEMU" / "test"))
|
||||
assert not mock.called
|
||||
|
||||
|
||||
def test_initrd_asa(vm, tmpdir):
|
||||
|
||||
vm.manager.config.set("Server", "images_path", str(tmpdir))
|
||||
|
||||
with patch("gns3server.modules.project.Project.emit") as mock:
|
||||
vm.initrd = str(tmpdir / "asa842-initrd.gz")
|
||||
assert vm.initrd == force_unix_path(str(tmpdir / "asa842-initrd.gz"))
|
||||
vm.initrd = "asa842-initrd.gz"
|
||||
assert vm.initrd == force_unix_path(str(tmpdir / "QEMU" / "asa842-initrd.gz"))
|
||||
assert mock.called
|
||||
|
||||
|
||||
def test_options(linux_platform, vm):
|
||||
vm.kvm = False
|
||||
vm.options = "-usb"
|
||||
|
||||
Reference in new issue
Block a user