2015-05-08 09:10:17 +00:00
|
|
|
import pytest
|
|
|
|
import subprocess
|
|
|
|
import time
|
|
|
|
|
|
|
|
|
|
|
|
def run_qemu(request, run_args=[]):
|
2015-05-10 10:32:53 +00:00
|
|
|
subprocess.check_call('rm -f ./state/empty-hd.img', shell=True)
|
2015-05-08 09:10:17 +00:00
|
|
|
print('\nrm ./state/*')
|
|
|
|
print('\nStarting QEMU')
|
|
|
|
p = subprocess.Popen(['./scripts/run'] + run_args,
|
|
|
|
stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True)
|
|
|
|
|
|
|
|
def fin():
|
|
|
|
print('\nTerminating QEMU')
|
|
|
|
p.terminate()
|
|
|
|
|
|
|
|
request.addfinalizer(fin)
|
|
|
|
return p
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.timeout(10)
|
2015-05-08 10:15:14 +00:00
|
|
|
def wait_for_ssh(ssh_command=['./scripts/ssh']):
|
|
|
|
while subprocess.call(ssh_command + ['/bin/true']) != 0:
|
2015-05-08 09:10:17 +00:00
|
|
|
time.sleep(1)
|