Skip to the content.

Linux 测试

收集下 Linux 的各种测试

我记得有一篇 lwn 分析过为什么测试 Linux kernel 很难

有时间应该看看这个

Coccinelle : 没太看懂

收集一个开发环境

https://github.com/kernel-cyrus/lightbox

居然有人专门跟踪 Linux 的 regression ,实在是有趣

lkvs

https://www.openeuler.org/zh/blog/20240306-lkvs/20240306-lkvs.html

lvm2 的测试

https://github.com/lvmteam/lvm2/blob/main/test/shell/integrity-caching.sh

网络的测试

https://lore.kernel.org/all/20230719140858.13224-1-daniel@iogearbox.net/

We tested this series with tc-testing selftest suite as well as BPF CI/selftests. Thanks!

思考

到底什么样子的测试才是好的测试?

单元测试比 gdb 好,但是好不了多少,因为单元测试也是将思维放到细节上了。

unitest 参考

selftest 实际上更加有趣啊

/home/martins3/core/linux/tools/testing/selftests/kvm/x86_64/hwcr_msr_test.c

总体来说

测试只能用来避免低级错误,抽象代码架构可以避免高级错误:

  1. 对于 syscall 测试,内存和调度器,依赖用户态工具
  2. 对于被依赖的内核模块,依靠社区大家都参与进来,因为其输入是其他的内存模块,例如 block layer
  3. 对于内核模块的测试,更多是依赖 selftests ,从用户态来保证其覆盖率,因为其交互来源都是用户态

io uring 的测试在 liburing 中

但是 aio 就没有测试了,我猜测,是因为 aio 比较简单,而且 aio 太简单了

参考下行业经验

https://mp.weixin.qq.com/s/H4NbhK_yEZYRR78waudBGA

特定模块的测试

bcachefs 的测试文件系统的 workflow

测试

https://github.com/kernelslacker/trinity

https://github.com/rapido-linux/rapido

原来图形领域本来就存在一个 ci

如果我自己作为一个 kernel model 的开发者,需要打开那些 CONFIG 来辅助测试

收集一些和测试相关的内容

原来 redhat 自己一直都有专业的测试工程师

https://patchwork.kernel.org/project/linux-nfs/patch/1485067624-3659-1-git-send-email-yin-jianhong@163.com/ https://cn.linkedin.com/in/yinjianhong

nfs 测试

https://git.linux-nfs.org/?p=cdmackay/pynfs.git;

这里查漏补缺一下

< > KUnit - Enable support for unit tests  ----
< > Notifier error injection
[ ] Fault-injections of functions
[*] Fault-injection framework
[ ]   Fault-injection capability for kmalloc (NEW)
[ ]   Fault-injection capability for alloc_pages() (NEW)
[ ]   Fault injection capability for usercopy functions (NEW)
[ ]   Fault-injection capability for disk IO (NEW)
[ ]   Fault-injection capability for faking disk interrupts (NEW)
[ ]   Fault-injection capability for futexes (NEW)
[ ]   Debugfs entries for fault-injection capabilities (NEW)
[ ]   Configfs interface for fault-injection capabilities (NEW)
[ ] Code coverage for fuzzing
[*] Runtime Testing  --->
[ ] Memtest
[ ] Microsoft Hyper-V driver testing

两种测试思路

到底是精确到具体的函数,还是只是需要整个结果相同。

内核是倾向于 emulator 的测试

记录一下 c 语言的基本框架

https://github.com/ThrowTheSwitch/Unity

有趣的统计很分析

https://pebblebed.com/blog/kernel-bugs : 这个东西有趣的

https://people.kernel.org/metan/towards-parallel-kernel-test-runs

内核到底是如何做测试的

https://lwn.net/Kernel/Index/#Development_tools-Testing

使用 um 配合 kunit test ,真的 nb 啊

commit 150ec68fa799 (“hfs: introduce KUnit tests for HFS string operations”)

经典

世界最流行的数据库 SQLite,本身代码15.6万行,但是测试用例9205万行,足足大了590倍! https://sqlite.org/testing.html

原来 kunit 是这样的测试的

python3 tools/testing/kunit/kunit.py run \
    --arch=x86_64 \
    --build_dir=.kunit-drm-sched \
    --kunitconfig=drivers/gpu/drm/scheduler \
    --summary

[10:08:30] Configuring KUnit Kernel ...
Regenerating .config ...
Populating config with:
$ make ARCH=x86_64 O=.kunit-drm-sched olddefconfig
[10:08:40] Building KUnit Kernel ...
Populating config with:
$ make ARCH=x86_64 O=.kunit-drm-sched olddefconfig

本站所有文章转发 CSDN 将按侵权追究法律责任,其它情况随意。