Skip to content

tests-integration;tests-filesystem: fix code causing compiler warnings and enable more tests #12658

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions TESTS/integration/COMMON/download_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand All @@ -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 */
Expand All @@ -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);
Expand All @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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);
}
Expand All @@ -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());
Expand Down
12 changes: 4 additions & 8 deletions TESTS/integration/COMMON/target_extended.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand Down
63 changes: 14 additions & 49 deletions TESTS/integration/fs-threaded/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -123,36 +105,19 @@ 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.join();
t2.join();
t3.join();

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.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();
t4.join();

return CaseNext;
}
Expand Down
3 changes: 1 addition & 2 deletions TESTS/integration/net-single/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
25 changes: 2 additions & 23 deletions TESTS/integration/net-threaded/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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();
Expand All @@ -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");
Expand Down
30 changes: 4 additions & 26 deletions TESTS/integration/stress-net-fs/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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();
Expand All @@ -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();
Expand All @@ -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()
{
Expand Down
10 changes: 6 additions & 4 deletions features/storage/TESTS/filesystem/general_filesystem/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -2131,4 +2134,3 @@ int main()
return !Harness::run(specification);
}

#endif // COMPONENT_SPIF || COMPONENT_SD