JP4847102B2 - Test program generation method for computer program - Google Patents
Test program generation method for computer program Download PDFInfo
- Publication number
- JP4847102B2 JP4847102B2 JP2005321613A JP2005321613A JP4847102B2 JP 4847102 B2 JP4847102 B2 JP 4847102B2 JP 2005321613 A JP2005321613 A JP 2005321613A JP 2005321613 A JP2005321613 A JP 2005321613A JP 4847102 B2 JP4847102 B2 JP 4847102B2
- Authority
- JP
- Japan
- Prior art keywords
- test program
- component
- random number
- syntax
- test
- 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 - Lifetime
Links
Images
Landscapes
- Stored Programmes (AREA)
- Debugging And Monitoring (AREA)
- Devices For Executing Special Programs (AREA)
Description
本発明は、乱数を用いてテストプログラムを自動で生成するコンピュータプログラムのテストプログラム生成方法に関する。 The present invention relates to a test program generation method for a computer program that automatically generates a test program using random numbers.
従来から、コンピュータプログラムのテストプログラムを生成する方法は各種提案されている。一般的には、検査担当者などがテストプログラム構文に沿ったテストプログラムを人手により作成するが、機械的に自動で作成する方法も提案されている。 Conventionally, various methods for generating a test program for a computer program have been proposed. Generally, an inspector or the like manually creates a test program according to the test program syntax, but a method of automatically creating a test program has also been proposed.
例えば、特許文献1には、コンパイラテストプログラムを自動生成するテストプログラム発生器が記載されている。このテストプログラム発生器200は、図2に示すように、構文に従って作成した単一文を複数行集めたプログラム記述の集まりを1つの要素(プログラムセル)とする。これらを集めたプログラムセル情報210と、集められた複数のプログラムセルからテストプログラムとして選択され易さを示すセル重み情報211をプログラムセル組合わせ器230に入力し、乱数発生器220により発生させた乱数を用いて、選択されたプログラムの集まりであるプログラムセルを組み合わせて、コンパイラのテストプログラム240を自動生成するというものである。集められた複数のプログラムセルに係るテストプログラムとして選択され易さを示すセル重み情報211は、以前にテスト対象プログラムの不良を発見できたプログラムセルや、不良を発見出来そうと予測されるプログラムセルに対して与えられる。集められたプログラムセルは乱数により選択する時の選択され易さを示すセル重みが重いほど選択されやすくなる。
For example,
また、特許文献2には、言語処理プログラム検証方式が記載されている。この技術は、用意された複数の構文生成規則から乱数を用いて規則を選択し、選択された規則を基にテストプログラムを生成するものである。また、特許文献3には、テストプログラム作成支援装置が記載されている。この装置は、既存のテストプログラムの文法網羅性を判定し、既存のテストプログラムから外れた文法を縮小文法仕様として出力し、その縮小文法仕様を基に追加テストプログラムを自動生成するものである。さらに、特許文献4には、テストプログラム作成支援装置が記載されている。この装置は、バッカス記法で記述された構文規則を基に文パターンを生成し、生成された文パターンを人手によって編集しテストプログラムとするものである。
例えばコンパイラの不良を摘出するためには、構文の組合せを考慮し多くの構文組合せテストを実施すること、およびテストデータとしてテストプログラムを多数作成しテストを実施することが必要である。従来のような人手によりテストプログラムを作成していたのでは、その工数は膨大であり充分なテストが実施できない恐れがあるため、上記のようなテストプログラムの自動生成法が提案されてきた。 For example, in order to identify a compiler defect, it is necessary to perform many syntax combination tests in consideration of syntax combinations, and to create a number of test programs as test data and perform tests. If a test program is created manually by a conventional method, the number of steps is enormous, and there is a possibility that a sufficient test cannot be performed. Therefore, an automatic test program generation method as described above has been proposed.
しかし、構文に従って作成した単一文を複数行集めたプログラム記述の集まりを要素として使用する場合には、プログラム文内の構文組合せは乱数等により機械的に決定するのではなく作成者のセンスに依存するため、その構文の組合せもプログラム文の作成者の考える域を越えた複雑な条件の記述については作成されない。 However, when a set of program descriptions that consist of multiple lines of a single statement created according to the syntax is used as an element, the syntax combination in the program statement is not determined mechanically by random numbers, but depends on the sense of the creator. Therefore, the syntax combination is not created for the description of complicated conditions beyond the scope of the creator of the program statement.
さらに、以前に不良を発見できたプログラム記述が集まった要素及び不良を発見出来そうと予測されるプログラム記述が集まった要素に対して、乱数を利用して要素を選択しテストプログラムを生成することができるが、この場合、選択され易さを示す重みが初期に設定された内容に固定されるため、構文の使用状況に関係なく常に同じプログラム記述の集まった要素が選択されやすくなり、新たな不良の発見が難しくなる。 In addition, a test program is generated by selecting an element using random numbers for an element for which a program description that has previously found a defect is gathered and an element for which a program description that is expected to be found is gathered. However, in this case, since the weight indicating the ease of selection is fixed to the initially set content, it is always easy to select elements with the same program description regardless of the usage status of the syntax. It becomes difficult to find defects.
また、あらかじめ用意した構文生成規則の中から、乱数により生成規則を選択しそれをもとにテストプログラムを生成する場合には、上記のように用意する構文生成規則はテストプログラム作成者の考える域を超えないため、同様な問題がある。さらに、用意した構文の情報を人手により選択することでテストプログラムを生成、あるいは文法網羅によるテストプログラムを生成する場合には、テストしたい単純な内容・項目については可能であるが、複雑な条件で発生する不良を検出することは困難である。 In addition, when generating a test program based on a random generation rule selected from among the syntax generation rules prepared in advance, the syntax generation rule prepared as described above is an area considered by the test program creator. There is a similar problem. Furthermore, when generating a test program by manually selecting the syntax information prepared, or generating a test program with grammar coverage, it is possible for simple contents / items to be tested, but under complicated conditions. It is difficult to detect defects that occur.
従って本発明の目的は、テスト対象プログラムに対し、複雑な条件で発生する不良の摘出が可能なテストプログラムを自動で生成するコンピュータプログラムのテストプログラム生成方法を提供することにある。 Accordingly, an object of the present invention is to provide a test program generation method for a computer program that automatically generates a test program capable of extracting defects generated under complicated conditions for a test target program.
上記目的は、テスト対象のコンピュータプログラムのテストプログラム生成用部品を複数集めたテストプログラム生成用部品群の中から乱数を用いて前記テストプログラム生成用部品の1つを第1部品として選択し確定する第1工程と、選択し確定した第(n−1)部品を構成する複数の第n部品の中から乱数を用いて前記第n部品の1つを選択し確定する工程を前記nを2から始めて順次大きくなる整数で繰返し行う第2工程と、前記選択し確定した第n部品がそれを構成する部品を持たない場合に前記選択し確定した第n部品の情報をテストプログラムの構成要素として選択し確定する第3工程とを備え、前記第1工程乃至第3工程を繰返し行うことにより得られた複数のテストプログラムの構成要素に基づいてテストプログラムを生成するコンピュータプログラムのテストプログラム生成方法により、達成される。 The object is to select and confirm one of the test program generation components as a first component using a random number from a group of test program generation components obtained by collecting a plurality of test program generation components of a computer program to be tested. The first step and the step of selecting and confirming one of the n-th components from among a plurality of n-th components constituting the selected (n-1) -th component by using a random number from n to 2 The second step, which is repeated for an integer that increases sequentially for the first time, and when the selected and confirmed n-th component does not have a component constituting it, the information on the selected and confirmed n-th component is selected as a component of the test program And generating a test program based on a plurality of test program components obtained by repeatedly performing the first to third steps. The test program generation method of a computer program that is achieved.
ここで、前記第1工程における前記第1部品の選択は、前記各テストプログラム生成用部品にそれぞれ対応して設けられた部品の選択され易さを示す重み情報を考慮して行うことができる。また、前記第2工程における前記第n部品の1つの選択は、前記各第n部品にそれぞれ対応して設けられた部品の選択され易さを示す重み情報を考慮して行うことができる。前記第2工程における前記第n部品の選択の際に、テストプログラムの構文上の制約条件が発生した場合、前記部品の選択され易さを示す重み情報が、前記制約条件に応じて変更され得る。また、前記テストプログラムを生成したときの乱数の乱数値を再現情報として保持し、前記テストプログラムを再現する場合に、前記再現情報として保持している前記乱数値を用いることができる。 Here, the selection of the first component in the first step can be performed in consideration of weight information indicating the ease of selection of components provided corresponding to the test program generation components. In addition, the selection of one of the n-th components in the second step can be performed in consideration of weight information indicating the ease of selection of components provided corresponding to the respective n-th components. When a constraint condition in the syntax of the test program occurs during the selection of the n-th component in the second step, weight information indicating the ease of selecting the component can be changed according to the constraint condition. . Further, when the test program is generated, the random number value of the random number is held as reproduction information, and when the test program is reproduced, the random number value held as the reproduction information can be used.
本発明によれば、テスト対象プログラムに対し、複雑な条件で発生する不良の摘出が可能なテストプログラムを自動で生成するコンピュータプログラムのテストプログラム生成方法を得ることができる。即ち、本発明では、テストプログラムの構文が要素単位で分割できるのを利用し、実測データ及び人手によって作成したテストプログラムでは見つけづらい複雑な条件で発生する不良の摘出が可能なテストプログラムを、効率的に自動で生成することができる。また、再テスト時には、再現情報として保持する乱数値を用いて、当該テストプログラムを再現することで、テスト対象プログラムのデバッグ効率及び品質の向上を図ることができる。このように、本発明のテストプログラム生成方法では、テストプログラムの構文を要素単位に分割し、乱数により選択された各構文の展開および使用状況にあった設定で部品として具現化していくことで、多種多様なテストに対応したテストプログラムを生成することができる。 ADVANTAGE OF THE INVENTION According to this invention, the test program production | generation method of the computer program which produces | generates automatically the test program which can extract the defect which generate | occur | produces on complicated conditions with respect to a test object program can be obtained. That is, the present invention utilizes the fact that the syntax of the test program can be divided into element units, and the test program capable of extracting defects that occur under complicated conditions that are difficult to find with actual measurement data and manually created test programs. Can be generated automatically. Further, at the time of retesting, the debugging efficiency and quality of the test target program can be improved by reproducing the test program using a random number value held as reproduction information. As described above, in the test program generation method of the present invention, the syntax of the test program is divided into element units, and each syntax selected by a random number is embodied as a component with settings corresponding to the development and usage status. A test program corresponding to various tests can be generated.
以下、本発明に係るコンピュータプログラムのテストプログラム生成方法の一実施例を図面を用いて説明する。
図1は、コンピュータプログラムのテストプログラムを自動生成するテストプログラム生成器100の構成例を示す図である。本実施例で示すテストプログラム生成器100は、例えばパーソナルコンピュータ上で動作するソフトウェアにより実現されるもので、図示のように、テストプログラム生成用部品群101と、テストプログラム生成用部品具現化部102と、乱数器103と、テストプログラム出力部104とを備える。テストプログラム生成用部品具現化部102は、部品重み情報105から部品の選択され易さを示す重み情報を得ることができる。テストプログラム出力部104は、生成したテストプログラムをテストプログラム106に出力するものである。乱数器103は、再現情報107との間で情報の授受を行う。ここでテストプログラムは例えばコンパイラのテストプログラムであるが、これに限定されない。
Hereinafter, an embodiment of a computer program test program generation method according to the present invention will be described with reference to the drawings.
FIG. 1 is a diagram illustrating a configuration example of a
ここでは、構文を構成する要素単位で分割したプログラム構文情報と、使用状況に応じて構文を定義した部品を乱数によって選択する際に使用する選択され易さを示す重みが定義されており、プログラム文(複数文)から変数の宣言文まで生成可能なように、プログラムとして実行できる構文が部品として登録されている。 Here, the program syntax information divided in units of elements constituting the syntax, and the weight indicating the ease of selection used when selecting a part for which the syntax is defined by a random number according to the usage status, are defined. A syntax that can be executed as a program is registered as a component so that statements from a plurality of statements to variable declaration statements can be generated.
図1において、テストプログラム生成用部品群101とは、生成するテストプログラムの構文を分割可能な要素単位で分割し、それを一つの部品として定義した部品の集まり(群)である。すなわち、分割可能な要素とは、構文を構成する各部品のことである。次に、この部品の例を図4〜図6を用いて説明する。
In FIG. 1, a test program
図4は、テストデータとなるテストプログラムのC言語構文例(バッカス記法)の一部を示す図である。本例は、C言語でexpressionの構文を要素で分割しバッカス記法で表現したものである。本図において、expression内の”assignment−expression”、および、”expression,assignment−expression”等が構文を構成する部品である。 FIG. 4 is a diagram showing a part of a C language syntax example (Bacchus notation) of a test program serving as test data. In this example, the expression syntax in C language is divided into elements and expressed in Bacchus notation. In this figure, “assignment-expression” in the expression, “expression, assignment-expression”, and the like are components constituting the syntax.
図5は、テストデータとなるテストプログラムのC言語構文例(構文木)の一部を示す図である。本例は、C言語でexpressionの構文を要素で分割し木構造で表現したものである。本図において、expressionにつながる”assignment−expression”、および、”expression,assignment−expression”等が構文を構成する部品である。 FIG. 5 is a diagram illustrating a part of a C language syntax example (syntax tree) of a test program serving as test data. In this example, the expression syntax in C language is divided into elements and expressed in a tree structure. In this figure, “assignment-expression”, “expression, assignment-expression”, etc. that lead to expression are components that constitute the syntax.
図4および図5に示す構文例はともに、expressionがassignment−expression、またはexpression,assignment−expressionのいずれかの構文を選択するように定義されている。しかし、構文としては単純でも、それを使用する場面は複数あり、その意味合いも異なっている。 Both the syntax examples shown in FIGS. 4 and 5 are defined such that expression selects one of the syntaxes of assignment-expression or expression, assignment-expression. However, even though the syntax is simple, there are several situations where it is used, and the meanings are different.
図6は、テストデータとなるテストプログラムのC言語構文例(バッカス記法)の一部を示す図である。本例は、C言語でforの構文を要素で分割しバッカス記法で表現したものである。ここで、for構文も部品であり、それを構成しているexpression群もfor構文を構成する部品である。このfor構文について、forの第1expression、第2expression、および第3expressionは、全てexpressionと表現されているが、それぞれ初期化用の代入文、判定用の比較文、および加減算文というように意味が異なっており、そのためテストプログラムの自動生成を考慮した場合、その状況に合った構文情報を多数用意する必要がある。 FIG. 6 is a diagram showing a part of a C language syntax example (Bacchus notation) of a test program serving as test data. In this example, the syntax of “for” in C language is divided into elements and expressed in Bacchus notation. Here, the for syntax is also a part, and the expression group constituting the for syntax is also a part constituting the for syntax. Regarding the for syntax, the first expression, the second expression, and the third expression of the for are all expressed as expressions, but have different meanings such as an assignment statement for initialization, a comparison statement for determination, and an addition / subtraction statement, respectively. Therefore, when automatic generation of test programs is considered, it is necessary to prepare a lot of syntax information suitable for the situation.
そこで、構文を要素単位に分割し、使用状況に応じて選択される構文と処理を部品に定義することにより意味のあるテストプログラムが生成可能であり、かつ構文の組合せ情報数を増やすことなく、乱数による部品選択により構文の組合せを決定していくため、多くのテストプログラムを生成すれば構文の組合せも自動で増えていくことになり、人手を介在させることなく意味のあるテストプログラムが生成でき、かつ構文組合せのテストプログラムも生成できる。 Therefore, it is possible to generate a meaningful test program by dividing the syntax into element units and defining the syntax and processing selected according to the usage status as parts, and without increasing the number of syntax combination information, Since the combination of syntax is determined by selecting parts using random numbers, the number of combinations of syntax will automatically increase if many test programs are generated, and a meaningful test program can be generated without human intervention. And a test program of syntax combination can be generated.
図3は、テストプログラム生成器100で処理するテストプログラム生成時の全体フローを示す図である。まず、ステップ301にて、再現情報指示の有無を検査する。ここで、再現情報とは、乱数器103より出力されるテストプログラムの再現情報107のことである。これが「なし」の場合、後述のステップ303に移行する。また「あり」の場合、ステップ302にて、再現情報設定処理を行う。この再現情報設定処理302では、テストプログラムを生成する初期段階にて、乱数器103より出力されるテストプログラムの再現情報107を乱数器103に指定することで、該当するテストプログラムの再現が可能となる。この再現情報設定処理302(テストプログラムの再現)については、後で図11を用いて詳述する。
FIG. 3 is a diagram showing an overall flow when generating a test program to be processed by the
次に、ステップ303にて、部品重み指示の有無を検査する。これが「なし」の場合、後述のステップ305に移行する。また「あり」の場合、ステップ304にて、部品重み情報設定処理を行う。この部品重み情報設定処理302では、部品重み情報105において定義されている要素単位に分割した構文の使用状況に合った選択部品別の重み割合を、該当する部品に対して設定する。この部品重み情報設定処理304については、後で図10を用いて詳述する。
Next, in
続いて、ステップ305にて、テストプログラム生成用部品具現化処理を行う。この部品具現化処理305では、テストプログラム生成用部品具現化部102において、テストプログラム生成用部品群101から乱数器103が発生する乱数により選択した部品の具現化を行う。ここで、具現化とは、選択した部品に実体を持たせることでその部品を確定することをいう。実体を持たせるとは、部品の使用状況に特化した内容で動的にメモリを確保することをいう。具現化(確定)された部品は更にそれを構成する部品に何回か展開可能である。展開可能の間、この具現化処理を繰返し行う。具現化された部品がそれ以上展開できなくなった時点で具現化処理を終了する。そして、この末端となる具現化された部品(末端部品)の情報(型、定数、変数、演算子等)を構文の使用状況により選択し確定する。この末端部品の情報がテストプログラムを構成する。以上の処理を次々に行うことにより、テストプログラム出力処理306によりテストプログラムを出力する。上記テストプログラム生成用部品具現化処理305について、以下図7〜図9を用いて説明する。
Subsequently, in
図7は、テストプログラム生成用部品具現化処理(具現化処理終了フラグのOFFの場合)の一例を説明するための図である。本例は、構文expressionをテストプログラム生成用部品701として登録したものである。expression部品701は、乱数により選択する具現化対象部品702別に、構文の使用状況に合わせて与えられるexpression部品701に対する展開指示703単位に、乱数により選択され易さを示す具現化対象部品の重みの割合(重み情報)が定義されている。
FIG. 7 is a diagram for explaining an example of a test program generation component realization process (when the realization process end flag is OFF). In this example, the syntax expression is registered as a test
expression部品701が持つ構文の部品(具現化対象部品)として、図7に示すように、assignment−expression704,およびComma−Exp705がある。選択対象となるこれらの部品は、具現化処理にて実体を持つまでは単なる構文の情報に過ぎない。また、Comma−Exp705は構文上存在する定義ではないが、”expression,assignment−expression”は通常カンマ演算子と呼ばれており、選択される部品単位として”expression,assignment−expression”を一つにまとめて便宜上使用しているものである。以降、構文を要素単位に分割した部品の具現化処理について説明する。
As parts of the syntax (implementation target parts) of the
図8は、部品の具現化処理フローの一例を示す図である。以下、本図と図7にそって部品の具現化処理について説明する。図7に示すように、expression部品701に対し、展開指示として「for第1式(代入文の重み)」707が与えられた場合、まず図8のステップ801にて、具現化処理で構文の制約条件が発生したかどうかを検査する。その結果、制約条件が未発生の場合は、ステップ803に移行する。一方、制約条件が発生の場合は、ステップ802にて、構文制約条件に沿った部品の重み割合に変更する。次に、ステップ803にて、具現化処理終了フラグのON,OFFの検査、即ち具現化処理終了の判定を実施する。具現化処理終了の判定とは、構文に沿って具現化されてきた部品について、これ以上の選択要素の存在有無を確認するものであり、expression部品701に定義されている具現化処理終了フラグ706のOFF/ONがその情報を示す。
FIG. 8 is a diagram illustrating an example of a component realization process flow. Hereinafter, the component realization process will be described with reference to FIGS. As shown in FIG. 7, when “for first expression (assignment statement weight)” 707 is given as an expansion instruction to the
図7の例では、具現化処理終了フラグ706がOFFと表示されており、これは具現化処理終了でないことを示す。具現化処理終了でない場合、図8のステップ804にて、与えられた展開指示別で具現化対象部品別に設定されている重み割合を取得する。図7の例の場合、太点線で囲まれたfor第1式部分708がそれに該当する。続いて、ステップ805にて、乱数器より発生した乱数と取得した重み割合を元に具現化する部品を選択し、ステップ806にて、選択した部品に実体を持たせることで部品を具現化する(図7のブロック709)。図7では、assignment−expression704が乱数により選択され具現化された部品に該当する。そして、ステップ807にて、具現した部品assignment−expression704に対して、対応する展開指示を与え(図7の矢印710)、以降の構文を決定するための部品の具現化処理を実行する。この具現化処理は繰返し行われる。その結果、具現化処理終了フラグが“ON”となった場合を次に説明する。
In the example of FIG. 7, the realization
図9は、テストプログラム生成用部品具現化処理(具現化処理終了フラグのONの場合)の一例を説明するための図である。部品の具現化処理を繰返し行った結果、該当する部品内の具現化処理フラグが“ON”となった場合、該当する部品は、構文の末端部品であることを示す。図9において、assignment_operator901は、代入文の代入演算子構文の部品である。assignment_operator901も、先に説明したexpression701と同様に、乱数により選択する具現化対象部品902別に、構文の使用状況に合わせて与えられるassignment_operator部品901に対する展開指示903単位に、乱数により選択され易さを示す具現化対象部品の重みの割合が定義されている。代入演算子構文では、構文の使用状況により使用可能な演算子は制限されるが、代入演算子以降の構文の展開はない。つまり、具現化処理終了フラグが“ON”の場合は、末端となる具現化部品の情報(型、定数、変数、演算子等)を構文の使用状況により選択し確定し、そして以降の具現処理を行わず、呼出元に戻ることになる。すなわち、図8のステップ808にて、末端となる具現化部品(末端部品)の情報(型、定数、変数、演算子等)を構文の使用状況により選択し確定する。これがテストプログラムの構成要素となる。次に、以上の具現化処理に基づいて行われるテストプログラムの生成方法を説明する。
FIG. 9 is a diagram for explaining an example of a test program generation component realization process (when the realization process end flag is ON). As a result of repetitive component realization processing, if the realization processing flag in the corresponding component is “ON”, this indicates that the corresponding component is a terminal component of the syntax. In FIG. 9,
図12は、テストプログラム生成用部品の具現化処理によるテストプログラム生成方法の一例を示す図である。図示のように、まず、テストプログラム生成用部品群の中から構文の基礎となる部品109を選択し確定する。次に、この部品109に対して具現すべき部品をテストプログラム生成用部品群の中から乱数を用いて部品110を選択し具現化(確定)する。このとき、部品110では代入文の構文が確定されたとして以後説明する。まず代入文を構成するために、テストプログラム生成用部品群の中から乱数を用いてテストプログラム生成用部品の1つを部品111として選択し確定する。次に、この部品111を構成する部品の1つを選択し具現化(確定)することで具現化部品112を得る。同様にして、この部品112を構成する部品の1つを乱数を用いて選択し具現化(確定)することで具現化部品113を得る。さらに同様にして、順次、具現化部品114・・・11aを得る。この場合、構成部品を持たない部品11aが末端部品(最終要素)となる。その末端部品の情報(型、定数、変数、演算子等)を構文の使用状況により選択し確定する。ここで選択し確定した末端部品の情報は本図では例えば「A」である。これがテストプログラムの構成要素となる。続いて、元に戻り、テストプログラム生成用部品群の中から乱数を用いてテストプログラム生成用部品の1つを部品112として選択し確定し、上記と同様にして具現化部品122、123、124・・・12bを得る。この場合、構成部品を持たない部品12bが末端部品(最終要素)となる。その末端部品の情報(型、定数、変数、演算子等)を構文の使用状況により選択し確定する。ここで選択し確定した末端部品の情報は本図では例えば「=」である。これがテストプログラムの構成要素となる。本例では、このようにしてテストプログラムの構成要素を次々と選択し確定し、これに基づいてテストプログラムを生成する。以上の工程を一般化すると次のようになる。すなわち、テスト対象のコンピュータプログラムのテストプログラム生成用部品を複数集めたテストプログラム生成用部品群の中から乱数を用いてテストプログラム生成用部品の1つを第1部品として選択し確定する第1工程と、選択し確定した第(n−1)部品を構成する複数の第n部品の中から乱数を用いて第n部品の1つを選択し確定する工程をnを2から始めて順次大きくなる整数で繰返し行う第2工程と、前記選択し確定した第n部品がそれを構成する部品を持たない場合に前記選択し確定した第n部品の情報をテストプログラムの構成要素として選択し確定する第3工程とを備え、第1工程乃至第3工程を繰返し行うことにより得られた複数のテストプログラムの構成要素に基づいてテストプログラムを生成するものである。
FIG. 12 is a diagram illustrating an example of a test program generation method based on a process for realizing a test program generation component. As shown in the figure, first, a
以上のテストプログラムの生成において、選択部品の重み割合変更について説明する。図9には、制約事項による選択部品重み割合変更の一例が示されている。部品の具現化処理において、確定した構文により以降の構文確定に制約が発生する場合がある。例えば、代入先の変数型がポインタ型と確定された場合(図9のブロック905)、部品assignment_operator901に対してポインタ代入式のみ(=,+=,−=のみ可)という構文制約条件が発生(図9のブロック906)する。既に具現化されているassignment_operator901には「代入式(all)」の展開指示907が既に指示されており、この重み割合のままでは、構文の制約に当てはまらない構文が選択されてしまうことになる。そこで、この場合、図8のステップ801からステップ802に移行する。このステップ802にて、assignment_operator901に与えられた展開指示907の具現化対象部品の重み割合を、構文制約条件に沿った具現化部品の重み割合に変更する(図9の太点線908)する。これにより、以降の部品選択処理において、構文制約外の部品が選択されることをなくすることができる。
In the above test program generation, the weight ratio change of the selected component will be described. FIG. 9 shows an example of changing the selected component weight ratio due to restrictions. In the component realization process, there are cases where restrictions are imposed on the subsequent syntax determination due to the determined syntax. For example, when the substitution target variable type is determined to be a pointer type (block 905 in FIG. 9), a syntax constraint condition that only a pointer substitution expression (=, + =,-= only possible) occurs for the component assignment_operator 901 (
図10は、部品重み情報を指定した場合の選択部品重み割合変更の一例を示す図である。図示のように、部品重み情報1001を指定した場合(図3のステップ303で指示ありの場合)、選択部品の重み変更は次のようにして行われる。すなわち、部品重み情報1001には、該当する具現化部品1002とそれに与えられる展開指示1003別に、具現化対象部品単位の選択され易さを示す重み割合1004が定義されている。テストプログラム生成時、具現化用部品重み指示がされていた場合に、具現化用部品重み情報設定処理1005(図3のステップ304)では、指示された部品重み情報1001を展開し、該当する具現化部品expression1006の展開指示部分情報1007を、展開した内容1008に変更する。これにより、以降のテストプログラム生成用部品具現処理(図3のステップ305)では、乱数により選択される具現化対象部品の重み割合が、部品重み情報1001で指示された内容に変更される。これにより、使用者が期待する構文の部品が選択されやすくなる。
FIG. 10 is a diagram illustrating an example of changing the selected component weight ratio when the component weight information is designated. As shown in the figure, when the
図11は、乱数器および乱数利用処理の一例を説明するための図である。以下、本図に沿って、テストプログラムの再現について説明する。図1のテストプログラム生成器100では、本図に示す乱数利用処理1110が行われる。乱数利用処理1110は、部品選択による具現化処理1103、変数の再利用処理1104、数値処理1105など構文・数値等を決定する処理毎に、乱数器1101を実行し、乱数値1102を発生させ、その値を基に部品の選択、変数再利用、数値設定を決定している。
FIG. 11 is a diagram for explaining an example of a random number generator and random number use processing. Hereinafter, the reproduction of the test program will be described with reference to FIG. In the
乱数器1101は、乱数基準値設定処理1106、乱数基準値1107、および乱数値発生器1108を備える。乱数基準値設定処理1106は、乱数値発生器1108で使用する最初の乱数基準値1107を生成して設定する。この最初に設定する基準値は実行毎にユニークとなるように生成される。また、乱数基準値1107の内容は、再現情報1109として外部に出力される。乱数値発生器1108は、乱数器1101に乱数発生の依頼があると、乱数基準値1107を入力し、乱数値1102を出力する。また、その時に生成した乱数値を乱数基準値1107に設定し、次回に乱数値発生の基準値にする。これにより、毎回設定されるユニークな値の乱数基準値1107を自動で設定することで、次回の乱数値生成を可能としている。この乱数器1101では、乱数基準値1107を基に乱数値を発生させるため、乱数器を使用するときは必ず乱数基準値1107を毎回ユニークにする必要がある。また、最初に設定する乱数基準値1107を前回と同じにすると、以降の乱数器1101から生成される乱数値1102は、前に生成した内容と同一になる。これを利用し乱数基準値設定処理1106で出力した再現情報1109をテストプログラム生成時に乱数基準値設定処理1106を介して乱数基準値1107に設定することで、乱数器1101から生成される乱数値が前回と同一なため選択される部品・具現処理も同じものとなり、前回生成したテストプログラムの再現が可能となる。また、再現情報1109は、乱数基準値設定処理1106が出力した内容だけでなく、テストプログラム生成器を実行させるときに使用者が設定可能である。
テストプログラム生成器100に関する内容は、テストプログラムの構文が要素単位に分割可能なもので部品化することが出来るものであれば他のテストプログラム生成方式でも使用可能である。また、コンピュータプログラムの検査システムは、例えば特許文献1のコンパイラ検査システムと同様に構成することができる。
The
The content related to the
本発明は、乱数を用いてテストプログラムを自動で生成するコンピュータプログラムのテストプログラム生成方法に関するものであり、産業上の利用可能性を有する。 The present invention relates to a test program generation method for a computer program that automatically generates a test program using random numbers, and has industrial applicability.
100 テストプログラム生成器
101 テストプログラム生成用部品群
102 テストプログラム生成用部品具現化部
103 乱数器
104 テストプログラム出力部
105 部品重み情報
106 テストプログラム
107 再現情報
301 再現情報指示
302 再現情報設定処理
303 テストプログラム生成用部品重み指示
304 部品重み情報設定処理
305 テストプログラム生成用部品具現化処理
306 テストプログラム出力処理
701 expression部品
702 expressionが持つ具現化対象部品
703 具現されたexpressionに与えられる展開指示
704 assignment−expression部品
705 Comma−Exp部品
706 expressionの具現化処理終了フラグ
707 expressionに与えられた展開指示(for第1式)
708 for第1式時の選択部品重み割合
709 乱数による部品の選択
710 乱数により選択した部品の具現化処理
801 構文制約条件
802 構文制約発生時の処理
803 具現化処理終了フラグ
804 展開指示別重み割合取得
805 乱数による部品選択
806 選択部品の具現化
807 部品に対する具現化処理
808 具現化処理終了時の処理
901 assignment_operator部品
902 assignment_operatorが持つ具現化対象部品
903 assignment_operatorに与えられる展開指示
904 assignment_operatorの具現化処理終了フラグ
905 構文の制約発生条件例
906 発生した構文制約条件例
907 assignment_operatorに与えられる展開指示
908 構文制約条件により変更された展開指示別の選択部品重み割合
1001 部品重み情報
1002 具現化部品
1003 具現化部品別展開指示
1004 具現化対象部品重み割合
1005 具現化用部品重み情報設定処理
1006 expression部品
1007 expressionの該当展開指示
1008 変更された具現化対象部品の重み割合
1110 乱数利用処理
1101 乱数器
1102 乱数値
1103 乱数を利用する部品の具現化処理
1104 乱数を利用する変数再利用処理
1105 乱数を利用する数値処理
1106 乱数基準値設定処理
1107 乱数基準値
1108 乱数値発生器
1109 再現情報
100
708 for Selected Formula Weight Ratio in
Claims (5)
Programming language syntax for describing a test program generated by dividing the at and the syntax capable division element by element, the test program for generating a collection of components that define it as one test program generation parts A first step of selecting and confirming one of the test program generation parts as a first part from a part group using a random number, and a plurality of nth parts constituting the selected and confirmed (n-1) part. A second step in which a step of selecting and confirming one of the n-th components from a group of test program generation components for the component by using a random number is repeated with an integer that starts from 2 and increases sequentially, and the selection If the confirmed n-th part does not have a part constituting it, the information on the selected and confirmed n-th part is selected and confirmed as a component of the test program. A test program generating method for a computer program, comprising: a third step, wherein a test program is generated based on a plurality of test program components obtained by repeating the first to third steps .
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| JP2005321613A JP4847102B2 (en) | 2005-11-04 | 2005-11-04 | Test program generation method for computer program |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| JP2005321613A JP4847102B2 (en) | 2005-11-04 | 2005-11-04 | Test program generation method for computer program |
Publications (2)
| Publication Number | Publication Date |
|---|---|
| JP2007128372A JP2007128372A (en) | 2007-05-24 |
| JP4847102B2 true JP4847102B2 (en) | 2011-12-28 |
Family
ID=38150965
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| JP2005321613A Expired - Lifetime JP4847102B2 (en) | 2005-11-04 | 2005-11-04 | Test program generation method for computer program |
Country Status (1)
| Country | Link |
|---|---|
| JP (1) | JP4847102B2 (en) |
Families Citing this family (1)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| JP6921976B2 (en) * | 2017-10-20 | 2021-08-18 | 株式会社日立製作所 | Diagnostic model parts reuse support device |
Family Cites Families (3)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| JPH01155438A (en) * | 1987-12-12 | 1989-06-19 | Hitachi Ltd | Compiler test method |
| JPH01220044A (en) * | 1988-02-29 | 1989-09-01 | Fujitsu Ltd | Language processing program testing system |
| JPH1131090A (en) * | 1997-07-14 | 1999-02-02 | Fujitsu Ltd | Medium recording processor system and selection program |
-
2005
- 2005-11-04 JP JP2005321613A patent/JP4847102B2/en not_active Expired - Lifetime
Also Published As
| Publication number | Publication date |
|---|---|
| JP2007128372A (en) | 2007-05-24 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| JP6973846B2 (en) | Systems and methods for automated test case expansion for coverage-based design models | |
| JP5874891B2 (en) | Program test apparatus, program test method, and program | |
| CN111679979A (en) | Destructive testing method and device | |
| EP3264274A1 (en) | Input discovery for unknown program binaries | |
| JP6310527B1 (en) | Object analysis apparatus, object analysis method, and program | |
| KR20190094779A (en) | Automatically Generate Device for PLC Instruction Compiler Test-Case | |
| JP4847102B2 (en) | Test program generation method for computer program | |
| JP2011191985A (en) | Symbolic execution support program, method and device | |
| JP2010102620A (en) | User operation scenario generating device, method and program | |
| JP6723483B2 (en) | Test case generation device, test case generation method, and test case generation program | |
| JP2012181666A (en) | Information processing device, information processing method and information processing program | |
| JP2010250669A (en) | Test case generation device, object inspection device, and program | |
| JP2001273169A (en) | Program test specification generator | |
| JP6547345B2 (en) | Test case generation program, test case generation method and test case generation apparatus | |
| JP5811978B2 (en) | Test case generation apparatus and test case generation method for model-based control apparatus | |
| CN115114136A (en) | Test data generation method and device, electronic equipment and program product | |
| US10579761B1 (en) | Method and system for reconstructing a graph presentation of a previously executed verification test | |
| JP2020098413A (en) | Test support device, test support method and computer program | |
| WO2004068347A1 (en) | Method and apparatus for categorising test scripts | |
| JP2005316710A (en) | Software test support device | |
| CN112527662A (en) | Test script generation method and device | |
| JP2012059202A (en) | Test case generation device, test case generation method and test case generation program | |
| JP2006259820A (en) | Failure detection improvement device, failure detection improvement program, failure detection improvement method | |
| CN112527574A (en) | Processor testing method, device, equipment and readable storage medium | |
| JP7059827B2 (en) | Source code generator |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| A621 | Written request for application examination |
Free format text: JAPANESE INTERMEDIATE CODE: A621 Effective date: 20081023 |
|
| A977 | Report on retrieval |
Free format text: JAPANESE INTERMEDIATE CODE: A971007 Effective date: 20100721 |
|
| A131 | Notification of reasons for refusal |
Free format text: JAPANESE INTERMEDIATE CODE: A131 Effective date: 20100824 |
|
| A521 | Request for written amendment filed |
Free format text: JAPANESE INTERMEDIATE CODE: A523 Effective date: 20101022 |
|
| A131 | Notification of reasons for refusal |
Free format text: JAPANESE INTERMEDIATE CODE: A131 Effective date: 20110215 |
|
| A521 | Request for written amendment filed |
Free format text: JAPANESE INTERMEDIATE CODE: A523 Effective date: 20110415 |
|
| 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: 20111011 |
|
| A01 | Written decision to grant a patent or to grant a registration (utility model) |
Free format text: JAPANESE INTERMEDIATE CODE: A01 |
|
| A61 | First payment of annual fees (during grant procedure) |
Free format text: JAPANESE INTERMEDIATE CODE: A61 Effective date: 20111013 |
|
| FPAY | Renewal fee payment (event date is renewal date of database) |
Free format text: PAYMENT UNTIL: 20141021 Year of fee payment: 3 |
|
| R150 | Certificate of patent or registration of utility model |
Ref document number: 4847102 Country of ref document: JP Free format text: JAPANESE INTERMEDIATE CODE: R150 Free format text: JAPANESE INTERMEDIATE CODE: R150 |
|
| S531 | Written request for registration of change of domicile |
Free format text: JAPANESE INTERMEDIATE CODE: R313531 |
|
| S533 | Written request for registration of change of name |
Free format text: JAPANESE INTERMEDIATE CODE: R313533 |
|
| R350 | Written notification of registration of transfer |
Free format text: JAPANESE INTERMEDIATE CODE: R350 |
|
| R250 | Receipt of annual fees |
Free format text: JAPANESE INTERMEDIATE CODE: R250 |
|
| R250 | Receipt of annual fees |
Free format text: JAPANESE INTERMEDIATE CODE: R250 |
|
| R250 | Receipt of annual fees |
Free format text: JAPANESE INTERMEDIATE CODE: R250 |
|
| R250 | Receipt of annual fees |
Free format text: JAPANESE INTERMEDIATE CODE: R250 |
|
| R250 | Receipt of annual fees |
Free format text: JAPANESE INTERMEDIATE CODE: R250 |
|
| R250 | Receipt of annual fees |
Free format text: JAPANESE INTERMEDIATE CODE: R250 |
|
| R250 | Receipt of annual fees |
Free format text: JAPANESE INTERMEDIATE CODE: R250 |
|
| R250 | Receipt of annual fees |
Free format text: JAPANESE INTERMEDIATE CODE: R250 |
|
| R250 | Receipt of annual fees |
Free format text: JAPANESE INTERMEDIATE CODE: R250 |
|
| R250 | Receipt of annual fees |
Free format text: JAPANESE INTERMEDIATE CODE: R250 |
|
| R250 | Receipt of annual fees |
Free format text: JAPANESE INTERMEDIATE CODE: R250 |