为了解决消息传递并行程序路径覆盖测试数据生成问题,提出一种基于覆盖难度选择目标路径的测试数据进化生成方法.通过影响路径执行的变量、路径关键条件的复杂度,以及Halstead测度等,选择最容易覆盖的路径作为目标路径,以降低目标路径覆盖的难度;基于该路径,建立测试数据生成问题的数学模型;采用遗传算法生成覆盖目标路径的测试数据.将所提方法应用于5个基准并行程序的测试数据生成,并与已有方法比较.结果表明,所提方法能够减少测试数据生成过程中的计算量,使用较少的个体评价次数,有效生成覆盖并行程序路径的测试数据.
In order to tackle the problem of generating test data covering paths of a message-passing parallel program, a method of evolutionarily generating test data was presented through selecting target paths based on the coverage difficulty. In the light of variables affecting a path's execution, complexities of a path's crucial conditions, and Halstead's metric, the path which is the easiest to be covered was selected as the target path to reduce the coverage difficulty. The mathematical model for generating test data was built according to the selected path. A genetic algorithm was employed to solve the above model so as to generate test data covering the target path. The proposed method was applied to generate test data for five benchmark parallel programs and compared to the existing methods. The results show that the proposed method can reduce the computation cost, and effectively generate test data for path coverage of parallel programs with the less number of evaluated individuals.