diff --git a/tests/include/test/arguments.h b/tests/include/test/arguments.h index 8c7dd5a43f..a975bfa2dc 100644 --- a/tests/include/test/arguments.h +++ b/tests/include/test/arguments.h @@ -37,7 +37,7 @@ typedef union { size_t len; - int32_t s32; + intmax_t sint; } mbedtls_test_argument_t; #endif /* TEST_ARGUMENTS_H */ diff --git a/tests/scripts/generate_test_code.py b/tests/scripts/generate_test_code.py index 263cd90eb5..a3f6937c70 100755 --- a/tests/scripts/generate_test_code.py +++ b/tests/scripts/generate_test_code.py @@ -473,7 +473,7 @@ def parse_function_argument(arg, arg_idx, args, local_vars, args_dispatch): typ, _ = m.groups() if typ in INTEGER_TYPES: args.append('int') - args_dispatch.append('((mbedtls_test_argument_t*)params[%d])->s32' % arg_idx) + args_dispatch.append('((mbedtls_test_argument_t*)params[%d])->sint' % arg_idx) return 1 if typ in STRING_TYPES: args.append('char*') diff --git a/tests/scripts/test_generate_test_code.py b/tests/scripts/test_generate_test_code.py index 889b96299c..7c0ac0c315 100755 --- a/tests/scripts/test_generate_test_code.py +++ b/tests/scripts/test_generate_test_code.py @@ -487,8 +487,8 @@ class ParseFuncSignature(TestCase): self.assertEqual(local, '') self.assertEqual(arg_dispatch, ['(char *) params[0]', - '((mbedtls_test_argument_t*)params[1])->s32', - '((mbedtls_test_argument_t*)params[2])->s32']) + '((mbedtls_test_argument_t*)params[1])->sint', + '((mbedtls_test_argument_t*)params[2])->sint']) def test_hex_params(self): """ @@ -503,7 +503,7 @@ class ParseFuncSignature(TestCase): '((mbedtls_test_argument_t*)params[2])->len};\n') self.assertEqual(arg_dispatch, ['(char *) params[0]', '&data1', - '((mbedtls_test_argument_t*)params[3])->s32']) + '((mbedtls_test_argument_t*)params[3])->sint']) def test_unsupported_arg(self): """ diff --git a/tests/suites/host_test.function b/tests/suites/host_test.function index 59b18d2896..06f391fa4f 100644 --- a/tests/suites/host_test.function +++ b/tests/suites/host_test.function @@ -32,21 +32,19 @@ int verify_string(char **str) * * \return 0 if success else 1 */ -int verify_int(char *str, int32_t *p_value) +int verify_int(char *str, intmax_t *p_value) { char *end = NULL; errno = 0; + /* Limit the range to long: for large integers, the test framework will + * use expressions anyway. */ long value = strtol(str, &end, 0); if (errno == EINVAL || *end != '\0') { mbedtls_fprintf(stderr, "Expected integer for parameter and got: %s\n", str); return KEY_VALUE_MAPPING_NOT_FOUND; } - if (errno == ERANGE -#if LONG_MAX > 0x7fffffff - || value > 0x7fffffffL || value < -0x80000000L -#endif - ) { + if (errno == ERANGE) { mbedtls_fprintf(stderr, "Integer out of range: %s\n", str); return KEY_VALUE_MAPPING_NOT_FOUND; } @@ -222,7 +220,7 @@ static int convert_params(size_t cnt, char **params, break; } } else if (strcmp(type, "int") == 0) { - if (verify_int(val, &int_params_store->s32) == 0) { + if (verify_int(val, &int_params_store->sint) == 0) { *out++ = (char *) int_params_store++; } else { ret = (DISPATCH_INVALID_TEST_DATA); @@ -245,7 +243,7 @@ static int convert_params(size_t cnt, char **params, } } else if (strcmp(type, "exp") == 0) { int exp_id = strtol(val, NULL, 10); - if (get_expression(exp_id, &int_params_store->s32) == 0) { + if (get_expression(exp_id, &int_params_store->sint) == 0) { *out++ = (char *) int_params_store++; } else { ret = (DISPATCH_INVALID_TEST_DATA); diff --git a/tests/suites/main_test.function b/tests/suites/main_test.function index 1e5c666ff8..335ce84f91 100644 --- a/tests/suites/main_test.function +++ b/tests/suites/main_test.function @@ -81,7 +81,7 @@ __MBEDTLS_TEST_TEMPLATE__FUNCTIONS_CODE * * \return 0 if exp_id is found. 1 otherwise. */ -int get_expression(int32_t exp_id, int32_t *out_value) +int get_expression(int32_t exp_id, intmax_t *out_value) { int ret = KEY_VALUE_MAPPING_FOUND;