Skip to content
This repository has been archived by the owner on Dec 8, 2022. It is now read-only.

Commit

Permalink
Fix compile warnings in common io and wifi tests (#1995)
Browse files Browse the repository at this point in the history
Co-authored-by: qiutongs <songqt01@gmail,com>
  • Loading branch information
qiutongs and qiutongs authored May 12, 2020
1 parent cbf360f commit 634318e
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 22 deletions.
9 changes: 6 additions & 3 deletions libraries/abstractions/common_io/test/test_iot_i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
#define testIotI2C_BAUDRATE_LOW_SPEED IOT_I2C_STANDARD_MODE_BPS
#define testIotI2C_DEFAULT_TIMEOUT 500 /**< 500 msec */
#define testIotI2C_FAST_TIMEOUT 100 /**< 100 msec */
#define testIotI2C_INVALID_IOCTL_INDEX UINT32_MAX
#define testIotI2C_INVALID_IOCTL_INDEX UINT8_MAX
#define testIotI2C_HANDLE_NUM 4
#define testIotI2C_MAX_TIMEOUT pdMS_TO_TICKS( 10000 )
#define testIotI2C_MESSAGE_LENGTH 50
Expand Down Expand Up @@ -126,6 +126,9 @@ TEST_TEAR_DOWN( TEST_IOT_I2C )
void prvI2CCallback( IotI2COperationStatus_t xOpStatus,
void * pvParam )
{
/* Disable unused parameter warning. */
( void ) pvParam;

if( xOpStatus == eI2CCompleted )
{
xSemaphoreGiveFromISR( xtestIotI2CSemaphore, NULL );
Expand Down Expand Up @@ -484,7 +487,7 @@ TEST( TEST_IOT_I2C, AFQP_IotI2CReadAsyncAssisted )
TEST_ASSERT_EQUAL( IOT_I2C_SUCCESS, lRetVal );

/* Read from i2c device */
lRetVal = iot_i2c_read_async( xI2CHandle, &ucReadBuf, sizeof( ucReadBuf ) );
lRetVal = iot_i2c_read_async( xI2CHandle, ucReadBuf, sizeof( ucReadBuf ) );
TEST_ASSERT_EQUAL( IOT_I2C_SUCCESS, lRetVal );

lRetVal = xSemaphoreTake( xtestIotI2CSemaphore, testIotI2C_MAX_TIMEOUT );
Expand Down Expand Up @@ -1188,7 +1191,7 @@ TEST( TEST_IOT_I2C, AFQP_IotI2CReadSyncAssisted )
TEST_ASSERT_EQUAL( IOT_I2C_SUCCESS, lRetVal );

/* Read from i2c device */
lRetVal = iot_i2c_read_sync( xI2CHandle, &ucReadBuf, sizeof( ucReadBuf ) );
lRetVal = iot_i2c_read_sync( xI2CHandle, ucReadBuf, sizeof( ucReadBuf ) );
TEST_ASSERT_EQUAL( IOT_I2C_SUCCESS, lRetVal );
}

Expand Down
4 changes: 4 additions & 0 deletions libraries/abstractions/common_io/test/test_iot_spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ static void prvOutputMessage();
static void prvSpiAsyncCallback( IotSPITransactionStatus_t xStatus,
void * pvUserContext )
{
/* Disable unused parameter warning. */
( void ) xStatus;
( void ) pvUserContext;

xSemaphoreGiveFromISR( xtestIotSPISemaphore, NULL );
}
/*-----------------------------------------------------------*/
Expand Down
26 changes: 14 additions & 12 deletions libraries/abstractions/common_io/test/test_iot_uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ static IotUARTConfig_t xSampleConfig2 =
static void prvReadWriteCallback( IotUARTOperationStatus_t xOpStatus,
void * pvParams )
{
/* Disable unused parameter warning. */
( void ) pvParams;

if( xOpStatus == eUartReadCompleted )
{
xSemaphoreGiveFromISR( xReadCompleteSemaphore, NULL );
Expand Down Expand Up @@ -175,7 +178,7 @@ TEST( TEST_IOT_UART, AFQP_AssistedIotUARTWriteReadSync )
uint8_t cpBuffer[ testIotUARTBUFFERSIZE ] = { 0 };
uint8_t cpBufferRead[ testIotUARTBUFFERSIZE ] = { 0 };

strncpy( ( char * ) cpBuffer, ( char * ) testIotUART_BUFFER_STRING, testIotUART_BUFFER_LENGTH );
memcpy( cpBuffer, testIotUART_BUFFER_STRING, testIotUART_BUFFER_LENGTH );
IotUARTHandle_t xUartHandle;
int32_t lRead, lWrite, lClose;

Expand Down Expand Up @@ -299,7 +302,7 @@ TEST( TEST_IOT_UART, AFQP_AssistedIotUARTBaudChange )
uint8_t cpBuffer[ testIotUARTBUFFERSIZE ] = { 0 };
uint8_t cpBufferRead[ testIotUARTBUFFERSIZE ] = { 0 };

strncpy( ( char * ) cpBuffer, ( char * ) testIotUART_BAUD_RATE_STRING, testIotUART_BAUD_RATE_BUFFER_TEST_LENGTH );
memcpy( cpBuffer, testIotUART_BAUD_RATE_STRING, testIotUART_BAUD_RATE_BUFFER_TEST_LENGTH );

xUartHandle = iot_uart_open( uctestIotUartPort );
TEST_ASSERT_NOT_EQUAL( NULL, xUartHandle );
Expand All @@ -324,7 +327,7 @@ TEST( TEST_IOT_UART, AFQP_AssistedIotUARTBaudChange )
vTaskDelay( pdMS_TO_TICKS( testIotUART_DELAY ) );

memset( cpBuffer, 0, testIotUARTBUFFERSIZE );
strncpy( ( char * ) cpBuffer, ( char * ) testIotUART_BUFFER_STRING, testIotUART_BUFFER_LENGTH );
memcpy( cpBuffer, testIotUART_BUFFER_STRING, testIotUART_BUFFER_LENGTH );

lWrite = iot_uart_write_sync( xUartHandle, cpBuffer, testIotUART_BUFFER_LENGTH );
TEST_ASSERT_EQUAL( IOT_UART_SUCCESS, lWrite );
Expand All @@ -334,7 +337,7 @@ TEST( TEST_IOT_UART, AFQP_AssistedIotUARTBaudChange )

TEST_ASSERT_EQUAL( 0, strncmp( ( char * ) cpBuffer, ( char * ) cpBufferRead, testIotUART_BUFFER_LENGTH ) );

strncpy( ( char * ) cpBuffer, ( char * ) testIotUART_BAUD_RATE_DEFAULT_STRING, testIotUART_BAUD_RATE_BUFFER_DEFAULT_LENGTH );
memcpy( cpBuffer, testIotUART_BAUD_RATE_DEFAULT_STRING, testIotUART_BAUD_RATE_BUFFER_DEFAULT_LENGTH );

/* Signal other device to revert to original baudrate */
lWrite = iot_uart_write_sync( xUartHandle, cpBuffer, testIotUART_BAUD_RATE_BUFFER_DEFAULT_LENGTH );
Expand All @@ -349,7 +352,7 @@ TEST( TEST_IOT_UART, AFQP_AssistedIotUARTBaudChange )
/* Wait for other UART to change baudrate. */
vTaskDelay( pdMS_TO_TICKS( testIotUART_DELAY ) );

strncpy( ( char * ) cpBuffer, ( char * ) testIotUART_BUFFER_STRING, testIotUART_BUFFER_LENGTH );
memcpy( cpBuffer, testIotUART_BUFFER_STRING, testIotUART_BUFFER_LENGTH );

lWrite = iot_uart_write_sync( xUartHandle, cpBuffer, testIotUART_BUFFER_LENGTH );
TEST_ASSERT_EQUAL( IOT_UART_SUCCESS, lWrite );
Expand Down Expand Up @@ -384,7 +387,7 @@ TEST( TEST_IOT_UART, AFQP_IotUARTWriteAsyncReadAsyncLoopbackTest )
uint8_t cpBufferRead[ testIotUART_BUFFER_LENGTH + 1 ] = { 0 };
uint8_t uStringCompare = 1;

strncpy( ( char * ) cpBuffer, testIotUART_BUFFER_STRING, testIotUART_BUFFER_LENGTH );
memcpy( cpBuffer, testIotUART_BUFFER_STRING, testIotUART_BUFFER_LENGTH );

xUartHandle = iot_uart_open( uctestIotUartPort );
TEST_ASSERT_NOT_EQUAL( NULL, xUartHandle );
Expand Down Expand Up @@ -477,7 +480,7 @@ TEST( TEST_IOT_UART, AFQP_IotUARTWriteReadAsyncWithCallback )
uint8_t cpBuffer[ testIotUARTBUFFERSIZE ] = { 0 };
uint8_t cpBufferRead[ testIotUARTBUFFERSIZE ] = { 0 };

strncpy( ( char * ) cpBuffer, ( char * ) testIotUART_BUFFER_STRING, testIotUART_BUFFER_LENGTH );
memcpy( cpBuffer, testIotUART_BUFFER_STRING, testIotUART_BUFFER_LENGTH );
int32_t lRead, lWrite, lClose;
BaseType_t xCallbackReturn;
uint8_t ucPort = uctestIotUartPort;
Expand Down Expand Up @@ -525,7 +528,7 @@ TEST( TEST_IOT_UART, AFQP_IotUARTCancel )
uint8_t cpBuffer[ testIotUARTBUFFERSIZE ] = { 0 };
uint8_t uSmallBuflen = sizeof( cSmallBuf ) / sizeof( uint8_t );

strncpy( ( char * ) cpBuffer, testIotUART_BUFFER_STRING, testIotUART_BUFFER_LENGTH );
memcpy( cpBuffer, testIotUART_BUFFER_STRING, testIotUART_BUFFER_LENGTH );

xUartHandle = iot_uart_open( uctestIotUartPort );
TEST_ASSERT_NOT_EQUAL( NULL, xUartHandle );
Expand Down Expand Up @@ -573,7 +576,7 @@ TEST( TEST_IOT_UART, AFQP_IotUARTWriteAsyncFuzzing )

uint8_t cpBuffer[ testIotUARTBUFFERSIZE ] = { 0 };

strncpy( ( char * ) cpBuffer, testIotUART_BUFFER_STRING, testIotUART_BUFFER_LENGTH );
memcpy( cpBuffer, testIotUART_BUFFER_STRING, testIotUART_BUFFER_LENGTH );

lWrite = iot_uart_write_async( NULL, cpBuffer, testIotUART_BUFFER_LENGTH );
TEST_ASSERT_EQUAL( IOT_UART_INVALID_VALUE, lWrite );
Expand Down Expand Up @@ -607,7 +610,7 @@ TEST( TEST_IOT_UART, AFQP_IotUARTWriteSyncFuzzing )

uint8_t cpBuffer[ testIotUARTBUFFERSIZE ] = { 0 };

strncpy( ( char * ) cpBuffer, testIotUART_BUFFER_STRING, testIotUART_BUFFER_LENGTH );
memcpy( cpBuffer, testIotUART_BUFFER_STRING, testIotUART_BUFFER_LENGTH );

lWrite = iot_uart_write_sync( NULL, cpBuffer, testIotUART_BUFFER_LENGTH );
TEST_ASSERT_EQUAL( IOT_UART_INVALID_VALUE, lWrite );
Expand Down Expand Up @@ -745,10 +748,9 @@ TEST( TEST_IOT_UART, AFQP_IotUARTIoctlWhenBusy )
{
IotUARTHandle_t xUartHandle;
int32_t lIoctl, lWrite, lClose;
BaseType_t xCallbackReturn;
uint8_t cpBuffer[ testIotUARTBUFFERSIZE ] = { 0 };

strncpy( ( char * ) cpBuffer, ( char * ) testIotUART_BUFFER_STRING, testIotUART_BUFFER_LENGTH );
memcpy( cpBuffer, testIotUART_BUFFER_STRING, testIotUART_BUFFER_LENGTH );
IotUARTConfig_t xUartConfig = { .ulBaudrate = testIotUART_TEST_BAUD_RATE_DEFAULT };

xUartHandle = iot_uart_open( uctestIotUartPort );
Expand Down
7 changes: 0 additions & 7 deletions libraries/abstractions/wifi/test/iot_test_wifi.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,13 +163,6 @@
#define testwifiTASK_SYNC_TIMEOUT pdMS_TO_TICKS( 30000 )
#endif

/* The event group used to synchronize the Wi-Fi multi-task tests. */
static EventGroupHandle_t xTaskFinishEventGroupHandle;

/* The event group to synchronize task connection and disconnection in the Wi-Fi
* multi-task test. */
static EventGroupHandle_t xTaskConnectDisconnectSyncEventGroupHandle;

/* Task status for WiFiSeperateTasksConnectingAndDisconnectingAtOnce test. */
typedef struct
{
Expand Down

0 comments on commit 634318e

Please sign in to comment.