X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs2.git;a=blobdiff_plain;f=direct%2Fbasic-test%2Fdtest.c;h=e6a0a146916cc38be18b08fa0f20022b20d48487;hp=34112c84ecc861dceb5cc28697199b5839b0a0b1;hb=757a553001be4016e9c5d8880648d3703f34b10e;hpb=4a700fe570d217c2c5df87070db7c2652bc0eaaf diff --git a/direct/basic-test/dtest.c b/direct/basic-test/dtest.c index 34112c8..e6a0a14 100644 --- a/direct/basic-test/dtest.c +++ b/direct/basic-test/dtest.c @@ -19,15 +19,17 @@ #include #include #include +#include #include "yaffsfs.h" +#include "yaffs_guts.h" /* Only for dumping device innards */ -void dumpDir(const char *dname); +extern int yaffs_trace_mask; -char xx[600]; +void dumpDir(const char *dname); -void copy_in_a_file(char *yaffsName,char *inName) +void copy_in_a_file(const char *yaffsName,const char *inName) { int inh,outh; unsigned char buffer[100]; @@ -49,7 +51,7 @@ void copy_in_a_file(char *yaffsName,char *inName) close(inh); } -void make_a_file(char *yaffsName,char bval,int sizeOfFile) +void make_a_file(const char *yaffsName,char bval,int sizeOfFile) { int outh; int i; @@ -177,21 +179,22 @@ void create_file_of_size(const char *fn,int syze) int h; int n; int result; - + int iteration = 0; char xx[200]; - - int iterations = (syze + strlen(fn) -1)/ strlen(fn); - + h = yaffs_open(fn, O_CREAT | O_RDWR | O_TRUNC, S_IREAD | S_IWRITE); - while (iterations > 0) + while (syze > 0) { - sprintf(xx,"%s %8d",fn,iterations); + sprintf(xx,"%s %8d",fn,iteration); n = strlen(xx); result = yaffs_write(h,xx,n); - if(result != n) - printf("Wrote %d, should have been %d\n",result,n); - iterations--; + if(result != n){ + printf("Wrote %d, should have been %d. syze is %d\n",result,n,syze); + syze = 0; + } else + syze-=n; + iteration++; } yaffs_close (h); } @@ -275,7 +278,7 @@ void yaffs_backward_scan_test(const char *path) { char fn[100]; - yaffs_StartUp(); + yaffs_start_up(); yaffs_mount(path); @@ -292,6 +295,22 @@ void yaffs_backward_scan_test(const char *path) yaffs_mount(path); } +void null_name_test(const char *path) +{ + char fn[100]; + int h; + yaffs_start_up(); + + yaffs_mount(path); + + sprintf(fn,"%s",path); + + h = yaffs_open(fn,O_CREAT| O_TRUNC| O_RDWR, 0666); + + printf("%d\n",h); + +} + char xxzz[2000]; @@ -301,7 +320,7 @@ void yaffs_device_flush_test(const char *path) int h; int i; - yaffs_StartUp(); + yaffs_start_up(); yaffs_mount(path); @@ -330,7 +349,7 @@ void short_scan_test(const char *path, int fsize, int niterations) sprintf(fn,"%s/%s",path,"f1"); - yaffs_StartUp(); + yaffs_start_up(); for(i = 0; i < niterations; i++) { printf("\n*****************\nIteration %d\n",i); @@ -355,7 +374,7 @@ void scan_pattern_test(const char *path, int fsize, int niterations) sprintf(fn[1],"%s/%s",path,"f1"); sprintf(fn[2],"%s/%s",path,"f2"); - yaffs_StartUp(); + yaffs_start_up(); for(i = 0; i < niterations; i++) { @@ -381,7 +400,8 @@ void fill_disk(const char *path,int nfiles) int n; int result; int f; - + + static char xx[600]; char str[50]; for(n = 0; n < nfiles; n++) @@ -461,7 +481,7 @@ void fill_files(const char *path,int flags, int maxIterations,int siz) } } -void leave_unlinked_file(char *path,int maxIterations,int siz) +void leave_unlinked_file(const char *path,int maxIterations,int siz) { int i; char str[50]; @@ -511,7 +531,7 @@ void dumpDirFollow(const char *dname) { sprintf(str,"%s/%s",dname,de->d_name); - yaffs_stat(str,&s); + yaffs_lstat(str,&s); printf("%s ino %d length %d mode %X ",de->d_name,(int)s.st_ino,(int)s.st_size,s.st_mode); switch(s.st_mode & S_IFMT) @@ -636,7 +656,7 @@ int long_test(int argc, char *argv[]) mode_t temp_mode; struct yaffs_stat ystat; - yaffs_StartUp(); + yaffs_start_up(); yaffs_mount("/boot"); yaffs_mount("/data"); @@ -721,7 +741,7 @@ int long_test(int argc, char *argv[]) dumpDir("/boot"); // Check stat - r = yaffs_stat("/boot/file with a long name",&ystat); + r = yaffs_lstat("/boot/file with a long name",&ystat); // Check rename @@ -808,7 +828,7 @@ int long_test(int argc, char *argv[]) // Check chmod - yaffs_stat("/boot/yyfile",&ystat); + yaffs_lstat("/boot/yyfile",&ystat); temp_mode = ystat.st_mode; yaffs_chmod("/boot/yyfile",0x55555); @@ -846,11 +866,11 @@ int long_test(int argc, char *argv[]) yaffs_unlink("/boot/zlf"); - yaffs_DumpDevStruct("/boot"); + yaffs_dump_dev("/boot"); fill_disk_and_delete("/boot",20,20); - yaffs_DumpDevStruct("/boot"); + yaffs_dump_dev("/boot"); fill_files("/boot",1,10000,0); fill_files("/boot",1,10000,5000); @@ -864,8 +884,8 @@ int long_test(int argc, char *argv[]) leave_unlinked_file("/data",20000,5000); leave_unlinked_file("/data",20000,5000); - yaffs_DumpDevStruct("/boot"); - yaffs_DumpDevStruct("/data"); + yaffs_dump_dev("/boot"); + yaffs_dump_dev("/data"); @@ -889,7 +909,7 @@ int huge_directory_test_on_path(char *path) char str[100]; - yaffs_StartUp(); + yaffs_start_up(); yaffs_mount(path); @@ -947,7 +967,7 @@ void rename_over_test(const char *mountpt) sprintf(b,"%s/b",mountpt); sprintf(c,"%s/c",mountpt); - yaffs_StartUp(); + yaffs_start_up(); yaffs_mount(mountpt); @@ -984,7 +1004,7 @@ int resize_stress_test(const char *path) char abuffer[1000]; char bbuffer[1000]; - yaffs_StartUp(); + yaffs_start_up(); yaffs_mount(path); @@ -1045,7 +1065,7 @@ int overwrite_test(const char *path) int j; int a; int b; - yaffs_StartUp(); + yaffs_start_up(); yaffs_mount(path); @@ -1070,16 +1090,16 @@ int root_perm_remount(const char *path) { struct yaffs_stat s; - yaffs_StartUp(); + yaffs_start_up(); yaffs_mount(path); - yaffs_stat(path,&s); + yaffs_lstat(path,&s); printf("root perms after mount %x\n",s.st_mode); yaffs_chmod(path, 0777); - yaffs_stat(path,&s); + yaffs_lstat(path,&s); printf("root perms after setting to 0777 is %x\n",s.st_mode); yaffs_unmount(path); @@ -1101,7 +1121,7 @@ int resize_stress_test_no_grow_complex(const char *path,int iters) char bbuffer[1000]; - yaffs_StartUp(); + yaffs_start_up(); yaffs_mount(path); @@ -1175,7 +1195,7 @@ int resize_stress_test_no_grow(const char *path,int iters) char abuffer[1000]; char bbuffer[1000]; - yaffs_StartUp(); + yaffs_start_up(); yaffs_mount(path); @@ -1240,7 +1260,7 @@ int resize_stress_test_no_grow(const char *path,int iters) int directory_rename_test(void) { int r; - yaffs_StartUp(); + yaffs_start_up(); yaffs_mount("/ram"); yaffs_mkdir("/ram/a",0); @@ -1280,7 +1300,7 @@ int cache_read_test(void) int sizeOfFiles = 500000; char buffer[100]; - yaffs_StartUp(); + yaffs_start_up(); yaffs_mount("/boot"); @@ -1319,7 +1339,7 @@ int cache_bypass_bug_test(void) memset(buffer1,0,sizeof(buffer1)); memset(buffer2,0,sizeof(buffer2)); - yaffs_StartUp(); + yaffs_start_up(); yaffs_mount("/boot"); @@ -1359,7 +1379,7 @@ int free_space_check(void) { int f; - yaffs_StartUp(); + yaffs_start_up(); yaffs_mount("/boot"); fill_disk("/boot/",2); f = yaffs_freespace("/boot"); @@ -1377,7 +1397,7 @@ int truncate_test(void) char y[10]; - yaffs_StartUp(); + yaffs_start_up(); yaffs_mount("/boot"); yaffs_unlink("/boot/trunctest"); @@ -1415,7 +1435,7 @@ int truncate_test(void) void fill_disk_test(const char *mountpt) { int i; - yaffs_StartUp(); + yaffs_start_up(); for(i = 0; i < 5; i++) { @@ -1430,7 +1450,7 @@ void fill_disk_test(const char *mountpt) void fill_files_test(const char *mountpt) { int i; - yaffs_StartUp(); + yaffs_start_up(); for(i = 0; i < 5; i++) { @@ -1444,7 +1464,7 @@ void fill_files_test(const char *mountpt) void fill_empty_files_test(const char *mountpt) { int i; - yaffs_StartUp(); + yaffs_start_up(); char name[100]; int result = 0; @@ -1473,12 +1493,12 @@ void fill_empty_files_test(const char *mountpt) void long_name_test(const char *mountpt) { int i; - yaffs_StartUp(); + yaffs_start_up(); char fullName[1000]; char name[300]; int result = 0; - int d,f; + int f; // Make a 256 byte name memset(name,0,sizeof(name)); @@ -1528,7 +1548,7 @@ void lookup_test(const char *mountpt) yaffs_DIR *d; yaffs_dirent *de; - yaffs_StartUp(); + yaffs_start_up(); yaffs_mount(mountpt); @@ -1582,13 +1602,12 @@ void lookup_test(const char *mountpt) void link_test0(const char *mountpt) { - int i; char namea[300]; char nameb[300]; int result = 0; - yaffs_StartUp(); + yaffs_start_up(); yaffs_mount(mountpt); @@ -1637,7 +1656,7 @@ void link_test1(const char *mountpt) sprintf(b,"%s/bbb",mountpt); sprintf(c,"%s/ccc",mountpt); - yaffs_StartUp(); + yaffs_start_up(); yaffs_mount(mountpt); @@ -1672,7 +1691,7 @@ void handle_test(const char *mountpt) sprintf(a,"%s/aaa",mountpt); - yaffs_StartUp(); + yaffs_start_up(); yaffs_mount(mountpt); @@ -1706,7 +1725,7 @@ void freespace_test(const char *mountpt) int f3; sprintf(a,"%s/aaa",mountpt); - yaffs_StartUp(); + yaffs_start_up(); yaffs_mount(mountpt); @@ -1747,7 +1766,7 @@ void simple_rw_test(const char *mountpt) sprintf(a,"%s/aaa",mountpt); - yaffs_StartUp(); + yaffs_start_up(); yaffs_mount(mountpt); @@ -1800,7 +1819,7 @@ void scan_deleted_files_test(const char *mountpt) int h; sprintf(sub,"%s/sdir",mountpt); - yaffs_StartUp(); + yaffs_start_up(); for(j = 0; j < 10; j++) { @@ -1933,7 +1952,7 @@ void check_resize_gc_bug(const char *mountpt) - yaffs_StartUp(); + yaffs_start_up(); yaffs_mount(mountpt); yaffs_unlink(a); yaffs_unlink(b); @@ -1963,7 +1982,7 @@ void multi_mount_test(const char *mountpt,int nmounts) sprintf(a,"%s/a",mountpt); - yaffs_StartUp(); + yaffs_start_up(); for(i = 0; i < nmounts; i++){ int h0; @@ -2040,7 +2059,7 @@ void small_mount_test(const char *mountpt,int nmounts) sprintf(a,"%s/a",mountpt); - yaffs_StartUp(); + yaffs_start_up(); @@ -2112,7 +2131,7 @@ void small_overwrite_test(const char *mountpt,int nmounts) sprintf(a,"%s/a",mountpt); - yaffs_StartUp(); + yaffs_start_up(); @@ -2156,7 +2175,7 @@ void small_overwrite_test(const char *mountpt,int nmounts) void seek_overwrite_test(const char *mountpt,int nmounts) { - + static char xx[5000]; char a[30]; int i; @@ -2167,7 +2186,7 @@ void seek_overwrite_test(const char *mountpt,int nmounts) sprintf(a,"%s/f",mountpt); - yaffs_StartUp(); + yaffs_start_up(); yaffs_mount(mountpt); @@ -2213,7 +2232,7 @@ void checkpoint_fill_test(const char *mountpt,int nmounts) - yaffs_StartUp(); + yaffs_start_up(); for(i = 0; i < nmounts; i++){ printf("############### Iteration %d Start\n",i); @@ -2287,7 +2306,7 @@ void checkpoint_upgrade_test(const char *mountpt,int nmounts) printf("Create start condition\n"); - yaffs_StartUp(); + yaffs_start_up(); yaffs_mount(mountpt); yaffs_mkdir(a,0); sprintf(b,"%s/zz",a); @@ -2342,7 +2361,7 @@ void huge_array_test(const char *mountpt,int n) - yaffs_StartUp(); + yaffs_start_up(); yaffs_mount(mountpt); @@ -2417,7 +2436,7 @@ void random_small_file_test(const char *mountpt,int iterations) int r; - yaffs_StartUp(); + yaffs_start_up(); yaffs_mount(mountpt); @@ -2476,7 +2495,7 @@ void random_small_file_test(const char *mountpt,int iterations) void rmdir_test(const char *mountpt) { char name[100]; - yaffs_StartUp(); + yaffs_start_up(); yaffs_mount(mountpt); @@ -2497,7 +2516,7 @@ static void print_xattrib_val(const char *path, const char *name) n = yaffs_getxattr(path,name,buffer,sizeof(buffer)); if(n >= 0){ - __u8 *b = (__u8 *)buffer; + u8 *b = (u8 *)buffer; printf("%d bytes:",n); if(n > 10) @@ -2536,9 +2555,8 @@ void basic_xattr_test(const char *mountpt) int h; int result; int val1; - int valread; - yaffs_StartUp(); + yaffs_start_up(); yaffs_mount(mountpt); @@ -2587,9 +2605,8 @@ void big_xattr_test(const char *mountpt) int h; int result; char val[1000]; - char valread[1000]; - yaffs_StartUp(); + yaffs_start_up(); yaffs_mount(mountpt); @@ -2623,7 +2640,76 @@ void big_xattr_test(const char *mountpt) list_xattr(name); } + + +void dump_dev_stats(struct yaffs_dev *dev, const char * str) +{ + printf("%s\n",str); + printf( "space free %d erased %d " + "nand reads %d writes %d erases %d " + "gc all %d passive %d oldestdirty %d blocks %d copies %d \n", + dev->n_free_chunks, dev->n_erased_blocks * dev->param.chunks_per_block, + dev->n_page_reads, dev->n_page_writes, dev->n_erasures, + dev->all_gcs, dev->passive_gc_count, dev->oldest_dirty_gc_count, dev->n_gc_blocks, dev->n_gc_copies); +} + +void test_flash_traffic(const char *mountpt) +{ + char name0[100]; + char name1[100]; + int i; + struct yaffs_dev *dev; + + yaffs_trace_mask = 0; + + yaffs_start_up(); + + yaffs_mount(mountpt); + + dev = yaffs_getdev(mountpt); + + strcpy(name0,mountpt); + strcat(name0,"/x"); + + strcpy(name1,mountpt); + strcat(name1,"/y"); + + dump_dev_stats(dev,"start"); + create_file_of_size(name0,32 * 1024 * 1024); + dump_dev_stats(dev,"32MB written"); + for(i = 0; i < 20; i++) + create_file_of_size(name1,1024 * 1024); + dump_dev_stats(dev,"20x 1MB files written"); + +} + +void link_follow_test(const char *mountpt) +{ + char fn[100]; + char sn[100]; + char hn[100]; + int result; + int h; + + yaffs_trace_mask = 0; + + yaffs_start_up(); + + yaffs_mount(mountpt); + + sprintf(fn,"%s/file",mountpt); + sprintf(sn,"%s/sym",mountpt); + sprintf(hn,"%s/hl-sym",mountpt); + h = yaffs_open(fn,O_CREAT| O_RDWR, S_IREAD | S_IWRITE); + result = yaffs_close(h); + + result = yaffs_symlink(fn,sn); + result = yaffs_link(sn,hn); + + h =yaffs_open(hn,O_RDWR,0); + +} int random_seed; int simulate_power_failure; @@ -2677,17 +2763,19 @@ int main(int argc, char *argv[]) //link_test("/flash/flash"); - - - // cache_bypass_bug_test(); //free_space_check(); //check_resize_gc_bug("/flash"); - basic_xattr_test("/yaffs2"); - big_xattr_test("/yaffs2"); + //basic_xattr_test("/yaffs2"); + //big_xattr_test("/yaffs2"); + + //null_name_test("yaffs2"); + + test_flash_traffic("yaffs2"); + link_follow_test("/yaffs2"); return 0;