Improve demo debug info
authorgkostka <kostka.grzegorz@gmail.com>
Sat, 8 Nov 2014 14:10:49 +0000 (14:10 +0000)
committergkostka <kostka.grzegorz@gmail.com>
Sat, 8 Nov 2014 14:10:49 +0000 (14:10 +0000)
demos/generic/main.c
demos/stm32f429_disco/main.c

index 7236060af97467aee0d898a13302db1ffb312542..a35fd9ef4efb33e013debbd39739a222e86ad7f6 100644 (file)
@@ -138,21 +138,20 @@ static void dir_ls(const char *path)
     ext4_dir d;\r
     ext4_direntry *de;\r
 \r
-    printf("**********************************************\n");\r
+    printf("ls %s:\n", path);\r
 \r
     ext4_dir_open(&d, path);\r
     de = ext4_dir_entry_get(&d, j++);\r
-    printf("ls %s\n", path);\r
+\r
 \r
     while(de){\r
         memcpy(sss, de->name, de->name_length);\r
         sss[de->name_length] = 0;\r
-        printf("%s", entry_to_str(de->inode_type));\r
+        printf("\t%s", entry_to_str(de->inode_type));\r
         printf("%s", sss);\r
         printf("\n");\r
         de = ext4_dir_entry_get(&d, j++);\r
     }\r
-    printf("**********************************************\n");\r
     ext4_dir_close(&d);\r
 }\r
 \r
@@ -161,19 +160,17 @@ static void mp_stats(void)
     struct ext4_mount_stats stats;\r
     ext4_mount_point_stats("/mp/", &stats);\r
 \r
-    printf("**********************************************\n");\r
-    printf("ext4_mount_point_stats\n");\r
-    printf("inodes_count        = %"PRIu32"\n", stats.inodes_count);\r
-    printf("free_inodes_count   = %"PRIu32"\n", stats.free_inodes_count);\r
-    printf("blocks_count        = %"PRIu32"\n", (uint32_t)stats.blocks_count);\r
-    printf("free_blocks_count   = %"PRIu32"\n", (uint32_t)stats.free_blocks_count);\r
-    printf("block_size          = %"PRIu32"\n", stats.block_size);\r
-    printf("block_group_count   = %"PRIu32"\n", stats.block_group_count);\r
-    printf("blocks_per_group    = %"PRIu32"\n", stats.blocks_per_group);\r
-    printf("inodes_per_group    = %"PRIu32"\n", stats.inodes_per_group);\r
-    printf("volume_name         = %s\n", stats.volume_name);\r
+    printf("ext4_mount_point_stats:\n");\r
+    printf("\tinodes_count        = %"PRIu32"\n", stats.inodes_count);\r
+    printf("\tfree_inodes_count   = %"PRIu32"\n", stats.free_inodes_count);\r
+    printf("\tblocks_count        = %"PRIu32"\n", (uint32_t)stats.blocks_count);\r
+    printf("\tfree_blocks_count   = %"PRIu32"\n", (uint32_t)stats.free_blocks_count);\r
+    printf("\tblock_size          = %"PRIu32"\n", stats.block_size);\r
+    printf("\tblock_group_count   = %"PRIu32"\n", stats.block_group_count);\r
+    printf("\tblocks_per_group    = %"PRIu32"\n", stats.blocks_per_group);\r
+    printf("\tinodes_per_group    = %"PRIu32"\n", stats.inodes_per_group);\r
+    printf("\tvolume_name         = %s\n", stats.volume_name);\r
 \r
-    printf("**********************************************\n");\r
 \r
 }\r
 \r
@@ -181,37 +178,35 @@ static void block_stats(void)
 {\r
     uint32_t i;\r
 \r
-    printf("**********************************************\n");\r
     printf("ext4 blockdev stats\n");\r
-    printf("bdev->bread_ctr          = %"PRIu32"\n", bd->bread_ctr);\r
-    printf("bdev->bwrite_ctr         = %"PRIu32"\n", bd->bwrite_ctr);\r
+    printf("\tbdev->bread_ctr          = %"PRIu32"\n", bd->bread_ctr);\r
+    printf("\tbdev->bwrite_ctr         = %"PRIu32"\n", bd->bwrite_ctr);\r
 \r
 \r
-    printf("bcache->ref_blocks       = %"PRIu32"\n", bc->ref_blocks);\r
-    printf("bcache->max_ref_blocks   = %"PRIu32"\n", bc->max_ref_blocks);\r
-    printf("bcache->lru_ctr          = %"PRIu32"\n", bc->lru_ctr);\r
+    printf("\tbcache->ref_blocks       = %"PRIu32"\n", bc->ref_blocks);\r
+    printf("\tbcache->max_ref_blocks   = %"PRIu32"\n", bc->max_ref_blocks);\r
+    printf("\tbcache->lru_ctr          = %"PRIu32"\n", bc->lru_ctr);\r
 \r
     printf("\n");\r
     for (i = 0; i < bc->cnt; ++i) {\r
-        printf("bcache->refctr[%"PRIu32"]     = %"PRIu32"\n", i, bc->refctr[i]);\r
+        printf("\tbcache->refctr[%"PRIu32"]     = %"PRIu32"\n", i, bc->refctr[i]);\r
     }\r
 \r
     printf("\n");\r
     for (i = 0; i < bc->cnt; ++i) {\r
-        printf("bcache->lru_id[%"PRIu32"]     = %"PRIu32"\n", i, bc->lru_id[i]);\r
+        printf("\tbcache->lru_id[%"PRIu32"]     = %"PRIu32"\n", i, bc->lru_id[i]);\r
     }\r
 \r
     printf("\n");\r
     for (i = 0; i < bc->cnt; ++i) {\r
-        printf("bcache->free_delay[%"PRIu32"] = %d\n", i, bc->free_delay[i]);\r
+        printf("\tbcache->free_delay[%"PRIu32"] = %d\n", i, bc->free_delay[i]);\r
     }\r
 \r
     printf("\n");\r
     for (i = 0; i < bc->cnt; ++i) {\r
-        printf("bcache->lba[%"PRIu32"]        = %"PRIu32"\n", i, (uint32_t)bc->lba[i]);\r
+        printf("\tbcache->lba[%"PRIu32"]        = %"PRIu32"\n", i, (uint32_t)bc->lba[i]);\r
     }\r
 \r
-    printf("**********************************************\n");\r
 }\r
 \r
 static clock_t get_ms(void)\r
@@ -230,23 +225,24 @@ static bool dir_test(int len)
     clock_t diff;\r
     clock_t stop;\r
     clock_t start;\r
-    start = get_ms();\r
 \r
-    printf("Directory create: /mp/dir1\n");\r
+    printf("\ndir_test: %d\n", len);\r
+    printf("directory create: /mp/dir1\n");\r
+    start = get_ms();\r
     r = ext4_dir_mk("/mp/dir1");\r
     if(r != EOK){\r
-        printf("Unable to create directory: /mp/dir1\n");\r
+        printf("\text4_dir_mk: rc = %d\n", r);\r
         return false;\r
     }\r
 \r
 \r
     ext4_cache_write_back("/mp/", 1);\r
-    printf("Add files to: /mp/dir1\n");\r
+    printf("add files to: /mp/dir1\n");\r
     for (i = 0; i < len; ++i) {\r
         sprintf(path, "/mp/dir1/f%d", i);\r
         r = ext4_fopen(&f, path, "wb");\r
         if(r != EOK){\r
-            printf("Unable to create file in directory: /mp/dir1\n");\r
+            printf("\text4_fopen: rc = %d\n", r);\r
             return false;\r
         }\r
     }\r
@@ -255,7 +251,7 @@ static bool dir_test(int len)
     stop =  get_ms();\r
     diff = stop - start;\r
     dir_ls("/mp/dir1");\r
-    printf("dir_test time: %d ms\n", (int)diff);\r
+    printf("dir_test: time: %d ms\n", (int)diff);\r
     return true;\r
 }\r
 \r
@@ -271,22 +267,23 @@ static bool file_test(void)
     clock_t diff;\r
     uint32_t kbps;\r
     uint64_t size_bytes;\r
+\r
+    printf("\nfile_test:\n");\r
     /*Add hello world file.*/\r
     r = ext4_fopen(&f, "/mp/hello.txt", "wb");\r
     r = ext4_fwrite(&f, "Hello World !\n", strlen("Hello World !\n"), 0);\r
     r = ext4_fclose(&f);\r
 \r
 \r
-    printf("ext4_fopen: test1\n");\r
-\r
+    printf("ext4_fopen: write test\n");\r
     start = get_ms();\r
     r = ext4_fopen(&f, "/mp/test1", "wb");\r
     if(r != EOK){\r
-        printf("ext4_fopen ERROR = %d\n", r);\r
+        printf("\text4_fopen rc = %d\n", r);\r
         return false;\r
     }\r
 \r
-    printf("ext4_write: %d * %d ..." , rw_szie, rw_count);\r
+    printf("ext4_write: %d * %d ...\n" , rw_szie, rw_count);\r
     for (i = 0; i < rw_count; ++i) {\r
 \r
         memset(wr_buff, i % 10 + '0', rw_szie);\r
@@ -298,31 +295,28 @@ static bool file_test(void)
     }\r
 \r
     if(i != rw_count){\r
-        printf("ERROR: rw_count = %d\n", i);\r
+        printf("\tfile_test: rw_count = %d\n", i);\r
         return false;\r
     }\r
 \r
-    printf("OK\n");\r
     stop = get_ms();\r
     diff = stop - start;\r
     size_bytes = rw_szie * rw_count;\r
     size_bytes = (size_bytes * 1000) / 1024;\r
     kbps = (size_bytes) / (diff + 1);\r
-    printf("file_test write time: %d ms\n", (int)diff);\r
-    printf("file_test write speed: %"PRIu32" KB/s\n", kbps);\r
+    printf("\twrite time: %d ms\n", (int)diff);\r
+    printf("\twrite speed: %"PRIu32" KB/s\n", kbps);\r
     r = ext4_fclose(&f);\r
-    printf("ext4_fopen: test1\n");\r
-\r
 \r
+    printf("ext4_fopen: read test\n");\r
     start = get_ms();\r
     r = ext4_fopen(&f, "/mp/test1", "r+");\r
     if(r != EOK){\r
-        printf("ext4_fopen ERROR = %d\n", r);\r
+        printf("\text4_fopen rc = %d\n", r);\r
         return false;\r
     }\r
 \r
-    printf("ext4_read: %d * %d ..." , rw_szie, rw_count);\r
-\r
+    printf("ext4_read: %d * %d ...\n" , rw_szie, rw_count);\r
     for (i = 0; i < rw_count; ++i) {\r
         memset(wr_buff, i % 10 + '0', rw_szie);\r
         r = ext4_fread(&f, rd_buff, rw_szie, &size);\r
@@ -335,17 +329,16 @@ static bool file_test(void)
         }\r
     }\r
     if(i != rw_count){\r
-        printf("ERROR: rw_count = %d\n", i);\r
+        printf("\tfile_test: rw_count = %d\n", i);\r
         return false;\r
     }\r
-    printf("OK\n");\r
     stop = get_ms();\r
     diff = stop - start;\r
     size_bytes = rw_szie * rw_count;\r
     size_bytes = (size_bytes * 1000) / 1024;\r
     kbps = (size_bytes) / (diff + 1);\r
-    printf("file_test read time: %d ms\n", (int)diff);\r
-    printf("file_test read speed: %"PRIu32" KB/s\n", kbps);\r
+    printf("\tread time: %d ms\n", (int)diff);\r
+    printf("\tread speed: %"PRIu32" KB/s\n", kbps);\r
     r = ext4_fclose(&f);\r
 \r
     return true;\r
@@ -357,18 +350,13 @@ static void cleanup(void)
     clock_t stop;\r
     clock_t diff;\r
 \r
+    printf("\ncleanup:\n");\r
     ext4_fremove("/mp/hello.txt");\r
-\r
     printf("cleanup: remove /mp/test1\n");\r
-    start = get_ms();\r
     ext4_fremove("/mp/test1");\r
-    stop = get_ms();\r
-    diff = stop - start;\r
-    printf("cleanup: time: %d ms\n", (int)diff);\r
-\r
 \r
     printf("cleanup: remove /mp/dir1\n");\r
-    start =get_ms();\r
+    start = get_ms();\r
     ext4_dir_rm("/mp/dir1");\r
     stop = get_ms();\r
     diff = stop - start;\r
@@ -380,7 +368,7 @@ static bool open_filedev(void)
     ext4_filedev_filename(input_name);\r
     bd = ext4_filedev_get();\r
     if(!bd){\r
-        printf("Block device ERROR\n");\r
+        printf("open_filedev: fail\n");\r
         return false;\r
     }\r
     return true;\r
@@ -392,7 +380,7 @@ static bool open_winpartition(void)
     ext4_io_raw_filename(input_name);\r
     bd = ext4_io_raw_dev_get();\r
     if(!bd){\r
-        printf("Block device ERROR\n");\r
+        printf("open_winpartition: fail\n");\r
         return false;\r
     }\r
     return true;\r
@@ -417,21 +405,21 @@ static bool mount(void)
     rd_buff = malloc(rw_szie);\r
 \r
     if(!wr_buff || !rd_buff){\r
-        printf("Read-Write allocation ERROR\n");\r
+        printf("mount: allocation failed\n");\r
         return false;\r
     }\r
 \r
     ext4_dmask_set(EXT4_DEBUG_ALL);\r
 \r
-    r = ext4_device_register(bd, cache_mode ? 0 : bc, "ext4_filesim");\r
+    r = ext4_device_register(bd, cache_mode ? 0 : bc, "ext4_fs");\r
     if(r != EOK){\r
-        printf("ext4_device_register ERROR = %d\n", r);\r
+        printf("ext4_device_register: rc = %d\n", r);\r
         return false;\r
     }\r
 \r
-    r = ext4_mount("ext4_filesim", "/mp/");\r
+    r = ext4_mount("ext4_fs", "/mp/");\r
     if(r != EOK){\r
-        printf("ext4_mount ERROR = %d\n", r);\r
+        printf("ext4_mount: rc = %d\n", r);\r
         return false;\r
     }\r
 \r
@@ -442,7 +430,7 @@ static bool umount(void)
 {\r
     int r = ext4_umount("/mp/");\r
     if(r != EOK){\r
-        printf("ext4_umount: FAIL %d", r);\r
+        printf("ext4_umount: rc = %d", r);\r
         return false;\r
     }\r
     return true;\r
@@ -511,11 +499,11 @@ int main(int argc, char **argv)
     if(!parse_opt(argc, argv))\r
         return EXIT_FAILURE;\r
 \r
-    printf("Test conditions:\n");\r
-    printf("Imput name: %s\n", input_name);\r
-    printf("RW size: %d\n",  rw_szie);\r
-    printf("RW count: %d\n", rw_count);\r
-    printf("Cache mode: %s\n", cache_mode ? "dynamic" : "static");\r
+    printf("test conditions:\n");\r
+    printf("\timput name: %s\n", input_name);\r
+    printf("\trw size: %d\n",  rw_szie);\r
+    printf("\trw count: %d\n", rw_count);\r
+    printf("\tcache mode: %s\n", cache_mode ? "dynamic" : "static");\r
 \r
     if(!mount())\r
         return EXIT_FAILURE;\r
@@ -549,7 +537,7 @@ int main(int argc, char **argv)
     if(!umount())\r
         return EXIT_FAILURE;\r
 \r
-    printf("Test finish: OK\n");\r
+    printf("\ntest finished\n");\r
     return EXIT_SUCCESS;\r
 \r
 }\r
index c810561164fe25d3e4f56c5a74369adaeefe673d..a6be1e21e90ac85e6627b04152277fc70296e446 100644 (file)
@@ -213,6 +213,7 @@ static bool dir_test(int len)
     clock_t stop;\r
     clock_t start;\r
 \r
+    printf("\ndir_test: %d\n", len);\r
     ext4_io_timings_clear();\r
     start = get_ms();\r
 \r
@@ -236,7 +237,7 @@ static bool dir_test(int len)
     stop =  get_ms();\r
     diff = stop - start;\r
     dir_ls("/mp/dir1");\r
-    printf("  time: %d ms\n", (int)diff);\r
+    printf("dir_test: time: %d ms\n", (int)diff);\r
     printf_io_timings(diff);\r
     return true;\r
 }\r
@@ -254,6 +255,8 @@ static bool file_test(void)
     uint32_t kbps;\r
     uint64_t size_bytes;\r
 \r
+    printf("\nfile_test:\n");\r
+\r
     /*Add hello world file.*/\r
     r = ext4_fopen(&f, "/mp/hello.txt", "wb");\r
     r = ext4_fwrite(&f, "Hello World !\n", strlen("Hello World !\n"), 0);\r
@@ -355,7 +358,7 @@ static void cleanup(void)
     ext4_dir_rm("/mp/dir1");\r
     stop = get_ms();\r
     diff = stop - start;\r
-    printf("  time: %d ms\n", (int)diff);\r
+    printf("cleanup: time: %d ms\n", (int)diff);\r
     printf_io_timings(diff);\r
 }\r
 \r
@@ -473,7 +476,7 @@ int main(void)
     if(!umount())\r
         return EXIT_FAILURE;\r
 \r
-    printf("press RESET button to restart\n");\r
+    printf("\npress RESET button to restart\n");\r
 \r
     while (1) {\r
         hw_wait_ms(500);\r