Merge pull request #12658 from VeijoPesonen/fix_tests-integration-fs

tests-integration;tests-filesystem: fix code causing compiler warnings and enable more tests
pull/12670/head
Martin Kojtal 2020-03-23 12:31:13 +01:00 committed by GitHub
commit ef2c1c89e6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 38 additions and 119 deletions

View File

@ -101,7 +101,7 @@ size_t download_test(NetworkInterface *interface, const unsigned char *data, siz
break;
}
ThisThread::sleep_for(1000);
tr_info("[NET-%d] Connection failed. Retry %d of %d", thread_id, tries, MAX_RETRIES);
tr_info("[NET-%" PRIu32 "] Connection failed. Retry %d of %d", thread_id, tries, MAX_RETRIES);
}
TEST_ASSERT_EQUAL_INT_MESSAGE(0, result, "failed to connect");
@ -119,7 +119,7 @@ size_t download_test(NetworkInterface *interface, const unsigned char *data, siz
} else {
TEST_ASSERT_MESSAGE(0, "wrong thread id");
}
tr_info("[NET-%d] Registered socket callback function", thread_id);
tr_info("[NET-%" PRIu32 "] Registered socket callback function", thread_id);
event_fired[thread_id] = false;
/* setup request */
@ -128,7 +128,7 @@ size_t download_test(NetworkInterface *interface, const unsigned char *data, siz
/* construct request */
size_t req_len = snprintf(request, REQ_BUF_SIZE - 1, req_template, dl_path, dl_host);
request[req_len] = 0;
tr_info("[NET-%d] Request header (%u): %s", thread_id, req_len, request);
tr_info("[NET-%" PRIu32 "] Request header (%u): %s", thread_id, req_len, request);
/* send request to server */
result = tcpsocket.send(request, req_len);
@ -138,7 +138,7 @@ size_t download_test(NetworkInterface *interface, const unsigned char *data, siz
char *receive_buffer = &g_receive_buffer[thread_id * RECV_BUF_SIZE];
tcpsocket.set_blocking(false);
tr_info("[NET-%d] Non-blocking socket mode set", thread_id);
tr_info("[NET-%" PRIu32 "] Non-blocking socket mode set", thread_id);
size_t received_bytes = 0;
int body_index = -1;
@ -174,7 +174,7 @@ size_t download_test(NetworkInterface *interface, const unsigned char *data, siz
if (body_index < 0) {
continue;
} else {
tr_info("[NET-%d] Found body index: %d", thread_id, body_index);
tr_info("[NET-%" PRIu32 "] Found body index: %d", thread_id, body_index);
/* remove header before comparison */
memmove(receive_buffer, &receive_buffer[body_index + 4], result - body_index - 4);
@ -194,7 +194,7 @@ size_t download_test(NetworkInterface *interface, const unsigned char *data, siz
speed = float(received_bytes) / timer.read();
percent = float(received_bytes) * 100 / float(data_length);
time_left = (data_length - received_bytes) / speed;
tr_info("[NET-%d] Received bytes: %u, (%.2f%%, %.2fKB/s, ETA: %02d:%02d:%02d)",
tr_info("[NET-%" PRIu32 "] Received bytes: %u, (%.2f%%, %.2fKB/s, ETA: %02" PRIu32 ":%02" PRIu32 ":%02" PRIu32 ")",
thread_id, received_bytes, percent, speed / 1024,
time_left / 3600, (time_left / 60) % 60, time_left % 60);
}
@ -205,7 +205,7 @@ size_t download_test(NetworkInterface *interface, const unsigned char *data, siz
timer.stop();
float f_received_bytes = float(received_bytes);
tr_info("[NET-%d] Downloaded: %.2fKB (%.2fKB/s, %.2f secs)", thread_id,
tr_info("[NET-%" PRIu32 "] Downloaded: %.2fKB (%.2fKB/s, %.2f secs)", thread_id,
f_received_bytes / 1024.,
f_received_bytes / (timer.read() * 1024.),
timer.read());

View File

@ -1,12 +1,11 @@
{
"target_overrides": {
"NUCLEO_F412ZG": {
"target.components_add" : ["SD"],
"target.components_add" : ["SD", "WIFI_WIZFI310"],
"sd.SPI_MOSI" : "D11",
"sd.SPI_MISO" : "D12",
"sd.SPI_CLK" : "D13",
"sd.SPI_CS" : "D10",
"target.components_add" : ["WIFI_WIZFI310"],
"target.network-default-interface-type" : "WIFI",
"wizfi310.tx" : "PD_5",
"wizfi310.rx" : "PD_6",
@ -47,12 +46,11 @@
},
"NUCLEO_L476RG": {
"target.macros_remove" : ["MBED_TICKLESS"],
"target.components_add" : ["SD"],
"target.components_add" : ["SD", "WIFI_WIZFI310"],
"sd.SPI_MOSI" : "D11",
"sd.SPI_MISO" : "D12",
"sd.SPI_CLK" : "D13",
"sd.SPI_CS" : "D10",
"target.components_add" : ["WIFI_WIZFI310"],
"target.network-default-interface-type" : "WIFI",
"wizfi310.tx" : "D8",
"wizfi310.rx" : "D2",
@ -66,13 +64,12 @@
},
"NUCLEO_L4R5ZI": {
"target.macros_remove" : ["MBED_TICKLESS"],
"target.components_add" : ["SD"],
"target.components_add" : ["SD", "WIFI_WIZFI310"],
"sd.SPI_MOSI" : "D11",
"sd.SPI_MISO" : "D12",
"sd.SPI_CLK" : "D13",
"sd.SPI_CS" : "D10",
"target.network-default-interface-type" : "WIFI",
"target.components_add" : ["WIFI_WIZFI310"],
"wizfi310.tx" : "D1",
"wizfi310.rx" : "D0",
"wizfi310.rts" : "PB_1",
@ -84,12 +81,11 @@
},
"NUCLEO_L496ZG": {
"target.macros_remove" : ["MBED_TICKLESS"],
"target.components_add" : ["SD"],
"target.components_add" : ["SD", "WIFI_WIZFI310"],
"sd.SPI_MOSI" : "D11",
"sd.SPI_MISO" : "D12",
"sd.SPI_CLK" : "D13",
"sd.SPI_CS" : "D10",
"target.components_add" : ["WIFI_WIZFI310"],
"target.network-default-interface-type" : "WIFI",
"wizfi310.tx" : "D1",
"wizfi310.rx" : "D0",

View File

@ -77,43 +77,25 @@ static control_t test_format(const size_t call_count)
static uint32_t thread_counter = 0;
void file_fn(size_t buffer)
void file_fn(size_t *block_size)
{
uint32_t thread_id = core_util_atomic_incr_u32(&thread_counter, 1);
char filename[255] = { 0 };
snprintf(filename, 255, "mbed-file-test-%d.txt", thread_id);
file_test_write(filename, 0, story, sizeof(story), buffer);
file_test_read(filename, 0, story, sizeof(story), buffer);
}
void file_4b_fn()
{
return file_fn(4);
}
void file_256b_fn()
{
return file_fn(256);
}
void file_1kb_fn()
{
return file_fn(1024);
}
void file_2kb_fn()
{
return file_fn(2048);
}
void file_4kb_fn()
{
return file_fn(4096);
snprintf(filename, 255, "mbed-file-test-%" PRIu32 ".txt", thread_id);
file_test_write(filename, 0, story, sizeof(story), *block_size);
file_test_read(filename, 0, story, sizeof(story), *block_size);
}
static control_t file_2_threads(const size_t call_count)
{
thread_counter = 0;
size_t block_size1 = 4;
size_t block_size2 = 256;
Thread t1;
Thread t2;
t1.start(file_4b_fn);
t2.start(file_256b_fn);
t1.start(callback(file_fn, &block_size1));
t2.start(callback(file_fn, &block_size2));
t1.join();
t2.join();
@ -123,13 +105,16 @@ static control_t file_2_threads(const size_t call_count)
static control_t file_3_threads(const size_t call_count)
{
thread_counter = 0;
size_t block_size1 = 256;
size_t block_size2 = 1024;
size_t block_size3 = 4096;
Thread t1;
Thread t2;
Thread t3;
t1.start(file_256b_fn);
t2.start(file_1kb_fn);
t3.start(file_4kb_fn);
t1.start(callback(file_fn, &block_size1));
t2.start(callback(file_fn, &block_size2));
t3.start(callback(file_fn, &block_size3));
t1.join();
t2.join();
t3.join();
@ -137,26 +122,6 @@ static control_t file_3_threads(const size_t call_count)
return CaseNext;
}
static control_t file_4_threads(const size_t call_count)
{
thread_counter = 0;
Thread t1;
Thread t2;
Thread t3;
Thread t4;
t1.start(file_256b_fn);
t2.start(file_256b_fn);
t3.start(file_1kb_fn);
t4.start(file_2kb_fn);
t1.join();
t2.join();
t3.join();
t4.join();
return CaseNext;
}
utest::v1::status_t greentea_setup(const size_t number_of_cases)
{
GREENTEA_SETUP(10 * 60, "default_auto");

View File

@ -72,8 +72,7 @@ static control_t setup_network(const size_t call_count)
}
}
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, err);
tr_info("[NET] IP address is '%s'", interface->get_ip_address());
tr_info("[NET] MAC address is '%s'", interface->get_mac_address());
return CaseNext;
}

View File

@ -72,8 +72,7 @@ static control_t setup_network(const size_t call_count)
}
}
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, err);
tr_info("[NET] IP address is '%s'", net->get_ip_address());
tr_info("[NET] MAC address is '%s'", net->get_mac_address());
return CaseNext;
}
@ -102,7 +101,7 @@ static control_t download_2_threads(const size_t call_count)
Thread t1;
Thread t2;
t1.start(download_fn);
wait(0.5);
ThisThread::sleep_for(1);
t2.start(download_fn);
t2.join();
t1.join();
@ -127,26 +126,6 @@ static control_t download_3_threads(const size_t call_count)
return CaseNext;
}
static control_t download_4_threads(const size_t call_count)
{
thread_counter = 0;
Thread t1;
Thread t2;
Thread t3;
Thread t4;
t1.start(download_fn);
t2.start(download_fn);
t3.start(download_fn);
t4.start(download_fn);
t1.join();
t2.join();
t3.join();
t4.join();
return CaseNext;
}
utest::v1::status_t greentea_setup(const size_t number_of_cases)
{
GREENTEA_SETUP(12 * 60, "default_auto");

View File

@ -78,8 +78,7 @@ static control_t setup_network(const size_t call_count)
}
}
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, err);
tr_info("[NET] IP address is '%s'", interface->get_ip_address());
tr_info("[NET] MAC address is '%s'", interface->get_mac_address());
return CaseNext;
}
@ -113,7 +112,7 @@ void file_fn(size_t buffer)
{
uint32_t thread_id = core_util_atomic_incr_u32(&thread_counter, 1);
char filename[255] = { 0 };
snprintf(filename, 255, "mbed-file-test-%d.txt", thread_id);
snprintf(filename, 255, "mbed-file-test-%" PRIu32 ".txt", thread_id);
file_test_write(filename, 0, story, sizeof(story), buffer);
file_test_read(filename, 0, story, sizeof(story), buffer);
}
@ -154,7 +153,7 @@ static control_t stress_2_threads(const size_t call_count)
Thread t1;
Thread t2;
t1.start(file_1kb_fn);
wait(1);
ThisThread::sleep_for(1);
t2.start(download_fn);
t2.join();
t1.join();
@ -171,7 +170,7 @@ static control_t stress_3_threads(const size_t call_count)
Thread t3;
t1.start(file_256b_fn);
t2.start(file_1kb_fn);
wait(1);
ThisThread::sleep_for(1);
t3.start(download_fn);
t3.join();
t2.join();
@ -180,27 +179,6 @@ static control_t stress_3_threads(const size_t call_count)
return CaseNext;
}
static control_t stress_4_threads(const size_t call_count)
{
thread_counter = 0;
Thread t1;
Thread t2;
Thread t3;
Thread t4;
t1.start(file_256b_fn);
t2.start(file_256b_fn);
t3.start(file_256b_fn);
wait(1);
t4.start(download_fn);
t4.join();
t3.join();
t2.join();
t1.join();
return CaseNext;
}
template <uint32_t size>
void test_malloc()
{

View File

@ -20,17 +20,20 @@
#include "FileSystem.h"
#include <stdlib.h>
#include "LittleFileSystem.h"
#if COMPONENT_SPIF
#include "SPIFBlockDevice.h"
#include "LittleFileSystem.h"
#elif COMPONENT_QSPIF
#include "QSPIFBlockDevice.h"
#elif COMPONENT_OSPIF
#include "OSPIFBlockDevice.h"
#elif COMPONENT_SD
#include "SDBlockDevice.h"
#include "FATFileSystem.h"
#else
#error [NOT_SUPPORTED] storage test not supported on this platform
#endif
#if COMPONENT_SPIF || COMPONENT_SD
using namespace utest::v1;
using namespace mbed;
@ -2131,4 +2134,3 @@ int main()
return !Harness::run(specification);
}
#endif // COMPONENT_SPIF || COMPONENT_SD