Turn off KVM for non x86 architectures

Fix #289
This commit is contained in:
Julien Duponchelle committed 2015-08-07 16:49:45 +02:00
1 parent 8b46a1a4ab
commit 323674ba5c
3 files changed
+106 -5

No files matched your search

+32
View File
@@ -165,3 +165,35 @@ def run_around_tests(monkeypatch):
shutil.rmtree(tmppath)
except:
pass
@pytest.yield_fixture
def darwin_platform():
"""
Change sys.plaform to Darwin
"""
old_platform = sys.platform
sys.platform = "darwin10.10"
yield
sys.plaform = old_platform
@pytest.yield_fixture
def windows_platform():
"""
Change sys.plaform to Windows
"""
old_platform = sys.platform
sys.platform = "win10"
yield
sys.plaform = old_platform
@pytest.yield_fixture
def linux_platform():
"""
Change sys.plaform to Linux
"""
old_platform = sys.platform
sys.platform = "linuxdebian"
yield
sys.plaform = old_platform
+51
View File
@@ -428,3 +428,54 @@ def test_get_qemu_img_not_exist(vm, tmpdir):
vm._qemu_path = str(tmpdir / "qemu-sytem-x86_64")
with pytest.raises(QemuError):
vm._get_qemu_img()
def test_run_with_kvm_darwin(darwin_platform, vm):
with patch("configparser.SectionProxy.getboolean", return_value=True):
assert vm._run_with_kvm("qemu-system-x86_64", "") is False
def test_run_with_kvm_windows(windows_platform, vm):
with patch("configparser.SectionProxy.getboolean", return_value=True):
assert vm._run_with_kvm("qemu-system-x86_64.exe", "") is False
def test_run_with_kvm_linux(linux_platform, vm):
with patch("os.path.exists", return_value=True) as os_path:
with patch("configparser.SectionProxy.getboolean", return_value=True):
assert vm._run_with_kvm("qemu-system-x86_64", "") is True
os_path.assert_called_with("/dev/kvm")
def test_run_with_kvm_linux_config_desactivated(linux_platform, vm):
with patch("os.path.exists", return_value=True) as os_path:
with patch("configparser.SectionProxy.getboolean", return_value=False):
assert vm._run_with_kvm("qemu-system-x86_64", "") is False
def test_run_with_kvm_linux_options_no_kvm(linux_platform, vm):
with patch("os.path.exists", return_value=True) as os_path:
with patch("configparser.SectionProxy.getboolean", return_value=True):
assert vm._run_with_kvm("qemu-system-x86_64", "-no-kvm") is False
def test_run_with_kvm_not_x86(linux_platform, vm):
with patch("os.path.exists", return_value=True) as os_path:
with patch("configparser.SectionProxy.getboolean", return_value=True):
assert vm._run_with_kvm("qemu-system-arm", "") is False
def test_run_with_kvm_linux_dev_kvm_missing(linux_platform, vm):
with patch("os.path.exists", return_value=False) as os_path:
with patch("configparser.SectionProxy.getboolean", return_value=True):
with pytest.raises(QemuError):
vm._run_with_kvm("qemu-system-x86_64", "")