X-Git-Url: http://www.aleph1.co.uk/gitweb/?a=blobdiff_plain;f=direct%2Fdtest.c;h=45bd9a9cab5430439f0cae0c60ee66d6c68ea553;hb=06781c4ca96ccdf097952eb97fe86b8db87b84b0;hp=3679b25b86b357f34ef0b3ff5f1fd653cde3f734;hpb=f67d10d7a5a6d1cc7d1cb6eaada2522873ce5e99;p=yaffs2.git diff --git a/direct/dtest.c b/direct/dtest.c index 3679b25..45bd9a9 100644 --- a/direct/dtest.c +++ b/direct/dtest.c @@ -248,6 +248,35 @@ void yaffs_backward_scan_test(const char *path) yaffs_mount(path); } +char xxzz[2000]; + + +void yaffs_device_flush_test(const char *path) +{ + char fn[100]; + int h; + int i; + + yaffs_StartUp(); + + yaffs_mount(path); + + do_some_file_stuff(path); + + // Open and add some data to a few files + for(i = 0; i < 10; i++) { + + sprintf(fn,"%s/ff%d",path,i); + + h = yaffs_open(fn, O_CREAT | O_RDWR | O_TRUNC, S_IWRITE | S_IREAD); + yaffs_write(h,xxzz,2000); + yaffs_write(h,xxzz,2000); + } + yaffs_unmount(path); + + yaffs_mount(path); +} + void short_scan_test(const char *path, int fsize, int niterations) @@ -1347,6 +1376,49 @@ void lookup_test(const char *mountpt) } +void link_test(const char *mountpt) +{ + int i; + int h; + char a[100]; + char b[100]; + char c[100]; + + int f0; + int f1; + int f2; + int f3; + sprintf(a,"%s/aaa",mountpt); + sprintf(b,"%s/bbb",mountpt); + sprintf(c,"%s/ccc",mountpt); + + yaffs_StartUp(); + + yaffs_mount(mountpt); + + + h = yaffs_open(a, O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE); + for(i = 0; i < 100; i++) + yaffs_write(h,a,100); + + yaffs_close(h); + + yaffs_unlink(b); + yaffs_unlink(c); + yaffs_link(a,b); + yaffs_link(a,c); + yaffs_unlink(b); + yaffs_unlink(c); + yaffs_unlink(a); + + + yaffs_unmount(mountpt); + yaffs_mount(mountpt); + + printf("link test done\n"); + +} + void freespace_test(const char *mountpt) { int i; @@ -1388,6 +1460,56 @@ void freespace_test(const char *mountpt) printf("%d\n%d\n%d\n%d\n",f0, f1,f2,f3); +} + +void simple_rw_test(const char *mountpt) +{ + int i; + int h; + char a[100]; + + int x; + int result; + + sprintf(a,"%s/aaa",mountpt); + + yaffs_StartUp(); + + yaffs_mount(mountpt); + + yaffs_unlink(a); + + h = yaffs_open(a,O_CREAT| O_TRUNC | O_RDWR, S_IREAD | S_IWRITE); + + for(i = 100000;i < 200000; i++){ + result = yaffs_write(h,&i,sizeof(i)); + + if(result != 4) + { + printf("write error\n"); + exit(1); + } + } + + //yaffs_close(h); + + // h = yaffs_open(a,O_RDWR, S_IREAD | S_IWRITE); + + + yaffs_lseek(h,0,SEEK_SET); + + for(i = 100000; i < 200000; i++){ + result = yaffs_read(h,&x,sizeof(x)); + + if(result != 4 || x != i){ + printf("read error %d %x %x\n",i,result,x); + } + } + + printf("Simple rw test passed\n"); + + + } @@ -1565,7 +1687,9 @@ int main(int argc, char *argv[]) //huge_directory_test_on_path("/ram2k"); - //yaffs_backward_scan_test("/flash") ; + //yaffs_backward_scan_test("/flash/flash"); + yaffs_device_flush_test("/flash/flash"); + //scan_pattern_test("/flash",10000,10); //short_scan_test("/flash",40000,200); @@ -1573,10 +1697,14 @@ int main(int argc, char *argv[]) //long_test_on_path("/ram2k"); // long_test_on_path("/flash"); - //fill_disk_test("/flash"); + //simple_rw_test("/flash/flash"); + //fill_disk_test("/flash/flash"); // rename_over_test("/flash"); //lookup_test("/flash"); - freespace_test("/flash"); + //freespace_test("/flash/flash"); + + //link_test("/flash/flash"); +