测试用例执行框架是代码测试系统(Code Testing System CTS)的重要组成部分,用于执行测试用例,捕获插装结果。在CTS系统从Windows平台向Linux平台移植的过程中,测试用例执行框架遇到了线程调用和控制不兼容,异常捕获失败以及代码编译不通过等问题。本文通过使用Linux平台上常用的Pthread线程库,解决线程调用问题,通过设计并实现异常栈解决C语言异常捕获失败的问题,通过解析被测单元所在C语言工程的makefile文件,提取出编译需要的头文件及链接共享库或静态链接库需要的链接选项,解决测试用例执行框架编译失败的问题。通过解决上述问题,CTS的测试用例执行框架能够在Linux平台上正常运行。
Path-oriented test case generation is in essence a constraint satisfaction problem (CSP) solved by search strategies, among which backtracking algorithms are widely used. In this article, the backtracking algorithm branch and bound (BB) is introduced to generate path-oriented test cases automatically. A model based on state space search is proposed to construct the search tree dynamically. The BB is optimized from two perspectives. Variable permutation with a heuristic rule to break ties is adopted for the branching operation, and interval computation with analysis on the monotony of branching conditions is utilized for the bounding operation. Empirical experiments show that the proposed method performs well with linear complexity, and reaches 100% coverage on some benchmark programs with an advantage over some static and dynamic algorithms.