I designed a pressure reading and writing test tools, open source in my github repository
rwcheck is a pressure measuring tool to read and write to the embedded device
What is rwcheck
As its name implies, rwcheck pressure sensing means for reading and writing. It is what it works? Why rwcheck it?
rwcheck intention is to provide tools to read and write smoke tests for embedded Linux devices, the IO big pressure test, make sure that the storage stability. rwcheck down test is also used to read and write, read and write down, and writes the file to be checked before the power failure after power.
He has the following characteristics:
- A variety of test patterns, covering a variety of sizes of a test file
- Random data read and write, to cover various combinations of data
- CRC checksum data, error and immediately exit the reservations site
- Supports read and write down, after the restart check historical data
- Dynamic access to system information, the storage space used by the limit on the total size of the test
- Supports multi-threaded write, simulate the real usage scenarios
How to use rwcheck
Download and compile
git clone https://github.com/gmpy/rwcheck.git rwcheck && make -C rwcheck
Instructions for use
rwcheck -h can get to use instructions
Usage: rwcheck [-h] [-d dir] [-t times] [-b size] [-e size]
[-s size] [-u size] [-p percent] [-i input] [-j jobs]
-h : show this massage and exit
-d # : the diretory to check [default currect path]
-t # : check times
-b # : [up mode] set begin size
-e # : [up mode] set end size
-s # : [same mode] set file size
-u # : set read/write buf size
-p # : set maximum ratio of total flash size to check. Eg. -p 95
-i # : input path of file [default <check_dir>/rwcheck.org]
if file don't existed, create 64K from /dev/urandom
-j # : multiple jobs
size trailing with k|m|g or not
rwcheck work in 3 mode:
1. -s # : files have the same size, keep testing until no enough space
2. -b # :
2. -e # : file size increase by The multiplier of 2, loop
from beginning to ending size until no enough space
3. none : file size is 50% of the free space, keep testing until
the less space is less than 64K
E.g:
rwcheck -d /mnt/UDISK -b 128k -p 90 -j 2 -t 10000000
Meaning above command:
- At / mnt / UDISK read and write the directory
- UP mode , test from 128K beginning of the file size, using the default maximum file size (16G)
- Test total size of the total capacity of the 90%
- With two threads simultaneously write
- Cycle test 10000000
1 cycle
-t <次数>
You can specify the number of test cycles, then, what is 1 cycle it?
In each cycle, comprising three steps:
- Write: according to different modes required to create multiple files, create a loop until space usage reaches the set percentage
- Checksum: reading each file, the file checksum CRC value (last file allows CRC checksum error)
- Delete: delete the test file
Q:为什么允许最后一个文件CRC校验值错误?
A:因为在随机掉电情况下,最后一个文件写入不完整,会导致校验值不准确,但实际上,这并不是错误
Q:为什么有时候没写任何文件直接跳入到校验环节?
A:当检查到已有文件存在的时候,写环节会跳过,进入到校验环节,以此实现检查上一次执行时创建的文件
Random data
rwcheck data is written from /dev/urandom
random data acquisition, test coverage to ensure that as much data as a combination. But this also has a problem, when there is a data error checking, and no comparative analysis of raw data, how to do it?
rwcheck is doing:
- Before each cycle begins, the
/dev/urandom
reading of a certain size to the random data rwcheck.org - rwcheck.org as a data source, from rwcheck.org cycle time, acquire enough data is written to the test file
- After the first test cycle, remove the old rwcheck.org file so that the next cycle to create a new source of random data
Because once the error rwcheck would immediately withdraw to preserve the site , so you can by contrast rwcheck.org the wrong file, analyze error conditions
Test log
root# rwcheck -d /mnt/UDISK -t 2 -b 128k -p 85 -j2
rwcheck: do read and write check
version: v0.1.0
build: Compiled in Aug 20 2019 at 02:32:41
date: Mon Aug 19 18:01:21 2019
free/total ddr: 33/53 MB
free/total flash: 62/63 MB
flash filesystem ubifs
set mode to Up Mode
set file begin size to 128 KB
set file end size to 1 GB
set times to 2
set max percent of total space to 85%
set buf size to 512 KB
set check diretory as /mnt/UDISK
set orgin file as /mnt/UDISK/rwcheck.org
set jobs as 2
--- CREATE ---
create : /mnt/UDISK/rwcheck.tmp.0_1 ... OK (64K)
create : /mnt/UDISK/rwcheck.tmp.0_0 ... OK (64K)
create : /mnt/UDISK/rwcheck.tmp.1_1 ... OK (128K)
create : /mnt/UDISK/rwcheck.tmp.1_0 ... OK (128K)
......
create : /mnt/UDISK/rwcheck.tmp.7_0 ... OK (64K)
create : /mnt/UDISK/rwcheck.tmp.7_1 ... OK (64K)
--- CHECK ---
check : /mnt/UDISK/rwcheck.tmp.0_0 ... OK
check : /mnt/UDISK/rwcheck.tmp.0_1 ... OK
......
check : /mnt/UDISK/rwcheck.tmp.7_0 ... OK
check : /mnt/UDISK/rwcheck.tmp.7_1 ... OK
--- REMOVE ---
remove : /mnt/UDISK/rwcheck.tmp.0_0 ... OK
remove : /mnt/UDISK/rwcheck.tmp.0_1 ... OK
......
remove : /mnt/UDISK/rwcheck.tmp.7_0 ... OK
remove : /mnt/UDISK/rwcheck.tmp.7_1 ... OK
Once an error occurs, it will print an error message similar to the
--- CREATE ---
--- CHECK ---
check : /mnt/UDISK/rwcheck.tmp.0_0 ... OK
check : /mnt/UDISK/rwcheck.tmp.0_1 ... OK
check : /mnt/UDISK/rwcheck.tmp.1_0 ... OK
check : /mnt/UDISK/rwcheck.tmp.1_1 ... OK
check : /mnt/UDISK/rwcheck.tmp.2_0 ... FAILED (crc error)
--- ERROR INFO ---
file: rwcheck.c (573)
errno: I/O error (5)
info: /mnt/UDISK/rwcheck.tmp.2_0 crc error
Test Mode
rwcheck supports three test modes are AUTO mode , UP mode , SAME mode
Under different test mode, the file size is not the same test , the test file size strategy visible function get_test_size () .
mode | Options | Feature |
---|---|---|
AUTO | (default) | Each test takes the remaining half of the current space to do the test file size |
UP | -b/-e | Set to begin from the start end end of the set, the file size is incremented in multiples of 2 |
SAME | -s | Fixed file size of each test |
AUTO mode
The default for the auto mode , in this mode, each test file size of the remaining space in the partition 50% (4G not exceed the maximum), until the test file size is less than 64K , or the remaining space reaches a set percentage .
Therefore, ** auto ** mode can also be said to be half the subtraction mode
For example, the current remaining space is 64M, test percentage to 95%, a file is created in the order:
32M -> 16M -> 8M -> 4M -> 1M
In the last test, because not enough free space, skip 2M, 1M size of the file directly to the test
UP mode
And auto mode contrary, up mode is incremented in multiples of 2, the option -b <开始大小>
and -e <结束大小>
setting the range increment, until the remaining space reaches a set percentage .
If you reach the end of the size of the set, but there are plenty of free space, start from setting the size of the re-circulated.
For example, the current remaining space is 64M, test percentage to 95%, beginning size to 128K, then create the file size:
128K -> 256K -> 512K -> 1M -> 2M -> 4M -> 8M -> 16M -> 128K -> 256K -> ...
SAME mode
same pattern is a fixed test file size, the option -s <文件大小>
to set the test file size, file creation cycle until the remaining space reaches a set percentage or does not have sufficient space to continue creating
For example, the current remaining space 64M, test percentage to 95%, to set a fixed size of 5M, the size of a file is created:
5M -> 5M -> 5M -> 5M -> 5M -> 5M -> 5M -> 5M -> 5M -> 5M -> 5M -> 5M