FreeCalypso > hg > fc-magnetite
comparison src/cs/drivers/drv_app/ffs/board/tffs.h @ 0:945cf7f506b2
src/cs: chipsetsw import from tcs211-fcmodem
binary blobs and LCD demo files have been excluded,
all line endings are LF only
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 25 Sep 2016 22:50:11 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:945cf7f506b2 |
---|---|
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.h 1.7.1.15 Fri, 19 Dec 2003 12:00:13 +0100 tsj $ | |
8 * | |
9 ******************************************************************************/ | |
10 | |
11 #include "ffs/ffs.h" | |
12 | |
13 | |
14 /****************************************************************************** | |
15 * Compile Defines | |
16 ******************************************************************************/ | |
17 | |
18 // Maximum number of parameters for a test case | |
19 #define FFS_TESTCASE_PARAMS_MAX 2 | |
20 | |
21 // Maximum length of a test case name | |
22 #define FFS_TESTCASE_NAME_MAX 11 | |
23 | |
24 | |
25 /****************************************************************************** | |
26 * Types used in test framework | |
27 ******************************************************************************/ | |
28 | |
29 struct ffs_state_s { | |
30 int inodes_used; // taken from bstat entry for inodes block | |
31 int inodes_lost; // taken from bstat entry for inodes block | |
32 int objects_free; // taken from bstat entry for inodes block | |
33 int objects_total; // accumulated number of valid objects | |
34 | |
35 int bytes_used; // accumulated over all blocks | |
36 int bytes_lost; // accumulated over all blocks | |
37 int bytes_free; // accumulated over all blocks | |
38 | |
39 int blocks_free; // accumulated over all blocks | |
40 }; | |
41 | |
42 struct ffs_params_s { | |
43 // Actual parameters | |
44 int filename_max; | |
45 int pathdepth_max; | |
46 int inodes_max; | |
47 int bytes_max; | |
48 int numblocks; | |
49 int atomsize; | |
50 int blocks_free_min; | |
51 | |
52 // Pseudo parameters | |
53 int block_size; // size of each block | |
54 int bytes_avail; // size of available data space | |
55 int data_blocks; // number of blocks available for data storage | |
56 }; | |
57 | |
58 struct this_test_s { | |
59 char name[FFS_TESTCASE_NAME_MAX]; // name of currently executing test case | |
60 int numcalls; // total number of ffs function calls so far | |
61 }; | |
62 | |
63 | |
64 /****************************************************************************** | |
65 * Types used in test cases | |
66 ******************************************************************************/ | |
67 | |
68 typedef int (*pf_t)(int, int); | |
69 | |
70 enum TEST_CASE_FLAGS { | |
71 IT = 0x01, // test case is runnable in target | |
72 PC = 0x02, // test case is runnable on PC | |
73 RND = 0x04 // test case is randomly runnable | |
74 }; | |
75 | |
76 struct testcase_s { | |
77 char *name; | |
78 int flags; | |
79 pf_t function; | |
80 char *comment; | |
81 }; | |
82 | |
83 struct test_file_s { | |
84 const char *name; | |
85 char *data; | |
86 int size; | |
87 }; | |
88 | |
89 extern char *ffs_strerror(effs_t error); | |
90 | |
91 | |
92 /****************************************************************************** | |
93 * Globals | |
94 ******************************************************************************/ | |
95 | |
96 extern struct ffs_params_s param; | |
97 | |
98 extern struct dir_s dir; | |
99 extern struct stat_s stat; | |
100 extern struct xstat_s xstat; | |
101 | |
102 extern int error; | |
103 | |
104 extern int smallbuf_size; | |
105 extern char *smallbuf; | |
106 extern int bigbuf_size; | |
107 extern char *bigbuf; | |
108 | |
109 | |
110 /****************************************************************************** | |
111 * Functions | |
112 ******************************************************************************/ | |
113 | |
114 void test_listall(void); | |
115 int test_run(char *testname); | |
116 void test_init(int keepgoing); | |
117 void test_exit(void); | |
118 void test_begin(char *name, int *params); | |
119 void test_end(struct this_test_s *test, int n); | |
120 void test_error(struct this_test_s *test, int n); | |
121 | |
122 int test_expect(int error, int xerror); | |
123 int test_expect_ok(int n); | |
124 int test_expect_equal(int n, int xn); | |
125 int test_expect_not_equal(int n, int xn); | |
126 int test_expect_greater_than(int n, int xn); | |
127 int test_expect_data(const void *data1, const void *data2, int size); | |
128 int test_expect_file(const char *name, const void *data, int size); | |
129 int test_expect_state(struct ffs_state_s *old, struct ffs_state_s *new); | |
130 int test_expect_objects(struct ffs_state_s *old, struct ffs_state_s *new); | |
131 | |
132 int test_ffs_params_get(void); | |
133 int test_ffs_state_get(struct ffs_state_s *s); | |
134 void test_state_print(struct ffs_state_s *state); | |
135 void test_state_objects_print(struct ffs_state_s *old, struct ffs_state_s *new); | |
136 void test_state_bytes_print(struct ffs_state_s *old, struct ffs_state_s *new); | |
137 void test_ffs_state_copy(struct ffs_state_s *dst, struct ffs_state_s *src); | |
138 void test_statistics_print(void); | |
139 | |
140 #define expect(error, xerror) if (test_expect(error, xerror)) return 1; | |
141 #define expect_ok(error) if (test_expect_ok(error)) return 1; | |
142 #define expect_eq(n, xnum) if (test_expect_equal(n, xnum)) return 1; | |
143 #define expect_ne(n, xnum) if (test_expect_not_equal(n, xnum)) return 1; | |
144 #define expect_gt(n, xnum) if (test_expect_greater_than(n, xnum)) return 1; | |
145 | |
146 #if 0 | |
147 // This does NOT work when <addr, size> is macro-expanded! | |
148 #define expect_file(name, addr, size) \ | |
149 if (test_expect_file(name, addr, size)) return 1; | |
150 #endif | |
151 | |
152 | |
153 /****************************************************************************** | |
154 * Test (blocking) versions of FFS API functions | |
155 ******************************************************************************/ | |
156 | |
157 effs_t tffs_fcreate(const char *name, void *addr, int size); | |
158 effs_t tffs_fupdate(const char *name, void *addr, int size); | |
159 effs_t tffs_fwrite(const char *name, void *addr, int size); | |
160 effs_t tffs_file_write(const char *name, void *addr, int size, uint16 option); | |
161 int tffs_fread(const char *name, void *addr, int size); | |
162 int tffs_file_read(const char *name, void *addr, int size); | |
163 effs_t tffs_mkdir(const char *name); | |
164 int tffs_opendir(const char *name, struct dir_s *dir); | |
165 int tffs_readdir (struct dir_s *dir, char *name, int8 size); | |
166 effs_t tffs_symlink(const char *name, const char *actualpath); | |
167 int tffs_readlink(const char *name, char *addr, int size); | |
168 int tffs_rename(const char *oldname, const char *newname); | |
169 effs_t tffs_stat(const char *name, struct stat_s *stat); | |
170 effs_t tffs_xstat(const char *name, struct xstat_s *stat); | |
171 effs_t tffs_fstat(fd_t fdi, struct stat_s *stat); | |
172 effs_t tffs_xfstat(fd_t fdi, struct xstat_s *stat); | |
173 effs_t tffs_linkstat(const char *name, struct stat_s *stat); | |
174 effs_t tffs_lstat(const char *name, struct stat_s *stat); | |
175 effs_t tffs_xlstat(const char *name, struct xstat_s *stat); | |
176 effs_t tffs_remove(const char *name); | |
177 effs_t tffs_fcontrol(const char *pathname, int8 action, uint16 param); | |
178 effs_t tffs_query(int8 query, void *p); | |
179 effs_t tffs_preformat(uint16 magic); | |
180 effs_t tffs_format(const char *name, uint16 magic); | |
181 effs_t tffs_initialize(void); | |
182 effs_t tffs_exit(void); | |
183 fd_t tffs_open(const char *pathname, ffs_options_t options); | |
184 effs_t tffs_close(fd_t fdi); | |
185 int tffs_write(fd_t fdi, void *addr, int size); | |
186 int tffs_read(fd_t fdi, void *addr, int size); | |
187 int tffs_seek(fd_t fdi, int offset, int whence); | |
188 effs_t tffs_truncate(const char *path, offset_t length); | |
189 effs_t tffs_ftruncate(fd_t fdi, offset_t length); | |
190 effs_t tffs_fdatasync(fd_t fdi); | |
191 | |
192 /****************************************************************************** | |
193 * Platform/OS dependent functions | |
194 ******************************************************************************/ | |
195 | |
196 // Defined in task.c | |
197 #if (WITH_TFFS == 1) | |
198 extern void tffs_delay(int delay); | |
199 extern int tffs_wait(const char *name); | |
200 extern struct ffs_cnfpath_s *tffs_cnfpath_get(void); | |
201 extern UINT32 tffs_timer_begin(void); | |
202 extern UINT32 tffs_timer_end(UINT32 time_begin); | |
203 #else | |
204 #define tffs_delay(delay) | |
205 #endif | |
206 | |
207 | |
208 | |
209 |