JP2018124654A - Determination program and determination method - Google Patents
Determination program and determination method Download PDFInfo
- Publication number
- JP2018124654A JP2018124654A JP2017014504A JP2017014504A JP2018124654A JP 2018124654 A JP2018124654 A JP 2018124654A JP 2017014504 A JP2017014504 A JP 2017014504A JP 2017014504 A JP2017014504 A JP 2017014504A JP 2018124654 A JP2018124654 A JP 2018124654A
- Authority
- JP
- Japan
- Prior art keywords
- combination
- variable
- conditional expression
- unit
- source code
- 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.)
- Pending
Links
Images
Landscapes
- Debugging And Monitoring (AREA)
Abstract
Description
本発明は、決定プログラムおよび決定方法に関する。 The present invention relates to a determination program and a determination method.
従来、作成したソースコードが正しく動作するか否かを検査する方法として、ソースコードのユニットごとに検査する単体検査が知られている。単体検査では、例えばテストデータを用いて検査対象であるソースコードをテスト項目ごとに実行することで、ソースコードの欠陥を検査する。 Conventionally, as a method for inspecting whether or not a created source code operates correctly, single unit inspection for inspecting each unit of source code is known. In the unit inspection, for example, the source code to be inspected is executed for each test item using the test data to inspect the source code for defects.
例えば、ソースコードで行うテスト項目を抽出する方法として、当該ソースコードの条件分岐を抽出し、抽出した条件分岐の正否両条件をプログラム入力変数のみで表した式に分解する方法が知られている。 For example, as a method for extracting test items to be performed in source code, a method is known in which a conditional branch of the source code is extracted, and both correct and incorrect conditions of the extracted conditional branch are decomposed into expressions representing only program input variables. .
しかしながら、従来の方法では条件分岐の正否両条件をプログラム入力変数で表しているため、プログラム入力変数に代入する値をユーザが設定する必要がある。例えばソースコードの規模が大きくなり、ユーザが設定すべき変数の数が増えるほど、ユーザの作業量が増えてしまう。 However, in the conventional method, both right and wrong conditions of the conditional branch are represented by program input variables, and therefore the user needs to set a value to be substituted for the program input variable. For example, as the size of the source code increases and the number of variables to be set by the user increases, the amount of work for the user increases.
本発明は、上記に鑑みてなされたものであって、ユーザの作業量を削減することができる決定プログラムおよび決定方法を提供することを目的とする。 The present invention has been made in view of the above, and an object of the present invention is to provide a determination program and a determination method that can reduce the amount of work of a user.
上述した課題を解決し、目的を達成するために、本発明に係る決定プログラムは、単体検査の対象であるソースコードを読み込む手順をコンピュータに実行させる。更に決定プログラムは、ソースコードに含まれる条件分岐を抽出する手順をコンピュータに実行させる。更に決定プログラムは、条件分岐の条件式に含まれる変数の取り得る値と、条件式の判定結果と、の組み合わせに基づき、単体検査を行う場合に代入する変数の設定値を決定する手順をコンピュータに実行させる。更に決定プログラムは、決定した設定値を出力する手順をコンピュータに実行させる。 In order to solve the above-described problems and achieve the object, the determination program according to the present invention causes a computer to execute a procedure for reading a source code that is an object of a unit inspection. Further, the determination program causes the computer to execute a procedure for extracting a conditional branch included in the source code. Further, the determination program uses a computer to determine a setting value of a variable to be substituted when performing a single inspection based on a combination of a possible value of a variable included in the conditional expression of the conditional branch and a determination result of the conditional expression. To run. Further, the determination program causes the computer to execute a procedure for outputting the determined setting value.
本発明によれば、ユーザの作業量を削減することができる。 According to the present invention, it is possible to reduce a user's workload.
以下、添付図面を参照して、本願の開示する決定プログラムおよび決定方法の実施形態を詳細に説明する。なお、この実施形態により本発明が限定されるものではない。 Hereinafter, embodiments of a determination program and a determination method disclosed in the present application will be described in detail with reference to the accompanying drawings. In addition, this invention is not limited by this embodiment.
(1.決定方法)
図1を用いて、実施形態に係る決定方法について説明する。図1は、実施形態に係る決定方法を説明する図である。実施形態に係る決定方法は、ソースコードの単体検査を行う場合にソースコードに含まれる変数に代入(設定)する設定値を決定する方法であり、例えば単体検査を行う検査装置で実行されるものとする。
(1. Determination method)
The determination method according to the embodiment will be described with reference to FIG. FIG. 1 is a diagram illustrating a determination method according to the embodiment. The determination method according to the embodiment is a method for determining a setting value to be assigned (set) to a variable included in the source code when performing a single inspection of the source code. And
ここで、ソースコードの単体検査とは、テストデータを用いてモジュールごとにソースコードを実行することで、ソースコードに不備がないか確認する検査のことである。単体検査には、例えば条件分岐で正しく処理が分岐するか否かを確認する検査が含まれる。かかる検査では、条件分岐の条件式に含まれる変数に取り得る値を設定することで、正しく条件分岐が行われるか否かが検査される。 Here, the single inspection of the source code is an inspection for checking whether the source code is incomplete by executing the source code for each module using the test data. The single inspection includes, for example, an inspection for confirming whether or not the process branches correctly in the conditional branch. In such a check, it is checked whether or not the conditional branch is correctly performed by setting a possible value for the variable included in the conditional expression of the conditional branch.
したがって、テストデータには、例えば条件式に含まれる変数の設定値が含まれる。変数が複数の設定値を取り得る場合、取り得る全ての設定値に対して単体検査が行われるように、テストデータを生成する。 Therefore, the test data includes, for example, set values of variables included in the conditional expression. When a variable can take a plurality of setting values, test data is generated so that a single inspection is performed for all possible setting values.
このとき、条件式に複数の変数が含まれる場合は、複数の変数の取り得る値を組み合わせてテストデータを生成する。したがって、例えば、ソースコードの規模が大きくなり、ソースコードに含まれる変数の数が増加すると、複数の変数の設定値の組み合わせ数が増加する。そのため、検査を行う人間(ユーザ)がテストデータを生成すると、作業量が増加するとともに、かかる組み合わせに漏れが発生してしまう可能性がある。 At this time, when a plurality of variables are included in the conditional expression, test data is generated by combining possible values of the plurality of variables. Therefore, for example, when the size of the source code increases and the number of variables included in the source code increases, the number of combinations of setting values of a plurality of variables increases. For this reason, when a person (user) who performs inspection generates test data, the amount of work increases and there is a possibility that such a combination may be leaked.
そこで、実施形態に係る決定方法では、ソースコード中の条件分岐の条件式に含まれる変数を抽出し、抽出した変数の取り得る値の組み合わせに基づいて、テストデータを生成するようにした。 Therefore, in the determination method according to the embodiment, variables included in the conditional expression of the conditional branch in the source code are extracted, and test data is generated based on combinations of values that can be taken by the extracted variables.
これにより、検査装置が自動でテストデータを生成することができ、ユーザの作業量を削減することができるとともに、単体検査の漏れを抑制することができる。 As a result, the inspection apparatus can automatically generate test data, the amount of work for the user can be reduced, and leakage of a single inspection can be suppressed.
以下、図1を用いて、テストデータとして変数の設定値を決定する決定方法について具体的に説明する。 Hereinafter, a determination method for determining a set value of a variable as test data will be specifically described with reference to FIG.
図1に示すように、検査装置は、まず検査対象であるC言語で記載されたソースコードを読み込む(ステップS1)。図1では、プリプロセッサ指令の条件分岐を示す「#if」を含むソースコード31を読み込むものとする。
As shown in FIG. 1, the inspection apparatus first reads a source code written in C language to be inspected (step S1). In FIG. 1, it is assumed that a
次に、検査装置は、ソースコード31に含まれる条件分岐を抽出する(ステップS2)。図1の例では、「#if (A==USE)&&(B==USE)」を抽出する。 Next, the inspection device extracts a conditional branch included in the source code 31 (step S2). In the example of FIG. 1, “#if (A == USE) && (B == USE)” is extracted.
検査装置は、抽出した条件分岐の条件式の取り得る値と条件式の判定結果との組み合わせに基づいて条件式に含まれる変数の設定値を決定する(ステップS3)。 The inspection apparatus determines the set value of the variable included in the conditional expression based on the combination of the possible value of the extracted conditional expression of the conditional branch and the determination result of the conditional expression (step S3).
図1に示す条件分岐の条件式「(A==USE)&&(B==USE)」は、2つの条件式の論理積で表されている。ここで、条件分岐の条件式を条件式cと記載する。また、条件式cの論理演算子「&&」の左辺の条件式「A==USE」を条件式a、右辺の条件式「B==USE」を条件式bと記載する。また、条件式aには変数Aが含まれており、条件式bには変数Bが含まれている。なお、ここでは、変数A、Bの取り得る値が「USE」、「NOT」、「OTHER」の3つであるとして説明する。 The conditional expression “(A == USE) && (B == USE)” of the conditional branch shown in FIG. 1 is expressed by a logical product of two conditional expressions. Here, the conditional expression for conditional branching is referred to as conditional expression c. Also, the conditional expression “A == USE” on the left side of the logical operator “&&” of the conditional expression c is referred to as a conditional expression a, and the conditional expression “B == USE” on the right side is referred to as a conditional expression b. The conditional expression a includes a variable A, and the conditional expression b includes a variable B. Here, description will be made assuming that there are three possible values of the variables A and B: “USE”, “NOT”, and “OTHER”.
検査装置は、条件式cに含まれる変数A、Bの設定値を決定するために、まず変数A、Bの取り得る値および各条件式a〜cの判定結果の組み合わせテーブル33aを生成する。例えば、変数Aが「USE」、変数Bが「USE」である場合、条件式a(A==USE)の判定結果はTRUE(図1では「T」と記載)になり、条件式b(B==USE)の判定結果もTRUEになる。したがって、条件式a、bの論理積である条件式cの判定結果はTRUEになる。 In order to determine the set values of the variables A and B included in the conditional expression c, the inspection apparatus first generates a combination table 33a of values that the variables A and B can take and the determination results of the conditional expressions a to c. For example, when the variable A is “USE” and the variable B is “USE”, the determination result of the conditional expression a (A == USE) is TRUE (described as “T” in FIG. 1), and the conditional expression b ( The determination result of B == USE) is also TRUE. Therefore, the determination result of conditional expression c, which is the logical product of conditional expressions a and b, is TRUE.
検査装置は、変数A、Bの取り得る値の組み合わせを変えながら各条件式a〜cの判定を行い、変数A、Bの取り得る値と、各条件式a〜cの判定結果との組み合わせテーブル33aを生成する。変数A、Bはともに3つの設定値を取り得るため、組み合わせ数は3×3=9通りとなる。 The inspection apparatus determines the conditional expressions a to c while changing combinations of values that the variables A and B can take, and combines the values that the variables A and B can take and the determination results of the conditional expressions a to c. A table 33a is generated. Since both variables A and B can take three set values, the number of combinations is 3 × 3 = 9.
検査装置は、生成した組み合わせテーブル33aに基づき、単体検査を行う場合に設定する設定値の組み合わせを決定する。 Based on the generated combination table 33a, the inspection apparatus determines a combination of setting values to be set when performing a single inspection.
ここで、変数A、Bの取り得る値の組み合わせ全てについて単体検査を行うとすると、組み合わせ数が多くなり、検査に時間がかかってしまう場合がある。例えば、変数の数が多い場合や、変数の取り得る値の数が多い場合、検査数が多くなり検査にかかる時間が長くなる。 Here, if the unit inspection is performed for all combinations of values that the variables A and B can take, the number of combinations increases, and the inspection may take time. For example, when the number of variables is large or the number of values that the variable can take is large, the number of inspections increases and the time required for the inspections increases.
そこで、検査装置は、例えば組み合わせテーブル33aの中から検査不要な組み合わせを除外して、検査時に設定する設定値の組み合わせを決定し設定値テーブル33を生成する。 Therefore, for example, the inspection apparatus excludes combinations that do not require inspection from the combination table 33a, determines a combination of setting values to be set at the time of inspection, and generates the setting value table 33.
例えば、変数A、Bの取り得る値の組み合わせには、検査対象のソースコードでは組み合わせられない組み合わせが含まれる。具体的には、例えば、ある変数Cが車両の種類を表し、別の変数Dがトランスミッションの種類を表しているものとする。このとき、ある車種Sのトランスミッションがオートマチックトランスミッション(AT)のみであり、マニュアルトランスミッション(MT)がないとする。この場合、変数C==S、変数D==MTの組み合わせは、車種Sの車両で実行されるソースコードでは組み合わせられない組み合わせとなる。このように、変数の取り得る値によっては、実際には組み合わせられない場合がある。実際にはソースコード上で組み合わせることがない組み合わせについて単体検査を行うと、検査数が無駄に増加し、検査時間が長くなってしまう。 For example, combinations of values that the variables A and B can take include combinations that cannot be combined in the source code to be inspected. Specifically, for example, it is assumed that a certain variable C represents the type of vehicle and another variable D represents the type of transmission. At this time, it is assumed that the transmission of a certain vehicle type S is only an automatic transmission (AT) and no manual transmission (MT). In this case, the combination of the variable C == S and the variable D == MT is a combination that cannot be combined in the source code executed on the vehicle of the vehicle type S. In this way, depending on the values that the variables can take, they may not actually be combined. If a single inspection is performed on combinations that are not actually combined on the source code, the number of inspections increases unnecessarily, and the inspection time becomes longer.
そこで、検査装置は、組み合わせられない変数の設定値の組み合わせでは単体検査を行わないとして、かかる組み合わせを除外する。例えば、変数Aが「NOT」であり、変数Bが「OTHER」である組み合わせが、ソースコード上で許容されない組み合わせであるとする。すなわち、図1に示す組み合わせテーブル33aの9行目の組み合わせが許容されない場合、検査装置はかかる9行目の組み合わせを単体検査時の設定値の組み合わせから除外する。 Therefore, the inspection apparatus excludes such combinations by assuming that a single inspection is not performed for combinations of set values of variables that cannot be combined. For example, a combination in which the variable A is “NOT” and the variable B is “OTHER” is a combination that is not allowed in the source code. That is, when the combination of the ninth line in the combination table 33a shown in FIG. 1 is not allowed, the inspection apparatus excludes the combination of the ninth line from the set value combinations during the single inspection.
また、検査装置は、条件式cの判定後の処理が重複する変数A、Bの組み合わせを除外する。これは、組み合わせテーブル33aの中には、変数の設定値にかかわらず同じ処理を行う組み合わせが含まれることがあるためである。 In addition, the inspection apparatus excludes the combination of variables A and B in which the processing after the determination of conditional expression c is duplicated. This is because the combination table 33a may include combinations that perform the same processing regardless of the set value of the variable.
例えば条件式cに2つの条件式a、bが含まれる場合、左の条件式aから順に条件判定を行う。そのため、条件式aが不成立(FALSE、図1では「F」と記載)の場合、条件式bの判定結果にかかわらず条件式cは不成立となりソースコード31の処理P1は実行されない。なお、例えば、図1の組み合わせテーブル33aでは、2、3、5、6、8、9行目の組み合わせで、変数Bの値にかかわらず、いずれも条件式cがFとなっている。
For example, when the conditional expression c includes two conditional expressions a and b, the condition determination is performed in order from the left conditional expression a. Therefore, when the conditional expression a is not satisfied (FALSE, described as “F” in FIG. 1), the conditional expression c is not satisfied regardless of the determination result of the conditional expression b, and the process P1 of the
このように、条件式aがF(不成立)となった場合、条件式bの正否、すなわち変数Bの値は、条件式cの判定結果に影響を与えない。したがって、例えば条件式aがFとなる検査を少なくとも一度行えば、その他の条件式aがFとなる検査を省略しても単体検査の精度に影響を与えない。 Thus, when the conditional expression a is F (not established), whether the conditional expression b is right or wrong, that is, the value of the variable B does not affect the determination result of the conditional expression c. Therefore, for example, if the inspection in which the conditional expression a is F is performed at least once, even if the inspection in which the other conditional expression a is F is omitted, the accuracy of the single inspection is not affected.
そこで、検査装置は、図1の組み合わせテーブル33aの中から、5、6、8および9行目の組み合わせを除外して設定値の組み合わせを決定する。なお、検査装置は、変数A、Bの取り得る値が、それぞれ少なくとも1回は設定されるように設定値を決定する。したがって、検査装置は、変数Aが「OTHER」である場合の単体検査を行うために、図1の組み合わせテーブル33aの3行目の組み合わせは除外しない。このように、検査装置は、図1の設定値テーブル33に示すように5つの組み合わせを、単体検査を行う場合の変数A、Bの設定値の組み合わせに決定する。 Therefore, the inspection apparatus determines a combination of setting values by excluding the combinations of the fifth, sixth, eighth, and ninth lines from the combination table 33a of FIG. Note that the inspection apparatus determines the setting values so that the values that the variables A and B can take are each set at least once. Therefore, the inspection apparatus does not exclude the combination in the third row of the combination table 33a in FIG. 1 in order to perform a single inspection when the variable A is “OTHER”. As described above, the inspection apparatus determines the five combinations as the combination of the setting values of the variables A and B when performing the single inspection as shown in the setting value table 33 of FIG.
検査装置は、決定した設定値の組み合わせを例えば図示しない記憶部に出力する(ステップS4)。 The inspection apparatus outputs the determined set value combination to, for example, a storage unit (not shown) (step S4).
このように、検査装置が実施形態に係る決定方法を実行することで、ソースコードに含まれる変数の設定値を自動で決定することができ、ユーザの作業量を削減することができる。また、ユーザが設定値を設定する場合に比べて、設定漏れを抑制することができる。 As described above, when the inspection apparatus executes the determination method according to the embodiment, the setting value of the variable included in the source code can be automatically determined, and the amount of work of the user can be reduced. Further, setting omission can be suppressed as compared with the case where the user sets the set value.
さらに、検査装置は、検査対象のソースコードでは組み合わせられない組み合わせや、条件式cの判定結果に影響しない変数Bの値を含む組み合わせを除外して、設定値の組み合わせを決定する。 Further, the inspection apparatus determines combinations of set values by excluding combinations that cannot be combined in the source code to be inspected and combinations that include the value of the variable B that does not affect the determination result of the conditional expression c.
これにより、検査装置は、単体検査の検査数を低減することができる。例えば図1では、変数A、Bの取り得る値の組み合わせ全てで検査を行う場合、9通りの検査を行わなければならないが、検査装置が所定の組み合わせを除外して、設定値の組み合わせ数を5つに減らすことで、検査数を5に削減することができる。 Thereby, the inspection apparatus can reduce the number of inspections of the single inspection. For example, in FIG. 1, when inspection is performed with all possible combinations of values of variables A and B, nine inspections must be performed. However, the inspection apparatus excludes predetermined combinations and sets the number of combinations of set values. By reducing the number to five, the number of inspections can be reduced to five.
(2.検査装置)
以下、検査装置1の構成例について、図2〜図12を参照して説明する。図2は、実施形態に係る検査装置1の構成を示すブロック図である。なお、図2では、実施形態の特徴を説明するために必要な構成要素のみを機能ブロックで表しており、一般的な構成要素についての記載を省略している。
(2. Inspection device)
Hereinafter, a configuration example of the
換言すれば、図2に図示される各構成要素は機能概念的なものであり、必ずしも物理的に図示の如く構成されていることを要しない。例えば、各機能ブロックの分散・統合の具体的形態は図示のものに限られず、その全部または一部を、各種の負荷や使用状況などに応じて、任意の単位で機能的または物理的に分散・統合して構成することが可能である。 In other words, each component illustrated in FIG. 2 is functionally conceptual and does not necessarily need to be physically configured as illustrated. For example, the specific form of distribution / integration of each functional block is not limited to the one shown in the figure, and all or a part thereof is functionally or physically distributed in arbitrary units according to various loads or usage conditions.・ It can be integrated and configured.
実施形態に係る検査装置1は、決定部10と、検査部20と、記憶部30とを備える。決定部10は、読込部110と、抽出部120と、設定値決定部130と、出力部140と、を備える。記憶部30は、ソースコード31、変数情報32、設定値テーブル33を記憶する。
The
ここで、検査装置1は、例えば、CPU(Central Processing Unit)、ROM(Read Only Memory)、RAM(Random Access Memory)、HDD(Hard Disk Drive)、入出力ポートなどを有するコンピュータや各種の回路を含む。
Here, the
コンピュータのCPUは、例えば、ROMに記憶された決定プログラムを読み出して実行することによって、決定部10の読込部110、抽出部120、設定値決定部130および出力部140として機能する。また、コンピュータのCPUは、例えばROMに記憶された検査プログラムを読み出して実行することによって、検査部20として機能する。
The CPU of the computer functions as the reading unit 110, the extracting unit 120, the setting value determining unit 130, and the output unit 140 of the determining
また、記憶部30は、たとえば、RAMやHDDに対応する。RAMやHDDは、ソースコード31、変数情報32、設定値テーブル33、決定プログラムや検査プログラム等の各種プログラムに関する情報等を記憶することができる。なお、検査装置1は、有線や無線のネットワークで接続された他のコンピュータや可搬型記録媒体を介して上記したプログラムや各種情報を取得することとしてもよい。
The
(2.1.決定部)
決定部10は、単体検査を行う場合に条件分岐の条件式に含まれる変数に設定する設定値の組み合わせを決定する。決定部10は、上述したように、読込部110と、抽出部120と、設定値決定部130と、出力部140と、を備える。
(2.1. Deciding part)
The
なお、ここでは、決定部10がC言語で記載されたソースコード31の変数の設定値を決定する場合について説明するがソースコード31に用いられるプログラミング言語はC言語に限定されない。例えばソースコード31がFORTRAN等の他のプログラミング言語で記載されていてもよい。
Here, the case where the
また、ここでは、ソースコード31のプリプロセス実行時に決定部10がソースコード31に含まれるプリプロセッサ指令の条件分岐を抽出するものとするが、これに限定されない。例えば、決定部10が抽出する条件分岐はプリプロセッサ指令以外の条件分岐であってもよい。また、プリプロセス実行時以外であっても、決定部10が設定値を決定するために条件分岐を抽出するようにしてもよい。
Here, it is assumed that the
(2.1.1.読込部)
読込部110は、記憶部30から検査対象であるソースコード31および変数情報32を読み出す。読込部110は読み出したソースコード31を抽出部120に出力する。また、読込部110は読み出した変数情報32を設定値決定部130に出力する。
(2.1.1. Reading part)
The reading unit 110 reads the
(2.1.2.抽出部)
抽出部120は、読込部110からソースコード31を受け取ると、ソースコード31から条件分岐の条件式や変数等、後段の設定値決定部130で変数の値を設定するために必要な情報を抽出する。抽出部120は、分岐抽出部121と、変数抽出部122と、定義抽出部123と、を備える。
(2.1.2. Extraction unit)
When the extraction unit 120 receives the
(2.1.2.1.分岐抽出部)
分岐抽出部121は、ソースコード31から条件分岐を抽出する。例えば、読込部110が図3に示すソースコード31を読み込んだ場合、分岐抽出部121は、条件分岐「#if(A==USE)||(B==USE)」を抽出する。このように、分岐抽出部121は、ソースコード31に含まれる条件分岐に関する指令「#if」や「#else」、「#elif」等を検出することで、ソースコード31に含まれる条件分岐を抽出する。なお、図3は、実施形態に係るソースコード31の一例を示す図である。
(2.1.2.1. Branch extraction unit)
The branch extraction unit 121 extracts a conditional branch from the
分岐抽出部121は、抽出した条件分岐を変数抽出部122に出力する。
The branch extraction unit 121 outputs the extracted conditional branch to the
なお、ここでは、分岐抽出部121が条件分岐を1つ抽出する例について説明したが、分岐抽出部121が抽出する条件分岐の数は1つに限定されない。分岐抽出部121は、例えばソースコード31に含まれる条件分岐を全て抽出する。ソースコード31に複数の条件分岐が含まれる場合、分岐抽出部121は、複数の条件分岐を抽出する。
Here, an example in which the branch extraction unit 121 extracts one conditional branch has been described, but the number of conditional branches extracted by the branch extraction unit 121 is not limited to one. For example, the branch extraction unit 121 extracts all conditional branches included in the
(2.1.2.2.変数抽出部)
変数抽出部122は、分岐抽出部121が抽出した条件分岐の条件式に含まれる変数を抽出する。変数抽出部122は、条件式に含まれる関係演算子の左辺のオペランドを変数として抽出する。例えば図3のソースコード31の場合、変数抽出部122は、変数A、Bを抽出する。
(2.1.2.2. Variable extraction unit)
The
変数抽出部122は、抽出した変数A、Bを定義抽出部123に出力する。
The
(2.1.2.3.定義抽出部)
定義抽出部123は、変数抽出部122が抽出した変数A、Bの定義をソースコード31から抽出する。定義抽出部123は、例えば変数A、Bの取り得る値を抽出する。ここでは、定義抽出部123は、変数A、Bの取り得る値として「USE」、「NOT」、「OTHER」の3つを抽出するものとする。
(2.1.2.3. Definition Extraction Unit)
The definition extraction unit 123 extracts the definitions of the variables A and B extracted by the
定義抽出部123は、変数A、Bおよびかかる変数A、Bの取り得る値を設定値決定部130に出力する。 The definition extraction unit 123 outputs the variables A and B and the possible values of the variables A and B to the set value determination unit 130.
なお、ここでは変数A、Bの取り得る値を文字列としているが、これに限定されない。例えば変数A、Bが「0」、「1」、「2」などの整数であってもよい。また、ここでは、定義抽出部123がソースコード31から変数A、Bの取り得る値を抽出するとしたが、これに限定されない。定義抽出部123が、例えば変数A、Bごとに取り得る値を予め定義した定義情報に基づいて変数A、Bの取り得る値を抽出してもよい。なお、定義情報は例えば記憶部30に記憶される。
In addition, although the value which the variable A and B can take here is made into the character string here, it is not limited to this. For example, the variables A and B may be integers such as “0”, “1”, and “2”. Here, the definition extraction unit 123 extracts the possible values of the variables A and B from the
また、ここでは、分岐抽出部121および変数抽出部122が条件分岐および変数A、Bを抽出してから変数A、Bの取り得る値を抽出するとしたが、これに限定されない。例えば、分岐抽出部121が条件分岐を抽出する前に、定義抽出部123がソースコード31に含まれる変数の定義情報を抽出するようにしてもよい。この場合、定義抽出部123は、抽出した定義情報に基づき、変数抽出部122が抽出した変数A、Bの取り得る値を決定するものとする。
Here, the branch extraction unit 121 and the
(2.1.3.設定値決定部)
設定値決定部130は、抽出部120が抽出した変数(図3の例では変数A、B)の取り得る値および条件式の判定結果の組み合わせに基づき、単体検査を行う場合に変数に設定する値(設定値)を決定する。設定値決定部130は、組み合わせ生成部131と、禁止除去部132と、重複除去部133とを備える。
(2.1.3. Setting value determination unit)
The set value determination unit 130 sets a variable when performing a unit test based on a combination of the values extracted by the extraction unit 120 (variables A and B in the example of FIG. 3) and the determination result of the conditional expression. Determine the value (setting value). The set value determination unit 130 includes a
(2.1.3.1.組み合わせ生成部)
組み合わせ生成部131は、抽出部120が抽出した変数の取り得る値および条件分岐の条件式の判定結果の組み合わせを含む組み合わせテーブルを生成する。組み合わせ生成部131は、生成した組み合わせを禁止除去部132に出力する。なお、組み合わせ生成部131による組み合わせの生成例については、図5A、図6等を用いて後述する。
(2.1.3.1. Combination generation unit)
The
(2.1.3.2.禁止除去部)
禁止除去部132は、組み合わせ生成部131が生成した変数の取り得る値の組み合わせのうち、ソースコード31を実行する場合に組み合わせられない、すなわち組み合わせが禁止されている組み合わせを除外する。
(2.1.3.2. Prohibited removal part)
The
禁止除去部132は、読込部110が読み込んだ変数情報32に基づいて禁止されている組み合わせを除外する。図4に示すように、変数情報32は、変数A、Bの組み合わせの可否を示すテーブルである。なお、図4は、実施形態に係る変数情報32を説明する図である。図4では、ソースコード31を実行する場合に組み合わせられる変数A、Bの組を「○」で表し、組み合わせられない変数A、Bの組を「×」で表している。
The
例えば、図4では、変数Aが「OTHER」であり、変数Bが「OTHER」である組み合わせが「×」になっている。この場合、禁止除去部132は、変数Aが「OTHER」であり、変数Bが「OTHER」である組み合わせを、組み合わせ生成部131が生成した組み合わせテーブルから除去する。
For example, in FIG. 4, the combination where the variable A is “OTHER” and the variable B is “OTHER” is “x”. In this case, the
なお、ここでは、禁止除去部132が、組み合わせ生成部131が生成した組み合わせテーブルから組み合わせが禁止されている組み合わせを除去するとしたが、これに限定されない。例えば、組み合わせ生成部131が、変数情報32を参照して禁止されている組み合わせを除いて組み合わせテーブルを生成するようにしてもよい。これにより、禁止除去部132が行う処理を省略することができる。
In this example, the
また、ここでは、禁止除去部132が記憶部30に記憶される変数情報32に基づいて除去する組み合わせを決定するとしたが、これに限定されない。例えばソースコード31に組み合わせを禁止する記載がある場合、禁止除去部132がかかる記載に基づいて組み合わせテーブルから除去するようにしてもよい。例えば、変数Aが「OTHER」であり、かつ、変数Bが「OTHER」である場合にエラーとなる記載がソースコード31に含まれている場合、禁止除去部132が、変数Aが「OTHER」であり、変数Bが「OTHER」である組み合わせを除去するようにしてもよい。
Here, the
(2.1.3.3.重複除去部)
重複除去部133は、条件式の判定後の処理が重複する変数の組み合わせを、組み合わせ生成部131が生成した組み合わせテーブルから除去し、単体検査に用いる変数の設定値を決定する。重複除去部133は、決定した設定値を含む設定値テーブル33を出力部140に出力する。
(2.1.2.3. Deduplication unit)
The
以下、図5A〜図11Eを用いて、組み合わせ生成部131が生成する組み合わせテーブルおよび重複除去部133が除去する変数の組み合わせについて条件式の演算子ごとに説明する。なお、説明を簡略化するために、禁止除去部132による組み合わせの除去は行われない、すなわち禁止される組み合わせはないものとして説明する。
Hereinafter, the combination of the combination table generated by the
(a.#if文)
まず、図5A〜図8Bを用いて、条件分岐に含まれるプリプロセッサ指令が「#if」である場合について説明する。
(A. #If statement)
First, the case where the preprocessor instruction included in the conditional branch is “#if” will be described with reference to FIGS. 5A to 8B.
(a−1.比較演算子:等号)
図5Aおよび図5Bを用いて、条件分岐(#if)の条件式に含まれる演算子が等号(==)である場合について説明する。図5Aは、実施形態に係る組み合わせ生成部131が生成する組み合わせテーブル33a_1の一例を示す図である。また、図5Bは、実施形態に係る重複除去部133が生成する設定値テーブル33_1を示す図である。
(A-1. Comparison operator: equal sign)
A case where the operator included in the conditional expression of the conditional branch (#if) is an equal sign (==) will be described with reference to FIGS. 5A and 5B. FIG. 5A is a diagram illustrating an example of the combination table 33a_1 generated by the
分岐抽出部121が抽出した条件分岐が「#if A==USE」であったとする。以下、条件分岐に含まれる「A==USE」を条件式ce1と記載する。この場合、組み合わせ生成部131は、図5Aに示すように、変数Aの取り得る値と条件式ce1の判定結果との組み合わせを含む組み合わせテーブル33a_1を生成する。
Assume that the conditional branch extracted by the branch extraction unit 121 is “#if A == USE”. Hereinafter, “A == USE” included in the conditional branch is referred to as a conditional expression ce1. In this case, the
図5Aに示すように、変数Aの取り得る値は「USE」、「NOT」、「OTHER」である。この場合、条件式ce1の対応する判定結果はそれぞれ「T」(TRUE)、「F」(FALSE)、「F」となる。 As shown in FIG. 5A, possible values of the variable A are “USE”, “NOT”, and “OTHER”. In this case, the determination results corresponding to the conditional expression ce1 are “T” (TRUE), “F” (FALSE), and “F”, respectively.
ここで、条件式ce1に含まれる変数Aの取り得る全ての値は、必ず1回は検査される必要がある。そのため、図5Aに示すように、変数Aが「NOT」であっても「OTHER」であっても判定結果は「F」となり判定後の処理は変わらないが、重複除去部133は、変数Aの取り得る値を除去せずに、取り得る値全てを検査時に設定する値とする。これにより、重複除去部133は、例えば図5Bに示すように、「USE」、「NOT」、「OTHER」を設定値とする設定値テーブル33_1を生成する。
Here, all possible values of the variable A included in the conditional expression ce1 must be inspected once. Therefore, as shown in FIG. 5A, the determination result is “F” regardless of whether the variable A is “NOT” or “OTHER”, and the processing after the determination does not change. All possible values are set as values to be set at the time of inspection without removing possible values. As a result, the
(a−2.比較演算子:等号否定)
次に、図6を用いて、条件式の演算子が等号否定(!=)である場合について説明する。図6は、実施形態に係る組み合わせ生成部131が生成する組み合わせテーブル33a_2の一例を示す図である。
(A-2. Comparison operator: negation of equal sign)
Next, a case where the operator of the conditional expression is equal sign negation (! =) Will be described with reference to FIG. FIG. 6 is a diagram illustrating an example of the combination table 33a_2 generated by the
分岐抽出部121が抽出した条件分岐が「#if A!=USE」であったとする。以下、条件分岐に含まれる「A!=USE」を条件式ce2と記載する。この場合、組み合わせ生成部131は、図6に示すように、変数Aの取り得る値と条件式ce2の判定結果との組み合わせを含む組み合わせテーブル33a_2を生成する。
Assume that the conditional branch extracted by the branch extracting unit 121 is “#if A! = USE”. Hereinafter, “A! = USE” included in the conditional branch is referred to as a conditional expression ce2. In this case, the
図6に示すように、変数Aの取り得る値は「USE」、「NOT」、「OTHER」である。この場合、条件式ce2の対応する判定結果はそれぞれ「F」、「T」、「T」となる。 As shown in FIG. 6, possible values of the variable A are “USE”, “NOT”, and “OTHER”. In this case, the determination results corresponding to the conditional expression ce2 are “F”, “T”, and “T”, respectively.
重複除去部133は、条件式ce1の場合と同様に変数Aの取り得る値を除去せずに、取り得る値全てを検査時に設定する値とする。これにより、重複除去部133は、例えば図5Bと同様に、「USE」、「NOT」、「OTHER」を設定値とする設定値テーブル33_1を生成する。
The
(a−3.論理演算子:論理和)
図7Aおよび図7Bを用いて、条件式に論理和(||、OR条件)が含まれる場合について説明する。図7Aは、実施形態に係る組み合わせ生成部131が生成する組み合わせテーブル33a_3の一例を示す図である。図7Bは、実施形態に係る重複除去部133が生成する設定値テーブル33_3の一例を示す図である。
(A-3. Logical operator: logical sum)
A case where a logical sum (||, OR condition) is included in the conditional expression will be described with reference to FIGS. 7A and 7B. FIG. 7A is a diagram illustrating an example of the combination table 33a_3 generated by the
分岐抽出部121が、図3に示すソースコード31から条件分岐「#if (A==USE) || (B==USE)」を抽出したとする。以下、条件分岐の条件式「(A==USE)||(B==USE)」を条件式ce3と記載する。また、条件式ce3に含まれる論理和の左辺の条件式「A==USE」を条件式ceL、右辺の条件式「B==USE」を条件式ceRと記載する。
Assume that the branch extraction unit 121 extracts the conditional branch “#if (A == USE) || (B == USE)” from the
この場合、組み合わせ生成部131は、図7Aに示すように変数A、Bの取り得る値と条件式ceL、ceR、ce3の判定結果との組み合わせを含む組み合わせテーブル33a_3を生成する。
In this case, the
図7Aの組み合わせテーブル33a_3の5行目に示すように、組み合わせ生成部131は、例えば変数Aを「USE」、変数Bを「USE」とする組み合わせを生成する。この場合、条件式ceLの判定結果は「T」、条件式ceRの判定結果は「T」となる。また、条件式ce3の判定結果は「T」となる。
As shown in the fifth row of the combination table 33a_3 in FIG. 7A, the
組み合わせ生成部131は、変数A、Bの取り得る値を「USE」、「NOT」、「OTHER」と変更させながら、各条件式ceL、ceR、ce3を判定し、判定結果を組み合わせテーブル33a_3に書き込む。
The
組み合わせ生成部131は、変数A、Bの取り得る値全ての組み合わせに対して条件式ceL、ceR、ce3の判定結果を算出することで、図7Aの組み合わせテーブル33a_3に示すように9通りの組み合わせを生成する。
The
次に、重複除去部133は、組み合わせ生成部131が生成した9通りの組み合わせの中から、判定結果に影響を与えない変数の値を含む組み合わせを除去する。
Next, the
例えば、C言語において論理和は左側から順に演算される。したがって、条件式ceLが成立した場合、条件式ceRの判定結果にかかわらず条件式ce3の判定結果は「成立(T)」となる。すなわち、変数Aが「USE」の場合、変数Bの値は条件式ce3の判定結果に影響を与えない。 For example, in the C language, the logical sum is calculated sequentially from the left side. Therefore, when the conditional expression ceL is satisfied, the determination result of the conditional expression ce3 is “Established (T)” regardless of the determination result of the conditional expression ceR. That is, when the variable A is “USE”, the value of the variable B does not affect the determination result of the conditional expression ce3.
したがって、変数Aが「USE」である組み合わせ、すなわち図7Aに示す組み合わせテーブル33a_3の2、5、8行目の組み合わせを少なくとも1回実行すると、条件式ce3が「T」である検査を少なくとも1回は実行することができる。換言すると、組み合わせテーブル33a_3の2、5、8行目の組み合わせで行う検査は、処理が重複する検査であると言える。 Therefore, when the combination in which the variable A is “USE”, that is, the combination in the second, fifth, and eighth rows of the combination table 33a_3 illustrated in FIG. 7A is executed at least once, at least one test in which the conditional expression ce3 is “T” Times can be performed. In other words, it can be said that the inspection performed by the combination of the second, fifth, and eighth rows of the combination table 33a_3 is an inspection in which processing is duplicated.
そこで、本実施形態では、重複除去部133が、処理が重複する組み合わせ(図7Aでは2、5、8行目の組み合わせ)の少なくとも1つを除去することで、検査数を削減することとした。ただし、このとき、重複除去部133は、変数A、Bの各取り得る値が少なくとも1回は検査されるように、削除する組み合わせを決定する。
Therefore, in the present embodiment, the
また、重複除去部133は、変数A、Bの各取り得る値と、条件式ce3の判定結果との異なる組み合わせが少なくとも1回は検査されるように、削除する組み合わせを決定する。例えば、変数Bが「NOT」の場合、条件式ce3の判定結果が「T」である組み合わせと、判定結果が「F」である組み合わせとが1回は検査されるように、重複除去部133は、変数A、Bの設定値を決定する。
In addition, the
なお、変数Bが「USE」の場合、条件式ce3は必ず「T」になるため、条件式ce3が「F」の組み合わせは存在しない。このように、変数A、Bの取り得る値によっては条件式ce3の判定結果が異なる組み合わせが存在しない場合もある。 When the variable B is “USE”, the conditional expression ce3 is always “T”, so there is no combination of the conditional expression ce3 “F”. Thus, depending on the possible values of the variables A and B, there may be no combination in which the determination result of the conditional expression ce3 is different.
重複除去部133は、例えば図7Aの組み合わせテーブル33a_3の場合、5行目の組み合わせは除去するが、8行目の組み合わせは除去しない。これは、5行目の組み合わせの変数Bが「USE」、条件式ce3が「T」であり、この組み合わせは4、6行目の組み合わせと同じであるためである。また、8行目の組み合わせは、変数Bが「OTHER」であり、条件式ce3が「T」であるが、この組み合わせは他の組み合わせに含まれないためである。
For example, in the case of the combination table 33a_3 in FIG. 7A, the
重複除去部133は、組み合わせテーブル33a_3の5行目の組み合わせを除外し、1〜4、6〜9行目に含まれる変数A、Bの組み合わせを設定値の組み合わせに決定し、図7Bに示す設定値テーブル33_3を生成する。
The
なお、論理積(&&、AND条件)については、図1を用いて上述したため、ここでの説明を省略する。 Note that the logical product (&&, AND condition) has been described above with reference to FIG.
(b.ネスト条件)
次に、図8Aおよび図8Bを用いて、分岐抽出部121が、#if文が入れ子になったネスト条件を抽出した場合について説明する。図8Aは、実施形態に係るソースコード31bの一例を示す図である。図8Bは、実施形態に係る組み合わせ生成部131が生成する組み合わせテーブル33a_4の一例を示す図である。
(B. Nest condition)
Next, a case where the branch extraction unit 121 extracts a nested condition in which a #if statement is nested will be described with reference to FIGS. 8A and 8B. FIG. 8A is a diagram illustrating an example of the
図8Aに示すように、ソースコード31bにネスト条件が含まれると、例えば条件分岐「#if A==USE」が成立する場合に、条件分岐「#if B==USE」を含む処理P1が実行される。
As shown in FIG. 8A, when the nest condition is included in the
このようにソースコード31bにネスト条件が含まれる場合、分岐抽出部121は、親となる条件分岐「#if A==USE」および子となる条件分岐「#if B==USE」をそれぞれ抽出する。
Thus, when the nesting condition is included in the
まず、組み合わせ生成部131は、親となる条件分岐「#if A==USE」に含まれる条件式「A==USE」の変数Aと判定結果との組み合わせテーブルを生成する。かかる組み合わせテーブルは、図5Aに示す組み合わせテーブル33a_1と同じであるため図示を省略する。
First, the
次に、組み合わせ生成部131は、子となる条件分岐「#if B==USE」の組み合わせテーブル33a_4を生成する。この場合、組み合わせ生成部131は、親となる条件分岐「#if A==USE」を考慮して組み合わせテーブル33a_4を生成する。すなわち、組み合わせ生成部131は、変数A、Bと条件式「A==USE」、「B==USE」の判定結果との組み合わせテーブル33a_4を生成する。
Next, the
重複除去部133は、子となる条件分岐に基づいて生成された組み合わせテーブル33a_4に含まれる組み合わせから、検査で行う処理が重複する組み合わせを削除する。例えば、図8Aに示すソースコード31bでは、親となる条件分岐が不成立(F)の場合、子となる条件分岐は処理されない。すなわち、変数Aが「USE」でなければ、変数Bの値にかかわらず処理P1は実行されない。
The
そこで、重複除去部133は、図8Bに示す組み合わせテーブル33a_4のうち、3、5、8、9行目の組み合わせを除外して、変数A、Bの設定値を決定する。なお、組み合わせを除外する方法は、図1を用いて説明した演算子に論理積が含まれる場合と同じであるため、説明を省略する。
Therefore, the
(c.#else文)
図9を用いて、分岐抽出部121が条件分岐として#else文を抽出した場合について説明する。図9は、実施形態に係るソースコード31cの一例を示す図である。
(C. # Else statement)
The case where the branch extraction unit 121 extracts an #else sentence as a conditional branch will be described with reference to FIG. FIG. 9 is a diagram illustrating an example of the
図9に示すように、分岐抽出部121が条件分岐「#if (A==USE)&&(B==USE)」および条件分岐「#else」を抽出したものとする。 As illustrated in FIG. 9, it is assumed that the branch extraction unit 121 extracts the conditional branch “#if (A == USE) && (B == USE)” and the conditional branch “#else”.
この場合、分岐抽出部121は、条件分岐「#else」の条件式として条件分岐「#if (A==USE)&&(B==USE)」の否定である条件式を抽出する。換言すると、分岐抽出部121は、図9に示すように、条件分岐「#else」を「#if (A!=USE)||(B!=USE)」に置き換える。図9では置き換えたソースコードをソースコード31c_1として示している。 In this case, the branch extraction unit 121 extracts a conditional expression that is the negative of the conditional branch “#if (A == USE) && (B == USE)” as the conditional expression of the conditional branch “#else”. In other words, the branch extraction unit 121 replaces the conditional branch “#else” with “#if (A! = USE) || (B! = USE)” as shown in FIG. In FIG. 9, the replaced source code is shown as source code 31c_1.
組み合わせ生成部131は、分岐抽出部121が抽出した条件分岐「#if (A==USE)&&(B==USE)」および「#if (A!=USE)||(B!=USE)」についてそれぞれ組み合わせテーブルを生成する。また、重複除去部133は、各組み合わせテーブルから処理が重複する組み合わせを除外して、条件分岐ごとに設定値テーブルを生成する。
The
(d.#elif文)
図10を用いて、分岐抽出部121が条件分岐として#elif文を抽出した場合について説明する。図10は、実施形態に係るソースコード31dの一例を示す図である。
(D. # Elif statement)
The case where the branch extraction unit 121 extracts a #elif sentence as a conditional branch will be described with reference to FIG. FIG. 10 is a diagram illustrating an example of the
図10に示すように、分岐抽出部121が条件分岐「#if (A==USE)&&(B==USE)」および条件分岐「#elif (C==USE)」を抽出したものとする。 As illustrated in FIG. 10, it is assumed that the branch extraction unit 121 has extracted the conditional branch “#if (A == USE) && (B == USE)” and the conditional branch “#elif (C == USE)”. .
この場合、分岐抽出部121は、条件分岐「#elif (C==USE)」の条件式として「(A==USE)&&(B==USE)」の否定である条件式と「C==USE」との論理積を抽出する。換言すると、分岐抽出部121は、図10に示すように、条件分岐「「#elif (C==USE)」を「#if ((A!=USE)||(B!=USE))&&(C==USE)」に置き換える。図10では置き換えたソースコードをソースコード31d_1として示している。 In this case, the branch extraction unit 121 uses a conditional expression that is a negative of “(A == USE) && (B == USE)” as a conditional expression of the conditional branch “#elif (C == USE)” and “C = AND with “= USE” is extracted. In other words, as shown in FIG. 10, the branch extraction unit 121 converts the conditional branch ““ #elif (C == USE) ”to“ #if ((A! = USE) || (B! = USE)) && (C == USE) ”. In FIG. 10, the replaced source code is shown as source code 31d_1.
組み合わせ生成部131は、分岐抽出部121が抽出した条件分岐「#if (A==USE)&&(B==USE)」および「#if ((A!=USE)||(B!=USE))&&(C==USE)」についてそれぞれ組み合わせテーブルを生成する。また、重複除去部133は、各組み合わせテーブルから処理が重複する組み合わせを除外して、条件分岐ごとに設定値テーブルを生成する。なお、条件分岐に含まれるCは変数であり、変数A、Bと同様に「USE」、「NOT」、「OTHER」の3つの値を取り得るものとする。
The
ここで、図11A〜図11Eを用いて条件分岐「#if ((A!=USE)||(B!=USE))&&(C==USE)」(図10参照)のように、条件式に複数の論理演算子が含まれる場合に、組み合わせ生成部131が生成する組み合わせテーブルについて説明する。
Here, a conditional branch “#if ((A! = USE) || (B! = USE)) && (C == USE)” (see FIG. 10) is used as shown in FIG. A combination table generated by the
図11Aは、実施形態に係るソースコード31eの一例を示す図である。また、図11Bは、実施形態に係る組み合わせ生成部131が生成する組み合わせテーブル33a_5の一例を示す図である。図11Cおよび図11Dは、実施形態にかかる重複除去部133が生成するテーブル33a_6、33a_8の一例を示す図である。図11Eは、実施形態にかかる重複除去部133が生成する設定値テーブル33_9の一例を示す図である。
FIG. 11A is a diagram illustrating an example of the
なお、以下、図11Aに示すように、条件式に複数の論理演算子が複数含まれる条件分岐として、「#if((A==USE)&&(B==USE))||((C==USE)||(D==USE))」を例にとって説明する。ここで、条件式に含まれるC、Dは変数であり、変数A、Bと同様に、「USE」、「NOT」、「OTHER」の3つの値を取り得るものとする。 Hereinafter, as shown in FIG. 11A, as a conditional branch in which a plurality of logical operators are included in a conditional expression, “#if ((A == USE) && (B == USE)) || ((C == USE) || (D == USE)) ". Here, C and D included in the conditional expression are variables, and, like the variables A and B, three values “USE”, “NOT”, and “OTHER” can be taken.
また、ここでは、「(A==USE)&&(B==USE)」を条件式ce5と記載し、「(C==USE)||(D==USE)」を条件式ce6と記載する。また、条件式ce5と条件式ce6の論理和、すなわち条件分岐の条件式「((A==USE)&&(B==USE))||((C==USE)||(D==USE))」を条件式ce7と記載する。 Here, “(A == USE) && (B == USE)” is described as conditional expression ce5, and “(C == USE) || (D == USE)” is described as conditional expression ce6. To do. Further, the logical sum of the conditional expression ce5 and the conditional expression ce6, that is, the conditional expression “((A == USE) && (B == USE)) || ((C == USE) || (D == USE)) ”is written as conditional expression ce7.
まず、組み合わせ生成部131は、図11Bに示すように、条件式ce5〜ce7の判定結果の組み合わせテーブル33a_5を生成する。
First, the
次に、組み合わせ生成部131は、条件式ce5について変数A、Bおよび条件式ce5の判定結果の組み合わせテーブル33a(図1参照)を生成する。
Next, the
重複除去部133は、図11Cに示すように、組み合わせテーブル33aから重複する組み合わせ(図1の組み合わせテーブル33aの5、6、8および9行目の組み合わせ)を除去したテーブル33a_6を生成する。
As illustrated in FIG. 11C, the
組み合わせ生成部131は、条件式ce6について変数C、Dおよび条件式ce6の判定結果の組み合わせテーブル33a_7を生成する。なお、組み合わせテーブル33a_7は、図7Aに示す組み合わせテーブル33a_3の変数A、Bを変数C、Dに置き換えたものであるため、図示を省略する。
The
また、重複除去部133は、組み合わせ生成部131が生成した組み合わせテーブル33a_7から重複する組み合わせ(図7Aの組み合わせテーブル33a_3の5行目の組み合わせ)を除去したテーブル33a_8を生成する。
In addition, the
重複除去部133は、生成したテーブル33a_6、33a_8を、組み合わせテーブル33a_5を用いて統合することで図11Eに示す設定値テーブル33_9を生成する。
The
例えば、図11Bに示す組み合わせテーブル33a_5の1行目は、条件式ce5の判定結果が「F」であり、条件式ce6が「F」である。そのため、重複除去部133は、テーブル33a_6の判定結果が「F」となる組み合わせ(図11Cのテーブル33a_6の2〜5行目の組み合わせ)とテーブル33a_8の判定結果が「F」となる組み合わせ(図11Dのテーブル33a_8の1、3、6、8行目の組み合わせ)を統合する。
For example, in the first row of the combination table 33a_5 illustrated in FIG. 11B, the determination result of the conditional expression ce5 is “F”, and the conditional expression ce6 is “F”. Therefore, the
なお、図11Eに示す設定値テーブル33_9の1〜4行目は、図11Bに示す組み合わせテーブル33a_5の2行目に該当する。また、設定値テーブル33_9の5〜20行目は、図11Bに示す組み合わせテーブル33a_5の3行目に該当する。設定値テーブル33_9の21〜36行目は、図11Bに示す組み合わせテーブル33a_5の1行目に該当する。 Note that the first to fourth lines of the setting value table 33_9 illustrated in FIG. 11E correspond to the second line of the combination table 33a_5 illustrated in FIG. 11B. Further, the 5th to 20th lines of the setting value table 33_9 correspond to the 3rd line of the combination table 33a_5 illustrated in FIG. 11B. The 21st to 36th lines of the setting value table 33_9 correspond to the first line of the combination table 33a_5 illustrated in FIG. 11B.
なお、図11Bに示す組み合わせテーブル33a_5の4行目の組み合わせは、2行目の組み合わせと重複するため、テーブル33a_6、33a_8を統合する際に組み合わせを除外している。これは、条件式ce5が「T」であるならば、条件式ce6の判定結果にかかわらず、条件式ce7が「T」になるためである。そのため、組み合わせテーブル33a_5の2、4行目のいずれか一方を除外しても単体検査に影響を与えないため、図11Bに示す組み合わせテーブル33a_5の4行目の組み合わせに基づいたテーブル33a_6、33a_8の統合は除外することができる。 Note that the combination in the fourth row of the combination table 33a_5 illustrated in FIG. 11B overlaps with the combination in the second row, and therefore the combination is excluded when integrating the tables 33a_6 and 33a_8. This is because if the conditional expression ce5 is “T”, the conditional expression ce7 becomes “T” regardless of the determination result of the conditional expression ce6. For this reason, even if any one of the second and fourth lines of the combination table 33a_5 is excluded, the single inspection is not affected. Therefore, the tables 33a_6 and 33a_8 based on the combination of the fourth line of the combination table 33a_5 illustrated in FIG. Integration can be excluded.
(2.1.4.出力部)
出力部140は、重複除去部133が生成した設定値テーブル33を記憶部30に記憶させる。なお、ここでは、出力部140が設定値テーブル33を記憶させるとしたが、例えば重複除去部133が記憶部30に記憶するようにしてもよい。
(2.1.4. Output unit)
The output unit 140 stores the setting value table 33 generated by the
また、出力部140が検査部20に設定値テーブル33を出力するようにしてもよく、あるいは図示しないディスプレイ等に出力するようにしてもよい。
Further, the output unit 140 may output the set value table 33 to the
(2.2.検査部)
検査部20は、記憶部30からソースコード31および設定値テーブル33を読み出すと、設定値テーブル33に含まれる変数の設定値を用いてソースコード31をモジュールごとに実行することで、ソースコード31の単体検査を行う。
(2.2. Inspection Department)
When the
(3.決定処理)
次に、図12を用いて、実施形態に係る検査装置1が実行する決定処理の処理手順について説明する。図12は、実施形態に係る検査装置1が実行する決定処理の処理手順を示すフローチャートである。
(3. Decision processing)
Next, with reference to FIG. 12, the procedure of the determination process executed by the
図12に示すように、まず、検査装置1は、ソースコード31を読み込む(ステップS101)。次に、検査装置1は、ソースコード31から条件分岐を抽出する(ステップS102)。
As shown in FIG. 12, first, the
検査装置1は、抽出した条件分岐の条件式に含まれる変数を抽出する(ステップS103)。検査装置1は、抽出した変数の取り得る値全てを抽出する(ステップS104)。
The
検査装置1は、変数の取り得る値と条件式の判定結果との組み合わせを生成する(ステップS105)。
The
検査装置1は、ステップS105で生成した組み合わせのなかから、ソースコード31を実行する場合には組み合わせられない変数の設定値を含む組み合わせを除外する(ステップS106)。
The
検査装置1は、ステップS105で生成した組み合わせのなかから、単体検査に影響を与えない変数の値を含む組み合わせを除外する(ステップ107)。
The
検査装置1は、ステップS106およびステップS107で除外した組み合わせに基づき、変数の設定値の組み合わせを決定し(ステップS108)、決定した設定値の組み合わせを出力する(ステップS109)。
The
以上のように、実施形態に係る検査装置1は、ソースコード31に含まれる変数の設定値を自動で決定することができ、ユーザの作業量を削減することができる。
As described above, the
(4.変形例)
以上、本発明の実施形態について説明してきたが、この発明は上記実施形態に限定されるものではなく様々な変形が可能である。以下では、このような変形例について説明する。上記実施形態および以下で説明する形態を含む全ての形態は、適宜に組み合わせ可能である。
(4. Modifications)
As mentioned above, although embodiment of this invention has been described, this invention is not limited to the said embodiment, A various deformation | transformation is possible. Below, such a modification is demonstrated. All the forms including the above embodiment and the forms described below can be appropriately combined.
上記実施形態では、検査装置1が変数と条件式の判定結果との組み合わせテーブルを生成してから、重複する組み合わせを除外するとしたが、これに限定されない。例えば論理積を含む条件式の組み合わせを算出する場合に、検査装置1が重複する組み合わせを除外しつつ、組み合わせテーブルを生成するようにしてもよい。
In the above-described embodiment, the
具体的に、検査装置1の組み合わせ生成部131は、複数の条件式の論理積を算出する場合に、複数の条件式が「T」となるようにしてから、各条件式が1つずつ「F」になるように複数の条件式に含まれる変数を設定する。
Specifically, when calculating the logical product of a plurality of conditional expressions, the
例えば図1に示す条件式c「(A==USE)&&(B==USE)」の場合、組み合わせ生成部131は、条件式a「A==USE」および条件式b「B==USE」がどちらも「T」になるように変数A、Bの組み合わせを生成する。この場合、組み合わせ生成部131は、変数A、Bともに「USE」とする。
For example, in the case of the conditional expression c “(A == USE) && (B == USE)” illustrated in FIG. "Is a combination of variables A and B so that both become" T ". In this case, the
次に、組み合わせ生成部131は、各条件式a、bが1つずつ「F」になるように変数A、Bの組み合わせを生成する。まず、組み合わせ生成部131は、条件式aが「F」となり、条件式bが「T」となる変数A、Bの組み合わせとして、変数Aが「NOT」、変数Bが「USE」の組み合わせと、変数Aが「OTHER」、変数Bが「USE」の組み合わせを生成する。続いて、組み合わせ生成部131は、条件式aが「T」となり、条件式bが「F」となる変数A、Bの組み合わせを生成する。最後に、条件式a、bともに「F」となる変数A、Bの組み合わせを生成する。
Next, the
これにより、図13に示すように、重複した組み合わせを除去した組み合わせテーブル33a_10を生成することができ、重複除去部133の処理を省略することができる。なお、図13は、変形例に係る組み合わせ生成部131が生成する組み合わせテーブルの一例を示す図である。
Thereby, as shown in FIG. 13, the combination table 33a_10 from which the duplicate combination is removed can be generated, and the process of the
また、上記実施形態では、検査装置1が変数の設定を決定する決定部10と、単体検査を行う検査部20とを備えるとしたが、これに限定されない。例えば決定部10と検査部20とをそれぞれ別の装置に実装するようにしてもよい。すなわち、実施形態に係る決定方法を実行する決定装置(図示せず)が、単体検査を行う検査装置1と別の装置であってもよい。
In the above-described embodiment, the
(5.効果)
上記実施形態に係る決定プログラムは、単体検査の対象であるソースコード31を読み込む手順をコンピュータに実行させる。更に決定プログラムは、ソースコード31に含まれる条件分岐を抽出する手順をコンピュータに実行させる。更に決定プログラムは、条件分岐の条件式に含まれる変数の取り得る値と、条件式の判定結果と、の組み合わせに基づき、単体検査を行う場合に代入する変数の設定値を決定する手順をコンピュータに実行させる。更に決定プログラムは、決定した設定値を出力する手順をコンピュータに実行させる。
(5. Effect)
The determination program according to the above-described embodiment causes the computer to execute a procedure for reading the
これにより、単体検査を行う場合に代入する変数の設定値をコンピュータが決定することができ、ユーザの作業量を削減することができる。 As a result, the computer can determine the set value of the variable to be substituted when performing a single inspection, and the amount of work for the user can be reduced.
上記実施形態に係る決定プログラムは、変数の設定値を決定する手順として、変数の取り得る値の全てが少なくとも1回は代入されるように、設定値を決定する。 The determination program according to the above embodiment determines the setting value as a procedure for determining the setting value of the variable so that all the possible values of the variable are substituted at least once.
これにより、変数の設定値の漏れを抑制することができ、単体検査の精度を向上させることができる。 Thereby, the leakage of the set value of the variable can be suppressed, and the accuracy of the single inspection can be improved.
上記実施形態に係る決定プログラムは、変数の設定値を決定する手順として、変数の取り得る値と判定結果との組み合わせが少なくとも1回は検査されるように、設定値を決定する。 The determination program according to the above-described embodiment determines the setting value as a procedure for determining the setting value of the variable so that the combination of the possible value of the variable and the determination result is examined at least once.
これにより、変数の設定値の漏れを抑制することができ、単体検査の精度を向上させることができる。 Thereby, the leakage of the set value of the variable can be suppressed, and the accuracy of the single inspection can be improved.
上記実施形態に係る決定プログラムは、変数の設定値を決定する手順として、複数の変数の取り得る値の組み合わせのうち、ソースコード31では組み合わせられない組み合わせを除外して設定値を決定する。
The determination program according to the above-described embodiment determines the setting value as a procedure for determining the setting value of the variable by excluding combinations that cannot be combined in the
これにより、単体検査の検査数を削減することができ検査規模の増加を抑制することができる。 Thereby, the number of inspections for a single inspection can be reduced, and an increase in the inspection scale can be suppressed.
上記実施形態に係る決定プログラムは、変数の設定値を決定する手順として、複数の変数の取り得る値の組み合わせのうち、判定結果に影響を与えない変数の設定値を含む組み合わせを除外して設定値を決定する。 In the determination program according to the embodiment, as a procedure for determining the setting value of a variable, a setting including a setting value of a variable that does not affect the determination result is excluded from combinations of values that a plurality of variables can take. Determine the value.
これにより、単体検査の検査数を削減することができ検査規模の増加を抑制することができる。 Thereby, the number of inspections for a single inspection can be reduced, and an increase in the inspection scale can be suppressed.
上記実施形態に係る決定プログラムは、変数の設定値を決定する手順として、条件式に含まれる演算子の演算順序に応じて、判定結果に影響を与えない前記変数の設定値を含む前記組み合わせの少なくとも1つが検査されるように前記設定値を決定する。 The determination program according to the embodiment includes, as a procedure for determining a variable setting value, the combination of the combination including the variable setting value that does not affect the determination result according to the calculation order of the operators included in the conditional expression. The set value is determined so that at least one is inspected.
これにより、単体検査の検査数を削減することができ検査規模の増加を抑制することができる。 Thereby, the number of inspections for a single inspection can be reduced, and an increase in the inspection scale can be suppressed.
上記実施形態に係る決定プログラムは、条件分岐を抽出する手順は、ソースコード31のプリプロセス実行時に行われる。
In the determination program according to the above-described embodiment, the procedure for extracting the conditional branch is performed when the
これにより、プリプロセス実行時に、単体検査を行う場合に変数に代入する設定値を決定することができる。 Thereby, it is possible to determine a setting value to be substituted into a variable when performing a single inspection during execution of the preprocess.
さらなる効果や変形例は、当業者によって容易に導き出すことができる。このため、本発明のより広範な態様は、以上のように表しかつ記述した特定の詳細および代表的な実施形態に限定されるものではない。したがって、添付の特許請求の範囲およびその均等物によって定義される総括的な発明の概念の精神または範囲から逸脱することなく、様々な変更が可能である。 Further effects and modifications can be easily derived by those skilled in the art. Thus, the broader aspects of the present invention are not limited to the specific details and representative embodiments shown and described above. Accordingly, various modifications can be made without departing from the spirit or scope of the general inventive concept as defined by the appended claims and their equivalents.
1 検査装置
10 決定部
110 読込部
120 抽出部
130 設定値決定部
140 出力部
20 検査部
30 記憶部
DESCRIPTION OF
Claims (8)
前記ソースコードに含まれる条件分岐を抽出する手順と、
前記条件分岐の条件式に含まれる変数の取り得る値と、前記条件式の判定結果と、の組み合わせに基づき、前記単体検査を行う場合に代入する前記変数の設定値を決定する手順と、
決定した前記設定値を出力する手順と、
をコンピュータに実行させることを特徴とする決定プログラム。 The procedure for reading the source code that is the subject of unit inspection,
A procedure for extracting a conditional branch included in the source code;
A procedure for determining a setting value of the variable to be substituted when performing the unit test based on a combination of a value included in the conditional expression of the conditional branch and a determination result of the conditional expression;
A procedure for outputting the determined setting value;
A determination program characterized by causing a computer to execute.
前記変数の取り得る値の全てが少なくとも1回は代入されるように、前記設定値を決定すること
を特徴とする請求項1に記載の決定プログラム。 As a procedure for determining the setting value of the variable,
The determination program according to claim 1, wherein the setting value is determined so that all of the possible values of the variable are substituted at least once.
前記変数の取り得る値と前記判定結果との組み合わせが少なくとも1回は検査されるように、前記設定値を決定すること
を特徴とする請求項1または2に記載の決定プログラム。 As a procedure for determining the setting value of the variable,
The determination program according to claim 1 or 2, wherein the set value is determined so that a combination of a possible value of the variable and the determination result is examined at least once.
複数の前記変数の取り得る値の組み合わせのうち、前記ソースコードでは組み合わせられない組み合わせを除外して前記設定値を決定すること
を特徴とする請求項1〜3のいずれか一項に記載の決定プログラム。 As a procedure for determining the setting value of the variable,
The determination according to any one of claims 1 to 3, wherein the setting value is determined by excluding combinations that cannot be combined in the source code from among combinations of values that can be taken by the plurality of variables. program.
複数の前記変数の取り得る値の組み合わせのうち、判定結果に影響を与えない前記変数の前記設定値を含む組み合わせを除外して前記設定値を決定すること
を特徴とする請求項1〜4のいずれか一項に記載の決定プログラム。 As a procedure for determining the setting value of the variable,
5. The set value is determined by excluding a combination including the set value of the variable that does not affect a determination result from combinations of possible values of the plurality of variables. The decision program according to any one of the above.
前記条件式に含まれる演算子の演算順序に応じて、判定結果に影響を与えない前記変数の前記設定値を含む前記組み合わせの少なくとも1つが検査されるように前記設定値を決定すること
を特徴とする請求項5に記載の決定プログラム。 As a procedure for determining the setting value of the variable,
The setting value is determined so that at least one of the combinations including the setting value of the variable that does not affect a determination result is examined according to an operation order of operators included in the conditional expression. The determination program according to claim 5.
前記ソースコードのプリプロセス実行時に行われること
を特徴とする請求項1〜6のいずれか一項に記載の決定プログラム。 The procedure for extracting the conditional branch is as follows:
The determination program according to claim 1, wherein the determination program is executed when the source code is preprocessed.
前記ソースコードに含まれる条件分岐を抽出する工程と、
前記条件分岐の条件式に含まれる変数の取り得る値と、前記条件式の判定結果と、の組み合わせに基づき、前記単体検査を行う場合に代入する前記変数の設定値を決定する工程と、
決定した前記設定値を出力する工程と、
を含むことを特徴とする決定方法。 The process of reading the source code that is the subject of the unit inspection;
Extracting a conditional branch included in the source code;
Determining a setting value of the variable to be substituted when performing the unit test based on a combination of a value that can be included in the conditional expression of the conditional branch and a determination result of the conditional expression;
Outputting the determined set value;
A determination method characterized by comprising:
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2017014504A JP2018124654A (en) | 2017-01-30 | 2017-01-30 | Determination program and determination method |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2017014504A JP2018124654A (en) | 2017-01-30 | 2017-01-30 | Determination program and determination method |
Publications (1)
Publication Number | Publication Date |
---|---|
JP2018124654A true JP2018124654A (en) | 2018-08-09 |
Family
ID=63111446
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
JP2017014504A Pending JP2018124654A (en) | 2017-01-30 | 2017-01-30 | Determination program and determination method |
Country Status (1)
Country | Link |
---|---|
JP (1) | JP2018124654A (en) |
-
2017
- 2017-01-30 JP JP2017014504A patent/JP2018124654A/en active Pending
Similar Documents
Publication | Publication Date | Title |
---|---|---|
JP2000148808A (en) | Method for verifying correctness of structural rtl for scheduled motion description | |
CN101751333A (en) | Method, computer program and computer system for assisting in analyzing program | |
JP2007012003A (en) | System for providing development environment of feature-oriented software product line | |
CN105446874A (en) | Method and device for detecting resource configuration file | |
JP2017041171A (en) | Test scenario generation support device and test scenario generation support method | |
US10628140B2 (en) | Program code generation apparatus | |
US8365114B2 (en) | Logic modification synthesis | |
Fu et al. | Llm4sechw: Leveraging domain-specific large language model for hardware debugging | |
JP6419667B2 (en) | Test DB data generation method and apparatus | |
JP4445517B2 (en) | Circuit design verification method and program for circuit design verification | |
CN112631925B (en) | Method for detecting single-variable atom violation defect | |
Beller et al. | The last line effect | |
CN112395198B (en) | Software defect discovery method based on differential subgraph mining | |
JP6567212B2 (en) | Equivalence verification device and equivalence verification program | |
JP2018124654A (en) | Determination program and determination method | |
JP2013077124A (en) | Software test case generation device | |
Akhtar et al. | A Systematic Literature Review on Software-refactoring Techniques, Challenges, and Practices | |
CN111666216B (en) | Intelligent contract analysis method and device | |
JP6369269B2 (en) | Verification support apparatus, verification support method, and computer program | |
JP2009134360A (en) | Model inspection system, model inspection method, and model inspection program | |
CN113553246A (en) | System evaluation device for computing platform | |
CN104038356A (en) | Execution method, configuration apparatus and processing apparatus for data route | |
JP6723483B2 (en) | Test case generation device, test case generation method, and test case generation program | |
CN112464636A (en) | Constraint file comparison method and device, electronic equipment and storage medium | |
Ba-Brahem et al. | The proposal of improved inexact isomorphic graph algorithm to detect design patterns |