循环展开:形式化定义及其在测试中的应用
Loop unrolling: formal definition and application to testing
AI总结:
针对循环导致测试覆盖率受限的问题,本文给出循环展开的形式化定义与性质并完成机械化验证,将该策略应用于自动化测试框架,评估了其提升缺陷检测能力的效果,为其成为测试标准环节提供了初步依据。
摘要:
测试流程通常以高覆盖率为目标,但循环会严重限制覆盖率的提升空间,因为循环迭代次数通常无法预测。大多数测试团队采用极端方案来解决这个问题,即仅满足于分支覆盖率——该指标只考虑循环体执行一次或完全不执行的循环执行情况。这种方法会遗漏所有需要两次及以上迭代才会触发的缺陷。为实现更具实际意义的覆盖率,测试策略可以采用循环展开的方式,即让循环最多执行n次(n为大于1的整数,根据可用计算能力务实选取)。尽管循环展开是编译器优化技术的标准组成部分,但它在测试领域的应用远未普及。部分原因在于,这一概念虽然看似直观,却缺乏普遍认可的精确定义。本文给出了循环展开的形式化定义及一组形式化性质,所有性质均通过Isabelle证明助手完成了机械化正确性验证。我们以此定义为概念基础,将循环展开策略应用于一个现有的自动化测试框架,并报告相关结果:当循环展开次数超过一次时,能多检测出多少缺陷?这些结果首次评估了循环展开是否应成为测试用例生成和测试覆盖率度量的标准组成部分。
英文摘要:
Testing processes usually aim at high coverage, but loops severely limit coverage ambitions since the number of iterations is generally not predictable. Most testing teams address this issue by adopting the extreme solution of limiting themselves to branch coverage, which only considers loop executions that iterate the body either once or not at all. This approach misses any bug that only arises after two or more iterations. To achieve more meaningful coverage, testing strategies may unroll loops, in the sense of using executions that iterate loops up to n times for some n greater than one, chosen pragmatically in consideration of the available computational power. While loop unrolling is a standard part of compiler optimization techniques, its use in testing is far less common. Part of the reason is that the concept, while seemingly intuitive, lacks a generally accepted and precise specification. The present article provides a formal definition and a set of formal properties of unrolling. All the properties have mechanically been proved correct (through the Isabelle proof assistant). Using this definition as the conceptual basis, we have applied an unrolling strategy to an existing automated testing framework and report the results: how many more bugs get detected once we unroll loops more than once? These results provide a first assessment of whether unrolling should become a standard part of test generation and test coverage measurement.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。