45bd9a9cab5430439f0cae0c60ee66d6c68ea553
[yaffs2.git] / direct / dtest.c
1 /*
2 * Test code for the "direct" interface. 
3 */
4
5
6 #include <stdio.h>
7 #include <string.h>
8 #include <unistd.h>
9 #include <fcntl.h>
10
11 #include "yaffsfs.h"
12
13 void dumpDir(const char *dname);
14
15 char xx[600];
16
17 void copy_in_a_file(char *yaffsName,char *inName)
18 {
19         int inh,outh;
20         unsigned char buffer[100];
21         int ni,no;
22         inh = open(inName,O_RDONLY);
23         outh = yaffs_open(yaffsName, O_CREAT | O_RDWR | O_TRUNC, S_IREAD | S_IWRITE);
24         
25         while((ni = read(inh,buffer,100)) > 0)
26         {
27                 no = yaffs_write(outh,buffer,ni);
28                 if(ni != no)
29                 {
30                         printf("problem writing yaffs file\n");
31                 }
32                 
33         }
34         
35         yaffs_close(outh);
36         close(inh);
37 }
38
39 void make_a_file(char *yaffsName,char bval,int sizeOfFile)
40 {
41         int outh;
42         int i;
43         unsigned char buffer[100];
44
45         outh = yaffs_open(yaffsName, O_CREAT | O_RDWR | O_TRUNC, S_IREAD | S_IWRITE);
46         
47         memset(buffer,bval,100);
48         
49         do{
50                 i = sizeOfFile;
51                 if(i > 100) i = 100;
52                 sizeOfFile -= i;
53                 
54                 yaffs_write(outh,buffer,i);
55                 
56         } while (sizeOfFile > 0);
57         
58                 
59         yaffs_close(outh);
60
61 }
62
63 void make_pattern_file(char *fn,int size)
64 {
65         int outh;
66         int marker;
67         int i;
68         outh = yaffs_open(fn, O_CREAT | O_RDWR | O_TRUNC, S_IREAD | S_IWRITE);
69         yaffs_lseek(outh,size-1,SEEK_SET);
70         yaffs_write(outh,"A",1);
71         
72         for(i = 0; i < size; i+=256)
73         {
74                 marker = ~i;
75                 yaffs_lseek(outh,i,SEEK_SET);
76                 yaffs_write(outh,&marker,sizeof(marker));
77         }
78         yaffs_close(outh);
79         
80 }
81
82 int check_pattern_file(char *fn)
83 {
84         int h;
85         int marker;
86         int i;
87         int size;
88         int ok = 1;
89         
90         h = yaffs_open(fn, O_RDWR,0);
91         size = yaffs_lseek(h,0,SEEK_END);
92                 
93         for(i = 0; i < size; i+=256)
94         {
95                 yaffs_lseek(h,i,SEEK_SET);
96                 yaffs_read(h,&marker,sizeof(marker));
97                 ok = (marker == ~i);
98                 if(!ok)
99                 {
100                    printf("pattern check failed on file %s, size %d at position %d. Got %x instead of %x\n",
101                                         fn,size,i,marker,~i);
102                 }
103         }
104         yaffs_close(h);
105         return ok;
106 }
107
108
109
110
111
112 int dump_file_data(char *fn)
113 {
114         int h;
115         int marker;
116         int i = 0;
117         int size;
118         int ok = 1;
119         unsigned char b;
120         
121         h = yaffs_open(fn, O_RDWR,0);
122
123                                 
124         printf("%s\n",fn);
125         while(yaffs_read(h,&b,1)> 0)
126         {
127                 printf("%02x",b);
128                 i++;
129                 if(i > 32) 
130                 {
131                    printf("\n");
132                    i = 0;;
133                  }
134         }
135         printf("\n");
136         yaffs_close(h);
137         return ok;
138 }
139
140
141
142 void dump_file(const char *fn)
143 {
144         int i;
145         int size;
146         int h;
147         
148         h = yaffs_open(fn,O_RDONLY,0);
149         if(h < 0)
150         {
151                 printf("*****\nDump file %s does not exist\n",fn);
152         }
153         else
154         {
155                 size = yaffs_lseek(h,0,SEEK_SET);
156                 printf("*****\nDump file %s size %d\n",fn,size);
157                 for(i = 0; i < size; i++)
158                 {
159                         
160                 }
161         }
162 }
163
164 void create_file_of_size(const char *fn,int syze)
165 {
166         int h;
167         int n;
168         
169         
170         int iterations = (syze + strlen(fn) -1)/ strlen(fn);
171         
172         h = yaffs_open(fn, O_CREAT | O_RDWR | O_TRUNC, S_IREAD | S_IWRITE);
173                 
174         while (iterations > 0)
175         {
176                 yaffs_write(h,fn,strlen(fn));
177                 iterations--;
178         }
179         yaffs_close (h);
180 }
181
182 void create_resized_file_of_size(const char *fn,int syze1,int reSyze, int syze2)
183 {
184         int h;
185         int n;
186         
187         
188         int iterations;
189         
190         h = yaffs_open(fn, O_CREAT | O_RDWR | O_TRUNC, S_IREAD | S_IWRITE);
191                 
192         iterations = (syze1 + strlen(fn) -1)/ strlen(fn);
193         while (iterations > 0)
194         {
195                 yaffs_write(h,fn,strlen(fn));
196                 iterations--;
197         }
198         
199         yaffs_truncate(h,reSyze);
200         
201         yaffs_lseek(h,0,SEEK_SET);
202         iterations = (syze2 + strlen(fn) -1)/ strlen(fn);
203         while (iterations > 0)
204         {
205                 yaffs_write(h,fn,strlen(fn));
206                 iterations--;
207         }
208         
209         yaffs_close (h);
210 }
211
212
213 void do_some_file_stuff(const char *path)
214 {
215
216         char fn[100];
217
218         sprintf(fn,"%s/%s",path,"f1");
219         create_file_of_size(fn,10000);
220
221         sprintf(fn,"%s/%s",path,"fdel");
222         create_file_of_size(fn,10000);
223         yaffs_unlink(fn);
224
225         sprintf(fn,"%s/%s",path,"f2");
226         
227         create_resized_file_of_size(fn,10000,3000,4000);
228 }
229
230 void yaffs_backward_scan_test(const char *path)
231 {
232         char fn[100];
233         
234         yaffs_StartUp();        
235         
236         yaffs_mount(path);
237         
238         do_some_file_stuff(path);
239         
240         sprintf(fn,"%s/ddd",path);
241         
242         yaffs_mkdir(fn,0);
243         
244         do_some_file_stuff(fn);
245         
246         yaffs_unmount(path);
247         
248         yaffs_mount(path);
249 }
250
251 char xxzz[2000];
252
253
254 void yaffs_device_flush_test(const char *path)
255 {
256         char fn[100];
257         int h;
258         int i;
259         
260         yaffs_StartUp();        
261         
262         yaffs_mount(path);
263         
264         do_some_file_stuff(path);
265         
266         // Open and add some data to a few files
267         for(i = 0; i < 10; i++) {
268         
269                 sprintf(fn,"%s/ff%d",path,i);
270
271                 h = yaffs_open(fn, O_CREAT | O_RDWR | O_TRUNC, S_IWRITE | S_IREAD);
272                 yaffs_write(h,xxzz,2000);
273                 yaffs_write(h,xxzz,2000);
274         }
275         yaffs_unmount(path);
276         
277         yaffs_mount(path);
278 }
279
280
281
282 void short_scan_test(const char *path, int fsize, int niterations)
283 {
284         int i;
285         char fn[100];
286         
287         sprintf(fn,"%s/%s",path,"f1");
288         
289         yaffs_StartUp();
290         for(i = 0; i < niterations; i++)
291         {
292                 printf("\n*****************\nIteration %d\n",i);
293                 yaffs_mount(path);
294                 printf("\nmount: Directory look-up of %s\n",path);
295                 dumpDir(path);
296                 make_a_file(fn,1,fsize);
297                 yaffs_unmount(path);
298         }
299 }
300
301
302
303 void scan_pattern_test(const char *path, int fsize, int niterations)
304 {
305         int i;
306         int j;
307         char fn[3][100];
308         int result;
309         
310         sprintf(fn[0],"%s/%s",path,"f0");
311         sprintf(fn[1],"%s/%s",path,"f1");
312         sprintf(fn[2],"%s/%s",path,"f2");
313         
314         yaffs_StartUp();
315         
316         for(i = 0; i < niterations; i++)
317         {
318                 printf("\n*****************\nIteration %d\n",i);
319                 yaffs_mount(path);
320                 printf("\nmount: Directory look-up of %s\n",path);
321                 dumpDir(path);
322                 for(j = 0; j < 3; j++)
323                 {
324                         result = dump_file_data(fn[j]);
325                         result = check_pattern_file(fn[j]);
326                         make_pattern_file(fn[j],fsize); 
327                         result = dump_file_data(fn[j]);
328                         result = check_pattern_file(fn[j]);
329                 }
330                 yaffs_unmount(path);
331         }
332 }
333
334 void fill_disk(char *path,int nfiles)
335 {
336         int h;
337         int n;
338         int result;
339         int f;
340         
341         char str[50];
342         
343         for(n = 0; n < nfiles; n++)
344         {
345                 sprintf(str,"%s/%d",path,n);
346                 
347                 h = yaffs_open(str, O_CREAT | O_RDWR | O_TRUNC, S_IREAD | S_IWRITE);
348                 
349                 printf("writing file %s handle %d ",str, h);
350                 
351                 while ((result = yaffs_write(h,xx,600)) == 600)
352                 {
353                         f = yaffs_freespace(path);
354                 }
355                 result = yaffs_close(h);
356                 printf(" close %d\n",result);
357         }
358 }
359
360 void fill_disk_and_delete(char *path, int nfiles, int ncycles)
361 {
362         int i,j;
363         char str[50];
364         int result;
365         
366         for(i = 0; i < ncycles; i++)
367         {
368                 printf("@@@@@@@@@@@@@@ cycle %d\n",i);
369                 fill_disk(path,nfiles);
370                 
371                 for(j = 0; j < nfiles; j++)
372                 {
373                         sprintf(str,"%s/%d",path,j);
374                         result = yaffs_unlink(str);
375                         printf("unlinking file %s, result %d\n",str,result);
376                 }
377         }
378 }
379
380
381 void fill_files(char *path,int flags, int maxIterations,int siz)
382 {
383         int i;
384         int j;
385         char str[50];
386         int h;
387         
388         i = 0;
389         
390         do{
391                 sprintf(str,"%s/%d",path,i);
392                 h = yaffs_open(str, O_CREAT | O_TRUNC | O_RDWR,S_IREAD | S_IWRITE);
393                 yaffs_close(h);
394
395                 if(h >= 0)
396                 {
397                         for(j = 0; j < siz; j++)
398                         {
399                                 yaffs_write(h,str,1);
400                         }
401                 }
402                 
403                 if( flags & 1)
404                 {
405                         yaffs_unlink(str);
406                 }
407                 i++;
408         } while(h >= 0 && i < maxIterations);
409         
410         if(flags & 2)
411         {
412                 i = 0;
413                 do{
414                         sprintf(str,"%s/%d",path,i);
415                         printf("unlink %s\n",str);
416                         i++;
417                 } while(yaffs_unlink(str) >= 0);
418         }
419 }
420
421 void leave_unlinked_file(char *path,int maxIterations,int siz)
422 {
423         int i;
424         char str[50];
425         int h;
426         
427         i = 0;
428         
429         do{
430                 sprintf(str,"%s/%d",path,i);
431                 printf("create %s\n",str);
432                 h = yaffs_open(str, O_CREAT | O_TRUNC | O_RDWR,S_IREAD | S_IWRITE);
433                 if(h >= 0)
434                 {
435                         yaffs_unlink(str);
436                 }
437                 i++;
438         } while(h < 0 && i < maxIterations);
439         
440         if(h >= 0)
441         {
442                 for(i = 0; i < siz; i++)
443                 {
444                         yaffs_write(h,str,1);
445                 }
446         }
447         
448         printf("Leaving file %s open\n",str);
449
450 }
451
452 void dumpDirFollow(const char *dname)
453 {
454         yaffs_DIR *d;
455         yaffs_dirent *de;
456         struct yaffs_stat s;
457         char str[100];
458                         
459         d = yaffs_opendir(dname);
460         
461         if(!d)
462         {
463                 printf("opendir failed\n");
464         }
465         else
466         {
467                 while((de = yaffs_readdir(d)) != NULL)
468                 {
469                         sprintf(str,"%s/%s",dname,de->d_name);
470                         
471                         yaffs_stat(str,&s);
472                         
473                         printf("%s length %d mode %X ",de->d_name,(int)s.st_size,s.st_mode);
474                         switch(s.st_mode & S_IFMT)
475                         {
476                                 case S_IFREG: printf("data file"); break;
477                                 case S_IFDIR: printf("directory"); break;
478                                 case S_IFLNK: printf("symlink -->");
479                                                           if(yaffs_readlink(str,str,100) < 0)
480                                                                 printf("no alias");
481                                                           else
482                                                                 printf("\"%s\"",str);    
483                                                           break;
484                                 default: printf("unknown"); break;
485                         }
486                         
487                         printf("\n");           
488                 }
489                 
490                 yaffs_closedir(d);
491         }
492         printf("\n");
493         
494         printf("Free space in %s is %d\n\n",dname,(int)yaffs_freespace(dname));
495
496 }
497
498
499 void dumpDir(const char *dname)
500 {
501         yaffs_DIR *d;
502         yaffs_dirent *de;
503         struct yaffs_stat s;
504         char str[100];
505                         
506         d = yaffs_opendir(dname);
507         
508         if(!d)
509         {
510                 printf("opendir failed\n");
511         }
512         else
513         {
514                 while((de = yaffs_readdir(d)) != NULL)
515                 {
516                         sprintf(str,"%s/%s",dname,de->d_name);
517                         
518                         yaffs_lstat(str,&s);
519                         
520                         printf("%s length %d mode %X ",de->d_name,(int)s.st_size,s.st_mode);
521                         switch(s.st_mode & S_IFMT)
522                         {
523                                 case S_IFREG: printf("data file"); break;
524                                 case S_IFDIR: printf("directory"); break;
525                                 case S_IFLNK: printf("symlink -->");
526                                                           if(yaffs_readlink(str,str,100) < 0)
527                                                                 printf("no alias");
528                                                           else
529                                                                 printf("\"%s\"",str);    
530                                                           break;
531                                 default: printf("unknown"); break;
532                         }
533                         
534                         printf("\n");           
535                 }
536                 
537                 yaffs_closedir(d);
538         }
539         printf("\n");
540         
541         printf("Free space in %s is %d\n\n",dname,(int)yaffs_freespace(dname));
542
543 }
544
545
546 static void PermissionsCheck(const char *path, mode_t tmode, int tflags,int expectedResult)
547 {
548         int fd;
549         
550         if(yaffs_chmod(path,tmode)< 0) printf("chmod failed\n");
551         
552         fd = yaffs_open(path,tflags,0);
553         
554         if((fd >= 0) != (expectedResult > 0))
555         {
556                 printf("Permissions check %x %x %d failed\n",tmode,tflags,expectedResult);
557         }
558         else
559         {
560                 printf("Permissions check %x %x %d OK\n",tmode,tflags,expectedResult);
561         }
562         
563         
564         yaffs_close(fd);
565         
566         
567 }
568
569 int long_test(int argc, char *argv[])
570 {
571
572         int f;
573         int r;
574         char buffer[20];
575         
576         char str[100];
577         
578         int h;
579         mode_t temp_mode;
580         struct yaffs_stat ystat;
581         
582         yaffs_StartUp();
583         
584         yaffs_mount("/boot");
585         yaffs_mount("/data");
586         yaffs_mount("/flash");
587         yaffs_mount("/ram");
588         
589         printf("\nDirectory look-up of /boot\n");
590         dumpDir("/boot");
591         printf("\nDirectory look-up of /data\n");
592         dumpDir("/data");
593         printf("\nDirectory look-up of /flash\n");
594         dumpDir("/flash");
595
596         //leave_unlinked_file("/flash",20000,0);
597         //leave_unlinked_file("/data",20000,0);
598         
599         leave_unlinked_file("/ram",20,0);
600         
601
602         f = yaffs_open("/boot/b1", O_RDONLY,0);
603         
604         printf("open /boot/b1 readonly, f=%d\n",f);
605         
606         f = yaffs_open("/boot/b1", O_CREAT,S_IREAD | S_IWRITE);
607         
608         printf("open /boot/b1 O_CREAT, f=%d\n",f);
609         
610         
611         r = yaffs_write(f,"hello",1);
612         printf("write %d attempted to write to a read-only file\n",r);
613         
614         r = yaffs_close(f);
615         
616         printf("close %d\n",r);
617
618         f = yaffs_open("/boot/b1", O_RDWR,0);
619         
620         printf("open /boot/b1 O_RDWR,f=%d\n",f);
621         
622         
623         r = yaffs_write(f,"hello",2);
624         printf("write %d attempted to write to a writeable file\n",r);
625         r = yaffs_write(f,"world",3);
626         printf("write %d attempted to write to a writeable file\n",r);
627         
628         r= yaffs_lseek(f,0,SEEK_END);
629         printf("seek end %d\n",r);
630         memset(buffer,0,20);
631         r = yaffs_read(f,buffer,10);
632         printf("read %d \"%s\"\n",r,buffer);
633         r= yaffs_lseek(f,0,SEEK_SET);
634         printf("seek set %d\n",r);
635         memset(buffer,0,20);
636         r = yaffs_read(f,buffer,10);
637         printf("read %d \"%s\"\n",r,buffer);
638         memset(buffer,0,20);
639         r = yaffs_read(f,buffer,10);
640         printf("read %d \"%s\"\n",r,buffer);
641
642         // Check values reading at end.
643         // A read past end of file should return 0 for 0 bytes read.
644                 
645         r= yaffs_lseek(f,0,SEEK_END);
646         r = yaffs_read(f,buffer,10);
647         printf("read at end returned  %d\n",r); 
648         r= yaffs_lseek(f,500,SEEK_END);
649         r = yaffs_read(f,buffer,10);
650         printf("read past end returned  %d\n",r);       
651         
652         r = yaffs_close(f);
653         
654         printf("close %d\n",r);
655         
656         copy_in_a_file("/boot/yyfile","xxx");
657         
658         // Create a file with a long name
659         
660         copy_in_a_file("/boot/file with a long name","xxx");
661         
662         
663         printf("\nDirectory look-up of /boot\n");
664         dumpDir("/boot");
665
666         // Check stat
667         r = yaffs_stat("/boot/file with a long name",&ystat);
668         
669         // Check rename
670         
671         r = yaffs_rename("/boot/file with a long name","/boot/r1");
672         
673         printf("\nDirectory look-up of /boot\n");
674         dumpDir("/boot");
675         
676         // Check unlink
677         r = yaffs_unlink("/boot/r1");
678         
679         printf("\nDirectory look-up of /boot\n");
680         dumpDir("/boot");
681
682         // Check mkdir
683         
684         r = yaffs_mkdir("/boot/directory1",0);
685         
686         printf("\nDirectory look-up of /boot\n");
687         dumpDir("/boot");
688         printf("\nDirectory look-up of /boot/directory1\n");
689         dumpDir("/boot/directory1");
690
691         // add a file to the directory                  
692         copy_in_a_file("/boot/directory1/file with a long name","xxx");
693         
694         printf("\nDirectory look-up of /boot\n");
695         dumpDir("/boot");
696         printf("\nDirectory look-up of /boot/directory1\n");
697         dumpDir("/boot/directory1");
698         
699         //  Attempt to delete directory (should fail)
700         
701         r = yaffs_rmdir("/boot/directory1");
702         
703         printf("\nDirectory look-up of /boot\n");
704         dumpDir("/boot");
705         printf("\nDirectory look-up of /boot/directory1\n");
706         dumpDir("/boot/directory1");
707         
708         // Delete file first, then rmdir should work
709         r = yaffs_unlink("/boot/directory1/file with a long name");
710         r = yaffs_rmdir("/boot/directory1");
711         
712         
713         printf("\nDirectory look-up of /boot\n");
714         dumpDir("/boot");
715         printf("\nDirectory look-up of /boot/directory1\n");
716         dumpDir("/boot/directory1");
717
718 #if 0
719         fill_disk_and_delete("/boot",20,20);
720                         
721         printf("\nDirectory look-up of /boot\n");
722         dumpDir("/boot");
723 #endif
724
725         yaffs_symlink("yyfile","/boot/slink");
726         
727         yaffs_readlink("/boot/slink",str,100);
728         printf("symlink alias is %s\n",str);
729         
730         
731         
732         
733         printf("\nDirectory look-up of /boot\n");
734         dumpDir("/boot");
735         printf("\nDirectory look-up of /boot (using stat instead of lstat)\n");
736         dumpDirFollow("/boot");
737         printf("\nDirectory look-up of /boot/directory1\n");
738         dumpDir("/boot/directory1");
739
740         h = yaffs_open("/boot/slink",O_RDWR,0);
741         
742         printf("file length is %d\n",(int)yaffs_lseek(h,0,SEEK_END));
743         
744         yaffs_close(h);
745         
746         yaffs_unlink("/boot/slink");
747
748         
749         printf("\nDirectory look-up of /boot\n");
750         dumpDir("/boot");
751         
752         // Check chmod
753         
754         yaffs_stat("/boot/yyfile",&ystat);
755         temp_mode = ystat.st_mode;
756         
757         yaffs_chmod("/boot/yyfile",0x55555);
758         printf("\nDirectory look-up of /boot\n");
759         dumpDir("/boot");
760         
761         yaffs_chmod("/boot/yyfile",temp_mode);
762         printf("\nDirectory look-up of /boot\n");
763         dumpDir("/boot");
764         
765         // Permission checks...
766         PermissionsCheck("/boot/yyfile",0, O_WRONLY,0);
767         PermissionsCheck("/boot/yyfile",0, O_RDONLY,0);
768         PermissionsCheck("/boot/yyfile",0, O_RDWR,0);
769
770         PermissionsCheck("/boot/yyfile",S_IREAD, O_WRONLY,0);
771         PermissionsCheck("/boot/yyfile",S_IREAD, O_RDONLY,1);
772         PermissionsCheck("/boot/yyfile",S_IREAD, O_RDWR,0);
773
774         PermissionsCheck("/boot/yyfile",S_IWRITE, O_WRONLY,1);
775         PermissionsCheck("/boot/yyfile",S_IWRITE, O_RDONLY,0);
776         PermissionsCheck("/boot/yyfile",S_IWRITE, O_RDWR,0);
777         
778         PermissionsCheck("/boot/yyfile",S_IREAD | S_IWRITE, O_WRONLY,1);
779         PermissionsCheck("/boot/yyfile",S_IREAD | S_IWRITE, O_RDONLY,1);
780         PermissionsCheck("/boot/yyfile",S_IREAD | S_IWRITE, O_RDWR,1);
781
782         yaffs_chmod("/boot/yyfile",temp_mode);
783         
784         //create a zero-length file and unlink it (test for scan bug)
785         
786         h = yaffs_open("/boot/zlf",O_CREAT | O_TRUNC | O_RDWR,0);
787         yaffs_close(h);
788         
789         yaffs_unlink("/boot/zlf");
790         
791         
792         yaffs_DumpDevStruct("/boot");
793         
794         fill_disk_and_delete("/boot",20,20);
795         
796         yaffs_DumpDevStruct("/boot");
797         
798         fill_files("/boot",1,10000,0);
799         fill_files("/boot",1,10000,5000);
800         fill_files("/boot",2,10000,0);
801         fill_files("/boot",2,10000,5000);
802         
803         leave_unlinked_file("/data",20000,0);
804         leave_unlinked_file("/data",20000,5000);
805         leave_unlinked_file("/data",20000,5000);
806         leave_unlinked_file("/data",20000,5000);
807         leave_unlinked_file("/data",20000,5000);
808         leave_unlinked_file("/data",20000,5000);
809         
810         yaffs_DumpDevStruct("/boot");
811         yaffs_DumpDevStruct("/data");
812         
813                 
814                 
815         return 0;
816
817 }
818
819 int huge_directory_test_on_path(char *path)
820 {
821
822         yaffs_DIR *d;
823         yaffs_dirent *de;
824         struct yaffs_stat s;
825
826         int f;
827         int i;
828         int r;
829         int total = 0;
830         int lastTotal = 0;
831         char buffer[20];
832         
833         char str[100];
834         char name[100];
835         char name2[100];
836         
837         int h;
838         mode_t temp_mode;
839         struct yaffs_stat ystat;
840         
841         yaffs_StartUp();
842         
843         yaffs_mount(path);
844         
845         // Create a large number of files
846         
847         for(i = 0; i < 2000; i++)
848         {
849           sprintf(str,"%s/%d",path,i);
850           
851            f = yaffs_open(str,O_CREAT,S_IREAD | S_IWRITE);
852            yaffs_close(f);
853         }
854         
855         
856         
857         d = yaffs_opendir(path);
858         i = 0;
859         if (d) {
860         while((de = yaffs_readdir(d)) != NULL) {
861         if (total >lastTotal+100*9*1024||(i & 1023)==0){
862         printf("files = %d, total = %d\n",i, total);
863         lastTotal = total;
864         }
865                 i++;
866                 sprintf(str,"%s/%s",path,de->d_name);
867                 yaffs_lstat(str,&s);
868                 switch(s.st_mode & S_IFMT){
869                 case S_IFREG:
870         //printf("data file");
871         total += s.st_size;
872         break;
873         }
874         }
875         
876         yaffs_closedir(d);
877         }
878         
879         return 0;
880 }
881
882 int yaffs_scan_test(const char *path)
883 {
884 }
885
886
887 void rename_over_test(const char *mountpt)
888 {
889         int i;
890         char a[100];
891         char b[100];
892         
893         sprintf(a,"%s/a",mountpt);
894         sprintf(b,"%s/b",mountpt);
895         
896         yaffs_StartUp();
897         
898         yaffs_mount(mountpt);
899         i = yaffs_open(a,O_CREAT | O_TRUNC | O_RDWR, 0); 
900         yaffs_close(i);
901         i = yaffs_open(b,O_CREAT | O_TRUNC | O_RDWR, 0);
902         yaffs_close(i);
903         yaffs_rename(a,b); // rename over
904         yaffs_rename(b,a); // rename back again (not renaimng over)
905         yaffs_rename(a,b); // rename back again (not renaimng over)
906         
907         
908         yaffs_unmount(mountpt);
909         
910 }
911
912 int resize_stress_test(const char *path)
913 {
914    int a,b,i,j;
915    int x;
916    int r;
917    char aname[100];
918    char bname[100];
919    
920    char abuffer[1000];
921    char bbuffer[1000];
922    
923    yaffs_StartUp();
924    
925    yaffs_mount(path);
926    
927    sprintf(aname,"%s%s",path,"/a");
928    sprintf(bname,"%s%s",path,"/b");
929    
930    memset(abuffer,'a',1000);
931    memset(bbuffer,'b',1000);
932    
933    a = yaffs_open(aname, O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
934    b = yaffs_open(bname, O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
935    
936    printf(" %s %d %s %d\n",aname,a,bname,b);
937   
938    x = 0;
939    
940    for(j = 0; j < 100; j++)
941    {
942                 yaffs_lseek(a,0,SEEK_END);
943
944                 
945                 for(i = 0; i <20000; i++)
946                 {
947                    //r =        yaffs_lseek(b,i,SEEK_SET);
948                         //r = yaffs_write(b,bbuffer,1000);
949                         
950                         if(x & 0x16)
951                         {
952                                 // shrink
953                                 int syz = yaffs_lseek(a,0,SEEK_END);
954                                 
955                                 syz -= 500;
956                                 if(syz < 0) syz = 0;
957                                 yaffs_truncate(a,syz);
958                                 
959                         }
960                         else
961                         {
962                                 //expand
963                                 r = yaffs_lseek(a,i * 500,SEEK_SET);
964                                 r = yaffs_write(a,abuffer,1000);
965                         }
966                         x++;
967                         
968                 }
969    }
970    
971    return 0;
972    
973 }
974
975
976 int resize_stress_test_no_grow_complex(const char *path,int iters)
977 {
978    int a,b,i,j;
979    int x;
980    int r;
981    char aname[100];
982    char bname[100];
983    
984    char abuffer[1000];
985    char bbuffer[1000];
986    
987    yaffs_StartUp();
988    
989    yaffs_mount(path);
990    
991    sprintf(aname,"%s%s",path,"/a");
992    sprintf(bname,"%s%s",path,"/b");
993    
994    memset(abuffer,'a',1000);
995    memset(bbuffer,'b',1000);
996    
997    a = yaffs_open(aname, O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
998    b = yaffs_open(bname, O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
999    
1000    printf(" %s %d %s %d\n",aname,a,bname,b);
1001   
1002    x = 0;
1003    
1004    for(j = 0; j < iters; j++)
1005    {
1006                 yaffs_lseek(a,0,SEEK_END);
1007
1008                 
1009                 for(i = 0; i <20000; i++)
1010                 {
1011                    //r =        yaffs_lseek(b,i,SEEK_SET);
1012                         //r = yaffs_write(b,bbuffer,1000);
1013                         
1014                         if(!(x%20))
1015                         {
1016                                 // shrink
1017                                 int syz = yaffs_lseek(a,0,SEEK_END);
1018                                 
1019                                 while(syz > 4000)
1020                                 {
1021                                 
1022                                         syz -= 2050;
1023                                         if(syz < 0) syz = 0;
1024                                         yaffs_truncate(a,syz);
1025                                         syz = yaffs_lseek(a,0,SEEK_END);
1026                                         printf("shrink to %d\n",syz);
1027                                 }
1028                                 
1029                                 
1030                         }
1031                         else
1032                         {
1033                                 //expand
1034                                 r = yaffs_lseek(a,500,SEEK_END);
1035                                 r = yaffs_write(a,abuffer,1000);
1036                         }
1037                         x++;
1038                         
1039                                         
1040                 }
1041                 printf("file size is %d\n",yaffs_lseek(a,0,SEEK_END));
1042
1043    }
1044    
1045    return 0;
1046    
1047 }
1048
1049 int resize_stress_test_no_grow(const char *path,int iters)
1050 {
1051    int a,b,i,j;
1052    int x;
1053    int r;
1054    char aname[100];
1055    char bname[100];
1056    
1057    char abuffer[1000];
1058    char bbuffer[1000];
1059    
1060    yaffs_StartUp();
1061    
1062    yaffs_mount(path);
1063    
1064    sprintf(aname,"%s%s",path,"/a");
1065    sprintf(bname,"%s%s",path,"/b");
1066    
1067    memset(abuffer,'a',1000);
1068    memset(bbuffer,'b',1000);
1069    
1070    a = yaffs_open(aname, O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
1071    b = yaffs_open(bname, O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
1072    
1073    printf(" %s %d %s %d\n",aname,a,bname,b);
1074   
1075    x = 0;
1076    
1077    for(j = 0; j < iters; j++)
1078    {
1079                 yaffs_lseek(a,0,SEEK_END);
1080
1081                 
1082                 for(i = 0; i <20000; i++)
1083                 {
1084                    //r =        yaffs_lseek(b,i,SEEK_SET);
1085                         //r = yaffs_write(b,bbuffer,1000);
1086                         
1087                         if(!(x%20))
1088                         {
1089                                 // shrink
1090                                 int syz = yaffs_lseek(a,0,SEEK_END);
1091                                 
1092                                 while(syz > 4000)
1093                                 {
1094                                 
1095                                         syz -= 2050;
1096                                         if(syz < 0) syz = 0;
1097                                         yaffs_truncate(a,syz);
1098                                         syz = yaffs_lseek(a,0,SEEK_END);
1099                                         printf("shrink to %d\n",syz);
1100                                 }
1101                                 
1102                                 
1103                         }
1104                         else
1105                         {
1106                                 //expand
1107                                 r = yaffs_lseek(a,-500,SEEK_END);
1108                                 r = yaffs_write(a,abuffer,1000);
1109                         }
1110                         x++;
1111                         
1112                                         
1113                 }
1114                 printf("file size is %d\n",yaffs_lseek(a,0,SEEK_END));
1115
1116    }
1117    
1118    return 0;
1119    
1120 }
1121
1122 int directory_rename_test(void)
1123 {
1124         int r;
1125         yaffs_StartUp();
1126         
1127         yaffs_mount("/ram");
1128         yaffs_mkdir("/ram/a",0);
1129         yaffs_mkdir("/ram/a/b",0);
1130         yaffs_mkdir("/ram/c",0);
1131         
1132         printf("\nDirectory look-up of /ram\n");
1133         dumpDir("/ram");
1134         dumpDir("/ram/a");
1135         dumpDir("/ram/a/b");
1136
1137         printf("Do rename (should fail)\n");
1138                 
1139         r = yaffs_rename("/ram/a","/ram/a/b/d");
1140         printf("\nDirectory look-up of /ram\n");
1141         dumpDir("/ram");
1142         dumpDir("/ram/a");
1143         dumpDir("/ram/a/b");
1144
1145         printf("Do rename (should not fail)\n");
1146                 
1147         r = yaffs_rename("/ram/c","/ram/a/b/d");
1148         printf("\nDirectory look-up of /ram\n");
1149         dumpDir("/ram");
1150         dumpDir("/ram/a");
1151         dumpDir("/ram/a/b");
1152         
1153         
1154         return 1;
1155         
1156 }
1157
1158 int cache_read_test(void)
1159 {
1160         int a,b,c;
1161         int i;
1162         int sizeOfFiles = 500000;
1163         char buffer[100];
1164         
1165         yaffs_StartUp();
1166         
1167         yaffs_mount("/boot");
1168         
1169         make_a_file("/boot/a",'a',sizeOfFiles);
1170         make_a_file("/boot/b",'b',sizeOfFiles);
1171
1172         a = yaffs_open("/boot/a",O_RDONLY,0);
1173         b = yaffs_open("/boot/b",O_RDONLY,0);
1174         c = yaffs_open("/boot/c", O_CREAT | O_RDWR | O_TRUNC, S_IREAD | S_IWRITE);
1175
1176         do{
1177                 i = sizeOfFiles;
1178                 if (i > 100) i = 100;
1179                 sizeOfFiles  -= i;
1180                 yaffs_read(a,buffer,i);
1181                 yaffs_read(b,buffer,i);
1182                 yaffs_write(c,buffer,i);
1183         } while(sizeOfFiles > 0);
1184         
1185         
1186         
1187         return 1;
1188         
1189 }
1190
1191 int cache_bypass_bug_test(void)
1192 {
1193         // This test reporoduces a bug whereby YAFFS caching *was* buypassed
1194         // resulting in erroneous reads after writes.
1195         // This bug has been fixed.
1196         
1197         int a;
1198         int i;
1199         char buffer1[1000];
1200         char buffer2[1000];
1201         
1202         memset(buffer1,0,sizeof(buffer1));
1203         memset(buffer2,0,sizeof(buffer2));
1204                 
1205         yaffs_StartUp();
1206         
1207         yaffs_mount("/boot");
1208         
1209         // Create a file of 2000 bytes.
1210         make_a_file("/boot/a",'X',2000);
1211
1212         a = yaffs_open("/boot/a",O_RDWR, S_IREAD | S_IWRITE);
1213         
1214         // Write a short sequence to the file.
1215         // This will go into the cache.
1216         yaffs_lseek(a,0,SEEK_SET);
1217         yaffs_write(a,"abcdefghijklmnopqrstuvwxyz",20); 
1218
1219         // Read a short sequence from the file.
1220         // This will come from the cache.
1221         yaffs_lseek(a,0,SEEK_SET);
1222         yaffs_read(a,buffer1,30); 
1223
1224         // Read a page size sequence from the file.
1225         yaffs_lseek(a,0,SEEK_SET);
1226         yaffs_read(a,buffer2,512); 
1227         
1228         printf("buffer 1 %s\n",buffer1);
1229         printf("buffer 2 %s\n",buffer2);
1230         
1231         if(strncmp(buffer1,buffer2,20))
1232         {
1233                 printf("Cache bypass bug detected!!!!!\n");
1234         }
1235         
1236         
1237         return 1;
1238 }
1239
1240
1241 int free_space_check(void)
1242 {
1243         int f;
1244         
1245                 yaffs_StartUp();
1246                 yaffs_mount("/boot");
1247             fill_disk("/boot/",2);
1248             f = yaffs_freespace("/boot");
1249             
1250             printf("%d free when disk full\n",f);           
1251             return 1;
1252 }
1253
1254 int truncate_test(void)
1255 {
1256         int a;
1257         int r;
1258         int i;
1259         int l;
1260
1261         char y[10];
1262
1263         yaffs_StartUp();
1264         yaffs_mount("/boot");
1265
1266         yaffs_unlink("/boot/trunctest");
1267         
1268         a = yaffs_open("/boot/trunctest", O_CREAT | O_TRUNC | O_RDWR,  S_IREAD | S_IWRITE);
1269         
1270         yaffs_write(a,"abcdefghijklmnopqrstuvwzyz",26);
1271         
1272         yaffs_truncate(a,3);
1273         l= yaffs_lseek(a,0,SEEK_END);
1274         
1275         printf("truncated length is %d\n",l);
1276
1277         yaffs_lseek(a,5,SEEK_SET);
1278         yaffs_write(a,"1",1);
1279
1280         yaffs_lseek(a,0,SEEK_SET);
1281         
1282         r = yaffs_read(a,y,10);
1283
1284         printf("read %d bytes:",r);
1285
1286         for(i = 0; i < r; i++) printf("[%02X]",y[i]);
1287
1288         printf("\n");
1289
1290         return 0;
1291
1292 }
1293
1294
1295
1296
1297
1298 void fill_disk_test(const char *mountpt)
1299 {
1300         int i;
1301         yaffs_StartUp();
1302         
1303         for(i = 0; i < 5; i++)
1304         {
1305                 yaffs_mount(mountpt);
1306                 fill_disk_and_delete(mountpt,100,i+1);
1307                 yaffs_unmount(mountpt);
1308         }
1309         
1310 }
1311
1312
1313
1314 void lookup_test(const char *mountpt)
1315 {
1316         int i;
1317         int h;
1318         char a[100];
1319         char b[100];
1320         
1321
1322         yaffs_DIR *d;
1323         yaffs_dirent *de;
1324         struct yaffs_stat s;
1325         char str[100];
1326
1327         yaffs_StartUp();
1328         
1329         yaffs_mount(mountpt);
1330                                 
1331         d = yaffs_opendir(mountpt);
1332         
1333         if(!d)
1334         {
1335                 printf("opendir failed\n");
1336         }
1337         else
1338         {
1339                 
1340                 for(i = 0; (de = yaffs_readdir(d)) != NULL; i++)
1341                 {
1342                         printf("unlinking %s\n",de->d_name);
1343                         yaffs_unlink(de->d_name);
1344                 }
1345                 
1346                 printf("%d files deleted\n",i);
1347         }
1348         
1349         
1350         for(i = 0; i < 2000; i++){
1351         sprintf(a,"%s/%d",mountpt,i);
1352                 h =  yaffs_open(a,O_CREAT | O_TRUNC | O_RDWR, 0);
1353                 yaffs_close(h);
1354         }
1355
1356         yaffs_rewinddir(d);
1357         for(i = 0; (de = yaffs_readdir(d)) != NULL; i++)
1358         {
1359                 printf("%d  %s\n",i,de->d_name);
1360         }       
1361         
1362         printf("%d files listed\n\n\n",i);
1363         
1364         yaffs_rewinddir(d);
1365         yaffs_readdir(d);
1366         yaffs_readdir(d);
1367         yaffs_readdir(d);
1368         
1369         for(i = 0; i < 2000; i++){
1370                 sprintf(a,"%s/%d",mountpt,i);
1371                 yaffs_unlink(a);
1372         }
1373         
1374                 
1375         yaffs_unmount(mountpt);
1376         
1377 }
1378
1379 void link_test(const char *mountpt)
1380 {
1381         int i;
1382         int h;
1383         char a[100];
1384         char b[100];
1385         char c[100];
1386         
1387         int  f0;
1388         int f1;
1389         int f2;
1390         int f3;
1391         sprintf(a,"%s/aaa",mountpt);
1392         sprintf(b,"%s/bbb",mountpt);
1393         sprintf(c,"%s/ccc",mountpt);
1394         
1395         yaffs_StartUp();
1396         
1397         yaffs_mount(mountpt);
1398         
1399         
1400         h = yaffs_open(a, O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
1401         for(i = 0; i < 100; i++)
1402                 yaffs_write(h,a,100);
1403         
1404         yaffs_close(h);
1405         
1406         yaffs_unlink(b);
1407         yaffs_unlink(c);
1408         yaffs_link(a,b);
1409         yaffs_link(a,c);
1410         yaffs_unlink(b);
1411         yaffs_unlink(c);
1412         yaffs_unlink(a);
1413         
1414         
1415         yaffs_unmount(mountpt);
1416         yaffs_mount(mountpt);
1417         
1418         printf("link test done\n");     
1419         
1420 }
1421
1422 void freespace_test(const char *mountpt)
1423 {
1424         int i;
1425         int h;
1426         char a[100];
1427         char b[100];
1428         
1429         int  f0;
1430         int f1;
1431         int f2;
1432         int f3;
1433         sprintf(a,"%s/aaa",mountpt);
1434         
1435         yaffs_StartUp();
1436         
1437         yaffs_mount(mountpt);
1438         
1439         f0 = yaffs_freespace(mountpt);
1440         
1441         h = yaffs_open(a, O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
1442         
1443         for(i = 0; i < 100; i++)
1444                 yaffs_write(h,a,100);
1445         
1446         yaffs_close(h);
1447         
1448         f1 = yaffs_freespace(mountpt);
1449         
1450         yaffs_unlink(a);
1451         
1452         f2 = yaffs_freespace(mountpt);
1453         
1454                 
1455         yaffs_unmount(mountpt);
1456         yaffs_mount(mountpt);
1457         
1458         f3 = yaffs_freespace(mountpt);
1459         
1460         printf("%d\n%d\n%d\n%d\n",f0, f1,f2,f3);
1461         
1462         
1463 }
1464
1465 void simple_rw_test(const char *mountpt)
1466 {
1467         int i;
1468         int h;
1469         char a[100];
1470         
1471         int x;
1472         int result;
1473
1474         sprintf(a,"%s/aaa",mountpt);
1475         
1476         yaffs_StartUp();
1477         
1478         yaffs_mount(mountpt);
1479         
1480         yaffs_unlink(a);
1481         
1482         h = yaffs_open(a,O_CREAT| O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
1483         
1484         for(i = 100000;i < 200000; i++){
1485                 result = yaffs_write(h,&i,sizeof(i));
1486                 
1487                 if(result != 4)
1488                 {
1489                         printf("write error\n");
1490                         exit(1);
1491                 }
1492         }
1493         
1494         //yaffs_close(h);
1495         
1496         // h = yaffs_open(a,O_RDWR, S_IREAD | S_IWRITE);
1497         
1498         
1499         yaffs_lseek(h,0,SEEK_SET);
1500         
1501         for(i = 100000; i < 200000; i++){
1502                 result = yaffs_read(h,&x,sizeof(x));
1503                 
1504                 if(result != 4 || x != i){
1505                         printf("read error %d %x %x\n",i,result,x);
1506                 }
1507         }
1508         
1509         printf("Simple rw test passed\n");
1510         
1511         
1512         
1513 }
1514
1515
1516 void scan_deleted_files_test(const char *mountpt)
1517 {
1518         char fn[100];
1519         char sub[100];
1520         
1521         const char *p;
1522         
1523         int i;
1524         int j;
1525         int k;
1526         int h;
1527         
1528         sprintf(sub,"%s/sdir",mountpt);
1529         yaffs_StartUp();
1530         
1531         for(j = 0; j < 10; j++)
1532         {
1533                 printf("\n\n>>>>>>> Run %d <<<<<<<<<<<<<\n\n",j);
1534                 yaffs_mount(mountpt);
1535                 yaffs_mkdir(sub,0);
1536                 
1537                 
1538                 p = (j & 0) ? mountpt: sub;
1539         
1540                 for(i = 0; i < 100; i++)
1541                 {
1542                   sprintf(fn,"%s/%d",p,i);  
1543                   
1544                   if(i & 1)
1545                   {
1546                           h = yaffs_open(fn,O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
1547                           for(k = 0; k < 1000; k++)
1548                                   yaffs_write(h,fn,100);
1549                           yaffs_close(h);
1550                   }
1551                   else
1552                         yaffs_mkdir(fn,0);
1553                 }
1554                 
1555                 for(i = 0; i < 10; i++)
1556                 {
1557                   sprintf(fn,"%s/%d",p,i);  
1558                   if(i & 1) 
1559                         yaffs_unlink(fn);
1560                   else
1561                         yaffs_rmdir(fn);
1562                   
1563                 }
1564                                 
1565                 yaffs_unmount(mountpt);
1566         }
1567         
1568         
1569         
1570
1571 }
1572
1573
1574 void write_10k(int h)
1575 {
1576    int i;
1577    const char *s="0123456789";
1578    for(i = 0; i < 1000; i++)
1579      yaffs_write(h,s,10);
1580
1581 }
1582 void write_200k_file(const char *fn, const char *fdel, const char *fdel1)
1583 {
1584    int h1;
1585    int h2;
1586    int i;
1587    
1588    h1 = yaffs_open(fn, O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
1589    
1590    for(i = 0; i < 100000; i+= 10000)
1591    {
1592         write_10k(h1);
1593         write_10k(h2);
1594    }
1595    
1596    if(yaffs_lseek(h1,0,SEEK_SET) != 1000000)
1597    {
1598         printf("Could not write file\n");
1599    }
1600    
1601    yaffs_unlink(fdel);
1602    for(i = 0; i < 100000; i+= 10000)
1603    {
1604         write_10k(h1);
1605         write_10k(h2);
1606    }
1607    
1608    if(yaffs_lseek(h1,0,SEEK_SET) != 2000000)
1609    {
1610         printf("Could not write file\n");
1611    }
1612    
1613    yaffs_close(h1);
1614    yaffs_close(h2);
1615    yaffs_unlink(fdel1);
1616    
1617    
1618 }
1619
1620
1621 void verify_200k_file(const char *fn)
1622 {
1623    int h1;
1624    int i;
1625    char x[11];
1626    const char *s="0123456789";
1627    
1628    h1 = yaffs_open(fn, O_RDONLY, 0);
1629    
1630    for(i = 0; i < 200000; i+= 10)
1631    {
1632         yaffs_read(h1,x,10);
1633         if(strncmp(x,s,10) != 0)
1634         {
1635                 printf("File verification failed at %d\n",i);
1636         }
1637    }
1638       
1639    yaffs_close(h1);        
1640         
1641 }
1642
1643
1644 void check_resize_gc_bug(const char *mountpt)
1645 {
1646
1647         char a[30];
1648         char b[30];
1649         char c[30];
1650         
1651         int i;
1652         
1653         sprintf(a,"%s/a",mountpt);
1654         sprintf(b,"%s/b",mountpt);
1655         sprintf(c,"%s/c",mountpt);
1656         
1657
1658         
1659         
1660         yaffs_StartUp();
1661         yaffs_mount(mountpt);
1662         yaffs_unlink(a);
1663         yaffs_unlink(b);
1664         
1665         for(i = 0; i < 50; i++)
1666         {  
1667            printf("A\n");write_200k_file(a,"",c);
1668            printf("B\n");verify_200k_file(a);
1669            printf("C\n");write_200k_file(b,a,c);
1670            printf("D\n");verify_200k_file(b);
1671            yaffs_unmount(mountpt);
1672            yaffs_mount(mountpt);
1673            printf("E\n");verify_200k_file(a);
1674            printf("F\n");verify_200k_file(b);
1675         }
1676                 
1677 }
1678
1679
1680 int main(int argc, char *argv[])
1681 {
1682         //return long_test(argc,argv);
1683         
1684         //return cache_read_test();
1685         
1686         //resize_stress_test_no_grow("/flash",20);
1687         
1688         //huge_directory_test_on_path("/ram2k");
1689         
1690          //yaffs_backward_scan_test("/flash/flash");
1691          yaffs_device_flush_test("/flash/flash");
1692
1693          
1694          //scan_pattern_test("/flash",10000,10);
1695         //short_scan_test("/flash",40000,200);
1696
1697         
1698         //long_test_on_path("/ram2k");
1699         // long_test_on_path("/flash");
1700         //simple_rw_test("/flash/flash");
1701         //fill_disk_test("/flash/flash");
1702         // rename_over_test("/flash");
1703         //lookup_test("/flash");
1704         //freespace_test("/flash/flash");
1705         
1706         //link_test("/flash/flash");
1707         
1708         
1709         
1710         
1711         // cache_bypass_bug_test();
1712         
1713          //free_space_check();
1714          
1715          //check_resize_gc_bug("/flash");
1716          
1717          return 0;
1718         
1719 }