JP5884657B2 - Program, test case generation method, and test case generation apparatus - Google Patents
Program, test case generation method, and test case generation apparatus Download PDFInfo
- Publication number
- JP5884657B2 JP5884657B2 JP2012140947A JP2012140947A JP5884657B2 JP 5884657 B2 JP5884657 B2 JP 5884657B2 JP 2012140947 A JP2012140947 A JP 2012140947A JP 2012140947 A JP2012140947 A JP 2012140947A JP 5884657 B2 JP5884657 B2 JP 5884657B2
- Authority
- JP
- Japan
- Prior art keywords
- condition
- test
- variable
- execution
- test case
- 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.)
- Expired - Fee Related
Links
Images
Landscapes
- Debugging And Monitoring (AREA)
- Stored Programmes (AREA)
Description
本技術は、プログラムのテストデータの生成技術に関する。 The present technology relates to a technology for generating test data for a program.
プログラムをテストするために準備されるテストケースには、テスト対象のプログラムへ入力するデータ(テスト入力という。)と期待結果が含まれる。期待結果は、テスト対象のプログラムの仕様に基づいて求められる。例えば、期待結果は、テスト対象のプログラムの出力データの値として設定される。 Test cases prepared for testing a program include data (referred to as test input) to be input to the test target program and expected results. Expected results are obtained based on the specifications of the program to be tested. For example, the expected result is set as the value of the output data of the test target program.
テストケースの生成では、テスト中にプログラム中の命令、分岐あるいは実行パスを網羅的に実行するようにテスト入力を生成することが望まれる。つまり、コードカバレッジを高めることが課題となる。 In test case generation, it is desirable to generate test inputs so that instructions, branches, or execution paths in a program are comprehensively executed during a test. In other words, increasing code coverage is an issue.
人的な判断に基づくテスト入力の生成の他に、ランダムにテスト入力を生成する方法や所定ルール(データの範囲やデータの形式)に従ってテスト入力を生成する方法もある。しかし、これらの方法では、プログラムのコードや仕様を反映してテスト入力を生成するわけではないので、コードカバレッジが上がりにくいという問題がある。また、コードカバレッジを上げるためにテストケースを増やすと、重複するテストケースが多くなる。 In addition to test input generation based on human judgment, there are a method of generating test inputs randomly and a method of generating test inputs according to predetermined rules (data range and data format). However, these methods have a problem that code coverage is difficult to increase because test input is not generated by reflecting the code and specifications of the program. In addition, if the number of test cases is increased in order to increase code coverage, the number of duplicate test cases increases.
ホワイトボックステストを前提とした場合に、ソースコードを静的に解析して分岐条件を抽出し、その分岐条件に基づいてテスト入力を生成する方法もある。この方法によれば、プログラムのソースコードの実際の条件に従ってテスト入力を決めることができるので、テストケースの重複は避けやすい。しかし、実際にプログラムを実行するわけではないので、テストケースの欠落が生じる。 If a white box test is assumed, there is a method of statically analyzing the source code to extract a branch condition and generating a test input based on the branch condition. According to this method, the test input can be determined according to the actual conditions of the program source code, so that it is easy to avoid duplication of test cases. However, since the program is not actually executed, test cases are lost.
これに対して、プログラムを実行させながらテスト入力を生成するシンボリック実行という方法がある。この方法では、プログラム中の変数に具体的な値を設定せずに、シンボル値という特殊な値を持たせたままプログラムを実行する。 On the other hand, there is a method called symbolic execution that generates a test input while executing a program. In this method, the program is executed with a special value called a symbol value, without setting a specific value for a variable in the program.
ここで、クラスをテスト対象とする例を示す。図1に、テスト対象クラスの例を示す。クラス「TargetClass」に含まれるメソッド「method1」をテストすることを想定する。 Here, an example in which a class is a test target is shown. FIG. 1 shows an example of a test target class. Assume that the method “method1” included in the class “TargetClass” is to be tested.
メソッド「method1」に入力する変数は、int型の「a」とint型の「b」である。いずれの入力変数も、プリミティブ型の変数である。処理コードは、「if(a!=0)」101の判断による分岐処理と、「if(a>5)」103の判断による分岐処理と、「if(a!=0)」105の判断による分岐処理と、「if(b<=0)」109の判断による分岐処理を含んでいる。また、処理コードは、「b=b+1;」107の演算処理と、「a=b/a;」111の演算処理を含んでいる。 The variables input to the method “method1” are int type “a” and int type “b”. Each input variable is a primitive type variable. The processing code is determined by “if (a! = 0)” 101 branch processing, “if (a> 5)” 103 branch processing, and “if (a! = 0)” 105 determination. Branch processing and branch processing based on the determination of “if (b <= 0)” 109 are included. The processing code includes an arithmetic process “b = b + 1;” 107 and an arithmetic process “a = b / a;” 111.
図1の処理を模式化したフローを図2に示す。前半のフローは、201から207の4つのルートを含んでいる。ルート201は、条件「a==0」を満たす場合に通過する。ルート203は、条件「a!=0」と条件「a>5」と条件「a==0」を満たす場合に通過する。ルート205は、条件「a!=0」と条件「a>5」と条件「a!=0」を満たす場合に通過する。ルート207は、条件「a!=0」と条件「a<=5」と条件「b=b+1」を満たす場合に通過する。また、ルート207は、「b=b+1」の演算処理を含んでいる。
A flow diagram schematically showing the processing of FIG. 1 is shown in FIG. The first half flow includes four
後半のフローは、209と211の2つのルートを含んでいる。ルート209は、条件「b>0」を満たす場合に通過する。ルート211は、条件「b<=0」を満たす場合に通過する。また、ルート209は、「a=b/a」の演算処理を含んでいる。
The latter half flow includes two
形式的には、前半のフローの4ルートと後半のフローの2ルートを任意に組み合わせることが可能なので、全体としては8通りのルートが考えられる。この例においてテストケースを動的に生成するために、入力変数aと入力変数bにシンボル値を持たせることが考えられる。 Formally, since four routes of the first half flow and two routes of the second half flow can be arbitrarily combined, eight routes are considered as a whole. In this example, in order to dynamically generate a test case, it is conceivable that the input variable a and the input variable b have symbol values.
シンボリック実行を行う場合には、シンボリック実行の対象となるメソッドを呼び出すためのドライバ(シンボル実行用ドライバという。)を用意する。シンボリック実行部は、シンボル実行用ドライバを起動し、シンボル実行用ドライバを介してシンボリック実行の対象となるプログラムの処理コードを実行する。 When performing symbolic execution, a driver (referred to as a symbol execution driver) for invoking a method to be subjected to symbolic execution is prepared. The symbolic execution unit activates the symbol execution driver and executes the processing code of the program to be symbolically executed via the symbol execution driver.
図1に示したメソッド「method1」を呼び出すシンボル実行用ドライバの例を、図3に示す。シンボル実行用ドライバのクラス「SymbolicDriver」について説明する。301は、シンボル変数の宣言に関するコードである。シンボル変数は、シンボル値を保持する変数である。この宣言により、int型の「P1」とint型の「P2」がシンボル変数となる。「testFunc();」303は、実行開始位置を示すコードである。「target.method1(P1, P2);」305は、対象メソッドを呼び出すコードである。引数に、「P1」と「P2」を設定することにより、入力変数「a」には、シンボル変数「P1」が割り当てられ、入力変数「b」には、シンボル変数「P2」が割り当てられる。
FIG. 3 shows an example of a symbol execution driver that calls the method “method1” shown in FIG. The symbol execution driver class “SymbolicDriver” will be described.
対象となるプログラムにシンボル変数に関する分岐処理が含まれている場合には、複数の実行パターンに分けることにより、分岐可能なパスを網羅的に実行する。そして、実行パターンを実行する際に、その実行パターンを導いた判定が成立するためにシンボル値が満たさなければならない条件(パス条件という)を生成する。例えば、分岐処理がニ分岐型の場合に、シンボル変数に関する条件式が真となる実行パターンと、シンボル変数に関する条件式が偽となる実行パターンを別に実行する。そして、条件式が真となる実行パターンを実行する際には、条件式が真となるためのパス条件を生成し、条件式が偽となる実行パターンを実行する際には、条件式が偽となるためのパス条件を生成する。また、分岐処理が多分岐型の場合に、シンボル変数に関する条件式の選択候補毎に別の実行パターンを実行する。そして、条件式が選択候補となるためのパス条件を生成する。 If the target program includes branch processing related to symbol variables, the paths that can be branched are comprehensively executed by dividing them into a plurality of execution patterns. Then, when executing the execution pattern, a condition (referred to as a path condition) that the symbol value must satisfy in order to establish the determination that led to the execution pattern is generated. For example, when the branch process is a bi-branch type, an execution pattern in which the conditional expression related to the symbol variable is true and an execution pattern in which the conditional expression related to the symbol variable is false are executed separately. When executing an execution pattern for which the conditional expression is true, a path condition is generated for the conditional expression to be true. When executing an execution pattern for which the conditional expression is false, the conditional expression is false. Generate a path condition to become When the branch process is a multi-branch type, another execution pattern is executed for each selection candidate of the conditional expression related to the symbol variable. Then, a path condition for the conditional expression to be a selection candidate is generated.
図4に、図1に示したメソッド「method1」をテスト対象として、シンボリック実行により生成したテストケースの例を示す。 FIG. 4 shows an example of a test case generated by symbolic execution with the method “method1” shown in FIG. 1 as a test target.
ケース番号1のパス条件(P1==0)とパス条件(P2>0)は、図2に示したルート201とルート209を組み合わせた実行パターンにより得られる。そして、これらのパス条件を充足する値として、テスト入力「P1=0、P2=1」が得られる。このテストケースに従って入力変数aに0を設定し、入力変数bに1を設定して、メソッド「method1」を実行するとルート201とルート209を通過することになる。
The path condition (P1 == 0) and path condition (P2> 0) of
ケース番号2のパス条件(P1==0)とパス条件(P2<=0)は、図2に示したルート201とルート211を組み合わせた実行パターンにより得られる。そして、これらのパス条件を充足する値として、テスト入力「P1=0、P2=0」が得られる。このテストケースに従って入力変数aに0を設定し、入力変数bに0を設定して、メソッド「method1」を実行するとルート201とルート211を通過することになる。
The path condition (P1 == 0) and the path condition (P2 <= 0) of
ケース番号3のパス条件(P1!=0)とパス条件(P1>5)とパス条件(P2<=0)は、図2に示したルート205とルート211を組み合わせた実行パターンにより得られる。そして、これらのパス条件を充足する値として、テスト入力「P1=6、P2=0」が得られる。このテストケースに従って入力変数aに6を設定し、入力変数bに0を設定して、メソッド「method1」を実行するとルート205とルート211を通過することになる。
The path condition (P1! = 0), path condition (P1> 5), and path condition (P2 <= 0) of
ケース番号4のパス条件(P1!=0)とパス条件(P1>5)とパス条件(P2>0)は、図2に示したルート205とルート209を組み合わせた実行パターンにより得られる。そして、これらのパス条件を充足する値として、テスト入力「P1=6、P2=1」が得られる。このテストケースに従って入力変数aに6を設定し、入力変数bに1を設定して、メソッド「method1」を実行するとルート205とルート209を通過することになる。
The path condition (P1! = 0), path condition (P1> 5), and path condition (P2> 0) of
ケース番号5のパス条件(P1!=0)とパス条件(P1<=5)とパス条件(P2+1<=0)は、図2に示したルート207とルート211を組み合わせた実行パターンにより得られる。そして、これらのパス条件を充足する値として、テスト入力「P1=1、P2=−1」が得られる。このテストケースに従って入力変数aに1を設定し、入力変数bに−1を設定して、メソッド「method1」を実行するとルート207とルート211を通過することになる。この例では、ルート207の演算処理「b=b+1」の結果がその後の条件判断に反映されている。
The path condition (P1! = 0), path condition (P1 <= 5), and path condition (P2 + 1 <= 0) of
ケース番号6のパス条件(P1!=0)とパス条件(P1<=5)とパス条件(P2+1>0)は、図2に示したルート207とルート209を組み合わせた実行パターンにより得られる。そして、これらのパス条件を充足する値として、テスト入力「P1=1、P2=0」が得られる。このテストケースに従って入力変数aに1を設定し、入力変数bに0を設定して、メソッド「method1」を実行するとルート207とルート209を通過することになる。この例でも、ルート207の演算処理「b=b+1」の結果がその後の条件判断に反映されている。
The path condition (P1! = 0), path condition (P1 <= 5), and path condition (P2 + 1> 0) of
尚、a!=0の条件を満たし、かつa==0の条件を満たすaの値は存在しないので、ルート203に至ることはない。つまり、ルート203とルート209を組み合わせた実行パターンと、ルート203とルート211を組み合わせた実行パターンは、パス条件を充足するような値がシンボル変数に対して存在しないことになる。このような実行パターンについては、実行不可能なのでテストケースとならない。
A! Since there is no value of a that satisfies the condition of = 0 and satisfies the condition of a == 0, the
パス条件を充足可能な場合には、ケース番号1からケース番号6のようにテストケースが生成できる。このようにして、プログラムを実行しながらテストケースを生成することによって、高いコードカバレッジが期待できる。
When the pass condition can be satisfied, test cases such as
しかし、シンボリック実行でシンボル変数として扱えるのは、主として数値や真偽値などのプリミティブ型変数である。オブジェクト指向プログラミング言語により記述されたプログラムについては、一般にオブジェクト型変数を用いており、そのような変数をテスト入力とするプログラムに対しては、シンボリック実行によりテストケースを生成することはできない。 However, what can be handled as symbolic variables in symbolic execution is mainly primitive variables such as numeric values and boolean values. An object type variable is generally used for a program written in an object-oriented programming language, and a test case cannot be generated by symbolic execution for a program that uses such a variable as a test input.
従って、本技術の目的は、一側面では、オブジェクト型変数を用いたプログラムに適したテストデータを生成することである。 Accordingly, an object of the present technology is, in one aspect, to generate test data suitable for a program using object type variables.
本実施の形態に係るテストケース生成方法は、(A)テスト対象のプログラムへ入力されるオブジェクト型変数の状態を示す制御変数を含む一又は複数のシンボル変数を用いて、制御変数に応じたオブジェクト型変数の初期化とテスト対象のプログラムの呼び出しを行うためのドライバ及び呼び出されるテスト対象のプログラムにおける実行パターン毎に、ドライバ及びテスト対象のプログラムの実行において一又は複数のシンボル変数が満たすべき第1のパス条件を計算し、第1のパス条件と第1のパス条件に対する一又は複数のシンボル変数の充足値とを含む第1のテストケースを生成するシンボリック実行処理と、(B)実行パターン毎に、テスト対象のプログラムの実行において状態としてオブジェクト型変数が満たすべき第2のパス条件を生成する第1の生成処理と、(C)実行パターン毎に、第1のテストケースに含まれる第1のパス条件から、制御変数が満たすべき条件を省き、第2のパス条件を加えた第3のパス条件を求め、第3のパス条件と一又は複数のシンボル変数の充足値とを含む第2のテストケースを生成する第2の生成処理と、(D)第3のパス条件が同義である第2のテストケースが複数ある場合に、第3のパス条件が同義である複数の第2のテストケースのうち、いずれかの第2のテストケースを省き、残った第2のテストケースを抽出する抽出処理とを含む。 The test case generation method according to the present embodiment uses (A) one or a plurality of symbol variables including a control variable indicating a state of an object type variable input to a test target program, and an object corresponding to the control variable For each execution pattern in the driver for invoking the type variable initialization and the test target program and the test target program to be called, the first one or more symbol variables to be satisfied in the execution of the driver and the test target program A symbolic execution process for generating a first test case including the first pass condition and a satisfaction value of one or more symbol variables for the first pass condition; and (B) for each execution pattern In addition, the second parameter that the object type variable should satisfy as the state in the execution of the program under test is First generation processing for generating a condition, and (C) for each execution pattern, a condition to be satisfied by a control variable is omitted from the first path condition included in the first test case, and a second path condition is added. A second generation process for determining a third path condition and generating a second test case including the third path condition and a satisfaction value of one or more symbol variables; and (D) a third path condition. When there are a plurality of second test cases having the same meaning, the second test case among the plurality of second test cases having the same third pass condition is omitted, and the remaining second test case is omitted. And an extraction process for extracting a test case.
オブジェクト型変数を用いたプログラムに適したテストデータを生成できるようになる。 Test data suitable for programs using object type variables can be generated.
図5に、テスト対象クラスの例を示す。ここでは、テスト対象のクラス「TargetClass」に含まれるテスト対象メソッド「targetMethod2」の動作をテストすることを想定する。テスト対象メソッド「targetMethod2」は、オブジェクト型変数「obj1」とオブジェクト型変数「obj2」を入力する構成になっている。 FIG. 5 shows an example of the test target class. Here, it is assumed that the operation of the test target method “targetMethod2” included in the test target class “TargetClass” is tested. The test target method “targetMethod2” is configured to input an object type variable “obj1” and an object type variable “obj2”.
図6に、ライブラリの例を示す。クラスAとクラスBとクラスCは、上述のテスト対象のクラス「TargetClass」で用いられる。クラスAは、メンバ変数a1を保持している。クラスBは、クラスAを継承している。つまり、Bは、親クラスAの子クラスである。クラスBは、メンバ変数b1を保持している。クラスCも、クラスAを継承している。つまり、Cも、親クラスAの子クラスである。 FIG. 6 shows an example of a library. Class A, class B, and class C are used in the above-described test target class “TargetClass”. Class A holds member variable a1. Class B inherits class A. That is, B is a child class of the parent class A. Class B holds member variable b1. Class C also inherits class A. That is, C is also a child class of the parent class A.
クラス「SymbolicExecUtil」が保持するメソッド「calcPathCondition(Object obj, String name)」は、オブジェクト指定命令である。オブジェクト指定命令は、パス条件の計算対象となるオブジェクト型変数を指定する命令である。シンボリック実行時にオブジェクト指定命令が呼ばれると、「obj」が参照するインスタンスについて、この命令以後のオブジェクトパス条件を計算する。また、オブジェクト指定命令は、オブジェクトパス条件内でobjを指す変数名としてnameを使うことも指定している。但し、通常のプログラム実行時にオブジェクト指定命令が呼ばれても、何もしない。 The method “calcPathCondition (Object obj, String name)” held by the class “SymbolExecUtil” is an object designation command. The object designation command is a command for designating an object type variable that is a calculation target of a path condition. When an object designation command is called during symbolic execution, the object path condition after this command is calculated for the instance referred to by “obj”. The object designation command also designates the use of name as a variable name indicating obj in the object path condition. However, nothing is done even if an object designation command is called during normal program execution.
テストケース生成装置は、テスト対象クラスとテスト対象クラスが用いるライブラリ(例えば、クラスAとクラスBとクラスC)に基づいて、シンボル実行用ドライバを生成する。シンボル実行用ドライバは、初期設定やテスト対象の呼び出しを行うドライバである。テストケース生成装置は、シンボル実行用ドライバを生成するために、サンプルフォームを用いる。 The test case generation device generates a symbol execution driver based on the test target class and a library used by the test target class (for example, class A, class B, and class C). The symbol execution driver is a driver that performs an initial setting and a test target call. The test case generation apparatus uses a sample form to generate a symbol execution driver.
図7に、シンボル実行用ドライバのサンプルフォームの例を示す。シンボル変数宣言エリア701は、シンボル変数の宣言を設定する領域である。対象クラス初期化エリア703は、対象クラスの初期化を設定する領域である。初期化コードエリア705は、パス条件の計算対象となるオブジェクト型変数を初期化するコードを設定する領域である。オブジェクト指定命令エリア707は、オブジェクト指定命令を設定する領域である。対象メソッドの呼び出しエリア709は、対象メソッド呼び出し命令を設定する領域である。
FIG. 7 shows an example of a symbol execution driver sample form. The symbol
図8に、サンプルフォームを用いて生成されたシンボル実行用ドライバの例を示す。 FIG. 8 shows an example of a symbol execution driver generated using the sample form.
コード801とコード803とコード805とコード807は、オブジェクト型変数P1に関するシンボル変数を宣言するコードである。尚、コード801とコード803は、制御変数の宣言であり、コード805とコード807は、メンバシンボル変数の宣言である。制御変数とメンバシンボル変数は、いずれもシンボル変数である。
A
コード809は、シンボリック実行による実行開始位置を示すコードである。コード811は、対象クラスの初期化を行うコードである。コード813は、オブジェクト型変数の宣言を行うコードである。コード815は、オブジェクト型変数のnull判定とnull値の代入を行うコードである。尚、elseにおける処理は、コード819によって閉じている。コード817は、オブジェクト型変数をクラス型に応じて初期化するコードである。コード821は、オブジェクト型変数をパス条件算出の対象とすることを指定するオブジェクト指定命令である。コード823は、テスト対象であるクラスを呼び出すコードである。
A
また、準備段階において、テスト対象クラスに基づいて制御変数テーブルも生成される。図9に、制御変数テーブルの例を示す。制御変数は、テスト対象メソッドへ入力されるオブジェクト型変数の状態を示している。この例で、制御変数P1_cnullは、オブジェクト型変数P1がnullであるか否かを示している。制御変数P1_cnullの値がtrueである場合には、オブジェクト型変数P1がnullであることを意味しており、意味式「P1==null」と同義である。制御変数P1_cnullの値がfalseである場合には、オブジェクト型変数P1がnullでないことを意味しており、意味式「P1!=null」と同義である。 In the preparation stage, a control variable table is also generated based on the test target class. FIG. 9 shows an example of the control variable table. The control variable indicates the state of the object type variable input to the test target method. In this example, the control variable P1_cull indicates whether or not the object type variable P1 is null. If the value of the control variable P1_cull is true, it means that the object type variable P1 is null, which is synonymous with the semantic expression “P1 == null”. If the value of the control variable P1_cull is false, it means that the object type variable P1 is not null, which is synonymous with the semantic expression “P1! = Null”.
この例で、制御変数P1_cClassは、オブジェクト型変数の実際のクラス型を示している。制御変数P1_cClassの値が0である場合には、オブジェクト型変数P1の実際の型がクラスAであることを意味しており、意味式「P1 instanceof A」と同義である。制御変数P1_cClassの値が1である場合には、オブジェクト型変数P1の実際の型がクラスBであることを意味しており、意味式「P1 instanceof B」と同義である。制御変数P1_cClassの値が0又は1以外である場合には、オブジェクト型変数P1の実際の型がクラスCであることを意味しており、意味式「P1 instanceof C」と同義である。尚、変数の入力方法は、参照可能な形式であればよく、引数形式に限らない。 In this example, the control variable P1_cClass indicates the actual class type of the object type variable. When the value of the control variable P1_cClass is 0, it means that the actual type of the object type variable P1 is class A, which is synonymous with the semantic expression “P1 instance of A”. When the value of the control variable P1_cClass is 1, it means that the actual type of the object type variable P1 is class B, which is synonymous with the semantic expression “P1 instanceof B”. When the value of the control variable P1_cClass is other than 0 or 1, it means that the actual type of the object type variable P1 is class C, which is synonymous with the semantic expression “P1 instanceof C”. Note that the variable input method is not limited to the argument format as long as it can be referred to.
まず、テストケース生成装置によりシンボル実行用ドライバと制御変数テーブルを生成する準備処理について説明する。図10に、テストケース生成装置のうち準備処理に係る構成例を示す。テストケース生成装置は、受付部1001、対象クラス格納部1003、ライブラリ格納部1005、サンプルフォーム格納部1007、ドライバ生成部1009、ドライバ格納部1011、制御変数テーブル生成部1013、及び制御変数テーブル格納部1015を有している。
First, preparation processing for generating a symbol execution driver and a control variable table by the test case generation apparatus will be described. FIG. 10 shows a configuration example related to the preparation process in the test case generation apparatus. The test case generation apparatus includes a
受付部1001は、対象クラスとライブラリを受け付けるように構成されている。対象クラス格納部1003は、対象クラスを格納するように構成されている。ライブラリ格納部1005は、ライブラリを格納するように構成されている。サンプルフォーム格納部1007は、サンプルフォームを予め格納している。ドライバ生成部1009は、シンボル実行用ドライバを生成するように構成されている。ドライバ格納部1011は、シンボル実行用ドライバを格納するように構成されている。制御変数テーブル生成部1013は、制御変数テーブルを生成するように構成されている。制御変数テーブル格納部1015は、制御変数テーブルを格納するように構成されている。
The receiving
図11に、準備処理フローの例を示す。受付部1001は、対象クラスとライブラリを受け付ける(S1101)。そして、ドライバ生成部1009は、ドライバ生成処理を行う(S1103)。続いて、制御変数テーブル生成部1013は、制御変数テーブル生成処理を行う(S1105)。制御変数テーブル生成処理(S1105)については、図24を用いて後述する。
FIG. 11 shows an example of a preparation process flow. The accepting
図12に、ドライバ生成処理フローの例を示す。ドライバ生成部1009は、まずサンプルフォーム格納部1007からサンプルフォームを読み出す(S1201)。そして、ドライバ生成部1009は、シンボル変数宣言処理を行う(S1203)。
FIG. 12 shows an example of a driver generation processing flow. The
図13に、シンボル変数宣言処理フローの例を示す。ドライバ生成部1009は、対象メソッドの入力変数を特定する(S1301)。例えば、図5では、「A obj1」と「A obj2」が入力変数である。尚、図1の例であれば、入力変数は「int a」と「int b」が入力変数である。
FIG. 13 shows an example of a symbol variable declaration processing flow. The
そして、ドライバ生成部1009は、入力変数毎に以下の処理を繰り返す(S1303)
Then, the
ドライバ生成部1009は、入力変数の型がオブジェクト型であるか、あるいはプリミティブ型であるかを判定する(S1305)。例えば、入力変数が「A obj1」であれば、オブジェクト型であると判定し、入力変数が「int a」であれば、プリミティブ型であると判定する。
The
まず、入力変数の型がオブジェクト型と判定された場合について説明する。ドライバ生成部1009は、制御変数宣言処理を行う(S1307)。
First, a case where the input variable type is determined to be an object type will be described. The
図14に、制御変数宣言処理フローの例を示す。ドライバ生成部1009は、規約に従ってnull制御変数名を決める(S1401)。この例で、i番目の入力変数に対するnull制御変数名は、「Pi_cnull」となる。そして、ドライバ生成部1009は、サンプルフォームのシンボル変数宣言エリア701に「@Symbolic(”true”)」の行を追加し(S1403)、更に「public static boolean;」の行を加える(S1405)。そして、ドライバ生成部1009は、boolean型のnull制御変数名を挿入する(S1407)。更に、ドライバ生成部1009は、null制御変数に具体値を代入するようにしてもよい。このようにして、例えば図8に示した801の宣言が生成される。
FIG. 14 shows an example of a control variable declaration process flow. The
続いて、ドライバ生成部1009は、規約に従って実際型制御変数名を決める(S1409)。この例で、i番目の入力変数に対する実際型制御変数名は、「Pi_cClass」となる。ドライバ生成部1009は、サンプルフォームのシンボル変数宣言エリア701に「@Symbolic(”true”)」の行を追加し(S1411)、更に、「public static int;」の行を加え(S1413)。そして、ドライバ生成部1009は、int型の実際型制御変数名を挿入する(S1415)。ドライバ生成部1009は、実際型制御変数に具体値を代入するようにしてもよい。このようにして、例えば図8に示した803の宣言が生成される。
Subsequently, the
図13の処理に戻って、ドライバ生成部1009は、メンバ宣言処理を行う(S1309)。
Returning to the processing of FIG. 13, the
図15に、メンバ宣言処理フローの例を示す。ドライバ生成部1009は、オブジェクト型変数として保持し得るメンバ変数毎に以下の処理を繰り返す(S1501)。ドライバ生成部1009は、規約に従ってメンバシンボル変数名を決める(S1503)。この例で、i番目の入力変数のメンバ変数Mに対するメンバシンボル変数名は、「Pi_mM」となる。ドライバ生成部1009は、サンプルフォームのシンボル変数宣言エリア701に「@Symbolic(”true”)」の行を追加し(S1505)、更に、「public static ;」の行を加える(S1507)。そして、ドライバ生成部1009は、データの型を挿入し(S1509)、メンバシンボル変数名を挿入する(S1511)。ドライバ生成部1009は、メンバシンボル変数に具体値を代入するようにしてもよい。このようにして、例えば図8に示した805と807の宣言が生成される。ドライバ生成部1009は、すべてのメンバ変数について処理したか否かを判定する(S1513)。処理していないメンバ変数があると判定した場合には、S1501へ戻る。すべてのメンバ変数について処理したと判定した場合には、ドライバ生成部1009は処理を終え、図13のS1311へ戻る。
FIG. 15 shows an example of the member declaration processing flow. The
図13の処理に戻って、ドライバ生成部1009は、初期化コード処理を行う(S1311)。
Returning to the processing of FIG. 13, the
図16に、初期化コード処理フローの例を示す。ドライバ生成部1009は、規約に従ってオブジェクト型変数名を決める(S1601)。この例で、i番目の入力変数名は、プリミティブ型変数であるかオブジェクト型変数であるかを問わず、「Pi」となる。ドライバ生成部1009は、サンプルフォームの初期化コードエリア705にオブジェクト型変数の宣言を追加する(S1603)。具体的には、クラス型とオブジェクト変数名が設定される。このようにして、例えば図8に示した813の宣言が生成される。
FIG. 16 shows an example of an initialization code processing flow. The
続いて、ドライバ生成部1009は、null化処理を行う(S1605)。図17に、null化処理フローの例を示す。ドライバ生成部1009は、サンプルフォームの初期化コードエリア705に判定制御コードを追加する(S1701)。この例では、判定制御コードとして図8の815と819に示した「if(){}else{}」(改行省略)を追加する。ドライバ生成部1009は、null判定条件を挿入する(S1703)。この例では、if文の()内にnull制御変数名を挿入する。ドライバ生成部1009は、if文の判定が真の場合に、null制御変数名へnullを代入する命令を追加し(S1705)、処理を終える。
Subsequently, the
図16の処理に戻って、ドライバ生成部1009は、クラス判定処理を行う(S1607)。ドライバ生成部1009は、クラス判定処理で(S1607)、例えば図8の817のコードを設定する。
Returning to the processing of FIG. 16, the
図18に、クラス判定処理フローの例を示す。ドライバ生成部1009は、サンプルフォームの初期化コードエリア705に分岐制御コードを追加する(S1801)。この例では、if文の判定が偽の場合の分岐制御コードとして「switch(){case:break;case:break;default:break;}」(改行省略)を追加する。ドライバ生成部1009は、分岐条件を挿入し(S1803)、処理を終える。この例では、switch文の()内に実際型制御変数名「P1_cClass」を挿入し、各caseの後に「0」と「1」を挿入する。
FIG. 18 shows an example of the class determination processing flow. The
図16の処理に戻って、ドライバ生成部1009は、オブジェクト型変数初期化処理を行う(S1609)。ドライバ生成部1009は、オブジェクト型変数初期化処理(S1609)で、オブジェクト型変数の型の候補となるクラス型毎の初期化のコードを設定する。
Returning to the processing of FIG. 16, the
図19に、オブジェクト型変数初期化処理フローの例を示す。ドライバ生成部1009は、候補となるクラス型毎に以下の処理を繰り返す(S1901)。ドライバ生成部1009は、オブジェクト型変数生成の命令を追加する(S1903)。例えばクラス型がAの場合には、「(オブジェクト型変数)=new A();」のコードを追加する。ドライバ生成部1009は、更に候補のクラス型で保持し得るメンバ変数についてメンバ初期化の命令を追加する(S1905)。具体的には、「(メンバ変数)=(メンバシンボル変数名);」のコードを追加する。ドライバ生成部1009は、すべての候補となるクラス型について処理したか否かを判定する(S1907)。処理していないクラス型があると判定した場合には、ドライバ生成部1009はS1901に戻る。すべての候補となるクラス型について処理したと判定した場合には、ドライバ生成部1009は処理を終え、図16の処理へ戻る。このようにして、例えば図8に示した817のコードが設定される。更に、ドライバ生成部1009は図16の処理を終え、図13のS1313へ戻る。
FIG. 19 shows an example of an object type variable initialization process flow. The
図13の処理に戻って、ドライバ生成部1009は、オブジェクト指定命令処理を行う(S1313)。ドライバ生成部1009は、オブジェクト指定命令処理(S1313)で、例えば、図8に示した821のコードを設定する。
Returning to the processing of FIG. 13, the
図20に、オブジェクト指定命令処理フローの例を示す。ドライバ生成部1009は、サンプルフォームのオブジェクト指定命令エリア707にオブジェクト指定命令「SymbolicExecUtil.calcPathCondition();」の行を追加する(S2001)。ドライバ生成部1009は、オブジェクト指定命令の引数にオブジェクト型変数名を挿入する(S2003)。
FIG. 20 shows an example of an object designation command processing flow. The
また、ドライバ生成部1009は、パス条件用変数名を特定する(S2005)。パス条件用変数名は、このオブジェクト型変数についてのパス条件を生成する際に用いる変数名である。この例では、パス条件用変数名は、オブジェクト型変数名と同じである。ドライバ生成部1009は、オブジェクト指定命令の引数にパス条件用変数名を挿入する(S2007)。ドライバ生成部1009は図20の処理を終え、図13のS1317へ戻る。
In addition, the
次に、図13の処理に戻って、S1305で入力変数の型がプリミティブ型と判定された場合について説明する。 Next, returning to the processing of FIG. 13, the case where the type of the input variable is determined to be a primitive type in S1305 will be described.
S1305で入力変数の型がプリミティブ型と判定された場合には、ドライバ生成部1009は、プリミティブ宣言処理を行う(S1315)。図21に、プリミティブ宣言処理フローの例を示す。ドライバ生成部1009は、規約に従ってプリミティブ型変数名を決める(S2101)。この例で、i番目の入力変数名は、プリミティブ型変数であるかオブジェクト型変数であるかを問わず、「Pi」となる。ドライバ生成部1009は、サンプルフォームのシンボル変数宣言エリア701に「@Symbolic(”true”)」の行を追加する(S2103)。ドライバ生成部1009は、「public static ;」の行を加える(S2105)。ドライバ生成部1009は、プリミティブ型変数のデータ型を挿入する(S2107)。ドライバ生成部1009は、シンボル変数名を挿入する(S2109)。このようにして、例えば図3の301のコードが設定される。ドライバ生成部1009は図21の処理を終えると、図13のS1317へ戻る。
If the input variable type is determined to be a primitive type in S1305, the
図13の処理に戻って、ドライバ生成部1009は、すべての引数について処理したか否かを判定する(S1317)。処理していない引数があると判定した場合には、ドライバ生成部1009はS1301へ戻る。すべての引数について処理したと判定した場合には、ドライバ生成部1009は図13の処理を終え、図12のS1205へ戻る。
Returning to the processing of FIG. 13, the
図12の処理に戻って、ドライバ生成部1009は、対象クラス初期化処理(S1205)で、対象クラスを初期化するコードを設定する。
Returning to the process of FIG. 12, the
図22は、対象クラス初期化処理フローの例を示す図である。ドライバ生成部1009は、図7に示したサンプルフォームの対象クラス初期化エリア703に「TargetClass target = new ();」の行を追加する(S2201)。ドライバ生成部1009は、対象クラス名を特定し(S2203)、「()」の前に挿入し(S2205)、処理を終える。このようにして、図8に示した811のコードが設定される。
FIG. 22 is a diagram illustrating an example of a target class initialization process flow. The
図22の処理を終えると、図12の処理に戻って、ドライバ生成部1009は、対象メソッド呼び出し処理を行う(S1207)。
When the process of FIG. 22 is completed, the process returns to the process of FIG. 12, and the
図23に、対象メソッド呼び出し処理フローの例を示す。ドライバ生成部1009は、図7に示したサンプルフォームの対象メソッドの呼び出しエリア709に「target.();」 の行を追加する(S2301)。ドライバ生成部1009は、対象メソッド名を特定し(S2303)、「.」の後に挿入する(S2305)。更に、ドライバ生成部1009は、引数に設定する変数名を挿入し(S2307)、処理を終える。ドライバ生成部1009は図12の対象メソッド呼び出し処理(S1207)を終え、更に図11のドライバ生成処理(S1103)を終える。
FIG. 23 shows an example of the target method call processing flow. The
続いて、図11の処理に戻って、S1105に示した制御変数テーブル生成処理について説明する。制御変数テーブル生成部1013は、制御変数テーブル生成処理で、例えば図9に示した制御変数テーブルを生成する。
Next, returning to the process of FIG. 11, the control variable table generation process shown in S1105 will be described. The control variable
図24に、制御変数テーブル生成処理フローの例を示す。制御変数テーブル生成部1013は、対象メソッドの入力変数を特定し(S2401)、入力変数毎に以下の処理を繰り返す(S2403)。制御変数テーブル生成部1013は、入力変数の型がオブジェクト型であるか、あるいはプリミティブ型であるかを判定する(S2405)。入力変数の型がプリミティブ型であると判定した場合には、制御変数テーブル生成部1013はS2417を行う。
FIG. 24 shows an example of a control variable table generation processing flow. The control variable
入力変数の型がオブジェクト型であると判定した場合には、制御変数テーブル生成部1013は、図14のS1401で決めたnull制御変数名を設定する(S2407)。そして、制御変数テーブル生成部1013は、trueと意味式を設定する(S2409)。意味式は、「(オブジェクト型変数名)==null」となる。制御変数テーブル生成部1013は、更にfalseと意味式を設定する(S2411)。意味式は、「(オブジェクト型変数名)!=null」となる。
If it is determined that the type of the input variable is an object type, the control variable
次に、制御変数テーブル生成部1013は、図14のS1409で決めた実際型制御変数名を設定する(S2413)。更に、制御変数テーブル生成部1013は、候補クラスを示す値と意味式を設定する(S2415)。値に応じて、「(オブジェクト型変数名) instanceof (候補クラス名)」とする。制御変数テーブル生成部1013は、すべての入力変数について処理した否かを判定する(S2417)。処理していない入力変数があると判定した場合には、制御変数テーブル生成部1013はS2403に戻る。すべての入力変数について処理したと判定した場合には、制御変数テーブル生成部1013は処理を終え、図11に戻り、準備処理を終える。
Next, the control variable
このように準備処理において、シンボル実行用ドライバと制御変数テーブルを生成することにより、テストケース生成作業の省力化が図られる。 In this way, in the preparation process, by generating the symbol execution driver and the control variable table, it is possible to save labor in the test case generation work.
続いて、シンボリック実行処理について説明する。図25は、テストケース生成装置のうちシンボリック実行処理に係る構成例を示す図である。テストケース生成装置は、更に、実行部1017、パターンテーブル格納部1019、シンボル変数テーブル記憶部1021、特定部1023、オブジェクトテーブル記憶部1025、第1テストケース格納部1027、第1生成部1029及びオブジェクトパス条件記憶部1031を有している。
Next, symbolic execution processing will be described. FIG. 25 is a diagram illustrating a configuration example related to symbolic execution processing in the test case generation device. The test case generation apparatus further includes an
実行部1017は、シンボリック実行を行い、第1テストケースを生成するように構成されている。パターンテーブル格納部1019は、プログラムパターンとメモリ条件パターンとパス条件パターンを対応付けるパターンテーブルを記憶するように構成されている。パターンテーブル格納部1019については、図26を用いて後述する。
The
シンボル変数テーブル記憶部1021は、シンボル変数とその型を対応付けるシンボル変数テーブルを記憶するように構成されている。特定部1023は、オブジェクト型変数の実体が格納されている位置を特定したオブジェクトテーブルを生成する処理を行うように構成されている。オブジェクトテーブル記憶部1025は、オブジェクトテーブルを記憶するように構成されている。第1テストケース格納部1027は、第1テストケースの集合である第1テストケースセットを記憶するように構成されている。第1生成部1029は、オブジェクトテーブルに基づいて、オブジェクト型変数が満たすべきオブジェクトパス条件を生成する処理を行うように構成されている。オブジェクトパス条件記憶部1031は、オブジェクトパス条件を記憶するように構成されている。
The symbol variable
図26に、パターンテーブルの例を示す。パターンテーブルは、パターン番号、プログラムパターン、メモリ条件パターン及びパス条件パターンを対応付けている。プログラムに含まれる式のパターンにより導かれるオブジェクトパス条件のパターンを定めている。更に、プログラムに含まれる式のパターンに加えて、メモリの条件も加えて判断する場合のメモリ条件のパターンも定めている。 FIG. 26 shows an example of the pattern table. The pattern table associates pattern numbers, program patterns, memory condition patterns, and path condition patterns. The object path condition pattern derived from the expression pattern included in the program is defined. Furthermore, in addition to the pattern of formulas included in the program, a memory condition pattern is also defined in the case of determining by adding a memory condition.
メモリ条件パターンが設定されていない場合には、プログラムパターンからパス条件パターンが導かれ、メモリ条件パターンが設定されている場合には、プログラムパターン及びメモリ条件パターンからパス条件パターンが導かれる。 When the memory condition pattern is not set, the path condition pattern is derived from the program pattern. When the memory condition pattern is set, the path condition pattern is derived from the program pattern and the memory condition pattern.
「OBJX」と「OBJY」は、オブジェクトパス条件を計算する対象となるオブジェクト変数を示している。例えば、パターン番号1に示したように、プログラム中の命令に「OBJX==null」の式が含まれる場合には、パス条件として「OBJX==null」が導かれる。
“OBJX” and “OBJY” indicate object variables for which object path conditions are calculated. For example, as shown in
また、「TX」は、型を示している。例えば、パターン番号3に示したように、プログラム中の命令に「OBJX instanceof TX」の式が含まれる場合には、パス条件として「OBJX instanceof TX」が導かれる。
“TX” indicates a type. For example, as shown in
「.member」は、メンバ変数へのアクセスを示している。例えば、パターン番号5に示したように、プログラム中の命令に「OBJX.member」の式が含まれる場合には、パス条件として「OBJX!=null」が導かれる。
“.Member” indicates access to a member variable. For example, as shown in
「.method()」は、メソッドの呼び出しを示している。例えば、パターン番号6に示したように、プログラム中の命令に「OBJX.method()」の式が含まれる場合には、パス条件として「OBJX!=null」が導かれる。
“.Method ()” indicates a method call. For example, as shown in
「VX」と「VY」は、オブジェクトパス条件を計算する対象とならない変数を示している。例えば、パターン番号7に示したように、プログラム中の命令に「OBJX==VX」の式が含まれ、更にメモリの状態が「VX==null」であれば、パス条件として「OBJX==null」が導かれる。
“VX” and “VY” indicate variables that are not targets for calculating the object path condition. For example, as shown in the
図27に、シンボル変数テーブル記憶部1021で記憶されるシンボル変数テーブルの例を示す。このように、シンボル変数テーブル記憶部1021は、シンボル変数とその型を対応付ける。
FIG. 27 shows an example of a symbol variable table stored in the symbol variable
図28に、オブジェクトテーブル記憶部1025で記憶されるオブジェクトテーブルの例を示す。図28に示したように、オブジェクトパス条件を計算する対象となるオブジェクト型変数名と、参照用IDと、パス条件用変数名を対応付けている。参照用IDは、オブジェクト型変数のインスタンスを参照するための情報である。パス条件用変数名は、オブジェクトパス条件で用いるオブジェクト型変数の変数名である。オブジェクト型変数名は、省略してもよい。
FIG. 28 shows an example of an object table stored in the object
図29a乃至図29cに、第1テストケース格納部1027で記憶される第1テストケースセットの例を示す。テストケースを識別するケース番号と、テスト入力と、シンボルパス条件を対応付けている。第1テストケースは、シンボリック実行処理により生成される。
FIGS. 29 a to 29 c show examples of the first test case set stored in the first test
図30に、オブジェクトパス条件記憶部1031で記憶されるオブジェクトパス条件の例を示す。テストケースを識別するケース番号とオブジェクトパス条件を対応付けている。例えば、ケース番号1の場合、「P1_cnull==true∧P2_cnull ==true」がオブジェクトパス条件となることを示している。オブジェクトパス条件は、第1生成部1029により生成される。
FIG. 30 shows an example of object path conditions stored in the object path
続いて、シンボリック実行処理について説明する。図31に、シンボリック実行処理フローの例を示す。実行部1017は、まず初期化処理を行う(S3101)。
Next, symbolic execution processing will be described. FIG. 31 shows an example of a symbolic execution process flow. The
図32に、初期化処理フローの例を示す。実行部1017は、シンボル変数テーブルを生成する(S3201)。シンボル変数テーブルは、シンボル実行用ドライバのシンボル変数宣言から抽出される。シンボル変数テーブルは、シンボル変数を特定するために用いられる。実行部1017は、実行開始位置を特定する(S3203)。実行開始位置は、図8の809のコードにより特定される。実行部1017は、第1テストケースに新規レコードを割り当てる(S3205)。このとき、ケース番号も割り振られる。実行部1017は処理を終了し、図31のS3103へ戻る。
FIG. 32 shows an example of an initialization process flow. The
図31の処理に戻って、実行部1017は、実行パターン処理を行う(S3103)。実行パターン処理では、実行パターン毎の処理を行う。図33に、実行パターン処理フローの例を示す。実行部1017は、実行開始位置から順に命令を特定する(S3301)。実行部1017は、命令が有るか否かを判定する(S3303)。命令が無いと判定した場合には、実行パターンの終点であるので、実行部1017は、処理結果を完了として処理を終了する(S3305)。実行部1017が処理を終えると、図31のS3105へ戻る。
Returning to the processing of FIG. 31, the
図33のS3303で命令が有ると判定した場合には、実行部1017は、命令がオブジェクト指定命令であるか否かを判定する(S3307)。オブジェクト指定命令は、例えば図8に示した821のコードである。命令がオブジェクト指定命令でないと判定した場合には、実行部1017はS3311へ処理を移す。命令がオブジェクト指定命令であると判定した場合には、特定部1023は、オブジェクト特定処理を行う(S3309)。
If it is determined in S3303 in FIG. 33 that there is an instruction, the
ここで、オブジェクト指定命令を判定する実行パターン処理の動作例を説明する。図34に、実行パターン処理の動作例を示す。シンボル実行用ドライバと対象メソッド中の命令の遷移を、矢印で示している。「if(P1_cnull)」の条件判断で、「true」と判断され、シンボルパス条件「P1_cnull==true」が生成される。また、「if(P2_cnull)」の条件判断で、「true」と判断され、シンボルパス条件「P2_cnull==true」が生成される。 Here, an example of execution pattern processing for determining an object designation command will be described. FIG. 34 shows an operation example of execution pattern processing. The transition of instructions in the symbol execution driver and the target method is indicated by arrows. In the condition determination of “if (P1_cull)”, “true” is determined, and the symbol path condition “P1_cull == true” is generated. Further, in the condition determination of “if (P2_cull)”, “true” is determined, and a symbol path condition “P2_cull == true” is generated.
「SymbolicExecUtil.calcPathCondition(P1, “P1”);」と「SymbolicExecUtil.calcPathCondition(P2, “P2”);」の行で、オブジェクト指定命令と判定され、オブジェクト特定処理が行われる。 In the lines of “SymbolicExecUil.calcPathCondition (P1,“ P1 ”);” and “SymbolicExecUil.calcPathCondition (P2,“ P2 ”);”, the object specifying command is determined, and the object specifying process is performed.
続けて、図33のオブジェクト特定処理(S3309)の説明をする。図35に、オブジェクト特定処理フローの例を示す。特定部1023は、オブジェクト指定命令の引数であるオブジェクト型変数名を特定する(S3501)。図34の例では、それぞれ「P1」と「P2」がオブジェクト型変数名である。特定部1023は、オブジェクト型変数名を実行部1017へ渡し、実行部1017からオブジェクト型変数のインスタンスを参照するための参照用IDを取得する(S3503)。このとき、実行部1017は、オブジェクト型変数名を受け、そのオブジェクト型変数のインスタンスを参照するための参照用IDを返すように動作する。特定部1023は、オブジェクト指定命令の引数であるパス条件用変数名を特定する(S3505)。図34の例では、それぞれ「“P1”」と「“P2”」がパス条件用変数名である。特定部1023は、オブジェクト型変数名と参照用IDとパス条件用変数名を対象テーブルのレコードに追加する(S3507)。特定部1023は処理を終え、図33のS3311へ戻る。
Subsequently, the object specifying process (S3309) of FIG. 33 will be described. FIG. 35 shows an example of an object specifying process flow. The identifying
図33の処理に戻って、実行部1017は、S3301で特定した命令を解析し(S3311)、その命令が分岐命令であるか否かを判定する。(S3313)。その命令が分岐命令でないと判定した場合には、S3317へ移る。その命令が分岐命令であると判定した場合には、実行部1017は、未だパスとして選択していない分岐を選択する(S3315)。そして、実行部1017は、選択した分岐についてのシンボルパス条件を計算する(S3317)。但し、S3313で分岐命令でないと判定し、シンボルパス条件の計算を行なわない場合もある。シンボルパス条件の計算については、従来のシンボリック実行の場合と同様であるので、説明を省略する。
Returning to the processing of FIG. 33, the
続いて、第1生成部1029は、オブジェクトパス条件生成処理を行う(S3319)。オブジェクトパス条件生成処理については、図38から図40を用いて後述する。
Subsequently, the
実行部1017は、パス条件の充足は可能であるか否かを判定する(S3321)。パス条件を充足できないと判定した場合には、実行不可能なパス(例えば、図2の203)を含むので、実行部1017は、処理結果を中断とする(S3323)。パス条件を充足できると判定した場合には、実行部1017は、命令を実行し(S3325)、S3301へ戻る。
The
図36に、図34の次の実行パターン処理の動作例を示す。図34で「return 0」に至り、図33のS3303とS3305で示したように次の命令が無いと判定すると、処理結果を完了として一旦実行パターン処理を終える。そして、未実行パスを選択する。具体的には、バックトラックにより未選択の分岐がある分岐点までもどり、未選択の分岐を次のパスの実行開始位置とする。図36の例では、次の実行開始位置「if(P2_cnull)」の判断結果「false」を選択する。このとき、実行開始位置「if(P2_cnull)」までに得られている既知のシンボルパス条件「P1_cnull==true」が特定され、新しいシンボルパス条件に設定される。そして、シンボルパス条件「P2_cnull==false」が生成される。
FIG. 36 shows an operation example of the next execution pattern process of FIG. When it reaches “
図31の処理に戻って、実行部1017は、S3103の実行パターン処理における処理結果が中断であるか、あるいは完了であるかを判定する(S3105)。処理結果が中断であると判定した場合には、実行部1017はテストケースを生成しない。処理結果が完了であると判定した場合には、実行部1017はテストケースを生成する(S3107)。具体的には、実行部1017は、シンボリックパス条件の充足値を求めて、その充足値をテスト入力に設定する。
Returning to the processing of FIG. 31, the
次に、実行部1017は、探索処理を行う(S3109)。探索処理では、次のパスを探索する。
Next, the
図37に、探索処理フローの例を示す。実行部1017は、未実行パスを選択する(S3701)。具体的には、実行部1017は、図36に示したように、バックトラックにより未選択の分岐がある分岐点までもどり、未選択の分岐を次のパスの実行開始位置とする。実行部1017は、未実行パスあったか否かを判定する(S3703)。バックトラックにより未選択の分岐が見つけられなかった場合には、実行部1017は未実行パスがないと判定して、処理結果をパスなしとする(S3705)。そして、実行部1017は処理を終え、図31のS3111へ戻る。
FIG. 37 shows an example of a search processing flow. The
バックトラックにより未選択の分岐が見つかった場合には、実行部1017は未実行パスがあると判定して、第1テストケースの新規レコードを割り当てる(S3707)。そして、実行部1017は、分岐点より上位の既知であるシンボリックパス条件を特定し、新たな第1テストケースのシンボリックパス条件に加える(S3709)。そして、実行部1017は、処理結果をパスありとして(S3711)、処理を終了する。そして、図31のS3111へ戻る。
If an unselected branch is found by backtracking, the
図31の処理に戻って、実行部1017は、探索処理(S3109)の処理結果がパスありであるか、あるいはパスなしであるかを判定する(S3111)。探索処理(S3109)の処理結果がパスありであると判定すると、実行部1017はS3103の処理に戻り、シンボリック実行処理を続行する。探索処理(S3109)の処理結果がパスなしであると判定すると、実行部1017はシンボリック実行処理を終える。
Returning to the processing of FIG. 31, the
次に、前述のオブジェクトパス条件生成処理(図33のS3319)について説明する。 Next, the above-described object path condition generation process (S3319 in FIG. 33) will be described.
ここで、図38にオブジェクトパス条件生成の動作例を示す。図38の例では、条件判断命令「if(obj1!=null)」から選択した分岐を示す式「obj1!=null」を得る。そして、オペランド「obj1」を参照先となるID「100」を特定する。この参照先ID「100」は、オブジェクトテーブルの参照用ID「100」と一致するので、このオペランドの変数はオブジェクトパス条件の計算対象であると判定される。そして、式「obj1!=null」に相当するプログラムパターン「OBJX!=null」をパターンテーブルで特定し、プログラムパターンに対応するパス条件パターン「OBJX!=null」に基づいて、オブジェクトパス条件「P1!=null」を生成している。その際、参照用ID「100」に対応するパス条件用変数名「P1」を用いている。尚、この例では、メモリ条件パターンは設定されていないので、メモリの状態については判定しない。 Here, FIG. 38 shows an operation example of object path condition generation. In the example of FIG. 38, an expression “obj1! = Null” indicating a branch selected from the condition determination instruction “if (obj1! = Null)” is obtained. Then, the ID “100” that is the reference destination of the operand “obj1” is specified. Since this reference destination ID “100” matches the reference ID “100” in the object table, it is determined that the variable of this operand is a calculation target of the object path condition. Then, the program pattern “OBJX! = Null” corresponding to the expression “obj1! = Null” is specified in the pattern table, and the object path condition “P1” is based on the path condition pattern “OBJX! = Null” corresponding to the program pattern. ! = Null "is generated. At this time, the path condition variable name “P1” corresponding to the reference ID “100” is used. In this example, since the memory condition pattern is not set, the state of the memory is not determined.
図39に、オブジェクトパス条件生成処理フローの例を示す。第1生成部1029は、命令から式を特定し(S3901)、第1生成部1029は、オペランドの変数を特定する(S3903)。条件判断命令の場合には、第1生成部1029は選択した分岐を示す式を特定する。
FIG. 39 shows an example of an object path condition generation process flow. The
そして、第1生成部1029は、変数の参照先IDを実行部1017から取得する(S3905)。このとき、第1生成部1029は変数名を実行部1017に渡す。これに対して、実行部1017はその変数名によるインスタンスを参照するためのIDを返すように動作する。第1生成部1029は、取得した参照先IDがオブジェクトテーブルのいずれかの参照用IDと一致するか否かを判定する(S3907)。取得した参照先IDがオブジェクトテーブルのいずれの参照用IDとも一致しないと判定した場合には、第1生成部1029は処理を終え、図33のS3321へ戻る。
The
図39のS3907で、取得した参照先IDがオブジェクトテーブルのいずれかの参照用IDと一致すると判定した場合には、第1生成部1029は、S3901で特定した式に対応するプログラムパターンを特定する(S3909)。S3901で特定した式が否定形式の場合には、肯定形式の式に置き換えてプログラムパターンと対比するようにしてもよい。第1生成部1029は、パターンテーブルにプログラムパターンに対応するメモリ条件パターンがあるか否かを判定する(S3911)。パターンテーブルにプログラムパターンに対応するメモリ条件パターンないと判定した場合には、第1生成部1029はS3917へ移る。
If it is determined in S3907 in FIG. 39 that the acquired reference destination ID matches any reference ID in the object table, the
パターンテーブルにプログラムパターンに対応するメモリ条件パターンあると判定した場合には、第1生成部1029は、メモリ条件パターンに関するメモリ情報を取得する(S3913)。例えば、第1生成部1029は「VX」に相当する変数名を実行部1017へ渡し、実行部1017はメモリに格納されている変数の値又はnullを返す。あるいは、別の例で第1生成部1029は「OBJX」に相当するオブジェクト型変数がnullであるか否かを問い合わせる要求を実行部1017へ渡し、実行部1017は「OBJX」に相当するオブジェクト型変数がnullであるか否かを示す回答を返す。
If it is determined that there is a memory condition pattern corresponding to the program pattern in the pattern table, the
そして、第1生成部1029は、メモリ情報がメモリ条件パターンに合致するか否かを判定する(S3915)。メモリ情報がメモリ条件パターンに合致しないと判定した場合には、第1生成部1029は処理を終了し、図33のS3321へ戻る。
Then, the
メモリ情報がメモリ条件パターンに合致すると判定した場合には、第1生成部1029は、オブジェクトパス条件を生成する(S3917)。具体的には、プログラムパターンに対応するパス条件パターンを特定し、パス条件パターンに基づいて、オブジェクトパス条件を生成する。その際、パス条件パターン中のオブジェクト変数(例えば「OBJX」)を、そのオブジェクト変数に相当するオブジェクト変数(「例えば、P1」)に対応するパス条件用変数名(例えば、「”P1”」)に変換する。尚、前述のように、特定した式が否定形式の場合であり、式を肯定形式に置き換えてプログラムパターンを特定した場合には、オブジェクトパス条件も肯定形式から否定形式に変換する。そして、第1生成部1029は、生成したオブジェクトパス条件をオブジェクトテーブル記憶部1025にケース番号に対応付けて記憶させる(S3919)。
If it is determined that the memory information matches the memory condition pattern, the
図40に、図38に続くオブジェクトパス条件生成の動作例を示す。図40の例では、条件判断命令「if(obj1 instanceof B)」で偽が選択されたと想定し、分岐を示す式「!(obj1 instanceof B)」を得る。そして、オペランド「obj1」の参照先となるID「100」を特定する。この参照先ID「100」は、オブジェクトテーブルの参照用ID「100」と一致するので、このオペランドの変数はオブジェクトパス条件の計算対象であると判定される。そして、式「obj1 instanceof B」に相当するプログラムパターン「OBJX instanceof TX」をパターンテーブルで特定し、プログラムパターンに対応するパス条件パターン「OBJX instanceof TX」に基づいて、オブジェクトパス条件「!(P1 instanceof B)」を生成する。その際、参照用ID「100」に対応するパス条件用変数名「P1」を用いている。また、「TX」は対応する「B」に置き換えている。この例では、式が否定形式であるので、オブジェクトパス条件も否定形式となっている。
FIG. 40 shows an operation example of object path condition generation following FIG. In the example of FIG. 40, assuming that false is selected by the condition determination instruction “if (obj1 instance of B)”, an expression “! (
前述の参照用IDは、オブジェクト変数のインスタンスを参照する情報である。図41に、メモリ状態の例を示す。スタックでは、変数毎に変数名と型と参照用IDを記憶している。ヒープでは、インスタンスを格納している。インスタンスは、参照用IDによって特定できるように構成されている。例えば、「obj1.a1」のメンバ変数の値を取得する場合には、スタックの情報に基づいて「obj1」の変数名に対応する参照用ID「100」を特定し、更に参照用ID「100」で特定されるインスタンスから、メンバ変数の値を取得する。通常の実行においては、メンバ変数には具体的な値が設定されているが、シンボリック実行においては、シンボル変数として宣言されているメンバ変数には、シンボル値が設定されている。図中、「symbol_P1_ma1」と「symbol_P2_ma1」は、シンボル値の例である。 The aforementioned reference ID is information for referring to an instance of an object variable. FIG. 41 shows an example of the memory state. In the stack, a variable name, a type, and a reference ID are stored for each variable. Instances are stored in the heap. The instance is configured to be identified by the reference ID. For example, when acquiring the value of the member variable “obj1.a1”, the reference ID “100” corresponding to the variable name “obj1” is specified based on the stack information, and the reference ID “100” is further specified. The value of the member variable is acquired from the instance specified by “”. In normal execution, a specific value is set for the member variable. In symbolic execution, a symbol value is set for the member variable declared as a symbol variable. In the figure, “symbol_P1_ma1” and “symbol_P2_ma1” are examples of symbol values.
複数の変数から同じインスタンスを参照する場合もある。図42に、複数の変数から同じインスタンスを参照する場合の例を示す。例えば、「(B)obj1.b1」のメンバ変数の値を取得する場合には、内部処理によってスタックに「obj1」と同じインスタンスを指すクラスB型の変数「tmp1」を用意する。そして、「tmp1」の変数名に対応する参照用ID「100」を特定し、更に参照用ID「100」で特定されるインスタンスから、メンバ変数の値を取得する。この場合も、シンボル変数として宣言されているメンバ変数にはシンボル値が設定されている。図中、「symbol_P1_mb1」は、シンボル値の例である。 The same instance may be referenced from multiple variables. FIG. 42 shows an example of referring to the same instance from a plurality of variables. For example, when acquiring the value of the member variable “(B) obj1.b1”, a class B type variable “tmp1” indicating the same instance as “obj1” is prepared in the stack by internal processing. Then, the reference ID “100” corresponding to the variable name “tmp1” is specified, and the value of the member variable is acquired from the instance specified by the reference ID “100”. In this case as well, symbol values are set for the member variables declared as symbol variables. In the figure, “symbol_P1_mb1” is an example of a symbol value.
上述のようにシンボリック実行処理により、第1テストケースセットとオブジェクトパス条件が生成される。図29a〜図29cに示した26の第1テストケースセットは、想定されるオブジェクト型変数の状態の組合せを網羅している。制御情報である「P1_cnull」、「P2_cnull」、「P1_cClass」、あるいは「P2_cClass」を含むシンボルパス条件により、想定されるオブジェクト型変数の状態を読み取ることができる。 As described above, the first test case set and the object path condition are generated by the symbolic execution process. The first test case set of 26 shown in FIGS. 29a to 29c covers possible combinations of states of object type variables. The state of an assumed object type variable can be read according to a symbol path condition including “P1_cull”, “P2_cull”, “P1_cClass”, or “P2_cClass” as control information.
但し、これらの制御情報を含むシンボルパス条件は、シンボル実行用ドライバの初期化コード(例えば、図8の815と817)での分岐により生成されたものであって、テスト対象のプログラムにおける分岐に基づくものではない。従って、これらの制御情報を含むパス条件は、テストケースを欠落させることなく抽出するためには役立つが、テスト対象のプログラムに対するコードカバレッジを判断するためには不適切なデータであると言える。 However, the symbol path condition including these control information is generated by branching in the initialization code of the symbol execution driver (for example, 815 and 817 in FIG. 8), and is used for branching in the program under test. Not based. Therefore, it can be said that the path condition including the control information is inappropriate data for determining the code coverage for the test target program, although it is useful for extracting the test cases without missing them.
一方、オブジェクトパス条件は、テスト対象のプログラムにおけるオブジェクト型変数の状態に関する分岐によるパス条件であり、テスト対象のプログラムに対するコードカバレッジを判断するのに適切なデータであると言える。 On the other hand, the object path condition is a path condition by branching regarding the state of the object type variable in the test target program, and can be said to be appropriate data for determining the code coverage for the test target program.
以下で説明するパス条件更新処理では、第1テストケースに含まれる制御変数を含むシンボルパス条件を除き、オブジェクトパス条件を加えた第2テストケースを生成する。第2テストケースは、テスト対象のプログラムに対するコードカバレッジの判断に適した対象内パス条件を備える。 In the path condition update process described below, a second test case with the object path condition added is generated except for the symbol path condition including the control variable included in the first test case. The second test case has an in-target path condition suitable for determining code coverage for the program to be tested.
また、パス条件更新処理に続くテストケース抽出処理では、第2テストケースセットから重複するテストケースを排除した第3テストケースセットを生成する。第3テストケースセットによるコードカバレッジは、第2テストケースセットによるコードカバレッジと等しい。 In the test case extraction process following the path condition update process, a third test case set is generated by excluding duplicate test cases from the second test case set. The code coverage by the third test case set is equal to the code coverage by the second test case set.
続いて、パス条件更新処理とテストケース抽出処理について説明する。図43は、テストケース生成装置のうちパス条件更新とテストケース抽出に係る構成例を示す図である。テストケース生成装置は、更に、第2生成部1033、第2テストケース格納部1035、抽出部1037、第3テストケース格納部1039及びテストケース出力部1041を有している。第2生成部1033は、パス条件を更新し、第2テストケースを生成するように動作する。第2テストケース格納部1035は、第2テストケースセットを記憶するように構成されている。抽出部1037は、第2テストケースセットから第3テストケースを抽出するように動作する。第3テストケース格納部1039は、第3テストケースの集合である第3テストケースセットを記憶するように構成されている。テストケース出力部1041は、第3テストケースセットを出力するように動作する。
Next, the path condition update process and the test case extraction process will be described. FIG. 43 is a diagram illustrating a configuration example related to path condition update and test case extraction in the test case generation apparatus. The test case generation apparatus further includes a
図44に、パス条件更新の概要を示す。第1テストケースのシンボルパス条件のうち、制御変数を含まないシンボルパス条件のみが第2テストケースの対象内パス条件にコピーされる。図44の例では、シンボルパス条件「(P2_ma1>P1_ma1)」が対象内パス条件にコピーされている。シンボルパス条件「P1_cnull==false」は、制御変数「P1_cnull」を含んでいるので、対象内パス条件にコピーされない。同様に、シンボルパス条件「P1_cClass==0」は、制御変数「P1_cClass」を含んでいるので、対象内パス条件にコピーされない。同様に、シンボルパス条件「P2_cnull==false」は、制御変数「P2_cnull」を含んでいるので、対象内パス条件にコピーされない。同様に、シンボルパス条件「P2_cClass==0」は、制御変数「P2_cClass」を含んでいるので、対象内パス条件にコピーされない。 FIG. 44 shows an outline of path condition update. Of the symbol path conditions of the first test case, only the symbol path condition not including the control variable is copied to the in-target path condition of the second test case. In the example of FIG. 44, the symbol path condition “(P2_ma1> P1_ma1)” is copied to the in-target path condition. Since the symbol path condition “P1_cull == false” includes the control variable “P1_cull”, it is not copied to the in-target path condition. Similarly, since the symbol path condition “P1_cClass == 0” includes the control variable “P1_cClass”, it is not copied to the in-target path condition. Similarly, since the symbol path condition “P2_cull == false” includes the control variable “P2_cull”, it is not copied to the in-target path condition. Similarly, since the symbol path condition “P2_cClass == 0” includes the control variable “P2_cClass”, it is not copied to the in-target path condition.
また、オブジェクトパス条件が第2テストケースの対象内パス条件にコピーされる。オブジェクトパス条件は、コピーの際に制御変数が満たすべき条件の形式に変換される。図44の例では、オブジェクトパス条件「P1!= null」は、対象内パス条件「P1_cnull==false」に変換されている。オブジェクトパス条件「!(P1 instanceof B)」は、対象内パス条件「P1_cClass!=1」に変換されている。オブジェクトパス条件「P2!=null」は、対象内パス条件「P2_cnull==false」に変換されている。オブジェクトパス条件「(P2.ma1>P1.ma1)」は、対象内パス条件「(P2_ma1>P1_ma1)」に変換されている。対象内パス条件「(P2_ma1>P1_ma1)」は、シンボルパス条件と重複しているので、1つの対象内パス条件のみ設定される。このように、オブジェクトパス条件とシンボルパス条件の一部が重複することも想定される。 Further, the object path condition is copied to the in-target path condition of the second test case. The object path condition is converted into a condition format to be satisfied by the control variable at the time of copying. In the example of FIG. 44, the object path condition “P1! = Null” is converted into the in-target path condition “P1_cull == false”. The object path condition “! (P1 instance of B)” is converted into the in-target path condition “P1_cClass! = 1”. The object path condition “P2! = Null” is converted into the in-target path condition “P2_cnull == false”. The object path condition “(P2.ma1> P1.ma1)” is converted into the in-target path condition “(P2_ma1> P1_ma1)”. Since the in-target path condition “(P2_ma1> P1_ma1)” overlaps with the symbol path condition, only one in-target path condition is set. In this way, it is assumed that part of the object path condition and the symbol path condition overlap.
制御変数が満たすべき条件の形式に変換することによって、テスト入力との関係を把握しやすくなる。 By converting to the format of the condition that the control variable should satisfy, it becomes easier to grasp the relationship with the test input.
更に、第1テストケースのテスト入力が第2テストケースのテスト入力にコピーされる。 Further, the test input of the first test case is copied to the test input of the second test case.
テスト入力「P1_cnull=false」と、テスト入力「P1_cClass=0」と、テスト入力「P1_ma1=0」と、テスト入力「P2_cnull=false」と、テスト入力「P2_cClass=0」と、テスト入力「P2_ma1=1」が、第1テストケースから第2テストケースへコピーされている。 Test input “P1_cull = false”, test input “P1_cClass = 0”, test input “P1_ma1 = 0”, test input “P2_cull = false”, test input “P2_cClass = 0”, test input “P2_ma1 = 1 "is copied from the first test case to the second test case.
図45に、第2テストケース生成処理フローの例を示す。第2生成部1033は、ケース番号毎に以下の処理を繰り返す(S4501)。第2生成部1033は、更にシンボルパス条件毎に以下の処理を繰り返す(S4503)。第2生成部1033は、シンボルパス条件が制御変数名を含むか否かを判定する(S4505)。シンボルパス条件が制御変数名を含ないと判定した場合には、第2生成部1033は、シンボルパス条件をコピーする(S4507)。一方、シンボルパス条件が制御変数名を含むと判定した場合には、第2生成部1033は、シンボルパス条件をコピーしない。第2生成部1033は、すべてのシンボルパス条件について処理したか否かを判定する(S4509)。処理していないシンボルパス条件があると判定した場合には、第2生成部1033はS4503へ処理を戻す。すべてのシンボルパス条件について処理したと判定した場合には、第2生成部1033はS4511へ処理を移す。
FIG. 45 shows an example of a second test case generation process flow. The
続いて、第2生成部1033は、オブジェクトパス条件毎に以下の処理を繰り返す(S4511)。第2生成部1033は、制御変数テーブルでオブジェクトパス条件と一致する意味式を特定する(S4513)。第2生成部1033は、意味式に対応する制御変数名と値を特定し、制御変数と値を用いた対象内パス条件を生成し、第2テストケースに加える(S4515)。例えば、図44の例でオブジェクト条件「P1!=null」と一致する意味式「P1!=null」に対応する制御変数名「P1_cnull」と値「false」を特定する。そして、対象内パス条件「P1_cnull==false」を生成する。
Subsequently, the
オブジェクトパス条件が否定形式である場合であり、オブジェクトパス条件を肯定形式に置き換えて意味式を特定するようにしてもよい。その場合には、制御変数と値を用いたパス条件を否定形式に置き換えることによって対象内パス条件を生成する。 This is a case where the object path condition has a negative form, and the semantic expression may be specified by replacing the object path condition with a positive form. In this case, the in-target path condition is generated by replacing the path condition using the control variable and the value with a negative form.
例えば、図44の例で否定形式のオブジェクトパス条件「!(P1 instanceof B)」を肯定形式「P1 instanceof B」に置き換えて、意味式「P1 instanceof B」を特定する。そして、意味式「P1 instanceof B」に対応する制御変数名「P1_cClass」と値「1」を特定し、パス条件「P1_cClass==1」を生成し、否定形式に置き換えて対象内パス条件「P1_cClass!=1」を生成する。 For example, the semantic expression “P1 instance of B” is identified by replacing the negative form object path condition “! (P1 instance of B)” with the positive form “P1 instance of B” in the example of FIG. Then, the control variable name “P1_cClass” and the value “1” corresponding to the semantic expression “P1 instanceof B” are specified, the path condition “P1_cClass == 1” is generated, and the in-target path condition “P1_cClass” is replaced with the negative form. ! = 1 ”is generated.
尚、制御変数ではないメンバ変数についても、メンバ変数の変換規則に従って対象内パス条件に変換するようにしてもよい。図44の例で、例えば変換規則で、「P2.ma1」が「P2_ma1」に相当し、「P1.ma1」が「P1_ma1」に相当すると規定されている場合には、オブジェクト条件「P2.ma1>P1.ma1」は、対象内パス条件「P2_ma1>P1_ma1」に変換される。 Note that member variables that are not control variables may be converted into the in-target path condition according to the conversion rules for member variables. In the example of FIG. 44, for example, in the conversion rule, it is defined that “P2.ma1” corresponds to “P2_ma1” and “P1.ma1” corresponds to “P1_ma1”, the object condition “P2.ma1”. > P1.ma1 ”is converted into the in-target path condition“ P2_ma1> P1_ma1 ”.
図44に示したように、シンボル変数「P1_ma1」とシンボル変数「P2_ma1」に関するシンボルパス条件「P2_ma1>P1_ma1」も同じ内容である。このように同じ内容である場合には、対象内パス条件には1つだけ設定される。第2生成部1033は、すべてのオブジェクトパス条件について処理したか否かを判定する(S4517)。処理していないオブジェクトパス条件があると判定した場合には、S4511へ戻る。
As shown in FIG. 44, the symbol path condition “P2_ma1> P1_ma1” regarding the symbol variable “P1_ma1” and the symbol variable “P2_ma1” has the same content. When the contents are the same, only one target path condition is set. The
一方、すべてのオブジェクトパス条件について処理したと判定した場合には、第2生成部1033は、第1テストケースのテスト入力を第2テストケースにコピーする(S4519)。第2生成部1033は、すべてのケース番号について処理したか否かを判定する(S4521)。処理していないケース番号があると判定した場合には、第2生成部1033はS4501へ処理を戻す。すべてのケース番号について処理した場合には、第2生成部1033は処理を終了する。
On the other hand, if it is determined that all object path conditions have been processed, the
図46a乃至46cに、第2テストケースの例を示す。第1テストケースに対応する第2テストケースが生成される。例えば、ケース番号1〜ケース番号4の第2テストケースは、同じ対象内パス条件「P1_cnull==true」を有する。ケース番号1〜ケース番号4は、テスト対象のプログラムの同じルートを通ることを示している。ケース番号1のテストケースで、テスト入力「P1_cnull=true」とテスト入力「P2_cnull=true」を入力して図5に示した対象クラスを実行した場合、「if(obj1!=null)」で偽と判定され、「return 0」で終了するルートを通る。更に、ケース番号2のテストケースで、テスト入力「P1_cnull=true」とテスト入力「P2_cnull=false」とテスト入力「P2_cClass=0」を入力して図5に示した対象クラスを実行した場合にも、同様に「if(obj1!=null)」で偽と判定され、「return 0」で終了するルートを通る。更に、ケース番号3のテストケースで、テスト入力「P1_cnull=true」とテスト入力「P2_cnull=false」とテスト入力「P2_cClass=1」を入力して図5に示した対象クラスを実行した場合にも、同様に「if(obj1!=null)」で偽と判定され、「return 0」で終了するルートを通る。更に、ケース番号4のテストケースで、テスト入力「P1_cnull=true」とテスト入力「P2_cnull=false」とテスト入力「P2_cClass=−1」を入力して図5に示した対象クラスを実行した場合にも、同様に「if(obj1!=null)」で偽と判定され、「return 0」で終了するルートを通る。このようにテスト対象のプログラムの同じルートを通る複数のテストケースは冗長であるので、削減することが望ましい。
An example of the second test case is shown in FIGS. 46a to 46c. A second test case corresponding to the first test case is generated. For example, the second test cases of
図47に、第3テストケースの例を示す。この例では、同じルートを通る複数の第2テストケースのうち、最も小さいケース番号のテストケースを第3テストケースに移し、それ以外は排除している。例えば、ケース番号1〜ケース番号4の第2テストケースのうち、ケース番号1の第2テストケースは第3テストケースセットに移されるが、ケース番号2〜ケース番号4の第2テストケースは第3テストケースセットに移されない。
FIG. 47 shows an example of the third test case. In this example, the test case with the smallest case number among the plurality of second test cases passing through the same route is moved to the third test case, and the other cases are excluded. For example, among the second test cases of
図48は、テストケース抽出処理フローの例を示す図である。抽出部1037は、第2テストケース毎に以下の処理を繰り返す(S4801)。抽出部1037は、第2テストケースのパス条件と同じパス条件を有する第3テストケースがあるか否かを判定する(S4803)。つまり、抽出部1037は、第2テストケースのパス条件と同じパス条件を有する第3テストケースが第3テストケース記憶部1039に格納されているか否かを判定する。第2テストケースのパス条件と同じパス条件を有する第3テストケースがあると判定した場合には、抽出部1037はS4807へ処理を進める。
FIG. 48 is a diagram illustrating an example of a test case extraction process flow. The
第2テストケースのパス条件と同じパス条件を有する第3テストケースがないと判定した場合には、抽出部1037は、第2テストケースを第3テストケースに加える(S4805)。つまり、抽出部1037は、第2テストケースを第3テストケース格納部1039に格納する。抽出部1037は、すべての第2テストケースについて処理したか否かを判定する(S4807)。処理していない第2テストケースがあると判定した場合には、S4801に戻る。すべての第2テストケースについて処理したと判定した場合には、抽出部1037は、第3テストケースセットを出力して(S4809)、終了する。
If it is determined that there is no third test case having the same pass condition as the pass condition of the second test case, the
上述のパス条件更新処理とテストケース抽出処理は、連続して行ってもよく、又は別に行ってもよい。パス条件更新処理とテストケース抽出処理を行うことによって、制御変数を用いたシンボリック実行により高めたコードカバレッジを低下させることなく、テストケースを削減することができる。 The path condition update process and the test case extraction process described above may be performed continuously or separately. By performing the path condition update process and the test case extraction process, it is possible to reduce the number of test cases without reducing the code coverage that has been enhanced by the symbolic execution using the control variable.
以上本技術の一実施の形態を説明したが、本技術はこれに限定されるものではない。例えば、上述の機能ブロック構成は必ずしも実際のプログラムモジュール構成に対応するものではない。 Although one embodiment of the present technology has been described above, the present technology is not limited to this. For example, the functional block configuration described above does not necessarily correspond to the actual program module configuration.
また、上で説明した各記憶領域の構成は一例であって、必ずしも上記のような構成でなければならないわけではない。さらに、処理フローにおいても、処理結果が変わらなければ処理の順番を入れ替えることも可能である。さらに、並列に実行させるようにしても良い。 The configuration of each storage area described above is an example, and the configuration as described above is not necessarily required. Further, in the processing flow, the processing order can be changed if the processing result does not change. Further, it may be executed in parallel.
なお、上で述べたテストケース生成装置は、コンピュータ装置であって、図49に示すように、メモリ2501とCPU(Central Processing Unit)2503とハードディスク・ドライブ(HDD:Hard Disk Drive)2505と表示装置2509に接続される表示制御部2507とリムーバブル・ディスク2511用のドライブ装置2513と入力装置2515とネットワークに接続するための通信制御部2517とがバス2519で接続されている。オペレーティング・システム(OS:Operating System)及び本実施例における処理を実施するためのアプリケーション・プログラムは、HDD2505に格納されており、CPU2503により実行される際にはHDD2505からメモリ2501に読み出される。CPU2503は、アプリケーション・プログラムの処理内容に応じて表示制御部2507、通信制御部2517、ドライブ装置2513を制御して、所定の動作を行わせる。また、処理途中のデータについては、主としてメモリ2501に格納されるが、HDD2505に格納されるようにしてもよい。本技術の実施例では、上で述べた処理を実施するためのアプリケーション・プログラムはコンピュータ読み取り可能なリムーバブル・ディスク2511に格納されて頒布され、ドライブ装置2513からHDD2505にインストールされる。インターネットなどのネットワーク及び通信制御部2517を経由して、HDD2505にインストールされる場合もある。このようなコンピュータ装置は、上で述べたCPU2503、メモリ2501などのハードウエアとOS及びアプリケーション・プログラムなどのプログラムとが有機的に協働することにより、上で述べたような各種機能を実現する。
The test case generation device described above is a computer device, and as shown in FIG. 49, a
以上述べた実施の形態をまとめると、以下のようになる。 The embodiment described above is summarized as follows.
第1の実施の形態に係るプログラムは、(A)テスト対象のプログラムへ入力されるオブジェクト型変数の状態を示す制御変数を含む一又は複数のシンボル変数を用いて、制御変数に応じたオブジェクト型変数の初期化とテスト対象のプログラムの呼び出しを行うためのドライバ及び呼び出されるテスト対象のプログラムにおける実行パターン毎に、ドライバ及びテスト対象のプログラムの実行において一又は複数のシンボル変数が満たすべき第1のパス条件を計算し、第1のパス条件と第1のパス条件に対する一又は複数のシンボル変数の充足値とを含む第1のテストケースを生成するシンボリック実行処理と、(B)実行パターン毎に、テスト対象のプログラムの実行において状態としてオブジェクト型変数が満たすべき第2のパス条件を生成する第1の生成処理と、(C)実行パターン毎に、第1のテストケースに含まれる第1のパス条件から、制御変数が満たすべき条件を省き、第2のパス条件を加えた第3のパス条件を求め、第3のパス条件と一又は複数のシンボル変数の充足値とを含む第2のテストケースを生成する第2の生成処理と、(D)第3のパス条件が同義である第2のテストケースが複数ある場合に、第3のパス条件が同義である複数の第2のテストケースのうち、いずれかの第2のテストケースを省き、残った第2のテストケースを抽出する抽出処理とをコンピュータに実行させる。 The program according to the first embodiment uses (A) one or a plurality of symbol variables including a control variable indicating a state of an object type variable input to a test target program, and an object type corresponding to the control variable. For each execution pattern in the driver for initiating the variable and invoking the test target program and in the called test target program, the first variable to be satisfied by one or more symbol variables in the execution of the driver and the test target program A symbolic execution process for calculating a path condition and generating a first test case including a first path condition and a satisfaction value of one or more symbol variables for the first path condition; and (B) for each execution pattern The second path condition to be satisfied by the object type variable as a state in the execution of the test target program The first generation process to be generated, and (C) the first pass condition included in the first test case for each execution pattern, the condition to be satisfied by the control variable is omitted, and the second pass condition is added. And (D) the third path condition is synonymous with the second generation process of generating a second test case including the third path condition and a sufficiency value of one or more symbol variables. When there are a plurality of second test cases, any one of the plurality of second test cases having the same third pass condition is omitted, and the remaining second test case The computer executes an extraction process for extracting.
上で述べたようなシンボリック実行処理を実行するので、オブジェクト型変数の状態に関する分岐処理を含むテスト対象のプログラムにおけるテストケースのカバレッジを向上させることができる。 Since the symbolic execution process as described above is executed, it is possible to improve the coverage of the test case in the test target program including the branch process related to the state of the object type variable.
更に、上で述べたようにテストケースを絞り込んでいるので、カバレッジの向上に寄与しないテストケースを排除することができる。つまり、制御変数が満たすべき条件が異なるテストケース同士でも、もしそれらの第2のパス条件が共通であるならば、テスト対象プログラムにおける実行ルートは同じになる。従って、いずれかのテストケースを省くことにより無駄を減らすことができる。 Furthermore, since test cases are narrowed down as described above, test cases that do not contribute to improvement in coverage can be eliminated. In other words, even among test cases having different conditions to be satisfied by the control variable, if the second path condition is common, the execution route in the test target program is the same. Therefore, waste can be reduced by omitting one of the test cases.
また、上記シンボリック実行処理において、テスト対象のプログラムに含まれる複数の命令のうち、実行すべき命令を特定するようにしてもよい。この場合、上記第1の生成処理において、実行すべき命令に含まれる変数の実体を参照するための位置を特定し、オブジェクト型変数の実体が格納されている位置と参照するための位置が一致する場合に、実行すべき命令に基づいて第2のパス条件を生成するようにしてもよい。 In the symbolic execution process, an instruction to be executed may be specified from among a plurality of instructions included in the test target program. In this case, in the first generation process, the position for referring to the entity of the variable included in the instruction to be executed is specified, and the position for storing the object type variable coincides with the position for reference. In this case, the second path condition may be generated based on the instruction to be executed.
このようにすれば、実行すべき命令に含まれる変数の実体を参照するための位置が、オブジェクト型変数の実体が格納されている位置と一致する場合に、実行すべき命令に基づいて第2のパス条件を生成するので、シンボル変数ではないオブジェクト型変数についてもパス条件を求めることができる。 In this way, when the position for referring to the entity of the variable included in the instruction to be executed matches the position where the entity of the object type variable is stored, the second is determined based on the instruction to be executed. Therefore, it is possible to obtain a path condition for an object type variable that is not a symbol variable.
また、上記シンボリック実行処理において、ドライバに含まれ、且つオブジェクト型変数を含む第1の命令を特定し、更に、第1の命令に基づいてオブジェクト型変数を特定し、特定されたオブジェクト型変数の実体が格納されている位置を特定する特定処理をコンピュータに実行させるようにしてもよい。 In the symbolic execution process, the first instruction included in the driver and including the object type variable is specified, the object type variable is specified based on the first instruction, and the specified object type variable You may make it make a computer perform the specific process which specifies the position where an entity is stored.
このようにすれば、ドライバに含まれる第1の命令に基づいてオブジェクト型変数を特定し、オブジェクト型変数の実体が格納されている位置を特定するので、ドライバから第2のパス条件の生成を指示できるようになる。従って、テスト対象のプログラムに手を加えることを要しない。 In this way, the object type variable is specified based on the first instruction included in the driver, and the position where the entity of the object type variable is stored is specified. Therefore, the driver generates the second path condition. You will be able to give instructions. Therefore, it is not necessary to modify the program to be tested.
また、上記第2の生成処理において、第2のパス条件を制御変数が満たすべき条件の形式に変換するようにしてもよい。 In the second generation process, the second path condition may be converted into a format of a condition that the control variable should satisfy.
このようにすれば、第2のパス条件を制御変数が満たすべき条件の形式に変換するので、オブジェクト型変数の状態に関する分岐におけるパス条件とシンボル変数の充足値を、ともに制御変数で表すことになり、これらの関係が把握されやすくなる。 In this way, since the second path condition is converted into the format of the condition that the control variable should satisfy, the path condition and the satisfaction value of the symbol variable in the branch related to the state of the object type variable are both represented by the control variable. Therefore, it becomes easy to grasp these relationships.
上記状態は、オブジェクト型変数がnullであるか否かにより特定されるものであってもよい。 The state may be specified by whether or not the object type variable is null.
このようにすれば、オブジェクト型変数がnullであるか否かによる分岐を含むプログラムのテストケースを生成することができる。 In this way, it is possible to generate a test case of a program including a branch depending on whether or not the object type variable is null.
上記状態は、オブジェクト型変数のクラス型により特定されるものであってもよい。 The state may be specified by the class type of the object type variable.
このようにすれば、オブジェクト型変数のクラス型による分岐を含むプログラムのテストケースを生成することができる。 In this way, it is possible to generate a test case of a program including a branch by the class type of the object type variable.
上記複数のシンボル変数は、オブジェクト型変数のメンバを示すシンボル変数を含んでもよい。 The plurality of symbol variables may include a symbol variable indicating a member of an object type variable.
このようにすれば、オブジェクト型変数のメンバによる分岐を含むプログラムのテストケースを生成することができる。 In this way, it is possible to generate a test case for a program including a branch by a member of an object type variable.
上記複数のシンボル変数は、テスト対象のプログラムへ入力されるプリミティブ型変数を示すシンボル変数を含んでもよい。 The plurality of symbol variables may include a symbol variable indicating a primitive type variable input to a test target program.
このようにすれば、プリミティブ型変数による分岐を含むプログラムのテストケースを生成することができる。 In this way, it is possible to generate a test case for a program including a branch by a primitive type variable.
上記抽出処理は、第3のパス条件が同義である複数の第2のテストケースのうち、一つの第2のテストケース以外を省くようにしてもよい。 In the extraction process, a plurality of second test cases having the same third pass condition may be omitted except for one second test case.
このようにすれば、テストケースを少なくすることができる。 In this way, the number of test cases can be reduced.
なお、上記方法による処理をコンピュータに行わせるためのプログラムを作成することができ、当該プログラムは、例えばフレキシブルディスク、CD−ROM、光磁気ディスク、半導体メモリ、ハードディスク等のコンピュータ読み取り可能な記憶媒体又は記憶装置に格納される。尚、中間的な処理結果はメインメモリ等の記憶装置に一時保管される A program for causing a computer to perform the processing according to the above method can be created. The program can be a computer-readable storage medium such as a flexible disk, a CD-ROM, a magneto-optical disk, a semiconductor memory, a hard disk, or the like. It is stored in a storage device. Note that intermediate processing results are temporarily stored in a storage device such as a main memory.
以上の実施例を含む実施形態に関し、さらに以下の付記を開示する。 The following supplementary notes are further disclosed with respect to the embodiments including the above examples.
(付記1)
テスト対象のプログラムへ入力されるオブジェクト型変数の状態を示す制御変数を含む一又は複数のシンボル変数を用いて、前記制御変数に応じた前記オブジェクト型変数の初期化と前記テスト対象のプログラムの呼び出しを行うためのドライバ及び呼び出される前記テスト対象のプログラムにおける実行パターン毎に、前記ドライバ及び前記テスト対象のプログラムの実行において前記一又は複数のシンボル変数が満たすべき第1のパス条件を計算し、前記第1のパス条件と前記第1のパス条件に対する前記一又は複数のシンボル変数の充足値とを含む第1のテストケースを生成するシンボリック実行処理と、
前記実行パターン毎に、前記テスト対象のプログラムの実行において前記状態として前記オブジェクト型変数が満たすべき第2のパス条件を生成する第1の生成処理と、
前記実行パターン毎に、前記第1のテストケースに含まれる前記第1のパス条件から、前記制御変数が満たすべき条件を省き、前記第2のパス条件を加えた第3のパス条件を求め、前記第3のパス条件と前記一又は複数のシンボル変数の前記充足値とを含む第2のテストケースを生成する第2の生成処理と、
前記第3のパス条件が同義である前記第2のテストケースが複数ある場合に、前記第3のパス条件が同義である複数の前記第2のテストケースのうち、いずれかの前記第2のテストケースを省き、残った前記第2のテストケースを抽出する抽出処理と、
をコンピュータに実行させるためのプログラム。
(Appendix 1)
Using one or a plurality of symbol variables including a control variable indicating the state of the object type variable input to the test target program, initialization of the object type variable according to the control variable and calling of the test target program For each execution pattern in the driver and the test target program to be called, calculate a first path condition that the one or more symbol variables should satisfy in the execution of the driver and the test target program, and A symbolic execution process for generating a first test case including a first pass condition and a sufficiency value of the one or more symbol variables with respect to the first pass condition;
For each execution pattern, a first generation process for generating a second path condition that the object type variable should satisfy as the state in the execution of the test target program;
For each execution pattern, from the first path condition included in the first test case, a condition that the control variable should satisfy is omitted, and a third path condition is obtained by adding the second path condition; A second generation process for generating a second test case including the third pass condition and the sufficiency value of the one or more symbol variables;
When there are a plurality of the second test cases in which the third pass condition is synonymous, any one of the second test cases in which the third pass condition is synonymous. An extraction process for omitting the test case and extracting the remaining second test case;
A program that causes a computer to execute.
(付記2)
前記シンボリック実行処理において、前記テスト対象のプログラムに含まれる複数の命令のうち、実行すべき命令を特定し、
前記第1の生成処理において、前記実行すべき命令に含まれる変数の実体を参照するための位置を特定し、前記オブジェクト型変数の実体が格納されている位置と前記参照するための位置が一致する場合に、前記実行すべき命令に基づいて前記第2のパス条件を生成する
付記1記載のプログラム。
(Appendix 2)
In the symbolic execution process, an instruction to be executed is specified from among a plurality of instructions included in the test target program,
In the first generation process, the position for referring to the entity of the variable included in the instruction to be executed is specified, and the position where the entity of the object type variable is stored matches the position for referring The program according to
(付記3)
前記シンボリック実行処理において、前記ドライバに含まれ、且つ前記オブジェクト型変数を含む第1の命令を特定し、
更に、前記第1の命令に基づいて前記オブジェクト型変数を特定し、特定された前記オブジェクト型変数の前記実体が格納されている前記位置を特定する特定処理をコンピュータに実行させる
付記2記載のプログラム。
(Appendix 3)
In the symbolic execution process, a first instruction included in the driver and including the object type variable is specified,
The program according to
(付記4)
前記第2の生成処理において、前記第2のパス条件を前記制御変数が満たすべき条件の形式に変換する
付記1乃至3のいずれか1つ記載のプログラム。
(Appendix 4)
The program according to any one of
(付記5)
前記状態は、前記オブジェクト型変数がnullであるか否かにより特定される
付記1乃至4のいずれか1つ記載のプログラム。
(Appendix 5)
The program according to any one of
(付記6)
前記状態は、前記オブジェクト型変数のクラス型により特定される
付記1乃至4のいずれか1つ記載のプログラム。
(Appendix 6)
The program according to any one of
(付記7)
前記複数のシンボル変数は、前記オブジェクト型変数のメンバを示すシンボル変数を含む
付記1乃至6のいずれか1つ記載のプログラム。
(Appendix 7)
The program according to any one of
(付記8)
前記複数のシンボル変数は、前記テスト対象のプログラムへ入力されるプリミティブ型変数を示すシンボル変数を含む
付記1乃至7のいずれか1つ記載のプログラム。
(Appendix 8)
The program according to any one of
(付記9)
前記抽出処理は、前記第3のパス条件が同義である前記複数の第2のテストケースのうち、一つの前記第2のテストケース以外を省く
付記1乃至8のいずれか1つ記載のプログラム。
(Appendix 9)
The program according to any one of
(付記10)
テスト対象のプログラムへ入力されるオブジェクト型変数の状態を示す制御変数を含む一又は複数のシンボル変数を用いて、前記制御変数に応じた前記オブジェクト型変数の初期化と前記テスト対象のプログラムの呼び出しを行うためのドライバ及び呼び出される前記テスト対象のプログラムにおける実行パターン毎に、前記ドライバ及び前記テスト対象のプログラムの実行において前記一又は複数のシンボル変数が満たすべき第1のパス条件を計算し、前記第1のパス条件と前記第1のパス条件に対する前記一又は複数のシンボル変数の充足値とを含む第1のテストケースを生成するシンボリック実行処理と、
前記実行パターン毎に、前記テスト対象のプログラムの実行において前記状態として前記オブジェクト型変数が満たすべき第2のパス条件を生成する第1の生成処理と、
前記実行パターン毎に、前記第1のテストケースに含まれる前記第1のパス条件から、前記制御変数が満たすべき条件を省き、前記第2のパス条件を加えた第3のパス条件を求め、前記第3のパス条件と前記一又は複数のシンボル変数の前記充足値とを含む第2のテストケースを生成する第2の生成処理と、
前記第3のパス条件が同義である前記第2のテストケースが複数ある場合に、前記第3のパス条件が同義である複数の前記第2のテストケースのうち、いずれかの前記第2のテストケースを省き、残った前記第2のテストケースを抽出する抽出処理と、
を含みコンピュータが実行するテストケース生成方法。
(Appendix 10)
Using one or a plurality of symbol variables including a control variable indicating the state of the object type variable input to the test target program, initialization of the object type variable according to the control variable and calling of the test target program For each execution pattern in the driver and the test target program to be called, calculate a first path condition that the one or more symbol variables should satisfy in the execution of the driver and the test target program, and A symbolic execution process for generating a first test case including a first pass condition and a sufficiency value of the one or more symbol variables with respect to the first pass condition;
For each execution pattern, a first generation process for generating a second path condition that the object type variable should satisfy as the state in the execution of the test target program;
For each execution pattern, from the first path condition included in the first test case, a condition that the control variable should satisfy is omitted, and a third path condition is obtained by adding the second path condition; A second generation process for generating a second test case including the third pass condition and the sufficiency value of the one or more symbol variables;
When there are a plurality of the second test cases in which the third pass condition is synonymous, any one of the second test cases in which the third pass condition is synonymous. An extraction process for omitting the test case and extracting the remaining second test case;
A test case generation method executed by a computer.
(付記11)
テスト対象のプログラムへ入力されるオブジェクト型変数の状態を示す制御変数を含む一又は複数のシンボル変数を用いて、前記制御変数に応じた前記オブジェクト型変数の初期化と前記テスト対象のプログラムの呼び出しを行うためのドライバ及び呼び出される前記テスト対象のプログラムにおける実行パターン毎に、前記ドライバ及び前記テスト対象のプログラムの実行において前記一又は複数のシンボル変数が満たすべき第1のパス条件を計算し、前記第1のパス条件と前記第1のパス条件に対する前記一又は複数のシンボル変数の充足値とを含む第1のテストケースを生成するシンボリック実行を行う実行部と、
前記実行パターン毎に、前記テスト対象のプログラムの実行において前記状態として前記オブジェクト型変数が満たすべき第2のパス条件を生成する第1の生成部と、
前記実行パターン毎に、前記第1のテストケースに含まれる前記第1のパス条件から、前記制御変数が満たすべき条件を省き、前記第2のパス条件を加えた第3のパス条件を求め、前記第3のパス条件と前記一又は複数のシンボル変数の前記充足値とを含む第2のテストケースを生成する第2の生成部と、
前記第3のパス条件が同義である前記第2のテストケースが複数ある場合に、前記第3のパス条件が同義である複数の前記第2のテストケースのうち、いずれかの前記第2のテストケースを省き、残った前記第2のテストケースを抽出する抽出部と、
を有するテストケース生成装置。
(Appendix 11)
Using one or a plurality of symbol variables including a control variable indicating the state of the object type variable input to the test target program, initialization of the object type variable according to the control variable and calling of the test target program For each execution pattern in the driver and the test target program to be called, calculate a first path condition that the one or more symbol variables should satisfy in the execution of the driver and the test target program, and An execution unit that performs symbolic execution to generate a first test case including a first pass condition and a satisfaction value of the one or more symbol variables with respect to the first pass condition;
A first generation unit that generates, for each execution pattern, a second path condition that the object type variable should satisfy as the state in the execution of the test target program;
For each execution pattern, from the first path condition included in the first test case, a condition that the control variable should satisfy is omitted, and a third path condition is obtained by adding the second path condition; A second generation unit that generates a second test case including the third pass condition and the sufficiency value of the one or more symbol variables;
When there are a plurality of the second test cases in which the third pass condition is synonymous, any one of the second test cases in which the third pass condition is synonymous. An extraction unit for omitting the test case and extracting the remaining second test case;
A test case generation device having:
701 シンボル変数宣言エリア 703 対象クラス初期化エリア
705 初期化コードエリア 707 オブジェクト指定命令エリア
709 対象メソッドの呼び出しエリア 1001 受付部
1003 対象クラス格納部 1005 ライブラリ格納部
1007 サンプルフォーム格納部 1009 ドライバ生成部
1011 ドライバ格納部 1013 制御変数テーブル生成部
1015 制御変数テーブル格納部 1017 実行部
1019 パターンテーブル格納部 1021 シンボル変数テーブル記憶部
1023 特定部 1025 オブジェクトテーブル記憶部
1027 第1テストケース格納部 1029 第1生成部
1031 オブジェクトパス条件記憶部 1033 第2生成部
1035 第2テストケース格納部 1037 抽出部
1039 第3テストケース格納部 1041 テストケース出力部
701 Symbol
Claims (6)
前記実行パターン毎に、前記テスト対象のプログラムの実行において前記状態として前記オブジェクト型変数が満たすべき第2のパス条件を生成する第1の生成処理と、
前記実行パターン毎に、前記第1のテストケースに含まれる前記第1のパス条件から、前記制御変数が満たすべき条件を省き、前記第2のパス条件を加えた第3のパス条件を求め、前記第3のパス条件と前記一又は複数のシンボル変数の前記充足値とを含む第2のテストケースを生成する第2の生成処理と、
前記第3のパス条件が同義である前記第2のテストケースが複数ある場合に、前記第3のパス条件が同義である複数の前記第2のテストケースのうち、いずれかの前記第2のテストケースを省き、残った前記第2のテストケースを抽出する抽出処理と、
をコンピュータに実行させるためのプログラム。 Using one or a plurality of symbol variables including a control variable indicating the state of the object type variable input to the test target program, initialization of the object type variable according to the control variable and calling of the test target program For each execution pattern in the driver and the test target program to be called, calculate a first path condition that the one or more symbol variables should satisfy in the execution of the driver and the test target program, and A symbolic execution process for generating a first test case including a first pass condition and a sufficiency value of the one or more symbol variables with respect to the first pass condition;
For each execution pattern, a first generation process for generating a second path condition that the object type variable should satisfy as the state in the execution of the test target program;
For each execution pattern, from the first path condition included in the first test case, a condition that the control variable should satisfy is omitted, and a third path condition is obtained by adding the second path condition; A second generation process for generating a second test case including the third pass condition and the sufficiency value of the one or more symbol variables;
When there are a plurality of the second test cases in which the third pass condition is synonymous, any one of the second test cases in which the third pass condition is synonymous. An extraction process for omitting the test case and extracting the remaining second test case;
A program that causes a computer to execute.
前記第1の生成処理において、前記実行すべき命令に含まれる変数の実体を参照するための位置を特定し、前記オブジェクト型変数の実体が格納されている位置と前記参照するための位置が一致する場合に、前記実行すべき命令に基づいて前記第2のパス条件を生成する
請求項1記載のプログラム。 In the symbolic execution process, an instruction to be executed is specified from among a plurality of instructions included in the test target program,
In the first generation process, the position for referring to the entity of the variable included in the instruction to be executed is specified, and the position where the entity of the object type variable is stored matches the position for referring The program according to claim 1, wherein the second path condition is generated based on the instruction to be executed.
更に、前記第1の命令に基づいて前記オブジェクト型変数を特定し、特定された前記オブジェクト型変数の前記実体が格納されている前記位置を特定する特定処理をコンピュータに実行させる
請求項2記載のプログラム。 In the symbolic execution process, a first instruction included in the driver and including the object type variable is specified,
3. The computer according to claim 2, further comprising: specifying the object type variable based on the first instruction, and causing the computer to execute a specifying process for specifying the position where the entity of the specified object type variable is stored. program.
請求項1乃至3のいずれか1つ記載のプログラム。 The program according to any one of claims 1 to 3, wherein, in the second generation process, the second path condition is converted into a format of a condition to be satisfied by the control variable.
前記実行パターン毎に、前記テスト対象のプログラムの実行において前記状態として前記オブジェクト型変数が満たすべき第2のパス条件を生成する第1の生成処理と、
前記実行パターン毎に、前記第1のテストケースに含まれる前記第1のパス条件から、前記制御変数が満たすべき条件を省き、前記第2のパス条件を加えた第3のパス条件を求め、前記第3のパス条件と前記一又は複数のシンボル変数の前記充足値とを含む第2のテストケースを生成する第2の生成処理と、
前記第3のパス条件が同義である前記第2のテストケースが複数ある場合に、前記第3のパス条件が同義である複数の前記第2のテストケースのうち、いずれかの前記第2のテストケースを省き、残った前記第2のテストケースを抽出する抽出処理と、
を含みコンピュータが実行するテストケース生成方法。 Using one or a plurality of symbol variables including a control variable indicating the state of the object type variable input to the test target program, initialization of the object type variable according to the control variable and calling of the test target program For each execution pattern in the driver and the test target program to be called, calculate a first path condition that the one or more symbol variables should satisfy in the execution of the driver and the test target program, and A symbolic execution process for generating a first test case including a first pass condition and a sufficiency value of the one or more symbol variables with respect to the first pass condition;
For each execution pattern, a first generation process for generating a second path condition that the object type variable should satisfy as the state in the execution of the test target program;
For each execution pattern, from the first path condition included in the first test case, a condition that the control variable should satisfy is omitted, and a third path condition is obtained by adding the second path condition; A second generation process for generating a second test case including the third pass condition and the sufficiency value of the one or more symbol variables;
When there are a plurality of the second test cases in which the third pass condition is synonymous, any one of the second test cases in which the third pass condition is synonymous. An extraction process for omitting the test case and extracting the remaining second test case;
A test case generation method executed by a computer.
前記実行パターン毎に、前記テスト対象のプログラムの実行において前記状態として前記オブジェクト型変数が満たすべき第2のパス条件を生成する第1の生成部と、
前記実行パターン毎に、前記第1のテストケースに含まれる前記第1のパス条件から、前記制御変数が満たすべき条件を省き、前記第2のパス条件を加えた第3のパス条件を求め、前記第3のパス条件と前記一又は複数のシンボル変数の前記充足値とを含む第2のテストケースを生成する第2の生成部と、
前記第3のパス条件が同義である前記第2のテストケースが複数ある場合に、前記第3のパス条件が同義である複数の前記第2のテストケースのうち、いずれかの前記第2のテストケースを省き、残った前記第2のテストケースを抽出する抽出部と、
を有するテストケース生成装置。 Using one or a plurality of symbol variables including a control variable indicating the state of the object type variable input to the test target program, initialization of the object type variable according to the control variable and calling of the test target program For each execution pattern in the driver and the test target program to be called, calculate a first path condition that the one or more symbol variables should satisfy in the execution of the driver and the test target program, and An execution unit that performs symbolic execution to generate a first test case including a first pass condition and a satisfaction value of the one or more symbol variables with respect to the first pass condition;
A first generation unit that generates, for each execution pattern, a second path condition that the object type variable should satisfy as the state in the execution of the test target program;
For each execution pattern, from the first path condition included in the first test case, a condition that the control variable should satisfy is omitted, and a third path condition is obtained by adding the second path condition; A second generation unit that generates a second test case including the third pass condition and the sufficiency value of the one or more symbol variables;
When there are a plurality of the second test cases in which the third pass condition is synonymous, any one of the second test cases in which the third pass condition is synonymous. An extraction unit for omitting the test case and extracting the remaining second test case;
A test case generation device having:
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| JP2012140947A JP5884657B2 (en) | 2012-06-22 | 2012-06-22 | Program, test case generation method, and test case generation apparatus |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| JP2012140947A JP5884657B2 (en) | 2012-06-22 | 2012-06-22 | Program, test case generation method, and test case generation apparatus |
Publications (2)
| Publication Number | Publication Date |
|---|---|
| JP2014006643A JP2014006643A (en) | 2014-01-16 |
| JP5884657B2 true JP5884657B2 (en) | 2016-03-15 |
Family
ID=50104317
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| JP2012140947A Expired - Fee Related JP5884657B2 (en) | 2012-06-22 | 2012-06-22 | Program, test case generation method, and test case generation apparatus |
Country Status (1)
| Country | Link |
|---|---|
| JP (1) | JP5884657B2 (en) |
Families Citing this family (8)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| JP6245006B2 (en) * | 2014-03-13 | 2017-12-13 | 富士通株式会社 | Test case generation apparatus, method, and program |
| JP6287447B2 (en) * | 2014-03-26 | 2018-03-07 | 富士通株式会社 | Test case generation program, apparatus, and method |
| JP6364263B2 (en) * | 2014-07-08 | 2018-07-25 | 株式会社エヌ・ティ・ティ・データ | Verification support method, verification support apparatus, and program |
| JP6583033B2 (en) * | 2016-02-12 | 2019-10-02 | 富士通株式会社 | Driver generation program, apparatus, and method |
| CN107038119B (en) * | 2017-03-31 | 2019-12-03 | 上海东软载波微电子有限公司 | Automatic example generation method and device |
| CN113468065B (en) * | 2021-07-19 | 2024-08-16 | 京东科技控股股份有限公司 | Test case operation method and device |
| KR102851995B1 (en) * | 2022-05-27 | 2025-08-29 | 쿠팡 주식회사 | Code coverage information providing method and electronic device for the same |
| WO2024232193A1 (en) * | 2023-05-09 | 2024-11-14 | ソニーグループ株式会社 | Information processing device, information processing method, and computer program |
Family Cites Families (1)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| JP5561135B2 (en) * | 2010-12-02 | 2014-07-30 | 富士通株式会社 | Data generation method, program, and apparatus |
-
2012
- 2012-06-22 JP JP2012140947A patent/JP5884657B2/en not_active Expired - Fee Related
Also Published As
| Publication number | Publication date |
|---|---|
| JP2014006643A (en) | 2014-01-16 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| JP5884657B2 (en) | Program, test case generation method, and test case generation apparatus | |
| JP7045357B2 (en) | Data processing methods and related products | |
| CA3062949C (en) | Conversion method, apparatus, computer device, and storage medium | |
| CN100555218C (en) | Apparatus and method for improving simulation speed of advanced language in simulation system on chip | |
| US9152389B2 (en) | Trace generating unit, system, and program of the same | |
| EP2804099B1 (en) | Apparatus and method managing power based on data | |
| US9734033B2 (en) | Implementing processor functional verification by generating and running constrained random irritator tests for multiple processor system and processor core with multiple threads | |
| US8752056B2 (en) | Running native code across single or multi-core hybrid processor achitecture | |
| CN113885877B (en) | Compiling method, device, equipment and medium | |
| Yamato | Study and evaluation of automatic offloading method in mixed offloading destination environment | |
| Yamato | Proposal and evaluation of adjusting resource amount for automatically offloaded applications | |
| CN113934632A (en) | Code detection method and device | |
| Katagiri et al. | Early experiences for adaptation of auto-tuning by ppOpen-AT to an explicit method | |
| JPWO2018042520A1 (en) | Program editing apparatus, program editing method, and program editing program | |
| JP6759851B2 (en) | Program generation program, program generation method, program generator and compilation program | |
| US12106076B2 (en) | Method for generating program for use in accelerator for deep learning | |
| Popov et al. | Piecewise holistic autotuning of compiler and runtime parameters | |
| Yi et al. | Optimizing DNN compilation for distributed training with joint OP and tensor fusion | |
| CN118069200B (en) | Multilingual programming method and system | |
| US20230096849A1 (en) | Offload server, offload control method, and offload program | |
| Shuai et al. | Software vulnerability detection based on code coverage and test cost | |
| CN116048903B (en) | Methods and devices for generating multi-threaded test cases, electronic devices, and storage media | |
| CN114041116A (en) | Method and device for optimizing data movement task | |
| CN116795515A (en) | Execution method, equipment, chip and storage medium of cyclic tasks | |
| JP6176380B2 (en) | Information processing apparatus, method, and program |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| A621 | Written request for application examination |
Free format text: JAPANESE INTERMEDIATE CODE: A621 Effective date: 20150319 |
|
| A977 | Report on retrieval |
Free format text: JAPANESE INTERMEDIATE CODE: A971007 Effective date: 20151211 |
|
| 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: 20160112 |
|
| A61 | First payment of annual fees (during grant procedure) |
Free format text: JAPANESE INTERMEDIATE CODE: A61 Effective date: 20160125 |
|
| R150 | Certificate of patent or registration of utility model |
Ref document number: 5884657 Country of ref document: JP Free format text: JAPANESE INTERMEDIATE CODE: R150 |
|
| LAPS | Cancellation because of no payment of annual fees |