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