JP6245006B2 - Test case generation apparatus, method, and program - Google Patents

Test case generation apparatus, method, and program Download PDF

Info

Publication number
JP6245006B2
JP6245006B2 JP2014050456A JP2014050456A JP6245006B2 JP 6245006 B2 JP6245006 B2 JP 6245006B2 JP 2014050456 A JP2014050456 A JP 2014050456A JP 2014050456 A JP2014050456 A JP 2014050456A JP 6245006 B2 JP6245006 B2 JP 6245006B2
Authority
JP
Japan
Prior art keywords
branch
route
path
program
inspected
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
JP2014050456A
Other languages
Japanese (ja)
Other versions
JP2015176230A (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 JP2014050456A priority Critical patent/JP6245006B2/en
Publication of JP2015176230A publication Critical patent/JP2015176230A/en
Application granted granted Critical
Publication of JP6245006B2 publication Critical patent/JP6245006B2/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Debugging And Monitoring (AREA)

Description

開示の技術は、テストケース生成装置、方法、及びプログラムに関する。   The disclosed technology relates to a test case generation apparatus, method, and program.

ソフトウエア開発において、開発対象であるプログラム(被検査プログラム)から、被検査プログラムの開始から終了までに至る経路(パス)を網羅的に抽出し、被検査プログラムの動作を検証する手法が知られている。   In software development, a method for exhaustively extracting the path from the start of the program to be inspected to the end of the program being inspected (inspected program) and verifying the operation of the inspected program is known. ing.

パスの抽出法として、例えば、被検査プログラムに含まれる全てのパスを網羅的に抽出するパス網羅、及び被検査プログラムに含まれる全ての条件分岐命令の分岐先を1回以上実行するパス集合を抽出する分岐網羅等が存在する。   As a path extraction method, for example, a path coverage that exhaustively extracts all paths included in the program to be inspected, and a path set that executes one or more branch destinations of all conditional branch instructions included in the program to be inspected are used. There is branch coverage etc. to extract.

そして、このようにして抽出されたパスに基づいて被検査プログラムを網羅的に実行し、被検査プログラムが目的とする動作を行うか否かを判定することで、被検査プログラムの動作を検証する。   Then, the program to be inspected is comprehensively executed based on the path thus extracted, and the operation of the program to be inspected is verified by determining whether or not the program to be inspected performs the intended operation. .

特開平11−232137号公報Japanese Patent Laid-Open No. 11-232137 特開平9−128266号公報JP-A-9-128266

しかしながら、パス網羅によるパス抽出では、被検査プログラムに含まれるループ終了条件が具体的な数値でなく、例えばα等のシンボル値を含んで表されている場合、ループ終了条件が不定値となる。従って、ループを継続するパスが無限に存在し、それに伴い抽出されるパスが膨大になる、所謂パス爆発が発生することがある。   However, in path extraction based on path coverage, when the loop end condition included in the program to be inspected is not a specific numerical value but is represented by including a symbol value such as α, the loop end condition becomes an indefinite value. Therefore, there may be an infinite number of paths that continue the loop, and so-called path explosion may occur where the number of paths extracted becomes enormous.

パス爆発の防止策として、例えば、パス抽出の方法を分岐網羅とすることで、抽出されるパス数を、パス網羅によって被検査プログラムから抽出されるパス数より減少させる方法が採られる。   As a path explosion prevention measure, for example, a method of reducing the number of paths to be extracted from the number of paths extracted from the program to be inspected by path coverage by using a path extraction method as branch coverage is adopted.

しかし、例えば、DART(Directed Auto-mated Random Testing)等の公知の分岐網羅では、分岐網羅を実現する最小数のパスよりも、多くのパスが抽出される場合がある。   However, for example, in known branch coverage such as DART (Directed Auto-mated Random Testing), more paths may be extracted than the minimum number of paths that realize branch coverage.

そこで、開示の技術は、より少数のパスで分岐網羅度を向上させることができるパス集合を被検査プログラムから抽出することを目的とする。   Therefore, the disclosed technique aims to extract from the program to be inspected a path set that can improve the branch coverage with a smaller number of paths.

開示の技術は、管理部は、被検査プログラムに含まれる条件分岐の分岐先への分岐実行回数を管理する。検出部は、分岐実行回数から得られる経路候補に対応した分岐情報と、既に抽出された被検査プログラムの既出経路に対応した分岐情報と、を比較して、経路候補が既出経路に含まれる重複経路か否かを検出する。選択部は、条件分岐の分岐実行回数に応じた予め定めた規則に基づいて分岐先を決定して、被検査プログラムの開始から終了までの経路を選択する。生成部は、選択された経路に対応した分岐情報を、既出経路に対応した分岐情報として生成する。制御部は、検出部により経路候補が重複経路ではないと検出された場合、選択部及び生成部の各々による処理を実行し、検出部により経路候補が重複経路であると検出された場合、選択部及び生成部の各々による処理を実行しないように選択部及び生成部を制御する。   In the disclosed technique, the management unit manages the number of branch executions to the branch destination of the conditional branch included in the program to be inspected. The detection unit compares the branch information corresponding to the route candidate obtained from the number of branch executions with the branch information corresponding to the already extracted route of the program to be inspected, and the route candidate is included in the already existing route. Detect whether the route. The selection unit determines a branch destination based on a predetermined rule corresponding to the number of branch executions of the conditional branch, and selects a path from the start to the end of the program to be inspected. The generation unit generates branch information corresponding to the selected route as branch information corresponding to the existing route. When the detection unit detects that the route candidate is not an overlapping route, the control unit executes processing by each of the selection unit and the generation unit, and when the detection unit detects that the route candidate is an overlapping route, the control unit selects The selection unit and the generation unit are controlled so as not to execute processing by each of the unit and the generation unit.

開示の技術は、一つの側面として、より少数のパスで分岐網羅度を向上させることができるパス集合を被検査プログラムから抽出する効果を有する。     As one aspect, the disclosed technique has an effect of extracting a path set that can improve the branch coverage with a smaller number of paths from the program to be inspected.

図1は、被検査プログラムの一例を示した図である。FIG. 1 is a diagram showing an example of a program to be inspected. 図2は、被検査プログラムに係るフローチャートの一例を示した図である。FIG. 2 is a diagram showing an example of a flowchart relating to the program to be inspected. 図3は、被検査プログラムから抽出されるパスの一例を示した図である。FIG. 3 is a diagram showing an example of a path extracted from the program to be inspected. 図4は、繰り返し処理を含む被検査プログラムの一例を示した図である。FIG. 4 is a diagram showing an example of a program to be inspected that includes repetitive processing. 図5は、外部処理呼び出しを含む被検査プログラムの一例を示した図である。FIG. 5 is a diagram showing an example of a program to be inspected including an external process call. 図6は、パス爆発の説明に用いられる被検査プログラムの一例を示した図である。FIG. 6 is a diagram showing an example of a program to be inspected used for explaining the path explosion. 図7は、第1実施形態に係るテストケース生成装置の機能ブロック図である。FIG. 7 is a functional block diagram of the test case generation device according to the first embodiment. 図8は、深さ優先探索の説明に用いられるパスツリーの一例を示した図である。FIG. 8 is a diagram showing an example of a path tree used for explaining the depth-first search. 図9は、第1実施形態に係る被検査プログラムの一例を示した図である。FIG. 9 is a diagram showing an example of a program to be inspected according to the first embodiment. 図10は、第1実施形態に係る被検査プログラムのフローチャートの一例を示した図である。FIG. 10 is a diagram showing an example of a flowchart of the program to be inspected according to the first embodiment. 図11は、分岐実行回数の管理について説明するための図である。FIG. 11 is a diagram for explaining management of the number of branch executions. 図12は、多分岐命令を含む被検査プログラムの一例を示した図である。FIG. 12 is a diagram showing an example of a program to be inspected including a multi-branch instruction. 図13は、パス選択規則について説明するための図である。FIG. 13 is a diagram for explaining a path selection rule. 図14は、重複パス検出ルールの生成方法について説明するための図である。FIG. 14 is a diagram for explaining a method of generating a duplicate path detection rule. 図15は、重複パスの検出について説明するための図である。FIG. 15 is a diagram for explaining detection of duplicate paths. 図16は、重複パスの検出について説明するための図である。FIG. 16 is a diagram for explaining detection of duplicate paths. 図17は、テストケース生成装置として機能するコンピュータのブロック図である。FIG. 17 is a block diagram of a computer that functions as a test case generation apparatus. 図18は、テストケース生成処理の流れを示すフローチャートである。FIG. 18 is a flowchart showing the flow of test case generation processing. 図19は、重複パス検出処理の流れを示すフローチャートである。FIG. 19 is a flowchart showing the flow of duplicate path detection processing. 図20は、第1実施形態に係る分岐実行回数管理処理の流れを示すフローチャートである。FIG. 20 is a flowchart showing the flow of branch execution frequency management processing according to the first embodiment. 図21は、分岐選択処理の流れを示すフローチャートである。FIG. 21 is a flowchart showing the flow of branch selection processing. 図22は、第2実施形態に係るテストケース生成装置の機能ブロック図である。FIG. 22 is a functional block diagram of the test case generation device according to the second embodiment. 図23は、外部処理内に条件分岐命令を含む被検査プログラムの一例を示した図である。FIG. 23 is a diagram showing an example of a program to be inspected that includes a conditional branch instruction in external processing. 図24は、第2実施形態に係る分岐実行回数管理処理の流れを示すフローチャートである。FIG. 24 is a flowchart showing the flow of branch execution frequency management processing according to the second embodiment.

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

(第1実施形態)   (First embodiment)

ソフトウエア開発において、シンボリック実行(symbolic execution)技術を利用して、被検査プログラムの動作を検証する手法がある。   In software development, there is a method of verifying the operation of a program to be inspected using symbolic execution technology.

シンボリック実行技術とは、被検査プログラムに含まれる変数に具体的な数値を代入する代わりに、数値を代表するシンボル値を代入することで被検査プログラムを疑似的に実行し、被検査プログラムの実行結果を評価する技術である。   Symbolic execution technology means that instead of substituting a specific numerical value for a variable included in the program under test, the program under test is executed in a pseudo manner by substituting a symbol value representing the numerical value, and the program under test is executed. A technique for evaluating the results.

そこで、まず被検査プログラムのシンボリック実行について簡単に説明する。   First, the symbolic execution of the program to be inspected will be briefly described.

図1は、一例としてCOBOL言語で記述された被検査プログラムを示した図である。なお、以降、被検査プログラムを例示する場合、COBOL言語で記述された被検査プログラムを示すものとするが、被検査プログラムがCOBOL言語以外の他のプログラム言語で記述されていてもよいことは言うまでもない。   FIG. 1 is a diagram showing an inspected program described in the COBOL language as an example. In the following, when the program to be inspected is illustrated, the program to be inspected written in the COBOL language is shown, but it goes without saying that the program to be inspected may be described in a program language other than the COBOL language. Yes.

図1の13行目のIF文は、変数である性別が‘男性’の場合には15行目に処理を分岐させ、性別が‘男性’でない場合には17行目に処理を分岐させる、条件分岐命令の一例である。   The IF statement on the 13th line in FIG. 1 branches the process to the 15th line when the gender variable is “male”, and branches the process to the 17th line when the gender is not “male”. It is an example of a conditional branch instruction.

また、図1に示した被検査プログラムには、19行目にもIF文が記述されており、19行目のIF文では、性別が‘女性’の場合には21行目に処理を分岐させ、性別が‘女性’ではない場合には23行目に処理を分岐させる。   Further, in the program to be inspected shown in FIG. 1, the IF statement is also described on the 19th line. In the IF statement on the 19th line, the process branches to the 21st line when the gender is “female”. If the gender is not “female”, the process branches to the 23rd line.

図2は、図1の被検査プログラムをフローチャートで示した図である。   FIG. 2 is a flowchart showing the program to be inspected in FIG.

このような被検査プログラムに対してシンボリック実行を行うと、変数である性別の値は、被検査プログラムの外部から与えられるため、シンボリック実行の際には不定であり、変数である性別の値はシンボル値として指定される。なお、このように、シンボリック実行の際、シンボル値に置き換えられる変数を外部変数という。   When symbolic execution is performed on such a program to be inspected, the value of gender as a variable is given from outside the program to be inspected, so it is undefined during symbolic execution, and the value of gender as a variable is Specified as a symbol value. In this way, a variable that is replaced with a symbol value during symbolic execution is called an external variable.

そして、シンボリック実行の結果、図3に示すような実行可能なパス1、パス2、及びパス3を含む3個のパス、及びパス毎のパス条件が抽出される。ここで、パス条件とは、パスが終了するまでに経由する条件分岐のうち、シンボル値を含む全ての条件を積(AND条件:以下、記号∧で表示する)で連結した条件である。換言すれば、パス条件とは、パスに含まれる条件分岐を通過する際に満たすべき論理的な制約ということができる。また、パスが実行可能とは、パス条件が充足可能であることをいう。   As a result of the symbolic execution, three paths including the executable path 1, path 2, and path 3 as shown in FIG. 3 and path conditions for each path are extracted. Here, the path condition is a condition in which all conditions including a symbol value are connected by a product (AND condition: hereinafter, indicated by symbol ∧) among conditional branches that are passed until the path is completed. In other words, the path condition can be said to be a logical restriction that must be satisfied when passing through a conditional branch included in the path. Also, “pass is executable” means that the path condition can be satisfied.

パス1は、図2のステップS10、ステップS12、ステップS16、及びステップS20を経由するパスであり、パス2は、図2のステップS10、ステップS14、ステップS16、及びステップS18を経由するパスである。更に、パス3は、図2のステップS10、ステップS14、ステップS16、及びステップS20を経由するパスである。   Path 1 is a path that passes through Step S10, Step S12, Step S16, and Step S20 of FIG. 2, and Path 2 is a path that passes through Step S10, Step S14, Step S16, and Step S18 of FIG. is there. Further, the path 3 is a path that passes through Step S10, Step S14, Step S16, and Step S20 of FIG.

パス1、パス2、及びパス3の各々のパス条件は、論理的に成立するため、充足可能である。なお、パス条件において、‘!’はNOT条件を表す。すなわち、‘!=’は右辺と左辺がイコールでないことを表している。   Each of the path conditions of path 1, path 2, and path 3 is logically satisfied and can be satisfied. In the pass condition, ‘! 'Represents a NOT condition. That is, ‘! = 'Indicates that the right side and the left side are not equal.

一方、パス4は、図2のステップS10、ステップS12、ステップS16、及びステップS18を経由するパスであるが、この際、パス4のパス条件は、(性別=男性)∧(性別=女性)となる。従って、パス4のパス条件は論理的に成立しない。すなわち、パス4のパス条件は充足可能でないためパス4は実行可能と判定されず、パスとして抽出されない。   On the other hand, the path 4 is a path that passes through step S10, step S12, step S16, and step S18 of FIG. 2. At this time, the path condition of the path 4 is (sex = male) ∧ (gender = female). It becomes. Therefore, the path condition of path 4 is not logically satisfied. That is, since the path condition of the path 4 cannot be satisfied, the path 4 is not determined to be executable and is not extracted as a path.

なお、パス条件の充足可能性の判定には、例えばSAT(satisfiability)、又はSMT(satisfiabilitymodulo theory)ソルバ等の制約ソルバが利用される。   In addition, for example, a constraint solver such as a SAT (satisfiability) or SMT (satisfiability modulus theory) solver is used to determine the satisfiability of the path condition.

このようにしてシンボリック実行により抽出された実行可能なパスの各々がテストケースとして生成され、パス毎のパス条件を充足する外部変数の値が、各テストケースに対応した被検査プログラムのテストデータとなる。   Each of the executable paths extracted by symbolic execution in this way is generated as a test case, and the value of the external variable that satisfies the path condition for each path is the test data of the program to be inspected corresponding to each test case. Become.

シンボリック実行におけるパス探索のアルゴリズムとして、パス網羅を実現するパス抽出法の1つである、深さ優先探索アルゴリズムが用いられることがある。   As a path search algorithm in symbolic execution, a depth-first search algorithm, which is one of path extraction methods for realizing path coverage, may be used.

深さ優先探索アルゴリズムは、被検査プログラムの開始点から終了点に向かって1つのパスを探索した後、探索したパス上をパスの分岐点がある地点まで遡り、当該分岐点でまだ選択されていない分岐先の経路を順次辿ることを繰り返すアルゴリズムである。   The depth-first search algorithm searches for one path from the start point to the end point of the program to be inspected, then goes back to the point where the path branch point is located on the searched path, and is still selected at the branch point. It is an algorithm that repeats the path of a non-branch destination sequentially.

シンボリック実行では、深さ優先探索アルゴリズムにより探索されたパスに対応するパス条件に対して、既に説明した制約ソルバを用いてパスの充足可能性を判定し、実行可能なパスを抽出する。   In the symbolic execution, the satisfiability of the path is determined using the previously described constraint solver for the path condition corresponding to the path searched by the depth-first search algorithm, and an executable path is extracted.

しかし、シンボリック実行時のパスの探索に深さ優先探索アルゴリズムを用いた場合、抽出されるパスの個数が、現実的には処理しきれない程度の膨大な数になる、所謂パス爆発が発生することがある。   However, when the depth-first search algorithm is used to search for a path during symbolic execution, a so-called path explosion occurs in which the number of extracted paths becomes so large that it cannot be processed in reality. Sometimes.

パス爆発が発生する原因としては、以下の2つの場合が考えられる。   The following two cases can be considered as causes of the path explosion.

パス爆発の1つ目の原因は、被検査プログラムの実行しうるパスの個数が無限にある場合である。例えば、被検査プログラムに繰り返し処理が含まれ、且つ、繰り返し終了条件にシンボル値が含まれる場合がこのケースに相当する。   The first cause of the path explosion is when the number of paths that can be executed by the program to be inspected is infinite. For example, this case corresponds to the case where the program to be inspected includes repetition processing and the repetition end condition includes a symbol value.

例えば、図4に示した被検査プログラムは、10行目から14行目にかけて繰り返し処理が含まれており、繰り返し処理を実行する度に、カウンタ変数の値を1ずつ増加させ、カウンタ変数の値が閾値変数より大きくなった場合に、繰り返し処理を終了する。   For example, the program to be inspected shown in FIG. 4 includes a repetition process from the 10th line to the 14th line, and every time the repetition process is executed, the value of the counter variable is incremented by one. When becomes larger than the threshold variable, the iterative process is terminated.

ここで、閾値変数は外部変数であるため、シンボリック実行の際、シンボル値として実行される。すなわち、シンボリック実行の際には閾値変数の値が不定となることから、繰り返し処理を継続するパスが常に存在し、パスの個数が無限となる。   Here, since the threshold variable is an external variable, it is executed as a symbol value during symbolic execution. That is, since the value of the threshold variable becomes indefinite during symbolic execution, there are always paths that continue to be repeated, and the number of paths is infinite.

また、図5に示した被検査プログラムは、15行目に実行先を外部処理に分岐させるPERFORM文を含んでおり、16行目に、外部処理に含まれるCALL文の戻り値に従って実行先を決定する条件分岐を含んでいる。なお、外部処理はサブルーチンとも称される場合がある。   In addition, the program to be inspected shown in FIG. 5 includes a PERFORM statement for branching the execution destination to the external process on the 15th line, and the execution destination according to the return value of the CALL statement included in the external process on the 16th line. Contains a conditional branch to be determined. External processing may also be referred to as a subroutine.

16行目の条件分岐では、戻り値が0の場合に外部処理を再帰呼び出しするため、CALL文の戻り値がシンボル値である場合、CALL文の戻り値が不定となることから、再帰呼び出し処理を継続するパスが常に存在し、パスの個数が無限となる。   In the conditional branch on the 16th line, when the return value is 0, the external process is recursively called. Therefore, if the return value of the CALL statement is a symbol value, the return value of the CALL statement becomes indefinite, so the recursive call process There are always paths that continue, and the number of paths is infinite.

パス爆発の2つ目の原因は、シンボリック実行におけるパス抽出の際、パス抽出に要する分析時間が現実的な時間を超過したり、パス抽出に要するメモリ量が、コンピュータに実装されているメモリ量を超過したりする場合である。例えば、被検査プログラムに、条件分岐命令が連続して多用されている場合がこのケースに相当する。   The second cause of the path explosion is that when extracting a path in symbolic execution, the analysis time required for path extraction exceeds the actual time, or the amount of memory required for path extraction is the amount of memory installed in the computer. It is a case of exceeding. For example, this case corresponds to a case where conditional branch instructions are frequently used continuously in the program to be inspected.

ここで、パス抽出に要する分析時間が現実的な時間を超過するとは、例えば、被検査プログラムに含まれるパスを抽出し終えるまでに要する時間が、予め予定された被検査プログラムの動作検証工程期間内に収まらない場合等をいう。   Here, the analysis time required for path extraction exceeds the realistic time, for example, the time required to finish extracting the path included in the program to be inspected is the operation verification process period of the program to be inspected in advance. When it does not fit within.

例えば、図6に示した被検査プログラムは、独立したIF文を20個含んでいる。このような独立したIF文がN個連続する場合、パス数は2のN乗個となり、図6の例では2の20乗個、すなわち1048576個のパスが被検査プログラムから抽出される。   For example, the program to be inspected shown in FIG. 6 includes 20 independent IF statements. When N such independent IF sentences are consecutive, the number of paths is 2 to the Nth power, and in the example of FIG. 6, 2 to the 20th power, that is, 1048576 paths are extracted from the program to be inspected.

一例として、コンピュータに実装されているメモリ量が1GB(ギガバイト)である場合、独立したIF文を15個含む被検査プログラムのパスを抽出することができる。しかし、独立したIF文を16個含む被検査プログラムのパスを抽出しようとすると、メモリ不足が発生し、被検査プログラムからパスを抽出できない。   As an example, when the amount of memory installed in the computer is 1 GB (gigabyte), the path of the program to be inspected including 15 independent IF statements can be extracted. However, if an attempt is made to extract a path of a program to be inspected that includes 16 independent IF statements, a memory shortage occurs and the path cannot be extracted from the program to be inspected.

この場合、コンピュータに実装するメモリ量を6倍の6GBに増設しても、独立したIF文を18個含む被検査プログラムのパスまでしか抽出することができない。この例からもわかるように、独立したIF文が連続することで、容易にパス爆発が発生することが理解される。   In this case, even if the amount of memory mounted on the computer is increased to 6 GB, which is six times, only the path of the program to be inspected including 18 independent IF statements can be extracted. As can be seen from this example, it is understood that a path explosion easily occurs when independent IF sentences are continued.

そこで、シンボリック実行におけるパス爆発を防止するパス抽出法として、深さ優先探索アルゴリズムに代表されるパス網羅より抽出パス数が抑制される分岐網羅、命令網羅等が用いられる場合がある。なお、命令網羅とは、被検査プログラムに含まれる全ての命令を実行するパス集合を抽出するパス抽出法である。   Therefore, as a path extraction method for preventing path explosion in symbolic execution, there are cases where branch coverage, instruction coverage, etc., in which the number of extracted paths is suppressed rather than path coverage represented by the depth-first search algorithm, may be used. Note that instruction coverage is a path extraction method for extracting a set of paths for executing all instructions included in a program to be inspected.

従来のパス爆発を防止するパス抽出法として、例えば、分岐ランダム探索方式、制御フローグラフ(Control Flow Graph:CFG)を利用する方式、及びDART等が存在する。   As a conventional path extraction method for preventing path explosion, there are, for example, a branch random search method, a method using a control flow graph (CFG), DART, and the like.

分岐ランダム探索方式とは、シンボリック実行で到達した条件分岐が分岐可能ならば、分岐先をランダムに選択して被検査プログラムからパスを抽出する方法である。CFGを利用する方式とは、まず、シンボリック実行する際に通過する可能性のある被検査プログラムの全経路をグラフで表した、所謂CFGを生成する。そして、生成したCFG上の未通過の命令文にシンボリック実行ラインが到達するように条件分岐の重み付けを行い、条件分岐の分岐先を、分岐条件の重み付けに基づいて決定する方法である。   The branch random search method is a method of extracting a path from a program to be inspected by randomly selecting a branch destination if a conditional branch reached by symbolic execution can be branched. In the method using CFG, first, a so-called CFG is generated in which all paths of a program to be inspected that may pass through symbolic execution are represented by a graph. The conditional branch is weighted so that the symbolic execution line reaches the non-passed command statement on the generated CFG, and the branch destination of the conditional branch is determined based on the branch condition weight.

また、DARTとは、分岐ランダム探索方式の改良版であり、まず、外部変数に具体的な値をランダムに設定した上で被検査プログラムを実行し、当該パス上のパス条件を収集する。次に、収集したパス条件から、既に通過したパスと異なるパスを通過する値を生成して、被検査プログラムから順次パスを抽出する。   DART is an improved version of the branch random search method. First, a specific value is randomly set in an external variable, the program to be inspected is executed, and path conditions on the path are collected. Next, from the collected path conditions, a value that passes a path different from the path that has already passed is generated, and paths are sequentially extracted from the program to be inspected.

以下に、図6に示した被検査プログラムから、DARTを用いてパスを抽出する例について説明する。   Hereinafter, an example of extracting a path using DART from the program to be inspected shown in FIG. 6 will be described.

手順A:項目1〜項目20の各々の外部変数の値を、仮に‘1’として設定する。
手順B:項目1〜項目20の各々の外部変数の値によりパス条件を収集する。例えば、手順Aで設定した外部変数値を用いた場合、「(項目1=1)∧(項目2=1)∧・・・∧(項目20=1)」のパス条件が収集される。
手順C:次に、手順Bで収集したパス条件の一部を否定したパス条件、例えば「!(項目1=1)∧(項目2=1)∧・・・∧(項目20=1)」を作成し、パス条件を充足する値を導き出す。本例の場合、例えば、項目1=‘2’、項目2〜項目20=‘1’の値が得られる。
Procedure A: The value of each external variable of item 1 to item 20 is temporarily set as “1”.
Procedure B: Collect path conditions based on the values of the external variables of items 1 to 20. For example, when the external variable value set in the procedure A is used, path conditions of “(item 1 = 1) ∧ (item 2 = 1) ∧... (Item 20 = 1)” are collected.
Procedure C: Next, a path condition in which a part of the path conditions collected in Procedure B is negated, for example, “! (Item 1 = 1) ∧ (item 2 = 1) ∧... ∧ (item 20 = 1)” To derive a value that satisfies the path condition. In the case of this example, for example, values of item 1 = “2”, item 2 to item 20 = “1” are obtained.

以降、パス抽出に関する終了条件、例えば分岐網羅を満たすまで手順B及び手順Cを繰り返し、被検査プログラムからパスを抽出する。   Thereafter, the procedure B and procedure C are repeated until an end condition related to path extraction, for example, branch coverage is satisfied, and a path is extracted from the program to be inspected.

しかしながら、分岐ランダム探索方式、CFGを利用する方式、及びDARTには、以下に示すような問題点が存在する。   However, the branch random search method, the method using CFG, and DART have the following problems.

分岐ランダム探索方式では、条件分岐の分岐先をランダムに選択するため、未通過の分岐先を意図的に選択することができない。従って、分岐網羅を実現するテストケースを得ようとした場合、パス探索の繰り返し回数が増大する上、被検査プログラムから抽出されるパス数も偶然性に左右されるという問題点が存在する。   In the branch random search method, since the branch destination of the conditional branch is selected at random, the branch destination that has not passed cannot be selected intentionally. Therefore, when trying to obtain a test case that realizes branch coverage, there are problems that the number of repetitions of the path search increases and the number of paths extracted from the program to be inspected also depends on chance.

CFGを利用する方式では、被検査プログラムを静的解析して、被検査プログラムに含まれる全経路を予めグラフ化した上で、更に、条件分岐の重み付けを実施する必要がある。従って、1つのパスに数十程度の条件分岐が含まれるような大規模な被検査プログラムへCFGを利用する方法を適用した場合、被検査プログラムの静的解析に要する計算量が増大し、計算時間及びメモリ量等の制約から適用困難となる場合がある。   In the method using the CFG, it is necessary to statically analyze the program to be inspected, graph all routes included in the program to be inspected in advance, and further weight the conditional branches. Therefore, when the method using CFG is applied to a large program to be inspected that includes several tens of conditional branches in one path, the amount of calculation required for static analysis of the program to be inspected increases, It may be difficult to apply due to constraints such as time and memory amount.

また、DARTでは、分岐網羅を実現するパス集合を生成する際、分岐網羅を実現する最小のパス集合に比べて、より多くのパスを含んだパス集合を生成してしまうという問題点が存在する。   In addition, in DART, when generating a path set that realizes branch coverage, there is a problem that a path set including more paths is generated than the minimum path set that realizes branch coverage. .

例えば、既に説明したように、DARTによって図6に示した被検査プログラムからパスを抽出する場合、まず、手順Aで収集したパス条件に対応したパスが1つ抽出される。そして、手順Aで収集したパス条件に対して、(項目1=1)から(項目20=1)までの各分岐条件を順次否定しながら20個のパスを抽出することから、手順Aで抽出したパスと合わせて、合計21個のパスが抽出されることになる。   For example, as described above, when a path is extracted from the program to be inspected shown in FIG. 6 by DART, first, one path corresponding to the path condition collected in the procedure A is extracted. Then, for the path conditions collected in procedure A, 20 paths are extracted while sequentially negating each branch condition from (item 1 = 1) to (item 20 = 1). In total, a total of 21 paths are extracted.

しかし、図6に示した被検査プログラムの場合、例えば、各条件分岐において全てTHEN側に分岐するパスと、全てELSE側に分岐するパスとの2つのパスで分岐網羅を実現することができるため、分岐網羅を実現する最小のパス数は2となる。   However, in the case of the program to be inspected shown in FIG. 6, for example, branch coverage can be realized by two paths: a path that branches all to the THEN side and a path that branches all to the ELSE side in each conditional branch. The minimum number of paths for realizing branch coverage is 2.

一方、開示の技術は、従来の分岐網羅に用いられるパス抽出法と比較して、より少数のパスで分岐網羅度を向上させることができるパス集合を被検査プログラムから抽出する。   On the other hand, the disclosed technique extracts from the program to be inspected a path set that can improve the branch coverage with a smaller number of paths as compared with the conventional path extraction method used for branch coverage.

図7には、本実施の形態に係るテストケース生成装置10が示されている。テストケース生成装置10は、入力部12、シンボリック実行部14、制御部16、深さ優先探索部18、管理部20、選択部22、生成部24、検出部26、及び出力部28を含む。   FIG. 7 shows a test case generation apparatus 10 according to the present embodiment. The test case generation device 10 includes an input unit 12, a symbolic execution unit 14, a control unit 16, a depth priority search unit 18, a management unit 20, a selection unit 22, a generation unit 24, a detection unit 26, and an output unit 28.

テストケース生成装置10は、シンボリック実行技術により被検査プログラム30を実行し、被検査プログラム30の動作を検証するためのテストケース32を生成するための装置である。   The test case generation apparatus 10 is an apparatus for generating a test case 32 for executing an inspected program 30 by a symbolic execution technique and verifying the operation of the inspected program 30.

入力部12は、被検査プログラム30を受け付け、被検査プログラム30をテストケース生成装置10内部に取り込む。   The input unit 12 receives the program to be inspected 30 and takes the program to be inspected 30 into the test case generation apparatus 10.

シンボリック実行部14は、入力部12を介して受け付けた被検査プログラム30に含まれる外部変数に具体的な値を設定する代わりにシンボル値を設定する。そして、外部変数をシンボル値としたまま、制御部16によって探索された被検査プログラム30に含まれるパスを模擬的に実行し、被検査プログラム30からパスを抽出する。そして、実行したパス毎にパス条件を抽出し、1つのパスと当該パスに対応したパス条件の組み合わせを1つのテストケースとして、複数のテストケースを生成する。また、各テストケースのパス条件を充足する外部変数の値を生成し、テストケースに対応した被検査プログラム30のテストデータとする。   The symbolic execution unit 14 sets a symbol value instead of setting a specific value for the external variable included in the program 30 to be inspected received via the input unit 12. Then, a path included in the inspected program 30 searched by the control unit 16 is simulated while the external variable is set as a symbol value, and a path is extracted from the inspected program 30. Then, a path condition is extracted for each executed path, and a plurality of test cases are generated by using one path and a combination of path conditions corresponding to the path as one test case. In addition, a value of an external variable that satisfies the pass condition of each test case is generated and used as test data of the inspected program 30 corresponding to the test case.

制御部16は、シンボリック実行の際に、後述する深さ優先探索部18、管理部20、選択部22、生成部24、及び検出部26の各機能部を制御して、被検査プログラム30に含まれるパスの探索を実行する。そして、制御部16は、探索したパスをシンボリック実行部14に引き渡す。   The control unit 16 controls the function units of the depth priority search unit 18, the management unit 20, the selection unit 22, the generation unit 24, and the detection unit 26, which will be described later, in the symbolic execution, so that the program to be inspected 30. Perform a search for included paths. Then, the control unit 16 passes the searched path to the symbolic execution unit 14.

深さ優先探索部18は、深さ優先探索アルゴリズムに基づいて、被検査プログラム30から網羅的にパスを探索する。   The depth priority search unit 18 comprehensively searches for paths from the program to be inspected 30 based on a depth priority search algorithm.

図8は、深さ優先探索部18において実行される、図6に示した被検査プログラムのパス探索のアルゴリズムを説明した図である。   FIG. 8 is a diagram for explaining the path search algorithm of the program to be inspected shown in FIG.

任意のパス1が探索されると、パス1終点から(項目20=1)の分岐点まで遡り、未選択の分岐側を選択してパス2を探索する。次に、パス2終点から未選択の分岐先を有する分岐点、この場合(項目19=1)の分岐点まで遡り、未選択の分岐側を選択してパス3を探索する。以後、同様の処理を繰り返して、被検査プログラム30に含まれるパスを網羅的に探索する。   When an arbitrary path 1 is searched, the path 2 is searched by selecting an unselected branch side from the end point of the path 1 to the branch point (item 20 = 1). Next, the path 3 is searched by going back to the branch point having the unselected branch destination from the end point of the path 2, to the branch point in this case (item 19 = 1), and selecting the unselected branch side. Thereafter, the same processing is repeated to exhaustively search for paths included in the program 30 to be inspected.

なお、深さ優先探索部18は、被検査プログラム30からパスを網羅的に探索する場合に制御部16によって呼び出される機能部であり、テストケース生成装置10が分岐網羅によるパス抽出を実行する場合には、必須の機能部ではない。   The depth-first search unit 18 is a functional unit that is called by the control unit 16 when exhaustively searching for paths from the program to be inspected 30, and the test case generation device 10 executes path extraction by branch coverage. Is not an essential functional part.

管理部20は、制御部16によって探索されたパスの実行順に基づいて、被検査プログラム30に含まれる条件分岐毎に、分岐先への分岐実行回数を管理する。以下では、管理部20の機能について詳細に説明する。   The management unit 20 manages the number of branch executions to the branch destination for each conditional branch included in the program 30 to be inspected based on the execution order of the paths searched by the control unit 16. Below, the function of the management part 20 is demonstrated in detail.

図9は、本実施の形態に係る被検査プログラム30の一例を示した図である。図9に示した被検査プログラム30には、条件分岐命令であるIF文が13行目、19行目、及び25行目の合計3箇所に存在する。また、16行目、20行目、26行目、及び36行目に、被検査プログラム30の終了を意味する「EXIT PROGRAM」が存在する。   FIG. 9 is a diagram showing an example of the program to be inspected 30 according to the present embodiment. In the program to be inspected 30 shown in FIG. 9, IF statements that are conditional branch instructions exist in a total of three locations on the 13th line, the 19th line, and the 25th line. Further, “EXIT PROGRAM” indicating the end of the program to be inspected 30 exists on the 16th, 20th, 26th, and 36th lines.

図10は、図9に示した被検査プログラム30をフローチャートで示した図である。ステップS30、ステップS34、及びステップS38の各処理が、それぞれ図9の被検査プログラム30の13行目、19行目、及び25行目の条件分岐に対応する。また、ステップS32、ステップS36、及びステップS40の各処理が、それぞれ図9の被検査プログラム30の14行目、22行目、及び28行目の処理に対応する。   FIG. 10 is a flowchart of the program to be inspected 30 shown in FIG. Each process of step S30, step S34, and step S38 corresponds to the conditional branch of the 13th line, the 19th line, and the 25th line of the inspected program 30 in FIG. In addition, each process of step S32, step S36, and step S40 corresponds to the process of the 14th line, the 22nd line, and the 28th line of the program 30 to be inspected in FIG.

図11は、管理部20で実行される、図9に示した被検査プログラム30の管理内容を示した図である。まず、管理部20は、被検査プログラム30から条件分岐命令であるIF文を取得する。そして、管理部20は、制御部16によって初めて被検査プログラム30のパス探索が開始される前の状態、すなわち初期状態において、各IF文の分岐実行回数を、例えば「直接=(0、0)」のように初期化する。ここで、「直接」とは、対応するIF文がPERFORM文等で呼び出される外部処理のIF文として実行されるものではないことを意味している。また、(0、0)とは、並び順に、IF文におけるTHEN側の分岐実行回数、ELSE側の分岐実行回数を表している。   FIG. 11 is a diagram showing the management contents of the program 30 to be inspected shown in FIG. First, the management unit 20 acquires an IF statement that is a conditional branch instruction from the program to be inspected 30. Then, the management unit 20 sets the number of branch executions of each IF statement in the state before the path search of the program 30 to be inspected for the first time by the control unit 16, that is, in the initial state, for example, “direct = (0, 0)”. ”. Here, “directly” means that the corresponding IF statement is not executed as an IF statement of an external process called by a PERFORM statement or the like. Further, (0, 0) represents the number of branch executions on the THEN side and the number of branch executions on the ELSE side in the IF statement in the order of arrangement.

例えば、制御部16によって、図10に示すステップS30→ステップS32→ステップS34→エンドで表されるパスが探索されたとする。この場合、13行目のIF文ではTHEN側の分岐(THEN分岐)が選択されたため、IF文(13行目)のTHEN側の分岐実行回数を1増やして、「直接=(1、0)」とする。また、19行目のIF文でもTHEN分岐が選択されたため、IF文(19行目)の分岐実行回数を、「直接=(1、0)」とする。   For example, assume that the control unit 16 searches for a path represented by step S30 → step S32 → step S34 → end shown in FIG. In this case, since the branch on the THEN side (THEN branch) is selected in the IF statement on the 13th line, the number of branch executions on the THEN side of the IF statement (13th line) is increased by 1, and “direct = (1, 0) " Also, since the THEN branch is selected in the IF statement on the 19th line, the number of branch executions of the IF statement (19th line) is “direct = (1, 0)”.

次に、制御部16によって、例えば、ステップS30→エンドで表されるパスが探索されたとする。この場合、13行目のIF文ではELSE側の分岐(ELSE分岐)が選択されたため、IF文(13行目)のELSE側の分岐実行回数を1増やして、「直接=(1、1)」とする。   Next, suppose that the control unit 16 searches for a path represented by, for example, step S30 → end. In this case, since the branch on the ELSE side (ELSE branch) is selected in the IF statement on the 13th line, the number of branch executions on the ELSE side of the IF statement (13th line) is increased by 1 and “direct = (1, 1)”. "

引き続き、制御部16によって、例えば、ステップS30→ステップS32→ステップS34→ステップS36→ステップS38→エンドで表されるパスが探索されたとする。この場合、上記と同様の方法により、IF文(13行目)の分岐実行回数を「直接=(2、1)」、IF文(19行目)の分岐実行回数を「直接=(1、1)」、IF文(25行目)の分岐実行回数を「直接=(1、0)」とする。   Next, assume that the control unit 16 searches for a path represented by, for example, step S30 → step S32 → step S34 → step S36 → step S38 → end. In this case, the number of branch executions of the IF statement (line 13) is “direct = (2, 1)” and the number of branch executions of the IF statement (line 19) is “direct = (1, 1) ”, and the IF statement (25th line) branch execution count is“ direct = (1, 0) ”.

以下、制御部16によってパスが探索される度に、上記に説明した方法に従って、探索されたパスによって実行されたIF文の分岐実行回数を更新する。   Thereafter, every time a path is searched for by the control unit 16, the number of branch executions of the IF statement executed by the searched path is updated according to the method described above.

なお、条件分岐命令には、IF文の他に、複数の異なる処理の中から条件に合った処理を選択するEVALUATE文のような多分岐命令も含まれる。   In addition to the IF statement, the conditional branch instruction includes a multi-branch instruction such as an EVALUATE statement that selects a process that meets a condition from a plurality of different processes.

図12は、EVALUATE文が含まれる被検査プログラム30の例を示した図である。   FIG. 12 is a diagram showing an example of the inspected program 30 including the EVALUATE sentence.

図12に示した被検査プログラム30には、12行目及び23行目に2つのEVALUATE文が含まれている。   The inspected program 30 shown in FIG. 12 includes two EVALUATE statements on the 12th and 23rd lines.

管理部20は初期状態において、12行目のEVALUATE文の分岐実行回数を、例えば「直接=(0、0、0、0)」のように初期化する。ここで(0、0、0、0)とは、並び順に、変数1が‘A’の場合の分岐実行回数、変数1が‘B’の場合の分岐実行回数、変数1が‘C’の場合の分岐実行回数、変数1が‘A’、‘B’、‘C’の何れの場合にも該当しない場合の分岐実行回数を表している。   In the initial state, the management unit 20 initializes the branch execution count of the EVALUATE statement on the 12th line, for example, “direct = (0, 0, 0, 0)”. Here, (0, 0, 0, 0) means the number of branch executions when the variable 1 is “A”, the number of branch executions when the variable 1 is “B”, and the variable 1 is “C”. Represents the number of branch executions in the case where the variable 1 does not correspond to any of “A”, “B”, and “C”.

また、管理部20は初期化状態において、23行目のEVALUATE文の分岐実行回数を、例えば「直接=(0、0、0)」のように初期化する。   In addition, the management unit 20 initializes the number of branch executions of the EVALUATE statement on the 23rd line in the initialization state, for example, “direct = (0, 0, 0)”.

そして、管理部20は、IF文における分岐実行回数の管理と同様に、EVALUATE文の分岐実行回数を管理する。例えば制御部16によって、14行目及び25行目のDISPLAY文を実行するパスが探索された場合、EVALUATE文(12行目)の分岐実行回数は、「直接=(1、0、0、0)」となる。また、EVALUATE文(23行目)の分岐実行回数は、「直接=(1、0、0)」となる。   Then, the management unit 20 manages the number of branch executions of the EVALUATE statement, similarly to the management of the number of branch executions in the IF statement. For example, when the control unit 16 searches for paths for executing the DISPLAY statements on the 14th and 25th lines, the number of branch executions of the EVALUATE statement (12th line) is “direct = (1, 0, 0, 0 ) ”. The number of branch executions of the EVALUATE statement (the 23rd line) is “direct = (1, 0, 0)”.

選択部22は、制御部16が被検査プログラム30からパスを探索する際に、制御部16から呼び出される機能部であり、パスが条件分岐に到達する毎に予め定めたパス選択規則に従って、分岐先を選択する。ここで、パス選択規則とは、条件分岐における分岐先を選択するための規則である。   The selection unit 22 is a functional unit that is called from the control unit 16 when the control unit 16 searches for a path from the program to be inspected 30, and branches according to a predetermined path selection rule every time the path reaches a conditional branch. Select the destination. Here, the path selection rule is a rule for selecting a branch destination in a conditional branch.

パス選択規則の一例として、例えば、選択部22は、パス上の条件分岐命令が分岐可能である場合に、管理部20によって管理される条件分岐毎の分岐実行回数に基づいて、分岐実行回数が少ない方の分岐を選択する。なお、条件分岐の分岐実行回数が同数である場合には、予め定めた選択規則に従って、分岐先を選択する。   As an example of the path selection rule, for example, when the conditional branch instruction on the path can branch, the selection unit 22 determines the branch execution count based on the branch execution count for each conditional branch managed by the management unit 20. Select the smaller branch. If the number of branch executions of the conditional branch is the same, the branch destination is selected according to a predetermined selection rule.

ここで、予め定めた選択規則とは、例えば条件分岐命令における最初の分岐を選択する等の規則をいう。具体的には、一例として、IF文の分岐実行回数が同数である場合、THEN分岐を選択する。なお、予め定めた選択規則はこれに限定されるものではなく、例えば、ELSE分岐を選択するようにしてもよい。   Here, the predetermined selection rule refers to a rule such as selecting the first branch in a conditional branch instruction. Specifically, as an example, when the number of IF statement branch executions is the same, the THEN branch is selected. Note that the predetermined selection rule is not limited to this, and for example, an ELSE branch may be selected.

また、条件分岐命令が分岐可能とは、条件分岐命令における各々の分岐の分岐条件が、共に充足可能である状態をいう。   Further, the conditional branch instruction being able to branch means a state where both branch conditions of the conditional branch instruction can be satisfied.

例えば、図9に示した被検査プログラム30の13行目のIF文は、(項目1=1)か否かが分岐条件となる。この場合、THEN分岐は分岐条件:(項目1=1)がTRUEの場合に選択される。一方、ELSE分岐は分岐条件:(項目1=1)がFALSEの場合に選択されるが、これは、分岐条件:!(項目1=1)がTRUEの場合に選択されると解釈することができる。   For example, the IF statement on the 13th line of the program to be inspected 30 shown in FIG. 9 is whether or not (item 1 = 1) is a branching condition. In this case, the THEN branch is selected when the branch condition: (item 1 = 1) is TRUE. On the other hand, the ELSE branch is selected when the branch condition: (item 1 = 1) is FALSE. It can be interpreted that (item 1 = 1) is selected when TRUE.

分岐条件に含まれる変数:項目1は外部変数であるため、図9に示した被検査プログラム30単体でシンボリック実行した場合には、変数:項目1はシンボル値に置き換えられる。従って、分岐条件:(項目1=1)の真偽値を確定することができない。   Since the variable: item 1 included in the branch condition is an external variable, when the program under test 30 shown in FIG. 9 is symbolically executed, the variable: item 1 is replaced with a symbol value. Therefore, the true / false value of the branch condition (item 1 = 1) cannot be determined.

そこで選択部22は、THEN分岐の分岐条件:(項目1=1)、及びELSE分岐の分岐条件:!(項目1=1)の充足可能性を判断する。この場合、THEN分岐の分岐条件とELSE分岐の分岐条件は共に充足可能であることから、選択部22は、図9に示した被検査プログラム30の13行目のIF文を分岐可能と判定し、THEN分岐とELSE分岐の2つの分岐の中から分岐先を選択する。   Therefore, the selection unit 22 determines the branch condition for THEN branch: (item 1 = 1) and the branch condition for ELSE branch:! Judge the possibility of satisfying (Item 1 = 1). In this case, since both the branch condition of the THEN branch and the branch condition of the ELSE branch can be satisfied, the selection unit 22 determines that the IF statement on the thirteenth line of the program under test 30 shown in FIG. , The branch destination is selected from the two branches, the THEN branch and the ELSE branch.

図13は、選択部22において、既に説明したパス選択規則のみに従って、図9に示した被検査プログラム30から探索されたパスの一例を示した図である。   FIG. 13 is a diagram showing an example of a path searched by the inspected program 30 shown in FIG. 9 in the selection unit 22 only according to the path selection rule already described.

図11に示したように、1回目のパス探索前では、管理部20によって管理される条件分岐毎の分岐実行回数は初期状態にある。   As shown in FIG. 11, before the first path search, the number of branch executions for each conditional branch managed by the management unit 20 is in an initial state.

従って、1回目のパス探索では、IF文(13行目)は分岐可能であり、且つ、分岐実行回数が(0、0)であることから、THEN分岐が選択される。そして、IF文(19行目)も分岐可能であり、且つ、分岐実行回数が(0、0)であることから、THEN分岐が選択され、図10におけるステップS30→ステップS32→ステップS34→エンドで表されるパス1が選択される。   Therefore, in the first path search, the IF statement (line 13) can be branched and the branch execution count is (0, 0), so the THEN branch is selected. Since the IF statement (line 19) can also be branched and the number of branch executions is (0, 0), the THEN branch is selected, and step S30 → step S32 → step S34 → end in FIG. Is selected.

次いで、2回目のパス探索では、IF文(13行目)の分岐実行回数が管理部20によって(1、0)に更新されていることから、分岐実行回数がより少ないELSE分岐が選択され、図10におけるステップS30→エンドで表されるパス2が選択される。   Next, in the second path search, the branch execution count of the IF statement (line 13) has been updated to (1, 0) by the management unit 20, so that an ELSE branch with a smaller branch execution count is selected. A path 2 represented by step S30 → end in FIG. 10 is selected.

次いで、3回目のパス探索では、IF文(13行目)の分岐実行回数が管理部20によって(1、1)に更新されていることから、THEN分岐が選択される。そして、IF文(19行目)の分岐実行回数も管理部20によって(1、0)に更新されていることから、分岐実行回数がより少ないELSE分岐が選択される。そして、IF文(25行目)の分岐実行回数は初期状態のまま(0、0)であることから、THEN分岐が選択され、図10におけるステップS30→ステップS32→ステップS34→ステップS36→ステップS38→エンドで表されるパス3が選択される。   Next, in the third path search, the THEN branch is selected because the number of branch executions of the IF statement (line 13) is updated to (1, 1) by the management unit 20. Since the branch execution count of the IF statement (line 19) is also updated to (1, 0) by the management unit 20, an ELSE branch having a smaller branch execution count is selected. Since the number of branch executions of the IF statement (line 25) remains in the initial state (0, 0), the THEN branch is selected, and step S30 → step S32 → step S34 → step S36 → step in FIG. The path 3 represented by S38 → end is selected.

以降、分岐網羅が実現されるまで、選択部22において同様のパス選択規則を繰り返すことで、図13におけるパス1からパス7までの7個のパスが選択される。   Thereafter, until the branch coverage is realized, the selection unit 22 repeats the same path selection rule, so that seven paths from the path 1 to the path 7 in FIG. 13 are selected.

生成部24は、選択部22によって選択された被検査プログラム30のパスに対して、既に選択部22によって選択されたパス(既出パス)であることを示すための、パスの重複を検出するためのルール(重複パス検出ルール)を生成する。   The generation unit 24 detects path duplication to indicate that the path of the program 30 to be inspected selected by the selection unit 22 is already selected by the selection unit 22 (existing path). Rule (duplicate path detection rule) is generated.

図14は、図9に示した被検査プログラム30を例にして、生成部24における重複パス検出ルールの生成方法の一例を示した図である。   FIG. 14 is a diagram showing an example of a duplicate path detection rule generation method in the generation unit 24, taking the program to be inspected 30 shown in FIG. 9 as an example.

生成部24は、後述する検出部26により生成される優先分岐番号と、選択部22でパス選択規則に従って選択されたパスと、に基づいて、重複パス検出ルールを生成する。ここで、優先分岐番号とは、選択部22がパス選択規則に従った場合に、次に選択される条件分岐毎の分岐先を表す番号である。   The generation unit 24 generates a duplicate path detection rule based on the priority branch number generated by the detection unit 26 described later and the path selected by the selection unit 22 according to the path selection rule. Here, the priority branch number is a number representing a branch destination for each conditional branch to be selected next when the selection unit 22 complies with the path selection rule.

図14に示すように、初期状態では管理部20によって管理される全ての条件分岐の分岐実行回数は(0、0)となるため、条件分岐の各々では、パス選択規則に基づいてTHEN分岐が選択されることになる。従って、例えばTHEN分岐を‘0’、ELSE分岐を‘1’で表した場合、検出部26では、IF文(13行目)、IF文(19行目)、IF文(25行目)の各々の条件分岐の分岐先を‘0’に設定した優先分岐番号を生成する。   As shown in FIG. 14, in the initial state, the number of branch executions of all conditional branches managed by the management unit 20 is (0, 0). Therefore, in each conditional branch, the THEN branch is based on the path selection rule. Will be selected. Therefore, for example, when the THEN branch is represented by “0” and the ELSE branch is represented by “1”, the detection unit 26 performs the IF sentence (13th line), IF sentence (19th line), and IF sentence (25th line). A priority branch number in which the branch destination of each conditional branch is set to “0” is generated.

一方、シンボリック実行部14によって、選択部22で選択されたパスに沿ってシンボリック実行が行われ、被検査プログラム30からパスが抽出されると、管理部20によって管理される条件分岐毎の分岐実行回数が、抽出されたパスの実行に伴い更新される。   On the other hand, when symbolic execution is performed by the symbolic execution unit 14 along the path selected by the selection unit 22 and a path is extracted from the program 30 to be inspected, branch execution for each conditional branch managed by the management unit 20 The number of times is updated as the extracted path is executed.

生成部24は、抽出されたパスによって被検査プログラム30の分岐網羅度が向上した場合に、抽出されたパスによって実行された条件分岐に対応した優先分岐番号を重複パス検出ルールとして生成する。   When the branch coverage of the program 30 to be inspected is improved by the extracted path, the generation unit 24 generates a priority branch number corresponding to the conditional branch executed by the extracted path as a duplicate path detection rule.

例えば、生成部24は、図14において、1回目のシンボリック実行により図13に示すパス1が抽出された場合、「優先分岐番号が{(IF文(13行目)=0)∧(IF文(19行目)=0)}ならば、パス1と重複する」というルール1を生成する。   For example, when the path 1 shown in FIG. 13 is extracted by the first symbolic execution in FIG. 14, the generation unit 24 selects “priority branch number {(IF sentence (13th line) = 0) ∧ (IF sentence If (19th line) = 0)}, the rule 1 “overlapping with the path 1” is generated.

図14では、説明を簡略化するため、例えば、被検査プログラム30に含まれる各々の条件分岐に対応した優先分岐番号のうち、何れの優先分岐番号が重複パス検出ルールに適用されるのかを示す識別子‘*’を優先分岐番号に対応した判定欄に付与している。   In FIG. 14, to simplify the description, for example, which priority branch number among the priority branch numbers corresponding to each conditional branch included in the program to be inspected 30 is applied to the duplicate path detection rule. The identifier “*” is assigned to the determination column corresponding to the priority branch number.

1回目のシンボリック実行後、検出部26は、管理部20によって管理される条件分岐毎の分岐実行回数に基づいて、優先分岐番号を生成する。1回目のシンボリック実行後、IF文毎の分岐実行回数は図14に示すように、{(1、0)、(1、0)、(0、0)}となる。ここで、1番目の小括弧はIF文(13行目)の分岐実行回数、2番目の小括弧はIF文(19行目)の分岐実行回数、3番目の小括弧はIF文(25行目)の分岐実行回数を表す。   After the first symbolic execution, the detection unit 26 generates a priority branch number based on the number of branch executions for each conditional branch managed by the management unit 20. After the first symbolic execution, the number of branch executions for each IF statement is {(1, 0), (1, 0), (0, 0)} as shown in FIG. Here, the first parenthesis is the number of branch executions of the IF statement (line 13), the second parenthesis is the number of branch executions of the IF statement (line 19), and the third parenthesis is the IF statement (line 25). This represents the number of branch executions.

従って、パス選択規則に基づいて、1回目のシンボリック実行後に生成される優先分岐番号は(1、1、0)となる。ここで、1番目の数値はIF文(13行目)の優先分岐番号、2番目の数値はIF文(19行目)の優先分岐番号、3番目の数値はIF文(25行目)の優先分岐番号を表す。   Therefore, based on the path selection rule, the priority branch number generated after the first symbolic execution is (1, 1, 0). Here, the first number is the priority branch number of the IF statement (line 13), the second number is the priority branch number of the IF statement (line 19), and the third number is the IF statement (line 25). Represents the priority branch number.

そして生成部24は、2回目のシンボリック実行により図13に示すパス2が抽出された場合、「優先分岐番号が(IF文(13行目)=1)ならば、パス2と重複する」というルール2を生成する。   When the path 2 shown in FIG. 13 is extracted by the second symbolic execution, the generation unit 24 says “If the priority branch number is (IF statement (13th line) = 1), it overlaps with path 2”. Rule 2 is generated.

2回目のシンボリック実行後、管理部20によって管理される条件分岐毎の分岐実行回数は、図14に示すように、{(1、1)、(1、0)、(0、0)}となる。従って、パス選択規則に基づいて、2回目のシンボリック実行後に生成される優先分岐番号は、(0、1、0)となる。そして生成部24は、3回目のシンボリック実行により図13に示すパス3が抽出された場合、「優先分岐番号が{(IF文(13行目)=0)∧(IF文(19行目)=1)∧(IF文(25行目)=0)}ならば、パス3と重複する」というルール3を生成する。   After the second symbolic execution, the number of branch executions for each conditional branch managed by the management unit 20 is {(1, 1), (1, 0), (0, 0)} as shown in FIG. Become. Therefore, the priority branch number generated after the second symbolic execution based on the path selection rule is (0, 1, 0). Then, when the path 3 shown in FIG. 13 is extracted by the third symbolic execution, the generation unit 24 “the priority branch number is {(IF sentence (13th line) = 0) ∧ (IF sentence (19th line)). = 1) ∧ (IF statement (25th line) = 0)}, rule 3 is generated, which overlaps with path 3.

以降、同様の処理に従って、生成部24は、シンボリック実行によるパスの抽出が終了するまで、重複パス検出ルールを生成する。なお、優先分岐番号は、分岐情報の一例である。   Thereafter, according to the same processing, the generation unit 24 generates duplicate path detection rules until the extraction of paths by symbolic execution is completed. The priority branch number is an example of branch information.

既に説明したように、選択部22でパス選択規則のみに従って図9に示した被検査プログラム30からパスの選択をした場合、例えば、図13に示すような分岐網羅を実現する7つのパスが選択される場合がある。   As already described, when the selection unit 22 selects a path from the program to be inspected 30 shown in FIG. 9 according to only the path selection rule, for example, seven paths that realize branch coverage as shown in FIG. 13 are selected. May be.

しかし、この場合、パス4及びパス6はパス2と重複したパスであり、パス5はパス1と重複したパスである。従って、パス4、パス6、及びパス5に基づいたシンボリック実行から新たなテストケースが生成されることはなく、テストケースの生成時間が無駄になるばかりか、被検査プログラム30の品質向上に寄与しない重複したテストケースが生成されることになる。   However, in this case, the path 4 and the path 6 are paths that overlap with the path 2, and the path 5 is a path that overlaps with the path 1. Therefore, a new test case is not generated from the symbolic execution based on the path 4, the path 6, and the path 5, and the generation time of the test case is not only wasted, but also contributes to the quality improvement of the inspected program 30. Duplicate test cases will be generated.

従って、検出部26は、管理部20によって管理される条件分岐毎の分岐実行回数に基づき、パス探索前にパス選択規則に従って優先分岐番号を生成し、優先分岐番号によって表されるパス候補を取得する。そして、検出部26は、選択部22によるパスの選択前に、パス候補に対応した優先分岐番号と、生成部24で生成された重複パス検出ルールとを比較して、次のシンボリック実行により抽出される予定のパスが、既出パスと一致するか否かを検出する。   Therefore, based on the number of branch executions for each conditional branch managed by the management unit 20, the detection unit 26 generates a priority branch number according to a path selection rule before path search, and acquires a path candidate represented by the priority branch number. To do. Then, the detection unit 26 compares the priority branch number corresponding to the path candidate with the duplicate path detection rule generated by the generation unit 24 before extraction of the path by the selection unit 22, and extracts the next symbolic execution. It is detected whether or not the scheduled path matches the already-existing path.

図15及び図16は、図9に示した被検査プログラム30に対する検出部26の処理を示した図である。   15 and 16 are diagrams showing the processing of the detection unit 26 for the program to be inspected 30 shown in FIG.

検出部26は、初期状態における条件分岐毎の分岐実行回数に基づいて、パス選択規則に従い、優先分岐番号を生成する。この際に生成される優先分岐番号は(0、0、0)となる。そして、検出部26は、生成された優先分岐番号と、生成部24によって生成された重複パス検出ルールとを比較して、重複パス検出ルールの中に、生成された優先分岐番号によって表されるパス候補と重複するルールが存在するか否かを判定する。   The detection unit 26 generates a priority branch number according to the path selection rule based on the number of branch executions for each conditional branch in the initial state. The priority branch number generated at this time is (0, 0, 0). Then, the detection unit 26 compares the generated priority branch number with the duplicate path detection rule generated by the generation unit 24, and is represented by the generated priority branch number in the duplicate path detection rule. It is determined whether there is a rule that overlaps with the path candidate.

そして、検出部26は、生成された優先分岐番号によって表されるパス候補と重複するルールが存在する場合には、シンボリック実行部14でのシンボリック実行によるパス抽出処理が行われないようにする。一方、検出部26は、生成された優先分岐番号によって表されるパス候補と重複するルールが存在しない場合には、シンボリック実行部14でのシンボリック実行によるパス抽出処理が行われるようにする。   Then, when there is a rule that overlaps with the path candidate represented by the generated priority branch number, the detection unit 26 prevents the path extraction process by the symbolic execution unit 14 from being performed. On the other hand, when there is no rule that overlaps with the path candidate represented by the generated priority branch number, the detection unit 26 performs the path extraction process by symbolic execution in the symbolic execution unit 14.

具体的には、テストケース生成装置10が初期状態の場合、まだ重複パス検出ルールが存在しないため、選択部22において図13のパス1が選択され、生成部24においてパス1に対応した重複パス検出ルール:ルール1が生成される。   Specifically, when the test case generation device 10 is in the initial state, there is no duplicate path detection rule yet, so the selection unit 22 selects the path 1 in FIG. 13 and the generation unit 24 selects the duplicate path corresponding to the path 1. Detection rule: Rule 1 is generated.

1回目の重複パス検出処理後、管理部20によって管理される条件分岐毎の分岐実行回数は、図15に示すように、{(1、0)、(1、0)、(0、0)}となる。従って、次に検出部26によって生成される優先分岐番号は、(1、1、0)となる。この場合、重複パス検出ルールにはルール1しか存在しないため、生成された優先分岐番号によって表されるパス候補と重複するルールは存在しない。従って、選択部22において図13のパス2が選択され、生成部24においてパス2に対応した重複パス検出ルール:ルール2が生成される。   After the first overlapping path detection process, the branch execution count for each conditional branch managed by the management unit 20 is {(1, 0), (1, 0), (0, 0) as shown in FIG. }. Therefore, the priority branch number generated by the detection unit 26 next is (1, 1, 0). In this case, since there is only rule 1 in the duplicate path detection rule, there is no rule that duplicates the path candidate represented by the generated priority branch number. Therefore, the selection unit 22 selects the path 2 in FIG. 13, and the generation unit 24 generates the duplicate path detection rule: rule 2 corresponding to the path 2.

2回目の重複パス検出処理後、管理部20によって管理される条件分岐毎の分岐実行回数は、図15に示すように、{(1、1)、(1、0)、(0、0)}となる。従って、次に検出部26によって生成される優先分岐番号は、(0、1、0)となる。この場合、重複パス検出ルールにはルール1及びルール2が存在するが、生成された優先分岐番号によって表されるパス候補と重複するルールは存在しない。従って、選択部22において図13のパス3が選択され、生成部24においてパス3に対応した重複パス検出ルール:ルール3が生成される。   After the second duplicate path detection process, the branch execution count for each conditional branch managed by the management unit 20 is {(1, 1), (1, 0), (0, 0) as shown in FIG. }. Therefore, the priority branch number generated by the detection unit 26 next is (0, 1, 0). In this case, rule 1 and rule 2 exist in the duplicate path detection rule, but no rule overlaps with the path candidate represented by the generated priority branch number. Therefore, the selection unit 22 selects the path 3 in FIG. 13, and the generation unit 24 generates the duplicate path detection rule: rule 3 corresponding to the path 3.

3回目の重複パス検出処理後、管理部20によって管理される条件分岐毎の分岐実行回数は、図15に示すように、{(2、1)、(1、1)、(1、0)}となる。従って、次に検出部26によって生成される優先分岐番号は、(1、0、1)となる。この場合、重複パス検出ルールにはルール1、ルール2、及びルール3が存在し、生成された優先分岐番号によって表されるパス候補とルール2が一致する。従って、重複パス検出ルールと一致するパス候補に従ったシンボリック実行によるパス抽出処理が省略される。具体的には、選択部22におけるパスの選択処理、及び生成部24における重複パス検出ルールの生成処理が省略される。ただし、生成された優先分岐番号によって表されるパス候補と、重複パス検出ルールとが一致した場合であっても、管理部20は、パス候補の生成に伴って、条件分岐毎の分岐実行回数を更新する。   After the third overlapping path detection process, the branch execution count for each conditional branch managed by the management unit 20 is {(2, 1), (1, 1), (1, 0) as shown in FIG. }. Accordingly, the priority branch number generated next by the detection unit 26 is (1, 0, 1). In this case, rule 1, rule 2, and rule 3 exist in the duplicate path detection rule, and the path candidate represented by the generated priority branch number matches rule 2. Therefore, the path extraction process by symbolic execution according to the path candidate that matches the duplicate path detection rule is omitted. Specifically, the path selection process in the selection unit 22 and the generation process of the duplicate path detection rule in the generation unit 24 are omitted. However, even when the path candidate represented by the generated priority branch number matches the duplicate path detection rule, the management unit 20 performs the number of branch executions for each conditional branch as the path candidate is generated. Update.

4回目の重複パス検出処理後、管理部20によって管理される条件分岐毎の分岐実行回数は、図16に示すように、{(2、2)、(1、1)、(1、0)}となる。従って、次に検出部26によって生成される優先分岐番号は、(0、0、1)となる。この場合、重複パス検出ルールにはルール1、ルール2、及びルール3が存在し、生成された優先分岐番号によって表されるパス候補とルール1が一致する。従って、重複パス検出ルールと一致するパス候補に従ったシンボリック実行によるパス抽出処理が省略される。   After the fourth overlapping path detection process, the branch execution count for each conditional branch managed by the management unit 20 is {(2, 2), (1, 1), (1, 0) as shown in FIG. }. Accordingly, the priority branch number generated next by the detection unit 26 is (0, 0, 1). In this case, rule 1, rule 2, and rule 3 exist in the duplicate path detection rule, and the path candidate represented by the generated priority branch number matches rule 1. Therefore, the path extraction process by symbolic execution according to the path candidate that matches the duplicate path detection rule is omitted.

5回目の重複パス検出処理後、管理部20によって管理される条件分岐毎の分岐実行回数は、図16に示すように、{(3、2)、(2、1)、(1、0)}となる。従って、次に検出部26によって生成される優先分岐番号は、(1、1、1)となる。この場合、重複パス検出ルールにはルール1、ルール2、及びルール3が存在し、生成された優先分岐番号によって表されるパス候補とルール2が一致する。従って、重複パス検出ルールと一致するパス候補に従ったシンボリック実行によるパス抽出処理が省略される。   After the fifth overlapping path detection process, the branch execution count for each conditional branch managed by the management unit 20 is {(3, 2), (2, 1), (1, 0) as shown in FIG. }. Accordingly, the priority branch number generated next by the detection unit 26 is (1, 1, 1). In this case, rule 1, rule 2, and rule 3 exist in the duplicate path detection rule, and the path candidate represented by the generated priority branch number matches rule 2. Therefore, the path extraction process by symbolic execution according to the path candidate that matches the duplicate path detection rule is omitted.

6回目の重複パス検出処理後、管理部20によって管理される条件分岐毎の分岐実行回数は、図16に示すように、{(3、3)、(2、1)、(1、0)}となる。従って、次に検出部26によって生成される優先分岐番号は、(0、1、1)となる。この場合、重複パス検出ルールには、生成された優先分岐番号によって表されるパス候補と重複するルールは存在しない。従って、選択部22において図13のパス7が選択され、生成部24においてパス7に対応した重複パス検出ルール:ルール4が生成される。なお、ルール4は、「優先分岐番号が{(IF文(13行目)=0)∧(IF文(19行目)=1)∧(IF文(25行目)=1)}ならば、パス7と重複する」というルールとなる。   After the sixth overlapping path detection process, the branch execution count for each conditional branch managed by the management unit 20 is {(3, 3), (2, 1), (1, 0) as shown in FIG. }. Therefore, the priority branch number generated by the detection unit 26 next is (0, 1, 1). In this case, the duplicate path detection rule has no rule that overlaps with the path candidate represented by the generated priority branch number. Accordingly, the selection unit 22 selects the path 7 in FIG. 13, and the generation unit 24 generates the duplicate path detection rule: rule 4 corresponding to the path 7. Note that rule 4 indicates that if the priority branch number is {(IF statement (13th line) = 0) ∧ (IF statement (19th row) = 1) ∧ (IF statement (25th row) = 1)}. , Overlaps with path 7 ”.

7回目の重複パス検出処理後、管理部20によって管理される条件分岐毎の分岐実行回数は、図16に示すように、{(4、3)、(2、2)、(1、1)}となる。この場合、被検査プログラム30に含まれる条件分岐毎の分岐実行回数の各々が1以上であることから、パス1、パス2、パス3、及びパス7によって分岐網羅が実現されることになる。従って、検出部26は重複パスの検出処理を終了する。   After the seventh overlapping path detection process, the branch execution count for each conditional branch managed by the management unit 20 is {(4, 3), (2, 2), (1, 1) as shown in FIG. }. In this case, since the number of branch executions for each conditional branch included in the program to be inspected is 1 or more, branch coverage is realized by the path 1, the path 2, the path 3, and the path 7. Therefore, the detection unit 26 ends the duplicate path detection process.

以上に説明したテストケース生成装置10は、例えば、図17に示すコンピュータ40で実現することができる。コンピュータ40は、CPU42、メモリ44、及び不揮発性の記憶部46を含み、これらはバス48を介して互いに接続される。   The test case generation device 10 described above can be realized by, for example, the computer 40 shown in FIG. The computer 40 includes a CPU 42, a memory 44, and a nonvolatile storage unit 46, which are connected to each other via a bus 48.

また、記憶部46はHDD(Hard Disk Drive)又はフラッシュメモリ等によって実現できる。記憶媒体としての記憶部46には、コンピュータ40を被検査プログラム30に対するテストケース生成装置10として機能させるためのテストケース生成プログラム50が記憶されている。CPU42は、テストケース生成プログラム50を記憶部46から読み出してメモリ44に展開し、テストケース生成プログラム50に含まれる各種プロセスを順次実行する。   The storage unit 46 can be realized by an HDD (Hard Disk Drive) or a flash memory. The storage unit 46 as a storage medium stores a test case generation program 50 for causing the computer 40 to function as the test case generation apparatus 10 for the program 30 to be inspected. The CPU 42 reads the test case generation program 50 from the storage unit 46 and expands it in the memory 44, and sequentially executes various processes included in the test case generation program 50.

テストケース生成プログラム50は、シンボリック実行プロセス52、制御プロセス54、管理プロセス56、選択プロセス58、生成プロセス60、検出プロセス62、深さ優先探索プロセス64、入力プロセス66、及び出力プロセス68を含む。   The test case generation program 50 includes a symbolic execution process 52, a control process 54, a management process 56, a selection process 58, a generation process 60, a detection process 62, a depth-first search process 64, an input process 66, and an output process 68.

CPU42は、シンボリック実行プロセス52を実行することで、図7に示すシンボリック実行部14として動作する。また、CPU42は、制御プロセス54を実行することで、図7に示す制御部16として動作する。また、CPU42は、管理プロセス56を実行することで、図7に示す管理部20として動作する。また、CPU42は、選択プロセス58を実行することで、図7に示す選択部22として動作する。また、CPU42は、生成プロセス60を実行することで、図7に示す生成部24として動作する。また、CPU42は、検出プロセス62を実行することで、図7に示す検出部26として動作する。また、CPU42は、深さ優先探索プロセス64を実行することで、図7に示す深さ優先探索部18として動作する。また、CPU42は、入力プロセス66を実行することで、図7に示す入力部12として動作する。また、CPU42は、出力プロセス68を実行することで、図7に示す出力部28として動作する。   The CPU 42 operates as the symbolic execution unit 14 illustrated in FIG. 7 by executing the symbolic execution process 52. Further, the CPU 42 operates as the control unit 16 illustrated in FIG. 7 by executing the control process 54. The CPU 42 operates as the management unit 20 illustrated in FIG. 7 by executing the management process 56. The CPU 42 operates as the selection unit 22 illustrated in FIG. 7 by executing the selection process 58. The CPU 42 operates as the generation unit 24 illustrated in FIG. 7 by executing the generation process 60. Further, the CPU 42 operates as the detection unit 26 illustrated in FIG. 7 by executing the detection process 62. Further, the CPU 42 operates as the depth priority search unit 18 illustrated in FIG. 7 by executing the depth priority search process 64. The CPU 42 operates as the input unit 12 illustrated in FIG. 7 by executing the input process 66. The CPU 42 operates as the output unit 28 illustrated in FIG. 7 by executing the output process 68.

以上により、テストケース生成プログラム50を実行したコンピュータ40が、テストケース生成装置10として動作する。なお、テストケース生成プログラム50は、開示の技術におけるテストケース生成プログラムの一例を示したものである。   As described above, the computer 40 that has executed the test case generation program 50 operates as the test case generation apparatus 10. Note that the test case generation program 50 is an example of a test case generation program in the disclosed technology.

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

次に、本実施の形態に係るテストケース生成装置10の作用を説明する。本実施の形態に係るテストケース生成装置10は、入力部12に被検査プログラム30が入力されると、図18に示すテストケース生成処理を実行する。なお、以下では、入力部12に入力される被検査プログラム30として、図9に示した被検査プログラム30を例に説明するものとする。また、テストケース生成プログラム50を記憶部46から読み出してメモリ44に展開する際、メモリ44の予め定めた領域に記憶される、被検査プログラム30の条件分岐毎の分岐実行回数は、{(0、0)、(0、0)、(0、0)}に初期化される。また、生成部24によって生成される重複パス検出ルールも、何れのルールも含まないように初期化される。   Next, the operation of the test case generation device 10 according to the present embodiment will be described. When the inspected program 30 is input to the input unit 12, the test case generation apparatus 10 according to the present embodiment executes a test case generation process shown in FIG. In the following description, the inspected program 30 shown in FIG. 9 will be described as an example of the inspected program 30 input to the input unit 12. Further, when the test case generation program 50 is read from the storage unit 46 and expanded in the memory 44, the number of branch executions for each conditional branch of the program under test 30 stored in a predetermined area of the memory 44 is {(0 , 0), (0, 0), (0, 0)}. Also, the duplicate path detection rule generated by the generation unit 24 is initialized so as not to include any rule.

ステップS100では、入力部12が、入力部12に入力された被検査プログラム30を取得して、例えばメモリ44に記憶する。更に、入力部12は、被検査プログラム30が入力されたことをシンボリック実行部14に通知する。   In step S <b> 100, the input unit 12 acquires the program to be inspected 30 input to the input unit 12 and stores it in the memory 44, for example. Further, the input unit 12 notifies the symbolic execution unit 14 that the program to be inspected 30 has been input.

ステップS102では、シンボリック実行部14が、被検査プログラム30に対するパス探索の終了条件を満たしたか否かを判定する。   In step S <b> 102, the symbolic execution unit 14 determines whether a path search end condition for the program to be inspected 30 is satisfied.

ここで、パス探索の終了条件とは、以下の3つの条件のうち、何れか1つの条件が成立することを言う。   Here, the path search end condition means that any one of the following three conditions is satisfied.

(終了条件1)既出パスにより分岐網羅が達成されること。
(終了条件2)分岐網羅度が収束回数に亘って変化しないこと。
(終了条件3)パスの探索回数が、パス探索回数に達すること。
(Termination condition 1) The branch coverage is achieved by the existing path.
(Termination condition 2) The branch coverage does not change over the number of times of convergence.
(End condition 3) The number of path searches reaches the number of path searches.

(終了条件1)は、例えば、管理部20によってメモリ44に記憶された、被検査プログラム30に含まれる条件分岐毎の分岐実行回数の各々が1以上となっている場合に、パス探索を終了する条件である。   (End condition 1) is, for example, when the number of branch executions for each conditional branch included in the program under test 30 stored in the memory 44 by the management unit 20 is 1 or more, the path search is ended. It is a condition to do.

(終了条件2)は、例えば、被検査プログラム30に含まれる全ての分岐数に対する実際にパス探索された分岐数の割合が、予め定めた収束回数に亘って連続して変化しない場合に、パス探索を終了する条件である。   The (end condition 2) is, for example, when the ratio of the number of branches actually searched for the number of branches included in the program to be inspected 30 does not continuously change over a predetermined number of convergence times. This is a condition for ending the search.

具体的には、条件分岐毎の分岐実行回数が{(1、1)、(1、0)、(0、0)}であれば、被検査プログラム30に含まれる全ての分岐数は6であり、実際にパス探索された分岐数は3であるので、分岐網羅度は50%となる。この分岐網羅度の状態からパス探索を繰り返しても、収束回数連続して分岐網羅度が50%のまま変化しない場合に、条件が成立したものとして判定される。   Specifically, if the number of branch executions for each conditional branch is {(1, 1), (1, 0), (0, 0)}, the number of all branches included in the program 30 to be inspected is 6. Yes, since the number of branches actually searched for paths is 3, the branch coverage is 50%. Even if the path search is repeated from this state of branch coverage, the condition is determined to be satisfied if the branch coverage remains unchanged at 50% for the number of convergences.

(終了条件3)は、シンボリック実行部14が制御部16へパス探索指示を通知して制御部16にパスの探索を実施させた回数が、予め定めたパス探索回数に達した場合に、パス探索を終了する条件である。   (End condition 3) is that the number of times the symbolic execution unit 14 notifies the control unit 16 of a path search instruction and causes the control unit 16 to search for a path reaches a predetermined number of path searches. This is a condition for ending the search.

なお、収束回数及びパス探索回数は、予め記憶部46に記憶されているものとするが、例えば、入力部12を介して取得し、記憶部46に記憶するようにしてもよい。   The convergence count and path search count are stored in advance in the storage unit 46, but may be acquired via the input unit 12 and stored in the storage unit 46, for example.

シンボリック実行部14によってパス探索の終了条件が成立したと判定された場合には、シンボリック実行を終了してステップS104へ移行する。パス探索の終了条件がまだ成立していないと判定された場合には、シンボリック実行部14が制御部16へパス探索指示を通知し、ステップS106へ移行する。   If the symbolic execution unit 14 determines that the path search termination condition is satisfied, the symbolic execution is terminated and the process proceeds to step S104. If it is determined that the path search termination condition has not yet been established, the symbolic execution unit 14 notifies the control unit 16 of a path search instruction, and the process proceeds to step S106.

ステップS106では、制御部16は、シンボリック実行部14からのパス探索指示によってパス探索を開始する。まず、制御部16は、検出部26へ重複パス検出処理の実行指示を通知し、検出部26に重複パス検出処理を実行させる。   In step S106, the control unit 16 starts a path search in response to a path search instruction from the symbolic execution unit 14. First, the control unit 16 notifies the detection unit 26 of an execution instruction for the duplicate path detection process, and causes the detection unit 26 to execute the duplicate path detection process.

図19は、ステップS106の重複パス検出処理の内容を示したフローチャートである。   FIG. 19 is a flowchart showing the contents of the duplicate path detection process in step S106.

ステップS200で、検出部26は、メモリ44の予め定めた領域に記憶されている、被検査プログラム30の条件分岐毎の分岐実行回数を参照し、パス選択規則に基づいて優先分岐番号を生成する。   In step S200, the detection unit 26 refers to the number of branch executions for each conditional branch of the program under test 30 stored in a predetermined area of the memory 44, and generates a priority branch number based on the path selection rule. .

例えば、テストケース生成装置10が初期状態にある場合、被検査プログラム30の条件分岐毎の分岐実行回数は{(0、0)、(0、0)、(0、0)}であるから、パス選択規則に基づいて生成される優先分岐番号は(0、0、0)となる。   For example, when the test case generation device 10 is in the initial state, the number of branch executions for each conditional branch of the program under test 30 is {(0, 0), (0, 0), (0, 0)}. The priority branch number generated based on the path selection rule is (0, 0, 0).

そして、ステップS202で、検出部26は、ステップS200で生成した優先分岐番号と、後述するステップS124の処理によって生成部24により生成される重複パス検出ルールとを比較する。そして、重複パス検出ルールの中に、ステップS200で生成した優先分岐番号の少なくとも一部と一致するルールが存在する場合、検出部26は、生成した優先分岐番号によって表されるパス候補が既出パスと重複することを、制御部16に通知する。   In step S202, the detection unit 26 compares the priority branch number generated in step S200 with the duplicate path detection rule generated by the generation unit 24 by the process in step S124 described later. If the duplicate path detection rule includes a rule that matches at least a part of the priority branch number generated in step S200, the detection unit 26 determines that the path candidate represented by the generated priority branch number is an existing path. Is notified to the control unit 16.

そして、ステップS108では、制御部16は、検出部26から重複パス検出処理の結果を受け取り、重複パス検出処理の結果に基づいて、今回のパス探索によって抽出される予定のパス候補が、既出パスと重複するか否かを判定する。   In step S108, the control unit 16 receives the result of the duplicate path detection process from the detection unit 26, and based on the result of the duplicate path detection process, the path candidate scheduled to be extracted by the current path search is the existing path. It is determined whether or not.

そして、パス候補が既出パスと重複する場合にはステップS110へ移行し、パス候補が既出パスと重複しない場合にはステップS112へ移行する。   If the path candidate overlaps with the already-exited path, the process proceeds to step S110. If the path candidate does not overlap with the already-existing path, the process proceeds to step S112.

ステップS110では、制御部16が、管理部20へ被検査プログラム30に含まれる条件分岐毎の分岐実行回数の更新を要求する。管理部20は、検出部26で生成されたパス候補に対応した優先分岐番号の値に基づいて、例えばメモリ44の予め定めた領域に記憶された条件分岐毎の分岐実行回数を更新する。そして、ステップS102へ移行して、被検査プログラム30に含まれるパスの探索を繰り返す。   In step S110, the control unit 16 requests the management unit 20 to update the number of branch executions for each conditional branch included in the program to be inspected 30. Based on the value of the priority branch number corresponding to the path candidate generated by the detection unit 26, the management unit 20 updates the number of branch executions for each conditional branch stored in a predetermined area of the memory 44, for example. Then, the process proceeds to step S102 and the search for the path included in the program to be inspected 30 is repeated.

一方、ステップS112では、制御部16が、メモリ44に記憶された被検査プログラム30から命令文を1行読み込む。そして、ステップS114では、制御部16が、ステップS112において読み込んだ命令文と共に、選択部22へ分岐選択処理の実行指示を通知し、選択部22に分岐選択処理を実行させる。   On the other hand, in step S <b> 112, the control unit 16 reads one line of a command sentence from the program to be inspected 30 stored in the memory 44. In step S114, the control unit 16 notifies the selection unit 22 of an execution instruction for the branch selection process together with the instruction sentence read in step S112, and causes the selection unit 22 to execute the branch selection process.

ステップS114では、選択部22は、制御部16から通知された命令文が条件分岐命令であれば、条件分岐命令が分岐可能か否かを判断する。そして、選択部22は条件分岐命令が分岐可能である場合に、既に説明したパス選択規則に従って分岐先を選択する。なお、ステップS114の分岐選択処理の詳細については後ほど説明する。   In step S <b> 114, if the instruction sentence notified from the control unit 16 is a conditional branch instruction, the selection unit 22 determines whether the conditional branch instruction can be branched. Then, when the conditional branch instruction can be branched, the selection unit 22 selects a branch destination according to the already described path selection rule. Details of the branch selection process in step S114 will be described later.

ステップS116では、制御部16が、管理部20へ被検査プログラム30に含まれる条件分岐毎の分岐実行回数の更新を要求する。   In step S <b> 116, the control unit 16 requests the management unit 20 to update the number of branch executions for each conditional branch included in the program to be inspected 30.

図20は、管理部20で実施される、ステップS116における分岐実行回数管理処理の内容を示したフローチャートである。   FIG. 20 is a flowchart showing the contents of the branch execution frequency management process in step S116, which is performed by the management unit 20.

ステップS400では、管理部20は、ステップS112の処理で制御部16が読み込んだ命令文が条件分岐命令か否かを判定し、否定判定の場合には分岐実行回数管理処理を終了する。一方、肯定判定の場合には、ステップS402へ移行する。   In step S400, the management unit 20 determines whether or not the instruction sentence read by the control unit 16 in the process of step S112 is a conditional branch instruction. If the determination is negative, the management unit 20 ends the branch execution number management process. On the other hand, if the determination is affirmative, the process proceeds to step S402.

ステップS402では、管理部20は、ステップS114での分岐選択処理の結果、選択部22が選択した条件分岐命令の分岐先を、メモリ44の予め定めた領域から取得する。条件分岐命令がIF文である場合、選択部22によってメモリ44の予め定めた領域には、例えば‘TRUE’又は‘FALSE’が記憶され、条件分岐命令がEVALUATE文であれば、分岐先番号が記憶されている。この場合、例えば分岐先番号が‘1’の場合には、EVALUATE文の最初のWHEN文が実行されたことを意味し、分岐先番号が‘2’の場合には、EVALUATE文の2番目のWHEN文が実行されたことを意味する。   In step S402, the management unit 20 acquires the branch destination of the conditional branch instruction selected by the selection unit 22 from the predetermined area of the memory 44 as a result of the branch selection process in step S114. If the conditional branch instruction is an IF statement, for example, 'TRUE' or 'FALSE' is stored in a predetermined area of the memory 44 by the selection unit 22, and if the conditional branch instruction is an EVALUATE statement, the branch destination number is It is remembered. In this case, for example, when the branch destination number is “1”, it means that the first WHEN statement of the EVALUATE statement has been executed, and when the branch destination number is “2”, the second of the EVALUATE statement This means that the WHEN statement has been executed.

ステップS404では、管理部20は、ステップS402の処理で取得した条件分岐命令の分岐先に基づいて、対応する条件分岐命令の分岐実行回数を1つ増加して、例えばメモリ44の予め定めた領域に記憶する。   In step S404, the management unit 20 increases the branch execution count of the corresponding conditional branch instruction by one based on the branch destination of the conditional branch instruction acquired in the process of step S402, for example, a predetermined area of the memory 44 To remember.

以上、ステップS400〜ステップS404の処理によって、ステップS116の分岐実行回数管理処理が実行される。   As described above, the branch execution frequency management process in step S116 is executed by the processes in steps S400 to S404.

次に、ステップS118では、制御部16が、ステップS112の処理で読み込んだ命令文が被検査プログラム30の終了を示す命令文、例えば「EXIT PROGRAM」であるか否かを判定する。否定判定の場合には、ステップS120へ移行する。ステップS120では、まだ1つのパスの探索が終了していない状態であるため、制御部16は、次に読み込むべき命令文が格納されているメモリ44上のアドレスを更新する。そして、ステップS112へ移行し、ステップS112〜ステップS120の処理を繰り返すことによって、被検査プログラム30から1つのパスを探索する。   Next, in step S118, the control unit 16 determines whether or not the instruction sentence read in the process of step S112 is an instruction sentence indicating the end of the program 30 to be inspected, for example, “EXIT PROGRAM”. If the determination is negative, the process proceeds to step S120. In step S120, since the search for one path has not been completed yet, the control unit 16 updates the address on the memory 44 in which the command statement to be read next is stored. And it transfers to step S112 and searches one path | pass from the to-be-inspected program 30 by repeating the process of step S112-step S120.

なお、ステップS120では、制御部16が、例えば被検査プログラム30から次に読み込むべき命令文の行番号を順次メモリ44に記憶して、パス探索の終了後に被検査プログラム30の実行経路が特定できるようにしておく。   In step S120, the control unit 16 sequentially stores, for example, the line numbers of the statements to be read next from the inspected program 30 in the memory 44, and can specify the execution path of the inspected program 30 after the path search is completed. Keep it like that.

一方、ステップS118の処理において肯定判定となった場合には、ステップS122へ移行する。なお、ステップS118の処理が肯定判定になるということは、被検査プログラム30から1つのパスが探索されたことを表している。また、ステップS122へ移行する際、制御部16は、探索されたパスに対応する条件分岐毎の分岐実行回数をパス探索回数と関連付けて、メモリ44の予め定めた領域に待避する。   On the other hand, when it becomes affirmation determination in the process of step S118, it transfers to step S122. The fact that the process of step S118 is affirmative means that one path has been searched for from the program to be inspected 30. When the process proceeds to step S122, the control unit 16 associates the number of branch executions for each conditional branch corresponding to the searched path with the number of path searches and saves it in a predetermined area of the memory 44.

ステップS122では、制御部16は、ステップS112〜ステップS120の処理によって新たに探索されたパスを考慮した被検査プログラム30の分岐網羅度(最新分岐網羅度)を算出する。なお、既にステップS102の処理で説明したように、被検査プログラム30の分岐網羅度は、例えばメモリ44に記憶されている条件分岐毎の分岐実行回数を参照することで算出される。   In step S122, the control unit 16 calculates the branch coverage (latest branch coverage) of the program to be inspected 30 in consideration of the path newly searched by the processing in steps S112 to S120. As already described in the process of step S102, the branch coverage of the program under test 30 is calculated by referring to the number of branch executions for each conditional branch stored in the memory 44, for example.

そして、制御部16は、最新分岐網羅度と、例えばメモリ44に記憶されている既出パスによって算出された被検査プログラム30の分岐網羅度(既出パス分岐網羅度)とを比較して、分岐網羅度が向上したか否かを判定する。   Then, the control unit 16 compares the latest branch coverage with the branch coverage (existing path branch coverage) of the inspected program 30 calculated based on the existing path stored in the memory 44, for example, and the branch coverage. Judge whether the degree has improved.

分岐網羅度が向上しない、すなわち最新分岐網羅度が既出パス分岐網羅度と等しい場合には、後述するステップS124及びステップS126の処理を行わずに、ステップS102へ移行し、被検査プログラム30から次のパスを探索する。一方、分岐網羅度が向上した、すなわち最新分岐網羅度が既出パス分岐網羅度よりも大きい場合には、ステップS124へ移行する。   When the branch coverage does not improve, that is, when the latest branch coverage is equal to the existing path branch coverage, the process proceeds to step S102 without performing the processing of step S124 and step S126 described later, and the program to be inspected 30 starts the next. Search for the path. On the other hand, when the branch coverage is improved, that is, when the latest branch coverage is larger than the existing path branch coverage, the process proceeds to step S124.

ステップS124では、制御部16は、生成部24へ重複パス検出ルールの生成指示を通知する。この場合、生成部24は、新たに探索したパスに対応する条件分岐毎の分岐実行回数と、前回探索したパスに対応する分岐条件毎の分岐実行回数と、の差分から、新たに探索したパスに含まれる条件分岐毎の分岐先を特定する。そして、生成部24は、特定した新たに探索したパスに含まれる条件分岐毎の分岐先と、図19のステップS200で検出部26によって生成された優先分岐番号とに基づいて、新たに探索したパスに対応した重複パス検出ルールを生成する。   In step S124, the control unit 16 notifies the generation unit 24 of an instruction for generating a duplicate path detection rule. In this case, the generation unit 24 uses the difference between the branch execution count for each conditional branch corresponding to the newly searched path and the branch execution count for each branch condition corresponding to the previously searched path, to the newly searched path. The branch destination for each conditional branch included in is specified. Then, the generation unit 24 newly searches based on the branch destination for each conditional branch included in the specified newly searched path and the priority branch number generated by the detection unit 26 in step S200 of FIG. A duplicate path detection rule corresponding to the path is generated.

具体的には、図14に示したように、例えば条件分岐毎の優先分岐番号のうち、新たに探索したパスが通過した条件分岐の優先分岐番号を重複パス検出ルールとして、メモリ44の予め定めた領域に記憶する。   Specifically, as shown in FIG. 14, for example, among the priority branch numbers for each conditional branch, the priority branch number of the conditional branch through which the newly searched path has passed is determined in advance in the memory 44 as a duplicate path detection rule. Store in the area.

このようにして生成された重複パス検出ルールは、前述したステップS106の重複パス検出処理で用いられる。   The duplicate path detection rule generated in this way is used in the duplicate path detection process in step S106 described above.

なお、新たに探索したパスの特定方法はこれに限らず、探索したパスが特定できる方法であれば何れの方法を用いてもよい。   The method for specifying a newly searched path is not limited to this, and any method may be used as long as the searched path can be specified.

ステップS126では、シンボリック実行部14は、探索されたパスに基づいてシンボリック実行を行い、探索されたパスが実行可能である場合に、被検査プログラム30から探索されたパスに対応するパス条件を抽出する。そして、シンボリック実行部14は、シンボリック実行によって抽出したパス及び当該パスに対応するパス条件を組み合わせた情報を、テストケースとして生成し、例えばメモリ44の予め定めた領域に記憶する。   In step S126, the symbolic execution unit 14 performs symbolic execution based on the searched path, and extracts a path condition corresponding to the path searched from the program to be inspected 30 when the searched path is executable. To do. Then, the symbolic execution unit 14 generates information combining the path extracted by the symbolic execution and the path condition corresponding to the path as a test case, and stores the information in a predetermined area of the memory 44, for example.

テストケース生成後、ステップS102へ移行して、被検査プログラム30から次のテストケースを生成する処理を繰り返す。   After the test case is generated, the process proceeds to step S102, and the process for generating the next test case from the program to be inspected 30 is repeated.

そして、ステップS102の処理において、シンボリック実行部14によってパス探索の終了条件が成立したと判定された場合、出力部28は、ステップS104の処理において、生成されたテストケースを、例えばメモリ44等にまとめて出力する。   When the symbolic execution unit 14 determines that the path search end condition is satisfied in the process of step S102, the output unit 28 stores the generated test case in the process of step S104, for example, in the memory 44 or the like. Output all at once.

なお、テストケースの出力先はメモリ44に限定されず、例えば、コンピュータ40と有線回線又は無線回線で接続された図示しない端末装置や、USB(Universal Serial Bus)メモリ等の可搬型記憶装置等であってもよい。   Note that the output destination of the test case is not limited to the memory 44, and may be, for example, a terminal device (not shown) connected to the computer 40 via a wired line or a wireless line, or a portable storage device such as a USB (Universal Serial Bus) memory. There may be.

このように、本実施の形態に係るテストケース生成装置10は、新たなパスが探索されたとしても分岐網羅度が向上しなければ、新たなパスに対応した優先分岐番号が重複パス検出ルールとして使用されることがない上、シンボリック実行が行われることもない。   As described above, the test case generation apparatus 10 according to the present embodiment, even if a new path is searched, if the branch coverage is not improved, the priority branch number corresponding to the new path is set as the duplicate path detection rule. It is not used and no symbolic execution is performed.

従って、探索された全てのパスに対応した優先分岐番号から重複パス検出ルールを生成し、シンボリック実行を行う場合と比較して、分岐網羅度の向上につながらない無駄なテストケースを予め排除することができる。また、分岐網羅度の向上につながらない無駄なテストケースを予め排除することから、テストケースの生成に要する時間を短縮することができる。   Therefore, a redundant path detection rule is generated from the priority branch numbers corresponding to all the searched paths, and unnecessary test cases that do not lead to improvement of branch coverage can be eliminated in advance compared to the case where symbolic execution is performed. it can. In addition, since unnecessary test cases that do not lead to an improvement in branch coverage are eliminated in advance, the time required for generating test cases can be shortened.

次に、ステップS114における分岐選択処理の内容について説明する。   Next, the contents of the branch selection process in step S114 will be described.

図21は、選択部22で実施される、ステップS114における分岐選択処理の内容を示したフローチャートである。   FIG. 21 is a flowchart showing the contents of the branch selection process in step S114, which is performed by the selection unit 22.

ステップS300では、選択部22は、図18のステップS112の処理で制御部16が読み込んだ命令文が条件分岐命令か否かを判定し、否定判定の場合には分岐選択処理を終了する。一方、肯定判定の場合には、ステップS302へ移行する。   In step S300, the selection unit 22 determines whether or not the instruction sentence read by the control unit 16 in the process of step S112 in FIG. 18 is a conditional branch instruction. If the determination is negative, the branch selection process ends. On the other hand, if the determination is affirmative, the process proceeds to step S302.

ステップS302では、選択部22は、読み込まれた条件分岐命令から分岐条件を取得し、例えばメモリ44の予め定めた領域に記憶する。なお、ステップS302の処理によって、探索中のパスに含まれる条件分岐命令の分岐条件が、順にメモリ44の予め定めた領域に記憶される。   In step S <b> 302, the selection unit 22 acquires a branch condition from the read conditional branch instruction, and stores it in a predetermined area of the memory 44, for example. Note that the branch condition of the conditional branch instruction included in the path being searched is sequentially stored in a predetermined area of the memory 44 by the process of step S302.

ステップS304では、選択部22は、被検査プログラム30を参照して、ステップS302の処理で取得した分岐条件の真偽値を確定することができるか否かを評価する。例えば、分岐条件が(項目1=1)である場合、被検査プログラム30において項目1の値が具体的な数値として確定しているならば、分岐条件の真偽値を確定することができる。   In step S304, the selection unit 22 refers to the program to be inspected 30 and evaluates whether or not the true / false value of the branch condition acquired in the process of step S302 can be determined. For example, if the branch condition is (item 1 = 1), the true / false value of the branch condition can be determined if the value of item 1 is determined as a specific numerical value in the program under test 30.

ステップS306では、選択部22は、ステップS304の処理によって評価された分岐条件の真偽値が確定するか否かを判定する。そして、肯定判定の場合にはステップS308へ移行する。   In step S306, the selection unit 22 determines whether or not the true / false value of the branch condition evaluated by the process of step S304 is confirmed. If the determination is affirmative, the process proceeds to step S308.

ステップS308では、ステップS302で取得した分岐条件の真偽値を確定し、選択部22は、ステップS302の処理で取得した分岐条件と、当該分岐条件での確定した真偽値とを関連付けて、例えばメモリ44の予め定めた領域に記憶する。そして、図21に示した分岐選択処理を終了する。   In step S308, the truth value of the branch condition acquired in step S302 is confirmed, and the selection unit 22 associates the branch condition acquired in the process of step S302 with the true / false value determined in the branch condition. For example, it is stored in a predetermined area of the memory 44. Then, the branch selection process shown in FIG.

一方、ステップS306の処理において、ステップS304の処理によって評価された分岐条件の真偽値を確定できないと判定された場合には、ステップS310へ移行する。   On the other hand, in the process of step S306, when it is determined that the true / false value of the branch condition evaluated by the process of step S304 cannot be determined, the process proceeds to step S310.

ステップS310では、選択部22は、ステップS302の処理でメモリ44に記憶した、現在探索中のパスに含まれる全ての分岐条件の充足可能性を評価する。   In step S310, the selection unit 22 evaluates the satisfiability of all branch conditions included in the currently searched path stored in the memory 44 in the process of step S302.

例えば、現在探索中のパスに含まれる過去の分岐条件の中に、(性別=‘男性’)という分岐条件が存在して、当該分岐条件に対応する真偽値が‘TRUE’であったとする。この場合、単独の分岐条件では真偽値を確定させることができない(性別=‘女性’)という分岐条件がステップS302の処理で取得されたとしても、過去の分岐条件の真偽値から、真偽値を‘FALSE’に確定させることができる。   For example, it is assumed that a branch condition (gender = 'male') exists in the past branch condition included in the currently searched path, and the truth value corresponding to the branch condition is 'TRUE'. . In this case, even if the branch condition that the true / false value cannot be determined (gender = 'female') by the single branch condition is acquired in the process of step S302, the true / false value of the past branch condition is calculated. The false value can be fixed to 'FALSE'.

このようにして、ステップS312では、選択部22は、ステップS302の処理で取得した分岐条件の分岐先が確定可能か否かを判定する。そして、肯定判定の場合にはステップS314へ移行する。   In this way, in step S312, the selection unit 22 determines whether or not the branch destination of the branch condition acquired in the process of step S302 can be determined. If the determination is affirmative, the process proceeds to step S314.

ステップS314では、ステップS302で取得した分岐条件の真偽値を確定し、選択部22は、ステップS302の処理で取得した分岐条件と、当該分岐条件の真偽値とを関連付けて、例えばメモリ44の予め定めた領域に記憶する。そして、図21に示した分岐選択処理を終了する。   In step S314, the truth value of the branch condition acquired in step S302 is confirmed, and the selection unit 22 associates the branch condition acquired in step S302 with the truth value of the branch condition, for example, the memory 44. Is stored in a predetermined area. Then, the branch selection process shown in FIG.

一方、ステップS312の処理において否定判定となった場合には、ステップS316へ移行し、選択部22は、既に説明したパス選択規則に従って、ステップS302の処理で取得した分岐条件の分岐先を選択する。そして、選択部22は、ステップS302の処理で取得した分岐条件と、選択した真偽値とを関連付けて、例えばメモリ44の予め定めた領域に記憶する。そして、図21に示した分岐選択処理を終了する。   On the other hand, if a negative determination is made in the process of step S312, the process proceeds to step S316, and the selection unit 22 selects the branch destination of the branch condition acquired in the process of step S302 according to the path selection rule already described. . Then, the selection unit 22 associates the branch condition acquired in the process of step S302 with the selected true / false value and stores it in a predetermined area of the memory 44, for example. Then, the branch selection process shown in FIG.

以上のようにして、コンピュータ40上で図18に示すテストケース生成処理が実行される。   As described above, the test case generation process shown in FIG. 18 is executed on the computer 40.

この様に、本実施の形態に係るテストケース生成装置10は、検出部26によりパス探索前に既出パスと重複するパス候補を検出し、重複するパス候補をパス探索前に予め排除する。従って、本実施の形態に係るテストケース生成装置10は、検出部26を含まない場合と比較して、テストケース生成時間を短縮することができる。また、検出部26は重複するパス候補を予め排除するため、本実施の形態に係るテストケース生成装置10は、DART等の従来のパス抽出法と比較して、より少ないパス数で分岐網羅を実現するパスを抽出することができる。   As described above, in the test case generation apparatus 10 according to the present embodiment, the detection unit 26 detects a path candidate that overlaps with an existing path before the path search, and eliminates the overlapping path candidate in advance before the path search. Therefore, the test case generation device 10 according to the present embodiment can shorten the test case generation time compared to the case where the detection unit 26 is not included. In addition, since the detection unit 26 eliminates redundant path candidates in advance, the test case generation apparatus 10 according to the present embodiment performs branch coverage with a smaller number of paths compared to a conventional path extraction method such as DART. The path to be realized can be extracted.

(第2実施形態)   (Second Embodiment)

次に、開示の技術の第2実施形態について説明する。なお、第1実施形態と同一の部分には同一の符号を付して説明を省略し、第1実施形態と異なる部分を中心に説明する。   Next, a second embodiment of the disclosed technique will be described. In addition, the same code | symbol is attached | subjected to the part same as 1st Embodiment, description is abbreviate | omitted, and it demonstrates centering on a different part from 1st Embodiment.

図22に、本実施の形態に係るテストケース生成装置10Aを示す。   FIG. 22 shows a test case generation device 10A according to the present embodiment.

本実施の形態に係るテストケース生成装置10Aが、図7に示した第1実施形態におけるテストケース生成装置10と異なる点は、管理部20が管理部20Aになった点であり、その他は同一であるので説明は省略する。   The test case generation device 10A according to the present embodiment is different from the test case generation device 10 in the first embodiment shown in FIG. 7 in that the management unit 20 is changed to the management unit 20A, and the others are the same. Therefore, explanation is omitted.

図23は、外部処理に条件分岐命令が含まれた被検査プログラム30の一例を示した図である。   FIG. 23 is a diagram showing an example of a program under test 30 in which a conditional branch instruction is included in external processing.

図23に示した被検査プログラム30は、19行目から26行目までが外部処理であり、20行目にIF文が含まれている。そして、外部処理は、12行目、14行目、及び16行目の3個のPERFORM文から呼び出される。   In the inspected program 30 shown in FIG. 23, the 19th to 26th lines are external processes, and the 20th line includes an IF statement. The external process is called from three PERFORM statements on the 12th, 14th and 16th lines.

この場合、管理部20Aは、初期状態において被検査プログラム30を解析し、20行目にIF文を検出した場合、第1実施形態における管理部20と同様に、IF文の分岐実行回数を、例えば「直接=(0、0)」のように初期化する。   In this case, when the management unit 20A analyzes the program to be inspected 30 in the initial state and detects an IF statement on the 20th line, the number of branch executions of the IF statement is determined as in the management unit 20 in the first embodiment. For example, initialization is performed as “direct = (0, 0)”.

そして、制御部16によって被検査プログラム30のパスが探索されると、まず、12行目のPERFORM文から外部処理が呼び出される。そして、パス選択規則に従って、20行目のIF文のTHEN分岐が実行され、外部処理の呼出元に実行先が復帰する。   When the control unit 16 searches for the path of the program 30 to be inspected, first, external processing is called from the PERFORM statement on the 12th line. Then, according to the path selection rule, the THEN branch of the IF statement on the 20th line is executed, and the execution destination returns to the caller of the external process.

この際、管理部20Aは、外部処理の呼出元毎にIF文の分岐実行回数を管理する。具体的には、初めての呼出元から外部処理呼び出しによってIF文を実行した場合に、例えば「Perform#12=(1、0)」といった分岐実行回数を記録する。ここで、‘#’の前の‘Perform’は外部処理を呼び出した命令文を表し、‘#’の後ろに続く‘12’の数値は、外部処理の呼出元行番号を示す。   At this time, the management unit 20A manages the number of times of IF statement branch execution for each caller of the external process. Specifically, when an IF statement is executed by an external process call from the first caller, the number of branch executions such as “Perform # 12 = (1, 0)” is recorded. Here, 'Perform' before '#' represents a command statement that called the external process, and the numerical value of '12' following '#' represents the call source line number of the external process.

引き続き、14行目のPERFORM文から外部処理が呼び出されると、パス選択規則に従って、20行目のIF文のTHEN分岐が実行され、外部処理の呼出元に処理が復帰する。この際、管理部20Aは、外部処理がこれまでとは異なる呼出元から呼び出されたことから、例えば「Perform#14=(1、0)」といった分岐実行回数を記録する。   Subsequently, when the external process is called from the PERFORM statement on the 14th line, the THEN branch of the IF statement on the 20th line is executed according to the path selection rule, and the process returns to the caller of the external process. At this time, the management unit 20A records the number of branch executions such as “Perform # 14 = (1, 0)” because the external process is called from a different call source.

更に、16行目のPERFORM文から外部処理が呼び出されると、パス選択規則に従って、20行目のIF文のTHEN分岐が実行され、外部処理の呼出元に処理が復帰する。この際、管理部20Aは、外部処理がこれまでとは異なる呼出元から呼び出されたことから、例えば「Perform#16=(1、0)」といった分岐実行回数を記録する。   Furthermore, when an external process is called from the PERFORM statement on the 16th line, the THEN branch of the IF statement on the 20th line is executed according to the path selection rule, and the process returns to the caller of the external process. At this time, the management unit 20A records the number of branch executions such as “Perform # 16 = (1, 0)” because the external process is called from a different call source.

すなわち、図23に示した被検査プログラム30の20行目のIF文に対して、直接=(0、0)、Perform#12=(1、0)、Perform#14=(1、0)、及びPerform#16=(1、0)の4つの分岐実行回数が管理される。   That is, direct = (0, 0), Perform # 12 = (1, 0), Perform # 14 = (1, 0), with respect to the IF statement on the 20th line of the inspected program 30 shown in FIG. And the number of branch executions of Perform # 16 = (1, 0) is managed.

次に、本実施の形態に係るテストケース生成装置10Aの作用を説明する。テストケース生成装置10Aのテストケース生成処理は、図18に示す第1実施形態におけるテストケース生成装置10のテストケース生成処理と同一である。ただし、ステップS116の分岐実行回数管理処理の内容が異なるため、以下に、本実施の形態に係る分岐実行回数管理処理について説明する。   Next, the operation of the test case generation device 10A according to the present embodiment will be described. The test case generation process of the test case generation apparatus 10A is the same as the test case generation process of the test case generation apparatus 10 in the first embodiment shown in FIG. However, since the contents of the branch execution number management process in step S116 are different, the branch execution number management process according to the present embodiment will be described below.

図24は、管理部20Aで実施される、分岐実行回数管理処理の内容を示したフローチャートである。図24に示す分岐実行回数管理処理が図20に示す分岐実行回数管理処理と異なるのは、ステップS403、ステップS406、及びステップS408の処理が追加された点である。その他の処理は図20に示す分岐実行回数管理処理と同一であるため、説明を省略する。   FIG. 24 is a flowchart showing the contents of the branch execution count management process performed by the management unit 20A. The branch execution number management process shown in FIG. 24 is different from the branch execution number management process shown in FIG. 20 in that the processes of step S403, step S406, and step S408 are added. Since the other processes are the same as the branch execution frequency management process shown in FIG.

ステップS403では、管理部20Aは、制御部16が図18に示すステップS112の処理で読み込んだ条件分岐命令が、外部処理呼び出しによって読み込まれた条件分岐命令か否かを判定する。具体的には、ステップS120の処理でメモリ44に記録された被検査プログラム30の実行経路を参照して判定すればよい。   In step S403, the management unit 20A determines whether or not the conditional branch instruction read by the control unit 16 in the process of step S112 shown in FIG. 18 is a conditional branch instruction read by an external process call. Specifically, the determination may be made with reference to the execution path of the program to be inspected 30 recorded in the memory 44 in the process of step S120.

そして、ステップS403の処理による判定が否定判定の場合には、既に説明したステップS404へ移行する。一方、肯定判定の場合には、ステップS406へ移行する。   If the determination in step S403 is negative, the process proceeds to step S404 already described. On the other hand, if the determination is affirmative, the process proceeds to step S406.

ステップS406では、管理部20Aは、ステップS120の処理でメモリ44に記録された被検査プログラム30の実行経路を参照して、図18に示すステップS112の処理で読み込んだ条件分岐命令のサブルーチン階層を取得する。   In step S406, the management unit 20A refers to the execution path of the program to be inspected 30 recorded in the memory 44 in the process of step S120, and sets the subroutine hierarchy of the conditional branch instruction read in the process of step S112 shown in FIG. get.

ここで、条件分岐命令のサブルーチン階層とは、条件分岐命令に至るまでの外部処理の呼出過程を示すものである。   Here, the subroutine hierarchy of the conditional branch instruction indicates a calling process of external processing up to the conditional branch instruction.

例えば、N1行目のPERFORM文から外部処理Aが呼び出され、外部処理Aに含まれるN2行目のPERFORM文から外部処理Bが更に呼び出され、外部処理Bに条件分岐命令が含まれる場合のサブルーチン階層について説明する。   For example, a subroutine when the external process A is called from the PERFORM statement on the N1 line, the external process B is further called from the PERFORM statement on the N2 line included in the external process A, and the external process B includes a conditional branch instruction The hierarchy will be described.

この場合、条件分岐命令は、外部処理A、外部処理Bの順に呼び出されるため、条件分岐命令のサブルーチン階層は、例えば外部処理の呼出元の行番号を用いて、「Perform#(N1、N2)」と取得される。   In this case, since the conditional branch instruction is called in the order of the external process A and the external process B, the subroutine hierarchy of the conditional branch instruction uses, for example, the line number of the caller of the external process, “Perform # (N1, N2) Is acquired.

なお、N1行目にあるPERFORM文から呼び出された外部処理Aの中に条件分岐命令が含まれる場合には、図23で既に説明したように、条件分岐命令のサブルーチン階層は、「Perform#N1」と取得される。   If the conditional branch instruction is included in the external process A called from the PERFORM statement on the N1th line, the subroutine hierarchy of the conditional branch instruction is “Perform # N1” as already described in FIG. Is acquired.

そして、ステップS408では、管理部20Aは、ステップS402の処理で取得した条件分岐命令の分岐先に基づいて、サブルーチン階層に対応する条件分岐命令の分岐実行回数を1つ増加して、例えばメモリ44の予め定めた領域に記憶する。   In step S408, the management unit 20A increases the branch execution count of the conditional branch instruction corresponding to the subroutine hierarchy by one based on the branch destination of the conditional branch instruction acquired in step S402, for example, the memory 44 Is stored in a predetermined area.

以上、ステップS400〜ステップS408の処理によって、図18に示すステップS116の分岐実行回数管理処理が実行される。   As described above, the branch execution frequency management process of step S116 shown in FIG. 18 is executed by the processes of steps S400 to S408.

このように、本実施の形態に係る管理部20Aは、条件分岐毎に分岐実行回数を管理するのに加え、更に、条件分岐命令が外部処理に含まれる場合、条件分岐命令に到達するまでに経由した外部処理の呼出元毎に条件分岐の分岐実行回数を管理する。   As described above, in addition to managing the number of branch executions for each conditional branch, the management unit 20A according to the present embodiment further includes a conditional branch instruction that is included in the external processing until the conditional branch instruction is reached. Manages the number of branch executions for conditional branches for each caller of the external process that has passed through.

従って、被検査プログラム30が外部処理の中に条件分岐を含む場合、単に条件分岐毎に分岐実行回数を管理する場合と比較して、効率よく分岐網羅を実現するテストケースを生成することができる。   Therefore, when the program to be inspected 30 includes a conditional branch in the external process, it is possible to generate a test case that realizes branch coverage more efficiently than when the number of branch executions is simply managed for each conditional branch. .

以上、開示の技術を実施の形態を用いて説明したが、開示の技術は上記実施の形態に記載の範囲には限定されない。開示の技術の要旨を逸脱しない範囲で上記実施の形態に多様な変更または改良を加えることができ、当該変更または改良を加えた形態も開示の技術の技術的範囲に含まれる。例えば、開示の技術の要旨を逸脱しない範囲で、図18〜図21、及び図24に示した処理の順序を変更してもよい。   Although the disclosed technique has been described using the embodiment, the disclosed technique is not limited to the scope described in the embodiment. Various changes or improvements can be added to the above-described embodiment without departing from the gist of the disclosed technology, and forms to which the changes or improvements are added are also included in the technical scope of the disclosed technology. For example, the order of the processes shown in FIGS. 18 to 21 and FIG. 24 may be changed without departing from the gist of the disclosed technology.

また、上記では開示の技術に係るテストケース生成プログラムの一例であるテストケース生成プログラム50が記憶部46に予め記憶(インストール)されている態様を説明したが、これに限定されるものではない。開示の技術に係るテストケース生成プログラムは、コンピュータ読取可能な記録媒体に記録されている形態で提供することも可能である。例えば、開示の技術に係るテストケース生成プログラムは、CD−ROM、DVD−ROM、及びUSBメモリ等の可搬型記録媒体、並びに、フラッシュメモリ等の半導体メモリ等に記録されている形態で提供することも可能である。   In the above description, the test case generation program 50, which is an example of the test case generation program according to the disclosed technology, is stored (installed) in the storage unit 46 in advance. However, the present invention is not limited to this. The test case generation program according to the disclosed technology can also be provided in a form recorded on a computer-readable recording medium. For example, the test case generation program according to the disclosed technology is provided in a form recorded in a portable recording medium such as a CD-ROM, a DVD-ROM, and a USB memory, and a semiconductor memory such as a flash memory. Is also possible.

また、実施形態に開示したテストケース生成装置10、10Aは、単一のコンピュータ40上で実現されるものとして説明した。しかし、プロセスを異なるコンピュータの記憶部46に記憶させ、各々のコンピュータを有線又は無線の通信回線で接続した分散処理の形態で、テストケース生成装置10、10Aを実現するようにしてもよい。   Further, the test case generation devices 10 and 10A disclosed in the embodiment have been described as being realized on the single computer 40. However, the process may be stored in the storage unit 46 of a different computer, and the test case generation apparatuses 10 and 10A may be realized in the form of distributed processing in which each computer is connected by a wired or wireless communication line.

また、実施形態に開示したテストケース生成装置10、10Aは、ネットワークを経由して被検査プログラム30を受け付け、生成したテストケースをネットワークを経由して出力する、所謂ネットサービスの態様をとるようにしてもよい。   Further, the test case generation apparatuses 10 and 10A disclosed in the embodiment take a so-called network service mode in which the inspected program 30 is received via the network and the generated test case is output via the network. May be.

以上の第1実施形態及び第2実施形態を含む実施形態に関し、更に以下の付記を開示する。   The following additional notes are further disclosed regarding the embodiment including the first embodiment and the second embodiment.

(付記1)
被検査プログラムに含まれる条件分岐の分岐先への分岐実行回数を管理する管理部と、
前記管理部により管理された前記分岐実行回数から得られる経路候補に対応した分岐情報と、既に抽出された前記被検査プログラムの既出経路に対応した分岐情報と、を比較して、前記経路候補が前記既出経路に含まれる重複経路か否かを検出する検出部と、
前記条件分岐の前記分岐実行回数に応じた予め定めた規則に基づいて分岐先を決定して、前記被検査プログラムの開始から終了までの経路を選択する選択部と、
前記選択部により選択された前記経路に対応した分岐情報を、前記既出経路に対応した分岐情報として生成する生成部と、
前記検出部により前記経路候補が前記重複経路ではないと検出された場合、前記選択部及び前記生成部の各々による処理が実行され、前記検出部により前記経路候補が前記重複経路であると検出された場合、前記選択部及び前記生成部の各々による処理が実行されないように、前記選択部及び前記生成部を制御する制御部と、
を有するテストケース生成装置。
(Appendix 1)
A management unit for managing the number of branch executions to the branch destination of the conditional branch included in the program to be inspected;
Comparing the branch information corresponding to the route candidate obtained from the number of branch executions managed by the management unit with the branch information corresponding to the already extracted route of the program to be inspected, the route candidate is A detection unit for detecting whether the route is an overlapping route included in the already-existing route;
A selection unit that determines a branch destination based on a predetermined rule corresponding to the number of branch executions of the conditional branch, and selects a path from the start to the end of the program to be inspected;
A generation unit that generates branch information corresponding to the route selected by the selection unit as branch information corresponding to the already-explained route;
When the detection unit detects that the route candidate is not the overlapping route, processing by each of the selection unit and the generation unit is executed, and the detection unit detects that the route candidate is the overlapping route. A control unit that controls the selection unit and the generation unit so that processing by each of the selection unit and the generation unit is not executed,
A test case generation device having:

(付記2)
前記管理部は、前記条件分岐が、前記被検査プログラムの呼出元から呼び出されるサブルーチンに含まれる条件分岐である場合には、前記条件分岐の各々について、前記条件分岐に対応した前記分岐実行回数を管理すると共に、前記サブルーチンの呼出元毎に前記条件分岐に対応した前記分岐実行回数を管理する
付記1記載のテストケース生成装置。
(Appendix 2)
When the conditional branch is a conditional branch included in a subroutine called from the call source of the program to be inspected, the management unit sets the number of branch executions corresponding to the conditional branch for each of the conditional branches. The test case generation device according to claim 1, wherein the test case generation device manages the branch execution count corresponding to the conditional branch for each caller of the subroutine.

(付記3)
前記制御部は、前記管理部で管理される前記分岐実行回数に基づいて算出される、前記選択部による新たな前記経路の選択前の分岐網羅度と、前記管理部で管理される前記分岐実行回数に基づいて算出される、前記選択部による新たな前記経路の選択後の分岐網羅度と、を比較し、新たな前記経路の選択後の分岐網羅度が新たな前記経路の選択前の分岐網羅度と同じ場合には、前記選択部により選択された新たな前記経路に対応した分岐情報を、前記既出経路に対応した分岐情報として生成しないように前記生成部を制御する
付記1又は付記2記載のテストケース生成装置。
(Appendix 3)
The control unit is calculated based on the number of branch executions managed by the management unit, the branch coverage before the selection of a new path by the selection unit, and the branch execution managed by the management unit The branch coverage after the selection of the new route by the selection unit calculated based on the number of times is compared, and the branch coverage after the selection of the new route is a branch before the selection of the new route If the coverage is the same, the generation unit is controlled not to generate branch information corresponding to the new route selected by the selection unit as branch information corresponding to the already-existing route. The test case generator described.

(付記4)
被検査プログラムに含まれる条件分岐の分岐先への分岐実行回数を管理し、
前記分岐実行回数から得られる経路候補に対応した分岐情報と、既に抽出された前記被検査プログラムの既出経路に対応した分岐情報と、を比較して、前記経路候補が前記既出経路に含まれる重複経路か否かを検出し、
前記経路候補が前記重複経路ではないと検出された場合、前記条件分岐の前記分岐実行回数に応じた予め定めた規則に基づいて分岐先を決定して、前記被検査プログラムの開始から終了までの経路を選択し、前記経路に対応した分岐情報を、前記既出経路に対応した分岐情報として生成し、前記経路候補が前記重複経路であると検出された場合、前記経路候補に対応した前記経路を選択せずに、且つ、前記経路に対応した分岐情報を、前記既出経路に対応した分岐情報として生成しないように制御する
ことを含むテストケース生成方法。
(Appendix 4)
Manage the number of branch executions to the branch destination of the conditional branch included in the program to be inspected.
The branch information corresponding to the route candidate obtained from the number of branch executions is compared with the branch information corresponding to the already-extracted route of the program to be inspected, and the route candidate is included in the already-existing route. Detect if it ’s a route,
When it is detected that the route candidate is not the overlapping route, a branch destination is determined based on a predetermined rule corresponding to the number of branch executions of the conditional branch, and from the start to the end of the inspected program When a route is selected, branch information corresponding to the route is generated as branch information corresponding to the already-existing route, and when the route candidate is detected as the duplicate route, the route corresponding to the route candidate is selected. A test case generation method including controlling to not generate branch information corresponding to the route without selecting as branch information corresponding to the already-existing route.

(付記5)
前記条件分岐が、前記被検査プログラムの呼出元から呼び出されるサブルーチンに含まれる条件分岐である場合には、前記条件分岐の各々について、前記条件分岐に対応した前記分岐実行回数を管理すると共に、前記サブルーチンの呼出元毎に前記条件分岐に対応した前記分岐実行回数を管理する
付記4記載のテストケース生成方法。
(Appendix 5)
When the conditional branch is a conditional branch included in a subroutine called from the calling source of the program to be inspected, for each conditional branch, the branch execution count corresponding to the conditional branch is managed, and The test case generation method according to appendix 4, wherein the number of branch executions corresponding to the conditional branch is managed for each caller of the subroutine.

(付記6)
前記分岐実行回数に基づいて算出される、新たな前記経路の選択前の分岐網羅度と、前記分岐実行回数に基づいて算出される、新たな前記経路の選択後の分岐網羅度と、を比較し、新たな前記経路の選択後の分岐網羅度が新たな前記経路の選択前の分岐網羅度と同じ場合には、新たな前記経路に対応した分岐情報を、前記既出経路に対応した分岐情報として生成しないように制御する
付記4又は付記5記載のテストケース生成方法。
(Appendix 6)
Comparing the branch coverage before selecting a new route calculated based on the number of branch executions with the branch coverage after selecting a new route calculated based on the number of branch executions If the branch coverage after selecting the new route is the same as the branch coverage before selecting the new route, the branch information corresponding to the new route is changed to the branch information corresponding to the existing route. The test case generating method according to appendix 4 or appendix 5, wherein the test case is controlled so as not to be generated.

(付記7)
コンピュータに、
被検査プログラムに含まれる条件分岐の分岐先への分岐実行回数を管理し、
前記分岐実行回数から得られる経路候補に対応した分岐情報と、既に抽出された前記被検査プログラムの既出経路に対応した分岐情報と、を比較して、前記経路候補が前記既出経路に含まれる重複経路か否かを検出し、
前記経路候補が前記重複経路ではないと検出された場合、前記条件分岐の前記分岐実行回数に応じた予め定めた規則に基づいて分岐先を決定して、前記被検査プログラムの開始から終了までの経路を選択し、前記経路に対応した分岐情報を、前記既出経路に対応した分岐情報として生成し、前記経路候補が前記重複経路であると検出された場合、前記経路候補に対応した前記経路を選択せずに、且つ、前記経路に対応した分岐情報を、前記既出経路に対応した分岐情報として生成しないように制御する
ことを含む処理を実行させるためのテストケース生成プログラム。
(Appendix 7)
On the computer,
Manage the number of branch executions to the branch destination of the conditional branch included in the program to be inspected.
The branch information corresponding to the route candidate obtained from the number of branch executions is compared with the branch information corresponding to the already-extracted route of the program to be inspected, and the route candidate is included in the already-existing route. Detect if it ’s a route,
When it is detected that the route candidate is not the overlapping route, a branch destination is determined based on a predetermined rule corresponding to the number of branch executions of the conditional branch, and from the start to the end of the inspected program When a route is selected, branch information corresponding to the route is generated as branch information corresponding to the already-existing route, and when the route candidate is detected as the duplicate route, the route corresponding to the route candidate is selected. A test case generation program for executing processing including controlling to not generate branch information corresponding to the route as branch information corresponding to the already-existing route without selecting.

(付記8)
コンピュータに、
被検査プログラムに含まれる条件分岐の分岐先への分岐実行回数を管理し、
前記分岐実行回数から得られる経路候補に対応した分岐情報と、既に抽出された前記被検査プログラムの既出経路に対応した分岐情報と、を比較して、前記経路候補が前記既出経路に含まれる重複経路か否かを検出し、
前記経路候補が前記重複経路ではないと検出された場合、前記条件分岐の前記分岐実行回数に応じた予め定めた規則に基づいて分岐先を決定して、前記被検査プログラムの開始から終了までの経路を選択し、前記経路に対応した分岐情報を、前記既出経路に対応した分岐情報として生成し、前記経路候補が前記重複経路であると検出された場合、前記経路候補に対応した前記経路を選択せずに、且つ、前記経路に対応した分岐情報を、前記既出経路に対応した分岐情報として生成しないように制御する
ことを含む処理を実行させるためのプログラムを記録したコンピュータ読み取り可能な記録媒体。
(Appendix 8)
On the computer,
Manage the number of branch executions to the branch destination of the conditional branch included in the program to be inspected.
The branch information corresponding to the route candidate obtained from the number of branch executions is compared with the branch information corresponding to the already-extracted route of the program to be inspected, and the route candidate is included in the already-existing route. Detect if it ’s a route,
When it is detected that the route candidate is not the overlapping route, a branch destination is determined based on a predetermined rule corresponding to the number of branch executions of the conditional branch, and from the start to the end of the inspected program When a route is selected, branch information corresponding to the route is generated as branch information corresponding to the already-existing route, and when the route candidate is detected as the duplicate route, the route corresponding to the route candidate is selected. A computer-readable recording medium on which a program for executing a process including controlling to not generate branch information corresponding to the route as branch information corresponding to the already-existing route without selection is recorded .

10、10A テストケース生成装置
12 入力部
14 シンボリック実行部
16 制御部
18 深さ優先探索部
20、20A 管理部
22 選択部
24 生成部
26 検出部
28 出力部
30 被検査プログラム
32 テストケース
40 コンピュータ
44 メモリ
46 記憶部
48 バス
10, 10A Test case generation device 12 Input unit 14 Symbolic execution unit 16 Control unit 18 Depth priority search unit 20, 20A Management unit 22 Selection unit 24 Generation unit 26 Detection unit 28 Output unit 30 Program to be tested 32 Test case 40 Computer 44 Memory 46 Storage unit 48 Bus

Claims (5)

被検査プログラムに含まれる条件分岐の分岐先への分岐実行回数を管理する管理部と、
前記管理部により管理された前記分岐実行回数から得られる経路候補に対応した分岐情報と、既に抽出された前記被検査プログラムの既出経路に対応した分岐情報と、を比較して、前記経路候補が前記既出経路に含まれる重複経路か否かを検出する検出部と、
前記条件分岐の前記分岐実行回数に応じた予め定めた規則に基づいて分岐先を決定して、前記被検査プログラムの開始から終了までの経路を選択する選択部と、
前記選択部により選択された前記経路に対応した分岐情報を、前記既出経路に対応した分岐情報として生成する生成部と、
前記検出部により前記経路候補が前記重複経路ではないと検出された場合、前記選択部及び前記生成部の各々による処理が実行され、前記検出部により前記経路候補が前記重複経路であると検出された場合、前記選択部及び前記生成部の各々による処理が実行されないように、前記選択部及び前記生成部を制御する制御部と、
を有するテストケース生成装置。
A management unit that manages the number of branch executions to the branch destination of the conditional branch included in the program under test;
Comparing the branch information corresponding to the route candidate obtained from the number of branch executions managed by the management unit with the branch information corresponding to the already extracted route of the program to be inspected, the route candidate is A detection unit for detecting whether the route is an overlapping route included in the already-existing route;
A selection unit that determines a branch destination based on a predetermined rule corresponding to the number of branch executions of the conditional branch, and selects a path from the start to the end of the program to be inspected;
A generation unit that generates branch information corresponding to the route selected by the selection unit as branch information corresponding to the already-explained route;
When the detection unit detects that the route candidate is not the overlapping route, processing by each of the selection unit and the generation unit is executed, and the detection unit detects that the route candidate is the overlapping route. A control unit that controls the selection unit and the generation unit so that processing by each of the selection unit and the generation unit is not executed,
A test case generation device having:
前記管理部は、前記条件分岐が前記被検査プログラムの呼出元から呼び出されるサブルーチンに含まれる条件分岐である場合には、前記条件分岐の各々について、前記条件分岐に対応した前記分岐実行回数を管理すると共に、前記サブルーチンの呼出元毎に前記条件分岐に対応した前記分岐実行回数を管理する
請求項1記載のテストケース生成装置。
When the conditional branch is a conditional branch included in a subroutine called from the call source of the program to be inspected, the management unit manages the number of branch executions corresponding to the conditional branch for each of the conditional branches. The test case generation device according to claim 1, wherein the branch execution count corresponding to the conditional branch is managed for each caller of the subroutine.
前記制御部は、前記管理部で管理される前記分岐実行回数に基づいて算出される、前記選択部による新たな前記経路の選択前の分岐網羅度と、前記管理部で管理される前記分岐実行回数に基づいて算出される、前記選択部による新たな前記経路の選択後の分岐網羅度と、を比較し、新たな前記経路の選択後の分岐網羅度が新たな前記経路の選択前の分岐網羅度と同じ場合には、前記選択部により選択された新たな前記経路に対応した分岐情報を、前記既出経路に対応した分岐情報として生成しないように前記生成部を制御する
請求項1又は請求項2記載のテストケース生成装置。
The control unit is calculated based on the number of branch executions managed by the management unit, the branch coverage before the selection of a new path by the selection unit, and the branch execution managed by the management unit The branch coverage after the selection of the new route by the selection unit calculated based on the number of times is compared, and the branch coverage after the selection of the new route is a branch before the selection of the new route When the degree of coverage is the same, the generation unit is controlled so as not to generate branch information corresponding to the new route selected by the selection unit as branch information corresponding to the existing route. Item 3. The test case generation device according to Item 2.
被検査プログラムに含まれる条件分岐の分岐先への分岐実行回数を管理し、
前記分岐実行回数から得られる経路候補に対応した分岐情報と、既に抽出された前記被検査プログラムの既出経路に対応した分岐情報と、を比較して、前記経路候補が前記既出経路に含まれる重複経路か否かを検出し、
前記経路候補が前記重複経路ではないと検出された場合、前記条件分岐の前記分岐実行回数に応じた予め定めた規則に基づいて分岐先を決定して、前記被検査プログラムの開始から終了までの経路を選択し、前記経路に対応した分岐情報を、前記既出経路に対応した分岐情報として生成し、前記経路候補が前記重複経路であると検出された場合、前記経路候補に対応した前記経路を選択せずに、且つ、前記経路に対応した分岐情報を、前記既出経路に対応した分岐情報として生成しないように制御する
ことを含むテストケース生成方法。
Manage the number of branch executions to the branch destination of the conditional branch included in the program to be inspected.
The branch information corresponding to the route candidate obtained from the number of branch executions is compared with the branch information corresponding to the already-extracted route of the program to be inspected, and the route candidate is included in the already-existing route. Detect if it ’s a route,
When it is detected that the route candidate is not the overlapping route, a branch destination is determined based on a predetermined rule corresponding to the number of branch executions of the conditional branch, and from the start to the end of the inspected program When a route is selected, branch information corresponding to the route is generated as branch information corresponding to the already-existing route, and when the route candidate is detected as the duplicate route, the route corresponding to the route candidate is selected. A test case generation method including controlling to not generate branch information corresponding to the route without selecting as branch information corresponding to the already-existing route.
コンピュータに、
被検査プログラムに含まれる条件分岐の分岐先への分岐実行回数を管理し、
前記分岐実行回数から得られる経路候補に対応した分岐情報と、既に抽出された前記被検査プログラムの既出経路に対応した分岐情報と、を比較して、前記経路候補が前記既出経路に含まれる重複経路か否かを検出し、
前記経路候補が前記重複経路ではないと検出された場合、前記条件分岐の前記分岐実行回数に応じた予め定めた規則に基づいて分岐先を決定して、前記被検査プログラムの開始から終了までの経路を選択し、前記経路に対応した分岐情報を、前記既出経路に対応した分岐情報として生成し、前記経路候補が前記重複経路であると検出された場合、前記経路候補に対応した前記経路を選択せずに、且つ、前記経路に対応した分岐情報を、前記既出経路に対応した分岐情報として生成しないように制御する
ことを含む処理を実行させるためのテストケース生成プログラム。
On the computer,
Manage the number of branch executions to the branch destination of the conditional branch included in the program to be inspected.
The branch information corresponding to the route candidate obtained from the number of branch executions is compared with the branch information corresponding to the already-extracted route of the program to be inspected, and the route candidate is included in the already-existing route. Detect if it ’s a route,
When it is detected that the route candidate is not the overlapping route, a branch destination is determined based on a predetermined rule corresponding to the number of branch executions of the conditional branch, and from the start to the end of the inspected program When a route is selected, branch information corresponding to the route is generated as branch information corresponding to the already-existing route, and when the route candidate is detected as the duplicate route, the route corresponding to the route candidate is selected. A test case generation program for executing processing including controlling to not generate branch information corresponding to the route as branch information corresponding to the already-existing route without selecting.
JP2014050456A 2014-03-13 2014-03-13 Test case generation apparatus, method, and program Active JP6245006B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2014050456A JP6245006B2 (en) 2014-03-13 2014-03-13 Test case generation apparatus, method, and program

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2014050456A JP6245006B2 (en) 2014-03-13 2014-03-13 Test case generation apparatus, method, and program

Publications (2)

Publication Number Publication Date
JP2015176230A JP2015176230A (en) 2015-10-05
JP6245006B2 true JP6245006B2 (en) 2017-12-13

Family

ID=54255412

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2014050456A Active JP6245006B2 (en) 2014-03-13 2014-03-13 Test case generation apparatus, method, and program

Country Status (1)

Country Link
JP (1) JP6245006B2 (en)

Families Citing this family (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP6827340B2 (en) * 2017-02-17 2021-02-10 三菱重工エンジニアリング株式会社 Software test equipment, software test systems, software test methods and programs
KR101989802B1 (en) * 2017-02-28 2019-06-18 주식회사 스패로우 Method for performing test using test case and apparatus for the same
JP6790921B2 (en) * 2017-03-02 2020-11-25 富士通株式会社 Program analyzer, program analysis method and program analysis program
JP7077909B2 (en) * 2018-10-22 2022-05-31 富士通株式会社 Dead code analysis program, dead code analysis method and dead code analysis device
CN110888803B (en) * 2019-11-08 2023-08-22 北京国家新能源汽车技术创新中心有限公司 Method and system for converting test decision table into test case
CN112817841B (en) * 2021-01-21 2022-12-09 西安交通大学 Method for determining MPI parallel program test data generation based on communication of path coverage

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP5884657B2 (en) * 2012-06-22 2016-03-15 富士通株式会社 Program, test case generation method, and test case generation apparatus

Also Published As

Publication number Publication date
JP2015176230A (en) 2015-10-05

Similar Documents

Publication Publication Date Title
JP6245006B2 (en) Test case generation apparatus, method, and program
US9600403B1 (en) Method and system for creating functional model of test cases
CN104899147B (en) A kind of code Static Analysis Method towards safety inspection
US8397104B2 (en) Creation of test plans
US10936474B2 (en) Software test program generation
JP6566576B2 (en) Hardware trojan detection method, hardware trojan detection program, and hardware trojan detection device
JP6142705B2 (en) Iterative generation of symbolic test drivers for object-oriented languages
JP6559600B2 (en) Information processing apparatus, information processing program, and inspection system
KR101645019B1 (en) Rule description language for software vulnerability detection
JP7077909B2 (en) Dead code analysis program, dead code analysis method and dead code analysis device
KR102114547B1 (en) Testing method and apparatus of target function incluede in target program
JP6416588B2 (en) Source code verification system
US10503633B2 (en) Symbolic execution of alternative branches
CN106155898B (en) Method and device for acquiring path of flow chart
JP7331681B2 (en) Test execution program, test execution method, and test execution device
JP7380851B2 (en) Test script generation device, test script generation method and program
JP6723483B2 (en) Test case generation device, test case generation method, and test case generation program
JP2017041196A (en) Stub object determination device, method, and program
CN113297069A (en) Software testing method and device based on target drive
JP5755861B2 (en) Test case generation apparatus, test case generation method, and test case generation program
JP2011048785A (en) Multiple event definition device, multiple event verification device, multiple event definition method, and multiple event definition program
JP2009244969A (en) Program operation comparison device, method, and program
JP2018151803A (en) Inspection device of computer program, and on-vehicle device for inspecting computer program for vehicle control
KR101658778B1 (en) String analysis method and apparatus based on path
US9411699B1 (en) Prioritization metrics for efficient post-Si failure localization

Legal Events

Date Code Title Description
A621 Written request for application examination

Free format text: JAPANESE INTERMEDIATE CODE: A621

Effective date: 20161206

A977 Report on retrieval

Free format text: JAPANESE INTERMEDIATE CODE: A971007

Effective date: 20171005

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: 20171017

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20171030

R150 Certificate of patent or registration of utility model

Ref document number: 6245006

Country of ref document: JP

Free format text: JAPANESE INTERMEDIATE CODE: R150