Skip to content

Commit ef2c1c8

Browse files
authored
Merge pull request #12658 from VeijoPesonen/fix_tests-integration-fs
tests-integration;tests-filesystem: fix code causing compiler warnings and enable more tests
2 parents cc799a8 + 244c2fb commit ef2c1c8

File tree

7 files changed

+38
-119
lines changed

7 files changed

+38
-119
lines changed

TESTS/integration/COMMON/download_test.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ size_t download_test(NetworkInterface *interface, const unsigned char *data, siz
101101
break;
102102
}
103103
ThisThread::sleep_for(1000);
104-
tr_info("[NET-%d] Connection failed. Retry %d of %d", thread_id, tries, MAX_RETRIES);
104+
tr_info("[NET-%" PRIu32 "] Connection failed. Retry %d of %d", thread_id, tries, MAX_RETRIES);
105105
}
106106
TEST_ASSERT_EQUAL_INT_MESSAGE(0, result, "failed to connect");
107107

@@ -119,7 +119,7 @@ size_t download_test(NetworkInterface *interface, const unsigned char *data, siz
119119
} else {
120120
TEST_ASSERT_MESSAGE(0, "wrong thread id");
121121
}
122-
tr_info("[NET-%d] Registered socket callback function", thread_id);
122+
tr_info("[NET-%" PRIu32 "] Registered socket callback function", thread_id);
123123
event_fired[thread_id] = false;
124124

125125
/* setup request */
@@ -128,7 +128,7 @@ size_t download_test(NetworkInterface *interface, const unsigned char *data, siz
128128
/* construct request */
129129
size_t req_len = snprintf(request, REQ_BUF_SIZE - 1, req_template, dl_path, dl_host);
130130
request[req_len] = 0;
131-
tr_info("[NET-%d] Request header (%u): %s", thread_id, req_len, request);
131+
tr_info("[NET-%" PRIu32 "] Request header (%u): %s", thread_id, req_len, request);
132132

133133
/* send request to server */
134134
result = tcpsocket.send(request, req_len);
@@ -138,7 +138,7 @@ size_t download_test(NetworkInterface *interface, const unsigned char *data, siz
138138
char *receive_buffer = &g_receive_buffer[thread_id * RECV_BUF_SIZE];
139139

140140
tcpsocket.set_blocking(false);
141-
tr_info("[NET-%d] Non-blocking socket mode set", thread_id);
141+
tr_info("[NET-%" PRIu32 "] Non-blocking socket mode set", thread_id);
142142

143143
size_t received_bytes = 0;
144144
int body_index = -1;
@@ -174,7 +174,7 @@ size_t download_test(NetworkInterface *interface, const unsigned char *data, siz
174174
if (body_index < 0) {
175175
continue;
176176
} else {
177-
tr_info("[NET-%d] Found body index: %d", thread_id, body_index);
177+
tr_info("[NET-%" PRIu32 "] Found body index: %d", thread_id, body_index);
178178

179179
/* remove header before comparison */
180180
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
194194
speed = float(received_bytes) / timer.read();
195195
percent = float(received_bytes) * 100 / float(data_length);
196196
time_left = (data_length - received_bytes) / speed;
197-
tr_info("[NET-%d] Received bytes: %u, (%.2f%%, %.2fKB/s, ETA: %02d:%02d:%02d)",
197+
tr_info("[NET-%" PRIu32 "] Received bytes: %u, (%.2f%%, %.2fKB/s, ETA: %02" PRIu32 ":%02" PRIu32 ":%02" PRIu32 ")",
198198
thread_id, received_bytes, percent, speed / 1024,
199199
time_left / 3600, (time_left / 60) % 60, time_left % 60);
200200
}
@@ -205,7 +205,7 @@ size_t download_test(NetworkInterface *interface, const unsigned char *data, siz
205205

206206
timer.stop();
207207
float f_received_bytes = float(received_bytes);
208-
tr_info("[NET-%d] Downloaded: %.2fKB (%.2fKB/s, %.2f secs)", thread_id,
208+
tr_info("[NET-%" PRIu32 "] Downloaded: %.2fKB (%.2fKB/s, %.2f secs)", thread_id,
209209
f_received_bytes / 1024.,
210210
f_received_bytes / (timer.read() * 1024.),
211211
timer.read());

TESTS/integration/COMMON/target_extended.json

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
{
22
"target_overrides": {
33
"NUCLEO_F412ZG": {
4-
"target.components_add" : ["SD"],
4+
"target.components_add" : ["SD", "WIFI_WIZFI310"],
55
"sd.SPI_MOSI" : "D11",
66
"sd.SPI_MISO" : "D12",
77
"sd.SPI_CLK" : "D13",
88
"sd.SPI_CS" : "D10",
9-
"target.components_add" : ["WIFI_WIZFI310"],
109
"target.network-default-interface-type" : "WIFI",
1110
"wizfi310.tx" : "PD_5",
1211
"wizfi310.rx" : "PD_6",
@@ -47,12 +46,11 @@
4746
},
4847
"NUCLEO_L476RG": {
4948
"target.macros_remove" : ["MBED_TICKLESS"],
50-
"target.components_add" : ["SD"],
49+
"target.components_add" : ["SD", "WIFI_WIZFI310"],
5150
"sd.SPI_MOSI" : "D11",
5251
"sd.SPI_MISO" : "D12",
5352
"sd.SPI_CLK" : "D13",
5453
"sd.SPI_CS" : "D10",
55-
"target.components_add" : ["WIFI_WIZFI310"],
5654
"target.network-default-interface-type" : "WIFI",
5755
"wizfi310.tx" : "D8",
5856
"wizfi310.rx" : "D2",
@@ -66,13 +64,12 @@
6664
},
6765
"NUCLEO_L4R5ZI": {
6866
"target.macros_remove" : ["MBED_TICKLESS"],
69-
"target.components_add" : ["SD"],
67+
"target.components_add" : ["SD", "WIFI_WIZFI310"],
7068
"sd.SPI_MOSI" : "D11",
7169
"sd.SPI_MISO" : "D12",
7270
"sd.SPI_CLK" : "D13",
7371
"sd.SPI_CS" : "D10",
7472
"target.network-default-interface-type" : "WIFI",
75-
"target.components_add" : ["WIFI_WIZFI310"],
7673
"wizfi310.tx" : "D1",
7774
"wizfi310.rx" : "D0",
7875
"wizfi310.rts" : "PB_1",
@@ -84,12 +81,11 @@
8481
},
8582
"NUCLEO_L496ZG": {
8683
"target.macros_remove" : ["MBED_TICKLESS"],
87-
"target.components_add" : ["SD"],
84+
"target.components_add" : ["SD", "WIFI_WIZFI310"],
8885
"sd.SPI_MOSI" : "D11",
8986
"sd.SPI_MISO" : "D12",
9087
"sd.SPI_CLK" : "D13",
9188
"sd.SPI_CS" : "D10",
92-
"target.components_add" : ["WIFI_WIZFI310"],
9389
"target.network-default-interface-type" : "WIFI",
9490
"wizfi310.tx" : "D1",
9591
"wizfi310.rx" : "D0",

TESTS/integration/fs-threaded/main.cpp

Lines changed: 14 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -77,43 +77,25 @@ static control_t test_format(const size_t call_count)
7777

7878
static uint32_t thread_counter = 0;
7979

80-
void file_fn(size_t buffer)
80+
void file_fn(size_t *block_size)
8181
{
8282
uint32_t thread_id = core_util_atomic_incr_u32(&thread_counter, 1);
8383
char filename[255] = { 0 };
84-
snprintf(filename, 255, "mbed-file-test-%d.txt", thread_id);
85-
file_test_write(filename, 0, story, sizeof(story), buffer);
86-
file_test_read(filename, 0, story, sizeof(story), buffer);
87-
}
88-
void file_4b_fn()
89-
{
90-
return file_fn(4);
91-
}
92-
void file_256b_fn()
93-
{
94-
return file_fn(256);
95-
}
96-
void file_1kb_fn()
97-
{
98-
return file_fn(1024);
99-
}
100-
void file_2kb_fn()
101-
{
102-
return file_fn(2048);
103-
}
104-
void file_4kb_fn()
105-
{
106-
return file_fn(4096);
84+
snprintf(filename, 255, "mbed-file-test-%" PRIu32 ".txt", thread_id);
85+
file_test_write(filename, 0, story, sizeof(story), *block_size);
86+
file_test_read(filename, 0, story, sizeof(story), *block_size);
10787
}
10888

10989
static control_t file_2_threads(const size_t call_count)
11090
{
11191
thread_counter = 0;
92+
size_t block_size1 = 4;
93+
size_t block_size2 = 256;
11294

11395
Thread t1;
11496
Thread t2;
115-
t1.start(file_4b_fn);
116-
t2.start(file_256b_fn);
97+
t1.start(callback(file_fn, &block_size1));
98+
t2.start(callback(file_fn, &block_size2));
11799
t1.join();
118100
t2.join();
119101

@@ -123,36 +105,19 @@ static control_t file_2_threads(const size_t call_count)
123105
static control_t file_3_threads(const size_t call_count)
124106
{
125107
thread_counter = 0;
108+
size_t block_size1 = 256;
109+
size_t block_size2 = 1024;
110+
size_t block_size3 = 4096;
126111

127112
Thread t1;
128113
Thread t2;
129114
Thread t3;
130-
t1.start(file_256b_fn);
131-
t2.start(file_1kb_fn);
132-
t3.start(file_4kb_fn);
133-
t1.join();
134-
t2.join();
135-
t3.join();
136-
137-
return CaseNext;
138-
}
139-
140-
static control_t file_4_threads(const size_t call_count)
141-
{
142-
thread_counter = 0;
143-
144-
Thread t1;
145-
Thread t2;
146-
Thread t3;
147-
Thread t4;
148-
t1.start(file_256b_fn);
149-
t2.start(file_256b_fn);
150-
t3.start(file_1kb_fn);
151-
t4.start(file_2kb_fn);
115+
t1.start(callback(file_fn, &block_size1));
116+
t2.start(callback(file_fn, &block_size2));
117+
t3.start(callback(file_fn, &block_size3));
152118
t1.join();
153119
t2.join();
154120
t3.join();
155-
t4.join();
156121

157122
return CaseNext;
158123
}

TESTS/integration/net-single/main.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,7 @@ static control_t setup_network(const size_t call_count)
7272
}
7373
}
7474
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, err);
75-
tr_info("[NET] IP address is '%s'", interface->get_ip_address());
76-
tr_info("[NET] MAC address is '%s'", interface->get_mac_address());
75+
7776
return CaseNext;
7877
}
7978

TESTS/integration/net-threaded/main.cpp

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,7 @@ static control_t setup_network(const size_t call_count)
7272
}
7373
}
7474
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, err);
75-
tr_info("[NET] IP address is '%s'", net->get_ip_address());
76-
tr_info("[NET] MAC address is '%s'", net->get_mac_address());
75+
7776
return CaseNext;
7877
}
7978

@@ -102,7 +101,7 @@ static control_t download_2_threads(const size_t call_count)
102101
Thread t1;
103102
Thread t2;
104103
t1.start(download_fn);
105-
wait(0.5);
104+
ThisThread::sleep_for(1);
106105
t2.start(download_fn);
107106
t2.join();
108107
t1.join();
@@ -127,26 +126,6 @@ static control_t download_3_threads(const size_t call_count)
127126
return CaseNext;
128127
}
129128

130-
static control_t download_4_threads(const size_t call_count)
131-
{
132-
thread_counter = 0;
133-
134-
Thread t1;
135-
Thread t2;
136-
Thread t3;
137-
Thread t4;
138-
t1.start(download_fn);
139-
t2.start(download_fn);
140-
t3.start(download_fn);
141-
t4.start(download_fn);
142-
t1.join();
143-
t2.join();
144-
t3.join();
145-
t4.join();
146-
147-
return CaseNext;
148-
}
149-
150129
utest::v1::status_t greentea_setup(const size_t number_of_cases)
151130
{
152131
GREENTEA_SETUP(12 * 60, "default_auto");

TESTS/integration/stress-net-fs/main.cpp

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,7 @@ static control_t setup_network(const size_t call_count)
7878
}
7979
}
8080
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, err);
81-
tr_info("[NET] IP address is '%s'", interface->get_ip_address());
82-
tr_info("[NET] MAC address is '%s'", interface->get_mac_address());
81+
8382
return CaseNext;
8483
}
8584

@@ -113,7 +112,7 @@ void file_fn(size_t buffer)
113112
{
114113
uint32_t thread_id = core_util_atomic_incr_u32(&thread_counter, 1);
115114
char filename[255] = { 0 };
116-
snprintf(filename, 255, "mbed-file-test-%d.txt", thread_id);
115+
snprintf(filename, 255, "mbed-file-test-%" PRIu32 ".txt", thread_id);
117116
file_test_write(filename, 0, story, sizeof(story), buffer);
118117
file_test_read(filename, 0, story, sizeof(story), buffer);
119118
}
@@ -154,7 +153,7 @@ static control_t stress_2_threads(const size_t call_count)
154153
Thread t1;
155154
Thread t2;
156155
t1.start(file_1kb_fn);
157-
wait(1);
156+
ThisThread::sleep_for(1);
158157
t2.start(download_fn);
159158
t2.join();
160159
t1.join();
@@ -171,7 +170,7 @@ static control_t stress_3_threads(const size_t call_count)
171170
Thread t3;
172171
t1.start(file_256b_fn);
173172
t2.start(file_1kb_fn);
174-
wait(1);
173+
ThisThread::sleep_for(1);
175174
t3.start(download_fn);
176175
t3.join();
177176
t2.join();
@@ -180,27 +179,6 @@ static control_t stress_3_threads(const size_t call_count)
180179
return CaseNext;
181180
}
182181

183-
static control_t stress_4_threads(const size_t call_count)
184-
{
185-
thread_counter = 0;
186-
187-
Thread t1;
188-
Thread t2;
189-
Thread t3;
190-
Thread t4;
191-
t1.start(file_256b_fn);
192-
t2.start(file_256b_fn);
193-
t3.start(file_256b_fn);
194-
wait(1);
195-
t4.start(download_fn);
196-
t4.join();
197-
t3.join();
198-
t2.join();
199-
t1.join();
200-
201-
return CaseNext;
202-
}
203-
204182
template <uint32_t size>
205183
void test_malloc()
206184
{

features/storage/TESTS/filesystem/general_filesystem/main.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,20 @@
2020
#include "FileSystem.h"
2121

2222
#include <stdlib.h>
23+
#include "LittleFileSystem.h"
24+
2325
#if COMPONENT_SPIF
2426
#include "SPIFBlockDevice.h"
25-
#include "LittleFileSystem.h"
27+
#elif COMPONENT_QSPIF
28+
#include "QSPIFBlockDevice.h"
29+
#elif COMPONENT_OSPIF
30+
#include "OSPIFBlockDevice.h"
2631
#elif COMPONENT_SD
2732
#include "SDBlockDevice.h"
28-
#include "FATFileSystem.h"
2933
#else
3034
#error [NOT_SUPPORTED] storage test not supported on this platform
3135
#endif
3236

33-
#if COMPONENT_SPIF || COMPONENT_SD
3437
using namespace utest::v1;
3538
using namespace mbed;
3639

@@ -2131,4 +2134,3 @@ int main()
21312134
return !Harness::run(specification);
21322135
}
21332136

2134-
#endif // COMPONENT_SPIF || COMPONENT_SD

0 commit comments

Comments
 (0)