update the test script
Update `mbedtls_test.py` script to work with Python 3.7. resolves #2653
This commit is contained in:
parent
2ab5cf658f
commit
33908e8429
@ -79,8 +79,7 @@ class TestDataParser(object):
|
|||||||
split_colon_fn = lambda x: re.sub(r'\\' + split_char, split_char, x)
|
split_colon_fn = lambda x: re.sub(r'\\' + split_char, split_char, x)
|
||||||
if len(split_char) > 1:
|
if len(split_char) > 1:
|
||||||
raise ValueError('Expected split character. Found string!')
|
raise ValueError('Expected split character. Found string!')
|
||||||
out = map(split_colon_fn, re.split(r'(?<!\\)' + split_char, inp_str))
|
out = list(map(split_colon_fn, re.split(r'(?<!\\)' + split_char, inp_str)))
|
||||||
out = [x for x in out if x]
|
|
||||||
return out
|
return out
|
||||||
|
|
||||||
def __parse(self, data_f):
|
def __parse(self, data_f):
|
||||||
@ -90,20 +89,24 @@ class TestDataParser(object):
|
|||||||
:param data_f: Data file object
|
:param data_f: Data file object
|
||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
for line in data_f:
|
while True:
|
||||||
line = line.strip()
|
line = data_f.readline().strip()
|
||||||
if not line:
|
if not line:
|
||||||
continue
|
break
|
||||||
# Read test name
|
# Read test name
|
||||||
name = line
|
name = line
|
||||||
|
|
||||||
# Check dependencies
|
# Check dependencies
|
||||||
dependencies = []
|
dependencies = []
|
||||||
line = data_f.next().strip()
|
line = data_f.readline().strip()
|
||||||
|
if not line:
|
||||||
|
break
|
||||||
match = re.search('depends_on:(.*)', line)
|
match = re.search('depends_on:(.*)', line)
|
||||||
if match:
|
if match:
|
||||||
dependencies = [int(x) for x in match.group(1).split(':')]
|
dependencies = [int(x) for x in match.group(1).split(':')]
|
||||||
line = data_f.next().strip()
|
line = data_f.readline().strip()
|
||||||
|
if not line:
|
||||||
|
break
|
||||||
|
|
||||||
# Read test vectors
|
# Read test vectors
|
||||||
line = line.replace('\\n', '\n')
|
line = line.replace('\\n', '\n')
|
||||||
@ -115,7 +118,7 @@ class TestDataParser(object):
|
|||||||
err_str_fmt = "Number of test arguments({}) should be even: {}"
|
err_str_fmt = "Number of test arguments({}) should be even: {}"
|
||||||
raise TestDataParserError(err_str_fmt.format(args_count, line))
|
raise TestDataParserError(err_str_fmt.format(args_count, line))
|
||||||
grouped_args = [(args[i * 2], args[(i * 2) + 1])
|
grouped_args = [(args[i * 2], args[(i * 2) + 1])
|
||||||
for i in range(len(args)/2)]
|
for i in range(int(len(args)/2))]
|
||||||
self.tests.append((name, function_name, dependencies,
|
self.tests.append((name, function_name, dependencies,
|
||||||
grouped_args))
|
grouped_args))
|
||||||
|
|
||||||
@ -310,7 +313,7 @@ class MbedTlsTest(BaseHostTest):
|
|||||||
|
|
||||||
param_bytes, length = self.test_vector_to_bytes(function_id,
|
param_bytes, length = self.test_vector_to_bytes(function_id,
|
||||||
dependencies, args)
|
dependencies, args)
|
||||||
self.send_kv(length, param_bytes)
|
self.send_kv(bytes(length).decode(), bytes(param_bytes).decode())
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_result(value):
|
def get_result(value):
|
||||||
|
Loading…
Reference in New Issue
Block a user