Linux内核开发人员在提交代码后如何在本地测试他们的代码?他们是否使用某种单元测试和构建自动化?测试计划?


当前回答

除了其他答案外,本文更强调Linux内核的功能测试、硬件认证测试和性能测试。

大量的测试实际上是通过脚本、静态代码分析工具、代码审查等进行的,这对于捕获错误非常有效,否则会破坏应用程序中的某些东西。

稀疏-一个开源工具,旨在发现Linux内核中的错误。

Coccinelle是另一个程序进行匹配和转换引擎,它提供了语言SmPL(语义补丁语言),用于在C代码中指定所需的匹配和转换。

checkpatch.pl and other scripts - coding style issues can be found in the file Documentation/CodingStyle in the kernel source tree. The important thing to remember when reading it is not that this style is somehow better than any other style, just that it is consistent. This helps developers easily find and fix coding style issues. The script scripts/checkpatch.pl in the kernel source tree has been developed for it. This script can point out problems easily, and should always be run by a developer on their changes, instead of having a reviewer waste their time by pointing out problems later on.

其他回答

还有:

MMTests是用来分析结果的基准测试和脚本的集合。

它是Linux系统调用模糊测试器。

此外,SourceForge的LTP页面已经相当过时,项目已经转移到GitHub。

除了其他答案外,本文更强调Linux内核的功能测试、硬件认证测试和性能测试。

大量的测试实际上是通过脚本、静态代码分析工具、代码审查等进行的,这对于捕获错误非常有效,否则会破坏应用程序中的某些东西。

稀疏-一个开源工具,旨在发现Linux内核中的错误。

Coccinelle是另一个程序进行匹配和转换引擎,它提供了语言SmPL(语义补丁语言),用于在C代码中指定所需的匹配和转换。

checkpatch.pl and other scripts - coding style issues can be found in the file Documentation/CodingStyle in the kernel source tree. The important thing to remember when reading it is not that this style is somehow better than any other style, just that it is consistent. This helps developers easily find and fix coding style issues. The script scripts/checkpatch.pl in the kernel source tree has been developed for it. This script can point out problems easily, and should always be run by a developer on their changes, instead of having a reviewer waste their time by pointing out problems later on.

Linux内核非常重视社区测试。

通常,任何开发人员都会在提交代码之前测试他们自己的代码,而且他们经常会使用Linus的内核开发版本,或者其他与他们工作相关的项目的不稳定/开发树之一。这意味着他们经常测试自己的更改和其他人的更改。

通常没有太多正式的测试计划,但是在将特性合并到上游树之前可能会要求进行额外的测试。

正如Dean所指出的,还有一些自动化测试:Linux测试项目和内核Autotest(很好的概述)。

开发人员通常还会编写针对测试他们的更改的自动化测试,但我不确定是否有一种(经常使用的)机制来集中收集这些临时测试。

当然,这在很大程度上取决于内核的哪个部分正在被更改——您为一个新的网络驱动程序所做的测试与替换核心调度算法时所做的测试是完全不同的。

我可以想象他们使用虚拟化来进行快速测试。它可以是QEMU、VirtualBox或Xen之类的东西,以及一些执行配置和自动化测试的脚本。

自动化测试可能是通过尝试许多随机配置或少数特定配置(如果他们处理特定问题)来完成的。Linux有很多低级工具(比如dmesg)来监视和记录来自内核的调试数据,所以我认为也会使用它。

LTP和memtest通常是首选工具。