我设计的一款读写压测工具,开源在我的github仓库


rwcheck是一个对嵌入式设备进行读写压测的工具

什么是rwcheck#

正如其名,rwcheck工具用于读写压测。它是什么工作原理呢?为什么要用rwcheck呢?

rwcheck的初衷是为嵌入式Linux设备提供读写冒烟测试的工具,在大压力的IO测试中,确保存储稳定。rwcheck也被用于读写掉电测试,在读写时掉电,并在上电后对掉电前写入的文件进行检查。

他有以下特点:

  • 多种测试模式,覆盖各种尺寸的测试文件
  • 读写随机数据,覆盖到各种数据组合
  • CRC校验数据,错误即刻退出并保留问题现场
  • 支持读写掉电,重启后校验历史数据
  • 动态获取系统信息,按存储空间使用比例限制测试总大小
  • 支持多线程写,模拟真实使用场景

怎么用rwcheck#

下载与编译#

Copy
git clone https://github.com/gmpy/rwcheck.git rwcheck && make -C rwcheck

使用说明#

rwcheck -h可以获取到使用说明

Copy
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

例如:

Copy
rwcheck -d /mnt/UDISK -b 128k -p 90 -j 2 -t 10000000

上面命令的含义:

  • 在 /mnt/UDISK 目录下进行读写
  • UP模式,测试从 128K 文件大小开始,使用默认最大文件大小(16G)
  • 测试总大小为总容量的 90%
  • 以 2个线程 同时写
  • 循环测试 10000000次

1次循环#

-t <次数>可以指定循环测试次数,那么,怎样才是1次循环呢?

每一次循环,包含3个步骤:

  1. 写:按不同模式要求创建多个文件,循环创建直至空间使用率达到设定的百分比
  2. 校验:读取每一个文件,校验文件CRC值 (允许最后一个文件CRC校验值错误)
  3. 删除:删除测试文件