yaffs Moving timothy_tests and updating the makefiles to work with the new test-framework
[yaffs2.git] / direct / test-framework / timothy_tests / threading / test_a.c
1 /*
2  * YAFFS: Yet another FFS. A NAND-flash specific file system.
3  *
4  * Copyright (C) 2002-2011 Aleph One Ltd.
5  *   for Toby Churchill Ltd and Brightstar Engineering
6  *
7  * Created by Timothy Manning <timothy@yaffs.net>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License version 2 as
11  * published by the Free Software Foundation.
12  */
13
14 #include "test_a.h"
15
16
17
18
19
20 void test_a(void *x)
21 {
22         struct bovver_context *bc = (struct bovver_context *)x;
23
24         int i;
25         int op;
26         int pos;
27         int n;
28         int n1;
29         struct yaffs_stat stat_buffer;
30         char name[200];
31         char name1[200];
32         
33         int start_op;
34         
35         
36         i = rand() % BOVVER_HANDLES;
37         op = rand() % bc->opMax;
38         pos = rand() & 20000000;
39         n = rand() % 100;
40         n1 = rand() % 100;
41         
42         start_op = op;
43                 
44         sprintf(name, "%s/xx%d",bc->baseDir,n);
45         sprintf(name1,"%s/xx%d",bc->baseDir,n1);
46
47         bc->op = op;
48         bc->cycle++;
49         
50         op-=1;
51         if(op < 0){
52                 if(bc->h[i]>= 0){
53                         yaffs_close(bc->h[i]);
54                         bc->h[i] = -1;
55                 }
56                 return;
57         }
58
59         op-=1;
60         if(op < 0){
61                 if(bc->h[i] < 0)
62                         bc->h[i] = yaffs_open(name,O_CREAT| O_RDWR, 0666);
63                 return;
64         }
65
66         op-=5;
67         if(op< 0){
68                 yaffs_lseek(bc->h[i],pos,SEEK_SET);
69                 yaffs_write(bc->h[i],name,n);
70                 return;
71         }
72
73         op-=1;
74         if(op < 0){
75                 yaffs_unlink(name);
76                 return;
77         }
78         op-=1;
79         if(op < 0){
80                 yaffs_rename(name,name1);
81                 return;
82         }
83         op-=1;
84         if(op < 0){
85                 yaffs_mkdir(name,0666);
86                 return;
87         }
88         op-=1;
89         if(op < 0){
90                 yaffs_rmdir(name);
91                 return;
92         }
93         op-=1;
94         if(op < 0){
95                 yaffs_rmdir(name);
96                 return;
97         }
98         op -=1;
99         if(op < 0){
100                 if(bc->h[i]>= 0){
101                         yaffs_fsync(bc->h[i]);
102                         return;
103                 }
104         }
105         op -=1;
106         if(op < 0){
107                 if(bc->h[i]>= 0){
108                         yaffs_fdatasync(bc->h[i]);
109                         return;
110                 }
111         }
112         op -=1;
113         if(op < 0){
114                 if(bc->h[i]>= 0){
115                         yaffs_flush(bc->h[i]);
116                         return;
117                 }
118         }
119
120         op -=1;
121         if(op < 0){
122                 if((bc->h[i]>= 0) && (bc->h[i+1] < 0)){
123                         bc->h[i+1]=yaffs_dup(bc->h[i]);
124                         return;
125                 }
126         }
127         op -=1;
128         if(op < 0){
129                 if(bc->h[i]>= 0){
130                         yaffs_ftruncate(bc->h[i],n);
131                         return;
132                 }
133         }
134
135         op -=1;
136         if(op < 0){
137                 if(bc->h[i]>= 0){
138                         yaffs_fstat(bc->h[i],&stat_buffer);
139                         yaffs_fchmod(bc->h[i], n);
140                         yaffs_fchmod(bc->h[i], ((S_IREAD|S_IWRITE)&(stat_buffer.st_mode)));
141                 }
142         }
143         op -=1;
144         if(op < 0){
145                 if(bc->h[i]>= 0){
146                         yaffs_stat(name,&stat_buffer);
147                         yaffs_chmod(name, n);
148                         yaffs_chmod(name, ((S_IREAD|S_IWRITE)&(stat_buffer.st_mode)));
149                 }
150         }
151         op -=1;
152         if(op < 0){
153                 if(bc->h[i]>= 0){
154                         yaffs_lstat(name,&stat_buffer);
155                 }
156         }
157         op -=1;
158         if(op < 0){
159                 if(bc->h[i]>= 0){
160                         yaffs_read(bc->h[i],name,n);
161                         return;
162                 }
163         }
164         op -=1;
165         if(op < 0){
166                 if(bc->h[i]>= 0){
167                         yaffs_pread(bc->h[i],name,n,n1);
168                         return;
169                 }
170         }
171         op -=1;
172         if(op < 0){
173                 if(bc->h[i]>= 0){
174                         yaffs_write(bc->h[i],name,n);
175                         return;
176                 }
177         }
178         op -=1;
179         if(op < 0){
180                 if(bc->h[i]>= 0){
181                         yaffs_pwrite(bc->h[i],name,n,n1);
182                         return;
183                 }
184         }
185         op -=1;
186         if(op < 0){
187                 if(bc->h[i]>= 0){
188                         yaffs_truncate(name,n);
189                         return;
190                 }
191         }
192         op -=1;
193         if(op < 0){
194                 if(bc->h[i]>= 0){
195                         yaffs_access(name,n);
196                         return;
197                 }
198         }
199         op -=1;
200         if(op < 0){
201                 if(bc->h[i]>= 0){
202                         yaffs_symlink(name,name1);
203                         return;
204                 }
205         }
206         op -=1;
207         if(op < 0){
208                 if(bc->h[i]>= 0){
209                         yaffs_link(name,name1);
210                         return;
211                 }
212         }
213                 op -=1;
214         if(op < 0){
215                 if(bc->h[i]>= 0){
216                         yaffs_unlink(name);
217                         return;
218                 }
219         }
220         return;         
221         
222 }
223