Improve generic & stm32f4 demos
authorgkostka <kostka.grzegorz@gmail.com>
Sun, 18 Oct 2015 20:26:56 +0000 (22:26 +0200)
committergkostka <kostka.grzegorz@gmail.com>
Sun, 18 Oct 2015 20:29:56 +0000 (22:29 +0200)
1. test_lwext4_file_test parameter list change
2. Update generic demo help & readme (short & long parameters)
3. Update readme.mediawiki

blockdev/test_lwext4.c
blockdev/test_lwext4.h
demos/generic/generic.c
demos/stm32f429_disco/main.c
readme.mediawiki

index c1b04efc4ae9a05a7a2a3c5fc3294449548c824f..f6e76d3a021eae36b012f314e042de78d5d377cb 100644 (file)
 
 #include "test_lwext4.h"
 
-/**@brief   Read-write size*/
-#define READ_MAX_WRITE_SZIZE 1024 * 16
-
-/**@brief   File read/write buffer*/
-static uint8_t rw_buff[READ_MAX_WRITE_SZIZE];
-
 /**@brief   Block device handle.*/
 static struct ext4_blockdev *bd;
 
@@ -219,7 +213,7 @@ static int verify_buf(const unsigned char *b, size_t len, unsigned char c)
        return 0;
 }
 
-bool test_lwext4_file_test(uint32_t rw_size, uint32_t rw_count)
+bool test_lwext4_file_test(uint8_t *rw_buff, uint32_t rw_size, uint32_t rw_count)
 {
        int r;
        size_t size;
@@ -232,9 +226,6 @@ bool test_lwext4_file_test(uint32_t rw_size, uint32_t rw_count)
 
        ext4_file f;
 
-       if (rw_size > READ_MAX_WRITE_SZIZE)
-               return false;
-
        printf("file_test:\n");
        printf("  rw size: %" PRIu32 "\n", rw_size);
        printf("  rw count: %" PRIu32 "\n", rw_count);
index 0ed04ac7a4090c2c70e151479e114fb9b7a52e35..eca904ce09e687e391338600446ab0600c2d06cf 100644 (file)
@@ -36,7 +36,7 @@ void test_lwext4_dir_ls(const char *path);
 void test_lwext4_mp_stats(void);
 void test_lwext4_block_stats(void);
 bool test_lwext4_dir_test(int len);
-bool test_lwext4_file_test(uint32_t rw_szie, uint32_t rw_count);
+bool test_lwext4_file_test(uint8_t *rw_buff, uint32_t rw_size, uint32_t rw_count);
 void test_lwext4_cleanup(void);
 
 bool test_lwext4_mount(struct ext4_blockdev *bdev, struct ext4_bcache *bcache);
index 71d6b6032c7bbea8ea53f6af208e2d120dc12039..bf7de198d123d8924130d5467403a86ef9f6de0f 100644 (file)
@@ -73,12 +73,6 @@ static bool sbstat = false;
 /**@brief   Indicates that input is windows partition.*/
 static bool winpart = false;
 
-/**@brief   File write buffer*/
-static uint8_t *wr_buff;
-
-/**@brief   File read buffer.*/
-static uint8_t *rd_buff;
-
 /**@brief   Block device handle.*/
 static struct ext4_blockdev *bd;
 
@@ -92,15 +86,15 @@ static const char *usage = "                                    \n\
 Welcome in ext4 generic demo.                                   \n\
 Copyright (c) 2013 Grzegorz Kostka (kostka.grzegorz@gmail.com)  \n\
 Usage:                                                          \n\
-    --i   - input file              (default = ext2)            \n\
-    --rws - single R/W size         (default = 1024 * 1024)     \n\
-    --rwc - R/W count               (default = 10)              \n\
-    --cache  - 0 static, 1 dynamic  (default = 1)               \n\
-    --dirs   - directory test count (default = 0)               \n\
-    --clean  - clean up after test                              \n\
-    --bstat  - block device stats                               \n\
-    --sbstat - superblock stats                                 \n\
-    --wpart  - windows partition mode                           \n\
+[-i] --input    - input file         (default = ext2)           \n\
+[-w] --rw_size  - single R/W size    (default = 1024 * 1024)    \n\
+[-c] --rw_count - R/W count          (default = 10)             \n\
+[-a] --cache  - 0 static, 1 dynamic  (default = 1)              \n\
+[-d] --dirs   - directory test count (default = 0)              \n\
+[-l] --clean  - clean up after test                             \n\
+[-b] --bstat  - block device stats                              \n\
+[-t] --sbstat - superblock stats                                \n\
+[-w] --wpart  - windows partition mode                          \n\
 \n";
 
 void io_timings_clear(void)
@@ -161,46 +155,46 @@ static bool parse_opt(int argc, char **argv)
        int c;
 
        static struct option long_options[] = {
-           {"in", required_argument, 0, 'a'},
-           {"rws", required_argument, 0, 'b'},
-           {"rwc", required_argument, 0, 'c'},
-           {"cache", required_argument, 0, 'd'},
-           {"dirs", required_argument, 0, 'e'},
-           {"clean", no_argument, 0, 'f'},
-           {"bstat", no_argument, 0, 'g'},
-           {"sbstat", no_argument, 0, 'h'},
-           {"wpart", no_argument, 0, 'i'},
+           {"input", required_argument, 0, 'i'},
+           {"rw_size", required_argument, 0, 's'},
+           {"rw_count", required_argument, 0, 'c'},
+           {"cache", required_argument, 0, 'a'},
+           {"dirs", required_argument, 0, 'd'},
+           {"clean", no_argument, 0, 'l'},
+           {"bstat", no_argument, 0, 'b'},
+           {"sbstat", no_argument, 0, 't'},
+           {"wpart", no_argument, 0, 'w'},
            {0, 0, 0, 0}};
 
-       while (-1 != (c = getopt_long(argc, argv, "a:b:c:d:e:fghi",
+       while (-1 != (c = getopt_long(argc, argv, "i:s:c:q:d:lbtw",
                                      long_options, &option_index))) {
 
                switch (c) {
-               case 'a':
+               case 'i':
                        strcpy(input_name, optarg);
                        break;
-               case 'b':
+               case 's':
                        rw_szie = atoi(optarg);
                        break;
                case 'c':
                        rw_count = atoi(optarg);
                        break;
-               case 'd':
+               case 'a':
                        cache_mode = atoi(optarg);
                        break;
-               case 'e':
+               case 'd':
                        dir_cnt = atoi(optarg);
                        break;
-               case 'f':
+               case 'l':
                        cleanup_flag = true;
                        break;
-               case 'g':
+               case 'b':
                        bstat = true;
                        break;
-               case 'h':
+               case 't':
                        sbstat = true;
                        break;
-               case 'i':
+               case 'w':
                        winpart = true;
                        break;
                default:
@@ -245,7 +239,10 @@ int main(int argc, char **argv)
                return EXIT_FAILURE;
 
        fflush(stdout);
-       if (!test_lwext4_file_test(rw_count, rw_szie))
+       uint8_t *rw_buff = malloc(rw_szie);
+       if (!rw_buff)
+               return EXIT_FAILURE;
+       if (!test_lwext4_file_test(rw_buff, rw_szie, rw_count))
                return EXIT_FAILURE;
 
        fflush(stdout);
index d553ea1f11b9d2abb40c54d424394697f5e71631..f304af7f0ef4374532ee3e4051595e58a2621ab7 100644 (file)
@@ -55,6 +55,9 @@ char input_name[128] = "ext2";
 /**@brief   Read-write size*/
 static int rw_szie = READ_WRITE_SZIZE;
 
+/**@brief   Read-write buffer*/
+static uint8_t rw_buff[READ_WRITE_SZIZE];
+
 /**@brief   Read-write size*/
 static int rw_count = 100;
 
@@ -136,7 +139,7 @@ int main(void)
                return EXIT_FAILURE;
 
        tim_wait_ms(TEST_DELAY_MS);
-       if (!test_lwext4_file_test(rw_szie, rw_count))
+       if (!test_lwext4_file_test(rw_buff, rw_szie, rw_count))
                return EXIT_FAILURE;
 
        if (sbstat) {
index fcdae5c2224d039b1f6e75ab8827df0b1e70c836..b97c3d46f7977a87fb5148df5977919c32ad55b1 100644 (file)
@@ -141,18 +141,7 @@ Windows volumes:
 
 Linux block devices:
  cd build_generic
- generic --in /dev/your_block_device
-
-Usage:                                                          
- --i   - input file              (default = ext2)            
- --rws - single R/W size         (default = 1024 * 1024)     
- --rwc - R/W count               (default = 10)                     
- --cache  - 0 static, 1 dynamic  (default = 1)               
- --dirs   - directory test count (default = 0)               
- --clean  - clean up after test                              
- --bstat  - block device stats                               
- --sbstat - superblock stats                                 
- --wpart  - windows partition mode                           
+ generic -i /dev/your_block_device
 
 ==Build and run automatic tests==
 Build and run automatic tests