Fix parsing issue when int parameter is in base 16

Fix error `ValueError: invalid literal for int() with base 10:` that
is caused when a parameter is given in base 16. Use relevant base
when calling `int()` function.
This commit is contained in:
Ron Eldor 2019-06-25 14:52:19 +03:00
parent e81ff54881
commit 7c52e229d5

View file

@ -80,6 +80,7 @@ class TestDataParser(object):
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 = list(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):
@ -260,7 +261,7 @@ class MbedTlsTest(BaseHostTest):
data_bytes += bytearray([function_id, len(parameters)]) data_bytes += bytearray([function_id, len(parameters)])
for typ, param in parameters: for typ, param in parameters:
if typ == 'int' or typ == 'exp': if typ == 'int' or typ == 'exp':
i = int(param) i = int(param, 0)
data_bytes += b'I' if typ == 'int' else b'E' data_bytes += b'I' if typ == 'int' else b'E'
self.align_32bit(data_bytes) self.align_32bit(data_bytes)
data_bytes += self.int32_to_big_endian_bytes(i) data_bytes += self.int32_to_big_endian_bytes(i)