tools/testing/fault-injection套件
来源:互联网 发布:linux c mmap 编辑:程序博客网 时间:2024/05/17 23:48
具体说明参考Documentation/fault-injection/fault-injection.txt文档
我在调试mmc驱动的时候用到了fail_mmc_request,可以控制产生data.error
内核配置是CONFIG_FAIL_MMC_REQUEST
Kernel hacking ---> [*] Fault-injection framework [*] Fault-injection capability for MMC IO [*] Debugfs entries for fault-injection capabilities
这样在/sys/kernel/debug/mmc0目录下面就会出现fail_mmc_request目录,进入这个目录
/sys/kernel/debug/mmc0/fail_mmc_request # lsinterval probability space task-filter times verbose
参数说明:
probability: 发生错误的概率,如果值为100,表示100%会发生
times: 限制发生错误的次数,每发生一次错误后他的值会减一。如果值为-1,表示不限错误次数。
/sys/kernel/debug/mmc0/fail_mmc_request # echo 1 > times /sys/kernel/debug/mmc0/fail_mmc_request # echo 100 > probability /sys/kernel/debug/mmc0/fail_mmc_request # veridisk -f /dev/mmcblk0 -e 1 -m 1 -v -doffset [0, 1), len [1, 2), seq pFAULT_INJECTION: forcing a failure attern 0x00offset 0, len 1, seCPU: 0 PID: 247 Comm: mmcqd/0 Not tainted 3.10.27+ #114 q pattern 0x01Stack : 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 83ee3cb0 ...Call Trace:[<800152a4>] 0x800152a4[<800152a4>] 0x800152a4[<801d036c>] 0x801d036c[<8034766c>] 0x8034766c[<80040000>] 0x80040000[<80348458>] 0x80348458[<803558bc>] 0x803558bc[<801b03cc>] 0x801b03cc[<80356ebc>] 0x80356ebc[<80347b60>] 0x80347b60[<80045f0c>] 0x80045f0c[<803575b4>] 0x803575b4[<80048898>] 0x80048898[<80357fe8>] 0x80357fe8[<80357f00>] 0x80357f00[<80357f00>] 0x80357f00[<8003cd10>] 0x8003cd10[<80045b4c>] 0x80045b4c[<80045c10>] 0x80045c10[<8003cc58>] 0x8003cc58[<800129fc>] 0x800129fcmmcblk0: error -145 transferring data, sector 0, nr 1, cmd response 0x900, card status 0x0w 0.002MB/s, r 1.055MB/spass 1/1, w 0.002MB/s, r 1.055MB/sveridisk_write_loop: -------------------- TEST RESULT --------------------veridisk_write_loop: pass 1/1, w 0.002MB/s, r 1.055MB/sveridisk_write_loop: failed count: open 0, write 0, read 0, compare 0//再次执行由于times已经变为0,所以不会在出现传输出错的情况。/sys/kernel/debug/mmc0/fail_mmc_request # veridisk -f /dev/mmcblk0 -e 1 -m 1 -v -doffset [0, 1), len [1, 2), seq pattern 0x00offset 0, len 1, seq pattern 0x01w 0.030MB/s, r 0.656MB/spass 1/1, w 0.030MB/s, r 0.656MB/sveridisk_write_loop: -------------------- TEST RESULT --------------------veridisk_write_loop: pass 1/1, w 0.030MB/s, r 0.656MB/sveridisk_write_loop: failed count: open 0, write 0, read 0, compare 0/sys/kernel/debug/mmc0/fail_mmc_request #
#ifdef CONFIG_FAIL_MMC_REQUESTstatic void mmc_should_fail_request(struct mmc_host *host, struct mmc_request *mrq){ struct mmc_command *cmd = mrq->cmd; struct mmc_data *data = mrq->data; static const int data_errors[] = { -ETIMEDOUT, -EILSEQ, -EIO, }; if (!data) return; if (cmd->error || data->error || !should_fail(&host->fail_mmc_request, data->blksz * data->blocks)) return; data->error = data_errors[prandom_u32() % ARRAY_SIZE(data_errors)]; data->bytes_xfered = (prandom_u32() % (data->bytes_xfered >> 9)) << 9;}#elsestatic inline void mmc_should_fail_request(struct mmc_host *host, struct mmc_request *mrq){}#endif
当在mmc_request_done函数中调用mmc_should_fail_request,会按照一定的规则赋值data->error,可能出现的错有ETIMEDOUT,EILSEQ,EIO,这样就可以模拟data传输概率出错的情况了。并且在mmc/core/debugfs.c文件中会在/sys/kernel/debug/mmc0目录下创建fail_mmc_request目录。
0 0
- tools/testing/fault-injection套件
- Fault Injection Testing with TestApi
- Fault Injection Technique
- Testing for SQL Injection
- X Auto Testing Tools
- Python Fuzz Testing Tools
- Mobile Automation testing Tools
- Testing Tools List
- Fault injection(错误注入)的概念
- Documentation/fault-injection/notifier-error-inject.txt
- Documentation/fault-injection/provoke-crashes.txt
- linux内核文件翻译-Fault Injection故障注入
- Fault Injection——持续更新
- C/C++ unit testing tools
- Web Application Testing Tools Collection
- leancloud tools for sioeye testing
- Openstack api security testing tools
- 错误注入攻击总结(Fault Injection Attack)
- C语言 第十八天
- STL之hashtable
- HDU 5029Relief grain-树链剖分+线段树+离线
- poj1836(dp) Alignment
- window7下安装mongdb
- tools/testing/fault-injection套件
- DMA函数分析
- 美团 二维数组打印
- linux sed 命令详解
- ACM--Maximum Increase--最长递增数组序列
- 1162. 【普及组模拟赛】最大杂置(set)
- hdu 1811 Rank of Tetris
- 【u201】矩形覆盖
- python基础之列表常用操作及知识点小结