Rename HexParam_t -> data_t for consistent coding style

This commit is contained in:
Azim Khan 2018-06-29 11:05:32 +01:00 committed by Mohammad Azim Khan
parent 62a5d7d65a
commit 5fcca46a3a
36 changed files with 248 additions and 248 deletions

View file

@ -300,19 +300,19 @@ def parse_function_signature(line):
elif re.search('char\s*\*\s*.*', arg.strip()):
args.append('char*')
args_dispatch.append('(char *) params[%d]' % arg_idx)
elif re.search('HexParam_t\s*\*\s*.*', arg.strip()):
elif re.search('data_t\s*\*\s*.*', arg.strip()):
args.append('hex')
# create a structure
pointer_initializer = '(uint8_t *) params[%d]' % arg_idx
len_initializer = '*( (uint32_t *) params[%d] )' % (arg_idx+1)
locals += """ HexParam_t hex%d = {%s, %s};
locals += """ data_t data%d = {%s, %s};
""" % (arg_idx, pointer_initializer, len_initializer)
args_dispatch.append('&hex%d' % arg_idx)
args_dispatch.append('&data%d' % arg_idx)
arg_idx += 1
else:
raise ValueError("Test function arguments can only be 'int', "
"'char *' or 'HexParam_t'\n%s" % line)
"'char *' or 'data_t'\n%s" % line)
arg_idx += 1
return name, args, locals, args_dispatch

View file

@ -442,11 +442,11 @@ class ParseFuncSignature(TestCase):
Test hex parameters parsing
:return:
"""
line = 'void entropy_threshold( char * a, HexParam_t * h, int result )'
line = 'void entropy_threshold( char * a, data_t * h, int result )'
name, args, local, arg_dispatch = parse_function_signature(line)
self.assertEqual(name, 'entropy_threshold')
self.assertEqual(args, ['char*', 'hex', 'int'])
self.assertEqual(local, ' HexParam_t hex1 = {(uint8_t *) params[1], *( (uint32_t *) params[2] )};\n')
self.assertEqual(local, ' data_t hex1 = {(uint8_t *) params[1], *( (uint32_t *) params[2] )};\n')
self.assertEqual(arg_dispatch, ['(char *) params[0]', '&hex1', '*( (int *) params[3] )'])
def test_non_void_function(self):
@ -454,15 +454,15 @@ class ParseFuncSignature(TestCase):
Test invalid signature (non void).
:return:
"""
line = 'int entropy_threshold( char * a, HexParam_t * h, int result )'
line = 'int entropy_threshold( char * a, data_t * h, int result )'
self.assertRaises(ValueError, parse_function_signature, line)
def test_unsupported_arg(self):
"""
Test unsupported arguments (not among int, char * and HexParam_t)
Test unsupported arguments (not among int, char * and data_t)
:return:
"""
line = 'int entropy_threshold( char * a, HexParam_t * h, int * result )'
line = 'int entropy_threshold( char * a, data_t * h, int * result )'
self.assertRaises(ValueError, parse_function_signature, line)
def test_no_params(self):