2 * Copyright (c) 2013 Grzegorz Kostka (kostka.grzegorz@gmail.com)
\r
3 * All rights reserved.
\r
5 * Redistribution and use in source and binary forms, with or without
\r
6 * modification, are permitted provided that the following conditions
\r
9 * - Redistributions of source code must retain the above copyright
\r
10 * notice, this list of conditions and the following disclaimer.
\r
11 * - Redistributions in binary form must reproduce the above copyright
\r
12 * notice, this list of conditions and the following disclaimer in the
\r
13 * documentation and/or other materials provided with the distribution.
\r
14 * - The name of the author may not be used to endorse or promote products
\r
15 * derived from this software without specific prior written permission.
\r
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
\r
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
\r
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
\r
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
\r
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
\r
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
\r
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
\r
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
\r
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
\r
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\r
30 #include <hw_init.h>
\r
37 #include <stdbool.h>
\r
42 #include <usb_msc_lwext4.h>
\r
44 #include "../../blockdev/test_lwext4.h"
\r
47 /**@brief Read-write size*/
\r
48 #define READ_WRITE_SZIZE 1024 * 16
\r
50 /**@brief Delay test (slower LCD scroll)*/
\r
51 #define TEST_DELAY_MS 1000
\r
53 /**@brief Input stream name.*/
\r
54 char input_name[128] = "ext2";
\r
56 /**@brief Read-write size*/
\r
57 static int rw_szie = READ_WRITE_SZIZE;
\r
59 /**@brief Read-write size*/
\r
60 static int rw_count = 100;
\r
62 /**@brief Directory test count*/
\r
63 static int dir_cnt = 100;
\r
65 /**@brief Static or dynamic cache mode*/
\r
66 static bool cache_mode = false;
\r
68 /**@brief Cleanup after test.*/
\r
69 static bool cleanup_flag = false;
\r
71 /**@brief Block device stats.*/
\r
72 static bool bstat = false;
\r
74 /**@brief Superblock stats.*/
\r
75 static bool sbstat = false;
\r
77 /**@brief Block device handle.*/
\r
78 static struct ext4_blockdev *bd;
\r
80 /**@brief Block cache handle.*/
\r
81 static struct ext4_bcache *bc;
\r
83 static bool open_filedev(void)
\r
86 bd = ext4_usb_msc_get();
\r
87 bc = ext4_usb_msc_cache_get();
\r
89 printf("open_filedev: fail\n");
\r
100 printf("connect usb drive...\n");
\r
102 while(!hw_usb_connected())
\r
104 printf("usb drive connected\n");
\r
106 while(!hw_usb_enum_done())
\r
108 printf("usb drive enum done\n");
\r
112 printf("test conditions:\n");
\r
113 printf(" rw size: %d\n", rw_szie);
\r
114 printf(" rw count: %d\n", rw_count);
\r
115 printf(" cache mode: %s\n", cache_mode ? "dynamic" : "static");
\r
117 if (!open_filedev())
\r
120 tim_wait_ms(TEST_DELAY_MS);
\r
121 if(!test_lwext4_mount(bd, bc))
\r
122 return EXIT_FAILURE;
\r
124 tim_wait_ms(TEST_DELAY_MS);
\r
126 ext4_cache_write_back("/mp/", 1);
\r
127 test_lwext4_cleanup();
\r
130 tim_wait_ms(TEST_DELAY_MS);
\r
131 test_lwext4_mp_stats();
\r
134 tim_wait_ms(TEST_DELAY_MS);
\r
135 test_lwext4_dir_ls("/mp/");
\r
136 if(!test_lwext4_dir_test(dir_cnt))
\r
137 return EXIT_FAILURE;
\r
139 tim_wait_ms(TEST_DELAY_MS);
\r
140 if(!test_lwext4_file_test(rw_szie, rw_count))
\r
141 return EXIT_FAILURE;
\r
144 tim_wait_ms(TEST_DELAY_MS);
\r
145 test_lwext4_mp_stats();
\r
149 tim_wait_ms(TEST_DELAY_MS);
\r
150 test_lwext4_cleanup();
\r
154 tim_wait_ms(TEST_DELAY_MS);
\r
155 test_lwext4_block_stats();
\r
158 ext4_cache_write_back("/mp/", 0);
\r
159 if(!test_lwext4_umount())
\r
160 return EXIT_FAILURE;
\r
162 printf("press RESET button to restart\n");
\r