mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-01-26 03:35:35 +00:00
Add line number to a few error messages
This is just a quick improvement, not meant to tackle the problem as a whole. Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
This commit is contained in:
parent
bc3db2e30a
commit
8542f5c81f
@ -705,7 +705,7 @@ def parse_test_data(data_f):
|
||||
execution.
|
||||
|
||||
:param data_f: file object of the data file.
|
||||
:return: Generator that yields test name, function name,
|
||||
:return: Generator that yields line number, test name, function name,
|
||||
dependency list and function argument list.
|
||||
"""
|
||||
__state_read_name = 0
|
||||
@ -748,7 +748,7 @@ def parse_test_data(data_f):
|
||||
parts = escaped_split(line, ':')
|
||||
test_function = parts[0]
|
||||
args = parts[1:]
|
||||
yield name, test_function, dependencies, args
|
||||
yield data_f.line_no, name, test_function, dependencies, args
|
||||
dependencies = []
|
||||
state = __state_read_name
|
||||
if state == __state_read_args:
|
||||
@ -931,7 +931,7 @@ def gen_from_test_data(data_f, out_data_f, func_info, suite_dependencies):
|
||||
unique_expressions = []
|
||||
dep_check_code = ''
|
||||
expression_code = ''
|
||||
for test_name, function_name, test_dependencies, test_args in \
|
||||
for line_no, test_name, function_name, test_dependencies, test_args in \
|
||||
parse_test_data(data_f):
|
||||
out_data_f.write(test_name + '\n')
|
||||
|
||||
@ -942,16 +942,16 @@ def gen_from_test_data(data_f, out_data_f, func_info, suite_dependencies):
|
||||
# Write test function name
|
||||
test_function_name = 'test_' + function_name
|
||||
if test_function_name not in func_info:
|
||||
raise GeneratorInputError("Function %s not found!" %
|
||||
test_function_name)
|
||||
raise GeneratorInputError("%d: Function %s not found!" %
|
||||
(line_no, test_function_name))
|
||||
func_id, func_args = func_info[test_function_name]
|
||||
out_data_f.write(str(func_id))
|
||||
|
||||
# Write parameters
|
||||
if len(test_args) != len(func_args):
|
||||
raise GeneratorInputError("Invalid number of arguments in test "
|
||||
raise GeneratorInputError("%d: Invalid number of arguments in test "
|
||||
"%s. See function %s signature." %
|
||||
(test_name, function_name))
|
||||
(line_no, test_name, function_name))
|
||||
expression_code += write_parameters(out_data_f, test_args, func_args,
|
||||
unique_expressions)
|
||||
|
||||
|
@ -1264,29 +1264,29 @@ dhm_selftest:
|
||||
# List of (name, function_name, dependencies, args)
|
||||
tests = list(parse_test_data(stream))
|
||||
test1, test2, test3, test4 = tests
|
||||
self.assertEqual(test1[0], 'Diffie-Hellman full exchange #1')
|
||||
self.assertEqual(test1[1], 'dhm_do_dhm')
|
||||
self.assertEqual(test1[2], [])
|
||||
self.assertEqual(test1[3], ['10', '"23"', '10', '"5"'])
|
||||
self.assertEqual(test1[1], 'Diffie-Hellman full exchange #1')
|
||||
self.assertEqual(test1[2], 'dhm_do_dhm')
|
||||
self.assertEqual(test1[3], [])
|
||||
self.assertEqual(test1[4], ['10', '"23"', '10', '"5"'])
|
||||
|
||||
self.assertEqual(test2[0], 'Diffie-Hellman full exchange #2')
|
||||
self.assertEqual(test2[1], 'dhm_do_dhm')
|
||||
self.assertEqual(test2[2], [])
|
||||
self.assertEqual(test2[3], ['10', '"93450983094850938450983409623"',
|
||||
self.assertEqual(test2[1], 'Diffie-Hellman full exchange #2')
|
||||
self.assertEqual(test2[2], 'dhm_do_dhm')
|
||||
self.assertEqual(test2[3], [])
|
||||
self.assertEqual(test2[4], ['10', '"93450983094850938450983409623"',
|
||||
'10', '"9345098304850938450983409622"'])
|
||||
|
||||
self.assertEqual(test3[0], 'Diffie-Hellman full exchange #3')
|
||||
self.assertEqual(test3[1], 'dhm_do_dhm')
|
||||
self.assertEqual(test3[2], [])
|
||||
self.assertEqual(test3[3], ['10',
|
||||
self.assertEqual(test3[1], 'Diffie-Hellman full exchange #3')
|
||||
self.assertEqual(test3[2], 'dhm_do_dhm')
|
||||
self.assertEqual(test3[3], [])
|
||||
self.assertEqual(test3[4], ['10',
|
||||
'"9345098382739712938719287391879381271"',
|
||||
'10',
|
||||
'"9345098792137312973297123912791271"'])
|
||||
|
||||
self.assertEqual(test4[0], 'Diffie-Hellman selftest')
|
||||
self.assertEqual(test4[1], 'dhm_selftest')
|
||||
self.assertEqual(test4[2], [])
|
||||
self.assertEqual(test4[1], 'Diffie-Hellman selftest')
|
||||
self.assertEqual(test4[2], 'dhm_selftest')
|
||||
self.assertEqual(test4[3], [])
|
||||
self.assertEqual(test4[4], [])
|
||||
|
||||
def test_with_dependencies(self):
|
||||
"""
|
||||
@ -1306,15 +1306,15 @@ dhm_do_dhm:10:"93450983094850938450983409623":10:"9345098304850938450983409622"
|
||||
# List of (name, function_name, dependencies, args)
|
||||
tests = list(parse_test_data(stream))
|
||||
test1, test2 = tests
|
||||
self.assertEqual(test1[0], 'Diffie-Hellman full exchange #1')
|
||||
self.assertEqual(test1[1], 'dhm_do_dhm')
|
||||
self.assertEqual(test1[2], ['YAHOO'])
|
||||
self.assertEqual(test1[3], ['10', '"23"', '10', '"5"'])
|
||||
self.assertEqual(test1[1], 'Diffie-Hellman full exchange #1')
|
||||
self.assertEqual(test1[2], 'dhm_do_dhm')
|
||||
self.assertEqual(test1[3], ['YAHOO'])
|
||||
self.assertEqual(test1[4], ['10', '"23"', '10', '"5"'])
|
||||
|
||||
self.assertEqual(test2[0], 'Diffie-Hellman full exchange #2')
|
||||
self.assertEqual(test2[1], 'dhm_do_dhm')
|
||||
self.assertEqual(test2[2], [])
|
||||
self.assertEqual(test2[3], ['10', '"93450983094850938450983409623"',
|
||||
self.assertEqual(test2[1], 'Diffie-Hellman full exchange #2')
|
||||
self.assertEqual(test2[2], 'dhm_do_dhm')
|
||||
self.assertEqual(test2[3], [])
|
||||
self.assertEqual(test2[4], ['10', '"93450983094850938450983409623"',
|
||||
'10', '"9345098304850938450983409622"'])
|
||||
|
||||
def test_no_args(self):
|
||||
@ -1335,7 +1335,7 @@ dhm_do_dhm:10:"93450983094850938450983409623":10:"9345098304850938450983409622"
|
||||
stream = StringIOWrapper('test_suite_ut.function', data)
|
||||
err = None
|
||||
try:
|
||||
for _, _, _, _ in parse_test_data(stream):
|
||||
for _, _, _, _, _ in parse_test_data(stream):
|
||||
pass
|
||||
except GeneratorInputError as err:
|
||||
self.assertEqual(type(err), GeneratorInputError)
|
||||
@ -1353,7 +1353,7 @@ depends_on:YAHOO
|
||||
stream = StringIOWrapper('test_suite_ut.function', data)
|
||||
err = None
|
||||
try:
|
||||
for _, _, _, _ in parse_test_data(stream):
|
||||
for _, _, _, _, _ in parse_test_data(stream):
|
||||
pass
|
||||
except GeneratorInputError as err:
|
||||
self.assertEqual(type(err), GeneratorInputError)
|
||||
|
Loading…
x
Reference in New Issue
Block a user