X-Git-Url: https://yaffs.net/gitweb/?a=blobdiff_plain;f=direct%2Ftest-framework%2Fbasic-tests%2Fdtest.c;h=dbd194fba236872b47ce1b5571f87521f71d37e6;hb=9545c19fb2de4e3578eb63329f99754dd5041b55;hp=1a98bcb18d17ced144f73d389893af8bb05e0f7d;hpb=1d642a6bacba667d53d3bba29d77c7bd7c956681;p=yaffs2.git diff --git a/direct/test-framework/basic-tests/dtest.c b/direct/test-framework/basic-tests/dtest.c index 1a98bcb..dbd194f 100644 --- a/direct/test-framework/basic-tests/dtest.c +++ b/direct/test-framework/basic-tests/dtest.c @@ -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; @@ -2631,6 +2662,64 @@ void basic_utime_test(const char *mountpt) struct yaffs_utimbuf utb; struct yaffs_stat st; + //setup + yaffs_start_up(); + + yaffs_mount(mountpt); + + strcpy(name,mountpt); + strcat(name,"/"); + strcat(name,"xfile"); + + yaffs_unlink(name); + + printf("created\n"); + h = yaffs_open(name,O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE); + + yaffs_fstat(h,&st); + printf(" times before %llu %llu %llu\n", + ( u64) st.yst_atime, ( u64) st.yst_ctime, ( u64) st.yst_mtime); + + //here are the last access and modification times. + utb.actime = 1000; + utb.modtime = 2000; + + //futime sets the last modification and access time of the file + result = yaffs_futime(h,&utb); + printf("setting times using the futime function to a 1000 m 2000 result %d\n",result); + + //read the times from the file header + yaffs_fstat(h,&st); + printf(" times %llu %llu %llu\n", + ( u64) st.yst_atime, ( u64) st.yst_ctime, ( u64) st.yst_mtime); + + + utb.actime = 5000; + utb.modtime = 8000; + result = yaffs_utime(name, &utb); + printf("utime to a 5000 m 8000 result %d\n",result); + yaffs_fstat(h,&st); + printf(" times %llu %llu %llu\n", + ( u64) st.yst_atime, ( u64) st.yst_ctime, ( u64) st.yst_mtime); + + result = yaffs_utime(name, NULL); + printf("utime to NULL result %d\n",result); + yaffs_fstat(h,&st); + printf(" times %llu %llu %llu\n", + ( u64) st.yst_atime, ( u64) st.yst_ctime, ( u64) st.yst_mtime); + + +} + +void size_utime_test(const char *mountpt) +{ + char name[100]; + int h; + int result; + struct yaffs_utimbuf utb; + struct yaffs_stat st; + + //setup yaffs_start_up(); yaffs_mount(mountpt); @@ -2645,16 +2734,30 @@ void basic_utime_test(const char *mountpt) h = yaffs_open(name,O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE); yaffs_fstat(h,&st); - printf(" times %lu %lu %lu\n", - st.yst_atime, st.yst_ctime, st.yst_mtime); + printf(" times before %llu %llu %llu\n", + ( u64) st.yst_atime, ( u64) st.yst_ctime, ( u64) st.yst_mtime); + + //first lets get the yaffs_object. + + //then check that yaffs_stat also works. + //yaffs_stat already uses 64 bits for both wince and unix times. + //To see if we are using 32 or 64 bit time, save a large number into the time and + //see if it overflows. + + printf("the times are %ld bits long\n", 8*sizeof(st.yst_ctime)); + //here are the last access and modification times. utb.actime = 1000; utb.modtime = 2000; + + //futime sets the last modification and access time of the file result = yaffs_futime(h,&utb); - printf("futime to a 1000 m 2000 result %d\n",result); + printf("setting times using the futime function to a 1000 m 2000 result %d\n",result); + + //read the times from the file header yaffs_fstat(h,&st); - printf(" times %lu %lu %lu\n", - st.yst_atime, st.yst_ctime, st.yst_mtime); + printf(" times %llu %llu %llu\n", + ( u64) st.yst_atime, ( u64) st.yst_ctime, ( u64) st.yst_mtime); utb.actime = 5000; @@ -2662,18 +2765,19 @@ void basic_utime_test(const char *mountpt) result = yaffs_utime(name, &utb); printf("utime to a 5000 m 8000 result %d\n",result); yaffs_fstat(h,&st); - printf(" times %lu %lu %lu\n", - st.yst_atime, st.yst_ctime, st.yst_mtime); + printf(" times %llu %llu %llu\n", + ( u64) st.yst_atime, ( u64) st.yst_ctime, ( u64) st.yst_mtime); result = yaffs_utime(name, NULL); printf("utime to NULL result %d\n",result); yaffs_fstat(h,&st); - printf(" times %lu %lu %lu\n", - st.yst_atime, st.yst_ctime, st.yst_mtime); + printf(" times %llu %llu %llu\n", + ( u64) st.yst_atime, ( u64) st.yst_ctime, ( u64) st.yst_mtime); } + void basic_xattr_test(const char *mountpt) { char name[100]; @@ -3406,11 +3510,36 @@ void rmdir_test2(void) try_rmdir("/nand/z/"); } + +void dump_yaffs_malloc_usage(void) +{ + unsigned current; + unsigned high_water; + + yaffsfs_get_malloc_values(¤t, &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 +3566,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 +3584,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"); @@ -3486,7 +3616,8 @@ int main(int argc, char *argv[]) //large_file_test("/nand"); //readdir_test("/nand"); - //basic_utime_test("/nand"); + basic_utime_test("/nand"); + size_utime_test("/nand"); //case_insensitive_test("/nand"); //yy_test("/nand");