tests: fix astyle

pull/8365/head
Martin Kojtal 2018-10-10 11:19:16 -05:00
parent 56eea3f582
commit bbfa322afb
13 changed files with 58 additions and 60 deletions

View File

@ -130,7 +130,7 @@ void test_thread(void)
char test[] = "123456789";
uint32_t crc;
MbedCRC<POLY_32BIT_ANSI, 32> ct;
TEST_ASSERT_EQUAL(0, ct.compute((void *)test, strlen((const char*)test), &crc));
TEST_ASSERT_EQUAL(0, ct.compute((void *)test, strlen((const char *)test), &crc));
TEST_ASSERT_EQUAL(0xCBF43926, crc);
}

View File

@ -25,7 +25,7 @@
#include <stdarg.h>
#if !MBED_MEM_TRACING_ENABLED
#error [NOT_SUPPORTED] test not supported
#error [NOT_SUPPORTED] test not supported
#endif
using utest::v1::Case;

View File

@ -151,7 +151,7 @@ static void _qspi_write_read_test(Qspi &qspi, qspi_bus_width_t write_inst_width,
TEST_ASSERT_EQUAL(QSPI_STATUS_OK, ret);
TEST_ASSERT_EQUAL(write_size, buf_len);
if(is_extended_mode(write_inst_width, write_addr_width, write_data_width)) {
if (is_extended_mode(write_inst_width, write_addr_width, write_data_width)) {
// on some flash chips in extended-SPI mode, control commands works only in 1-1-1 mode
// so switching back to 1-1-1 mode
qspi.cmd.configure(MODE_1_1_1, ADDR_SIZE_24, ALT_SIZE_8);
@ -195,7 +195,7 @@ static void _qspi_write_read_test(Qspi &qspi, qspi_bus_width_t write_inst_width,
}
qspi.cmd.set_dummy_cycles(0);
if(is_extended_mode(read_inst_width, read_addr_width, read_data_width)) {
if (is_extended_mode(read_inst_width, read_addr_width, read_data_width)) {
// on some flash chips in extended-SPI mode, control commands works only in 1-1-1 mode
// so switching back to 1-1-1 mode
qspi.cmd.configure(MODE_1_1_1, ADDR_SIZE_24, ALT_SIZE_8);

View File

@ -201,11 +201,11 @@ qspi_status_t erase(uint32_t erase_cmd, uint32_t flash_addr, Qspi &qspi)
qspi_status_t mode_enable(Qspi &qspi, qspi_bus_width_t inst_width, qspi_bus_width_t addr_width, qspi_bus_width_t data_width)
{
if(is_extended_mode(inst_width, addr_width, data_width)) {
if (is_extended_mode(inst_width, addr_width, data_width)) {
return extended_enable(qspi);
} else if(is_dual_mode(inst_width, addr_width, data_width)) {
} else if (is_dual_mode(inst_width, addr_width, data_width)) {
return dual_enable(qspi);
} else if(is_quad_mode(inst_width, addr_width, data_width)) {
} else if (is_quad_mode(inst_width, addr_width, data_width)) {
return quad_enable(qspi);
} else {
return QSPI_STATUS_OK;
@ -214,11 +214,11 @@ qspi_status_t mode_enable(Qspi &qspi, qspi_bus_width_t inst_width, qspi_bus_widt
qspi_status_t mode_disable(Qspi &qspi, qspi_bus_width_t inst_width, qspi_bus_width_t addr_width, qspi_bus_width_t data_width)
{
if(is_extended_mode(inst_width, addr_width, data_width)) {
if (is_extended_mode(inst_width, addr_width, data_width)) {
return extended_disable(qspi);
} else if(is_dual_mode(inst_width, addr_width, data_width)) {
} else if (is_dual_mode(inst_width, addr_width, data_width)) {
return dual_disable(qspi);
} else if(is_quad_mode(inst_width, addr_width, data_width)) {
} else if (is_quad_mode(inst_width, addr_width, data_width)) {
return quad_disable(qspi);
} else {
return QSPI_STATUS_OK;

View File

@ -83,10 +83,10 @@ void sleep_usticker_test()
const unsigned int wakeup_timestamp = us_ticker_read();
sprintf(info, "Delta ticks: %u, Ticker width: %u, Expected wake up tick: %d, Actual wake up tick: %d, delay ticks: %d, wake up after ticks: %d",
us_to_ticks(sleep_mode_delta_us, ticker_freq), ticker_width, next_match_timestamp, wakeup_timestamp, us_to_ticks(i, ticker_freq) , wakeup_timestamp - start_timestamp);
us_to_ticks(sleep_mode_delta_us, ticker_freq), ticker_width, next_match_timestamp, wakeup_timestamp, us_to_ticks(i, ticker_freq), wakeup_timestamp - start_timestamp);
TEST_ASSERT_MESSAGE(compare_timestamps(us_to_ticks(sleep_mode_delta_us, ticker_freq),
ticker_width, next_match_timestamp, wakeup_timestamp), info);
ticker_width, next_match_timestamp, wakeup_timestamp), info);
}
set_us_ticker_irq_handler(us_ticker_irq_handler_org);
@ -127,10 +127,10 @@ void deepsleep_lpticker_test()
const timestamp_t wakeup_timestamp = lp_ticker_read();
sprintf(info, "Delta ticks: %u, Ticker width: %u, Expected wake up tick: %d, Actual wake up tick: %d, delay ticks: %d, wake up after ticks: %d",
us_to_ticks(deepsleep_mode_delta_us, ticker_freq), ticker_width, next_match_timestamp, wakeup_timestamp, us_to_ticks(i, ticker_freq) , wakeup_timestamp - start_timestamp);
us_to_ticks(deepsleep_mode_delta_us, ticker_freq), ticker_width, next_match_timestamp, wakeup_timestamp, us_to_ticks(i, ticker_freq), wakeup_timestamp - start_timestamp);
TEST_ASSERT_MESSAGE(compare_timestamps(us_to_ticks(deepsleep_mode_delta_us, ticker_freq), ticker_width,
next_match_timestamp, wakeup_timestamp), info);
next_match_timestamp, wakeup_timestamp), info);
}
set_lp_ticker_irq_handler(lp_ticker_irq_handler_org);
@ -178,7 +178,7 @@ void deepsleep_high_speed_clocks_turned_off_test()
/* Check if we have woken-up after expected time. */
TEST_ASSERT_MESSAGE(compare_timestamps(us_to_ticks(deepsleep_mode_delta_us, lp_ticker_freq), lp_ticker_width,
wakeup_time, lp_ticks_after_sleep), info);
wakeup_time, lp_ticks_after_sleep), info);
}
#endif

View File

@ -72,10 +72,10 @@ base64_result_e trng_DecodeNBase64(const char *string,
}
*writePtr = 0;
while (( currPos < stringMaxSize ) &&
( string[currPos] != 0 ) &&
( writePtr < bufferEnd ) &&
( !isEndOfString )) {
while ((currPos < stringMaxSize) &&
(string[currPos] != 0) &&
(writePtr < bufferEnd) &&
(!isEndOfString)) {
uint8_t val;
if (string[currPos] == 0) {
@ -125,11 +125,11 @@ base64_result_e trng_DecodeNBase64(const char *string,
}
// Check if additional bytes should have been processed but buffer isn't sufficient.
if (( result == BASE64_SUCCESS ) &&
( !isEndOfString ) &&
( currPos < stringMaxSize ) &&
( string[currPos] != 0 ) &&
( string[currPos] != '=' ) ) {
if ((result == BASE64_SUCCESS) &&
(!isEndOfString) &&
(currPos < stringMaxSize) &&
(string[currPos] != 0) &&
(string[currPos] != '=')) {
return BASE64_BUFFER_TOO_SMALL;
}

View File

@ -92,7 +92,7 @@ static int fill_buffer_trng(uint8_t *buffer, trng_t *trng_obj, size_t trng_len)
void print_array(uint8_t *buffer, size_t size)
{
for (size_t i=0; i < size; i++) {
for (size_t i = 0; i < size; i++) {
utest_printf("%02x", buffer[i]);
}
utest_printf("\n");
@ -120,7 +120,7 @@ static void compress_and_compare(char *key, char *value)
uint32_t lengthWritten = 0;
uint32_t charsProcessed = 0;
result = trng_DecodeNBase64((const char *)value,
MSG_VALUE_LEN,
MSG_VALUE_LEN,
buffer,
BUFFER_LEN,
&lengthWritten,
@ -143,11 +143,11 @@ static void compress_and_compare(char *key, char *value)
(char *)out_comp_buf,
OUT_COMP_BUF_SIZE,
9);
if (comp_sz <= BUFFER_LEN){
print_array(buffer, BUFFER_LEN);
if (comp_sz <= BUFFER_LEN) {
print_array(buffer, BUFFER_LEN);
}
TEST_ASSERT_MESSAGE(comp_sz > BUFFER_LEN,
"TRNG_TEST_STEP1: trng_get_bytes was able to compress thus not random");
"TRNG_TEST_STEP1: trng_get_bytes was able to compress thus not random");
/*pithy_Compress will try to compress the random data with a different buffer size*/
result = fill_buffer_trng(temp_buf, &trng_obj, TEMP_BUF_SIZE);
@ -158,11 +158,11 @@ static void compress_and_compare(char *key, char *value)
(char *)out_comp_buf,
OUT_COMP_BUF_SIZE,
9);
if (comp_sz <= TEMP_BUF_SIZE){
print_array(temp_buf, TEMP_BUF_SIZE);
if (comp_sz <= TEMP_BUF_SIZE) {
print_array(temp_buf, TEMP_BUF_SIZE);
}
TEST_ASSERT_MESSAGE(comp_sz > TEMP_BUF_SIZE,
"TRNG_TEST_STEP2: trng_get_bytes was able to compress thus not random");
"TRNG_TEST_STEP2: trng_get_bytes was able to compress thus not random");
memcpy(input_buf + BUFFER_LEN, temp_buf, TEMP_BUF_SIZE);
/*pithy_Compress will try to compress the random data from before reset concatenated with new random data*/
@ -171,11 +171,11 @@ static void compress_and_compare(char *key, char *value)
(char *)out_comp_buf,
OUT_COMP_BUF_SIZE,
9);
if (comp_sz <= TEMP_BUF_SIZE + BUFFER_LEN){
print_array(input_buf, TEMP_BUF_SIZE + BUFFER_LEN);
if (comp_sz <= TEMP_BUF_SIZE + BUFFER_LEN) {
print_array(input_buf, TEMP_BUF_SIZE + BUFFER_LEN);
}
TEST_ASSERT_MESSAGE(comp_sz > TEMP_BUF_SIZE + BUFFER_LEN,
"TRNG_TEST_STEP3: concatenated buffer after reset was able to compress thus not random");
"TRNG_TEST_STEP3: concatenated buffer after reset was able to compress thus not random");
greentea_send_kv(MSG_TRNG_TEST_SUITE_ENDED, MSG_VALUE_DUMMY);
}
@ -184,9 +184,9 @@ static void compress_and_compare(char *key, char *value)
if (strcmp(key, MSG_TRNG_TEST_STEP1) == 0) {
int result = 0;
/*Using base64 to encode data sending from host*/
result = trng_EncodeBase64(buffer,
BUFFER_LEN,
(char *)out_comp_buf,
result = trng_EncodeBase64(buffer,
BUFFER_LEN,
(char *)out_comp_buf,
OUT_COMP_BUF_SIZE);
TEST_ASSERT_EQUAL(RESULT_SUCCESS, result);

View File

@ -67,7 +67,7 @@ void test_case_malloc_free_size()
TEST_ASSERT_EQUAL_UINT32(stats_start.alloc_cnt + 1, stats_current.alloc_cnt);
TEST_ASSERT_EQUAL_UINT32(stats_start.alloc_fail_cnt, stats_current.alloc_fail_cnt);
// Library header 0x4-0x8, stats header 0x8 and alignment addition 0x4
TEST_ASSERT_INT_WITHIN(0x8, stats_start.overhead_size + 0xC , stats_current.overhead_size);
TEST_ASSERT_INT_WITHIN(0x8, stats_start.overhead_size + 0xC, stats_current.overhead_size);
// Free memory and assert back to starting size
free(data);
mbed_stats_heap_get(&stats_current);
@ -97,7 +97,7 @@ void test_case_allocate_zero()
TEST_ASSERT_EQUAL_UINT32(stats_start.alloc_fail_cnt, stats_current.alloc_fail_cnt);
// Library header 0x4-0x8, stats header 0x8 and alignment addition 0x4
if (NULL != data) {
TEST_ASSERT_INT_WITHIN(0x8, stats_start.overhead_size + 0xC , stats_current.overhead_size);
TEST_ASSERT_INT_WITHIN(0x8, stats_start.overhead_size + 0xC, stats_current.overhead_size);
}
// Free memory and assert back to starting size
free(data);

View File

@ -199,7 +199,7 @@ void test_dual_thread_lock_lock_thread(Mutex *mutex)
bool stat = mutex->trylock_for(TEST_DELAY);
TEST_ASSERT_EQUAL(false, stat);
TEST_ASSERT_UINT32_WITHIN(5000, TEST_DELAY*1000, timer.read_us());
TEST_ASSERT_UINT32_WITHIN(5000, TEST_DELAY * 1000, timer.read_us());
}
/** Test dual thread lock

View File

@ -38,10 +38,10 @@ utest::v1::status_t test_setup(const size_t number_of_cases)
}
Case cases[] = {
Case("NETWORKINTERFACE_STATUS", NETWORKINTERFACE_STATUS),
Case("NETWORKINTERFACE_STATUS_NONBLOCK", NETWORKINTERFACE_STATUS_NONBLOCK),
Case("NETWORKINTERFACE_STATUS_GET", NETWORKINTERFACE_STATUS_GET),
Case("NETWORKINTERFACE_CONN_DISC_REPEAT", NETWORKINTERFACE_CONN_DISC_REPEAT),
Case("NETWORKINTERFACE_STATUS", NETWORKINTERFACE_STATUS),
Case("NETWORKINTERFACE_STATUS_NONBLOCK", NETWORKINTERFACE_STATUS_NONBLOCK),
Case("NETWORKINTERFACE_STATUS_GET", NETWORKINTERFACE_STATUS_GET),
Case("NETWORKINTERFACE_CONN_DISC_REPEAT", NETWORKINTERFACE_CONN_DISC_REPEAT),
};
Specification specification(test_setup, cases);

View File

@ -23,10 +23,9 @@
using namespace utest::v1;
namespace
{
NetworkInterface* net;
const int repeats = 5;
namespace {
NetworkInterface *net;
const int repeats = 5;
}
void NETWORKINTERFACE_CONN_DISC_REPEAT()

View File

@ -23,16 +23,15 @@
using namespace utest::v1;
namespace
{
NetworkInterface* net;
rtos::Semaphore status_semaphore;
int status_write_counter = 0;
int status_read_counter = 0;
const int repeats = 5;
const int status_buffer_size = 100;
nsapi_connection_status_t current_status = NSAPI_STATUS_ERROR_UNSUPPORTED;
nsapi_connection_status_t statuses[status_buffer_size];
namespace {
NetworkInterface *net;
rtos::Semaphore status_semaphore;
int status_write_counter = 0;
int status_read_counter = 0;
const int repeats = 5;
const int status_buffer_size = 100;
nsapi_connection_status_t current_status = NSAPI_STATUS_ERROR_UNSUPPORTED;
nsapi_connection_status_t statuses[status_buffer_size];
}
void status_cb(nsapi_event_t event, intptr_t value)

View File

@ -34,7 +34,7 @@ void wifi_connect_params_channel_fail(void)
return;
}
uint8_t wrong_channel = 1 + (MBED_CONF_APP_WIFI_CH_SECURE%10);
uint8_t wrong_channel = 1 + (MBED_CONF_APP_WIFI_CH_SECURE % 10);
nsapi_error_t error = wifi->connect(MBED_CONF_APP_WIFI_SECURE_SSID, MBED_CONF_APP_WIFI_PASSWORD, get_security(), wrong_channel);
TEST_ASSERT(error == NSAPI_ERROR_CONNECTION_TIMEOUT || error == NSAPI_ERROR_NO_CONNECTION);