Qemu fixes for windows

This commit is contained in:
Julien Duponchelle committed 2016-09-27 18:01:50 +02:00
1 parent 20772a310b
commit fd3ac65eb5
4 files changed
+32 -35

No files matched your search

+4 -3
View File
@@ -15,9 +15,10 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import asyncio
import pytest
import uuid
import asyncio
import sys
import os
from tests.utils import asyncio_patch, AsyncioMagicMock
@@ -871,7 +872,7 @@ def test_get_image_informations(project, manager, loop):
loop.run_until_complete(asyncio.async(vm._get_image_information()))
mock.assert_called_with("GET", "images/ubuntu:latest/json")
@pytest.mark.skipif(sys.platform.startswith("win"), reason="Not supported on Windows")
def test_mount_binds(vm, tmpdir):
image_infos = {
"ContainerConfig": {
@@ -929,7 +930,7 @@ def test_create_network_interfaces(vm):
assert "eth4" in content
assert "eth5" not in content
@pytest.mark.skipif(sys.platform.startswith("win"), reason="Not supported on Windows")
def test_fix_permission(vm, loop):
vm._volumes = ["/etc"]
process = MagicMock()
+1 -1
View File
@@ -185,7 +185,7 @@ def test_get_kvm_archs_kvm_ok(loop):
if platform.machine() == 'x86_64':
assert archs == ['x86_64', 'i386']
else:
assert archs == platform.machine()
assert archs == [ platform.machine() ]
with patch("os.path.exists", return_value=False):
archs = loop.run_until_complete(asyncio.async(Qemu.get_kvm_archs()))
+23 -24
View File
@@ -56,7 +56,7 @@ def fake_qemu_img_binary():
def fake_qemu_binary():
if sys.platform.startswith("win"):
bin_path = os.path.join(os.environ["PATH"], "qemu-system-x86_64.EXE")
bin_path = os.path.join(os.environ["PATH"], "qemu-system-x86_64w.exe")
else:
bin_path = os.path.join(os.environ["PATH"], "qemu-system-x86_64")
with open(bin_path, "w+") as f:
@@ -233,7 +233,10 @@ def test_set_qemu_path(vm, tmpdir, fake_qemu_binary):
vm.qemu_path = None
# Should not crash with unicode characters
path = str(tmpdir / "\u62FF" / "qemu-system-mips")
if sys.platform.startswith("win"):
path = str(tmpdir / "\u62FF" / "qemu-system-mipsw.exe")
else:
path = str(tmpdir / "\u62FF" / "qemu-system-mips")
os.makedirs(str(tmpdir / "\u62FF"))
@@ -248,8 +251,7 @@ def test_set_qemu_path(vm, tmpdir, fake_qemu_binary):
if not sys.platform.startswith("win"):
with pytest.raises(QemuError):
vm.qemu_path = path
os.chmod(path, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR)
os.chmod(path, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR)
vm.qemu_path = path
assert vm.qemu_path == path
@@ -269,7 +271,8 @@ def test_set_qemu_path_windows(vm, tmpdir):
bin_path = os.path.join(os.environ["PATH"], "qemu-system-x86_64w.EXE")
open(bin_path, "w+").close()
os.chmod(bin_path, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR)
if not sys.platform.startswith("win"):
os.chmod(bin_path, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR)
vm.qemu_path = bin_path
@@ -281,7 +284,8 @@ def test_set_qemu_path_old_windows(vm, tmpdir):
bin_path = os.path.join(os.environ["PATH"], "qemu.exe")
open(bin_path, "w+").close()
os.chmod(bin_path, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR)
if not sys.platform.startswith("win"):
os.chmod(bin_path, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR)
vm.qemu_path = bin_path
@@ -614,27 +618,22 @@ def test_hdd_disk_image(vm, images_dir):
assert vm.hdd_disk_image == force_unix_path(os.path.join(images_dir, "QEMU", "test2"))
def test_initrd(vm, tmpdir):
def test_initrd(vm, images_dir):
vm.manager.config.set("Server", "images_path", str(tmpdir))
open(os.path.join(images_dir, "test1"), "w+").close()
vm.initrd = os.path.join(images_dir, "test1")
assert vm.initrd == force_unix_path(os.path.join(images_dir, "test1"))
open(os.path.join(images_dir, "QEMU", "test2"), "w+").close()
vm.initrd = "test2"
assert vm.initrd == force_unix_path(os.path.join(images_dir, "QEMU", "test2"))
def test_initrd_asa(vm, images_dir):
with patch("gns3server.compute.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.compute.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"))
open(os.path.join(images_dir, "asa842-initrd.gz"), "w+").close()
vm.initrd = os.path.join(images_dir, "asa842-initrd.gz")
assert vm.initrd == force_unix_path(os.path.join(images_dir, "asa842-initrd.gz"))
assert mock.called