2013-12-22 00:42:33 +00:00
|
|
|
from gns3server.modules.dynamips import Hypervisor
|
|
|
|
import time
|
|
|
|
|
|
|
|
|
|
|
|
def test_is_started(hypervisor):
|
|
|
|
|
|
|
|
assert hypervisor.is_running()
|
|
|
|
|
|
|
|
|
|
|
|
def test_port(hypervisor):
|
|
|
|
|
2014-08-08 13:32:32 +00:00
|
|
|
assert hypervisor.port == 7200
|
2013-12-22 00:42:33 +00:00
|
|
|
|
|
|
|
|
|
|
|
def test_host(hypervisor):
|
|
|
|
|
2014-12-09 13:49:45 +00:00
|
|
|
assert hypervisor.host == "0.0.0.0"
|
2013-12-22 00:42:33 +00:00
|
|
|
|
|
|
|
|
2014-03-02 22:20:03 +00:00
|
|
|
def test_working_dir(hypervisor):
|
2013-12-22 00:42:33 +00:00
|
|
|
|
2014-03-02 22:20:03 +00:00
|
|
|
assert hypervisor.working_dir == "/tmp"
|
2013-12-22 00:42:33 +00:00
|
|
|
|
|
|
|
|
|
|
|
def test_path(hypervisor):
|
|
|
|
|
2014-08-08 13:32:32 +00:00
|
|
|
dynamips_path = '/usr/bin/dynamips'
|
2013-12-22 00:42:33 +00:00
|
|
|
assert hypervisor.path == dynamips_path
|
|
|
|
|
|
|
|
|
|
|
|
def test_stdout():
|
|
|
|
|
|
|
|
# try to launch Dynamips on the same port
|
|
|
|
# this will fail so that we can read its stdout/stderr
|
2014-08-08 14:00:44 +00:00
|
|
|
dynamips_path = '/usr/bin/dynamips'
|
|
|
|
hypervisor = Hypervisor(dynamips_path, "/tmp", "127.0.0.1", 7200)
|
2013-12-22 00:42:33 +00:00
|
|
|
hypervisor.start()
|
|
|
|
# give some time for Dynamips to start
|
2014-08-08 16:54:30 +00:00
|
|
|
time.sleep(0.1)
|
2013-12-22 00:42:33 +00:00
|
|
|
output = hypervisor.read_stdout()
|
|
|
|
assert output
|