Style fixes
This commit is contained in:
parent
440d8737c6
commit
d2d0112ca8
@ -1,10 +1,10 @@
|
||||
#! /usr/bin/env sh
|
||||
|
||||
# This file is part of mbed TLS (https://tls.mbed.org)
|
||||
# This file is part of Mbed TLS (https://tls.mbed.org)
|
||||
#
|
||||
# Copyright (c) 2018, ARM Limited, All Rights Reserved
|
||||
# Copyright (c) 2018, Arm Limited, All Rights Reserved
|
||||
#
|
||||
# Purpose
|
||||
# Purpose:
|
||||
#
|
||||
# Run 'pylint' on Python files for programming errors and helps enforcing
|
||||
# PEP8 coding standards.
|
||||
|
@ -57,10 +57,9 @@ Parameters can be of type string, binary data specified as hex
|
||||
string and integer constants specified as integer, macro or
|
||||
as an expression. Following is an example test definition:
|
||||
|
||||
X509 CRL Unsupported critical extension (issuingDistributionPoint)
|
||||
depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_RSA_C:MBEDTLS_SHA256_C
|
||||
mbedtls_x509_crl_parse:"data_files/crl-idp.pem":\
|
||||
MBEDTLS_ERR_X509_INVALID_EXTENSIONS + MBEDTLS_ERR_ASN1_UNEXPECTED_TAG
|
||||
AES 128 GCM Encrypt and decrypt 8 bytes
|
||||
depends_on:MBEDTLS_AES_C:MBEDTLS_GCM_C
|
||||
enc_dec_buf:MBEDTLS_CIPHER_AES_128_GCM:"AES-128-GCM":128:8:-1
|
||||
|
||||
Test functions:
|
||||
---------------
|
||||
@ -965,13 +964,11 @@ def write_test_source_file(template_file, c_file, snippets):
|
||||
:return:
|
||||
"""
|
||||
with open(template_file, 'r') as template_f, open(c_file, 'w') as c_f:
|
||||
line_no = 1
|
||||
for line in template_f.readlines():
|
||||
for line_no, line in enumerate(template_f.readlines(), 1):
|
||||
# Update line number. +1 as #line directive sets next line number
|
||||
snippets['line_no'] = line_no + 1
|
||||
code = line.format(**snippets)
|
||||
c_f.write(code)
|
||||
line_no += 1
|
||||
|
||||
|
||||
def parse_function_file(funcs_file, snippets):
|
||||
|
@ -455,13 +455,13 @@ static void test_fail( const char *test, int line_no, const char* filename )
|
||||
test_info.filename = filename;
|
||||
}
|
||||
|
||||
int hexcmp( uint8_t * a, uint8_t * b, uint32_t a_len, uint32_t b_len)
|
||||
int hexcmp( uint8_t * a, uint8_t * b, uint32_t a_len, uint32_t b_len )
|
||||
{
|
||||
int ret = 0;
|
||||
uint32_t i = 0;
|
||||
|
||||
if ( a_len != b_len )
|
||||
return( a_len - b_len );
|
||||
return( -1 );
|
||||
|
||||
for( i = 0; i < a_len; i++ )
|
||||
{
|
||||
|
@ -10,8 +10,8 @@
|
||||
*/
|
||||
int verify_string( char **str )
|
||||
{
|
||||
if( (*str)[0] != '"' ||
|
||||
(*str)[strlen( *str ) - 1] != '"' )
|
||||
if( ( *str )[0] != '"' ||
|
||||
( *str )[strlen( *str ) - 1] != '"' )
|
||||
{
|
||||
mbedtls_fprintf( stderr,
|
||||
"Expected string (with \"\") for parameter and got: %s\n", *str );
|
||||
@ -49,7 +49,7 @@ int verify_int( char *str, int *value )
|
||||
}
|
||||
|
||||
if( ( ( minus && i == 2 ) || ( !minus && i == 1 ) ) &&
|
||||
str[i - 1] == '0' && str[i] == 'x' )
|
||||
str[i - 1] == '0' && ( str[i] == 'x' || str[i] == 'X' ) )
|
||||
{
|
||||
hex = 1;
|
||||
continue;
|
||||
@ -87,8 +87,9 @@ int verify_int( char *str, int *value )
|
||||
#define USAGE \
|
||||
"Usage: %s [OPTIONS] files...\n\n" \
|
||||
" Command line arguments:\n" \
|
||||
" files... One or more test data file. If no file is specified\n" \
|
||||
" the followimg default test case is used:\n" \
|
||||
" files... One or more test data files. If no file is\n" \
|
||||
" specified the following default test case\n" \
|
||||
" file is used:\n" \
|
||||
" %s\n\n" \
|
||||
" Options:\n" \
|
||||
" -v | --verbose Display full information about each test\n" \
|
||||
@ -165,7 +166,7 @@ static int parse_arguments( char *buf, size_t len, char **params,
|
||||
|
||||
params[cnt++] = cur;
|
||||
|
||||
while( *p != '\0' && p < buf + len )
|
||||
while( *p != '\0' && p < ( buf + len ) )
|
||||
{
|
||||
if( *p == '\\' )
|
||||
{
|
||||
@ -195,23 +196,23 @@ static int parse_arguments( char *buf, size_t len, char **params,
|
||||
|
||||
while( *p != '\0' )
|
||||
{
|
||||
if( *p == '\\' && *(p + 1) == 'n' )
|
||||
if( *p == '\\' && *( p + 1 ) == 'n' )
|
||||
{
|
||||
p += 2;
|
||||
*(q++) = '\n';
|
||||
*( q++ ) = '\n';
|
||||
}
|
||||
else if( *p == '\\' && *(p + 1) == ':' )
|
||||
else if( *p == '\\' && *( p + 1 ) == ':' )
|
||||
{
|
||||
p += 2;
|
||||
*(q++) = ':';
|
||||
*( q++ ) = ':';
|
||||
}
|
||||
else if( *p == '\\' && *(p + 1) == '?' )
|
||||
else if( *p == '\\' && *( p + 1 ) == '?' )
|
||||
{
|
||||
p += 2;
|
||||
*(q++) = '?';
|
||||
*( q++ ) = '?';
|
||||
}
|
||||
else
|
||||
*(q++) = *(p++);
|
||||
*( q++ ) = *( p++ );
|
||||
}
|
||||
*q = '\0';
|
||||
}
|
||||
@ -231,8 +232,8 @@ static int parse_arguments( char *buf, size_t len, char **params,
|
||||
* }
|
||||
*
|
||||
*
|
||||
* \param cnt Input string.
|
||||
* \param params Out array of found strings.
|
||||
* \param cnt Parameter array count.
|
||||
* \param params Out array of found parameters.
|
||||
* \param int_params_store Memory for storing processed integer parameters.
|
||||
*
|
||||
* \return 0 for success else 1
|
||||
@ -241,7 +242,7 @@ static int convert_params( size_t cnt , char ** params , int * int_params_store
|
||||
{
|
||||
char ** cur = params;
|
||||
char ** out = params;
|
||||
int ret = ( DISPATCH_TEST_SUCCESS );
|
||||
int ret = DISPATCH_TEST_SUCCESS;
|
||||
|
||||
while ( cur < params + cnt )
|
||||
{
|
||||
@ -262,7 +263,7 @@ static int convert_params( size_t cnt , char ** params , int * int_params_store
|
||||
}
|
||||
else if ( strcmp( type, "int" ) == 0 )
|
||||
{
|
||||
if ( verify_int ( val, int_params_store ) == 0 )
|
||||
if ( verify_int( val, int_params_store ) == 0 )
|
||||
{
|
||||
*out++ = (char *) int_params_store++;
|
||||
}
|
||||
@ -276,12 +277,7 @@ static int convert_params( size_t cnt , char ** params , int * int_params_store
|
||||
{
|
||||
if ( verify_string( &val ) == 0 )
|
||||
{
|
||||
int j;
|
||||
*int_params_store = unhexify( (unsigned char *) val, val );
|
||||
printf ("\n");
|
||||
for (j = 0; j < *int_params_store; j++)
|
||||
printf ("%02x ", (uint8_t)val[j]);
|
||||
printf ("\n len %d\n", *int_params_store);
|
||||
*out++ = val;
|
||||
*out++ = (char *)(int_params_store++);
|
||||
}
|
||||
@ -401,7 +397,8 @@ int execute_tests( int argc , const char ** argv )
|
||||
FILE *file;
|
||||
char buf[5000];
|
||||
char *params[50];
|
||||
int int_params[50]; // Store for proccessed integer params.
|
||||
/* Store for proccessed integer params. */
|
||||
int int_params[50];
|
||||
void *pointer;
|
||||
#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
|
||||
int stdout_fd = -1;
|
||||
@ -436,10 +433,10 @@ int execute_tests( int argc , const char ** argv )
|
||||
|
||||
while( arg_index < argc )
|
||||
{
|
||||
next_arg = argv[ arg_index ];
|
||||
next_arg = argv[arg_index];
|
||||
|
||||
if( strcmp(next_arg, "--verbose" ) == 0 ||
|
||||
strcmp(next_arg, "-v" ) == 0 )
|
||||
if( strcmp( next_arg, "--verbose" ) == 0 ||
|
||||
strcmp( next_arg, "-v" ) == 0 )
|
||||
{
|
||||
option_verbose = 1;
|
||||
}
|
||||
|
@ -16,7 +16,7 @@
|
||||
* Test suite data : {test_case_data_file}
|
||||
*
|
||||
*
|
||||
* This file is part of mbed TLS (https://tls.mbed.org)
|
||||
* This file is part of Mbed TLS (https://tls.mbed.org)
|
||||
*/
|
||||
|
||||
#if !defined(MBEDTLS_CONFIG_FILE)
|
||||
@ -149,7 +149,7 @@ int dispatch_test( int func_idx, void ** params )
|
||||
int ret = DISPATCH_TEST_SUCCESS;
|
||||
TestWrapper_t fp = NULL;
|
||||
|
||||
if ( func_idx < (int)( sizeof(test_funcs)/sizeof( TestWrapper_t ) ) )
|
||||
if ( func_idx < (int)( sizeof( test_funcs ) / sizeof( TestWrapper_t ) ) )
|
||||
{{
|
||||
fp = test_funcs[func_idx];
|
||||
if ( fp )
|
||||
|
@ -31,11 +31,11 @@ while( 0 )
|
||||
* \param len Length of byte array
|
||||
*
|
||||
*/
|
||||
#define ALIGN_32BIT(p, start, len) do \
|
||||
{ \
|
||||
uint32_t align = ( - (uintptr_t)( p ) ) % 4;\
|
||||
INCR_ASSERT( ( p ), ( start ), ( len ), align);\
|
||||
} \
|
||||
#define ALIGN_32BIT(p, start, len) do \
|
||||
{ \
|
||||
uint32_t align = ( - (uintptr_t)( p ) ) % 4; \
|
||||
INCR_ASSERT( ( p ), ( start ), ( len ), align );\
|
||||
} \
|
||||
while( 0 )
|
||||
|
||||
|
||||
@ -210,7 +210,7 @@ uint32_t find_hex_count( uint8_t count, uint8_t * data, uint32_t data_len )
|
||||
* the memory after use.
|
||||
*/
|
||||
void ** parse_parameters( uint8_t count, uint8_t * data, uint32_t data_len,
|
||||
int * error )
|
||||
int * error )
|
||||
{
|
||||
uint32_t i = 0, hex_count = 0;
|
||||
char c;
|
||||
@ -393,7 +393,7 @@ int execute_tests( int args, const char ** argv )
|
||||
|
||||
if ( data )
|
||||
{
|
||||
free(data);
|
||||
free( data );
|
||||
data = NULL;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user