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.

其他回答

LTP和memtest通常是首选工具。

据我所知,英特尔有一个自动性能回归检查工具(名为lkp/0 day)运行/资助。它将测试发送到邮件列表的每个有效补丁,并检查从不同的微基准测试(如hackbench, fio, unixbench, netperf等)更改的分数。

一旦出现性能下降/改进,相应的报告将直接发送给补丁作者和Cc相关的维护者。

自动化内核测试并不容易。大多数Linux开发人员自己进行测试,就像adobriyan提到的那样。

然而,有一些事情可以帮助调试Linux内核:

kexec: A system call that allows you to put another kernel into memory and reboot without going back to the BIOS, and if it fails, reboot back. dmesg: Definitely the place to look for information about what happened during the kernel boot and whether it works/doesn't work. Kernel Instrumentation: In addition to printk's (and an option called 'CONFIG_PRINTK_TIME' which allows you to see (to microsecond accuracy) when the kernel output what), the kernel configuration allows you to turn on a lot of tracers that enable them to debug what is happening.

然后,开发人员通常会让其他人检查他们的补丁。一旦补丁在本地被检查,并且没有干扰其他任何东西,并且补丁被测试与来自Linus的最新内核一起工作而没有破坏任何东西,补丁就会被推送到上游。

这里有一个很好的视频,详细介绍了一个补丁在集成到内核之前所经历的过程。

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

从传统意义上来说,没有。

例如,Ingo Molnar正在运行以下工作负载:

用一组随机配置选项构建一个新内核 引导进入 转到第1节

每个构建失败、启动失败、错误或运行时警告都将得到处理。24/7。乘以几个方框,就可以发现很多问题。

测试计划?

No.

可能存在误解,认为有一个中央测试设施,但实际上没有。每个人都做他/她想做的事。

还有:

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

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

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