JP6330490B2 - Test case generation program, test case generation apparatus, and test case generation method - Google Patents

Test case generation program, test case generation apparatus, and test case generation method Download PDF

Info

Publication number
JP6330490B2
JP6330490B2 JP2014112808A JP2014112808A JP6330490B2 JP 6330490 B2 JP6330490 B2 JP 6330490B2 JP 2014112808 A JP2014112808 A JP 2014112808A JP 2014112808 A JP2014112808 A JP 2014112808A JP 6330490 B2 JP6330490 B2 JP 6330490B2
Authority
JP
Japan
Prior art keywords
index
index value
test case
generated
unit
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
JP2014112808A
Other languages
Japanese (ja)
Other versions
JP2015228085A (en
Inventor
翔一朗 藤原
翔一朗 藤原
忠弘 上原
忠弘 上原
英生 谷田
英生 谷田
朝子 片山
朝子 片山
スッパシット モンプラターンチャイ
スッパシット モンプラターンチャイ
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Fujitsu Ltd
Original Assignee
Fujitsu Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Fujitsu Ltd filed Critical Fujitsu Ltd
Priority to JP2014112808A priority Critical patent/JP6330490B2/en
Publication of JP2015228085A publication Critical patent/JP2015228085A/en
Application granted granted Critical
Publication of JP6330490B2 publication Critical patent/JP6330490B2/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Debugging And Monitoring (AREA)

Description

本発明は、テストケース生成プログラム、テストケース生成装置、及びテストケース生成方法に関する。   The present invention relates to a test case generation program, a test case generation device, and a test case generation method.

従来から、コンピュータのプログラムを実行し、正しく動作するかどうか確認する作業が行われている。   Conventionally, an operation for executing a computer program and confirming whether or not it operates correctly has been performed.

プログラムのテストを実行するためには、入力データ(テストデータ)及び期待結果等を含むテストケースが必要となる。テストで実行する一連のテストケースの集合をここではテストケースセットと呼ぶ。テストでは、確認すべき観点を全て網羅するようにテストケースセットを準備する必要がある。   In order to execute a program test, a test case including input data (test data) and expected results is required. A set of test cases to be executed in the test is referred to as a test case set here. In the test, it is necessary to prepare a test case set to cover all the viewpoints to be confirmed.

ここでは、テストの中でも、特にプログラムのホワイトボックステストに注目する。ホワイトボックステストでは、コードカバレッジの指標に従って、プログラム中の命令や分岐、あるいは実行パスを網羅するようにテストケースを準備してテストを実行する。   Here, we focus on the white box test of the program. In the white box test, a test case is prepared and the test is executed so as to cover instructions, branches, or execution paths in the program according to the code coverage index.

テストケースの準備、特に入力データの作成は、多くの場合は人手でなされており、大きな労力を要している。この労力を解決する方法として、近年注目されているのが、シンボリック実行(Symbolic execution)によるテストデータ生成技術である。   The preparation of test cases, especially the creation of input data, is often done manually and requires a lot of effort. As a method for solving this labor, a test data generation technique based on symbolic execution has been attracting attention in recent years.

シンボリック実行を効率化する技術として、例えば、特許文献1及び特許文献2に記載された技術が知られている。   As a technique for improving the efficiency of symbolic execution, for example, techniques described in Patent Document 1 and Patent Document 2 are known.

特開2011−191985号公報Japanese Unexamined Patent Publication No. 2011-191985 特開2013−143067号公報JP 2013-143067 A

シンボリック実行では、パス条件を生成するために探索及び実行するパスの範囲が広くなり、実用的な時間及び空間計算量で扱えなくなる、いわゆる組合せ爆発を引き起こす懸念がある。組合せ爆発を抑制するために、シンボリック実行を効率化することが望まれる。   In symbolic execution, the range of paths to be searched and executed in order to generate a path condition is widened, and there is a concern of causing a so-called combination explosion that cannot be handled with practical time and space complexity. In order to suppress combinational explosions, it is desirable to improve the efficiency of symbolic execution.

本発明は一つの側面として、シンボリック実行によるプログラムのテストケースの生成において、シンボリック実行の効率化を実現することを目的とする。   An object of the present invention is to realize the efficiency of symbolic execution in generating a test case of a program by symbolic execution.

1つの態様では、配列を構成する複数の要素の各々の位置を表すシンボル変数であるインデックス値で、除外されていない未選択のインデックス値を選択対象として、該選択対象からインデックス値を選択する。また、対象プログラムをシンボリック実行することにより、選択したインデックス値に対応する要素に応じて分岐するパスを表すパス条件を生成する。さらに、生成したパス条件及び該生成したパス条件が表すパスを通過するテストデータをテストケースとして出力する。また、前記選択対象に含まれるインデックス値であり、パス条件を生成した要素と同一の要素に対応するインデックス値が、生成した該パス条件からインデックス値に由来する制約を除外したインデックス等価条件を充足可能か判定する。さらに、充足可能なインデックス値を前記選択対象から除外する。 In one aspect, an index value that is a symbol variable representing the position of each of a plurality of elements constituting an array and an unselected index value that is not excluded is selected, and the index value is selected from the selection target. Further, by executing symbolically the target program, a path condition representing a path that branches depending on the element corresponding to the selected index value is generated. Further, the generated path condition and test data passing through the path represented by the generated path condition are output as test cases. In addition, the index value included in the selection target, the index value corresponding to the same element as the element that generated the path condition satisfies the index equivalent condition that excludes the constraint derived from the index value from the generated path condition Determine if it is possible. Further, a satisfiable index value is excluded from the selection target.

一つの側面として、シンボリック実行によるプログラムのテストケースの生成において、シンボリック実行の効率化を実現することができる、という効果を有する。   As one aspect, in the generation of a test case of a program by symbolic execution, the efficiency of symbolic execution can be realized.

本実施形態のテストケース生成装置の一例の概略構成を示すブロック図である。It is a block diagram which shows schematic structure of an example of the test case production | generation apparatus of this embodiment. 本実施形態のシンボリック実行対象となるプログラム(TargetClass.method1)の具体例を示す図である。It is a figure which shows the specific example of the program (TargetClass.method1) used as the symbolic execution object of this embodiment. 図2に示したプログラムのフローを表したフロー図である。FIG. 3 is a flowchart showing the flow of the program shown in FIG. 2. 本実施形態のテストケース生成装置によるテストケースの生成を説明するための図である。It is a figure for demonstrating the production | generation of the test case by the test case production | generation apparatus of this embodiment. 本実施形態のテストケース生成装置によるシンボリック実行における図2に示したプログラムの実行空間を表した図である。It is a figure showing the execution space of the program shown in FIG. 2 in the symbolic execution by the test case production | generation apparatus of this embodiment. 本実施形態のテストケース生成装置で生成されるテストケースの具体例を説明するための図である。It is a figure for demonstrating the specific example of the test case produced | generated with the test case production | generation apparatus of this embodiment. 本実施例のテストケース生成装置の一例の概略構成を示すブロック図である。It is a block diagram which shows schematic structure of an example of the test case production | generation apparatus of a present Example. テストケース生成装置として機能するコンピュータの概略構成を示すブロック図である。It is a block diagram which shows schematic structure of the computer which functions as a test case production | generation apparatus. 本実施例に係るシンボリック実行対象となるプログラム(TargetClass.method1)の具体例を示す図である。It is a figure which shows the specific example of the program (TargetClass.method1) used as the symbolic execution object based on a present Example. 図9に示したプログラムのフローを表したフロー図である。FIG. 10 is a flowchart showing the flow of the program shown in FIG. 9. テストケース生成装置で実行されるテストケース生成処理の一例を示すフローチャートである。It is a flowchart which shows an example of the test case production | generation process performed with a test case production | generation apparatus. 本実施例のテストケース生成装置で生成されるテストケースの具体例を説明するための図である。It is a figure for demonstrating the specific example of the test case produced | generated with the test case production | generation apparatus of a present Example. 本実施例のテストケース生成装置で実行されるシンボリック実行処理の一例を示すフローチャートである。It is a flowchart which shows an example of the symbolic execution process performed with the test case production | generation apparatus of a present Example. 本実施例のテストケース生成装置で実行される手順1を説明するための図であるIt is a figure for demonstrating the procedure 1 performed with the test case production | generation apparatus of a present Example. 本実施例のテストケース生成装置で実行される分岐選択処理の一例を示すフローチャートである。It is a flowchart which shows an example of the branch selection process performed with the test case production | generation apparatus of a present Example. 本実施例のテストケース生成装置で実行される手順2を説明するための図である。It is a figure for demonstrating the procedure 2 performed with the test case production | generation apparatus of a present Example. 本実施例のテストケース生成装置で実行される手順3を説明するための図である。It is a figure for demonstrating the procedure 3 performed with the test case production | generation apparatus of a present Example. 同一要素インデックス情報のその他の例について説明した図である。It is a figure explaining other examples of the same element index information. 本実施例のテストケース生成装置で実行される手順4を説明するための図である。It is a figure for demonstrating the procedure 4 performed with the test case production | generation apparatus of a present Example. 本実施例のテストケース生成装置で実行される情報更新処理の一例を示すフローチャートである。It is a flowchart which shows an example of the information update process performed with the test case production | generation apparatus of a present Example. 本実施例のテストケース生成装置で実行される手順5を説明するための図である。It is a figure for demonstrating the procedure 5 performed with the test case production | generation apparatus of a present Example. 本実施例のテストケース生成装置で実行される手順6を説明するための図である。It is a figure for demonstrating the procedure 6 performed with the test case production | generation apparatus of a present Example. 本実施例のテストケース生成装置で実行されるバックトラック先判定処理の一例を示すフローチャートである。It is a flowchart which shows an example of the backtrack destination determination process performed with the test case production | generation apparatus of a present Example. 本実施例のテストケース生成装置で実行される手順7を説明するための図である。It is a figure for demonstrating the procedure 7 performed with the test case production | generation apparatus of a present Example. 本実施例のテストケース生成装置で実行される手順4(2回目)を説明するための図である。It is a figure for demonstrating the procedure 4 (2nd time) performed with the test case production | generation apparatus of a present Example. 本実施例のテストケース生成装置で実行される手順5(2回目)を説明するための図である。It is a figure for demonstrating the procedure 5 (2nd time) performed with the test case production | generation apparatus of a present Example. 本実施例のテストケース生成装置で実行される手順6(2回目)を説明するための図である。It is a figure for demonstrating the procedure 6 (2nd time) performed with the test case production | generation apparatus of a present Example. 本実施例のテストケース生成装置で実行される手順7(2回目)を説明するための図である。It is a figure for demonstrating the procedure 7 (2nd time) performed with the test case production | generation apparatus of a present Example. 本実施例のテストケース生成装置で実行される手順4(3回目)を説明するための図である。It is a figure for demonstrating the procedure 4 (3rd time) performed with the test case production | generation apparatus of a present Example. 本実施例のテストケース生成装置で実行される手順5(3回目)を説明するための図である。It is a figure for demonstrating the procedure 5 (3rd time) performed with the test case production | generation apparatus of a present Example. 本実施例のテストケース生成装置で実行される手順6(3回目)を説明するための図である。It is a figure for demonstrating the procedure 6 (3rd time) performed with the test case production | generation apparatus of a present Example. 本実施例のテストケース生成装置で実行される手順7(3回目)を説明するための図である。It is a figure for demonstrating the procedure 7 (3rd time) performed with the test case production | generation apparatus of a present Example. 本実施例のテストケース生成装置で実行される手順4(4回目)を説明するための図である。It is a figure for demonstrating the procedure 4 (4th) performed with the test case production | generation apparatus of a present Example. 本実施例のテストケース生成装置で実行される手順5(4回目)を説明するための図である。It is a figure for demonstrating the procedure 5 (4th) performed with the test case production | generation apparatus of a present Example. 本実施例のテストケース生成装置で実行される手順6(4回目)を説明するための図である。It is a figure for demonstrating the procedure 6 (4th) performed with the test case production | generation apparatus of a present Example. 本実施例のテストケース生成装置で実行される手順7(4回目)を説明するための図である。It is a figure for demonstrating the procedure 7 (4th) performed with the test case production | generation apparatus of a present Example. 同一パス上に複数の配列アクセスが存在する場合のシンボリック実行の例を説明するための図である。It is a figure for demonstrating the example of symbolic execution in case the some array access exists on the same path. 比較例のシンボリック実行の手法を説明するための図である。It is a figure for demonstrating the method of the symbolic execution of a comparative example. 比較例のテストケース生成装置によるシンボリック実行における図2に示したプログラムの実行空間を表した図である。It is a figure showing the execution space of the program shown in FIG. 2 in the symbolic execution by the test case production | generation apparatus of a comparative example.

以下、図面を参照して開示の技術の一例を詳細に説明する。   Hereinafter, an example of the disclosed technique will be described in detail with reference to the drawings.

まず、開示の技術の一例の概略について説明する。図1は、本実施形態に係るテストケース生成装置10の一例の概略構成を示すブロック図である。図1に示すように、テストケース生成装置10は、シンボリック実行部12、インデックスアクセス検出部14、及びインデックス選択部16を備える。さらに、テストケース生成装置10は、同一要素インデックス情報生成部18、同一要素判定部20、インデックス等価条件生成部22、及びインデックス等価判定部24を備える。   First, an outline of an example of the disclosed technique will be described. FIG. 1 is a block diagram illustrating a schematic configuration of an example of a test case generation device 10 according to the present embodiment. As illustrated in FIG. 1, the test case generation device 10 includes a symbolic execution unit 12, an index access detection unit 14, and an index selection unit 16. Further, the test case generation apparatus 10 includes an identical element index information generation unit 18, an identical element determination unit 20, an index equivalent condition generation unit 22, and an index equivalence determination unit 24.

本実施形態のテストケース生成装置10は、配列を構成する複数の要素の位置を表すインデックスをシンボル変数としたシンボリック実行を行う機能を有する。   The test case generation apparatus 10 of the present embodiment has a function of performing symbolic execution using an index representing the position of a plurality of elements constituting an array as a symbol variable.

シンボリック実行とは、プログラム中の変数を具体化せず、シンボル値という特殊な値を持たせたまま実行する技術である。このシンボル値を保持する変数のことをシンボル変数という。   Symbolic execution is a technique that does not embody variables in a program but executes them with special values called symbol values. A variable that holds this symbol value is called a symbol variable.

シンボリック実行では、シンボル変数が分岐等の判定条件に利用された場合に、判定条件が成立する場合及び成立しない場合のそれぞれのパターンを網羅的に実行する。この場合、現在のパターンを実行するために、すなわち、判定条件を成立させる及び成立させないために、シンボル値が満たさなければならない条件を保持する。シンボル値が満たさなければならない条件をパス条件という。パス条件は、シンボリック実行によって実行された各実行パス毎に保持される。あるパス条件を充足するようなシンボル値が存在しない場合、そのパス条件を保持する実行パスは実行不可能であるため、テスト対象から除外できる。充足可能なパス条件を保持する実行パスについては、パス条件の充足値をテストデータとみなすことで、テストデータを生成することができる。また、各テストデータが満たすパス条件は、テストデータがどのような実行経路を通過したかを示しており、テストデータに対するある面からの意味づけを与えている。   In symbolic execution, when a symbol variable is used for a determination condition such as a branch, each pattern when the determination condition is satisfied and when the determination condition is not satisfied is comprehensively executed. In this case, in order to execute the current pattern, that is, in order to satisfy and not satisfy the determination condition, the condition that the symbol value must satisfy is held. A condition that a symbol value must satisfy is called a path condition. The path condition is held for each execution path executed by symbolic execution. If there is no symbol value that satisfies a certain path condition, the execution path that holds the path condition is not executable and can be excluded from the test target. For an execution path that holds a satisfying path condition, test data can be generated by regarding the satisfaction value of the path condition as test data. The path condition satisfied by each test data indicates what execution path the test data has passed through, and gives a certain meaning to the test data.

なお、シンボリック実行に関する基礎的な事項は、非特許文献である玉井哲雄、福永光一、「記号実行システム」、情報処理、pp.18-28等に記載されている。また、Java(登録商標)プログラムに対するシンボリック実行エンジンとしては、http://babelfish.arc.nasa.gov/trac/jpfに、Java(登録商標) PathFinder等が開示されている。また、シンボリック実行技術の公知例としては、特開2009−087355号公報に記載された技術等が挙げられる。そのため、ここでは、シンボリック実行に関する基礎的な事項の詳細な説明を省略する。   Basic items regarding symbolic execution are described in non-patent documents Tetsuo Tamai, Koichi Fukunaga, “Symbol Execution System”, Information Processing, pp.18-28, etc. Further, as a symbolic execution engine for a Java (registered trademark) program, Java (registered trademark) PathFinder or the like is disclosed at http://babelfish.arc.nasa.gov/trac/jpf. Further, as a known example of the symbolic execution technique, a technique described in JP 2009-087355 A can be cited. For this reason, detailed description of basic matters related to symbolic execution is omitted here.

開示の技術の実行部の一例であるシンボリック実行部12は、シンボリック実行対象であるプログラム11(以下、「対象プログラム」という)に対して、シンボリック実行を行う機能を有する。また、シンボリック実行部12は、シンボル変数に関するテストデータとパス条件26とを含むテストケース33を生成して出力する機能を有する。具体的には、シンボリック実行部12は、シンボリック実行を行い、インデックス選択部16により選択されたインデックス値に対応する要素(シンボル値)が通過するパスを表すパス条件26を生成する。さらに、シンボリック実行部12は、生成したパス条件26を充足するテストデータと、前記パス条件とを含むテストケース33を出力する。   The symbolic execution unit 12, which is an example of the execution unit of the disclosed technology, has a function of performing symbolic execution on a program 11 that is a symbolic execution target (hereinafter, “target program”). Further, the symbolic execution unit 12 has a function of generating and outputting a test case 33 including the test data regarding the symbol variable and the path condition 26. Specifically, the symbolic execution unit 12 performs symbolic execution and generates a path condition 26 representing a path through which an element (symbol value) corresponding to the index value selected by the index selection unit 16 passes. Further, the symbolic execution unit 12 outputs a test case 33 including the test data that satisfies the generated path condition 26 and the path condition.

なお、シンボリック実行においては、配列のアクセスに関するパス条件を制約ソルバが扱える形で表現することが必要となる。制約ソルバが扱える条件式は、数値、文字列等のプリミティブ、あるいはそれに準ずるデータ型に関するものであり、データ型がinstanceof等の一般のオブジェクト型(Object型)である条件式は扱えない。そのため、シンボリック実行部12では、データ型がint型のパス条件26を生成する。   In symbolic execution, it is necessary to express path conditions related to array access in a form that can be handled by the constraint solver. The conditional expressions that can be handled by the constraint solver are related to primitives such as numerical values and character strings, or data types equivalent thereto, and cannot handle conditional expressions whose data type is a general object type (Object type) such as instanceof. Therefore, the symbolic execution unit 12 generates a path condition 26 whose data type is an int type.

インデックスアクセス検出部14は、シンボリック実行部12で実行する命令が、シンボル変数をインデックスとした配列を構成する要素へのアクセス命令か否かを検出する機能を有する。インデックスアクセス検出部14は、開示の技術の検出部の一例である。   The index access detection unit 14 has a function of detecting whether an instruction executed by the symbolic execution unit 12 is an access instruction to an element constituting an array having a symbol variable as an index. The index access detection unit 14 is an example of a detection unit according to the disclosed technique.

開示の技術の選択部の一例であるインデックス選択部16は、インデックス値の中から、現在の命令の後続の処理を継続するインデックス値を選択する機能を有する。シンボリック実行部12では、選択されたインデックス値に対応するパス条件26を生成する。そのため、具体的には、インデックス選択部16は、シンボリック実行部12によってパス条件を生成するインデックス値を選択してシンボリック実行部12に出力する機能を有する。より具体的には、インデックス選択部16は、選択済のインデックス値と未選択のインデックス値とを表す情報であるインデックス選択情報28を生成する。インデックス選択情報28の未選択のインデックス値がインデックス値の選択対象となる。そして、インデックス選択部16は、生成したインデックス選択情報28から、未選択のインデックス値を選択してシンボリック実行部12に出力する機能を有する。   The index selection unit 16, which is an example of the selection unit of the disclosed technique, has a function of selecting an index value that continues the subsequent processing of the current instruction from among the index values. The symbolic execution unit 12 generates a path condition 26 corresponding to the selected index value. Therefore, specifically, the index selection unit 16 has a function of selecting an index value for generating a path condition by the symbolic execution unit 12 and outputting it to the symbolic execution unit 12. More specifically, the index selection unit 16 generates index selection information 28 that is information indicating a selected index value and an unselected index value. An unselected index value of the index selection information 28 is an index value selection target. The index selection unit 16 has a function of selecting an unselected index value from the generated index selection information 28 and outputting it to the symbolic execution unit 12.

同一要素判定部20は、命令を実行する際の配列に存在する要素同士が同一で有るか否かを判定する機能を有する。   The same element determination unit 20 has a function of determining whether or not elements existing in an array when executing an instruction are the same.

同一要素インデックス情報生成部18は、シンボル変数をインデックスとした配列のアクセス命令に対して、同一要素が格納されているインデックス値をまとめた同一要素インデックス情報30を生成する機能を有する。具体的には、同一要素インデックス情報生成部18は、同一要素判定部20の判定結果に基づいて、同一要素インデックス情報30を生成する。同一要素インデックス情報生成部18は、開示の技術の生成部の一例である。   The same element index information generation unit 18 has a function of generating the same element index information 30 in which index values storing the same element are collected in response to an access instruction having an array using a symbol variable as an index. Specifically, the same element index information generation unit 18 generates the same element index information 30 based on the determination result of the same element determination unit 20. The same element index information generation unit 18 is an example of a generation unit of the disclosed technology.

インデックス等価条件生成部22は、シンボル変数をインデックスとした配列のアクセス命令を含む実行パスに関し、対応するパス条件からインデックス等価条件32を生成する機能を有する。具体的には、インデックス等価条件32とは、シンボリック実行部12が生成したパス条件26から選択したインデックス値に由来する制約式を除いたものである。すなわち、インデックス等価条件32とは、同一要素を有し、インデックス値が同じパスを通過するための条件である。   The index equivalent condition generation unit 22 has a function of generating an index equivalent condition 32 from a corresponding path condition with respect to an execution path including an array access instruction using a symbol variable as an index. Specifically, the index equivalent condition 32 is obtained by excluding the constraint expression derived from the index value selected from the path condition 26 generated by the symbolic execution unit 12. That is, the index equivalent condition 32 is a condition for having the same element and having the same index value through the same path.

インデックス等価判定部24は、シンボリック実行部12で使用したインデックス値の要素と同一の要素に対応する未選択のインデックス値が、インデックス等価条件32を充足可能か否かを判定する機能を有する。具体的には、同一要素インデックス情報30に基づいて、シンボリック実行部12で使用したインデックス値の要素と同一の要素を検出して、判定を行う。また、インデックス等価判定部24は、インデックス値がインデックス等価条件32を充足可能と判定した場合は、判定したインデックス値をインデックス選択情報28において未選択のインデックス値から除外する機能を有する。すなわち、インデックス等価判定部24は、インデックス等価条件32を充足可能なインデックス値を選択対象のインデックス値から除外する機能を有する。具体的には、インデックス等価判定部24は、除外するインデックス値を、インデックス選択情報28において未選択から選択済に変更することにより選択対象から除外して更新を行う。   The index equivalence determination unit 24 has a function of determining whether or not an unselected index value corresponding to the same element as the index value element used in the symbolic execution unit 12 can satisfy the index equivalence condition 32. Specifically, based on the same element index information 30, the same element as the index value element used in the symbolic execution unit 12 is detected and determined. In addition, the index equivalence determination unit 24 has a function of excluding the determined index value from the unselected index values in the index selection information 28 when it is determined that the index value can satisfy the index equivalence condition 32. That is, the index equivalence determination unit 24 has a function of excluding index values that can satisfy the index equivalence condition 32 from the index values to be selected. Specifically, the index equivalence determination unit 24 updates the index value to be excluded from the selection target by changing the index selection information 28 from unselected to selected.

このように、インデックス等価判定部24がインデックス値を未選択から選択済に変更する更新を行うことにより、インデックス値が選択対象から除外されるため、インデックス選択部16は、除外されたインデックス値を選択することがなくなる。このため、シンボリック実行部12では、間引かれたインデックス値に対するパス条件の生成(後続処理の実行)を行わない。   As described above, since the index equivalence determining unit 24 updates the index value to change from unselected to selected, the index value is excluded from the selection target. There is no choice. For this reason, the symbolic execution unit 12 does not generate path conditions for the thinned index values (execution of subsequent processing).

テストケース生成装置10の動作について説明する。具体例として、TargetClass.method1に対して、テストケース生成装置10がシンボリック実行を行い、テストケース33を生成する場合について説明する。図2には、プログラム(TargetClass.method1)の具体例を示す。また、図3には、図2に示したプログラムのフローを表したフロー図を示す。なお、図3に示したフロー図の記号内の数字は、プログラムの行に対応している。さらに、図4には、テストケース生成装置10によるテストケースの生成を説明するための図を示す。   The operation of the test case generation device 10 will be described. As a specific example, a case where the test case generation apparatus 10 performs symbolic execution on TargetClass.method1 to generate a test case 33 will be described. FIG. 2 shows a specific example of the program (TargetClass.method1). FIG. 3 is a flowchart showing the flow of the program shown in FIG. The numbers in the symbols of the flowchart shown in FIG. 3 correspond to program lines. Further, FIG. 4 shows a diagram for explaining test case generation by the test case generation apparatus 10.

テストケース生成装置10により、図2及び図3に示した、プログラム(TargetClass.method1)のシンボリック実行を実行する。TargetClass.method1では、シンボル変数としてidxが指定されている。このidxに対するシンボル値をαとした場合、シンボリック実行では、図5に示した実行空間を探索する。   The test case generation apparatus 10 executes symbolic execution of the program (TargetClass.method1) shown in FIGS. In TargetClass.method1, idx is specified as a symbol variable. If the symbol value for this idx is α, the symbolic execution searches the execution space shown in FIG.

シンボリック実行開始後、シンボリック実行部12はプログラムの06行目の命令を実行する。ここではシンボル変数に関する操作はないので実行空間上で分岐は生成されず、シンボリック実行部12は、引き続き07行目を実行する。07行目の命令の「value = array[α]」は配列へのアクセスを行う。この場合、アクセスに使用するインデックス値はシンボル値であり、シンボル値の条件によって返却される配列の要素が異なってくるので実行空間に分岐が発生する。実行空間の07行目から続く各エッジが発生する分岐に対応している。エッジに付与した「α==0」及び「α==1」といったラベルはそれぞれインデックス値が「0」の場合及び「1」の場合といった場合分けを示唆している。ここで、07行目の実行時点において、配列(array)には6つの要素(「a1」、「b1」、「a2]、「b1」、「b1」、及び「a1」)が格納されている。   After starting symbolic execution, the symbolic execution unit 12 executes the instruction on the 06th line of the program. Here, since there is no operation related to the symbol variable, no branch is generated in the execution space, and the symbolic execution unit 12 continues to execute the 07th line. The instruction “value = array [α]” on the 07th line accesses the array. In this case, the index value used for access is a symbol value, and since the elements of the array to be returned differ depending on the symbol value condition, a branch occurs in the execution space. This corresponds to a branch where each edge occurs from the 07th line of the execution space. Labels such as “α == 0” and “α == 1” given to the edges suggest case classification such as when the index value is “0” and “1”, respectively. Here, at the time of execution of the 07th row, six elements (“a1”, “b1”, “a2”, “b1”, “b1”, and “a1”) are stored in the array. Yes.

インデックスアクセス検出部14は、07行目の「value=array[α]」がシンボル変数を使用した配列へのアクセス命令であることを検出する。   The index access detection unit 14 detects that “value = array [α]” on the 07th line is an instruction to access an array using a symbol variable.

同一要素インデックス情報生成部18及び同一要素判定部20は、この配列に基づいて、同一要素インデックス情報30を生成する。図4及び図5には、生成される同一要素インデックス情報30の具体例が示されている。   The same element index information generation unit 18 and the same element determination unit 20 generate the same element index information 30 based on this array. 4 and 5 show specific examples of the generated identical element index information 30. FIG.

インデックス選択部16は、インデックス選択情報28を生成する。図4に示した更新前のインデックス選択情報28は、既に、インデックス値「0」及び「5」が選択済であり、新たに、インデックス選択部16がインデックス値「1」を選択して、シンボリック実行部12に出力した状態を示している。   The index selection unit 16 generates index selection information 28. In the index selection information 28 before update shown in FIG. 4, the index values “0” and “5” have already been selected, and the index selection unit 16 newly selects the index value “1”. The state output to the execution unit 12 is shown.

シンボリック実行部12では、インデックス値「1」に応じたパス条件26を生成する。ここでは、図4及び図5に示したように、パス条件26として、「α==1 && α<4」が生成される。シンボリック実行部12は、テスト入力が「idx(α):1」、及びパス条件が「α==1 && α<4」のテストケースをテストケース33の1つとして出力する。   The symbolic execution unit 12 generates a path condition 26 corresponding to the index value “1”. Here, as shown in FIGS. 4 and 5, “α == 1 && α <4” is generated as the path condition 26. The symbolic execution unit 12 outputs a test case whose test input is “idx (α): 1” and whose path condition is “α == 1 && α <4” as one of the test cases 33.

インデックス等価条件生成部22は、生成されたパス条件26からインデックス値(idx)に由来した制約を除いたインデックス等価条件32を生成する。パス条件26が「α==1 && α<4」の場合、「α==1」を除くため、インデックス等価条件32は、「α<4」となる。   The index equivalent condition generation unit 22 generates an index equivalent condition 32 in which the restriction derived from the index value (idx) is removed from the generated path condition 26. When the path condition 26 is “α == 1 && α <4”, since “α == 1” is excluded, the index equivalence condition 32 is “α <4”.

インデックス等価判定部24は、同一要素インデックス情報30に基づいて、インデックス等価条件32を充足可能なインデックス値を判定する。上記具体例の場合、インデックス値が1と同じ要素を有するインデックス値は、同一要素インデックス情報30によると、「3」及び「4」である。インデックス値が「3」の場合は、インデックス等価条件32である「α<4」を充足する。一方、インデックス値が「4」の場合は、インデックス等価条件32である「α<4」を充足できない。そのため、インデックス等価判定部24は、インデックス値「3」を充足可能であると判定する。すなわち、インデックス値「3」の場合は、パス条件26がインデックス値「1」の場合と同様になるため、テストケースを生成せずとも(テストを行わなくとも)、プログラムの動作確認には支障がない。そこで、インデックス等価判定部24は、インデックス値「3」を未選択から選択済に変更し、インデックス選択情報28の更新を行う。インデックス値「3」が選択済となったため、インデックス選択部16は、インデックス値「3」を選択しない。そのため、シンボリック実行部12では、インデックス値「3」に応じたパス条件26は生成しない。   The index equivalence determination unit 24 determines an index value that can satisfy the index equivalence condition 32 based on the same element index information 30. In the case of the above specific example, according to the same element index information 30, the index values having the same element as the index value “1” are “3” and “4”. When the index value is “3”, the index equivalent condition 32 “α <4” is satisfied. On the other hand, when the index value is “4”, the index equivalent condition 32 “α <4” cannot be satisfied. Therefore, the index equivalence determination unit 24 determines that the index value “3” can be satisfied. That is, when the index value is “3”, the path condition 26 is the same as when the index value is “1”. Therefore, it is difficult to check the operation of the program without generating a test case (without performing a test). There is no. Therefore, the index equivalence determination unit 24 changes the index value “3” from unselected to selected, and updates the index selection information 28. Since the index value “3” has been selected, the index selection unit 16 does not select the index value “3”. Therefore, the symbolic execution unit 12 does not generate the path condition 26 corresponding to the index value “3”.

図6には、上述のようにしてテストケース生成装置10により形成されるテストケース33を示す。テストケース生成装置10では、図5に示したように、インデックス値が「0」及び「5」の場合は、生成されるテストケースを1つにまとめることができる。また、テストケース生成装置10では、図5に示したように、インデックス値が「1」及び「3」の場合は、生成されるテストケースを1つにまとめることができる。従って、テストケース生成装置10では、図6に示したように、No.1〜4まで、4つのテストケースを含むテストケース33が生成される。   FIG. 6 shows the test case 33 formed by the test case generation apparatus 10 as described above. As shown in FIG. 5, when the index values are “0” and “5”, the test case generation apparatus 10 can combine the generated test cases into one. Further, as shown in FIG. 5, when the index values are “1” and “3”, the test case generation apparatus 10 can combine the generated test cases into one. Therefore, in the test case generation apparatus 10, as shown in FIG. From 1 to 4, a test case 33 including four test cases is generated.

(比較例)
ここで、比較例として、従来のテストケース生成装置によりシンボリック実行を行う場合について説明する。
(Comparative example)
Here, a case where symbolic execution is performed by a conventional test case generation device will be described as a comparative example.

シンボリック実行ではシンボル変数が関係する各分岐に関して、分岐条件成立の場合と非成立の場合のそれぞれの場合を探索・実行する。すなわち、各分岐条件の成立・非成立の組合せを行うことに等しい。この組合せの数はシンボル変数が関係する分岐条件数に対して幾何級数的に増加するため、ある程度規模の大きいプログラムになると組合せ数が多くなりすぎてシンボリック実行に要する計算資源が用意されたものを超えてしまう。例えば、図38に示すように、n個の独立した分岐が存在するプログラムを考える。図38に示したプログラムは分岐の組合せとして、2のパスを持つため、容易に組合せ爆発を引き起こす懸念がある。 In symbolic execution, each branch related to a symbol variable is searched for and executed when the branch condition is satisfied and when it is not satisfied. That is, it is equivalent to performing a combination of establishment / non-establishment of each branch condition. Since the number of combinations increases geometrically with respect to the number of branch conditions related to the symbol variable, the number of combinations becomes too large for a program with a certain size, so that the computing resources required for symbolic execution are prepared. It will exceed. For example, consider a program in which n independent branches exist as shown in FIG. Since the program shown in FIG. 38 has 2n paths as a combination of branches, there is a concern that a combination explosion may easily occur.

配列へのアクセスが含まれるプログラムに対するシンボリック実行の従来技術として、次に述べる手法を比較例として説明する。比較例の手法では、シンボリック実行中にシンボル変数による配列へのインデックスアクセスに遭遇した場合、配列を構成する全要素に関して、各要素を選択した場合のパスを解析する。例えば、配列に3要素ある場合、0番目、1番目、2番目をそれぞれ選択した場合の実行パターンをすべて解析する。   As a conventional technique of symbolic execution for a program including access to an array, the following method will be described as a comparative example. In the method of the comparative example, when index access to an array by a symbol variable is encountered during symbolic execution, the path when each element is selected is analyzed for all elements constituting the array. For example, when there are three elements in the array, all execution patterns when 0th, 1st, and 2nd are selected are analyzed.

実施形態で示したプログラム(図2参照)に対して比較例の手法を適用した場合について説明する。命令の07行目を実行する時点において、配列(array)には6つの要素が格納されており、比較例ではそれにしたがって「α==0」から「α==5」までの6通りの分岐を発生させる。シンボリック実行エンジンはこれら6通りの分岐を解析し、最終的には図39に示す実行空間を探索してNo.1〜6までのテストケースを含んだテストケースを得る。ここで、探索した実行パターンは9パターンであるが、そのうちの3パターンは実際には通過し得ない分岐の組合せを経ていることがパス条件から分かり、対応するテストケースもそれらのパターンを除いたものとなっている。   A case where the method of the comparative example is applied to the program (see FIG. 2) shown in the embodiment will be described. At the time of executing the 07th line of the instruction, six elements are stored in the array, and in the comparative example, there are six branches from “α == 0” to “α == 5” accordingly. Is generated. The symbolic execution engine analyzes these six branches, and finally searches the execution space shown in FIG. A test case including 1 to 6 test cases is obtained. Here, there are nine execution patterns that have been searched for, but it is clear from the path condition that three of these patterns have undergone a combination of branches that cannot actually pass through, and the corresponding test cases also exclude those patterns. It has become a thing.

比較例のテストケース生成装置では、9パターンを探索した結果、6つのテストケースを生成している。一方、上述したように本実施形態のテストケース生成装置10では、6パターンを探索した結果、4つのテストケースを含むテストケース33を生成している。このように、本実施形態のテストケース生成装置10では、探索するパターンの数を少なくし、シンボリック実行の効率化を図ることができる。そのため、本実施形態のテストケース生成装置10では、組合せ爆発の発生を抑制することができる。   In the test case generation device of the comparative example, six test cases are generated as a result of searching for nine patterns. On the other hand, as described above, the test case generation apparatus 10 of the present embodiment generates a test case 33 including four test cases as a result of searching for six patterns. Thus, in the test case generation device 10 of the present embodiment, the number of patterns to be searched can be reduced, and the efficiency of symbolic execution can be improved. Therefore, in the test case generation device 10 of the present embodiment, it is possible to suppress the occurrence of a combination explosion.

(実施例)
次に、開示の技術について、実施例を参照して詳細に説明する。なお、本実施例は、上述したテストケース生成装置10と同様の技術に関して詳細に説明するためのものであるため、テストケース生成装置100において上述と同様の構成及び動作については、詳細な説明を省略する場合がある。
(Example)
Next, the disclosed technique will be described in detail with reference to examples. In addition, since the present Example is for explaining in detail about the same technology as the test case generation device 10 described above, the same configuration and operation as described above in the test case generation device 100 will be described in detail. May be omitted.

図7は、本実施例に係るテストケース生成装置100の一例の概略構成を示すブロック図である。図7に示すように、テストケース生成装置100は、シンボリック実行部112、インデックスアクセス検出部114、及びインデックス選択部116を備える。さらに、テストケース生成装置100は、同一要素インデックス情報生成部118、同一要素判定部120、インデックス等価条件生成部122、及びインデックス等価判定部124を備える。   FIG. 7 is a block diagram illustrating a schematic configuration of an example of the test case generation device 100 according to the present embodiment. As illustrated in FIG. 7, the test case generation device 100 includes a symbolic execution unit 112, an index access detection unit 114, and an index selection unit 116. Furthermore, the test case generation apparatus 100 includes an identical element index information generation unit 118, an identical element determination unit 120, an index equivalent condition generation unit 122, and an index equivalence determination unit 124.

シンボリック実行部112は、上述したテストケース生成装置10のシンボリック実行部12(図1参照)に対応している。なお、シンボリック実行部112は、シンボリック実行部12と有している機能は同じであるが、有している種々の機能を実現するための機能部を備える。本実施例のシンボリック実行部112は、プログラム実行部140、パス条件計算部142、及び充足可能性判定部144を備えている。   The symbolic execution unit 112 corresponds to the symbolic execution unit 12 (see FIG. 1) of the test case generation apparatus 10 described above. The symbolic execution unit 112 has the same functions as the symbolic execution unit 12, but includes functional units for realizing various functions. The symbolic execution unit 112 of this embodiment includes a program execution unit 140, a path condition calculation unit 142, and a satisfiability determination unit 144.

プログラム実行部140は、シンボリック実行対象であるプログラム111(以下、「対象プログラム」という)に対して、シンボリック実行を行う機能を有する。パス条件計算部142は、インデックス選択部116により選択されたインデックス値に対応する要素(シンボル値)が通過するパスを表すパス条件126を計算することによりパス条件126を生成する機能を有する。充足可能性判定部144は、インデックス選択部116により選択されたインデックス値がパス条件126を充足する可能性の有無を判定する機能を有する。シンボリック実行部112は、パス条件126と充足可能性判定結果146とを含むテストケース133を出力する。   The program execution unit 140 has a function of performing symbolic execution on a program 111 that is a symbolic execution target (hereinafter referred to as “target program”). The path condition calculation unit 142 has a function of generating a path condition 126 by calculating a path condition 126 representing a path through which an element (symbol value) corresponding to the index value selected by the index selection unit 116 passes. The satisfiability determination unit 144 has a function of determining whether or not the index value selected by the index selection unit 116 may satisfy the path condition 126. The symbolic execution unit 112 outputs a test case 133 including the path condition 126 and the satisfiability determination result 146.

インデックスアクセス検出部114は、上述したテストケース生成装置10のインデックスアクセス検出部14(図1参照)に対応している。また、インデックス選択部116は、上述したテストケース生成装置10のインデックス選択部16(図1参照)に対応している。また、同一要素インデックス情報生成部118は、上述したテストケース生成装置10の同一要素インデックス情報生成部18(図1参照)に対応している。また、同一要素判定部120は、上述したテストケース生成装置10の同一要素判定部20(図1参照)に対応している。さらに、インデックス等価条件生成部122は、上述したテストケース生成装置10のインデックス等価条件生成部22(図1参照)に対応している。テストケース生成装置100が有するこれらの各機能部は、それぞれ対応するテストケース生成装置10の各機能部と同様の機能を有している。   The index access detection unit 114 corresponds to the index access detection unit 14 (see FIG. 1) of the test case generation device 10 described above. The index selection unit 116 corresponds to the index selection unit 16 (see FIG. 1) of the test case generation device 10 described above. The same element index information generation unit 118 corresponds to the same element index information generation unit 18 (see FIG. 1) of the test case generation apparatus 10 described above. Moreover, the same element determination part 120 respond | corresponds to the same element determination part 20 (refer FIG. 1) of the test case production | generation apparatus 10 mentioned above. Furthermore, the index equivalent condition generation unit 122 corresponds to the index equivalent condition generation unit 22 (see FIG. 1) of the test case generation apparatus 10 described above. Each of these functional units included in the test case generation device 100 has the same function as each functional unit of the corresponding test case generation device 10.

また、インデックス等価判定部124は、上述したテストケース生成装置10のインデックス等価判定部24(図1参照)に対応している。なお、インデックス等価判定部124は、インデックス等価判定部24と有している機能は同じであるが、有している種々の機能を実現するための機能部を備える。本実施例のインデックス等価判定部124は、チェック対象インデックス特定部150、シンボルインデックス具体化部152、充足可能性判定部154、結果集計部156、及びインデックス選択情報更新部158を備えている。   The index equivalence determination unit 124 corresponds to the index equivalence determination unit 24 (see FIG. 1) of the test case generation apparatus 10 described above. The index equivalence determination unit 124 has the same function as the index equivalence determination unit 24, but includes a function unit for realizing various functions. The index equivalence determining unit 124 of this embodiment includes a check target index specifying unit 150, a symbol index specifying unit 152, a satisfiability determining unit 154, a result counting unit 156, and an index selection information updating unit 158.

チェック対象インデックス特定部150は、同一の要素に対応する未選択のインデックス値をインデックス選択情報128及び同一要素インデックス情報130に基づいて特定する機能を有する。シンボルインデックス具体化部152は、インデックス等価条件132に対してシンボル化されたインデックス(シンボルインデックス)を具体化して制約ソルバとする機能を有する。充足可能性判定部154は、未選択のインデックス値が、制約ソルバ(インデックス等価条件132)を全て充足可能か否かを判定する機能を有する。結果集計部156は、充足可能性判定部154の判定結果を集計する機能を有する。また、インデックス選択情報更新部158は、結果集計部156で集計した集計結果に基づいて、インデックス選択情報128を更新する機能を有する。   The check target index specifying unit 150 has a function of specifying an unselected index value corresponding to the same element based on the index selection information 128 and the same element index information 130. The symbol index materialization unit 152 has a function of materializing an index (symbol index) symbolized with respect to the index equivalence condition 132 to obtain a constraint solver. The satisfiability determining unit 154 has a function of determining whether or not all unselected index values can satisfy the constraint solver (index equivalence condition 132). The result totaling unit 156 has a function of totaling the determination results of the satisfiability determining unit 154. Further, the index selection information update unit 158 has a function of updating the index selection information 128 based on the tabulation results tabulated by the result tabulation unit 156.

なお、テストケース生成装置100及び上述したテストケース生成装置10は、例えば図8に示すコンピュータ60で実現することができる。コンピュータ60はCPU(Central Processing Unit)62、メモリ64、不揮発性の記憶部66、入出力インターフェース(I/F)68、及びネットワークI/F70を備える。CPU62、メモリ64、記憶部66、入出力I/F68、及びネットワークI/F70は、バス71を介して互いに接続されている。入出力I/F68は、外部の入力装置及び出力装置に接続されている。入力装置は、テストケースを生成するための種々の情報を入力するための機能を有する装置であり、具体例としては、キーボードや、マウス等が挙げられる。また、出力装置は、生成されたテストケース133、33等を出力する機能を有する装置であり、具体例としては、ディスプレイ等の各種表示装置やプリンタ等が挙げられる。   Note that the test case generation apparatus 100 and the test case generation apparatus 10 described above can be realized by, for example, a computer 60 shown in FIG. The computer 60 includes a CPU (Central Processing Unit) 62, a memory 64, a nonvolatile storage unit 66, an input / output interface (I / F) 68, and a network I / F 70. The CPU 62, the memory 64, the storage unit 66, the input / output I / F 68, and the network I / F 70 are connected to each other via a bus 71. The input / output I / F 68 is connected to an external input device and output device. The input device is a device having a function for inputting various information for generating a test case, and specific examples include a keyboard and a mouse. The output device is a device having a function of outputting the generated test cases 133, 33 and the like, and specific examples include various display devices such as a display, a printer, and the like.

記憶部66はHDD(Hard Disk Drive)やフラッシュメモリ等によって実現できる。記憶媒体としての記憶部66には、コンピュータ60をテストケース生成装置100、10として機能させるためのテストケース生成プログラム72が記憶されている。CPU62は、テストケース生成プログラム72を記憶部66から読み出してメモリ64に展開し、テストケース生成プログラム72が有する各プロセスを順次実行する。   The storage unit 66 can be realized by an HDD (Hard Disk Drive), a flash memory, or the like. The storage unit 66 as a storage medium stores a test case generation program 72 for causing the computer 60 to function as the test case generation devices 100 and 10. The CPU 62 reads the test case generation program 72 from the storage unit 66 and expands it in the memory 64, and sequentially executes each process of the test case generation program 72.

テストケース生成プログラム72は、シンボリック実行プロセス74、インデックスアクセス検出プロセス76、インデックス選択プロセス78、及び同一要素インデックス情報生成プロセス80を有する。また、テストケース生成プログラム72は、同一要素判定プロセス82、インデックス等価条件生成プロセス84、及びインデックス等価判定プロセス86を有する。   The test case generation program 72 includes a symbolic execution process 74, an index access detection process 76, an index selection process 78, and an identical element index information generation process 80. The test case generation program 72 includes an identical element determination process 82, an index equivalent condition generation process 84, and an index equivalence determination process 86.

CPU62は、シンボリック実行プロセス74を実行することで、シンボリック実行部112、12として動作する。また、CPU62は、インデックスアクセス検出プロセス76を実行することで、インデックスアクセス検出部114、14として動作する。また、CPU62は、インデックス選択プロセス78を実行することで、インデックス選択部116、16として動作する。また、CPU62は、同一要素インデックス情報生成プロセス80を実行することで、同一要素インデックス情報生成部118、18として動作する。また、CPU62は、同一要素判定プロセス82を実行することで、同一要素判定部120、20として動作する。また、CPU62は、インデックス等価条件生成プロセス84を実行することで、インデックス等価条件生成部122、22として動作する。さらに、CPU62は、インデックス等価判定プロセス86を実行することで、インデックス等価判定部124、24として動作する。   The CPU 62 operates as the symbolic execution units 112 and 12 by executing the symbolic execution process 74. Further, the CPU 62 operates as the index access detection units 114 and 14 by executing the index access detection process 76. Further, the CPU 62 operates as the index selection units 116 and 16 by executing the index selection process 78. Further, the CPU 62 operates as the same element index information generation units 118 and 18 by executing the same element index information generation process 80. The CPU 62 operates as the same element determination units 120 and 20 by executing the same element determination process 82. Further, the CPU 62 operates as the index equivalent condition generation units 122 and 22 by executing the index equivalent condition generation process 84. Further, the CPU 62 operates as the index equivalence judgment units 124 and 24 by executing the index equivalence judgment process 86.

これにより、テストケース生成プログラム72を実行したコンピュータ60が、テストケース生成装置100、10として機能する。   As a result, the computer 60 that has executed the test case generation program 72 functions as the test case generation apparatuses 100 and 10.

なお、テストケース生成装置100、10は、例えば半導体集積回路、より詳しくはASIC(Application Specific Integrated Circuit)等で実現することも可能である。   Note that the test case generation apparatuses 100 and 10 can be realized by, for example, a semiconductor integrated circuit, more specifically, an ASIC (Application Specific Integrated Circuit) or the like.

次に、本実施例に係るテストケース生成装置100による作用を、具体例として、図9に示したプログラム(TargetClass.method1)のテストケース133を生成する場合について説明する。図9には、プログラム(TargetClass.method1)の具体例を示す。また、図10には、図9に示したプログラムのフローを表したフロー図を示す。なお、図10に示したフロー図の記号内の数字は、プログラムの行に対応している。   Next, a case where the test case 133 of the program (TargetClass.method1) shown in FIG. 9 is generated will be described as an example of the operation of the test case generation apparatus 100 according to the present embodiment. FIG. 9 shows a specific example of the program (TargetClass.method1). FIG. 10 is a flow chart showing the flow of the program shown in FIG. The numbers in the symbols in the flowchart shown in FIG. 10 correspond to the program lines.

まず、テストケース生成装置100で実行されるテストケース生成処理の全体の流れについて説明する。図11は、テストケース生成装置100で実行されるテストケース生成処理の一例を示すフローチャートである。図11に示したテストケース生成処理は、入出力I/F68等を介して、ユーザ等からテストケースの生成を指示された場合に実行される。   First, the overall flow of the test case generation process executed by the test case generation apparatus 100 will be described. FIG. 11 is a flowchart illustrating an example of a test case generation process executed by the test case generation apparatus 100. The test case generation process illustrated in FIG. 11 is executed when a user or the like is instructed to generate a test case via the input / output I / F 68 or the like.

ステップS100では、詳細を後述するシンボリック実行処理を、テストケース生成装置100の各機能部が、シンボリック実行対象111のプログラム(図9参照)に対して行う。シンボリック実行処理により、テストケース133が生成される。   In step S100, each functional unit of the test case generation device 100 performs symbolic execution processing, which will be described in detail later, on the program (see FIG. 9) of the symbolic execution target 111. A test case 133 is generated by the symbolic execution process.

なお、本実施例では、具体例として、対象プログラムは、入出力I/F68または、ネットワークI/F70を介してメモリ64に格納される。   In the present embodiment, as a specific example, the target program is stored in the memory 64 via the input / output I / F 68 or the network I / F 70.

次のステップS102では、テストケース生成装置100が、入出力I/F68等を介して生成されたテストケース133を出力した後、本処理を終了する。   In the next step S102, the test case generation device 100 outputs the test case 133 generated via the input / output I / F 68 or the like, and then ends this process.

本実施例のテストケース生成装置100で、生成されて出力される図9に示したプログラムのテストケース133を図12に示す。   FIG. 12 shows a test case 133 of the program shown in FIG. 9 that is generated and output by the test case generation apparatus 100 of the present embodiment.

次に、テストケース生成処理のステップS100のシンボリック実行処理について説明する。図13は、テストケース生成装置100で実行されるシンボリック実行処理(図11、ステップS100)の一例を示すフローチャートである。   Next, the symbolic execution process in step S100 of the test case generation process will be described. FIG. 13 is a flowchart illustrating an example of symbolic execution processing (FIG. 11, step S100) executed by the test case generation device 100.

まず、ステップS200では、シンボリック実行部112が、シンボリック実行を開始するための処理として初期化を行う。初期化の手順を手順1として説明する。図14は、本実施例のテストケース生成装置100で実行される手順1を説明するための図である。   First, in step S200, the symbolic execution unit 112 performs initialization as processing for starting symbolic execution. The initialization procedure will be described as procedure 1. FIG. 14 is a diagram for explaining the procedure 1 executed by the test case generation apparatus 100 according to the present embodiment.

対象プログラムでは、具体例として、06行目までは、シンボル変数が関係しないため、実行パスの分岐が生じない。そのため、シンボリック実行部112が、対象プログラムを06行目まで実行する。   In the target program, as a specific example, up to the 06th line, since the symbol variable is not related, the branch of the execution path does not occur. Therefore, the symbolic execution unit 112 executes the target program up to the 06th line.

次のステップS202では、シンボリック実行部112が対象プログラムに後続の命令が存在するか否かを判定し、後続する命令が有る場合は、ステップS204へ移行する。   In the next step S202, the symbolic execution unit 112 determines whether or not a subsequent instruction exists in the target program. If there is a subsequent instruction, the process proceeds to step S204.

ステップS204では、シンボリック実行部112が対象プログラムの命令を解析し、さらに次のステップS206では、各機能部により分岐選択処理が実行される。図15は、ステップS206の分岐選択処理の一例を示すフローチャートである。   In step S204, the symbolic execution unit 112 analyzes the instruction of the target program, and in the next step S206, branch selection processing is executed by each functional unit. FIG. 15 is a flowchart illustrating an example of the branch selection process in step S206.

ステップS300では、インデックスアクセス検出部114が、シンボル変数による配列アクセスであるか否かを判定する。シンボル変数ではない場合は、ステップS310へ移行する。シンボル変数である場合は、ステップS302へ移行する。ステップS300の処理の手順を手順2として説明する。図16は、本実施例のテストケース生成装置100で実行される手順2を説明するための図である。   In step S300, the index access detection unit 114 determines whether or not the array access is based on symbol variables. If it is not a symbol variable, the process proceeds to step S310. If it is a symbol variable, the process proceeds to step S302. The procedure of step S300 will be described as procedure 2. FIG. 16 is a diagram for explaining the procedure 2 executed by the test case generation apparatus 100 according to the present embodiment.

シンボリック実行部112は、07行目の命令「07:value = array[α]」が配列アクセス命令のオペランドがシンボル値であるか否かを確認する。なお、簡略化のため、array[α]と記載しているが、配列(array)のメモリ状態は、{a1,b1,b2,b1,b1,a1}であるため、正確には、{a1,b1,b2,b1,b1,a1}[α]と記載すべきである。より正確には、a1,b1,b2もヒープへの参照IDとすべきであるが、説明の便宜上、上記のように簡略化する。   The symbolic execution unit 112 checks whether or not the instruction “07: value = array [α]” on the 07th line is a symbol value as an operand of the array access instruction. For simplicity, array [α] is described. However, since the memory state of the array is {a1, b1, b2, b1, b1, a1}, exactly {a1 , B1, b2, b1, b1, a1} [α]. More precisely, a1, b1, and b2 should also be reference IDs to the heap, but are simplified as described above for convenience of explanation.

シンボル変数を使用しないアクセスであれば、シンボリック実行部112は、通常のシンボリック実行を継続するため、ステップS300からステップS310へ移行する。ステップS310では、分岐発生の有無を判定し、分岐が発生していない場合は、本分岐選択処理を終了する。一方、分岐が発生している場合は、ステップS312へ移行する。ステップS312でシンボリック実行部12は、命令に従い分岐を選択した後、本分岐選択処理を終了する。   If the access does not use a symbol variable, the symbolic execution unit 112 proceeds from step S300 to step S310 in order to continue normal symbolic execution. In step S310, it is determined whether or not a branch has occurred. If no branch has occurred, the branch selection process ends. On the other hand, if a branch has occurred, the process proceeds to step S312. In step S312, the symbolic execution unit 12 selects a branch according to the instruction, and then ends the branch selection process.

一方、シンボリック実行部112が、シンボル変数を使用するアクセスであると判定した場合は、ステップS302へ移行する。   On the other hand, if the symbolic execution unit 112 determines that the access uses symbol variables, the process proceeds to step S302.

ステップS302では、テストケース生成装置100がインデックス情報の有無を判定する。具体的には、テストケース生成装置100は、インデックス選択情報128及び同一要素インデックス情報130の両方が存在するか否かを判定する。インデックス選択情報128及び同一要素インデックス情報130の少なくとも一方が存在しない場合は、ステップS304へ移行する。ステップS304では、同一要素インデックス情報生成部118が同一要素インデックス情報130を生成する。次のステップS306では、インデックス選択部16がインデックス選択情報128を生成する。ステップS304及びS306の処理の手順を手順3として説明する。図17は、本実施例のテストケース生成装置100で実行される手順3を説明するための図である。   In step S302, the test case generation device 100 determines whether there is index information. Specifically, the test case generation device 100 determines whether both the index selection information 128 and the same element index information 130 exist. If at least one of the index selection information 128 and the same element index information 130 does not exist, the process proceeds to step S304. In step S304, the same element index information generation unit 118 generates the same element index information 130. In the next step S306, the index selection unit 16 generates index selection information 128. The procedure of steps S304 and S306 will be described as procedure 3. FIG. 17 is a diagram for explaining the procedure 3 executed by the test case generation apparatus 100 according to the present embodiment.

同一要素インデックス情報生成部118は、同一要素判定部120の判定結果に基づいて、ヒープ上の同じオブジェクトを参照しているものをまとめることにより、同一要素インデックス情報130を生成する。本実施例の同一要素インデックス情報生成部118は、配列の各要素の中で、インデックス値が同じものとして、ヒープ上の同じオブジェクトを参照しているものをまとめる。同一要素インデックス情報130のNo.1は、配列(array)の0番目と5番目は、内容的に同じ要素を有することを表している。また、No.2は、配列(array)の1番目、3番目、及び4番目は、内容的に同じ要素を有することを表している。さらにNo.3は、配列(array)の2番目は、内容的に同じ要素を有するものがないことを表している。   The same element index information generation unit 118 generates the same element index information 130 by collecting items that refer to the same object on the heap based on the determination result of the same element determination unit 120. The same element index information generation unit 118 of the present embodiment collects elements in the array that refer to the same object on the heap, assuming that the index values are the same. No. of the same element index information 130. 1 indicates that the 0th and 5th elements of the array have the same elements in terms of content. No. 2 indicates that the first, third, and fourth elements of the array have the same elements. Furthermore, no. 3 represents that the second of the array does not have the same content element.

なお、ここで、同一要素判定部120が同一要素であるか否かについて判定する判定基準は予め定めておき、記憶部66やメモリ64等に記憶しておけばよい。判定基準は、本実施例に限らず、属性やオブジェクト等に応じて可変であり、対象プログラムのテストを行いたい観点等に基づいて定めることができる。例えば、要素「a」、「b」という観点を判定基準として、同一要素インデックス情報生成部118が同一要素インデックス情報を生成した場合は、図18に示した同一要素インデックス情報130Aが生成される。   Here, determination criteria for determining whether or not the same element determination unit 120 is the same element may be determined in advance and stored in the storage unit 66, the memory 64, or the like. The determination criteria are not limited to the present embodiment, but can be changed according to attributes, objects, and the like, and can be determined based on the viewpoint of testing the target program. For example, when the same element index information generation unit 118 generates the same element index information using the viewpoints of the elements “a” and “b” as the determination criteria, the same element index information 130A illustrated in FIG. 18 is generated.

また、インデックス選択部116は、インデックス選択情報128を生成する。ここでは、インデックス選択情報128を生成したばかりであり、いずれのインデックス値も選択されていないため、インデックス選択情報128は、全てのインデックス値が未選択(初期化)の状態となる。   Further, the index selection unit 116 generates index selection information 128. Here, since the index selection information 128 has just been generated and no index value has been selected, all the index values of the index selection information 128 are not selected (initialized).

ステップS306の次、または、ステップS302でインデックス情報が有ると判定した場合に移行するステップS308では、インデックス選択部116が未選択のインデックス値を選択した後、本分岐選択処理を終了する。ステップS308の処理の手順を手順4として説明する。図19は、本実施例のテストケース生成装置100で実行される手順4を説明するための図である。   Subsequent to step S306 or in step S308, which is shifted when it is determined that there is index information in step S302, the index selection unit 116 selects an unselected index value, and then ends the branch selection process. The procedure of step S308 will be described as procedure 4. FIG. 19 is a diagram for explaining the procedure 4 executed by the test case generation device 100 of the present embodiment.

インデックス選択部116は、インデックス選択情報128を参照し、未選択のインデックス値の中から一つ選択し、選択したインデックス値を選択済とする。図19は、インデックス選択部116がインデックス値「0」を選択した状態を示している。インデックス選択部116は、選択したインデックス値をシンボリック実行部112に出力する。なお、インデックス選択部116がいずれのインデックス値を選択するかは任意である。シンボリック実行部112は、インデックス選択部116が選択したインデックス値に対応する分岐を作成し、実行する。   The index selection unit 116 refers to the index selection information 128, selects one of the unselected index values, and sets the selected index value as selected. FIG. 19 shows a state in which the index selection unit 116 has selected the index value “0”. The index selection unit 116 outputs the selected index value to the symbolic execution unit 112. Note that it is arbitrary which index value the index selection unit 116 selects. The symbolic execution unit 112 creates and executes a branch corresponding to the index value selected by the index selection unit 116.

このようにしてステップS206の分岐選択処理が終了すると、ステップS208へ進む。   When the branch selection process in step S206 is completed in this way, the process proceeds to step S208.

ステップS208では、シンボリック実行部112が、インデックス選択部116により選択されたインデックス値に応じたパス条件を計算して生成する。シンボリック実行部112は、計算したパス条件に基づいて、各制約(制約ソルバ)がどの分岐に由来するものかを表す対応関係をメモリ64等に記憶しておく。   In step S208, the symbolic execution unit 112 calculates and generates a path condition corresponding to the index value selected by the index selection unit 116. The symbolic execution unit 112 stores, in the memory 64 or the like, a correspondence relationship indicating which branch each constraint (constraint solver) is derived from based on the calculated path condition.

次のステップS210では、シンボリック実行部112は、ステップS208で得たパス条件を充足可能であるか否かを判定する。充足不可能である場合は、ステップS218へ移行する。一方、充足可能である場合は、ステップS212へ移行する。ステップS212では、シンボリック実行部12が対象プログラムの命令を実行した後、ステップS202に戻る。   In the next step S210, the symbolic execution unit 112 determines whether or not the path condition obtained in step S208 can be satisfied. If it cannot be satisfied, the process proceeds to step S218. On the other hand, if it can be satisfied, the process proceeds to step S212. In step S212, after the symbolic execution unit 12 executes the instruction of the target program, the process returns to step S202.

ステップS202で、後続の命令が存在しない場合は、ステップS214へ移行する。ステップS214では、シンボリック実行部112が、テストケースを生成する。具体的には、シンボリック実行部112は、インデックス選択部116で選択されたインデックス値に対応するテストケースを生成する。   If there is no subsequent instruction in step S202, the process proceeds to step S214. In step S214, the symbolic execution unit 112 generates a test case. Specifically, the symbolic execution unit 112 generates a test case corresponding to the index value selected by the index selection unit 116.

次のステップS216では、インデックス情報更新処理を行う。図20は、ステップS216の情報更新処理の一例を示すフローチャートである。   In the next step S216, index information update processing is performed. FIG. 20 is a flowchart illustrating an example of the information update process in step S216.

ステップS400では、インデックス等価条件生成部122が、ステップS214で生成したテストケースがシンボル変数による配列アクセスが関係するテストケースであるか否かを判定する。本実施例では、シンボリック実行部112は、上記ステップS208の処理で記憶しておいた、対応関係に基づいて、パス条件の各制約式が由来する命令を取得し、取得した命令が配列アクセス命令であるか否かを確認する。配列アクセスが関係するテストケースではない場合は、本インデックス情報更新処理を終了する。一方、配列アクセスが関係するテストケースである場合は、ステップS402へ移行する。   In step S400, the index equivalent condition generation unit 122 determines whether or not the test case generated in step S214 is a test case related to array access using symbol variables. In this embodiment, the symbolic execution unit 112 acquires an instruction derived from each constraint expression of the path condition based on the correspondence relationship stored in the process of step S208, and the acquired instruction is an array access instruction. It is confirmed whether or not. If the test case is not related to array access, the index information update process is terminated. On the other hand, if the test case involves array access, the process proceeds to step S402.

ステップS402では、インデックス等価条件生成部122がインデックス等価条件132を計算する。本実施例では、計算したインデックス等価条件132は、少なくとも、下記のステップS406の処理まで、保持する必要があるため、メモリ64等に記憶しておく。テップS402の処理の手順を手順5として説明する。図21は、本実施例のテストケース生成装置100で実行される手順5を説明するための図である。インデックス等価条件生成部122は、インデックス選択を含むパス毎に、インデックス等価条件132を計算する。具体的には、パス条件からインデックス値によるアクセス由来の制約を除いたものがインデックス等価条件132である。図21に示した例では、インデックス値「0」の場合、No.1のテストケースは、テスト入力が「idx(α):0、n(β):4」、「パス条件が「α==0 && β>3」である。この場合は、インデックス値に由来する「α==0」を除いたものがインデックス等価条件132となるため、インデックス等価条件132は、「β>3」となる。また、No.2のテストケースは、テスト入力が「idx(α):0、n(β):0」、「パス条件が「α==0 && β<=3」である。この場合は、インデックス値に由来する「α==0」を除いたものがインデックス等価条件132となるため、インデックス等価条件132は、「β<=3」となる。   In step S402, the index equivalent condition generation unit 122 calculates the index equivalent condition 132. In the present embodiment, the calculated index equivalence condition 132 needs to be held at least until the processing in step S406 below, and is stored in the memory 64 or the like. The procedure of step S402 will be described as procedure 5. FIG. 21 is a diagram for explaining the procedure 5 executed by the test case generation apparatus 100 according to the present embodiment. The index equivalent condition generation unit 122 calculates an index equivalent condition 132 for each path including index selection. Specifically, the index equivalence condition 132 is obtained by removing the restriction derived from the access by the index value from the path condition. In the example shown in FIG. 21, when the index value is “0”, No. In the test case 1, the test input is “idx (α): 0, n (β): 4”, and the path condition is “α == 0 && β> 3”. In this case, since the index equivalent condition 132 is obtained by excluding “α == 0” derived from the index value, the index equivalent condition 132 is “β> 3”. No. In the test case 2, the test input is “idx (α): 0, n (β): 0”, and the path condition is “α == 0 && β <= 3”. In this case, since the index equivalent condition 132 is obtained by excluding “α == 0” derived from the index value, the index equivalent condition 132 is “β <= 3”.

次のステップS404では、インデックス等価判定部124は、注目するインデックス値選択について以降の全状態を探索済みであるか否かを判定する。すなわち、インデックス等価判定部124は、インデックス選択部116で選択し、テストケースを生成したインデックス値について、全状態の探索が済んでいるか否かを判定する。探索済みでない場合は、本インデックス情報更新処理を終了する。一方、探索済みの場合は、ステップS406へ移行する。   In the next step S404, the index equivalence determination unit 124 determines whether or not all subsequent states have been searched for the index value selection to be noticed. That is, the index equivalence determination unit 124 determines whether or not the search of all states has been completed for the index value selected by the index selection unit 116 and for which the test case is generated. If the search has not been completed, the index information update process is terminated. On the other hand, if the search has been completed, the process proceeds to step S406.

ステップS406では、インデックス等価判定部124が、未選択かつ注目するインデックス値と同じ要素が格納されているインデックス値を取得する。次のステップS408では、インデックス等価判定部124が、インデックス選択情報128において、取得したインデックス値のうち、インデックス等価条件132を満たすものを選択済にする。ステップS408の処理によりインデックス等価判定部124がインデックス選択情報128を更新した後、本インデックス情報更新処理を終了する。   In step S406, the index equivalence determination unit 124 acquires an index value in which the same element as the index value that has not been selected and is noticed is stored. In the next step S <b> 408, the index equivalence determining unit 124 selects the acquired index values satisfying the index equivalence condition 132 in the index selection information 128. After the index equivalence determination unit 124 updates the index selection information 128 by the process of step S408, the index information update process ends.

ステップS406及びS408の処理の手順を手順6として説明する。図22は、本実施例のテストケース生成装置100で実行される手順6を説明するための図である。インデックス等価判定部124は、同一要素インデックス情報130を参照し、選択(注目)したインデックス値と要素が同一のインデックス値を取得する。上述した具体例のように、インデックス値「0」を選択(注目)している場合、インデックス等価判定部124は、同一要素インデックス情報130を参照し、同じ「a1」を要素とする、インデックス値「5」を取得する。なお、この時点では、インデックス選択情報128において、インデックス値「5」は、未選択状態である。   The procedure of steps S406 and S408 will be described as procedure 6. FIG. 22 is a diagram for explaining the procedure 6 executed by the test case generation apparatus 100 according to the present embodiment. The index equivalence determination unit 124 refers to the same element index information 130 and acquires an index value having the same element as the selected (attention) index value. When the index value “0” is selected (attention) as in the specific example described above, the index equivalence determination unit 124 refers to the same element index information 130 and uses the same “a1” as an element. Obtain “5”. At this time, the index value “5” in the index selection information 128 is not selected.

さらに、インデックス等価判定部124は、上記ステップS402(手順5)で計算したインデックス等価条件132の全てをインデックス値「5」の場合に充足可能か否かを判定する。具体的には、インデックス等価判定部124は、インデックス等価条件132に、インデックス値に由来する制約である「α==5」を付加して制約ソルバを生成する。そして、インデックス等価判定部124は、インデックス値「5」の場合に、生成した全ての制約ソルバを充足可能か否かを判定する。インデックス値「5」の場合は、全ての制約ソルバを充足する。これは、インデックス値「0」の場合と、インデックス値「5」の場合とでは、同じパスを通過することを意味している。そのため、本実施例のテストケース生成装置100では、インデックス値「5」については、探索を行わず、テストケースを生成しない。そのため、インデックス等価判定部124は、インデックス選択情報128において、インデックス値「5」を選択済にして更新する。   Furthermore, the index equivalence determination unit 124 determines whether or not all of the index equivalence conditions 132 calculated in step S402 (procedure 5) can be satisfied when the index value is “5”. Specifically, the index equivalence determination unit 124 adds “α == 5” that is a constraint derived from the index value to the index equivalence condition 132 to generate a constraint solver. Then, the index equivalence determination unit 124 determines whether or not all the generated constraint solvers can be satisfied when the index value is “5”. When the index value is “5”, all constraint solvers are satisfied. This means that the same path is passed for the index value “0” and the index value “5”. Therefore, the test case generation apparatus 100 of the present embodiment does not search for the index value “5” and does not generate a test case. Therefore, the index equivalence determination unit 124 updates the index value “5” with the index value “5” selected in the index selection information 128.

このようにしてステップS216のインデックス情報更新処理が終了すると、ステップS218へ進む。   When the index information update process in step S216 is completed in this way, the process proceeds to step S218.

ステップS218では、シンボリック実行部112がバックトラック先の有無を判定する。図23は、ステップS218におけるバックトラック先判定処理の一例を示すフローチャートである。   In step S218, the symbolic execution unit 112 determines whether there is a backtrack destination. FIG. 23 is a flowchart illustrating an example of the backtrack destination determination process in step S218.

ステップS500では、シンボリック実行部112が、対象プログラムが開始状態であるか否かを判定する。開始状態である場合は、バックトラック先が無いとして、本バックトラック先判定処理を終了する。一方、開始状態ではない場合は、ステップS502へ移行する。   In step S500, the symbolic execution unit 112 determines whether the target program is in a start state. If it is in the start state, it is determined that there is no backtrack destination, and the backtrack destination determination process is terminated. On the other hand, if it is not in the start state, the process proceeds to step S502.

ステップS502では、シンボリック実行部112がシンボル変数による配列アクセスであるか否かを判定する。シンボル変数による配列アクセスである場合は、ステップS504へ移行する。ステップS502及びS504の処理の手順を手順7として説明する。図24は、本実施例のテストケース生成装置100で実行される手順7を説明するための図である。図24(1)は、上述した具体例のように、インデックス値「0」、「5」が選択済となっている場合のインデックス選択情報128を示している。また、図24(2)は、具体例として、全てのインデックス値が選択済となっている場合のインデックス選択情報128を示している。   In step S502, the symbolic execution unit 112 determines whether or not the array access is based on symbol variables. In the case of array access using symbol variables, the process proceeds to step S504. The procedure of steps S502 and S504 will be described as procedure 7. FIG. 24 is a diagram for explaining the procedure 7 executed by the test case generation device 100 of the present embodiment. FIG. 24 (1) shows the index selection information 128 when the index values “0” and “5” are already selected as in the specific example described above. FIG. 24 (2) shows the index selection information 128 when all index values have been selected as a specific example.

シンボル変数による配列アクセスであり、未選択のインデックス値がある場合、すなわち、図24(1)の場合は、ステップS504の判定により、バックトラック先が有るとして本バックトラック先判定処理を終了する。一方、シンボル変数による配列アクセスであり、未選択のインデックス値が無い場合、すなわち、図24(2)の場合は、配列アクセスの前の命令までバックトラックするために、ステップS506へ移行する。   In the case of array access by symbol variables and there is an unselected index value, that is, in the case of FIG. 24 (1), the backtrack destination determination processing is terminated by determining in step S504 that there is a backtrack destination. On the other hand, in the case of array access using symbol variables and there is no unselected index value, that is, in the case of FIG. 24 (2), the process proceeds to step S506 in order to backtrack to the instruction before the array access.

ステップS506で、シンボリック実行部112が、直前の状態に戻った後、ステップS500に戻る。ステップS500でプログラム開始状態ではなく、また、ステップS502でシンボル変数による配列アクセスでは無い場合は、ステップS508へ移行する。ステップS508では、シンボリック実行部112が、未選択の分岐の有無を判定する。全て選択済の場合等は、ステップS506へ移行し、本バックトラック先判定処理を繰り返す。一方、未選択の分岐がある場合は、バックトラック先が有るとして本バックトラック先判定処理を終了する。   In step S506, the symbolic execution unit 112 returns to the previous state, and then returns to step S500. If it is not in the program start state in step S500, and if it is not array access by symbol variables in step S502, the process proceeds to step S508. In step S508, the symbolic execution unit 112 determines whether there is an unselected branch. If all have been selected, the process moves to step S506, and the backtrack destination determination process is repeated. On the other hand, if there is an unselected branch, it is determined that there is a backtrack destination, and this backtrack destination determination processing is terminated.

このようにしてステップS218のバックトラック先判定処理が終了すると、バックトラック先が無い場合は、対象プログラムの全てのテストケース(テストケース133)を生成したため、本シンボリック実行処理を終了する。一方、パックトラック先がある場合は、ステップS220へ移行し、シンボリック実行部112が、バックトラック先にバックトラックした後、ステップS204へ移行し、本シンボリック実行処理を繰り返す。   When the backtrack destination determination processing in step S218 is completed in this way, if there is no backtrack destination, all test cases (test case 133) of the target program have been generated, and thus this symbolic execution processing ends. On the other hand, if there is a pack track destination, the process proceeds to step S220, where the symbolic execution unit 112 backtracks to the backtrack destination, then proceeds to step S204, and repeats this symbolic execution process.

上記では具体例として、インデックス値「0」、「5」が選択済となった状態について説明した。この具体例の場合は、ステップS218からステップS220、ステップS204を経由してステップS206の分岐選択処理を再び行う。分岐選択処理(図15参照)では、ステップS300で肯定され、さらにステップS302で肯定されるため、ステップS308に移行する。この場合の、ステップS308の処理である手順4(2回目)について説明する。図25は、本実施例のテストケース生成装置100で実行される手順4(2回目)を説明するための図である。上述の処理により、インデックス値「0」については、テストケースが生成されており、パス条件126を満たすインデックス値「5」も選択状態となっている。インデックス選択部116は、インデックス選択情報128を参照し、未選択のインデックス値「1」を選択し、選択済にする。   In the above, as a specific example, the state where the index values “0” and “5” have been selected has been described. In this specific example, the branch selection process in step S206 is performed again from step S218 through step S220 and step S204. In the branch selection process (see FIG. 15), the result is affirmative in step S300 and further affirmed in step S302, so the process proceeds to step S308. The procedure 4 (second time) that is the process of step S308 in this case will be described. FIG. 25 is a diagram for explaining the procedure 4 (second time) executed by the test case generation device 100 of the present embodiment. With the above processing, a test case is generated for the index value “0”, and the index value “5” that satisfies the path condition 126 is also selected. The index selection unit 116 refers to the index selection information 128, selects an unselected index value “1”, and makes it selected.

このように未選択のインデックス値をインデックス選択部116が選択することにより、シンボリック実行部112は、新たにインデックス値「0」に対応するパスを実行し、テストケースを生成する。そのため、シンボリック実行処理(図13参照)を継続し、ステップS214において、インデックス値「0」に対応するテストケースを生成する。具体的には、シンボリック実行部112は、図12に示したテストケース133のうち、No.3のテストケースを生成する。テストケースの生成後、ステップS216に進み、インデックス情報更新処理を行う。インデックス情報更新処理では、インデックス等価条件生成部122が上述した手順5(図20、ステップS402)によりインデックス等価条件132を生成する。図26は、本実施例のテストケース生成装置100で実行される手順5(2回目)を説明するための図である。   When the index selection unit 116 selects an unselected index value in this way, the symbolic execution unit 112 newly executes a path corresponding to the index value “0” to generate a test case. Therefore, the symbolic execution process (see FIG. 13) is continued, and a test case corresponding to the index value “0” is generated in step S214. Specifically, the symbolic execution unit 112 selects No. 1 among the test cases 133 shown in FIG. 3 test cases are generated. After the test case is generated, the process proceeds to step S216 to perform index information update processing. In the index information update process, the index equivalent condition generation unit 122 generates the index equivalent condition 132 by the above-described procedure 5 (FIG. 20, step S402). FIG. 26 is a diagram for explaining the procedure 5 (second time) executed by the test case generation device 100 of the present embodiment.

図26に示した例では、インデックス値「1」の場合、No.3のテストケースは、テスト入力が「idx(α):1、n(β):0」、「パス条件が「α==1 && α<4」である。この場合は、インデックス値に由来する「α==1」を除いたものがインデックス等価条件132となるため、インデックス等価条件132は、「α<4」となる。   In the example shown in FIG. 26, when the index value is “1”, No. In the test case 3, the test input is “idx (α): 1, n (β): 0”, and the path condition is “α == 1 && α <4”. In this case, since the index equivalent condition 132 is obtained by excluding “α == 1” derived from the index value, the index equivalent condition 132 is “α <4”.

このようにしてインデックス等価条件132が生成されると、インデックス等価判定部124が、手順6(図20、ステップS406及びS408)を行う。図27は、本実施例のテストケース生成装置100で実行される手順6(2回目)を説明するための図である。インデックス等価判定部124は、同一要素インデックス情報130を参照し、選択(注目)したインデックス値と要素が同一のインデックス値を取得する。ここでは、インデックス値「1」を選択(注目)しているため、インデックス等価判定部124は、同一要素インデックス情報130を参照し、同じ「b1」を要素とするインデックス値を取得する。具体的には、インデックス値「3」及び「4」を取得する。なお、この時点では、インデックス選択情報128において、インデックス値「3」、「4」は、未選択状態である。   When the index equivalence condition 132 is generated in this way, the index equivalence determining unit 124 performs the procedure 6 (FIG. 20, steps S406 and S408). FIG. 27 is a diagram for explaining the procedure 6 (second time) executed by the test case generation device 100 of the present embodiment. The index equivalence determination unit 124 refers to the same element index information 130 and acquires an index value having the same element as the selected (attention) index value. Here, since the index value “1” is selected (attention), the index equivalence determination unit 124 refers to the same element index information 130 and acquires an index value having the same “b1” as an element. Specifically, the index values “3” and “4” are acquired. At this time, the index values “3” and “4” in the index selection information 128 are not selected.

さらに、インデックス等価判定部124は、上記ステップS402(手順5(2回目))で計算したインデックス等価条件132の全てをインデックス値「3」及び「4」の場合に、充足可能か否かを判定する。具体的には、インデックス等価判定部124は、インデックス値「3」の場合は、インデックス等価条件132に、インデックス値に由来する制約である「α==3」を付加して制約ソルバを生成する。そして、インデックス等価判定部124は、生成した全ての制約ソルバをインデックス値「3」の場合に充足可能か否かを判定する。インデックス値「3」の場合は、全ての制約ソルバを充足する。これは、インデックス値「1」の場合と、インデックス値「3」の場合とでは、同じパスを通過することを意味している。そのため、本実施例のテストケース生成装置100では、インデックス値「3」については、探索を行わず、テストケースを生成しない。そのため、インデックス等価判定部124は、インデックス選択情報128において、インデックス値「3」を選択済にして更新する。   Further, the index equivalence determination unit 124 determines whether or not all of the index equivalence conditions 132 calculated in step S402 (procedure 5 (second time)) can be satisfied when the index values are “3” and “4”. To do. Specifically, when the index value is “3”, the index equivalence determining unit 124 adds “α == 3” that is a constraint derived from the index value to the index equivalence condition 132 to generate a constraint solver. . Then, the index equivalence determination unit 124 determines whether or not all the generated constraint solvers can be satisfied when the index value is “3”. When the index value is “3”, all constraint solvers are satisfied. This means that the same path is passed for the index value “1” and the index value “3”. Therefore, the test case generation device 100 of the present embodiment does not search for the index value “3” and does not generate a test case. For this reason, the index equivalence determining unit 124 updates the index value “3” in the index selection information 128 with the index value “3” selected.

一方、インデックス値「4」の場合は、インデックス等価条件132に、インデックス値に由来する制約である「α==4」を付加して制約ソルバを生成する。そして、インデックス等価判定部124は、生成した全ての制約ソルバをインデックス値「4」の場合に充足可能か否かを判定する。インデックス値「4」の場合は、充足不能の場合がある。これは、インデックス値「1」の場合と、インデックス値「4」の場合とでは、異なるパスを通過することを意味している。そのため、本実施例のインデックス等価判定部124では、インデックス値「4」については、未選択のままとする。   On the other hand, in the case of the index value “4”, a constraint solver is generated by adding “α == 4”, which is a constraint derived from the index value, to the index equivalence condition 132. Then, the index equivalence determination unit 124 determines whether or not all the generated constraint solvers can be satisfied when the index value is “4”. In the case of the index value “4”, there are cases where it cannot be satisfied. This means that the index value “1” and the index value “4” pass different paths. Therefore, in the index equivalence determination unit 124 of the present embodiment, the index value “4” is left unselected.

このようにしてインデックス等価判定部124がインデックス選択情報128を更新すると、シンボリック実行部112が、手順7(図23、ステップS502及びS504)を行う。図28は、本実施例のテストケース生成装置100で実行される手順7(2回目)を説明するための図である。図28に示したように、インデックス選択情報128には、未選択のインデックス値があるため、上述したように、バックトラックを行い、手順4に戻る。具体例の移行の処理について、上述と同様に、手順4〜7を繰り返すため、以降の処理については、手順に従って、簡略に説明する。   When the index equivalence determining unit 124 updates the index selection information 128 in this way, the symbolic execution unit 112 performs the procedure 7 (FIG. 23, steps S502 and S504). FIG. 28 is a diagram for explaining the procedure 7 (second time) executed by the test case generation device 100 of the present embodiment. As shown in FIG. 28, since there is an unselected index value in the index selection information 128, backtracking is performed as described above, and the procedure returns to step 4. Since the procedures 4 to 7 are repeated in the same way as described above for the migration processing of the specific example, the subsequent processing will be briefly described according to the procedure.

図29は、本実施例のテストケース生成装置100で実行される手順4(3回目)を説明するための図である。上述の処理により、インデックス値「0」、「1」、「3」、及び「5」が選択状態となっている。インデックス選択部116は、インデックス選択情報128を参照し、未選択のインデックス値「2」を選択し、選択済にする。シンボリック実行部112は、新たにインデックス値「2」に対応するパスを実行し、テストケースを生成する。シンボリック実行部112は、インデックス値「2」に対応して、図12に示したテストケース133のうち、No.4及び5のテストケースを生成する。   FIG. 29 is a diagram for explaining the procedure 4 (third time) executed by the test case generation device 100 of the present embodiment. Through the above-described processing, the index values “0”, “1”, “3”, and “5” are selected. The index selection unit 116 refers to the index selection information 128, selects the unselected index value “2”, and makes it selected. The symbolic execution unit 112 newly executes a path corresponding to the index value “2” to generate a test case. The symbolic execution unit 112 corresponds to the index value “2” in the test case 133 shown in FIG. Generate test cases 4 and 5.

テストケースの生成後、手順5(3回目)によりインデックス等価条件132を生成する。図30は、本実施例のテストケース生成装置100で実行される手順5(3回目)を説明するための図である。   After the test case is generated, the index equivalent condition 132 is generated by the procedure 5 (third time). FIG. 30 is a diagram for explaining the procedure 5 (third time) executed by the test case generation device 100 of the present embodiment.

図30に示した例では、インデックス値「2」の場合、No.4のテストケースは、テスト入力が「idx(α):2、n(β):3」、「パス条件が「α==2 && β>3」である。この場合は、インデックス値に由来する「α==2」を除いたものがインデックス等価条件132となるため、インデックス等価条件132は、「β>3」となる。また、No.5のテストケースは、テスト入力が「idx(α):2、n(β):0」、「パス条件が「α==2 && β<=3」である。この場合は、インデックス値に由来する「α==2」を除いたものがインデックス等価条件132となるため、インデックス等価条件132は、「β<=3」となる。   In the example shown in FIG. 30, when the index value is “2”, No. In the test case 4, the test input is “idx (α): 2, n (β): 3”, and the path condition is “α == 2 && β> 3”. In this case, since the index equivalent condition 132 is obtained by excluding “α == 2” derived from the index value, the index equivalent condition 132 is “β> 3”. No. In the test case 5, the test input is “idx (α): 2, n (β): 0”, and the path condition is “α == 2 && β <= 3”. In this case, since the index equivalent condition 132 is obtained by excluding “α == 2” derived from the index value, the index equivalent condition 132 is “β <= 3”.

このようにしてインデックス等価条件132が生成されると、インデックス等価判定部124が、手順6(3回目)を行う。図31は、本実施例のテストケース生成装置100で実行される手順6(3回目)を説明するための図である。インデックス等価判定部124は、同一要素インデックス情報130を参照し、選択(注目)したインデックス値と要素が同一のインデックス値を取得する。インデックス値「2」と要素が同一のインデックス値は存在しない。そのため、インデックス等価判定部124は、インデックス値を取得せず、また、上述した処理も行わない。そのため、インデックス選択情報128は更新前と更新後とで変化しない。   When the index equivalence condition 132 is generated in this way, the index equivalence determining unit 124 performs the procedure 6 (third time). FIG. 31 is a diagram for explaining the procedure 6 (third time) executed by the test case generation device 100 of the present embodiment. The index equivalence determination unit 124 refers to the same element index information 130 and acquires an index value having the same element as the selected (attention) index value. There is no index value having the same element as the index value “2”. For this reason, the index equivalence determination unit 124 does not acquire an index value and does not perform the above-described processing. Therefore, the index selection information 128 does not change before and after the update.

続いてシンボリック実行部112は手順7(3回目)を行う。図32は、本実施例のテストケース生成装置100で実行される手順7(3回目)を説明するための図である。図31に示したように、インデックス選択情報128には、未選択のインデックス値があるため、上述したように、バックトラックを行い、手順4に戻る。   Subsequently, the symbolic execution unit 112 performs step 7 (third time). FIG. 32 is a diagram for explaining the procedure 7 (third time) executed by the test case generation device 100 of the present embodiment. As shown in FIG. 31, since the index selection information 128 includes an unselected index value, backtracking is performed as described above, and the procedure returns to step 4.

図33は、本実施例のテストケース生成装置100で実行される手順4(4回目)を説明するための図である。上述の処理により、インデックス値「0」、「1」、「2」、「3」、及び「5」が選択状態となっている。インデックス選択部116は、インデックス選択情報128を参照し、未選択のインデックス値「4」を選択し、選択済にする。シンボリック実行部112は、新たにインデックス値「4」に対応するパスを実行し、テストケースを生成する。シンボリック実行部112は、インデックス値「4」に対応して、図12に示したテストケース133のうち、No.6及び7のテストケースを生成する。   FIG. 33 is a diagram for explaining the procedure 4 (fourth) executed by the test case generation device 100 of the present embodiment. As a result of the above processing, the index values “0”, “1”, “2”, “3”, and “5” are selected. The index selection unit 116 refers to the index selection information 128, selects the unselected index value “4”, and makes it selected. The symbolic execution unit 112 newly executes a path corresponding to the index value “4” to generate a test case. The symbolic execution unit 112 corresponds to the index value “4” in the test case 133 shown in FIG. 6 and 7 test cases are generated.

テストケースの生成後、手順5(4回目)によりインデックス等価条件132を生成する。図34は、本実施例のテストケース生成装置100で実行される手順5(4回目)を説明するための図である。   After the test case is generated, the index equivalent condition 132 is generated by the procedure 5 (fourth time). FIG. 34 is a diagram for explaining the procedure 5 (fourth time) executed by the test case generation device 100 of the present embodiment.

図34に示した例では、インデックス値「4」の場合、No.6のテストケースは、テスト入力が「idx(α):4、n(β):5」、「パス条件が「α==4 && α>=4 && α<β」である。この場合は、インデックス値に由来する「α==4」を除いたものがインデックス等価条件132となるため、インデックス等価条件132は、「α>=4 && α<β」となる。また、No.7のテストケースは、テスト入力が「idx(α):4、n(β):0」、「パス条件が「α==4 && α>=4 && α>=β」である。この場合は、インデックス値に由来する「α==4」を除いたものがインデックス等価条件132となるため、インデックス等価条件132は、「α>=4 && α>=β」となる。   In the example shown in FIG. 34, when the index value is “4”, No. In the test case 6, the test input is “idx (α): 4, n (β): 5”, and the “path condition is“ α == 4 && α> = 4 && α <β ”. In this case, since the index equivalent condition 132 is obtained by excluding “α == 4” derived from the index value, the index equivalent condition 132 is “α> = 4 && α <β”. No. In the test case 7, the test input is “idx (α): 4, n (β): 0”, and the path condition is “α == 4 && α> = 4 && α> = β”. In this case, since the index equivalent condition 132 is obtained by excluding “α == 4” derived from the index value, the index equivalent condition 132 is “α> = 4 && α> = β”.

このようにしてインデックス等価条件132が生成されると、インデックス等価判定部124が、手順6(4回目)を行う。図35は、本実施例のテストケース生成装置100で実行される手順6(4回目)を説明するための図である。インデックス等価判定部124は、同一要素インデックス情報130を参照し、選択(注目)したインデックス値と要素が同一のインデックス値を取得する。インデックス値「4」と要素が同一で未選択のインデックス値は存在しない。そのため、インデックス等価判定部124は、インデックス値を取得せず、また、上述した処理も行わない。そのため、インデックス選択情報128は更新前と更新後とで変化しない。   When the index equivalence condition 132 is generated in this way, the index equivalence determining unit 124 performs the procedure 6 (fourth). FIG. 35 is a diagram for explaining the procedure 6 (fourth) executed by the test case generation device 100 of the present embodiment. The index equivalence determination unit 124 refers to the same element index information 130 and acquires an index value having the same element as the selected (attention) index value. There is no unselected index value that has the same element as the index value “4”. For this reason, the index equivalence determination unit 124 does not acquire an index value and does not perform the above-described processing. Therefore, the index selection information 128 does not change before and after the update.

続いてシンボリック実行部112は手順7(4回目)を行う。図36は、本実施例のテストケース生成装置100で実行される手順7(4回目)を説明するための図である。図36に示したように、インデックス選択情報128には、未選択のインデックス値がない。すなわち、配列アクセスのインデックス値に対応するパスは全て探索済みとなった。そのため、配列アクセスの前までバックトラックを行う。   Subsequently, the symbolic execution unit 112 performs step 7 (fourth time). FIG. 36 is a diagram for explaining the procedure 7 (fourth) executed by the test case generation device 100 of the present embodiment. As shown in FIG. 36, the index selection information 128 has no unselected index value. That is, all the paths corresponding to the array access index values have been searched. Therefore, backtracking is performed before array access.

上述の処理により、テストケース133の生成が完了したため、テストケース生成処理では、ステップ100が終了したことになる。このようにして生成されたテストケース133(図12参照)では、No.1〜7まで7つのテストケースが生成される。テストケース生成装置100では、インデックス値「5」の場合は、インデックス値「0」にまとめられ、インデックス値「3」の場合は、インデックス値「1」にまとめられる。そのため、テストケース生成装置100では、これらのインデックス値に対する探索を間引くことにより、シンボリック実行の効率化を図ることができる。テストケース生成装置100では、このようにシンボリック実行を効率化することにより、組合せ爆発の発生を抑制することができる。   Since the generation of the test case 133 is completed by the above-described process, step 100 is completed in the test case generation process. In the test case 133 generated in this way (see FIG. 12), No. Seven test cases 1 to 7 are generated. In the test case generation device 100, when the index value is “5”, the index value is “0”, and when the index value is “3”, the index value is “1”. Therefore, the test case generation device 100 can improve the efficiency of symbolic execution by thinning out searches for these index values. In the test case generation device 100, it is possible to suppress the occurrence of a combination explosion by improving the efficiency of symbolic execution in this way.

以上説明したように、テストケース生成装置10及びテストケース生成装置100によれば、インデックス選択部16、116が配列を構成する複数の要素の位置を表すインデックスのインデックス値の中から、パス条件を生成するインデックス値を選択する。シンボリック実行部12、112は、対象プログラムを、シンボリック実行する。シンボリック実行部12、112は、インデックス選択部16、116が選択したインデックス値に対応する要素が通過するパスを表すパス条件を生成して生成したパス条件を充足するテストデータと、前記パス条件とをテストケースとして出力する。   As described above, according to the test case generation device 10 and the test case generation device 100, the index selection units 16 and 116 determine the path condition from the index values of the indexes representing the positions of a plurality of elements constituting the array. Select the index value to be generated. The symbolic execution units 12 and 112 execute the target program symbolically. The symbolic execution units 12 and 112 generate test conditions that satisfy a path condition generated by generating a path condition representing a path through which an element corresponding to the index value selected by the index selection units 16 and 116 passes, and the path condition Is output as a test case.

同一要素インデックス情報生成部18、118は、同一要素判定部20、120の判定結果に基づいて、予め定められた判定基準に基づいて同一要素毎に、インデックス値をまとめた同一要素インデックス情報30、130を生成する。インデックス等価判定部24、124は、同一要素インデックス情報30、130を参照し、パス条件を生成した要素と同一要素に対応する未選択のインデックス値を選択する。また、インデックス等価判定部24、124は、パス条件からインデックス値に由来する制約を除いたインデックス等価条件32、132を生成する。インデックス等価判定部24、124は、選択したインデックス値の場合に、インデックス等価条件32、132を充足可能か判定し、充足可能である場合は、インデックス選択情報28、128において選択済として選択対象から除外する。   The same element index information generation units 18 and 118 are based on the determination results of the same element determination units 20 and 120, and the same element index information 30 that summarizes index values for each same element based on a predetermined determination criterion. 130 is generated. The index equivalence determination units 24 and 124 refer to the same element index information 30 and 130 and select an unselected index value corresponding to the same element as the element that generated the path condition. In addition, the index equivalence determination units 24 and 124 generate index equivalence conditions 32 and 132 excluding restrictions derived from index values from the path condition. In the case of the selected index value, the index equivalence determination units 24 and 124 determine whether or not the index equivalence conditions 32 and 132 can be satisfied. exclude.

このように、テストケース生成装置10、100では、シンボリック実行によるテストケースの生成において、テストケースを生成したインデックス値と同一要素であり、パス条件が同一のインデックス値を選択済とする。これにより、選択済としたインデックス値については探索を間引く(除外する)ことができるため、パスの発生を抑制することができ、シンボリック実行の効率化を図ることができる。従って、テストケース生成装置10、100では、シンボリック実行に要する時間及び空間計算量を抑制することができ、組合せ爆発の発生を抑制することができる。   As described above, in the test case generation apparatuses 10 and 100, in the test case generation by symbolic execution, the index value that is the same element as the index value that generated the test case and the same path condition is selected. Thereby, since it is possible to thin out (exclude) the search for the selected index value, it is possible to suppress the occurrence of a path and to improve the efficiency of symbolic execution. Therefore, in the test case generation apparatuses 10 and 100, the time and space calculation amount required for symbolic execution can be suppressed, and the occurrence of a combination explosion can be suppressed.

なお、上記実施形態及び実施例で説明したシンボリック実行(テストケース)は、同一パス上に配列アクセスが複数存在するプログラムに対しても適用可能であることはいうまでもない。この場合のテストケース生成装置の動作の概略について図37に示した具体例を参照して説明する。図37に示した具体例では、対象プログラムの01行目(図37、S1参照)と03行目(図37、S2、S3参照)に配列アクセスが存在するため、同一パス上に、2つの配列アクセスが存在している。インデックスは、idx1=α1と、idx2=α2と2種類存在する。このような場合では、インデックス選択情報及び同一要素インデックス情報を実行空間の状態毎にもたせることで対応することができる。図37に示した場合では、状態S1、S2、及びS3毎に、インデックス選択情報及び同一要素インデックス情報をもたせればよい。また、生成されたパス条件(インデックス等価条件)には、状態S1と、状態S2またはS3と、に応じた条件式が含まれる。例えば、図37に示した場合において、「α1==0」、「α2==0」を選択した場合では、パス条件が「α1==0 && α1<4 && α2==0 && α2<2 && α1<2」となる。このうち、「α2<2 && α1<2」は、「α2==0」を選択した場合の状態S2のインデックス等価条件である。また、「α1<4 && α2==0 && α2<2 && α1<2」は、「α2==1」を選択した場合の状態S1のインデックス等価条件である。このようにインデックス等価条件も独立して計算することができるため、上記実施形態及び実施例で説明したシンボリック実行(テストケース)が適用可能となる。   Needless to say, the symbolic execution (test case) described in the above embodiments and examples can be applied to a program having a plurality of array accesses on the same path. An outline of the operation of the test case generation apparatus in this case will be described with reference to a specific example shown in FIG. In the specific example shown in FIG. 37, there are array accesses in the 01st line (see FIG. 37, S1) and the 03rd line (see FIG. 37, S2, S3) of the target program. Array access exists. There are two types of indexes, idx1 = α1 and idx2 = α2. In such a case, the index selection information and the same element index information can be provided for each state of the execution space. In the case shown in FIG. 37, the index selection information and the same element index information may be provided for each of the states S1, S2, and S3. Further, the generated path condition (index equivalent condition) includes a conditional expression corresponding to the state S1 and the state S2 or S3. For example, in the case shown in FIG. 37, when “α1 == 0” and “α2 == 0” are selected, the path condition is “α1 == 0 && α1 <4 && α2 == 0 && α2 <2. && α1 <2 ”. Among these, “α2 <2 && α1 <2” is an index equivalent condition of the state S2 when “α2 == 0” is selected. Further, “α1 <4 && α2 == 0 && α2 <2 && α1 <2” is an index equivalent condition of the state S1 when “α2 == 1” is selected. Since the index equivalence condition can also be calculated independently in this way, the symbolic execution (test case) described in the above embodiment and examples can be applied.

なお、上記実施形態及び実施例では、対象プログラムとして、プログラミング言語としてJava(登録商標)を用いたプログラムを用いたが、プログラミング言語はこれに限定されず、どのようなものであってもよい。   In the above-described embodiment and examples, a program using Java (registered trademark) as a programming language is used as the target program. However, the programming language is not limited to this, and any program may be used.

また、上記では、テストケース生成プログラム72が記憶部66に予め記憶(インストール)されている態様を説明したが、テストケース生成プログラム72を記憶媒体に記録された形態で提供することも可能である。記憶媒体としては、例えば、CD−ROM(Compact Disc Read Only Memory)、DVD−ROM(Digital Versatile Disk Read Only Memory)、及びUSB(Universal Serial Bus)等が挙げられる。   In the above description, the test case generation program 72 has been stored (installed) in the storage unit 66 in advance. However, the test case generation program 72 may be provided in a form recorded on a storage medium. . Examples of the storage medium include a CD-ROM (Compact Disc Read Only Memory), a DVD-ROM (Digital Versatile Disk Read Only Memory), and a USB (Universal Serial Bus).

以上の上記実施形態に関し、更に以下の付記を開示する。   Regarding the above embodiment, the following additional notes are disclosed.

(付記1)
コンピュータに、
配列を構成する複数の要素の各々の位置を表すシンボル変数であるインデックス値で、除外されていない未選択のインデックス値を選択対象として、該選択対象からインデックス値を選択し、
対象プログラムをシンボリック実行することにより、選択したインデックス値に対応する要素が通過するパスを表すパス条件を生成し、生成したパス条件及び該生成したパス条件が表すパスを通過するテストデータをテストケースとして出力し、
前記選択対象に含まれるインデックス値であり、パス条件を生成した要素と同一の要素に対応するインデックス値が、生成した該パス条件からインデックス値に由来する制約を除外したインデックス等価条件を充足可能か判定し、充足可能なインデックス値を前記選択対象から除外する、
ことを含む処理を実行させるテストケース生成プログラム。
(Appendix 1)
On the computer,
An index value that is a symbol variable representing the position of each of a plurality of elements constituting the array, and an unselected index value that is not excluded is selected as an object of selection, and an index value is selected from the object of selection,
Generate a path condition that represents the path that the element corresponding to the selected index value passes by executing the target program symbolically, and test data that passes through the path that is generated and the path that the generated path condition represents Output as
Is the index value included in the selection target, and whether the index value corresponding to the same element as the element that generated the path condition can satisfy the index equivalent condition that excludes the constraint derived from the index value from the generated path condition Determining and excluding satisfiable index values from the selection target,
A test case generation program that executes processing including the above.

(付記2)
コンピュータに、
前記対象プログラム中の命令がインデックス値をシンボル変数とした配列の要素へのアクセス命令か否かを検出し、
同一であると判定した要素毎に、インデックス値をまとめた同一要素インデックス情報を生成し、
生成した前記同一要素インデックス情報に基づき、パス条件を生成した要素と同一の要素に対応する前記選択対象に含まれるインデックス値を検出する
ことを含む処理を実行させる付記1に記載のテストケース生成プログラム。
(Appendix 2)
On the computer,
Detecting whether an instruction in the target program is an access instruction to an element of an array having an index value as a symbol variable;
For each element determined to be the same, generate the same element index information that summarizes the index values,
The test case generation program according to appendix 1, which executes a process including detecting an index value included in the selection target corresponding to the same element as the element that generated the path condition based on the generated same element index information .

(付記3)
コンピュータに、
前記アクセス命令を検出した場合に、予め定められた判定基準に基づいて同一であると判定し、
判定結果に基づいて、同一であると判定した要素毎に、インデックス値をまとめた同一要素インデックス情報を生成する、
ことを含む処理を実行させる付記2に記載のテストケース生成プログラム。
(Appendix 3)
On the computer,
When the access instruction is detected, it is determined to be the same based on a predetermined criterion,
For each element that is determined to be the same based on the determination result, the same element index information that summarizes the index values is generated.
The test case generation program according to appendix 2, which executes a process including the above.

(付記4)
コンピュータに、
前記インデックス等価条件を、生成したパス条件からインデックス値に由来する制約を除くことにより生成する、
ことを含む処理を実行させる付記1から付記3のいずれか1項に記載のテストケース生成プログラム。
(Appendix 4)
On the computer,
The index equivalent condition is generated by removing the constraint derived from the index value from the generated path condition.
The test case generation program according to any one of appendix 1 to appendix 3, which causes a process including the above to be executed.

(付記5)
配列を構成する複数の要素の各々の位置を表すシンボル変数であるインデックス値で、除外されていない未選択のインデックス値を選択対象として、該選択対象からインデックス値を選択する選択部と、
対象プログラムをシンボリック実行することにより、前記選択部が選択したインデックス値に対応する要素が通過するパスを表すパス条件を生成し、生成したパス条件及び該生成したパス条件が表すパスを通過するテストデータをテストケースとして出力する実行部と、
前記選択対象に含まれるインデックス値であり、前記実行部でパス条件を生成した要素と同一の要素に対応するインデックス値が、生成した該パス条件からインデックス値に由来する制約を除外したインデックス等価条件を充足可能か判定し、充足可能なインデックス値を前記選択対象から除外する判定部と、
を備えた、テストケース生成装置。
(Appendix 5)
An index value that is a symbol variable representing each position of a plurality of elements constituting the array, and an unselected index value that is not excluded is selected as a selection target; a selection unit that selects an index value from the selection target;
Generate a path condition representing a path through which an element corresponding to the index value selected by the selection unit passes through symbolic execution of the target program, and pass the path represented by the generated path condition and the generated path condition An execution unit that outputs data as a test case;
An index equivalent condition that is an index value that is included in the selection target and that corresponds to an element that is the same as the element that has generated a path condition in the execution unit, and that excludes a constraint derived from the index value from the generated path condition A determination unit that determines whether or not the index value that can be satisfied is excluded from the selection target;
A test case generation apparatus comprising:

(付記6)
前記実行部で実行する命令がインデックス値をシンボル変数とした配列の要素へのアクセス命令か否かを検出する検出部と、
前記検出部が前記アクセス命令であると検出した場合に、予め定められた判定基準に基づいて同一であると判定した要素毎に、インデックス値をまとめた同一要素インデックス情報を生成する生成部と、
を備え、前記判定部は、前記同一要素インデックス情報に基づき、前記実行部によりパス条件を生成した要素と同一の要素に対応する前記選択対象に含まれるインデックス値を検出する、
付記5に記載のテストケース生成装置。
(Appendix 6)
A detection unit that detects whether an instruction to be executed by the execution unit is an instruction to access an element of an array having an index value as a symbol variable;
When the detection unit detects that it is the access command, a generation unit that generates the same element index information that summarizes index values for each element that is determined to be the same based on a predetermined determination criterion;
The determination unit detects an index value included in the selection target corresponding to the same element as the element for which a path condition is generated by the execution unit, based on the same element index information.
The test case generation device according to attachment 5.

(付記7)
前記アクセス命令を検出した場合に、予め定められた判定基準に基づいて同一であると判定する同一要素判定部を備え、
前記生成部は、前記同一要素判定部の判定結果に基づいて、同一であると判定した要素毎に、インデックス値をまとめた同一要素インデックス情報を生成する、
付記6に記載のテストケース生成装置。
(Appendix 7)
When the access instruction is detected, the same element determination unit that determines the same based on a predetermined determination criterion is provided,
The generation unit generates the same element index information that summarizes the index values for each element determined to be the same based on the determination result of the same element determination unit.
The test case generation device according to attachment 6.

(付記8)
前記インデックス等価条件を、生成したパス条件からインデックス値に由来する制約を除くことにより生成する等価条件生成部を備えた、
付記5から付記7のいずれか1項に記載のテストケース生成装置。
(Appendix 8)
An equivalent condition generation unit that generates the index equivalent condition by removing the constraint derived from the index value from the generated path condition,
The test case generation device according to any one of appendix 5 to appendix 7.

(付記9)
コンピュータに、
配列を構成する複数の要素の各々の位置を表すシンボル変数であるインデックス値で、除外されていない未選択のインデックス値を選択対象として、該選択対象からインデックス値を選択し、
対象プログラムをシンボリック実行することにより、選択したインデックス値に対応する要素が通過するパスを表すパス条件を生成し、生成したパス条件及び該生成したパス条件が表すパスを通過するテストデータをテストケースとして出力し、
前記選択対象に含まれるインデックス値であり、パス条件を生成した要素と同一の要素に対応するインデックス値が、生成した該パス条件からインデックス値に由来する制約を除外したインデックス等価条件を充足可能か判定し、充足可能なインデックス値を前記選択対象から除外する、
ことを含む処理を実行させるテストケース生成方法。
(Appendix 9)
On the computer,
An index value that is a symbol variable representing the position of each of a plurality of elements constituting the array, and an unselected index value that is not excluded is selected as an object of selection, and an index value is selected from the object of selection,
Generate a path condition that represents the path that the element corresponding to the selected index value passes by executing the target program symbolically, and test data that passes through the path that is generated and the path that the generated path condition represents Output as
Is the index value included in the selection target, and whether the index value corresponding to the same element as the element that generated the path condition can satisfy the index equivalent condition that excludes the constraint derived from the index value from the generated path condition Determining and excluding satisfiable index values from the selection target,
A test case generation method for executing a process including the above.

(付記10)
コンピュータに、
前記対象プログラム中の命令がインデックス値をシンボル変数とした配列の要素へのアクセス命令か否かを検出し、
同一であると判定した要素毎に、インデックス値をまとめた同一要素インデックス情報を生成し、
生成した前記同一要素インデックス情報に基づき、パス条件を生成した要素と同一の要素に対応する前記選択対象に含まれるインデックス値を検出する
ことを含む処理を実行させる付記9に記載のテストケース生成方法。
(Appendix 10)
On the computer,
Detecting whether an instruction in the target program is an access instruction to an element of an array having an index value as a symbol variable;
For each element determined to be the same, generate the same element index information that summarizes the index values,
The test case generation method according to appendix 9, wherein a process including detecting an index value included in the selection target corresponding to the same element as the element that generated the path condition is executed based on the generated same element index information .

(付記11)
コンピュータに、
前記アクセス命令を検出した場合に、予め定められた判定基準に基づいて同一であると判定し、
判定結果に基づいて、同一であると判定した要素毎に、インデックス値をまとめた同一要素インデックス情報を生成する、
ことを含む処理を実行させる付記10に記載のテストケース生成方法。
(Appendix 11)
On the computer,
When the access instruction is detected, it is determined to be the same based on a predetermined criterion,
For each element that is determined to be the same based on the determination result, the same element index information that summarizes the index values is generated.
The test case generation method according to attachment 10, wherein the process including the above is executed.

(付記12)
コンピュータに、
前記インデックス等価条件を、生成したパス条件からインデックス値に由来する制約を除くことにより生成する、
ことを含む処理を実行させる付記9から付記11のいずれか1項に記載のテストケース生成方法。
(Appendix 12)
On the computer,
The index equivalent condition is generated by removing the constraint derived from the index value from the generated path condition.
12. The test case generation method according to any one of appendix 9 to appendix 11, wherein the process including the above is executed.

10、100 テストケース生成装置
12、112 シンボリック実行部
14、114 インデックスアクセス検出部
16、116 インデックス選択部
18、118 同一要素インデックス情報生成部
20、120 同一要素判定部
22、122 インデックス等価条件生成部
24、124 インデックス等価判定部
62 CPU
64 メモリ
66 記憶部
72 テストケース生成プログラム
74 シンボリック実行プロセス
76 インデックスアクセス検出プロセス
78 インデックス選択プロセス
80 同一要素インデックス情報生成プロセス
82 同一要素判定プロセス
84 インデックス等価条件生成プロセス
86 インデックス等価判定プロセス
10, 100 Test case generation device 12, 112 Symbolic execution unit 14, 114 Index access detection unit 16, 116 Index selection unit 18, 118 Same element index information generation unit 20, 120 Same element determination unit 22, 122 Index equivalent condition generation unit 24, 124 Index equivalence determination unit 62 CPU
64 Memory 66 Storage Unit 72 Test Case Generation Program 74 Symbolic Execution Process 76 Index Access Detection Process 78 Index Selection Process 80 Same Element Index Information Generation Process 82 Same Element Determination Process 84 Index Equivalent Condition Generation Process 86 Index Equivalence Determination Process

Claims (7)

コンピュータに、
配列を構成する複数の要素の各々の位置を表すシンボル変数であるインデックス値で、除外されていない未選択のインデックス値を選択対象として、該選択対象からインデックス値を選択し、
対象プログラムをシンボリック実行することにより、選択したインデックス値に対応する要素に応じて分岐するパスを表すパス条件を生成し、生成したパス条件及び該生成したパス条件が表すパスを通過するテストデータをテストケースとして出力し、
前記選択対象に含まれるインデックス値であり、パス条件を生成した要素と同一の要素に対応するインデックス値が、生成した該パス条件からインデックス値に由来する制約を除外したインデックス等価条件を充足可能か判定し、充足可能なインデックス値を前記選択対象から除外する、
ことを含む処理を実行させるテストケース生成プログラム。
On the computer,
An index value that is a symbol variable representing the position of each of a plurality of elements constituting the array, and an unselected index value that is not excluded is selected as an object of selection, and an index value is selected from the object of selection,
By performing symbolic execution of the target program, a path condition representing a path branching according to an element corresponding to the selected index value is generated, and the generated path condition and test data passing through the path represented by the generated path condition are Output as a test case,
Is the index value included in the selection target, and whether the index value corresponding to the same element as the element that generated the path condition can satisfy the index equivalent condition that excludes the constraint derived from the index value from the generated path condition Determining and excluding satisfiable index values from the selection target,
A test case generation program that executes processing including the above.
コンピュータに、
前記対象プログラム中の命令がインデックス値をシンボル変数とした配列の要素へのアクセス命令か否かを検出し、
同一であると判定した要素毎に、インデックス値をまとめた同一要素インデックス情報を生成し、
生成した前記同一要素インデックス情報に基づき、パス条件を生成した要素と同一の要素に対応する前記選択対象に含まれるインデックス値を検出する
ことを含む処理を実行させる請求項1に記載のテストケース生成プログラム。
On the computer,
Detecting whether an instruction in the target program is an access instruction to an element of an array having an index value as a symbol variable;
For each element determined to be the same, generate the same element index information that summarizes the index values,
The test case generation according to claim 1, wherein a process including detecting an index value included in the selection target corresponding to the same element as the element that generated the path condition is executed based on the generated same element index information. program.
コンピュータに、
前記アクセス命令を検出した場合に、予め定められた判定基準に基づいて同一であると判定し、
判定結果に基づいて、同一であると判定した要素毎に、インデックス値をまとめた同一要素インデックス情報を生成する、
ことを含む処理を実行させる請求項2に記載のテストケース生成プログラム。
On the computer,
When the access instruction is detected, it is determined to be the same based on a predetermined criterion,
For each element that is determined to be the same based on the determination result, the same element index information that summarizes the index values is generated.
The test case generation program according to claim 2, wherein processing including the above is executed.
コンピュータに、
前記インデックス等価条件を、生成したパス条件からインデックス値に由来する制約を除くことにより生成する、
ことを含む処理を実行させる請求項1から請求項3のいずれか1項に記載のテストケース生成プログラム。
On the computer,
The index equivalent condition is generated by removing the constraint derived from the index value from the generated path condition.
The test case generation program according to any one of claims 1 to 3, wherein a process including the above is executed.
配列を構成する複数の要素の各々の位置を表すシンボル変数であるインデックス値で、除外されていない未選択のインデックス値を選択対象として、該選択対象からインデックス値を選択する選択部と、
対象プログラムをシンボリック実行することにより、前記選択部が選択したインデックス値に対応する要素に応じて分岐するパスを表すパス条件を生成し、生成したパス条件及び該生成したパス条件が表すパスを通過するテストデータをテストケースとして出力する実行部と、
前記選択対象に含まれるインデックス値であり、前記実行部でパス条件を生成した要素と同一の要素に対応するインデックス値が、生成した該パス条件からインデックス値に由来する制約を除外したインデックス等価条件を充足可能か判定し、充足可能なインデックス値を前記選択対象から除外する判定部と、
を備えた、テストケース生成装置。
An index value that is a symbol variable representing each position of a plurality of elements constituting the array, and an unselected index value that is not excluded is selected as a selection target; a selection unit that selects an index value from the selection target;
By executing the target program symbolically, a path condition representing a path that branches according to the element corresponding to the index value selected by the selection unit is generated, and the generated path condition and the path represented by the generated path condition are passed. An execution unit that outputs test data to be tested as a test case;
An index equivalent condition that is an index value that is included in the selection target and that corresponds to an element that is the same as the element that has generated a path condition in the execution unit, and that excludes a constraint derived from the index value from the generated path condition A determination unit that determines whether or not the index value that can be satisfied is excluded from the selection target;
A test case generation apparatus comprising:
前記実行部で実行する命令がインデックス値をシンボル変数とした配列の要素へのアクセス命令か否かを検出する検出部と、
前記検出部が前記アクセス命令であると検出した場合に、予め定められた判定基準に基づいて同一であると判定した要素毎に、インデックス値をまとめた同一要素インデックス情報を生成する生成部と、
を備え、前記判定部は、前記同一要素インデックス情報に基づき、前記実行部によりパス条件を生成した要素と同一の要素に対応する前記選択対象に含まれるインデックス値を検出する、
請求項5に記載のテストケース生成装置。
A detection unit that detects whether an instruction to be executed by the execution unit is an instruction to access an element of an array having an index value as a symbol variable;
When the detection unit detects that it is the access command, a generation unit that generates the same element index information that summarizes index values for each element that is determined to be the same based on a predetermined determination criterion;
The determination unit detects an index value included in the selection target corresponding to the same element as the element for which a path condition is generated by the execution unit, based on the same element index information.
The test case generation device according to claim 5.
コンピュータに、
配列を構成する複数の要素の各々の位置を表すシンボル変数であるインデックス値で、除外されていない未選択のインデックス値を選択対象として、該選択対象からインデックス値を選択し、
対象プログラムをシンボリック実行することにより、選択したインデックス値に対応する要素に応じて分岐するパスを表すパス条件を生成し、生成したパス条件及び該生成したパス条件が表すパスを通過するテストデータをテストケースとして出力し、
前記選択対象に含まれるインデックス値であり、パス条件を生成した要素と同一の要素に対応するインデックス値が、生成した該パス条件からインデックス値に由来する制約を除外したインデックス等価条件を充足可能か判定し、充足可能なインデックス値を前記選択対象から除外する、
ことを含む処理を実行させるテストケース生成方法。
On the computer,
An index value that is a symbol variable representing the position of each of a plurality of elements constituting the array, and an unselected index value that is not excluded is selected as an object of selection, and an index value is selected from the object of selection,
By performing symbolic execution of the target program, a path condition representing a path branching according to an element corresponding to the selected index value is generated, and the generated path condition and test data passing through the path represented by the generated path condition are Output as a test case,
Is the index value included in the selection target, and whether the index value corresponding to the same element as the element that generated the path condition can satisfy the index equivalent condition that excludes the constraint derived from the index value from the generated path condition Determining and excluding satisfiable index values from the selection target,
A test case generation method for executing a process including the above.
JP2014112808A 2014-05-30 2014-05-30 Test case generation program, test case generation apparatus, and test case generation method Active JP6330490B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2014112808A JP6330490B2 (en) 2014-05-30 2014-05-30 Test case generation program, test case generation apparatus, and test case generation method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2014112808A JP6330490B2 (en) 2014-05-30 2014-05-30 Test case generation program, test case generation apparatus, and test case generation method

Publications (2)

Publication Number Publication Date
JP2015228085A JP2015228085A (en) 2015-12-17
JP6330490B2 true JP6330490B2 (en) 2018-05-30

Family

ID=54885533

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2014112808A Active JP6330490B2 (en) 2014-05-30 2014-05-30 Test case generation program, test case generation apparatus, and test case generation method

Country Status (1)

Country Link
JP (1) JP6330490B2 (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108595341B (en) * 2018-05-11 2019-11-22 清华大学 Automatic example generation method and system

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP5884652B2 (en) * 2012-06-08 2016-03-15 富士通株式会社 Test data generation program, test data generation device, and test data generation method

Also Published As

Publication number Publication date
JP2015228085A (en) 2015-12-17

Similar Documents

Publication Publication Date Title
JP2019220141A (en) Branch Coverage Guided Symbolic Execution for Hybrid Fuzz Testing of Software Binaries
CN101751333A (en) Method, computer program and computer system for assisting in analyzing program
US11610117B2 (en) System and method for adapting a neural network model on a hardware platform
JP2016004576A (en) Method for verification of model of gui-based application and computer readable memory medium
JP6245006B2 (en) Test case generation apparatus, method, and program
JP6330490B2 (en) Test case generation program, test case generation apparatus, and test case generation method
JP5164920B2 (en) Test data generation method, apparatus and program
JP5440287B2 (en) Symbolic execution support program, method and apparatus
KR102255470B1 (en) Method and apparatus for artificial neural network
Legg et al. A SAT-based counterexample guided method for unbounded synthesis
US20120317526A1 (en) Verification method, computer-readable recording medium, and design verification apparatus
JP5887811B2 (en) Compiling device, compiling method, compiling program, and recording medium
Haghighatkhah Test case prioritization using build history and test distances: an approach for improving automotive regression testing in continuous integration environments
US20190294637A1 (en) Similar data search device, similar data search method, and recording medium
JP2008197897A (en) Test pattern generation apparatus and generation method
JP6512032B2 (en) Stub target determination apparatus, method, and program
JP2014048856A (en) Software verification program and software verification system
JP5900212B2 (en) Test data generation apparatus, program, and method
JP5884652B2 (en) Test data generation program, test data generation device, and test data generation method
JP5755861B2 (en) Test case generation apparatus, test case generation method, and test case generation program
JP2017224185A (en) Bug contamination probability calculation program and bug contamination probability calculation method
JP6748357B2 (en) Analysis device, analysis program, and analysis method
JP5900197B2 (en) Route condition selection apparatus, program, and method
JP6583033B2 (en) Driver generation program, apparatus, and method
Zhao et al. Automatic model completion for Web applications

Legal Events

Date Code Title Description
A621 Written request for application examination

Free format text: JAPANESE INTERMEDIATE CODE: A621

Effective date: 20170206

A977 Report on retrieval

Free format text: JAPANESE INTERMEDIATE CODE: A971007

Effective date: 20171130

A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20171212

A521 Written amendment

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20180124

TRDD Decision of grant or rejection written
A01 Written decision to grant a patent or to grant a registration (utility model)

Free format text: JAPANESE INTERMEDIATE CODE: A01

Effective date: 20180327

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20180409

R150 Certificate of patent or registration of utility model

Ref document number: 6330490

Country of ref document: JP

Free format text: JAPANESE INTERMEDIATE CODE: R150