JP6503724B2 - Stub method, program and apparatus - Google Patents

Stub method, program and apparatus Download PDF

Info

Publication number
JP6503724B2
JP6503724B2 JP2014252989A JP2014252989A JP6503724B2 JP 6503724 B2 JP6503724 B2 JP 6503724B2 JP 2014252989 A JP2014252989 A JP 2014252989A JP 2014252989 A JP2014252989 A JP 2014252989A JP 6503724 B2 JP6503724 B2 JP 6503724B2
Authority
JP
Japan
Prior art keywords
stub
description
program
unit
symbolic execution
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
Application number
JP2014252989A
Other languages
Japanese (ja)
Other versions
JP2016115124A (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 JP2014252989A priority Critical patent/JP6503724B2/en
Publication of JP2016115124A publication Critical patent/JP2016115124A/en
Application granted granted Critical
Publication of JP6503724B2 publication Critical patent/JP6503724B2/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Debugging And Monitoring (AREA)

Description

本発明は、スタブ化方法、プログラム及び装置に関する。   The present invention relates to a stubbing method, program and apparatus.

プログラムテストにおいて、プログラム中の変数値を具体化せずに、記号(シンボル値)のまま実行する技術(シンボリック実行技術)が用いられることがある。このプログラムテストでは、シンボリック実行によって得たパス条件の充足値をテストデータとして用いる。   In program testing, a technique (symbolic execution technique) may be used which executes as it is (symbol value) without embodying variable values in the program. In this program test, the satisfaction value of the path condition obtained by symbolic execution is used as test data.

特開2012−181666号公報JP 2012-181666 A

しかしながら、実際のプログラムには、シンボリック実行エンジンが解析対象とできないが、一般的な処理系では実行可能な記述が存在する。このような記述が存在する場合、当該記述を置き換えるスタブを用意して使用する必要がある。なお、スタブは一般的には人手で記述する必要があり、手間が掛かる。   However, an actual program can not be analyzed by the symbolic execution engine, but there is an executable description in a general processing system. If such a description exists, it is necessary to prepare and use a stub that replaces the description. Generally, stubs need to be described manually, which takes time and effort.

これに対し、JUnit(Java(登録商標)で開発されたプログラムにおいてユニットテスト(単体テスト)の自動化を行うためのフレームワーク)では、戻り値の型に応じて予め決められた定数を返すスタブの自動生成は可能である。例えば、戻り値の型が整数であれば、0を返すスタブを生成し、戻り値の型が真偽値であれば、falseを返すスタブを生成するなどである。しかし、このように予め決められた定数を返すスタブを生成すると、プログラムのうち元々実行し得ない文まで実行されてしまい、テスト結果の信頼性が低下するおそれがある。   On the other hand, in JUnit (a framework for unit test (unit test) automation in a program developed with Java (registered trademark)), an automatic stub that returns a constant determined according to the return value type Generation is possible. For example, if the return type is an integer, a stub that returns 0 is generated, and if the return type is a boolean, a stub that returns false is generated. However, if a stub that returns a constant determined in this way is generated, even a statement that can not be originally executed in the program is executed, which may lower the reliability of the test result.

なお、従来においては、特許文献1のような技術も知られているが、本技術ではスタブの自動生成はできない。   In addition, although a technique like patent document 1 is also known conventionally, a stub can not be automatically generated by this technique.

1つの側面では、本発明は、プログラムのテスト結果の信頼性低下を抑制することが可能なプログラムのスタブ化方法、プログラム及び装置を提供することを目的とする。   In one aspect, the present invention aims to provide a program stubbing method, program, and apparatus capable of suppressing deterioration in reliability of a test result of a program.

一つの態様では、スタブ化方法は、シンボリック実行エンジンによるテスト対象のプログラムに含まれる前記シンボリック実行エンジンが解析できないスタブ化対象の記述を検出し、検出された前記スタブ化対象の記述が実行される際のパス条件を充足する変数値を設定し、設定された前記変数値を用いて前記スタブ化対象の記述を前記シンボリック実行エンジンが解析できない記述を解析できる情報処理部に実行させ、該情報処理部からの返却値に基づいてスタブを生成し、前記テスト対象のプログラムの前記スタブ化対象の記述を前記スタブで置換する、処理をコンピュータが実行する。 In one aspect, the stubbing method detects a description of a stubbed object that can not be analyzed by the symbolic execution engine included in a program to be tested by a symbolic execution engine , and the description of the detected stubbed object is executed Setting a variable value that satisfies the path condition at the time of execution, causing the information processing unit capable of analyzing a description that can not be analyzed by the symbolic execution engine to execute the description of the stub target using the set variable value; The computer executes processing for generating a stub based on a return value from the unit and replacing the description of the stub target of the program to be tested with the stub.

プログラムのテスト結果の信頼性低下を抑制することができる。   It is possible to suppress the decrease in the reliability of program test results.

一実施形態に係る情報処理装置のハードウェア構成を示す図である。It is a figure showing hardware constitutions of an information processor concerning one embodiment. 情報処理装置の機能ブロック図である。It is a functional block diagram of an information processor. 情報処理装置の処理を示すフローチャートである。It is a flow chart which shows processing of an information processor. 図4(a)〜図4(d)は、図3の処理を説明するための図(その1)である。FIGS. 4A to 4D are diagrams for explaining the process of FIG. 3 (part 1). 図5(a)、図5(b)は、図3の処理を説明するための図(その2)である。FIG. 5A and FIG. 5B are diagrams for explaining the process of FIG. 3 (part 2). 図3の処理を説明するための図(その3)である。FIG. 6 is a diagram (part 3) for explaining the process of FIG. 3; 図7(a)、図7(b)は、図3の処理を説明するための図(その4)である。FIGS. 7A and 7B are diagrams for explaining the process of FIG. 3 (part 4). 図3の処理を説明するための図(その5)である。FIG. 16 is a fifth diagram illustrating the process of FIG. 3; 図9(a)、図9(b)は、実施形態の効果を説明するための図である。Fig.9 (a) and FIG.9 (b) are figures for demonstrating the effect of embodiment.

以下、情報処理装置の一実施形態について、図1〜図9に基づいて詳細に説明する。本実施形態の情報処理装置は、テスト対象のプログラム(スタブ化前プログラム)の入力を受け付け、スタブ化を実行した後、スタブ化後プログラムを出力するスタブ化装置としての機能を有している。   Hereinafter, an embodiment of the information processing apparatus will be described in detail based on FIGS. 1 to 9. The information processing apparatus according to the present embodiment has a function as a stubbing apparatus that receives an input of a program to be tested (a program before stubbing), executes stubbing, and then outputs the program after stubbing.

図1には、本実施形態にかかる情報処理装置10のハードウェア構成が示されている。図1に示すように、情報処理装置10は、CPU(Central Processing Unit)90、ROM(Read Only Memory)92、RAM(Random Access Memory)94、記憶部(ここではHDD(Hard Disk Drive))96、ネットワークインタフェース97、表示部93、入力部95、及び可搬型記憶媒体用ドライブ99等を備えている。これら情報処理装置10の構成各部は、バス98に接続されている。表示部93は、液晶ディスプレイ等を含み、入力部95は、キーボードやマウス、タッチパネル等を含む。情報処理装置10では、ROM92あるいはHDD96に格納されているプログラム(スタブ化プログラムを含む)、或いは可搬型記憶媒体用ドライブ99が可搬型記憶媒体91から読み取ったプログラム(スタブ化プログラムを含む)をCPU90が実行することにより、図2に示す各部としての機能が実現されている。   FIG. 1 shows the hardware configuration of the information processing apparatus 10 according to the present embodiment. As shown in FIG. 1, the information processing apparatus 10 includes a central processing unit (CPU) 90, a read only memory (ROM) 92, a random access memory (RAM) 94, and a storage unit (here, HDD (hard disk drive)) 96. , A network interface 97, a display unit 93, an input unit 95, a portable storage medium drive 99, and the like. Each component of the information processing apparatus 10 is connected to a bus 98. The display unit 93 includes a liquid crystal display and the like, and the input unit 95 includes a keyboard, a mouse, a touch panel and the like. In the information processing apparatus 10, the CPU 90 stores a program (including a stubbed program) stored in the ROM 92 or the HDD 96, or a program (including a stubbed program) read by the portable storage medium drive 99 from the portable storage medium 91. The functions of the respective units shown in FIG. 2 are realized by executing.

図2は、情報処理装置10の機能ブロック図である。図2に示すように、CPU90がプログラムを実行することにより、シンボリック実行部12、検出部としてのスタブ化対象記述検出部14、設定部としての具体値入力生成部16、生成部としてのスタブ生成部18、置換部としてのスタブ挿入部20、として情報処理装置10を機能させる。なお、図2には、HDD96等に格納されている格納部としてのスタブ化対象記述DB40も記載されている。また、図2には、シンボリック実行部12(シンボリック実行エンジン)とは異なる一般的な処理系である情報処理部としての処理部30も記載されている。   FIG. 2 is a functional block diagram of the information processing apparatus 10. As shown in FIG. 2, when the CPU 90 executes a program, the symbolic execution unit 12, a stubbed object description detection unit 14 as a detection unit, a specific value input generation unit 16 as a setting unit, stub generation as a generation unit The information processing apparatus 10 functions as the unit 18 and the stub insertion unit 20 as the replacement unit. Note that FIG. 2 also describes a stubified object description DB 40 as a storage unit stored in the HDD 96 or the like. Further, FIG. 2 also shows a processing unit 30 as an information processing unit which is a general processing system different from the symbolic execution unit 12 (symbolic execution engine).

シンボリック実行部12は、テスト対象のプログラムをシンボリック実行する。本実施形態では、シンボリック実行部12は、スタブ化前プログラムの入力を受け付け、スタブ化後プログラムを出力する。   The symbolic execution unit 12 executes the program to be tested symbolically. In the present embodiment, the symbolic execution unit 12 receives an input of the pre-stub program, and outputs the stub program.

スタブ化対象記述検出部14は、シンボリック実行部12から入力されるプログラム内の各記述を、スタブ化対象記述データベース(DB)40の内容と比較し、スタブ化対象とするかを判定する。すなわち、スタブ化対象記述検出部14は、プログラムに含まれるスタブ化対象の記述を検出する。なお、スタブ化対象記述DB40には、スタブ化する必要のある記述(スタブ化対象記述)、すなわちシンボリック実行部12では解析できないが一般的な処理系(処理部30)では解析できる記述を格納しているものとする。なお、スタブ化対象記述は、スタブ化対象記述DB40に対して人手で入力されてもよいが、過去のテストにおいてシンボリック実行部12が処理できなかった記述をスタブ化対象記述DB40に自動的に格納してもよい。   The stub target description detecting unit 14 compares each description in the program input from the symbolic execution unit 12 with the contents of the stub target description database (DB) 40 to determine whether to make a stub target. That is, the stubbed object description detection unit 14 detects the description of the stubbed object included in the program. The stub target description DB 40 stores a description that needs to be stubbed (stub target description), that is, a description that can not be analyzed by the symbolic execution unit 12 but can be analyzed by a general processing system (processing unit 30). It shall be. Although the stub target description may be manually input to the stub target description DB 40, a description that can not be processed by the symbolic execution unit 12 in the past test is automatically stored in the stub target description DB 40. You may

具体値入力生成部16は、スタブ化対象記述が実行される際のパス条件を充足する各変数の具体値(変数値)をSMT(Satisfiability Modulo Theories)ソルバを用いて算出する。この場合、過去に同一のスタブ化対象記述がスタブ化されていた場合であっても、具体値入力生成部16は、実行時のパス条件が異なる場合にはそのパス条件に応じた各変数の具体値を新たに算出する。   The specific value input generation unit 16 calculates a specific value (variable value) of each variable satisfying the path condition when the stub target description is executed, using a SMT (Satisfiability Modulo Theories) solver. In this case, even if the same stubbed target description has been stubbed in the past, the concrete value input generation unit 16 may use each variable according to the path condition when the path condition at the time of execution is different. Calculate specific values anew.

スタブ生成部18は、具体値入力生成部16で得られた具体値入力を用いて一般的な処理系(処理部30)にスタブ化対象記述を実行させる。処理部30では、シンボリック実行部12が解析対象とできない記述も実行可能であり、スタブ生成部18は、処理部30からの返却値を取得すると、当該返却値に基づいてスタブを生成する。   The stub generation unit 18 uses a specific value input obtained by the specific value input generation unit 16 to cause a general processing system (processing unit 30) to execute a stub target description. The processing unit 30 can also execute a description that the symbolic execution unit 12 can not analyze, and the stub generation unit 18 generates a stub based on the return value when the return value from the processing unit 30 is acquired.

スタブ挿入部20は、スタブ生成部18において生成されたスタブによって、テスト対象のプログラムのスタブ化対象記述を置換することで、プログラムにスタブを挿入し、シンボリック実行部12の解析対象にできるようにする。   The stub insertion unit 20 inserts the stub into the program by replacing the stub target description of the program to be tested with the stub generated in the stub generation unit 18 so that the symbolic execution unit 12 can be analyzed Do.

(情報処理装置10の処理)
次に、情報処理装置10の処理について、図3のフローチャートに沿って、その他図面を適宜参照しつつ、詳細に説明する。
(Processing of the information processing apparatus 10)
Next, the process of the information processing apparatus 10 will be described in detail along the flowchart of FIG. 3 with reference to other drawings as appropriate.

ステップS10では、シンボリック実行部12が、スタブ化前プログラムの入力を受け付け、初期パス条件をcとする。例えば、シンボリック実行部12は、スタブ化前プログラムとして、図4(a)に示すようなテスト対象関数main2の入力を受け付けたものとする。なお、テスト対象関数main2の制御構造は、図4(d)に示すようになっている。また、シンボリック実行においては、テスト対象関数main2の引数aをシンボルとして指定する。また、プログラム実行中においてシンボルの値が満たすべき条件をパス条件と呼ぶものとする。なお、本実施形態では、説明の簡素化のため、図4(b)に示すように、関数func1(a)(a>0)をスタブ化対象関数と仮定し、図4(c)に示すように、関数func2(a)(a==0)をスタブ化対象外関数と仮定している。   In step S10, the symbolic execution unit 12 receives the input of the pre-stub program, and sets the initial path condition to c. For example, it is assumed that the symbolic execution unit 12 receives an input of a test target function main2 as shown in FIG. 4A as a pre-stub program. The control structure of the test target function main2 is as shown in FIG. 4 (d). In symbolic execution, the argument a of the function to be tested main2 is specified as a symbol. Further, a condition that the symbol value should satisfy during program execution is called a pass condition. In the present embodiment, as shown in FIG. 4B, the function func1 (a) (a> 0) is assumed to be a stub target function as shown in FIG. As such, it is assumed that the function func2 (a) (a == 0) is a stubified outlier function.

次いで、ステップS12では、シンボリック実行部12が、スタブ化前プログラム内の次命令iを読み出す。ここでは、シンボリック実行部12は、図4(a)のテスト対象関数main2のfunc2を読み出したものとする。なお、シンボリック実行部12は、読み出した命令iをスタブ化対象記述検出部14に送信する。   Next, in step S12, the symbolic execution unit 12 reads the next instruction i in the pre-stubbed program. Here, it is assumed that the symbolic execution unit 12 reads out func2 of the test target function main2 in FIG. 4A. The symbolic execution unit 12 transmits the read instruction i to the stub target description detection unit 14.

ステップS14では、スタブ化対象記述検出部14が、シンボリック実行部12から受信した命令iがスタブ化対象記述DB40に含まれるか否かを判断する。ここで、func2は、図4(c)に示すようにスタブ化対象外関数であるものとする。すなわち、func2は、スタブ化対象記述DB40に含まれていないため、ステップS14の判断は否定され、ステップS26に移行する。   In step S14, the stubification target description detection unit 14 determines whether the instruction i received from the symbolic execution unit 12 is included in the stubification target description DB 40 or not. Here, it is assumed that func2 is a stubified non-target function as shown in FIG. 4 (c). That is, since func2 is not included in the stub target description DB 40, the determination in step S14 is negative, and the process proceeds to step S26.

ステップS26に移行すると、シンボリック実行部12は、命令iのシンボリック実行を行いパス条件cを更新する(ここでは、a==0とする)。その後は、ステップS28に移行し、シンボリック実行部12は、プログラムの次命令が存在しないか否かを判断する。ここでは、次の命令が存在しているので、ステップS28の判断は否定され、ステップS12に戻る。   At step S26, the symbolic execution unit 12 executes the symbolic execution of the instruction i to update the path condition c (here, a == 0). Thereafter, the process proceeds to step S28, where the symbolic execution unit 12 determines whether there is a next instruction of the program. Here, since the next instruction is present, the determination at step S28 is denied, and the process returns to step S12.

ステップS12に戻ると、シンボリック実行部12は、スタブ化前プログラム内の次命令iを読み出す。ここでは、シンボリック実行部12は、図4(a)のテスト対象関数main2のfunc1を読み出したものとする。   Returning to step S12, the symbolic execution unit 12 reads the next instruction i in the pre-stubbed program. Here, it is assumed that the symbolic execution unit 12 reads out func1 of the test target function main2 in FIG. 4A.

次いで、ステップS14では、スタブ化対象記述検出部14が、シンボリック実行部12から受信した命令i(func1)がスタブ化対象記述DB40に含まれるか否かを判断する。ここで、func1は、図4(b)に示すようにスタブ化対象関数であるものとする。すなわち、func1は、スタブ化対象記述DB40に含まれているため、ステップS14の判断は肯定され、ステップS16に移行する。   Next, in step S14, the stubification target description detection unit 14 determines whether or not the instruction i (func1) received from the symbolic execution unit 12 is included in the stubification target description DB 40. Here, it is assumed that func1 is a stub target function as shown in FIG. 4 (b). That is, since func1 is included in the stub target description DB 40, the determination in step S14 is affirmed, and the process proceeds to step S16.

ステップS16に移行すると、具体値入力生成部16が、パス条件c(a==0)を充足する具体値入力を生成する。ここでは、図5(a)に示すように、具体値(変数値)として、パス条件c(a==0)を充足するa=0が生成される。   In step S16, the specific value input generation unit 16 generates a specific value input that satisfies the path condition c (a == 0). Here, as shown in FIG. 5A, a = 0 is generated as a specific value (variable value) which satisfies the path condition c (a == 0).

次いで、ステップS18では、スタブ生成部18が、具体値入力を用いて、処理部30において命令iまでスタブ化前プログラムを実行する。この場合、図5(b)に示すように、処理部30では、func1(a)=func1(0)=falseという返却値が得られるので、処理部30は、この返却値(false)をスタブ生成部18に戻す。   Next, in step S18, the stub generation unit 18 executes the pre-stubbed program up to the instruction i in the processing unit 30 using the specific value input. In this case, as shown in FIG. 5B, the processing unit 30 can obtain a return value such as func1 (a) = func1 (0) = false, so the processing unit 30 can stub this return value (false). The generation unit 18 is returned to.

次いで、ステップS20では、スタブ生成部18が、処理部30による命令iの返却値(評価値)に基づいてスタブを生成する。この場合、スタブ生成部18は、図6において太線枠で示すようなスタブ関数を生成する。次いで、ステップS22では、スタブ挿入部20が、生成されたスタブをプログラムに挿入する。なお、スタブ挿入部20は、スタブ挿入後のプログラムをシンボリック実行部12に送信する。   Next, in step S20, the stub generation unit 18 generates a stub based on the return value (evaluation value) of the instruction i by the processing unit 30. In this case, the stub generation unit 18 generates a stub function as indicated by a bold line frame in FIG. Next, in step S22, the stub insertion unit 20 inserts the generated stub into the program. The stub insertion unit 20 transmits the program after stub insertion to the symbolic execution unit 12.

次いで、ステップS24では、シンボリック実行部12が、スタブ挿入後のプログラムを命令iまでシンボリック実行し、パス条件cを更新する。この場合、シンボリック実行部12は、スタブ化前に実行し得ない記述、すなわち、図6において下線を付して示すif-if側の分岐内記述(print(“positive”))を実行しないようにすることができる。また、シンボリック実行部12は、パス条件cを、次のパス条件(a!=0)に更新する。   Next, in step S24, the symbolic execution unit 12 executes the program after stub insertion symbolically up to the instruction i and updates the path condition c. In this case, the symbolic execution unit 12 should not execute the description that can not be executed before stubbing, that is, the in-branch description (print (“positive”)) on the if-if side underlined in FIG. Can be Also, the symbolic execution unit 12 updates the path condition c to the next path condition (a! = 0).

次いで、ステップS28では、シンボリック実行部12が、プログラムの次命令が存在しないか否かを判断するが、プログラムには、次命令が存在しているので、ステップS12に再度戻る。   Next, in step S28, the symbolic execution unit 12 determines whether or not the next instruction of the program exists. However, since the next instruction exists in the program, the process returns to step S12 again.

ステップS12に戻ると、シンボリック実行部12は、スタブ化前プログラム内の次命令iを読み出す。ここでは、シンボリック実行部12は、図4(a)のテスト対象関数main2の下側のfunc1(else-if側のfunc1(a))を読み出したものとする。   Returning to step S12, the symbolic execution unit 12 reads the next instruction i in the pre-stubbed program. Here, it is assumed that the symbolic execution unit 12 reads out func1 (func1 (a) on the else-if side) on the lower side of the test target function main2 in FIG. 4A.

次いで、ステップS14では、スタブ化対象記述検出部14が、シンボリック実行部12から受信した命令i(func1)がスタブ化対象記述DB40に含まれるか否かを判断する。ここで、func1は、スタブ化対象記述DB40に含まれているため、ステップS14の判断は肯定され、ステップS16に移行する。   Next, in step S14, the stubification target description detection unit 14 determines whether or not the instruction i (func1) received from the symbolic execution unit 12 is included in the stubification target description DB 40. Here, since func1 is included in the stub target description DB 40, the determination in step S14 is affirmed, and the process proceeds to step S16.

ステップS16に移行すると、具体値入力生成部16が、パス条件c(a!=0)を充足する具体値入力を生成する。ここでは、一例として、図7(a)に示すように、具体値(変数値)として、パス条件c(a!=0)を充足するa=1が生成されたものとする。   At step S16, the specific value input generation unit 16 generates a specific value input that satisfies the path condition c (a! = 0). Here, as an example, as shown in FIG. 7A, it is assumed that a = 1 satisfying the path condition c (a! = 0) is generated as a specific value (variable value).

次いで、ステップS18では、スタブ生成部18が、具体値入力を用いて、処理部30において命令iまでスタブ化前プログラムを実行する。この場合、図5(b)に示すように、処理部30では、func1(a)=func1(1)=trueという返却値が得られるので、処理部30は、この返却値(true)をスタブ生成部18に戻す。   Next, in step S18, the stub generation unit 18 executes the pre-stubbed program up to the instruction i in the processing unit 30 using the specific value input. In this case, as shown in FIG. 5B, the processing unit 30 can obtain a return value such as func1 (a) = func1 (1) = true, so the processing unit 30 can stub this return value (true). The generation unit 18 is returned to.

次いで、ステップS20では、スタブ生成部18が、処理部30による命令iの返却値(評価値)に基づいてスタブを生成する。この場合、スタブ生成部18は、図8において太線枠で示すようなスタブ関数を生成する。次いで、ステップS22では、スタブ挿入部20が、生成されたスタブをプログラムに挿入し、該プログラムをシンボリック実行部12に送信する。   Next, in step S20, the stub generation unit 18 generates a stub based on the return value (evaluation value) of the instruction i by the processing unit 30. In this case, the stub generation unit 18 generates a stub function as indicated by a bold line frame in FIG. Next, in step S22, the stub insertion unit 20 inserts the generated stub into a program, and transmits the program to the symbolic execution unit 12.

次いで、ステップS24では、シンボリック実行部12が、スタブ挿入後のプログラムを命令iまでシンボリック実行し、パス条件cを更新する。ここで、シンボリック実行部12は、図8において下線を付して示すelse-if側の分岐内記述(print(“positive”))をシンボリック実行する。なお、この段階では、パス条件cは更新されずに、ステップS28に移行する。   Next, in step S24, the symbolic execution unit 12 executes the program after stub insertion symbolically up to the instruction i and updates the path condition c. Here, the symbolic execution unit 12 symbolically executes the in-branch description (print (“positive”)) on the else-if side shown underlined in FIG. At this stage, the path condition c is not updated, and the process proceeds to step S28.

なお、パス条件cがa!=0の場合、例えば、具体値入力をa=−1とすることもできる(S16)。このようにした場合、処理部30からの返却値はfalseとなるので、シンボリック実行部12は、else-else側の分岐内記述(print(“negative”))を実行することになる(S24)。   When the pass condition c is a! = 0, for example, the specific value input can be a = −1 (S16). In this case, since the return value from the processing unit 30 is false, the symbolic execution unit 12 executes the statement in the branch on the else-else side (print (“negative”)) (S24) .

次いで、ステップS28では、シンボリック実行部12が、プログラムの次命令が存在しないか否かを判断するが、プログラムには、次命令が存在していないので、ステップS30に移行する。   Next, in step S28, the symbolic execution unit 12 determines whether or not the next instruction of the program is present, but since there is no next instruction in the program, the process proceeds to step S30.

ステップS30に移行した場合、シンボリック実行部12は、スタブ化後プログラムを出力する。   When the process proceeds to step S30, the symbolic execution unit 12 outputs the stubbed program.

ここで、本実施形態では、図9(a)において×印で示すように、スタブ化前に実行し得ない記述であるif-if側の分岐内記述が実行されることがなく、スタブ化前に実行可能な記述のみが実行されるようになっている。これにより、テスト結果において一定の信頼性を確保することができるようになる。なお、比較例としては、予めfunc1に対しては、trueなどの定数を返却するスタブを生成する技術がある。このような比較例では、func1に対してはtrueが返却されると、スタブ化前に実行し得ない記述であるif-if側の分岐内記述(図9(a)において×印で示す記述)が実行されてしまうため、テスト結果において信頼性が低くなるおそれがある。   Here, in the present embodiment, as indicated by a cross in FIG. 9A, the in-branch description on the if-if side, which is a description that can not be executed before stubbing, is not executed, and stubbing is performed. Only previously executable descriptions are to be executed. This makes it possible to ensure a certain level of reliability in the test results. As a comparative example, there is a technique of generating a stub that returns a constant such as true for func1 in advance. In such a comparative example, if “true” is returned for “func 1”, the in-branch description on the if-if side, which can not be executed before stubbing (description indicated by “x” in FIG. 9A) May be unreliable in test results, because

また、本実施形態では、スタブ化対象記述の処理及び返却値の決定処理を一般的な処理系である処理部30が実行するため、シンボリック実行部(シンボリック実行エンジン)が解析対象とできない記述も解析することが可能となる。この結果、図9(b)に太線及び白抜きの線にて示すように、関数func1の記述を解析できずに、解析が停止してしまうのを防止することができる。なお、図9(b)のように解析が停止した場合、解析を継続するためには、func1のスタブを手動で記述する必要があるが、本実施形態では、このような人手の介入が不要である。   Further, in the present embodiment, since the processing unit 30, which is a general processing system, executes the processing of the stub target description and the determination processing of the return value, the description that the symbolic execution unit (symbolic execution engine) can not analyze is also included. It becomes possible to analyze. As a result, as shown by a thick line and a white line in FIG. 9B, it is possible to prevent the analysis from being stopped without analyzing the description of the function func1. When analysis is stopped as shown in FIG. 9B, in order to continue the analysis, it is necessary to manually describe the stub of func1, but in the present embodiment, such manual intervention is unnecessary. It is.

以上、詳細に説明したように、本実施形態によると、スタブ化対象記述検出部14がシンボリック実行によるテスト対象のプログラムに含まれるスタブ化対象記述を検出し(S14:肯定)、具体値入力生成部16が、スタブ化対象記述が実行される際のパス条件を充足する変数値を生成し(S16)、スタブ生成部18が、生成された変数値を用いてスタブ化対象記述を処理部30に実行させ、処理部30からの返却値に基づいてスタブを生成し(S18、S20)、スタブ挿入部20が、スタブ化対象記述を生成されたスタブで置換する(プログラムにスタブを挿入する)(S22)。これにより、プログラム実行時のパス条件を考慮したスタブが生成されるので、スタブ化前プログラムで実行可能な記述のみが実行され、スタブ化前プログラムでは実行され得ない記述が実行されるのを防止することができる。これにより、テスト結果の信頼性の低下を抑制することが可能である。また、処理部30にスタブ化対象記述を実行させ、スタブを自動生成し、スタブ化後のプログラムをシンボリック実行部12がシンボリック実行するため、シンボリック実行部12による解析が停止することがなくなる。これにより、人手によるスタブの記述の手間を省くことが可能となる。   As described above in detail, according to the present embodiment, the stub target description detecting unit 14 detects a stub target description included in a program to be tested by symbolic execution (S14: Yes), and generates a specific value input The unit 16 generates a variable value that satisfies the path condition when the stub target description is executed (S16), and the stub generation unit 18 processes the stub target description using the generated variable value. To generate a stub based on the return value from the processing unit 30 (S18, S20), and the stub insertion unit 20 replaces the stub target description with the generated stub (inserts the stub into the program) (S22). As a result, a stub is generated in consideration of a path condition at the time of program execution, so that only an executable description can be executed in the program before stubbing, and a description that can not be executed in the program before stubbing can be prevented from being executed can do. This makes it possible to suppress the reduction in the reliability of the test results. In addition, since the processing unit 30 executes the stub target description, automatically generates a stub, and the symbolic execution unit 12 executes the program after stubification symbolically, the analysis by the symbolic execution unit 12 is not stopped. This makes it possible to save time and labor for manual description of stubs.

また、本実施形態では、スタブ化対象記述検出部14は、スタブ化する必要のある記述(スタブ化対象記述)を格納したスタブ化対象記述DB40に基づいて、プログラム中の記述がスタブ化対象記述であるかを判断する。これにより、簡易に、スタブ化対象記述であるかどうかの判断を行うことができる。   Further, in the present embodiment, the stubbed object description detection unit 14 describes the stubbed object description based on the stubbed object description DB 40 in which the description that needs to be stubbed (the stubified object description) is stored. Determine if it is. This makes it possible to easily determine whether or not the description is a stub target.

なお、上記実施形態では、情報処理装置10が処理部30を有する場合について説明したが、これに限らず、情報処理装置10とネットワーク等により接続された外部の装置が処理部30と同等の機能を有していてもよい。   Although the above embodiment describes the case where the information processing apparatus 10 includes the processing unit 30, the present invention is not limited to this, and an external device connected to the information processing apparatus 10 by a network or the like has the same function as the processing unit 30. May be included.

なお、上記の処理機能は、コンピュータによって実現することができる。その場合、処理装置が有すべき機能の処理内容を記述したプログラムが提供される。そのプログラムをコンピュータで実行することにより、上記処理機能がコンピュータ上で実現される。処理内容を記述したプログラムは、コンピュータで読み取り可能な記録媒体(ただし、搬送波は除く)に記録しておくことができる。   The above processing functions can be realized by a computer. In that case, a program is provided which describes the processing content of the function that the processing device should have. The above processing functions are realized on the computer by executing the program on the computer. The program in which the processing content is described can be recorded on a computer readable recording medium (except for the carrier wave).

プログラムを流通させる場合には、例えば、そのプログラムが記録されたDVD(Digital Versatile Disc)、CD−ROM(Compact Disc Read Only Memory)などの可搬型記録媒体の形態で販売される。また、プログラムをサーバコンピュータの記憶装置に格納しておき、ネットワークを介して、サーバコンピュータから他のコンピュータにそのプログラムを転送することもできる。   In the case of distributing the program, for example, the program is sold in the form of a portable recording medium such as a DVD (Digital Versatile Disc), a CD-ROM (Compact Disc Read Only Memory) or the like in which the program is recorded. Alternatively, the program may be stored in the storage device of the server computer, and the program may be transferred from the server computer to another computer via a network.

プログラムを実行するコンピュータは、例えば、可搬型記録媒体に記録されたプログラムもしくはサーバコンピュータから転送されたプログラムを、自己の記憶装置に格納する。そして、コンピュータは、自己の記憶装置からプログラムを読み取り、プログラムに従った処理を実行する。なお、コンピュータは、可搬型記録媒体から直接プログラムを読み取り、そのプログラムに従った処理を実行することもできる。また、コンピュータは、サーバコンピュータからプログラムが転送されるごとに、逐次、受け取ったプログラムに従った処理を実行することもできる。   The computer executing the program stores, for example, the program recorded on the portable recording medium or the program transferred from the server computer in its own storage device. Then, the computer reads the program from its storage device and executes processing according to the program. The computer can also read the program directly from the portable recording medium and execute processing in accordance with the program. The computer can also execute processing in accordance with the received program each time the program is transferred from the server computer.

上述した実施形態は本発明の好適な実施の例である。但し、これに限定されるものではなく、本発明の要旨を逸脱しない範囲内において種々変形実施可能である。   The embodiments described above are examples of preferred implementations of the invention. However, the present invention is not limited to this, and various modifications can be made without departing from the scope of the present invention.

なお、以上の実施形態の説明に関して、更に以下の付記を開示する。
(付記1) シンボリック実行によるテスト対象のプログラムに含まれるスタブ化対象の記述を検出し、
検出された前記スタブ化対象の記述が実行される際のパス条件を充足する変数値を設定し、
設定された前記変数値を用いて前記スタブ化対象の記述を情報処理部に実行させ、該情報処理部からの返却値に基づいてスタブを生成し、
前記テスト対象のプログラムの前記スタブ化対象の記述を前記スタブで置換する、処理をコンピュータが実行するスタブ化方法。
(付記2) 前記検出する処理では、スタブ化する必要のある記述を格納した格納部に基づいて、前記テスト対象のプログラムの中から前記スタブ化対象の記述を検出することを特徴とする付記1に記載のスタブ化方法。
(付記3) シンボリック実行によるテスト対象のプログラムに含まれるスタブ化対象の記述を検出し、
検出された前記スタブ化対象の記述が実行される際のパス条件を充足する変数値を設定し、
設定された前記変数値を用いて前記スタブ化対象の記述を情報処理部に実行させ、該情報処理部からの返却値に基づいてスタブを生成し、
前記テスト対象のプログラムの前記スタブ化対象の記述を前記スタブで置換する、処理をコンピュータに実行させるスタブ化プログラム。
(付記4) 前記検出する処理では、スタブ化する必要のある記述を格納した格納部に基づいて、前記テスト対象のプログラムの中から前記スタブ化対象の記述を検出することを特徴とする付記3に記載のスタブ化プログラム。
(付記5) シンボリック実行によるテスト対象のプログラムに含まれるスタブ化対象の記述を検出する検出部と、
前記検出部が検出した前記スタブ化対象の記述が実行される際のパス条件を充足する変数値を設定する設定部と、
前記設定部が設定した前記変数値を用いて前記スタブ化対象の記述を情報処理部に実行させ、該情報処理部からの返却値に基づいてスタブを生成する生成部と、
前記テスト対象のプログラムの前記スタブ化対象の記述を前記スタブで置換する置換部と、を備えるスタブ化装置。
(付記6) スタブ化する必要のある記述を格納した格納部を更に備え、
前記検出部は、前記格納部に基づいて、前記テスト対象のプログラムの中から前記スタブ化対象の記述を検出することを特徴とする付記5に記載のスタブ化装置。
In addition, the following additional remarks are disclosed regarding description of the above embodiment.
(Supplementary note 1) Detect the description of stubbed target included in the program to be tested by symbolic execution,
Set a variable value that satisfies the path condition when the detected description of stub object is executed,
Causing the information processing unit to execute the description of the stub target using the set variable value, and generating a stub based on a return value from the information processing unit;
A stubbing method in which a computer executes processing for replacing the stubbed description of the program to be tested with the stub.
(Supplementary Note 2) In the detection process, the description of the stub target is detected from the program to be tested based on the storage unit storing the description that needs to be stubbed. The stubbing method described in.
(Supplementary note 3) Detect the description of stubbed target included in the program to be tested by symbolic execution,
Set a variable value that satisfies the path condition when the detected description of stub object is executed,
Causing the information processing unit to execute the description of the stub target using the set variable value, and generating a stub based on a return value from the information processing unit;
A stubbed program that causes a computer to execute processing for replacing the stubbed description of the program to be tested with the stub.
(Supplementary Note 4) In the detection process, the description of the stub target is detected from the program to be tested based on the storage unit storing the description that needs to be stubbed. The stubbed program described in.
(Supplementary Note 5) A detection unit that detects a description of a stub target included in a program to be tested by symbolic execution;
A setting unit configured to set a variable value that satisfies a path condition when the description of the stub target detected by the detection unit is executed;
A generation unit that causes the information processing unit to execute the description of the stub target using the variable value set by the setting unit, and generates a stub based on a return value from the information processing unit;
A replacing unit that replaces the description of the stub target of the program to be tested with the stub.
(Supplementary Note 6) A storage unit storing a description that needs to be stubbed is further provided,
The stub generation device according to claim 5, wherein the detection unit detects a description of the stub target from the program to be tested based on the storage unit.

10 情報処理装置(スタブ化装置)
14 スタブ化対象記述検出部(検出部)
16 具体値入力生成部(設定部)
18 スタブ生成部(生成部)
20 スタブ挿入部(置換部)
30 処理部(情報処理部)
40 スタブ化対象記述DB(格納部)
10 Information processing device (stub device)
14 Stubification target description detection unit (detection unit)
16 Specific value input generation unit (setting unit)
18 Stub generation unit (generation unit)
20 stub insertion part (replacement part)
30 processing unit (information processing unit)
40 Stubification target description DB (storage unit)

Claims (4)

シンボリック実行エンジンによるテスト対象のプログラムに含まれる前記シンボリック実行エンジンが解析できないスタブ化対象の記述を検出し、
検出された前記スタブ化対象の記述が実行される際のパス条件を充足する変数値を設定し、
設定された前記変数値を用いて前記スタブ化対象の記述を前記シンボリック実行エンジンが解析できない記述を解析できる情報処理部に実行させ、該情報処理部からの返却値に基づいてスタブを生成し、
前記テスト対象のプログラムの前記スタブ化対象の記述を前記スタブで置換する、処理をコンピュータが実行するスタブ化方法。
Detect a description of a stub target that can not be analyzed by the symbolic execution engine included in a program to be tested by the symbolic execution engine ,
Set a variable value that satisfies the path condition when the detected description of stub object is executed,
The information processing unit capable of analyzing the description that can not be analyzed by the symbolic execution engine is executed using the set variable value, and the stub is generated based on the return value from the information processing unit.
A stubbing method in which a computer executes processing for replacing the stubbed description of the program to be tested with the stub.
前記検出する処理では、スタブ化する必要のある記述を格納した格納部に基づいて、前記テスト対象のプログラムの中から前記スタブ化対象の記述を検出することを特徴とする請求項1に記載のスタブ化方法。   2. The process according to claim 1, wherein the description of the stubbing target is detected from the program to be tested based on a storage unit storing a description that needs to be stubbed. Stubbing method. シンボリック実行エンジンによるテスト対象のプログラムに含まれる前記シンボリック実行エンジンが解析できないスタブ化対象の記述を検出し、
検出された前記スタブ化対象の記述が実行される際のパス条件を充足する変数値を設定し、
設定された前記変数値を用いて前記スタブ化対象の記述を前記シンボリック実行エンジンが解析できない記述を解析できる情報処理部に実行させ、該情報処理部からの返却値に基づいてスタブを生成し、
前記テスト対象のプログラムの前記スタブ化対象の記述を前記スタブで置換する、処理をコンピュータに実行させるスタブ化プログラム。
Detect a description of a stub target that can not be analyzed by the symbolic execution engine included in a program to be tested by the symbolic execution engine ,
Set a variable value that satisfies the path condition when the detected description of stub object is executed,
The information processing unit capable of analyzing the description that can not be analyzed by the symbolic execution engine is executed using the set variable value, and the stub is generated based on the return value from the information processing unit.
A stubbed program that causes a computer to execute processing for replacing the stubbed description of the program to be tested with the stub.
シンボリック実行エンジンによるテスト対象のプログラムに含まれる前記シンボリック実行エンジンが解析できないスタブ化対象の記述を検出する検出部と、
前記検出部が検出した前記スタブ化対象の記述が実行される際のパス条件を充足する変数値を設定する設定部と、
前記設定部が設定した前記変数値を用いて前記スタブ化対象の記述を前記シンボリック実行エンジンが解析できない記述を解析できる情報処理部に実行させ、該情報処理部からの返却値に基づいてスタブを生成する生成部と、
前記テスト対象のプログラムの前記スタブ化対象の記述を前記スタブで置換する置換部と、を備えるスタブ化装置。
A detection unit that detects a description of a stub target that can not be analyzed by the symbolic execution engine included in a program to be tested by the symbolic execution engine ;
A setting unit configured to set a variable value that satisfies a path condition when the description of the stub target detected by the detection unit is executed;
The information processing unit capable of analyzing the description that can not be analyzed by the symbolic execution engine is executed using the variable value set by the setting unit, and the stub is generated based on the return value from the information processing unit. A generation unit to generate
A replacing unit that replaces the description of the stub target of the program to be tested with the stub.
JP2014252989A 2014-12-15 2014-12-15 Stub method, program and apparatus Expired - Fee Related JP6503724B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2014252989A JP6503724B2 (en) 2014-12-15 2014-12-15 Stub method, program and apparatus

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2014252989A JP6503724B2 (en) 2014-12-15 2014-12-15 Stub method, program and apparatus

Publications (2)

Publication Number Publication Date
JP2016115124A JP2016115124A (en) 2016-06-23
JP6503724B2 true JP6503724B2 (en) 2019-04-24

Family

ID=56141958

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2014252989A Expired - Fee Related JP6503724B2 (en) 2014-12-15 2014-12-15 Stub method, program and apparatus

Country Status (1)

Country Link
JP (1) JP6503724B2 (en)

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP4957521B2 (en) * 2007-11-22 2012-06-20 日本電気株式会社 Software partial test system, method and program used therefor
JPWO2013161195A1 (en) * 2012-04-26 2015-12-21 日本電気株式会社 Program unit test support device
US9081892B2 (en) * 2013-03-14 2015-07-14 Fujitsu Limited Software verification

Also Published As

Publication number Publication date
JP2016115124A (en) 2016-06-23

Similar Documents

Publication Publication Date Title
US9507943B1 (en) Analysis tool for data security
US10545855B1 (en) Software testing assurance through inconsistent treatment detection
US8370945B2 (en) Identifying security breaches caused by web-enabled software applications
US9128723B2 (en) Method and apparatus for dynamic document object model (DOM) aware code editing
US20170031800A1 (en) Determining code complexity scores
US20130007887A1 (en) Black-box testing of web applications with client-side code evaluation
US9471790B2 (en) Remediation of security vulnerabilities in computer software
US8607193B2 (en) Tracking stale comments in source code listings
US20150007330A1 (en) Scoring security risks of web browser extensions
JP5110640B2 (en) Accessibility information obtaining method, computer program, and accessibility information device
US20120192155A1 (en) Code advisor for web compatibility and interoperability
US20180260308A1 (en) Checking a computer processor design for soft error handling
US11797639B2 (en) Systems and methods for development of web products
US10380313B1 (en) Implementation and evaluation of designs for heterogeneous computing platforms with hardware acceleration
US20160112285A1 (en) Apparatus and method for detecting abnormal connection
van Riet et al. From 6.2 to 0.15 seconds–an industrial case study on mobile web performance
Ochin Cross browser incompatibility: reasons and solutions
JP6503724B2 (en) Stub method, program and apparatus
US20150082278A1 (en) Clone detection method and clone function commonalizing method
US20140067854A1 (en) Crawling of generated server-side content
US10127202B2 (en) Detecting overlapping web elements in a graphical user interface
US20240202109A1 (en) Test support apparatus, test support method, and program
US8397192B2 (en) Proof based bounded model checking
US11354440B1 (en) Analyzing and mitigating privacy issues on a computing device using cookie generation flows
US20150095304A1 (en) Crawling computer-based objects

Legal Events

Date Code Title Description
A621 Written request for application examination

Free format text: JAPANESE INTERMEDIATE CODE: A621

Effective date: 20171113

A977 Report on retrieval

Free format text: JAPANESE INTERMEDIATE CODE: A971007

Effective date: 20180718

A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20180731

A521 Request for written amendment filed

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20180925

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

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20190311

R150 Certificate of patent or registration of utility model

Ref document number: 6503724

Country of ref document: JP

Free format text: JAPANESE INTERMEDIATE CODE: R150

LAPS Cancellation because of no payment of annual fees