diff options
Diffstat (limited to 'apps')
-rw-r--r-- | apps/plugins/test_disk.c | 43 |
1 files changed, 24 insertions, 19 deletions
diff --git a/apps/plugins/test_disk.c b/apps/plugins/test_disk.c index c83fb7e1d2..443e9eb18b 100644 --- a/apps/plugins/test_disk.c +++ b/apps/plugins/test_disk.c | |||
@@ -110,7 +110,7 @@ static bool test_fs(void) | |||
110 | { | 110 | { |
111 | unsigned char text_buf[32]; | 111 | unsigned char text_buf[32]; |
112 | int total, current, align; | 112 | int total, current, align; |
113 | int fd; | 113 | int fd, ret; |
114 | 114 | ||
115 | log_init(); | 115 | log_init(); |
116 | log_text("test_disk WRITE&VERIFY", true); | 116 | log_text("test_disk WRITE&VERIFY", true); |
@@ -126,7 +126,7 @@ static bool test_fs(void) | |||
126 | fd = rb->creat(TEST_FILE, 0666); | 126 | fd = rb->creat(TEST_FILE, 0666); |
127 | if (fd < 0) | 127 | if (fd < 0) |
128 | { | 128 | { |
129 | rb->splash(HZ, "creat() failed."); | 129 | rb->splashf(HZ, "creat() failed: %d", fd); |
130 | goto error; | 130 | goto error; |
131 | } | 131 | } |
132 | 132 | ||
@@ -142,9 +142,10 @@ static bool test_fs(void) | |||
142 | log_text(text_buf, false); | 142 | log_text(text_buf, false); |
143 | 143 | ||
144 | mem_fill_frnd(audiobuf + align, current); | 144 | mem_fill_frnd(audiobuf + align, current); |
145 | if (current != rb->write(fd, audiobuf + align, current)) | 145 | ret = rb->write(fd, audiobuf + align, current); |
146 | if (current != ret) | ||
146 | { | 147 | { |
147 | rb->splash(0, "write() failed."); | 148 | rb->splashf(0, "write() failed: %d/%d", ret, current); |
148 | rb->close(fd); | 149 | rb->close(fd); |
149 | goto error; | 150 | goto error; |
150 | } | 151 | } |
@@ -155,7 +156,7 @@ static bool test_fs(void) | |||
155 | fd = rb->open(TEST_FILE, O_RDONLY); | 156 | fd = rb->open(TEST_FILE, O_RDONLY); |
156 | if (fd < 0) | 157 | if (fd < 0) |
157 | { | 158 | { |
158 | rb->splash(0, "open() failed."); | 159 | rb->splashf(0, "open() failed: %d", ret); |
159 | goto error; | 160 | goto error; |
160 | } | 161 | } |
161 | 162 | ||
@@ -170,9 +171,10 @@ static bool test_fs(void) | |||
170 | current >> 10, total >> 10); | 171 | current >> 10, total >> 10); |
171 | log_text(text_buf, false); | 172 | log_text(text_buf, false); |
172 | 173 | ||
173 | if (current != rb->read(fd, audiobuf + align, current)) | 174 | ret = rb->read(fd, audiobuf + align, current); |
175 | if (current != ret) | ||
174 | { | 176 | { |
175 | rb->splash(0, "read() failed."); | 177 | rb->splashf(0, "read() failed: %d/%d", ret, current); |
176 | rb->close(fd); | 178 | rb->close(fd); |
177 | goto error; | 179 | goto error; |
178 | } | 180 | } |
@@ -201,7 +203,7 @@ error: | |||
201 | static bool file_speed(int chunksize, bool align) | 203 | static bool file_speed(int chunksize, bool align) |
202 | { | 204 | { |
203 | unsigned char text_buf[64]; | 205 | unsigned char text_buf[64]; |
204 | int fd; | 206 | int fd, ret; |
205 | long filesize = 0; | 207 | long filesize = 0; |
206 | long size, time; | 208 | long size, time; |
207 | 209 | ||
@@ -214,15 +216,16 @@ static bool file_speed(int chunksize, bool align) | |||
214 | fd = rb->creat(TEST_FILE, 0666); | 216 | fd = rb->creat(TEST_FILE, 0666); |
215 | if (fd < 0) | 217 | if (fd < 0) |
216 | { | 218 | { |
217 | rb->splash(HZ, "creat() failed."); | 219 | rb->splashf(HZ, "creat() failed: %d", fd); |
218 | goto error; | 220 | goto error; |
219 | } | 221 | } |
220 | time = *rb->current_tick; | 222 | time = *rb->current_tick; |
221 | while (TIME_BEFORE(*rb->current_tick, time + TEST_TIME*HZ)) | 223 | while (TIME_BEFORE(*rb->current_tick, time + TEST_TIME*HZ)) |
222 | { | 224 | { |
223 | if (chunksize != rb->write(fd, audiobuf + (align ? 0 : 1), chunksize)) | 225 | ret = rb->write(fd, audiobuf + (align ? 0 : 1), chunksize); |
226 | if (chunksize != ret) | ||
224 | { | 227 | { |
225 | rb->splash(HZ, "write() failed."); | 228 | rb->splashf(HZ, "write() failed: %d/%d", ret, chunksize); |
226 | rb->close(fd); | 229 | rb->close(fd); |
227 | goto error; | 230 | goto error; |
228 | } | 231 | } |
@@ -238,15 +241,16 @@ static bool file_speed(int chunksize, bool align) | |||
238 | fd = rb->open(TEST_FILE, O_WRONLY); | 241 | fd = rb->open(TEST_FILE, O_WRONLY); |
239 | if (fd < 0) | 242 | if (fd < 0) |
240 | { | 243 | { |
241 | rb->splash(0, "open() failed."); | 244 | rb->splashf(0, "open() failed: %d", fd); |
242 | goto error; | 245 | goto error; |
243 | } | 246 | } |
244 | time = *rb->current_tick; | 247 | time = *rb->current_tick; |
245 | for (size = filesize; size > 0; size -= chunksize) | 248 | for (size = filesize; size > 0; size -= chunksize) |
246 | { | 249 | { |
247 | if (chunksize != rb->write(fd, audiobuf + (align ? 0 : 1), chunksize)) | 250 | ret = rb->write(fd, audiobuf + (align ? 0 : 1), chunksize); |
251 | if (chunksize != ret) | ||
248 | { | 252 | { |
249 | rb->splash(0, "write() failed."); | 253 | rb->splashf(0, "write() failed: %d/%d", ret, chunksize); |
250 | rb->close(fd); | 254 | rb->close(fd); |
251 | goto error; | 255 | goto error; |
252 | } | 256 | } |
@@ -261,15 +265,16 @@ static bool file_speed(int chunksize, bool align) | |||
261 | fd = rb->open(TEST_FILE, O_RDONLY); | 265 | fd = rb->open(TEST_FILE, O_RDONLY); |
262 | if (fd < 0) | 266 | if (fd < 0) |
263 | { | 267 | { |
264 | rb->splash(0, "open() failed."); | 268 | rb->splashf(0, "open() failed: %d", fd); |
265 | goto error; | 269 | goto error; |
266 | } | 270 | } |
267 | time = *rb->current_tick; | 271 | time = *rb->current_tick; |
268 | for (size = filesize; size > 0; size -= chunksize) | 272 | for (size = filesize; size > 0; size -= chunksize) |
269 | { | 273 | { |
270 | if (chunksize != rb->read(fd, audiobuf + (align ? 0 : 1), chunksize)) | 274 | ret = rb->read(fd, audiobuf + (align ? 0 : 1), chunksize); |
275 | if (chunksize != ret) | ||
271 | { | 276 | { |
272 | rb->splash(0, "read() failed."); | 277 | rb->splashf(0, "read() failed: %d/%d", ret, chunksize); |
273 | rb->close(fd); | 278 | rb->close(fd); |
274 | goto error; | 279 | goto error; |
275 | } | 280 | } |
@@ -315,7 +320,7 @@ static bool test_speed(void) | |||
315 | if (fd < 0) | 320 | if (fd < 0) |
316 | { | 321 | { |
317 | last_file = i; | 322 | last_file = i; |
318 | rb->splash(HZ, "creat() failed."); | 323 | rb->splashf(HZ, "creat() failed: %d", fd); |
319 | goto error; | 324 | goto error; |
320 | } | 325 | } |
321 | rb->close(fd); | 326 | rb->close(fd); |
@@ -335,7 +340,7 @@ static bool test_speed(void) | |||
335 | fd = rb->open(text_buf, O_RDONLY); | 340 | fd = rb->open(text_buf, O_RDONLY); |
336 | if (fd < 0) | 341 | if (fd < 0) |
337 | { | 342 | { |
338 | rb->splash(HZ, "open() failed."); | 343 | rb->splashf(HZ, "open() failed: %d", fd); |
339 | goto error; | 344 | goto error; |
340 | } | 345 | } |
341 | rb->close(fd); | 346 | rb->close(fd); |