Skip to main content
QUICK REVIEW

[论文解读] Mathematical Execution: A Unified Approach for Testing Numerical Code

Zhoulai Fu, Zhendong Su|arXiv (Cornell University)|Oct 4, 2016
Software Testing and Debugging Techniques参考文献 46被引用 4
一句话总结

本文提出数学执行(Mathematical Execution, ME),通过将自动化测试建模为数学优化问题,实现对数值代码的统一测试方法。该方法使用表示函数编码测试目标,并利用数学优化技术最小化该函数,从而实现高效、语义无关的输入空间探索。在Sun公司C数学库上的评估表明,基于ME的工具CoverMe实现了接近最优的分支覆盖率(91%),显著优于随机测试和Austin工具,平均耗时仅6.9秒,远低于Austin的6058.4秒。

ABSTRACT

This paper presents Mathematical Execution (ME), a new, unified approach for testing numerical code. The key idea is to (1) capture the desired testing objective via a representing function and (2) transform the automated testing problem to the minimization problem of the representing function. The minimization problem is to be solved via mathematical optimization. The main feature of ME is that it directs input space exploration by only executing the representing function, thus avoiding static or symbolic reasoning about the program semantics, which is particularly challenging for numerical code. To illustrate this feature, we develop an ME-based algorithm for coverage-based testing of numerical code. We also show the potential of applying and adapting ME to other related problems, including path reachability testing, boundary value analysis, and satisfiability checking. To demonstrate ME's practical benefits, we have implemented CoverMe, a proof-of-concept realization for branch coverage based testing, and evaluated it on Sun's C math library (used in, for example, Android, Matlab, Java and JavaScript). We have compared CoverMe with random testing and Austin, a publicly available branch coverage based testing tool that supports numerical code (Austin combines symbolic execution and search-based heuristics). Our experimental results show that CoverMe achieves near-optimal and substantially higher coverage ratios than random testing on all tested programs, across all evaluated coverage metrics. Compared with Austin, CoverMe improves branch coverage from 43% to 91%, with significantly less time (6.9 vs. 6058.4 seconds on average).

研究动机与目标

  • 为解决数值代码测试的挑战,这些挑战源于符号执行的路径爆炸和数值约束,以及随机测试的覆盖率低下问题。
  • 开发一种统一的、语义无关的自动化测试方法,避免对程序逻辑进行复杂静态或符号分析。
  • 证明通过数学优化表示函数,可系统且高效地探索数值代码的输入空间。
  • 在基于覆盖率的测试、路径可达性分析、边界值分析及可满足性检查等方面评估该方法在数值程序中的有效性。
  • 构建并验证一个实用工具(CoverMe),用于在真实世界的数值库上使用ME实现分支覆盖率测试。

提出的方法

  • 定义一个表示函数 FOO_R,用于量化输入 x 与目标程序 FOO 的错误执行之间的接近程度,其中 FOO_R(x) = 0 当且仅当 FOO(x) ↓ 错误。
  • 将测试问题转化为最小化 FOO_R 的问题,利用成熟的数学优化技术,无需分析 FOO 的语义。
  • 使用现成的优化求解器(如模拟退火、马尔可夫链蒙特卡洛)来探索输入空间,仅依赖于对 FOO_R 的评估结果。
  • 设计 FOO_R 以通过类似距离的度量方式编码测试目标,如分支覆盖率、路径可达性或边界值分析。
  • 实现 CoverMe 作为概念验证工具,利用 ME 在浮点数代码中实现高分支覆盖率。
  • 通过理论证明确保:在存在错误输入的前提下,FOO(x) ↓ 错误 当且仅当 x 最小化 FOO_R。

实验结果

研究问题

  • RQ1能否构建一种统一的数值代码测试方法,避免对程序语义进行符号或静态分析?
  • RQ2对表示函数进行数学优化,能否有效引导数值代码的输入空间探索?
  • RQ3ME 与随机测试及混合符号/搜索类工具(如 Austin)相比,在覆盖率和效率方面表现如何?
  • RQ4ME 是否可适配多种测试目标,包括分支覆盖率、路径可达性及可满足性检查?
  • RQ5表示函数的形式化表达是否足够强大,能够编码多样的数值测试目标,并提供坚实的理论保障?

主要发现

  • CoverMe 在 Sun 公司 C 数学库的所有测试程序中均实现了接近最优的分支覆盖率,且在所有指标上均优于随机测试。
  • CoverMe 将平均分支覆盖率从 Austin 的 43% 提升至 91%,展现出显著且一致的改进。
  • CoverMe 将平均测试时间从 Austin 的 6058.4 秒降低至 6.9 秒,效率提升达 99.9%。
  • 该方法在多种数值代码中均表现有效,包括浮点数运算、非线性关系以及外部数学函数(如三角函数、对数函数)。
  • 表示函数的形式化方法提供了坚实的理论基础,即 FOO(x) ↓ 错误 当且仅当 x 最小化 FOO_R。
  • ME 仅依赖函数评估,无需静态分析,因而具备良好的可扩展性与对各类测试问题的适应能力。

更好的研究,从现在开始

从阅读论文到最终审阅,大幅缩短您的研究时间。

无需绑定信用卡

本解读由 AI 生成,并经人工编辑审核。