diff direct/dtest.c @ 162:5d6744904e2c

Fix issue with rescan of pending retired blocks
author charles <charles>
date Tue, 14 Nov 2006 03:07:17 +0000
parents 6e3cbd76247b
children 582d5458b4c6
line wrap: on
line diff
--- a/direct/dtest.c
+++ b/direct/dtest.c
@@ -1866,6 +1866,68 @@ void small_mount_test(const char *mountp
 }
 
 
+int early_exit;
+
+void small_overwrite_test(const char *mountpt,int nmounts)
+{
+
+	char a[30];
+	char b[30];
+	char c[30];
+	
+	int i;
+	int j;
+
+	int h0;
+	int h1;
+	int len0;
+	int len1;
+	int nread;
+	
+	sprintf(a,"%s/a",mountpt);
+
+	yaffs_StartUp();
+	
+	
+	
+	for(i = 0; i < nmounts; i++){
+		
+		static char xx[8000];
+		
+		printf("############### Iteration %d   Start\n",i);
+		if(1)
+			yaffs_mount(mountpt);
+
+		dump_directory_tree(mountpt);
+		
+		yaffs_mkdir(a,0);
+		
+		sprintf(xx,"%s/0",a);
+		h0 = yaffs_open(xx, O_RDWR | O_CREAT | O_TRUNC, S_IREAD | S_IWRITE);
+		sprintf(xx,"%s/1",a);
+		h1 = yaffs_open(xx, O_RDWR | O_CREAT | O_TRUNC, S_IREAD | S_IWRITE);
+		
+		for(j = 0; j < 1000000; j+=1000){
+			yaffs_truncate(h0,j);
+			yaffs_lseek(h0,j,SEEK_SET);
+			yaffs_write(h0,xx,7000);
+			yaffs_write(h1,xx,7000);
+			
+			if(early_exit)
+				exit(0);
+		}
+		
+		yaffs_close(h0);
+		
+		printf("########### %d\n",i);
+		dump_directory_tree(mountpt);
+
+		if(1)
+			yaffs_unmount(mountpt);
+	}
+}
+
+
 void yaffs_touch(const char *fn)
 {
 	yaffs_chmod(fn, S_IREAD | S_IWRITE);
@@ -2071,7 +2133,8 @@ int main(int argc, char *argv[])
 	 
 	 //scan_pattern_test("/flash",10000,10);
 	//short_scan_test("/flash/flash",40000,200);
-	  small_mount_test("/flash/flash",1000);
+	  //small_mount_test("/flash/flash",1000);
+	  small_overwrite_test("/flash/flash",1000);
 	 //checkpoint_fill_test("/flash/flash",20);
 	 //checkpoint_upgrade_test("/flash/flash",20);
 	 // huge_array_test("/flash/flash",10);