Fix unmatched temporary buffer allocations
[yaffs2.git] / direct / test-framework / basic-tests / dtest.c
index 1a98bcb18d17ced144f73d389893af8bb05e0f7d..405f00aad72cdf74a2b60103bee517e292a374d1 100644 (file)
@@ -118,9 +118,6 @@ int check_pattern_file(char *fn)
 }
 
 
-
-
-
 int dump_file_data(char *fn)
 {
        int h;
@@ -1524,6 +1521,40 @@ void fill_disk_test(const char *mountpt)
 }
 
 
+void fill_n_file_test(const char *mountpt, int n, int syz)
+{
+       int i;
+       int l;
+
+       yaffs_start_up();
+
+       yaffs_format(mountpt, 0, 0, 0);
+       yaffs_mount(mountpt);
+
+
+       for(i = 0; i < n; i++)
+       {
+               int h;
+               char fname[200];
+
+               sprintf(fname, "%s/%d", mountpt, i);
+
+               h = yaffs_open(fname, O_CREAT | O_TRUNC | O_RDWR,  S_IREAD | S_IWRITE);
+
+               l = syz;
+
+               while(l > 0) {
+                       yaffs_write(h, fname, sizeof(fname));
+                       l -= sizeof(fname);
+               }
+
+               yaffs_close(h);
+
+       }
+
+}
+
+
 void fill_files_test(const char *mountpt)
 {
        int i;
@@ -3406,11 +3437,36 @@ void rmdir_test2(void)
        try_rmdir("/nand/z/");
 }
 
+
+void dump_yaffs_malloc_usage(void)
+{
+       unsigned current;
+       unsigned high_water;
+
+       yaffsfs_get_malloc_values(&current, &high_water);
+
+       printf("\n"
+              "***************************************\n"
+              "Dump of yaffs malloc usage during run\n"
+              "Currently allocated : %u bytes\n"
+              "High water allocated : %u bytes\n"
+              "Note, this is not accurate on all platforms\n",
+               current, high_water);
+
+}
+
+
 int random_seed;
 int simulate_power_failure;
 
 int main(int argc, char *argv[])
 {
+
+       //unlink("emfile-nand");
+
+
+       atexit(dump_yaffs_malloc_usage);
+
        (void) argc;
        (void) argv;
 
@@ -3437,7 +3493,8 @@ int main(int argc, char *argv[])
        //link_test0("/nand");
        //link_test1("yaffs2");
         //scan_pattern_test("/flash",10000,10);
-       short_scan_test("/yflash2",40000,200);
+       //short_scan_test("/yflash2",40000,200);
+       //short_scan_test("/nand128MB",40000,200);
          //small_mount_test("/flash/flash",1000);
          //small_overwrite_test("/flash/flash",1000);
          //seek_overwrite_test("/flash/flash",1000);
@@ -3454,7 +3511,7 @@ int main(int argc, char *argv[])
        //long_test_on_path("/ram2k");
        // long_test_on_path("/flash");
        //simple_rw_test("/flash/flash");
-       //fill_disk_test("/flash/flash");
+        fill_n_file_test("/nand128MB", 50, 128000000/50);
        // rename_over_test("/flash");
        //lookup_test("/flash");
        //freespace_test("/flash/flash");