Skip to content

Commit d46c397

Browse files
author
Veijo Pesonen
committed
tests-integration-*: Stops using deprecated wait()
Additionally removes some dead code.
1 parent 148cf85 commit d46c397

File tree

3 files changed

+17
-93
lines changed

3 files changed

+17
-93
lines changed

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-threaded/main.cpp

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ static control_t download_2_threads(const size_t call_count)
101101
Thread t1;
102102
Thread t2;
103103
t1.start(download_fn);
104-
wait(0.5);
104+
ThisThread::sleep_for(1);
105105
t2.start(download_fn);
106106
t2.join();
107107
t1.join();
@@ -126,26 +126,6 @@ static control_t download_3_threads(const size_t call_count)
126126
return CaseNext;
127127
}
128128

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

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

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ static control_t stress_2_threads(const size_t call_count)
153153
Thread t1;
154154
Thread t2;
155155
t1.start(file_1kb_fn);
156-
wait(1);
156+
ThisThread::sleep_for(1);
157157
t2.start(download_fn);
158158
t2.join();
159159
t1.join();
@@ -170,7 +170,7 @@ static control_t stress_3_threads(const size_t call_count)
170170
Thread t3;
171171
t1.start(file_256b_fn);
172172
t2.start(file_1kb_fn);
173-
wait(1);
173+
ThisThread::sleep_for(1);
174174
t3.start(download_fn);
175175
t3.join();
176176
t2.join();
@@ -179,27 +179,6 @@ static control_t stress_3_threads(const size_t call_count)
179179
return CaseNext;
180180
}
181181

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

0 commit comments

Comments
 (0)