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"; char test[] = "123456789";
uint32_t crc; uint32_t crc;
MbedCRC<POLY_32BIT_ANSI, 32> ct; 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); TEST_ASSERT_EQUAL(0xCBF43926, crc);
} }

View File

@ -25,7 +25,7 @@
#include <stdarg.h> #include <stdarg.h>
#if !MBED_MEM_TRACING_ENABLED #if !MBED_MEM_TRACING_ENABLED
#error [NOT_SUPPORTED] test not supported #error [NOT_SUPPORTED] test not supported
#endif #endif
using utest::v1::Case; 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(QSPI_STATUS_OK, ret);
TEST_ASSERT_EQUAL(write_size, buf_len); 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 // 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 // so switching back to 1-1-1 mode
qspi.cmd.configure(MODE_1_1_1, ADDR_SIZE_24, ALT_SIZE_8); 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); 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 // 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 // so switching back to 1-1-1 mode
qspi.cmd.configure(MODE_1_1_1, ADDR_SIZE_24, ALT_SIZE_8); 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) 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); 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); 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); return quad_enable(qspi);
} else { } else {
return QSPI_STATUS_OK; 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) 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); 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); 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); return quad_disable(qspi);
} else { } else {
return QSPI_STATUS_OK; return QSPI_STATUS_OK;

View File

@ -83,10 +83,10 @@ void sleep_usticker_test()
const unsigned int wakeup_timestamp = us_ticker_read(); 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", 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), 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); 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(); 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", 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, 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); 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. */ /* 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, 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 #endif

View File

@ -72,10 +72,10 @@ base64_result_e trng_DecodeNBase64(const char *string,
} }
*writePtr = 0; *writePtr = 0;
while (( currPos < stringMaxSize ) && while ((currPos < stringMaxSize) &&
( string[currPos] != 0 ) && (string[currPos] != 0) &&
( writePtr < bufferEnd ) && (writePtr < bufferEnd) &&
( !isEndOfString )) { (!isEndOfString)) {
uint8_t val; uint8_t val;
if (string[currPos] == 0) { 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. // Check if additional bytes should have been processed but buffer isn't sufficient.
if (( result == BASE64_SUCCESS ) && if ((result == BASE64_SUCCESS) &&
( !isEndOfString ) && (!isEndOfString) &&
( currPos < stringMaxSize ) && (currPos < stringMaxSize) &&
( string[currPos] != 0 ) && (string[currPos] != 0) &&
( string[currPos] != '=' ) ) { (string[currPos] != '=')) {
return BASE64_BUFFER_TOO_SMALL; 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) 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("%02x", buffer[i]);
} }
utest_printf("\n"); utest_printf("\n");
@ -143,11 +143,11 @@ static void compress_and_compare(char *key, char *value)
(char *)out_comp_buf, (char *)out_comp_buf,
OUT_COMP_BUF_SIZE, OUT_COMP_BUF_SIZE,
9); 9);
if (comp_sz <= BUFFER_LEN){ if (comp_sz <= BUFFER_LEN) {
print_array(buffer, BUFFER_LEN); print_array(buffer, BUFFER_LEN);
} }
TEST_ASSERT_MESSAGE(comp_sz > 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*/ /*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); 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, (char *)out_comp_buf,
OUT_COMP_BUF_SIZE, OUT_COMP_BUF_SIZE,
9); 9);
if (comp_sz <= TEMP_BUF_SIZE){ if (comp_sz <= TEMP_BUF_SIZE) {
print_array(temp_buf, TEMP_BUF_SIZE); print_array(temp_buf, TEMP_BUF_SIZE);
} }
TEST_ASSERT_MESSAGE(comp_sz > 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); 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*/ /*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, (char *)out_comp_buf,
OUT_COMP_BUF_SIZE, OUT_COMP_BUF_SIZE,
9); 9);
if (comp_sz <= TEMP_BUF_SIZE + BUFFER_LEN){ if (comp_sz <= TEMP_BUF_SIZE + BUFFER_LEN) {
print_array(input_buf, TEMP_BUF_SIZE + BUFFER_LEN); print_array(input_buf, TEMP_BUF_SIZE + BUFFER_LEN);
} }
TEST_ASSERT_MESSAGE(comp_sz > 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); greentea_send_kv(MSG_TRNG_TEST_SUITE_ENDED, MSG_VALUE_DUMMY);
} }

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_cnt + 1, stats_current.alloc_cnt);
TEST_ASSERT_EQUAL_UINT32(stats_start.alloc_fail_cnt, stats_current.alloc_fail_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 // 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 memory and assert back to starting size
free(data); free(data);
mbed_stats_heap_get(&stats_current); 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); 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 // Library header 0x4-0x8, stats header 0x8 and alignment addition 0x4
if (NULL != data) { 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 memory and assert back to starting size
free(data); free(data);

View File

@ -199,7 +199,7 @@ void test_dual_thread_lock_lock_thread(Mutex *mutex)
bool stat = mutex->trylock_for(TEST_DELAY); bool stat = mutex->trylock_for(TEST_DELAY);
TEST_ASSERT_EQUAL(false, stat); 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 /** 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 cases[] = {
Case("NETWORKINTERFACE_STATUS", NETWORKINTERFACE_STATUS), Case("NETWORKINTERFACE_STATUS", NETWORKINTERFACE_STATUS),
Case("NETWORKINTERFACE_STATUS_NONBLOCK", NETWORKINTERFACE_STATUS_NONBLOCK), Case("NETWORKINTERFACE_STATUS_NONBLOCK", NETWORKINTERFACE_STATUS_NONBLOCK),
Case("NETWORKINTERFACE_STATUS_GET", NETWORKINTERFACE_STATUS_GET), Case("NETWORKINTERFACE_STATUS_GET", NETWORKINTERFACE_STATUS_GET),
Case("NETWORKINTERFACE_CONN_DISC_REPEAT", NETWORKINTERFACE_CONN_DISC_REPEAT), Case("NETWORKINTERFACE_CONN_DISC_REPEAT", NETWORKINTERFACE_CONN_DISC_REPEAT),
}; };
Specification specification(test_setup, cases); Specification specification(test_setup, cases);

View File

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

View File

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

View File

@ -34,7 +34,7 @@ void wifi_connect_params_channel_fail(void)
return; 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); 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); TEST_ASSERT(error == NSAPI_ERROR_CONNECTION_TIMEOUT || error == NSAPI_ERROR_NO_CONNECTION);