Some test case changes
[yaffs2.git] / direct / dtest.c
index 5b038c4b036c10971b8462d4567f890756c03b69..5b4d6a6828668511a4f80d8b6799f9e8a389ce63 100644 (file)
@@ -22,6 +22,8 @@
 
 #include "yaffsfs.h"
 
+#include "nor_stress.h"
+
 void dumpDir(const char *dname);
 
 char xx[600];
@@ -941,9 +943,11 @@ void rename_over_test(const char *mountpt)
        int i;
        char a[100];
        char b[100];
+       char c[100];
        
        sprintf(a,"%s/a",mountpt);
        sprintf(b,"%s/b",mountpt);
+       sprintf(c,"%s/c",mountpt);
        
        yaffs_StartUp();
        
@@ -953,9 +957,13 @@ void rename_over_test(const char *mountpt)
        dumpDirFollow(mountpt);
        
        
-       i = yaffs_open(a,O_CREAT | O_TRUNC | O_RDWR, 0); 
+       
+       i = yaffs_open(c,O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
+       printf("File c handle is %d\n",i);
        yaffs_close(i);
-       i = yaffs_open(b,O_CREAT | O_TRUNC | O_RDWR, 0);
+       i = yaffs_open(a,O_CREAT | O_TRUNC | O_RDWR,  S_IREAD | S_IWRITE); 
+       yaffs_close(i);
+       i = yaffs_open(b,O_CREAT | O_TRUNC | O_RDWR,  S_IREAD | S_IWRITE);
        yaffs_close(i);
        yaffs_rename(a,b); // rename over
        yaffs_rename(b,a); // rename back again (not renaimng over)
@@ -966,6 +974,7 @@ void rename_over_test(const char *mountpt)
        
 }
 
+
 int resize_stress_test(const char *path)
 {
    int a,b,i,j;
@@ -1029,6 +1038,28 @@ int resize_stress_test(const char *path)
    
 }
 
+int root_perm_remount(const char *path)
+{
+   struct yaffs_stat s;
+   
+   yaffs_StartUp();
+   
+   yaffs_mount(path);
+   
+   yaffs_stat(path,&s);
+   printf("root perms after mount %x\n",s.st_mode);
+   
+   yaffs_chmod(path, 0777);
+
+   yaffs_stat(path,&s);
+   printf("root perms after setting to 0777 is  %x\n",s.st_mode);
+   
+   yaffs_unmount(path);
+      
+   return 0;
+   
+}
+
 
 int resize_stress_test_no_grow_complex(const char *path,int iters)
 {
@@ -2250,23 +2281,44 @@ void random_small_file_test(const char *mountpt,int iterations)
                
        yaffs_unmount(mountpt);
 }
+
+void rmdir_test(const char *mountpt)
+{
+       char name[100];
+       yaffs_StartUp();
+       
+       yaffs_mount(mountpt);
+       
+       strcpy(name,mountpt);
+       strcat(name,"/");
+       strcat(name,"hello");
+       yaffs_mkdir(name,0666);
+       yaffs_rmdir(name);
+       yaffs_unmount(mountpt);
+}
        
 
+int random_seed;
+int simulate_power_failure;
 
 int main(int argc, char *argv[])
 {
+       random_seed = time(NULL);
        //return long_test(argc,argv);
        
        //return cache_read_test();
        
-       //resize_stress_test_no_grow("/flash/flash",20);
+       // resize_stress_test_no_grow("/flash/flash",20);
+       //root_perm_remount("/flash/flash");
        
        //huge_directory_test_on_path("/ram2k");
        
         //yaffs_backward_scan_test("/flash/flash");
        // yaffs_device_flush_test("/flash/flash");
 
-       rename_over_test("/flash/yaffs1");
+       //rename_over_test("//////////////////flash///////////////////yaffs1///////////");
+       
+       rmdir_test("M18-1");
        
         //scan_pattern_test("/flash",10000,10);
        //short_scan_test("/flash/flash",40000,200);