mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-06-16 17:40:57 +03:00
Support different types in the parameter store
The test framework stores size_t and int32_t values in the parameter store by converting them all to int. This is ok in practice, since we assume int covers int32_t and we don't have test data larger than 2GB. But it's confusing and error-prone. So make the parameter store a union, which allows size_t values not to be potentially truncated and makes the code a little clearer. Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
This commit is contained in:
@ -485,9 +485,10 @@ class ParseFuncSignature(TestCase):
|
||||
args, local, arg_dispatch = parse_function_arguments(line)
|
||||
self.assertEqual(args, ['char*', 'int', 'int'])
|
||||
self.assertEqual(local, '')
|
||||
self.assertEqual(arg_dispatch, ['(char *) params[0]',
|
||||
'*( (int *) params[1] )',
|
||||
'*( (int *) params[2] )'])
|
||||
self.assertEqual(arg_dispatch,
|
||||
['(char *) params[0]',
|
||||
'((mbedtls_test_argument_t*)params[1])->s32',
|
||||
'((mbedtls_test_argument_t*)params[2])->s32'])
|
||||
|
||||
def test_hex_params(self):
|
||||
"""
|
||||
@ -499,10 +500,10 @@ class ParseFuncSignature(TestCase):
|
||||
self.assertEqual(args, ['char*', 'hex', 'int'])
|
||||
self.assertEqual(local,
|
||||
' data_t data1 = {(uint8_t *) params[1], '
|
||||
'*( (uint32_t *) params[2] )};\n')
|
||||
'((mbedtls_test_argument_t*)params[2])->len};\n')
|
||||
self.assertEqual(arg_dispatch, ['(char *) params[0]',
|
||||
'&data1',
|
||||
'*( (int *) params[3] )'])
|
||||
'((mbedtls_test_argument_t*)params[3])->s32'])
|
||||
|
||||
def test_unsupported_arg(self):
|
||||
"""
|
||||
|
Reference in New Issue
Block a user