yaffs-direct: Add reldir and reldev interfaces
[yaffs2.git] / direct / test-framework / basic-tests / dtest.c
index 665071b052a49cf12e135fad13d323ae9eb11e5d..644c1e54ed21f55a8a5fd5a3be1b7ca8488d40f6 100644 (file)
@@ -3074,7 +3074,7 @@ void large_file_test(const char *mountpt)
        yaffs_unmount(mountpt);
 
 
-       yaffs_mount_common(mountpt, 0, 1);
+       yaffs_mount3(mountpt, 0, 1);
        printf("mounted with no checkpt\n");
         dumpDir(mountpt);
        handle = yaffs_open(fullname, O_RDONLY, 0);
@@ -3082,7 +3082,7 @@ void large_file_test(const char *mountpt)
        yaffs_unmount(mountpt);
 
        /* Check resize by adding to the end, resizing back and verifying. */
-       yaffs_mount_common(mountpt, 0, 1);
+       yaffs_mount3(mountpt, 0, 1);
        printf("checking resize\n");
         dumpDir(mountpt);
        handle = yaffs_open(fullname, O_RDWR, 0);
@@ -3199,7 +3199,6 @@ void readdir_test(const char *mountpt)
 
        yaffs_unmount(mountpt);
 
-
 }
 
 void format_test(const char *mountpt)
@@ -3209,21 +3208,25 @@ void format_test(const char *mountpt)
        yaffs_start_up();
 
        ret = yaffs_format(mountpt, 0, 0, 0);
-       printf("yaffs_format(...,0, 0, 0) of unmounted returned %d\n", ret);
+       printf("yaffs_format(...,0, 0, 0) of unmounted returned %d."
+               " Should return 0\n\n\n", ret);
 
        yaffs_mount(mountpt);
 
        ret = yaffs_format(mountpt, 0, 0, 0);
-       printf("yaffs_format(...,0, 0, 0) of mounted returned %d\n", ret);
+       printf("yaffs_format(...,0, 0, 0) of mounted returned %d."
+               " Should return -1 (busy)\n\n\n", ret);
 
        ret = yaffs_format(mountpt, 1, 0, 0);
-       printf("yaffs_format(...,1, 0, 0) of mounted returned %d\n", ret);
+       printf("yaffs_format(...,1, 0, 0) of mounted returned %d."
+               " Should return 0.\n\n\n", ret);
 
        ret = yaffs_mount(mountpt);
-       printf("mount should return 0 returned %d\n", ret);
+       printf("mount should return 0 returned %d\n\n\n", ret);
 
        ret = yaffs_format(mountpt, 1, 0, 1);
-       printf("yaffs_format(...,1, 0, 1) of mounted returned %d\n", ret);
+       printf("yaffs_format(...,1, 0, 1) of mounted returned %d."
+               " Should return 0.\n\n\n", ret);
 
        ret = yaffs_mount(mountpt);
        printf("mount should return -1 returned %d\n", ret);
@@ -3297,6 +3300,40 @@ void dir_fd_test(const char *mountpt)
 
 }
 
+
+
+void create_delete_many_files_test(const char *mountpt)
+{
+
+       char fn[100];
+       int i;
+       int fsize;
+       char buffer[1000];
+       int h;
+       int wrote;
+
+
+       yaffs_start_up();
+       yaffs_mount(mountpt);
+
+       for(i = 1; i < 2000; i++) {
+               sprintf(fn,"%s/f%d",mountpt, i);
+               fsize = (i%10) * 10000 + 20000;
+               h = yaffs_open(fn, O_CREAT | O_TRUNC | O_RDWR, 0666);
+               while (fsize > 0) {
+                       wrote = yaffs_write(h, buffer, sizeof(buffer));
+                       if (wrote != sizeof(buffer)) {
+                               printf("Writing file %s, only wrote %d bytes\n", fn, wrote);
+                               break;
+                       }
+                       fsize -= wrote;
+               }
+               yaffs_unlink(fn);
+               yaffs_close(h);
+       }
+
+}
+
 int random_seed;
 int simulate_power_failure;
 
@@ -3380,8 +3417,10 @@ int main(int argc, char *argv[])
         //yy_test("/nand");
         //dir_rename_test("/nand");
 
-       dir_fd_test("/nand");
+       //dir_fd_test("/nand");
 
+       //format_test("/nand");
+       create_delete_many_files_test("/nand");
         return 0;
 
 }