#include <ext4_filedev.h>\r
#include <ext4.h>\r
\r
-\r
-\r
char input_name[128] = "ext2";\r
\r
/**@brief Read-write size*/\r
static int rw_szie = 1024;\r
\r
/**@brief Read-write size*/\r
-static int rw_count = 1024;\r
+static int rw_count = 10000;\r
\r
/**@brief Directory test count*/\r
static int dir_cnt = 10;\r
\r
+/**@brief Static or dynamic cache mode*/\r
static bool cache_mode = false;\r
\r
+/**@brief Cleanup after test.*/\r
+static bool cleanup_flag = false;\r
+\r
+/**@brief Block device stats.*/\r
+static bool bstat = false;\r
+\r
+/**@brief Superblock stats.*/\r
+static bool sbstat = false;\r
\r
/**@brief File write buffer*/\r
static uint8_t *wr_buff;\r
Usage: \n\\r
-i - input file (default = ext2) \n\\r
-rws - single R/W size (default = 1024) \n\\r
- -rwc - R/W count (default = 1024) \n\\r
- -cache - 0 static, 1 dynamic (default = 0) \n\\r
- -dirs - directory test count (default = 0) \n\\r
+ -rwc - R/W count (default = 10000) \n\\r
+ -cache - 0 static, 1 dynamic (default = 0) \n\\r
+ -dirs - directory test count (default = 10) \n\\r
+ -clean - clean up after test \n\\r
+ -bstat - block device stats \n\\r
+ -sbstat - superblock stats \n\\r
\n";\r
\r
static char* entry_to_str(uint8_t type)\r
int i;\r
char path[64];\r
\r
- printf("Remove directory /mp/dir1\n");\r
- ext4_dir_rm("/mp/dir1");\r
-\r
-\r
printf("Directory create: /mp/dir1\n");\r
r = ext4_dir_mk("/mp/dir1");\r
if(r != EOK){\r
}\r
}\r
\r
- printf("Add directories to: /mp/dir1\n");\r
- for (i = 0; i < len; ++i) {\r
- sprintf(path, "/mp/dir1/d%d", i);\r
- r = ext4_dir_mk(path);\r
- if(r != EOK){\r
- printf("Unable to create directory in directory: /mp/dir1\n");\r
- return false;\r
- }\r
- }\r
-\r
- printf("Add file directories in: /mp/dir1\n");\r
-\r
- for (i = 0; i < len; ++i) {\r
- sprintf(path, "/mp/dir1/d%d/ff", i);\r
- r = ext4_fopen(&f, path, "wb");\r
- if(r != EOK){\r
- printf("Unable to create file in directory: /mp/dir1\n");\r
- return false;\r
- }\r
- }\r
-\r
dir_ls("/mp/dir1");\r
return true;\r
}\r
\r
+static void cleanup(void)\r
+{\r
+ ext4_fremove("/mp/hello.txt");\r
+ ext4_fremove("/mp/test1");\r
+ ext4_dir_rm("/mp/dir1");\r
+}\r
+\r
int main(int argc, char **argv)\r
{\r
int option_index = 0;\r
{"rws", required_argument, 0, 'b'},\r
{"rwc", required_argument, 0, 'c'},\r
{"cache", required_argument, 0, 'd'},\r
- {"dirs", required_argument, 0, 'e'},\r
+ {"dirs", required_argument, 0, 'e'},\r
+ {"clean", no_argument, 0, 'f'},\r
+ {"bstat", no_argument, 0, 'g'},\r
+ {"sbstat", no_argument, 0, 'h'},\r
{0, 0, 0, 0}\r
};\r
\r
- while(-1 != (c = getopt_long (argc, argv, "a:b:c:d:e:", long_options, &option_index))) {\r
+ while(-1 != (c = getopt_long (argc, argv, "a:b:c:d:e:fgh", long_options, &option_index))) {\r
\r
switch(c){\r
case 'a':\r
case 'e':\r
dir_cnt = atoi(optarg);\r
break;\r
+ case 'f':\r
+ cleanup_flag = true;\r
+ break;\r
+ case 'g':\r
+ bstat = true;\r
+ break;\r
+ case 'h':\r
+ sbstat = true;\r
+ break;\r
default:\r
printf(usage);\r
return EXIT_FAILURE;\r
return EXIT_FAILURE;\r
}\r
\r
- dir_test(dir_cnt);\r
+ cleanup();\r
+\r
+ if(sbstat)\r
+ mp_stats();\r
\r
- ext4_fremove("/mp/hello.txt");\r
- ext4_fremove("/mp/test1");\r
- mp_stats();\r
- dir_ls("/mp/");\r
+\r
+ dir_ls("/mp/");\r
+ dir_test(dir_cnt);\r
\r
/*Add hello world file.*/\r
r = ext4_fopen(&f, "/mp/hello.txt", "wb");\r
}\r
\r
printf("OK\n");\r
-\r
r = ext4_fclose(&f);\r
\r
-\r
- mp_stats();\r
dir_ls("/mp/");\r
\r
- block_stats();\r
- r = ext4_umount("/mp/");\r
+ if(sbstat)\r
+ mp_stats();\r
+\r
+ if(bstat)\r
+ block_stats();\r
\r
+ if(cleanup_flag)\r
+ cleanup();\r
+\r
+ r = ext4_umount("/mp/");\r
printf("Test finish: OK\n");\r
return EXIT_SUCCESS;\r
\r