一句话:大规模分析 C 项目测试套件,提出安全并行执行判定与进程/线程并行策略,显著加速测试。
测试套件执行延迟与测试用例的并发程度密切相关,但若测试用例未按并发执行设计,彼此干扰会导致结果偏离顺序执行;为每个测试提供隔离环境虽可避免干扰,却会带来开销并削弱并行测试的价值。作者对 Debian Buster 软件包仓库的大规模分析表明,现有 C 项目测试套件对并行化的利用有限。为此,论文提出一种方法:先分析 C 测试套件能否安全并发执行,即以顺序执行结果为基准判断结果不变性;若安全,则采用进程或线程按不同并行策略执行测试。作者将方法应用于 9 个 C 项目,发现多数项目因测试代码不安全或程序代码中共享变量/文件使用不安全而无法安全并行;并行执行在多数项目上显著快于顺序执行;多线程很少优于多进程;同时缺少统一的 C 测试框架,使 make 成为标准测试驱动,并引入不必要的测试执行性能开销。
The execution latency of a test suite strongly depends on the degree of concurrency with which test cases are executed. However, if test cases are not designed for concurrent execution, they may interfere, causing result deviations compared to sequential execution. To prevent this, each test case can be provided with an isolated execution environment, but the resulting overheads diminish the merit of parallel testing. Our large-scale analysis of the Debian Buster package repository shows that existing test suites in C projects make limited use of parallelization. We present an approach to (a) analyze the potential of C test suites for safe concurrent execution, i.e., result invariance compared to sequential execution, and (b) execute tests concurrently with different parallelization strategies using processes or threads if it is found to be safe. Applying our approach to 9 C projects, we find that most of them cannot safely execute tests in parallel due to unsafe test code or unsafe usage of shared variables or files within the program code. Parallel test execution shows a significant acceleration over sequential execution for most projects. We find that multi-threading rarely outperforms multi-processing. Finally, we observe that the lack of a common test framework for C leaves make as the standard driver for running tests, which introduces unnecessary performance overheads for test execution.