Toward the unification of kselftests and KUnit
The kernel project, for many years, lacked a formal testing setup; it was often joked that testing was the project's main reason for keeping users around.
长期以来,内核项目一直缺乏正式的测试体系;人们常开玩笑说,保持用户留存的主要原因就是测试本身。
While many types of kernel testing can only be done in the presence of specific hardware, there are other parts of the kernel that could be more widely tested.
虽然许多类型的内核测试只能在特定硬件环境下进行,但内核的其他部分是可以更广泛进行测试的。
Over time, though, the kernel has gained two separate testing frameworks and a growing body of automated tests to go with them. These two frameworks — kselftests and KUnit — take different approaches to the testing problem; now this patch series from Thomas Weißschuh aims to bring them together.
不过,随着时间推移,内核逐渐引入了两个独立的测试框架,并配套建立了日益丰富的自动化测试体系。这两个框架是 kselftests 和 KUnit,它们对测试问题采取了不同的方法;而现在 Thomas Weißschuh 的这一系列补丁则旨在将它们融合在一起。
Kselftests and KUnit
Kselftests 与 KUnit
Kselftests was first added by Frederic Weisbecker in 2012, with the first test being focused on the handling of breakpoints on the x86 architecture. These self tests run in user space, exercising the normal kernel system-call interface. Over the years, kselftests has grown a test-harness structure based around the Test Anything Protocol (TAP) and a set of functions, macros, and makefile support for the creation of tests.
kselftests 由 Frederic Weisbecker 于 2012 年首次引入,第一个测试聚焦于 x86 架构下断点的处理。这些自测运行在用户态,调用普通的内核系统调用接口。多年发展以来,kselftests 已建立起基于 Test Anything Protocol(TAP)的测试框架,并配套了一整套函数、宏和 makefile 支持,以便编写测试用例。
In current kernels, the kselftests directory has over 100 subdirectories, each containing tests for a specific subsystem. There are tests focused on system calls, architecture support, sysctl knobs, kernel behavior (such as the sealing of system mappings), /proc files, and a handful of device drivers, among other things.