Skip to main content
QUICK REVIEW

[论文解读] On the Generation of Test Data for Prolog by Partial Evaluation

Miguel Gómez‐Zamalloa, Elvira Albert|ArXiv.org|Mar 12, 2009
Software Testing and Debugging Techniques参考文献 21被引用 7
一句话总结

本文提出了一种基于部分求值(PE)的新型Prolog程序测试数据生成(TDG)方法,通过显式表示失败来克服逻辑编程中常见失败推导的处理难题。该方法通过两阶段PE实现测试用例及测试用例生成器的生成:首先,将Prolog解释器专业化以捕获失败路径;其次,通过约束求解生成具体测试输入,将基于PE的TDG优势扩展至声明式语言。

ABSTRACT

In recent work, we have proposed an approach to Test Data Generation (TDG) of imperative bytecode by partial evaluation (PE) of CLP which consists in two phases: (1) the bytecode program is first transformed into an equivalent CLP program by means of interpretive compilation by PE, (2) a second PE is performed in order to supervise the generation of test-cases by execution of the CLP decompiled program. The main advantages of TDG by PE include flexibility to handle new coverage criteria, the possibility to obtain test-case generators and its simplicity to be implemented. The approach in principle can be directly applied for TDG of any imperative language. However, when one tries to apply it to a declarative language like Prolog, we have found as a main difficulty the generation of test-cases which cover the more complex control flow of Prolog. Essentially, the problem is that an intrinsic feature of PE is that it only computes non-failing derivations while in TDG for Prolog it is essential to generate test-cases associated to failing computations. Basically, we propose to transform the original Prolog program into an equivalent Prolog program with explicit failure by partially evaluating a Prolog interpreter which captures failing derivations w.r.t. the input program. Another issue that we discuss in the paper is that, while in the case of bytecode the underlying constraint domain only manipulates integers, in Prolog it should properly handle the symbolic data manipulated by the program. The resulting scheme is of interest for bringing the advantages which are inherent in TDG by PE to the field of logic programming.

研究动机与目标

  • 为解决生成覆盖失败推导的Prolog测试用例的挑战,而标准部分求值通常忽略此类情况。
  • 将原有的面向指令式字节码的基于PE的TDG框架扩展至声明式语言(如Prolog)。
  • 实现从Prolog程序自动合成CLP形式的测试用例生成器,以提升可重用性与覆盖率灵活性。
  • 通过集成约束处理规则(CHR)与多域约束求解器,有效处理Prolog中的符号数据与复杂统一,特别是否定统一。
  • 通过在递归谓词(如sorted/1)上的初步实验,评估该方法的可行性与有效性,证明其可覆盖具有有限递归深度的路径。

提出的方法

  • 将原始Prolog程序转换为等价形式,通过部分求值一个追踪失败推导的Prolog解释器,显式表示失败。
  • 采用两阶段部分求值流程:首先,将字节码解释器专业化以将Prolog反编译为CLP;其次,通过PE对CLP程序进行监督,实现测试用例生成。
  • 集成约束处理规则(CHR)以管理由否定统一产生的不等式约束,如\+ L=[] 或 \+ A#>0。
  • 利用多域约束求解器(如布尔与数值)将负向条件表示为正向约束,实现可行性检查。
  • 应用块计数等覆盖标准,指导路径枚举,确保测试用例针对特定程序路径。
  • 在PE框架内应用符号执行原理,累积路径条件,并通过约束求解生成测试输入。

实验结果

研究问题

  • RQ1部分求值能否被适配以生成包含失败推导的Prolog程序测试用例,而这些情况在标准PE中通常被忽略?
  • RQ2在基于PE的TDG框架中,如何有效建模并求解Prolog中的否定统一与符号数据结构?
  • RQ3现有基于PE的TDG方法在字节码上的应用,能在多大程度上推广至声明式语言(如Prolog)?
  • RQ4生成的测试用例生成器能否以CLP程序形式表达,使其既可执行又可重用于回归测试?
  • RQ5块计数等覆盖标准在指导生成多样化、路径覆盖充分的Prolog测试输入方面表现如何?

主要发现

  • 该方法成功为Prolog谓词`sorted/1`生成了覆盖最多三重递归调用的所有路径的测试用例,如块计数(2)标准所示。
  • 共生成了七个不同的测试用例,涵盖成功与失败路径,例如`[[0,1,2,0|_]],[],no/first-try`用于非排序列表。
  • 该方法实现了CLP形式测试用例生成器的自动合成,可重复使用以生成新测试输入,而无需重新运行完整PE流程。
  • CHR与多域约束求解器的集成,使否定统一(如`\+ L=[]` 和 `\+ A#>0`)能被有效处理,通过转换为正向不等式约束实现。
  • 初步实验表明,该方法在递归谓词上具有可行性与可扩展性,但需在更大规模程序上进一步评估。
  • 该框架支持Prolog的高级特性(如cut/0与fail/0),尽管完整集成与现有工具的实证比较仍在进行中。

更好的研究,从现在开始

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

无需绑定信用卡

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