|
|
@ -320,8 +320,8 @@ class TestRun: |
|
|
|
|
|
|
|
|
|
|
|
@classmethod |
|
|
|
@classmethod |
|
|
|
def make_exitcode(cls, test: 'TestSerialisation', test_env: typing.Dict[str, str], |
|
|
|
def make_exitcode(cls, test: 'TestSerialisation', test_env: typing.Dict[str, str], |
|
|
|
returncode: int, duration: float, stdo: typing.Optional[str], |
|
|
|
returncode: int, starttime: float, duration: float, |
|
|
|
stde: typing.Optional[str], |
|
|
|
stdo: typing.Optional[str], stde: typing.Optional[str], |
|
|
|
cmd: typing.Optional[typing.List[str]]) -> 'TestRun': |
|
|
|
cmd: typing.Optional[typing.List[str]]) -> 'TestRun': |
|
|
|
if returncode == GNU_SKIP_RETURNCODE: |
|
|
|
if returncode == GNU_SKIP_RETURNCODE: |
|
|
|
res = TestResult.SKIP |
|
|
|
res = TestResult.SKIP |
|
|
@ -331,11 +331,12 @@ class TestRun: |
|
|
|
res = TestResult.EXPECTEDFAIL if bool(returncode) else TestResult.UNEXPECTEDPASS |
|
|
|
res = TestResult.EXPECTEDFAIL if bool(returncode) else TestResult.UNEXPECTEDPASS |
|
|
|
else: |
|
|
|
else: |
|
|
|
res = TestResult.FAIL if bool(returncode) else TestResult.OK |
|
|
|
res = TestResult.FAIL if bool(returncode) else TestResult.OK |
|
|
|
return cls(test, test_env, res, returncode, duration, stdo, stde, cmd) |
|
|
|
return cls(test, test_env, res, returncode, starttime, duration, stdo, stde, cmd) |
|
|
|
|
|
|
|
|
|
|
|
@classmethod |
|
|
|
@classmethod |
|
|
|
def make_tap(cls, test: 'TestSerialisation', test_env: typing.Dict[str, str], |
|
|
|
def make_tap(cls, test: 'TestSerialisation', test_env: typing.Dict[str, str], |
|
|
|
returncode: int, duration: float, stdo: str, stde: str, |
|
|
|
returncode: int, starttime: float, duration: float, |
|
|
|
|
|
|
|
stdo: str, stde: str, |
|
|
|
cmd: typing.Optional[typing.List[str]]) -> 'TestRun': |
|
|
|
cmd: typing.Optional[typing.List[str]]) -> 'TestRun': |
|
|
|
res = None |
|
|
|
res = None |
|
|
|
num_tests = 0 |
|
|
|
num_tests = 0 |
|
|
@ -369,15 +370,16 @@ class TestRun: |
|
|
|
else: |
|
|
|
else: |
|
|
|
res = TestResult.FAIL if failed else TestResult.OK |
|
|
|
res = TestResult.FAIL if failed else TestResult.OK |
|
|
|
|
|
|
|
|
|
|
|
return cls(test, test_env, res, returncode, duration, stdo, stde, cmd) |
|
|
|
return cls(test, test_env, res, returncode, starttime, duration, stdo, stde, cmd) |
|
|
|
|
|
|
|
|
|
|
|
def __init__(self, test: 'TestSerialisation', test_env: typing.Dict[str, str], |
|
|
|
def __init__(self, test: 'TestSerialisation', test_env: typing.Dict[str, str], |
|
|
|
res: TestResult, returncode: int, duration: float, |
|
|
|
res: TestResult, returncode: int, starttime: float, duration: float, |
|
|
|
stdo: typing.Optional[str], stde: typing.Optional[str], |
|
|
|
stdo: typing.Optional[str], stde: typing.Optional[str], |
|
|
|
cmd: typing.Optional[typing.List[str]]): |
|
|
|
cmd: typing.Optional[typing.List[str]]): |
|
|
|
assert isinstance(res, TestResult) |
|
|
|
assert isinstance(res, TestResult) |
|
|
|
self.res = res |
|
|
|
self.res = res |
|
|
|
self.returncode = returncode |
|
|
|
self.returncode = returncode |
|
|
|
|
|
|
|
self.starttime = starttime |
|
|
|
self.duration = duration |
|
|
|
self.duration = duration |
|
|
|
self.stdo = stdo |
|
|
|
self.stdo = stdo |
|
|
|
self.stde = stde |
|
|
|
self.stde = stde |
|
|
@ -391,7 +393,10 @@ class TestRun: |
|
|
|
res += 'NONE\n' |
|
|
|
res += 'NONE\n' |
|
|
|
else: |
|
|
|
else: |
|
|
|
test_only_env = set(self.env.items()) - set(os.environ.items()) |
|
|
|
test_only_env = set(self.env.items()) - set(os.environ.items()) |
|
|
|
res += '{}{}\n'.format(env_tuple_to_str(test_only_env), ' '.join(self.cmd)) |
|
|
|
starttime_str = time.strftime("%H:%M:%S", time.gmtime(self.starttime)) |
|
|
|
|
|
|
|
res += '{} {}{}\n'.format( |
|
|
|
|
|
|
|
starttime_str, env_tuple_to_str(test_only_env), ' '.join(self.cmd) |
|
|
|
|
|
|
|
) |
|
|
|
if self.stdo: |
|
|
|
if self.stdo: |
|
|
|
res += '--- stdout ---\n' |
|
|
|
res += '--- stdout ---\n' |
|
|
|
res += self.stdo |
|
|
|
res += self.stdo |
|
|
@ -417,6 +422,7 @@ def write_json_log(jsonlogfile: typing.TextIO, test_name: str, result: TestRun) |
|
|
|
jresult = {'name': test_name, |
|
|
|
jresult = {'name': test_name, |
|
|
|
'stdout': result.stdo, |
|
|
|
'stdout': result.stdo, |
|
|
|
'result': result.res.value, |
|
|
|
'result': result.res.value, |
|
|
|
|
|
|
|
'starttime': result.starttime, |
|
|
|
'duration': result.duration, |
|
|
|
'duration': result.duration, |
|
|
|
'returncode': result.returncode, |
|
|
|
'returncode': result.returncode, |
|
|
|
'env': result.env, |
|
|
|
'env': result.env, |
|
|
@ -480,7 +486,7 @@ class SingleTestRunner: |
|
|
|
cmd = self._get_cmd() |
|
|
|
cmd = self._get_cmd() |
|
|
|
if cmd is None: |
|
|
|
if cmd is None: |
|
|
|
skip_stdout = 'Not run because can not execute cross compiled binaries.' |
|
|
|
skip_stdout = 'Not run because can not execute cross compiled binaries.' |
|
|
|
return TestRun(self.test, self.test_env, TestResult.SKIP, GNU_SKIP_RETURNCODE, 0.0, skip_stdout, None, None) |
|
|
|
return TestRun(self.test, self.test_env, TestResult.SKIP, GNU_SKIP_RETURNCODE, time.time(), 0.0, skip_stdout, None, None) |
|
|
|
else: |
|
|
|
else: |
|
|
|
wrap = TestHarness.get_wrapper(self.options) |
|
|
|
wrap = TestHarness.get_wrapper(self.options) |
|
|
|
if self.options.gdb: |
|
|
|
if self.options.gdb: |
|
|
@ -610,14 +616,14 @@ class SingleTestRunner: |
|
|
|
stdo = "" |
|
|
|
stdo = "" |
|
|
|
stde = additional_error |
|
|
|
stde = additional_error |
|
|
|
if timed_out: |
|
|
|
if timed_out: |
|
|
|
return TestRun(self.test, self.test_env, TestResult.TIMEOUT, p.returncode, duration, stdo, stde, cmd) |
|
|
|
return TestRun(self.test, self.test_env, TestResult.TIMEOUT, p.returncode, starttime, duration, stdo, stde, cmd) |
|
|
|
else: |
|
|
|
else: |
|
|
|
if self.test.protocol == 'exitcode': |
|
|
|
if self.test.protocol == 'exitcode': |
|
|
|
return TestRun.make_exitcode(self.test, self.test_env, p.returncode, duration, stdo, stde, cmd) |
|
|
|
return TestRun.make_exitcode(self.test, self.test_env, p.returncode, starttime, duration, stdo, stde, cmd) |
|
|
|
else: |
|
|
|
else: |
|
|
|
if self.options.verbose: |
|
|
|
if self.options.verbose: |
|
|
|
print(stdo, end='') |
|
|
|
print(stdo, end='') |
|
|
|
return TestRun.make_tap(self.test, self.test_env, p.returncode, duration, stdo, stde, cmd) |
|
|
|
return TestRun.make_tap(self.test, self.test_env, p.returncode, starttime, duration, stdo, stde, cmd) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TestHarness: |
|
|
|
class TestHarness: |
|
|
|