forked from KolibriOS/kolibrios
[KERNEL][TEST] Make qemu tests position-independent
git-svn-id: svn://kolibrios.org@9331 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
134e54dcbb
commit
b61452e9e1
@ -150,11 +150,10 @@ def run_tests_serially_thread(test, root_dir):
|
|||||||
for test in tests:
|
for test in tests:
|
||||||
test_dir = f"{root_dir}/{test}"
|
test_dir = f"{root_dir}/{test}"
|
||||||
|
|
||||||
os.chdir(test_dir)
|
|
||||||
print(f"[{test_number}/{len(tests)}] {test}... ", end = "", flush=True)
|
print(f"[{test_number}/{len(tests)}] {test}... ", end = "", flush=True)
|
||||||
start = timeit.default_timer()
|
start = timeit.default_timer()
|
||||||
try:
|
try:
|
||||||
SourceFileLoader("test", "test.py").load_module().run()
|
SourceFileLoader("test", f"{test_dir}/test.py").load_module().run(root_dir, test_dir)
|
||||||
except common.TestTimeoutException:
|
except common.TestTimeoutException:
|
||||||
result = "TIMEOUT"
|
result = "TIMEOUT"
|
||||||
except common.TestFailureException:
|
except common.TestFailureException:
|
||||||
@ -163,7 +162,6 @@ def run_tests_serially_thread(test, root_dir):
|
|||||||
result = "SUCCESS"
|
result = "SUCCESS"
|
||||||
finish = timeit.default_timer()
|
finish = timeit.default_timer()
|
||||||
print(f"{result} ({finish - start:.2f} seconds)")
|
print(f"{result} ({finish - start:.2f} seconds)")
|
||||||
os.chdir(root_dir)
|
|
||||||
|
|
||||||
test_number += 1
|
test_number += 1
|
||||||
|
|
||||||
|
@ -28,12 +28,12 @@ class TestFailureException(Exception):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
class Qemu:
|
class Qemu:
|
||||||
def __init__(self, popen):
|
def __init__(self, popen, debug_log):
|
||||||
self.popen = popen
|
self.popen = popen
|
||||||
# Qemu needs time to create debug.log file
|
# Qemu needs time to create debug.log file
|
||||||
while not os.path.exists("debug.log"):
|
while not os.path.exists(debug_log):
|
||||||
self.wait()
|
self.wait()
|
||||||
self.debug = open("debug.log", "rb")
|
self.debug = open(debug_log, "rb")
|
||||||
|
|
||||||
def wait_for_debug_log(self, needle, timeout = 1):
|
def wait_for_debug_log(self, needle, timeout = 1):
|
||||||
needle = bytes(needle, "utf-8")
|
needle = bytes(needle, "utf-8")
|
||||||
@ -87,14 +87,14 @@ def get_file_directory(path):
|
|||||||
else:
|
else:
|
||||||
return "." # Just a filename, let's return current folder
|
return "." # Just a filename, let's return current folder
|
||||||
|
|
||||||
def run_qemu():
|
def run_qemu(root_dir, test_dir, debug_log):
|
||||||
qemu_command = f"qemu-system-i386"
|
qemu_command = f"qemu-system-i386"
|
||||||
flags = ""
|
flags = ""
|
||||||
flags += "-nographic " # Makes it faster
|
flags += "-nographic " # Makes it faster
|
||||||
flags += "-debugcon file:debug.log " # 0xe9 port output
|
flags += f"-debugcon file:{debug_log} " # 0xe9 port output
|
||||||
flags += "-L . " # IDK why it does not work without this
|
flags += "-L . " # IDK why it does not work without this
|
||||||
flags += "-m 128 "
|
flags += "-m 128 "
|
||||||
flags += "-drive format=raw,file=../../kolibri_test.img,index=0,if=floppy -boot a "
|
flags += f"-drive format=raw,file={root_dir}/kolibri_test.img,index=0,if=floppy -boot a "
|
||||||
flags += "-vga vmware "
|
flags += "-vga vmware "
|
||||||
flags += "-net nic,model=rtl8139 -net user "
|
flags += "-net nic,model=rtl8139 -net user "
|
||||||
flags += "-soundhw ac97 "
|
flags += "-soundhw ac97 "
|
||||||
@ -103,17 +103,18 @@ def run_qemu():
|
|||||||
qemu_directory = get_file_directory(qemu_full_path)
|
qemu_directory = get_file_directory(qemu_full_path)
|
||||||
flags += f"-L {qemu_directory} "
|
flags += f"-L {qemu_directory} "
|
||||||
s = f"{qemu_command} {flags}"
|
s = f"{qemu_command} {flags}"
|
||||||
qemu_stdout = open("qemu_stdout.log", "w")
|
qemu_stdout = open(f"{test_dir}/qemu_stdout.log", "w")
|
||||||
qemu_stderr = open("qemu_stderr.log", "w")
|
qemu_stderr = open(f"{test_dir}/qemu_stderr.log", "w")
|
||||||
if is_win32():
|
if is_win32():
|
||||||
return subprocess.Popen(s, bufsize = 0, stdout = qemu_stdout, stderr = qemu_stderr, stdin = subprocess.DEVNULL, shell = True, start_new_session = True)
|
return subprocess.Popen(s, bufsize = 0, stdout = qemu_stdout, stderr = qemu_stderr, stdin = subprocess.DEVNULL, shell = True, start_new_session = True)
|
||||||
else:
|
else:
|
||||||
a = shlex.split(s)
|
a = shlex.split(s)
|
||||||
return subprocess.Popen(a, bufsize = 0, stdout = qemu_stdout, stderr = qemu_stderr, stdin = subprocess.DEVNULL, start_new_session = True)
|
return subprocess.Popen(a, bufsize = 0, stdout = qemu_stdout, stderr = qemu_stderr, stdin = subprocess.DEVNULL, start_new_session = True)
|
||||||
|
|
||||||
def run():
|
def run(root_dir, test_dir):
|
||||||
if os.path.exists("debug.log"):
|
debug_log = f"{test_dir}/debug.log"
|
||||||
os.remove("debug.log")
|
if os.path.exists(debug_log):
|
||||||
popen = run_qemu()
|
os.remove(debug_log)
|
||||||
return Qemu(popen)
|
popen = run_qemu(root_dir, test_dir, debug_log)
|
||||||
|
return Qemu(popen, debug_log)
|
||||||
|
|
||||||
|
@ -4,8 +4,8 @@ import sys
|
|||||||
sys.path.append('../')
|
sys.path.append('../')
|
||||||
import common
|
import common
|
||||||
|
|
||||||
def run():
|
def run(root_dir, test_dir):
|
||||||
os = common.run()
|
os = common.run(root_dir, test_dir)
|
||||||
os.wait_for_debug_log("K : kernel SVN", timeout = 10)
|
os.wait_for_debug_log("K : kernel SVN", timeout = 10)
|
||||||
os.kill()
|
os.kill()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user