FreeCalypso > hg > tcs211-c139
comparison chipsetsw/drivers/drv_app/ffs/board/tffs.c @ 0:509db1a7b7b8
initial import: leo2moko-r1
author | Space Falcon <falcon@ivan.Harhan.ORG> |
---|---|
date | Mon, 01 Jun 2015 03:24:05 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:509db1a7b7b8 |
---|---|
1 /****************************************************************************** | |
2 * Flash File System (ffs) | |
3 * Idea, design and coding by Mads Meisner-Jensen, mmj@ti.com | |
4 * | |
5 * ffs test scaffold/framework | |
6 * | |
7 * $Id: tffs.c 1.12.1.1.1.20 Fri, 19 Dec 2003 12:00:13 +0100 tsj $ | |
8 * | |
9 ******************************************************************************/ | |
10 | |
11 #ifndef TARGET | |
12 #include "ffs.cfg" | |
13 #endif | |
14 | |
15 #include "ffs/ffs.h" | |
16 #include "ffs/board/core.h" | |
17 #include "ffs/board/tffs.h" | |
18 #include "ffs/board/tdata.h" | |
19 #include "ffs/board/tmffs.h" | |
20 #include "ffs/board/ffstrace.h" | |
21 | |
22 #if (TARGET == 1) | |
23 #include "ffs/board/task.h" | |
24 #endif | |
25 | |
26 #include <stdio.h> | |
27 #include <string.h> | |
28 #include <stdlib.h> | |
29 #include <ctype.h> | |
30 | |
31 | |
32 /****************************************************************************** | |
33 * Prototypes and Globals | |
34 ******************************************************************************/ | |
35 | |
36 struct dir_s dir; | |
37 struct stat_s stat; | |
38 struct xstat_s xstat; | |
39 | |
40 int error; | |
41 #if (TARGET == 1) | |
42 int smallbuf_size = 512; | |
43 int bigbuf_size = 65536; | |
44 | |
45 #else | |
46 int smallbuf_size = 1024; | |
47 int bigbuf_size = 1024*1024*8; | |
48 #endif | |
49 | |
50 char *smallbuf = 0; | |
51 char *bigbuf = 0; | |
52 | |
53 | |
54 /****************************************************************************** | |
55 * Globals and Main | |
56 ******************************************************************************/ | |
57 | |
58 extern struct testcase_s testcase[]; | |
59 | |
60 struct test_s { | |
61 char *name; // name of currently executing test case | |
62 int numcases; // number of test cases run so far | |
63 int numcalls; // total number of ffs function calls so far | |
64 int numfails; // total number of failed test cases | |
65 int keepgoing; // keep going when a test case fails | |
66 } test; | |
67 | |
68 struct ffs_params_s param; | |
69 | |
70 | |
71 /****************************************************************************** | |
72 * Main Functions | |
73 ******************************************************************************/ | |
74 | |
75 effs_t ffs_initialize(void); | |
76 effs_t ffs_exit(void); | |
77 | |
78 // Each test case returns zero on success, non-zero on failure. | |
79 // test_execute() decides whether to continue with remaining test cases or | |
80 // not. | |
81 | |
82 #if (TARGET == 0) | |
83 void test_listall(void) | |
84 { | |
85 struct testcase_s *p; | |
86 | |
87 printf("Test Cases:\n"); | |
88 for (p = testcase; p->name != 0; p++) { | |
89 printf("%8s: %s\n", p->name, p->comment); | |
90 } | |
91 } | |
92 #endif | |
93 | |
94 // <tests> is a comma-separated string of names of the test cases to | |
95 // run. Return number of test cases that failed. This is typically only 1, | |
96 // unless arg_keepgoing is set in which case it can be several. | |
97 int test_run(char *tests) | |
98 { | |
99 struct testcase_s *ptc; | |
100 int i, failed, tparams[FFS_TESTCASE_PARAMS_MAX]; | |
101 struct this_test_s this; | |
102 char *pname, *testsnew; | |
103 | |
104 failed = 0; | |
105 | |
106 while (*tests != 0 && (failed == 0 || test.keepgoing)) | |
107 { | |
108 // Make local copy of test case name. We have to make local copies | |
109 // because we can be recursively called | |
110 pname = this.name; | |
111 while (isalpha(*tests) && *tests != 0 && *tests != ';') | |
112 *pname++ = *tests++; | |
113 *pname = 0; | |
114 | |
115 // Reset test case parameter(s) | |
116 for (i = 0; i < FFS_TESTCASE_PARAMS_MAX; i++) | |
117 tparams[i] = 0; | |
118 | |
119 // Collect parameter(s) for test case | |
120 i = 0; | |
121 while (isdigit(*tests)) { | |
122 tparams[i] = strtol(tests, &testsnew, 0); | |
123 if (tests == testsnew) | |
124 break; | |
125 tests = testsnew; | |
126 if (*tests == ',') | |
127 tests++; | |
128 i++; | |
129 if (i > FFS_TESTCASE_PARAMS_MAX) { | |
130 ttw(ttr(TTrTest, "TEST %s has TOO MANY PARAMS" NL, this.name)); | |
131 tw(tr(TR_FUNC, TrTest, "TEST %s TOO MANY PARAMS\n", this.name)); | |
132 return 1; | |
133 } | |
134 } | |
135 | |
136 if (*tests == ';') | |
137 tests++; | |
138 | |
139 // Lookup the test name in the array of test cases | |
140 for (ptc = testcase; ptc->name != 0; ptc++) { | |
141 if (strcmp(this.name, ptc->name) == 0) | |
142 break; | |
143 } | |
144 if (ptc->name == 0) { | |
145 ttw(ttr(TTrTest, "TEST %s UNKNOWN" NL, this.name)); | |
146 tw(tr(TR_FUNC, TrTest, "TEST %s UNKNOWN\n", this.name)); | |
147 return 1; | |
148 } | |
149 | |
150 this.numcalls = test.numcalls; | |
151 test_begin(this.name, tparams); | |
152 i = ptc->function(tparams[0], tparams[1]); | |
153 if (i != 0) { | |
154 failed++; | |
155 test_error(&this, test.numcalls); | |
156 } | |
157 test_end(&this, test.numcalls); | |
158 } | |
159 | |
160 return failed; | |
161 } | |
162 | |
163 // Overall test initialization. Read static ffs params with ffs_query() | |
164 void test_init(int keepgoing) | |
165 { | |
166 test.numcases = 0; | |
167 test.numcalls = 0; | |
168 test.numfails = 0; | |
169 test.keepgoing = keepgoing; | |
170 | |
171 memset(¶m, 0, sizeof(struct ffs_params_s)); | |
172 | |
173 if (smallbuf == 0) { | |
174 #if (TARGET == 1) | |
175 smallbuf = (char*)target_malloc(smallbuf_size); | |
176 #else | |
177 smallbuf = malloc(smallbuf_size); | |
178 #endif | |
179 tw(tr(TR_FUNC, TrTest, "smallbuf = 0x%X, %d\n", | |
180 smallbuf, smallbuf_size)); | |
181 } | |
182 if (bigbuf == 0) { | |
183 #if (TARGET == 1) | |
184 // We continuously halve the buffer size until we succeed to allocate | |
185 // it. | |
186 while(1) { | |
187 if ((bigbuf = (char*)target_malloc(bigbuf_size)) != 0) | |
188 break; | |
189 bigbuf_size /= 2; | |
190 } | |
191 #else | |
192 bigbuf = malloc(bigbuf_size); | |
193 #endif | |
194 tw(tr(TR_FUNC, TrTest, "bigbuf = 0x%X, %d\n", bigbuf, bigbuf_size)); | |
195 } | |
196 | |
197 test_tdata_init(); | |
198 | |
199 tffs_initialize(); | |
200 } | |
201 | |
202 void test_exit(void) | |
203 { | |
204 test_state_print(0); | |
205 } | |
206 | |
207 | |
208 // Begin new test case | |
209 void test_begin(char *name, int *params) | |
210 { | |
211 test.numcases++; | |
212 | |
213 tw(tr(TR_BEGIN, TrTest, "TEST %s(%d,%d)\n", name, params[0], params[1])); | |
214 ttw(ttr(TTrTest, "TEST %s(%d,%d)" NL, name, params[0], params[1])); | |
215 } | |
216 | |
217 void test_end(struct this_test_s *test, int n) | |
218 { | |
219 int objects = 0; | |
220 | |
221 ffs_query(Q_TOTAL_OBJECTS, (uint16 *) &objects); | |
222 tw(tr(TR_FUNC, TrTestHigh, "(total objects = %d)\n", objects)); | |
223 tw(tr(TR_END, TrTest, "")); | |
224 //tw(tr(TR_END, TrTest, "TEST END %s (calls = %d)\n", | |
225 // test->name, n - test->numcalls)); | |
226 } | |
227 | |
228 void test_error(struct this_test_s *test, int n) | |
229 { | |
230 ttw(ttr(TTrTest, "TEST FAIL %s, call %d" NL, | |
231 test->name, n - test->numcalls)); | |
232 tw(tr(TR_FUNC, TrTest, "TEST FAIL %s, call %d\n", | |
233 test->name, n - test->numcalls)); | |
234 } | |
235 | |
236 | |
237 /****************************************************************************** | |
238 * Miscellaneous | |
239 ******************************************************************************/ | |
240 | |
241 int test_ffs_state_get(struct ffs_state_s *s) | |
242 { | |
243 memset(s, 0, sizeof(struct ffs_state_s)); | |
244 | |
245 error = ffs_query(Q_INODES_USED, (uint16 *) &s->inodes_used); | |
246 error += ffs_query(Q_INODES_LOST, (uint16 *) &s->inodes_lost); | |
247 error += ffs_query(Q_OBJECTS_FREE, (uint16 *) &s->objects_free); | |
248 error += ffs_query(Q_TOTAL_OBJECTS, (uint16 *) &s->objects_total); | |
249 | |
250 error += ffs_query(Q_BYTES_USED, (uint16 *) &s->bytes_used); | |
251 error += ffs_query(Q_BYTES_LOST, (uint16 *) &s->bytes_lost); | |
252 error += ffs_query(Q_BYTES_FREE, (uint16 *) &s->bytes_free); | |
253 | |
254 error += ffs_query(Q_BLOCKS_FREE, (uint16 *) &s->blocks_free); | |
255 | |
256 return error; | |
257 } | |
258 | |
259 void test_ffs_state_copy(struct ffs_state_s *dst, struct ffs_state_s *src) | |
260 { | |
261 memcpy(dst, src, sizeof(struct ffs_state_s)); | |
262 } | |
263 | |
264 void test_state_print(struct ffs_state_s *state) | |
265 { | |
266 struct ffs_state_s mystate; | |
267 | |
268 if (state == 0) { | |
269 state = &mystate; | |
270 test_ffs_state_get(state); | |
271 } | |
272 | |
273 tw(tr(TR_FUNC, TrTest, "\nFFS State Summary:\n\n")); | |
274 ttw(str(TTrTest, NL "FFS State Summary:" NL NL)); | |
275 | |
276 tw(tr(TR_FUNC, TrTest, " block_size = %d\n", param.block_size)); | |
277 tw(tr(TR_FUNC, TrTest, " bytes_avail = %d\n\n", param.bytes_avail)); | |
278 | |
279 ttw(ttr(TTrTest, " block_size = %d" NL, param.block_size)); | |
280 ttw(ttr(TTrTest, " bytes_avail = %d" NL NL, param.bytes_avail)); | |
281 | |
282 test_state_bytes_print(state, 0); | |
283 test_state_objects_print(state, 0); | |
284 | |
285 } | |
286 | |
287 void test_state_objects_print(struct ffs_state_s *old, struct ffs_state_s *new) | |
288 { | |
289 ttw(str(TTrTest, " inodes objects" NL)); | |
290 ttw(str(TTrTest, " -------------------------------------------" NL)); | |
291 ttw(str(TTrTest, " objects: used lost free total" NL)); | |
292 ttw(ttr(TTrTest, " old: %6d %6d %6d %6d" NL, | |
293 old->inodes_used, old->inodes_lost, | |
294 old->objects_free, old->objects_total)); | |
295 | |
296 tw(tr(TR_FUNC, TrTest, " inodes objects\n")); | |
297 tw(tr(TR_FUNC, TrTest, " -------------------------------------------\n")); | |
298 tw(tr(TR_FUNC, TrTest, " objects: used lost free total\n")); | |
299 tw(tr(TR_FUNC, TrTest, " old: %6d %6d %6d %6d\n", | |
300 old->inodes_used, old->inodes_lost, | |
301 old->objects_free, old->objects_total)); | |
302 | |
303 if (new != NULL) | |
304 { | |
305 ttw(ttr(TTrTest, | |
306 " new: %6d %6d %6d %6d" NL, | |
307 new->inodes_used, new->inodes_lost, | |
308 new->objects_free, new->objects_total)); | |
309 ttw(ttr(TTrTest, | |
310 " diff: %6d %6d %6d %6d" NL, | |
311 new->inodes_used - old->inodes_used, | |
312 new->inodes_lost - old->inodes_lost, | |
313 new->objects_free - old->objects_free, | |
314 new->objects_total - old->objects_total)); | |
315 | |
316 tw(tr(TR_FUNC, TrTest, | |
317 " new: %6d %6d %6d %6d\n", | |
318 new->inodes_used, new->inodes_lost, | |
319 new->objects_free, new->objects_total)); | |
320 tw(tr(TR_FUNC, TrTest, | |
321 " diff: %6d %6d %6d %6d\n", | |
322 new->inodes_used - old->inodes_used, | |
323 new->inodes_lost - old->inodes_lost, | |
324 new->objects_free - old->objects_free, | |
325 new->objects_total - old->objects_total)); | |
326 } | |
327 ttw(str(TTrTest, "" NL)); | |
328 tw(tr(TR_FUNC, TrTest, "\n")); | |
329 } | |
330 | |
331 void test_state_bytes_print(struct ffs_state_s *old, struct ffs_state_s *new) | |
332 { | |
333 tw(tr(TR_FUNC, TrTest, " bytes: used lost free total\n")); | |
334 tw(tr(TR_FUNC, TrTest, " old: %8d %8d %8d %8d\n", | |
335 old->bytes_used, old->bytes_lost, | |
336 old->bytes_free, param.bytes_max)); | |
337 tw(tr(TR_FUNC, TrTest, " +/-: %8d %8d\n", | |
338 old->bytes_used - old->bytes_lost, | |
339 old->bytes_free + old->bytes_lost)); | |
340 | |
341 ttw(str(TTrTest, " bytes: used lost free total" NL)); | |
342 ttw(ttr(TTrTest, " old: %8d %8d %8d %8d" NL, | |
343 old->bytes_used, old->bytes_lost, | |
344 old->bytes_free, param.bytes_max)); | |
345 ttw(ttr(TTrTest, " +/-: %8d %8d" NL, | |
346 old->bytes_used - old->bytes_lost, | |
347 old->bytes_free + old->bytes_lost)); | |
348 | |
349 if (new != NULL) { | |
350 tw(tr(TR_FUNC, TrTest, " new: %8d %8d %8d\n", | |
351 new->bytes_used, new->bytes_lost, | |
352 new->bytes_free)); | |
353 tw(tr(TR_FUNC, TrTest, " diff: %8d %8d %8d\n", | |
354 new->bytes_used - old->bytes_used, | |
355 new->bytes_lost - old->bytes_lost, | |
356 new->bytes_free - old->bytes_free)); | |
357 | |
358 ttw(ttr(TTrTest, " new: %8d %8d %8d" NL, | |
359 new->bytes_used, new->bytes_lost, | |
360 new->bytes_free)); | |
361 ttw(ttr(TTrTest, " diff: %8d %8d %8d" NL, | |
362 new->bytes_used - old->bytes_used, | |
363 new->bytes_lost - old->bytes_lost, | |
364 new->bytes_free - old->bytes_free)); | |
365 } | |
366 tw(tr(TR_FUNC, TrTest, "\n")); | |
367 ttw(str(TTrTest, "" NL)); | |
368 } | |
369 | |
370 | |
371 // Retrieve all static ffs parameters with ffs_query() | |
372 int test_ffs_params_get(void) | |
373 { | |
374 error = ffs_query(Q_FILENAME_MAX, ¶m.filename_max); | |
375 error += ffs_query(Q_PATH_DEPTH_MAX, ¶m.pathdepth_max); | |
376 error += ffs_query(Q_INODES_MAX, ¶m.inodes_max); | |
377 error += ffs_query(Q_BYTES_MAX, ¶m.bytes_max); | |
378 error += ffs_query(Q_DEV_BLOCKS, ¶m.numblocks); | |
379 error += ffs_query(Q_DEV_ATOMSIZE, ¶m.atomsize); | |
380 error += ffs_query(Q_BLOCKS_FREE_MIN, ¶m.blocks_free_min); | |
381 | |
382 // Compute block size | |
383 param.block_size = param.bytes_max / param.numblocks; | |
384 | |
385 // Compute total number of available storage space, subtracting | |
386 // fs.blocks_free_min plus one block for inodes | |
387 param.bytes_avail = | |
388 param.bytes_max - (param.block_size * (1 + param.blocks_free_min)); | |
389 | |
390 // Compute number of blocks available for data storage | |
391 param.data_blocks = param.numblocks - (1 + param.blocks_free_min); | |
392 | |
393 return error; | |
394 } | |
395 | |
396 void test_statistics_print(void) | |
397 { | |
398 tw(tr(TR_FUNC, TrTest, "Data allocated(%dMB)\n", stats.data_allocated>>20)); | |
399 tw(tr(TR_FUNC, TrTest, "Reclaim candidates: most-lost(%d), most-unused(%d), youngest(%d)\n", stats.drec.most_lost, stats.drec.most_unused, stats.drec.youngest)); | |
400 | |
401 tw(tr(TR_FUNC, TrTest, "Data reclaimed: lost(%dMB), valid(%dMB)\n", | |
402 stats.drec.lost[0]>>20 , stats.drec.valid[0]>>20)); | |
403 | |
404 tw(tr(TR_FUNC, TrTest, "Inodes reclaimed: num(%d), valid(%d), lost(%d)\n", | |
405 stats.irec.num, stats.irec.valid, stats.irec.lost)); | |
406 | |
407 ttw(ttr(TTrTest, "Data allocated(%dMB)\n" NL, stats.data_allocated>>20)); | |
408 ttw(ttr(TTrTest, "Reclaim candidates: most-lost(%d), most-unused(%d), youngest(%d)\n" NL, stats.drec.most_lost, stats.drec.most_unused, stats.drec.youngest)); | |
409 | |
410 ttw(ttr(TTrTest, "Data reclaimed: lost(%dMB), valid(%dMB)\n" NL, | |
411 stats.drec.lost[0]>>20 , stats.drec.valid[0]>>20)); | |
412 | |
413 ttw(ttr(TTrTest, "Inodes reclaimed: num(%d), valid(%d), lost(%d)\n" NL, | |
414 stats.irec.num, stats.irec.valid, stats.irec.lost)); | |
415 } | |
416 | |
417 /****************************************************************************** | |
418 * Test and Expect Functions | |
419 ******************************************************************************/ | |
420 | |
421 int test_expect(int n, int xn) | |
422 { | |
423 if (n == xn) | |
424 return 0; | |
425 | |
426 tw(tr(TR_FUNC, TrTest, | |
427 "ERROR: expect(%d,%d): got %d, '%s', expected %d, '%s'\n", | |
428 n, xn, n, ffs_strerror(n), xn, ffs_strerror(xn))); | |
429 ttw(ttr(TTrTest, "ERROR: expect(%d,%d)" NL, n, xn)); | |
430 | |
431 return -1; | |
432 } | |
433 | |
434 // Expect a return code >= 0 meaning EFFS_OK. | |
435 int test_expect_ok(int n) | |
436 { | |
437 if (n >= 0) | |
438 return 0; | |
439 | |
440 tw(tr(TR_FUNC, TrTest, | |
441 "ERROR: expect_ok(%d) got %d, '%s', expected >= EFFS_OK\n", | |
442 n, ffs_strerror(n))); | |
443 ttw(ttr(TTrTest, "ERROR: expect_ok(%d)" NL, n)); | |
444 | |
445 return -1; | |
446 } | |
447 | |
448 int test_expect_equal(int n, int xn) | |
449 { | |
450 if (n == xn) | |
451 return 0; | |
452 | |
453 tw(tr(TR_FUNC, TrTest, "ERROR: got %d, expected %d\n", n, xn)); | |
454 ttw(ttr(TTrTest, "ERROR: expect_eq(%d,%d" NL, n, xn)); | |
455 | |
456 return -1; | |
457 } | |
458 | |
459 int test_expect_not_equal(int n, int xn) | |
460 { | |
461 if (n != xn) | |
462 return 0; | |
463 | |
464 tw(tr(TR_FUNC, TrTest, "ERROR: expect_ne(%d)\n", n)); | |
465 ttw(ttr(TTrTest, "ERROR: expect_ne(%d)" NL, n)); | |
466 | |
467 return -1; | |
468 } | |
469 | |
470 int test_expect_greater_than(int n, int xn) | |
471 { | |
472 if (n > xn) | |
473 return 0; | |
474 | |
475 tw(tr(TR_FUNC, TrTest, "ERROR: expect_gt(%d,%d) got %d but expected > %d\n", | |
476 n, xn, n, xn)); | |
477 ttw(ttr(TTrTest, "ERROR: expect_gt(%d,%d)" NL, n, xn)); | |
478 | |
479 return -1; | |
480 } | |
481 | |
482 int test_expect_data(const void *data1, const void *data2, int size) | |
483 { | |
484 if (memcmp(data1, data2, size) == 0) | |
485 return 0; | |
486 | |
487 tw(tr(TR_FUNC, TrTest, | |
488 "ERROR: expect_data(%d) got unexpected data\n", size)); | |
489 ttw(ttr(TTrTest, "ERROR: expect_data(%d)" NL, size)); | |
490 | |
491 return -1; | |
492 } | |
493 | |
494 // Check that contents of file with name <name> is the same as <data> of | |
495 // size <size>. | |
496 int test_expect_file(const char *name, const void *data, int size) | |
497 { | |
498 test.numcalls++; | |
499 if (size > bigbuf_size) { | |
500 tw(tr(TR_FUNC, TrTest, "WARNING: expect_file(%d) buffer too small\n", | |
501 size)); | |
502 ttw(ttr(TTrTest, "WARNING: expect_file(%d) buffer too small" NL, size)); | |
503 #if (TARGET == 1) | |
504 return 0; | |
505 #endif | |
506 return -1; | |
507 } | |
508 | |
509 error = ffs_file_read(name, bigbuf, size); | |
510 if (test_expect_greater_than(error, EFFS_OK - 1)) | |
511 return -1; | |
512 return test_expect_data(bigbuf, data, size); | |
513 } | |
514 | |
515 int test_expect_state(struct ffs_state_s *old, struct ffs_state_s *new) | |
516 { | |
517 int old_total, new_total; | |
518 | |
519 old_total = old->inodes_used - old->inodes_lost; | |
520 new_total = new->inodes_used - new->inodes_lost; | |
521 | |
522 if (old->objects_total == new->objects_total && | |
523 old->objects_total == new_total && | |
524 new->objects_total == old_total && | |
525 old->bytes_used == new->bytes_used && | |
526 old->bytes_lost == new->bytes_lost && | |
527 old->bytes_free == new->bytes_free) { | |
528 return 0; | |
529 } | |
530 | |
531 ttw(str(TTrTest, "ERROR: ffs state mismatch:" NL NL)); | |
532 tw(tr(TR_FUNC, TrTest, "ERROR: ffs state mismatch:\n\n")); | |
533 test_state_objects_print(old, new); | |
534 test_state_bytes_print(old, new); | |
535 | |
536 return -1; | |
537 } | |
538 | |
539 // Check if number of objects is unchanged | |
540 int test_expect_objects(struct ffs_state_s *old, struct ffs_state_s *new) | |
541 { | |
542 int old_total, new_total; | |
543 | |
544 test_ffs_state_get(new); | |
545 | |
546 old_total = old->inodes_used - old->inodes_lost; | |
547 new_total = new->inodes_used - new->inodes_lost; | |
548 | |
549 if (old->objects_total == new->objects_total && | |
550 old->objects_total == new_total && | |
551 new->objects_total == old_total) { | |
552 return 0; | |
553 } | |
554 | |
555 ttw(ttr(TTrTest, "ERROR: expect_objects(%d, %d, %d, %d, %d, %d)" NL)); | |
556 tw(tr(TR_FUNC, TrTest, "ERROR: ffs state mismatch:\n\n")); | |
557 test_state_objects_print(old, new); | |
558 | |
559 return -1; | |
560 } | |
561 | |
562 | |
563 /****************************************************************************** | |
564 * FFS Functions | |
565 ******************************************************************************/ | |
566 | |
567 effs_t tffs_fcreate(const char *name, void *addr, int size) | |
568 { | |
569 test.numcalls++; | |
570 return ffs_fcreate(name, addr, size); | |
571 } | |
572 | |
573 effs_t tffs_fupdate(const char *name, void *addr, int size) | |
574 { | |
575 test.numcalls++; | |
576 return ffs_fupdate(name, addr, size); | |
577 } | |
578 | |
579 effs_t tffs_fwrite(const char *name, void *addr, int size) | |
580 { | |
581 test.numcalls++; | |
582 return ffs_fwrite(name, addr, size); | |
583 } | |
584 | |
585 effs_t tffs_file_write(const char *name, void *addr, int size, uint16 option) | |
586 { | |
587 test.numcalls++; | |
588 return ffs_file_write(name, addr, size, option); | |
589 } | |
590 | |
591 effs_t tffs_mkdir(const char *name) | |
592 { | |
593 test.numcalls++; | |
594 return ffs_mkdir(name); | |
595 } | |
596 | |
597 effs_t tffs_symlink(const char *name, const char *actualpath) | |
598 { | |
599 test.numcalls++; | |
600 return ffs_symlink(name, actualpath); | |
601 } | |
602 | |
603 effs_t tffs_remove(const char *name) | |
604 { | |
605 test.numcalls++; | |
606 return ffs_remove(name); | |
607 } | |
608 | |
609 effs_t tffs_fcontrol(const char *name, int8 action, uint16 param) | |
610 { | |
611 test.numcalls++; | |
612 return ffs_fcontrol(name, action, param); | |
613 } | |
614 | |
615 effs_t tffs_preformat(uint16 magic) | |
616 { | |
617 test.numcalls++; | |
618 return ffs_preformat(magic); | |
619 } | |
620 | |
621 effs_t tffs_format(const char *name, uint16 magic) | |
622 { | |
623 test.numcalls++; | |
624 return ffs_format(name, magic); | |
625 } | |
626 | |
627 | |
628 int tffs_fread(const char *name, void *addr, int size) | |
629 { | |
630 test.numcalls++; | |
631 return ffs_file_read(name, addr, size); | |
632 } | |
633 | |
634 int tffs_file_read(const char *name, void *addr, int size) | |
635 { | |
636 test.numcalls++; | |
637 return ffs_file_read(name, addr, size); | |
638 } | |
639 | |
640 int tffs_opendir(const char *name, struct dir_s *dir) | |
641 { | |
642 test.numcalls++; | |
643 return ffs_opendir(name, dir); | |
644 } | |
645 | |
646 int tffs_readdir (struct dir_s *dir, char *name, int8 size) | |
647 { | |
648 test.numcalls++; | |
649 return ffs_readdir(dir, name, size); | |
650 } | |
651 | |
652 int tffs_readlink(const char *name, char *addr, int size) | |
653 { | |
654 test.numcalls++; | |
655 return ffs_readlink(name, addr, size); | |
656 } | |
657 | |
658 int tffs_rename(const char *oldname, const char *newname) | |
659 { | |
660 test.numcalls++; | |
661 return ffs_rename(oldname, newname); | |
662 } | |
663 | |
664 effs_t tffs_stat(const char *name, struct stat_s *stat) | |
665 { | |
666 test.numcalls++; | |
667 return ffs_stat(name, stat); | |
668 } | |
669 | |
670 effs_t tffs_fstat(fd_t fdi, struct stat_s *stat) | |
671 { | |
672 test.numcalls++; | |
673 return ffs_fstat(fdi, stat); | |
674 } | |
675 | |
676 effs_t tffs_linkstat(const char *name, struct stat_s *stat) | |
677 { | |
678 test.numcalls++; | |
679 return ffs_lstat(name, stat); | |
680 } | |
681 | |
682 effs_t tffs_lstat(const char *name, struct stat_s *stat) | |
683 { | |
684 test.numcalls++; | |
685 return ffs_lstat(name, stat); | |
686 } | |
687 | |
688 effs_t tffs_xlstat(const char *name, struct xstat_s *stat) | |
689 { | |
690 test.numcalls++; | |
691 return ffs_xlstat(name, stat); | |
692 } | |
693 | |
694 effs_t tffs_query(int8 query, void *p) | |
695 { | |
696 return ffs_query(query, p); | |
697 } | |
698 | |
699 | |
700 effs_t tffs_initialize(void) | |
701 { | |
702 effs_t myerror; | |
703 struct ffs_stats_s old_stats; | |
704 | |
705 test.numcalls++; | |
706 | |
707 memcpy(&old_stats, &stats, sizeof(struct ffs_stats_s)); | |
708 myerror = ffs_initialize(); | |
709 memcpy(&stats, &old_stats, sizeof(struct ffs_stats_s)); | |
710 | |
711 test_ffs_params_get(); | |
712 return myerror; | |
713 } | |
714 | |
715 effs_t tffs_exit(void) | |
716 { | |
717 test.numcalls++; | |
718 return ffs_exit(); | |
719 } | |
720 | |
721 fd_t tffs_open(const char *pathname, ffs_options_t options) | |
722 { | |
723 test.numcalls++; | |
724 return ffs_open(pathname, options); | |
725 } | |
726 | |
727 effs_t tffs_close(fd_t fdi) | |
728 { | |
729 test.numcalls++; | |
730 return ffs_close(fdi); | |
731 } | |
732 | |
733 int tffs_write(fd_t fdi, void *addr, int size) | |
734 { | |
735 test.numcalls++; | |
736 return ffs_write(fdi, addr, size); | |
737 } | |
738 | |
739 int tffs_read(fd_t fdi, void *addr, int size) | |
740 { | |
741 test.numcalls++; | |
742 return ffs_read(fdi, addr, size); | |
743 } | |
744 | |
745 int tffs_seek(fd_t fdi, int offset, int whence) | |
746 { | |
747 test.numcalls++; | |
748 return ffs_seek(fdi, offset, whence); | |
749 } | |
750 | |
751 effs_t tffs_truncate(const char *path, offset_t length) | |
752 { | |
753 test.numcalls++; | |
754 return ffs_truncate(path, length); | |
755 } | |
756 | |
757 effs_t tffs_ftruncate(fd_t fdi, offset_t length) | |
758 { | |
759 test.numcalls++; | |
760 return ffs_ftruncate(fdi, length); | |
761 } | |
762 | |
763 effs_t tffs_fdatasync(fd_t fdi) | |
764 { | |
765 test.numcalls++; | |
766 return ffs_fdatasync(fdi); | |
767 } |