Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 9919 → Rev 9920

/kernel/trunk/runtests.py
12,6 → 12,7
import subprocess
from threading import Thread
import filecmp
import traceback
 
sys.path.append('test')
import common
145,6 → 146,7
 
 
def run_tests_serially_thread(test, root_dir):
errors = []
test_number = 1
for test in tests:
test_dir = f"{root_dir}/{test}"
154,10 → 156,9
try:
loader = SourceFileLoader("test", f"{test_dir}/test.py")
loader.load_module().run(root_dir, test_dir)
except common.TestTimeoutException:
result = "TIMEOUT"
except common.TestFailureException:
result = "FAILURE"
except common.TestException as exception:
result = exception.kind()
errors.append((test, exception))
else:
result = "SUCCESS"
finish = timeit.default_timer()
164,8 → 165,14
print(f"{result} ({finish - start:.2f} seconds)")
 
test_number += 1
if len(errors) != 0:
print("Some tests failed:")
for error in errors:
test, exception = error
print(f"\n{test}: {str(exception)}\n\nTraceback:")
traceback.print_tb(exception.__traceback__)
print(f"\nQemu command:\n {exception.cmd()}\n")
 
 
def run_tests_serially(tests, root_dir):
thread = Thread(target=run_tests_serially_thread, args=(tests, root_dir))
thread.start()
/kernel/trunk/test/common/__init__.py
21,13 → 21,26
def is_osx():
return True if sys.platform == "darwin" else False
 
class TestTimeoutException(Exception):
pass
class TestException(Exception):
def __init__(self, error_kind, message, qemu_cmd):
self.error_kind = error_kind
super().__init__(message)
self.qemu_cmd = qemu_cmd
 
class TestFailureException(Exception):
def __init__(self, message):
self.message = message
def kind(self):
return self.error_kind
 
def cmd(self):
return self.qemu_cmd
 
class TestException_Timeout(TestException):
def __init__(self, message, qemu_cmd):
super().__init__("TIMEOUT", message, qemu_cmd)
 
class TestException_Failure(TestException):
def __init__(self, message, qemu_cmd):
super().__init__("FAILURE", message, qemu_cmd)
 
class Qemu:
def __init__(self, popen, debug_log):
self.popen = popen
34,7 → 47,7
# Qemu needs time to create debug.log file
while not os.path.exists(debug_log) and self.qemu_is_alive():
self.wait(0.250)
self.assert_qemu_not_died("waiting for the debug log file")
self.assert_qemu_not_died("waiting for the debug log file creation")
self.debug = open(debug_log, "rb")
 
def qemu_is_alive(self):
42,7 → 55,7
 
def assert_qemu_not_died(self, while_):
if not self.qemu_is_alive():
raise TestFailureException(f"Qemu has finished while {while_}.")
raise TestException_Failure(f"Qemu has finished while {while_}.", ' '.join(self.popen.args))
 
def wait_for_debug_log(self, needle, timeout = 1):
needle = bytes(needle, "utf-8")
69,7 → 82,7
 
self.assert_qemu_not_died("waiting for the debug log")
 
self.timeout()
self.timeout("waiting for the debug log")
 
def kill(self):
if is_win32():
78,9 → 91,9
else:
os.killpg(os.getpgid(self.popen.pid), signal.SIGTERM)
 
def timeout(self):
def timeout(self, while_):
self.kill()
raise TestTimeoutException()
raise TestException_Timeout(while_, ' '.join(self.popen.args))
 
def wait(self, seconds):
time.sleep(seconds)