Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /home/zhenxiangba/zhenxiangba.com/public_html/phproxy-improved-master/index.php on line 456
JP7629880B2 - Program modification support system and program modification support method - Google Patents
[go: Go Back, main page]

JP7629880B2 - Program modification support system and program modification support method - Google Patents

Program modification support system and program modification support method Download PDF

Info

Publication number
JP7629880B2
JP7629880B2 JP2022009741A JP2022009741A JP7629880B2 JP 7629880 B2 JP7629880 B2 JP 7629880B2 JP 2022009741 A JP2022009741 A JP 2022009741A JP 2022009741 A JP2022009741 A JP 2022009741A JP 7629880 B2 JP7629880 B2 JP 7629880B2
Authority
JP
Japan
Prior art keywords
test
code
source code
input
program
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
JP2022009741A
Other languages
Japanese (ja)
Other versions
JP2023108555A (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.)
Hitachi Ltd
Original Assignee
Hitachi 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 Hitachi Ltd filed Critical Hitachi Ltd
Priority to JP2022009741A priority Critical patent/JP7629880B2/en
Publication of JP2023108555A publication Critical patent/JP2023108555A/en
Application granted granted Critical
Publication of JP7629880B2 publication Critical patent/JP7629880B2/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Debugging And Monitoring (AREA)

Description

本発明は、プログラム修正支援システム、プログラム修正支援方法に関する。 The present invention relates to a program correction support system and a program correction support method.

従来から、プログラムの単体テストにおけるデバッグ作業において、不具合を含む箇所を特定し、当該箇所に対する修正パッチを生成する技術がある。このような技術として、例えば、特許文献1がある。特許文献1には、ソフトウェアプログラム内の欠陥箇所を特定し、修復候補に基づき、前記欠陥箇所で、可能な修復を生成し、前記可能な修復をテストするよう第1テストを自動生成し、前記第1テストに基づき、第1テストオラクルのための第1クエリを生成し、前記第1クエリに対する応答を人間から取得し、前記第1クエリ及び該第1クエリに対する前記取得された応答に基づき、人間が提供した第1テストオラクルを生成し、拡張された第1テストを生成するよう、前記人間が提供した第1テストオラクルを前記第1テストに加え、前記拡張された第1テストを含むようテストスイートを増補し、前記増補されたテストスイートを用いて、前記可能な修復をテストする、ことが記載されている。 There has been a technique for identifying a location containing a defect and generating a patch for the location in the debugging work in the unit test of a program. For example, Patent Document 1 is one such technique. Patent Document 1 describes the following: identifying a defective location in a software program, generating a possible repair at the defective location based on a repair candidate, automatically generating a first test to test the possible repair, generating a first query for a first test oracle based on the first test, obtaining a response to the first query from a human, generating a first human-provided test oracle based on the first query and the obtained response to the first query, adding the first human-provided test oracle to the first test to generate an extended first test, augmenting a test suite to include the extended first test, and testing the possible repair using the augmented test suite.

特開2019-29015号公報JP 2019-29015 A

上記特許文献1では、テストケースの入力を生成する方法として、引数を並べ替えることしか開示されていない。この方法では、必ずしもパッチ候補の検証に有効なテストケースを生成できないことがある。 The above-mentioned Patent Document 1 discloses only rearranging arguments as a method for generating test case inputs. This method may not necessarily generate test cases that are effective for verifying patch candidates.

例えば、中央値を求める機能median(n1,n2,n3)のテストケースとして、元々「median(2,6,8)の出力が6である」がある場合、新たな入力として、median(8,6,2)やmedian(6,8,2)を生成することができない。また、例えば、元のソースコードにおいて、引数に負の数が入るときに不具合が発生する場合、不具合箇所の特定において見落としが生じてしまう。さらに、生成されたパッチにおいて同様の不具合が発生する場合、パッチ候補の検証で見落としてしまい、不具合が発生するパッチを出力してしまう。 For example, if the test case for the function median(n1, n2, n3) that finds the median is originally "the output of median(2, 6, 8) is 6," it is not possible to generate median(8, 6, 2) or median(6, 8, 2) as new inputs. Also, for example, if a defect occurs when a negative number is entered as an argument in the original source code, the defect will be overlooked when identifying the defective location. Furthermore, if a similar defect occurs in the generated patch, it will be overlooked when verifying the patch candidate, and the patch with the defect will be output.

一方で、網羅的(brute-force)またはランダムにテストケースの入力を生成すると、無駄に多くのテストケースが生成され、開発者が出力(期待値)を設定する手間が増えてしまう。 On the other hand, brute-force or random generation of test case inputs generates many unnecessary test cases and increases the effort required of developers to set the outputs (expectations).

本発明は、パッチ候補の検証に効果的なテストケースを、無駄なテストケースを生成することなく生成することが可能な技術を提供することを目的とする。 The present invention aims to provide a technology that can generate test cases that are effective for verifying patch candidates without generating unnecessary test cases.

本発明にかかるプログラム修正支援システムは、演算部と記憶部とを有したコンピュータにより、プログラムの修正を支援するプログラム修正支援システムであって、前記演算部は、ソースコードを解析し、当該解析により得られた前記ソースコードの入力値の条件と出力とを取得し、前記入力値の条件と出力とについての修正に関する候補を示す修正時情報と、テストコードにより前記ソースコードをテストするテストケースを増やすためのテスト追加基準とに基づいて、前記テストケースを拡充する、ことを特徴とするプログラム修正支援システムとして構成される。 The program correction support system according to the present invention is a program correction support system that supports program correction using a computer having a calculation unit and a storage unit, and is configured as a program correction support system characterized in that the calculation unit analyzes source code, obtains input value conditions and outputs of the source code obtained by the analysis, and expands the test cases based on correction time information indicating candidates for correction of the input value conditions and outputs and test addition criteria for increasing the number of test cases that test the source code using test code.

本発明によれば、パッチ候補の検証に効果的なテストケースを、無駄なテストケースを生成することなく生成することができる。 According to the present invention, it is possible to generate test cases that are effective for verifying patch candidates without generating unnecessary test cases.

本実施例におけるプログラム修正支援システムのハードウェア構成の一例を示す図である。FIG. 2 is a diagram illustrating an example of a hardware configuration of the program modification support system according to the present embodiment. 図1に示したプログラム修正装置の機能的な構成の一例を示す図である。2 is a diagram illustrating an example of a functional configuration of the program correction device illustrated in FIG. 1 . ソースコードの一例を示す図である。FIG. 13 is a diagram illustrating an example of source code. テストコードの一例を示す図である。FIG. 13 illustrates an example of a test code. 不具合箇所候補の一例を示す図である。FIG. 11 is a diagram showing an example of a defective part candidate; パッチ候補の一例を示す図である。FIG. 13 is a diagram illustrating an example of patch candidates. テスト追加基準の一例を示す図である。FIG. 13 is a diagram showing an example of a test addition criterion. 生成後テストコードの一例を示す図である。FIG. 13 is a diagram illustrating an example of generated test code. 修正結果の一例を示す図である。FIG. 13 is a diagram showing an example of a correction result. 本実施例において行われるプログラム修正処理の処理手順を示すフローチャートの一例を示す図である。FIG. 13 is a diagram illustrating an example of a flowchart showing a processing procedure of a program correction process performed in the present embodiment. 図10に示したS1003において行われるテスト生成処理の処理手順を示すフローチャートの一例を示す図である。FIG. 11 is a diagram illustrating an example of a flowchart showing a processing procedure of the test generation process performed in step S1003 shown in FIG. 10;

以下、図面を参照して本発明の実施形態を説明する。以下の記載および図面は、本発明を説明するための例示であって、説明の明確化のため、適宜、省略および簡略化がなされている。本発明は、他の種々の形態でも実施する事が可能である。特に限定しない限り、各構成要素は単数でも複数でも構わない。 The following describes an embodiment of the present invention with reference to the drawings. The following description and drawings are examples for explaining the present invention, and some parts have been omitted or simplified as appropriate for clarity of explanation. The present invention can also be implemented in various other forms. Unless otherwise specified, each component may be singular or plural.

図面において示す各構成要素の位置、大きさ、形状、範囲などは、発明の理解を容易にするため、実際の位置、大きさ、形状、範囲などを表していない場合がある。このため、本発明は、必ずしも、図面に開示された位置、大きさ、形状、範囲などに限定されない。 The position, size, shape, range, etc. of each component shown in the drawings may not represent the actual position, size, shape, range, etc., in order to facilitate understanding of the invention. Therefore, the present invention is not necessarily limited to the position, size, shape, range, etc. disclosed in the drawings.

以下の説明では、「データベース」、「テーブル」、「リスト」等の表現にて各種情報を説明することがあるが、各種情報は、これら以外のデータ構造で表現されていてもよい。データ構造に依存しないことを示すために「XXテーブル」、「XXリスト」等を「XX情報」と呼ぶことがある。識別情報について説明する際に、「識別情報」、「識別子」、「名」、「ID」、「番号」等の表現を用いた場合、これらについてはお互いに置換が可能である。 In the following explanation, various types of information may be explained using expressions such as "database," "table," and "list," but the various types of information may be expressed in data structures other than these. To indicate independence from data structure, "XX table," "XX list," and the like may be referred to as "XX information." When explaining identification information, when expressions such as "identification information," "identifier," "name," "ID," and "number" are used, these are interchangeable.

同一あるいは同様な機能を有する構成要素が複数ある場合には、同一の符号に異なる添字を付して説明する場合がある。ただし、これらの複数の構成要素を区別する必要がない場合には、添字を省略して説明する場合がある。 When there are multiple components with the same or similar functions, they may be described using the same reference numerals with different subscripts. However, when there is no need to distinguish between these multiple components, the subscripts may be omitted.

また、以下の説明では、プログラムを実行して行う処理を説明する場合があるが、プログラムは、プロセッサ(例えばCPU(Central Processing Unit)、GPU(Graphics Processing Unit))によって実行されることで、定められた処理を、適宜に記憶資源(例えばメモリ)および/またはインターフェースデバイス(例えば通信ポート)等を用いながら行うため、処理の主体がプロセッサとされてもよい。同様に、プログラムを実行して行う処理の主体が、プロセッサを有するコントローラ、装置、システム、計算機、ノードであってもよい。プログラムを実行して行う処理の主体は、演算部であれば良く、特定の処理を行う専用回路(例えばFPGA(Field-Programmable Gate Array)やASIC(Application Specific Integrated Circuit))を含んでいてもよい。 In addition, the following description may describe processing performed by executing a program, but the program is executed by a processor (e.g., a CPU (Central Processing Unit), a GPU (Graphics Processing Unit)) to perform a specified process using storage resources (e.g., memory) and/or interface devices (e.g., communication ports) as appropriate, so the subject of the processing may be the processor. Similarly, the subject of the processing performed by executing a program may be a controller, device, system, computer, or node having a processor. The subject of the processing performed by executing a program may be a calculation unit, and may include a dedicated circuit (e.g., an FPGA (Field-Programmable Gate Array) or an ASIC (Application Specific Integrated Circuit)) that performs a specific process.

プログラムは、プログラムソースから計算機のような装置にインストールされてもよい。プログラムソースは、例えば、プログラム配布サーバまたは計算機が読み取り可能な記憶メディアであってもよい。プログラムソースがプログラム配布サーバの場合、プログラム配布サーバはプロセッサと配布対象のプログラムを記憶する記憶資源を含み、プログラム配布サーバのプロセッサが配布対象のプログラムを他の計算機に配布してもよい。また、以下の説明において、2以上のプログラムが1つのプログラムとして実現されてもよいし、1つのプログラムが2以上のプログラムとして実現されてもよい。 The program may be installed in a device such as a computer from a program source. The program source may be, for example, a program distribution server or a computer-readable storage medium. When the program source is a program distribution server, the program distribution server may include a processor and a storage resource that stores the program to be distributed, and the processor of the program distribution server may distribute the program to be distributed to other computers. Also, in the following description, two or more programs may be realized as one program, and one program may be realized as two or more programs.

以下、本実施例にかかるプログラム修正支援システム、プログラム修正支援方法の一実施例の構成について説明する。 The following describes the configuration of one embodiment of the program correction support system and program correction support method according to this embodiment.

図1は、本実施例におけるプログラム修正支援システムのハードウェア構成の一例を示す図である。以下では、プログラム修正支援システムが、ある1つのコンピュータであるプログラム修正装置100により構成される場合を例示するが、これらの機能の全部または一部が、クラウドのような1または複数のコンピュータに分散して設けられ、ネットワークを介して互いに通信することにより同様の機能を実現してもよい。プログラム修正装置100を構成する各部が行う具体的な処理については、フローチャートを用いて後述する。
図1に示すようにプログラム修正装置100は、CPU等のプロセッサ110と、メモリ等の主記憶装置120と、HDD(Hard Disk Drive)等の補助記憶装置130と、スキャナ、キーボード、マウスといった入力装置140と、ディスプレイ等の出力装置150と、通信ネットワークに接続するためのNIC(Network Interface Card)等の通信装置160と、を備えた一般的なコンピュータにより実現できる。
1 is a diagram showing an example of the hardware configuration of a program modification support system in this embodiment. In the following, an example is shown in which the program modification support system is configured by a program modification device 100, which is a single computer, but all or part of these functions may be distributed and provided in one or more computers, such as a cloud, and similar functions may be realized by communicating with each other via a network. Specific processes performed by each unit constituting the program modification device 100 will be described later using a flowchart.
As shown in FIG. 1, the program modification device 100 can be realized by a general computer having a processor 110 such as a CPU, a main storage device 120 such as a memory, an auxiliary storage device 130 such as a HDD (Hard Disk Drive), an input device 140 such as a scanner, keyboard, or mouse, an output device 150 such as a display, and a communication device 160 such as a NIC (Network Interface Card) for connecting to a communication network.

図2は、図1に示したプログラム修正装置100の機能的な構成の一例を示す図である。図2に示すように、本実施例にかかるプログラム修正装置100は、不具合箇所特定部210と、パッチ候補生成部220と、テスト生成部230と、パッチ候補検証部240と、情報記憶部290とを有して構成される。また、情報記憶部290には、ソースコード291と、テストコード292と、不具合箇所候補293と、パッチ候補294と、テスト追加基準295と、生成後テストコード296と、修正結果297とが記憶される。 Figure 2 is a diagram showing an example of the functional configuration of the program correction device 100 shown in Figure 1. As shown in Figure 2, the program correction device 100 according to this embodiment is configured to have a defect location identification unit 210, a patch candidate generation unit 220, a test generation unit 230, a patch candidate verification unit 240, and an information storage unit 290. The information storage unit 290 also stores source code 291, test code 292, defect location candidates 293, patch candidates 294, test addition criteria 295, generated test code 296, and correction results 297.

プログラム修正装置100に記憶され、あるいは処理に用いられる様々なデータ(例えば、ソースコード291、テストコード292、不具合箇所候補293、パッチ候補294、テスト追加基準295、生成後テストコード296、修正結果297)は、プロセッサ110が主記憶装置120または補助記憶装置130から読み出して利用することにより実現可能である。また、プログラム修正装置100の各機能部(例えば、不具合箇所特定部210、パッチ候補生成部220、テスト生成部230、パッチ候補検証部240)は、プロセッサ110が補助記憶装置130に記憶されている所定のプログラムを主記憶装置120にロードして実行することにより実現可能である。 The various data stored in the program modification device 100 or used in processing (e.g., source code 291, test code 292, defect location candidate 293, patch candidate 294, test addition criteria 295, generated test code 296, modification result 297) can be realized by the processor 110 reading them from the main memory device 120 or the auxiliary memory device 130 and using them. Also, each functional unit of the program modification device 100 (e.g., defect location identification unit 210, patch candidate generation unit 220, test generation unit 230, patch candidate verification unit 240) can be realized by the processor 110 loading a specific program stored in the auxiliary memory device 130 into the main memory device 120 and executing it.

上述した所定のプログラムは、通信装置160を介してネットワークから、あるいはUSB(Universal Serial Bus)等の記憶媒体から、補助外部記憶装置130に記憶(ダウンロード)され、それから、主記憶装置120上にロードされて、プロセッサ110により実行されるようにしてもよいし、主記憶装置120上に直接ロードされ、プロセッサ110により実行されるようにしてもよい。 The above-mentioned specific program may be stored (downloaded) into the auxiliary external storage device 130 from a network via the communication device 160 or from a storage medium such as a USB (Universal Serial Bus), and then loaded onto the main storage device 120 and executed by the processor 110, or may be loaded directly onto the main storage device 120 and executed by the processor 110.

不具合箇所特定部210は、ソースコード291と、ソースコード291をテストするためのテストコード292とを用いて、ソースコード291の不具合箇所の候補を特定する。 The defect identification unit 210 uses the source code 291 and the test code 292 for testing the source code 291 to identify candidates for defect locations in the source code 291.

パッチ候補生成部220は、所定の修正パタンに基づいて、ソースコードの不具合箇所の候補を修正したパッチ候補を生成する。 The patch candidate generation unit 220 generates patch candidates that correct candidate defect locations in the source code based on a specified correction pattern.

テスト生成部230は、上記ソースコードの不具合箇所の候補または/および上記パッチ候補の検証に関するテスト基準や後述するテスト追加基準に基づいて、前記ソースコードに対するテストケースを生成する。 The test generation unit 230 generates test cases for the source code based on test criteria related to verification of candidate defect locations in the source code and/or candidate patches, as well as test addition criteria described below.

図3は、ソースコード291の一例を示す図である。ソースコード291は、不具合を含むコードである。具体的には後述するが、図3では、例えば、ソースコード291に、本来であれば「false」が記述されるべきところ、「true」が記述された不具合箇所301が含まれていることを示している。 Figure 3 is a diagram showing an example of source code 291. Source code 291 is code that includes a defect. As will be described in detail later, Figure 3 shows, for example, that source code 291 includes a defect location 301 in which "true" is written where "false" should actually be written.

図4は、テストコード292の一例を示す図である。テストコード292は、ソースコード291の不具合箇所を特定するためのコードである。図4では、例えば、数値「5」をソースコード291に入力した場合の期待値は「false」であり(test1)、数値「20」をソースコード291に入力した場合の期待値は「false」である(test2)ことを示している。 Figure 4 is a diagram showing an example of test code 292. Test code 292 is code for identifying defective parts of source code 291. Figure 4 shows, for example, that when a numeric value "5" is input into source code 291, the expected value is "false" (test1), and when a numeric value "20" is input into source code 291, the expected value is "false" (test2).

図5は、不具合箇所候補293の一例を示す図である。不具合箇所候補293は、ソースコード291の含まれる不具合箇所の候補を記憶したテーブルである。図5に示すように、不具合箇所候補293は、不具合箇所を識別するためのIDと、当該IDで識別される不具合箇所の候補とが対応付けて記憶される。図5では、例えば、ID「1」で識別される不具合箇所の候補は「2行目」であることを示している。 Figure 5 is a diagram showing an example of defect location candidate 293. Defect location candidate 293 is a table that stores defect location candidate included in source code 291. As shown in Figure 5, defect location candidate 293 stores an ID for identifying a defect location and a defect location candidate identified by the ID in association with each other. Figure 5 shows, for example, that the defect location candidate identified by ID "1" is "line 2."

図6は、パッチ候補294の一例を示す図である。パッチ候補294は、ソースコード291を所定の修正パタンで修正したコードである。図6に示すように、パッチ候補294は、パッチの候補を識別するためのIDと、当該IDで識別されるパッチの候補とが対応付けて記憶される。図6では、例えば、ID「1」で識別されるパッチの候補は、ソースコード291の2行目の「x>1」を「x>=1」に修正したコードであることを示している。 Figure 6 is a diagram showing an example of a patch candidate 294. Patch candidate 294 is code obtained by modifying source code 291 using a specified modification pattern. As shown in Figure 6, patch candidate 294 is stored in association with an ID for identifying the patch candidate and the patch candidate identified by that ID. In Figure 6, for example, the patch candidate identified by ID "1" indicates that it is code obtained by modifying "x>1" on the second line of source code 291 to "x>=1".

図7は、テスト追加基準295の一例を示す図である。テスト追加基準295は、テストケースを追加する基準を定めたテーブルである。図7に示すように、テスト追加基準295は、追加する基準を識別するためのIDと、当該IDで識別されるテストの追加基準とが対応付けて記憶される。本例では特に例示していないが、追加される前のテスト基準については、従来から知られている様々な方法により定められているものとする。 Figure 7 is a diagram showing an example of test addition criteria 295. Test addition criteria 295 is a table that defines criteria for adding test cases. As shown in Figure 7, test addition criteria 295 stores an ID for identifying the criteria to be added and the test addition criteria identified by that ID in association with each other. Although not specifically illustrated in this example, it is assumed that the test criteria before being added are defined by various conventionally known methods.

図7では、例えば、ID「1」で識別されるテストの追加基準は、「不具合箇所候補のカバレッジを上げる入力値」であることを示している。特許文献1では、テストケースの入力を生成する方法として、引数を並べ替えることが記載されているが、どのような基準でテストを行うのかについては開示されておらず、必ずしも適切にソースコードの不具合をテストすることができない。この例では、「不具合箇所候補のカバレッジを上げる入力値」のほか、「パッチ候補の条件式の境界値」をテスト追加基準として例示する。具体的には後述するが、前者の例では、不具合箇所特定の結果、不具合のある(あるいは可能性の高い)メソッドや命令ブロックに対してテストコードを生成するため、当該箇所のカバレッジ(テストで実行される処理、条件分岐、実行パスの網羅率)が向上することで、パッチ候補の検証精度を向上できる。また、後者の例では、パッチ候補生成の結果、出力されたパッチ候補に基づいてテストコードを生成するため、例えば、境界値を生成することで、パッチ候補の検証精度を向上できる。一例を示すと、if(x>0)をif(x>1)に修正すべきところ、パッチ候補としてif(x≧1)が生成された場合、境界値x=1を入力とするテストを追加することで、誤ったパッチ候補を落とすことができる。 In FIG. 7, for example, the additional criterion for the test identified by ID "1" is "input value that increases the coverage of the defective part candidate". Patent Document 1 describes rearranging arguments as a method for generating input for a test case, but does not disclose the criteria for testing, and source code defects cannot always be tested appropriately. In this example, in addition to "input value that increases the coverage of the defective part candidate", "boundary value of the conditional expression of the patch candidate" is exemplified as an additional criterion for testing. As will be described later in detail, in the former example, test code is generated for a defective (or highly likely) method or instruction block as a result of identifying the defective part, so that the coverage of the part (coverage rate of the process executed in the test, conditional branch, and execution path) is improved, thereby improving the verification accuracy of the patch candidate. In the latter example, test code is generated based on the patch candidate output as a result of patch candidate generation, so that, for example, boundary values can be generated to improve the verification accuracy of the patch candidate. As an example, if if(x>0) should be corrected to if(x>1), but if(x>1) is generated as a patch candidate, adding a test with the boundary value x=1 as input can eliminate the incorrect patch candidate.

図8は、生成後テストコード296の一例を示す図である。生成後テストコード296は、テストコード292に、テスト追加基準295で定められた基準のテストコードが追加されたコードである。図8に示すように、生成後テストコード296は、図4に示したテストコード292に含まれるtest1、test2に、新たにtest3、test4、test5で示すコードが追加されていることを示している。 Figure 8 is a diagram showing an example of generated test code 296. Generated test code 296 is code in which test code according to the criteria defined in test addition criteria 295 has been added to test code 292. As shown in Figure 8, generated test code 296 indicates that new code shown as test3, test4, and test5 has been added to test1 and test2 included in test code 292 shown in Figure 4.

図9は、修正結果297の一例を示す図である。修正結果297は、ソースコード291を修正した結果を示すコードである。図9に示すように、修正結果297は、図2に示したソースコード291を、図6に示したパッチ候補294のID「3」のコードで修正されていることを示している。 Figure 9 is a diagram showing an example of the correction result 297. The correction result 297 is code that shows the result of correcting the source code 291. As shown in Figure 9, the correction result 297 shows that the source code 291 shown in Figure 2 has been corrected with the code with ID "3" of the patch candidate 294 shown in Figure 6.

図10は、本実施例において行われるプログラム修正処理の処理手順を示すフローチャートの一例を示す図である。 Figure 10 is an example of a flowchart showing the processing steps of the program correction process performed in this embodiment.

S1010において、不具合箇所特定部210は、図4に示したテストコード292を図3に示したソースコード291に適用し、ソースコード291の不具合箇所を特定する。例えば、不具合箇所特定部210は、ソースコード中の各行に対し、不具合を含む可能性の高さを計算し、計算した結果が所定の閾値以上となる行を不具合箇所として特定する。不具合箇所特定部210は、特定した不具合箇所を、図5に示した不具合箇所候補293として出力する。 In S1010, the defect identification unit 210 applies the test code 292 shown in FIG. 4 to the source code 291 shown in FIG. 3 to identify a defect in the source code 291. For example, the defect identification unit 210 calculates the likelihood that each line in the source code contains a defect, and identifies a line for which the calculation result is equal to or greater than a predetermined threshold as a defect. The defect identification unit 210 outputs the identified defect as a defect candidate 293 shown in FIG. 5.

S1020において、パッチ候補生成部220は、ソースコード291において、出力された不具合箇所を、所定の修正パタンにより修正したソースコードを、パッチ候補294として出力する。このように、パッチ候補生成部220は、不具合を含む可能性の高い行を書き換えることで、テストに通るような修正パッチ案を複数生成する。上記所定の修正パタンは、例えば、不足する文の挿入、インスタンス生成方法の変更、条件式の変更等、修正内容を記述したパタンをあらかじめ定めておけばよい。 In S1020, the patch candidate generation unit 220 outputs source code obtained by correcting the output defect location in the source code 291 using a predetermined correction pattern as a patch candidate 294. In this way, the patch candidate generation unit 220 generates multiple correction patch proposals that pass the test by rewriting lines that are likely to contain defects. The above-mentioned predetermined correction pattern may be a pattern that describes the correction content, such as inserting missing statements, changing the instance generation method, changing a conditional expression, etc., that is determined in advance.

S1030において、テスト生成部230は、出力されたパッチ候補のそれぞれについて、テスト追加基準295に基づいたテストコードを生成する。S1003の具体的な処理については、図11を用いて後述する。 In S1030, the test generation unit 230 generates test code for each of the output patch candidates based on the test addition criteria 295. The specific processing of S1003 will be described later with reference to FIG. 11.

S1040において、パッチ候補検証部240は、生成されたテストコードを実行し、あらかじめ定められた各種テストに成功するパッチ候補を、最終的なパッチ案として出力する。 At S1040, the patch candidate verification unit 240 executes the generated test code and outputs patch candidates that pass various predefined tests as the final patch proposal.

図11は、図10に示したS1003において行われるテスト生成処理の処理手順を示すフローチャートの一例を示す図である。 Figure 11 is an example of a flowchart showing the processing steps of the test generation process performed in S1003 shown in Figure 10.

S1110において、テスト生成部230は、修正前のソースコード291を解析し、入力値の条件と出力値の組を取得する。例えば、テスト生成部230は、図3に示したソースコード291を解析し、入力条件として、「x>1」および「x≦1」、それぞれに対応する出力「true」、「false」を取得する。これらの情報は、記号実行(シンボリック実行)等の技術を用いて実現することができる。 In S1110, the test generation unit 230 analyzes the source code 291 before modification and obtains pairs of input value conditions and output values. For example, the test generation unit 230 analyzes the source code 291 shown in FIG. 3 and obtains the input conditions "x>1" and "x≦1" and the corresponding outputs "true" and "false", respectively. This information can be realized using a technique such as symbolic execution.

S1120において、テスト生成部230は、追加される前のテストコードで実行されていない命令または条件を実行するような入力値と期待値を取得する。期待値は、修正前のソースコードの出力値としてもよい。例えば、図4に示したテストコード292では、ソースコード291における「x≦1」を満たすテストケースが記載されていない。したがって、テスト生成部230は、例えば、当該「x≦1」を満たすテストケースを満たすような「X=0」の入力値を取得する。S1120に示したように、テスト生成部230は、図7に示したテスト追加基準295を読み出し、ID「1」に対応する「不具合箇所候補のカバレッジを上げる入力値」を取得する。 In S1120, the test generation unit 230 obtains an input value and an expected value that executes an instruction or condition that is not executed in the test code before it is added. The expected value may be the output value of the source code before modification. For example, in the test code 292 shown in FIG. 4, a test case that satisfies "x≦1" in the source code 291 is not described. Therefore, the test generation unit 230 obtains an input value of "X=0" that satisfies the test case that satisfies "x≦1". As shown in S1120, the test generation unit 230 reads the test addition criteria 295 shown in FIG. 7, and obtains the "input value that increases the coverage of the defective part candidate" that corresponds to ID "1".

S1130において、テスト生成部230は、パッチ候補のそれぞれを解析し、入力条件の境界値を取得する。当該境界値の取得は、記号実行(シンボリック実行)等の技術を用いて実現することができる。例えば、テスト生成部230は、図6に示したID「1」のパッチ候補について、境界値として「x=1」を取得する。また、テスト生成部230は、ID「2」、「3」のパッチ候補について、境界値として「x=10」を取得する。S1130に示したように、テスト生成部230は、図7に示したテスト追加基準295を読み出し、ID「2」に対応する「パッチ候補の条件式の境界値」を取得する。 In S1130, the test generation unit 230 analyzes each patch candidate and obtains the boundary value of the input condition. The boundary value can be obtained using a technique such as symbolic execution. For example, the test generation unit 230 obtains "x=1" as the boundary value for the patch candidate with ID "1" shown in FIG. 6. The test generation unit 230 also obtains "x=10" as the boundary value for the patch candidates with IDs "2" and "3". As shown in S1130, the test generation unit 230 reads the test addition criteria 295 shown in FIG. 7 and obtains the "boundary value of the conditional expression of the patch candidate" corresponding to ID "2".

S1140において、テスト生成部230は、取得したテストの入力値を開発者に提示し、正しい期待値を開発者から取得する。例えば、テスト生成部230は、出力装置150の一例であるディスプレイに、取得した境界値「x=1」、あるいは「x=10」を表示する。また、例えば、テスト生成部230は、開発者から、入力装置140の一例であるキーボードから入力された期待値「true」あるいは「false」を取得する。 In S1140, the test generation unit 230 presents the acquired test input values to the developer and acquires the correct expected values from the developer. For example, the test generation unit 230 displays the acquired boundary values "x=1" or "x=10" on a display, which is an example of the output device 150. Also, for example, the test generation unit 230 acquires from the developer the expected values "true" or "false" input from a keyboard, which is an example of the input device 140.

S1150において、テスト生成部230は、S1120、S1130において取得した入力値、およびS1140において取得した期待値をテストケースとするテストコードを生成する。例えば、テスト生成部230は、S1120で取得した入力値「X=0」および期待値「false」を含むコード801を、生成後テストコード296に追加する。また、テスト生成部230は、S1130で取得した入力値「X=1」および期待値「false」を含むコード802、および入力値「X=10」および期待値「true」を含むコード803を、生成後テストコード296に追加する。 In S1150, the test generation unit 230 generates test code with the input values acquired in S1120 and S1130, and the expected value acquired in S1140 as test cases. For example, the test generation unit 230 adds code 801 including the input value "X=0" and expected value "false" acquired in S1120 to the generated test code 296. The test generation unit 230 also adds code 802 including the input value "X=1" and expected value "false" acquired in S1130, and code 803 including the input value "X=10" and expected value "true" to the generated test code 296.

このように、本実施例では、演算部(例えば、CPU)と記憶部(例えば、メモリ)とを有したコンピュータにより、プログラムの修正を支援するプログラム修正支援システムにおいて、上記演算部は、ソースコード(例えば、ソースコード291)を解析し、当該解析により得られた上記ソースコードの入力値の条件と出力(例えば、「x>1」および「true」、「x≦1」および「false」の組)とを取得し、上記入力値の条件と出力とについての修正に関する候補を示す修正時情報(例えば、不具合箇所候補293、パッチ候補294)と、テストコード(例えば、テストコード292)により上記ソースコードをテストするテストケースを増やすためのテスト追加基準(例えば、テスト追加基準295)とに基づいて、上記テストケースを拡充する。このように、修正時情報とテスト追加基準に基づいたテストケースを拡充することで、パッチ候補検証において,正しくないパッチ候補を高い精度で除外できる。また、修正時情報とテスト追加基準に基づいたテストケースのみを拡充することで、開発者が期待値を設定する手間を削減できる。 In this embodiment, in a program correction support system that supports program correction using a computer having a calculation unit (e.g., a CPU) and a storage unit (e.g., a memory), the calculation unit analyzes source code (e.g., source code 291), obtains input value conditions and outputs (e.g., a set of "x>1" and "true", "x≦1" and "false") of the source code obtained by the analysis, and expands the test cases based on correction time information (e.g., defect location candidate 293, patch candidate 294) indicating candidates for correction of the input value conditions and outputs, and test addition criteria (e.g., test addition criteria 295) for increasing the number of test cases that test the source code using test code (e.g., test code 292). In this way, by expanding the test cases based on the correction time information and the test addition criteria, incorrect patch candidates can be excluded with high accuracy in patch candidate verification. In addition, by expanding only the test cases based on the correction time information and the test addition criteria, the developer's effort in setting expected values can be reduced.

また、上記修正時情報には、上記ソースコードの不具合箇所の候補(例えば、不具合箇所候補293に示したソースコード291の「2行目」)を含み、上記演算部は、上記不具合箇所のカバレッジが増加する入力を含むテストケース(例えば、ソースコード291における「x≦1」を満たすテストケース「X=0」)を生成し、上記テストケースを含むテストコードを出力する。したがって、パッチ候補検証において、不具合箇所のカバレッジを考慮しつつ、正しくないパッチ候補を高い精度で除外できる。 The modification time information also includes a candidate for the defective part of the source code (e.g., "line 2" of source code 291 shown as defective part candidate 293), and the calculation unit generates a test case including an input that increases the coverage of the defective part (e.g., test case "X=0" that satisfies "x≦1" in source code 291), and outputs test code including the test case. Therefore, in patch candidate verification, incorrect patch candidates can be excluded with high accuracy while taking into account the coverage of the defective part.

また、上記修正時情報には、上記ソースコードのパッチ候補(例えば、ソースコード291を所定の修正パタンで修正したパッチ候補294)を含み、上記演算部は、上記パッチ候補における境界値の入力を含むテストケース(例えば、パッチ候補294のID「1」のパッチ候補についての境界値「x=1」)を生成し、上記テストケースを含むテストコードを出力する。したがって、パッチ候補検証において、パッチ候補における境界値を考慮しつつ、正しくないパッチ候補を高い精度で除外できる。 The modification time information also includes a patch candidate for the source code (e.g., patch candidate 294 obtained by modifying source code 291 with a predetermined modification pattern), and the calculation unit generates a test case including an input of a boundary value for the patch candidate (e.g., boundary value "x=1" for patch candidate with ID "1" of patch candidate 294), and outputs test code including the test case. Therefore, in patch candidate verification, incorrect patch candidates can be excluded with high accuracy while taking into account the boundary values for the patch candidates.

また、上記演算部は、テストの入力値(例えば、上記「X=0」の入力値)を生成し、生成した入力値に対する期待値を上記プログラム修正支援システムの外部から取得(例えば、開発者が入力した期待値「true」を取得)し、上記入力値と上記期待値を含むテストケースを生成し、上記テストケースを含むテストコードを生成する。したがって、開発者の想定(設計)通りのテストケースを生成でき、その結果、生成されるテストケースの品質を向上させることができる。 The calculation unit also generates a test input value (e.g., the input value of "X=0"), obtains an expected value for the generated input value from outside the program correction support system (e.g., obtains the expected value "true" input by the developer), generates a test case including the input value and the expected value, and generates test code including the test case. Therefore, it is possible to generate test cases as expected (designed) by the developer, and as a result, the quality of the generated test cases can be improved.

なお、本実施例では、取得した境界値を出力装置150の一例であるディスプレイに表示し、あるいは入力装置140の一例であるキーボードから入力された期待値を取得することとした。しかし、入力装置140としてマイクのような音声入力装置や、出力装置150としてスピーカのような音声出力装置を有する場合には、当該装置を通じた音声により境界値を出力したり、あるいは期待値の入力を受け付ける等、ユーザが認識可能な他の態様のインタフェースを用いてもよい。 In this embodiment, the acquired boundary value is displayed on a display, which is an example of the output device 150, or the expected value is acquired as input from a keyboard, which is an example of the input device 140. However, if the input device 140 includes an audio input device such as a microphone, or the output device 150 includes an audio output device such as a speaker, it is also possible to use other types of interface that can be recognized by the user, such as outputting the boundary value by voice through the device, or accepting input of the expected value.

本発明は、上記実施の形態そのままに限定されるものではなく、実施段階ではその要旨を逸脱しない範囲で構成要素を変形して具体化したり、上記実施の形態に開示されている複数の構成要素を適宜組み合わせて実施することができる。 The present invention is not limited to the above-described embodiment as it is, and in the implementation stage, the components can be modified and embodied without departing from the spirit of the invention, or multiple components disclosed in the above-described embodiment can be appropriately combined.

100 プログラム修正装置
210 不具合箇所特定部
220 パッチ候補生成部
230 テスト生成部
240 パッチ候補検証部
290 情報記憶部
291 ソースコード
292 テストコード
293 不具合箇所候補
294 パッチ候補
295 テスト追加基準
296 生成後テストコード
297 修正結果
100 Program correction device 210 Defective part identification unit 220 Patch candidate generation unit 230 Test generation unit 240 Patch candidate verification unit 290 Information storage unit 291 Source code 292 Test code 293 Defective part candidate 294 Patch candidate 295 Test addition criteria 296 Generated test code 297 Correction result

Claims (6)

演算部と記憶部とを有したコンピュータにより、プログラムの修正を支援するプログラム修正支援システムであって、
前記演算部は、
ソースコードを解析し、当該解析により得られた前記ソースコードの入力値の条件と出力とを取得し、
前記入力値の条件と出力とについての修正に関する候補を示す修正時情報と、テストコードにより前記ソースコードをテストするテストケースを増やすためのテスト追加基準とに基づいて、前記テストケースを拡充する場合において、
前記修正時情報には、前記ソースコードの不具合箇所の候補を含み、
前記演算部は、前記不具合箇所のカバレッジが増加する入力として、テストで実行される処理、条件分岐、実行パスの網羅率を向上させる入力を含むテストケースを生成し、前記テストケースを含むテストコードを出力する、
ことを特徴とするプログラム修正支援システム。
A program correction support system that supports program correction by a computer having a calculation unit and a storage unit,
The calculation unit is
Analyzing a source code, and obtaining input value conditions and outputs of the source code obtained by the analysis;
In a case where the test cases are expanded based on modification time information indicating candidates for modification of the input value conditions and the output and test addition criteria for increasing the number of test cases for testing the source code by the test code,
The modification time information includes candidates for defect locations in the source code,
the calculation unit generates a test case including an input that increases coverage of the defective portion, the input improving coverage of a process, a conditional branch, and an execution path executed in a test, and outputs a test code including the test case;
A program correction support system comprising:
前記修正時情報には、前記ソースコードのパッチ候補を含み、
前記演算部は、前記パッチ候補における境界値の入力を含むテストケースを生成し、前記テストケースを含むテストコードを出力する、
ことを特徴とする請求項1に記載のプログラム修正支援システム。
The modification time information includes a patch candidate for the source code,
the calculation unit generates a test case including an input of a boundary value in the patch candidate, and outputs a test code including the test case.
2. The program correction support system according to claim 1.
前記演算部は、テストの入力値を生成し、生成した入力値に対する期待値を前記プログラム修正支援システムの外部から取得し、前記入力値と前記期待値を含むテストケースを生成し、前記テストケースを含むテストコードを生成する、
ことを特徴とする請求項1に記載のプログラム修正支援システム。
the calculation unit generates a test input value, acquires an expected value for the generated input value from outside the program correction support system, generates a test case including the input value and the expected value, and generates a test code including the test case;
2. The program correction support system according to claim 1.
演算部と記憶部とを有したコンピュータにより、プログラムの修正を支援するプログラム修正支援システムで行われるプログラム修正支援方法であって、
ソースコードを解析し、当該解析により得られた前記ソースコードの入力値の条件と出力とを取得し、
前記入力値の条件と出力とについての修正に関する候補を示す修正時情報と、テストコードにより前記ソースコードをテストするテストケースを増やすためのテスト追加基準とに基づいて、前記テストケースを拡充する場合において、
前記修正時情報には、前記ソースコードの不具合箇所の候補を含み、
前記演算部は、前記不具合箇所のカバレッジが増加する入力として、テストで実行される処理、条件分岐、実行パスの網羅率を向上させる入力を含むテストケースを生成し、前記テストケースを含むテストコードを出力する、
ことを特徴とするプログラム修正支援方法。
A program modification support method performed in a program modification support system that supports program modification using a computer having a calculation unit and a storage unit, comprising:
Analyzing a source code, and obtaining input value conditions and outputs of the source code obtained by the analysis;
In a case where the test cases are expanded based on modification time information indicating candidates for modification of the input value conditions and the output and test addition criteria for increasing the number of test cases for testing the source code by the test code,
The modification time information includes candidates for defect locations in the source code,
the calculation unit generates a test case including an input that increases coverage of the defective portion, the input improving coverage of a process, a conditional branch, and an execution path executed in a test, and outputs a test code including the test case;
23. A program modification support method comprising:
前記修正時情報には、前記ソースコードのパッチ候補を含み、
前記パッチ候補における境界値の入力を含むテストケースを生成し、前記テストケースを含むテストコードを出力する、
ことを特徴とする請求項に記載のプログラム修正支援方法。
The modification time information includes a patch candidate for the source code,
generating a test case including an input of a boundary value in the patch candidate, and outputting a test code including the test case;
5. The program correction support method according to claim 4 .
テストの入力値を生成し、生成した入力値に対する期待値を前記プログラム修正支援システムの外部から取得し、前記入力値と前記期待値を含むテストケースを生成し、前記テストケースを含むテストコードを生成する、
ことを特徴とする請求項に記載のプログラム修正支援方法。
generating input values for a test, acquiring expected values for the generated input values from outside the program correction support system, generating test cases including the input values and the expected values, and generating test code including the test cases;
5. The program correction support method according to claim 4 .
JP2022009741A 2022-01-25 2022-01-25 Program modification support system and program modification support method Active JP7629880B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2022009741A JP7629880B2 (en) 2022-01-25 2022-01-25 Program modification support system and program modification support method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2022009741A JP7629880B2 (en) 2022-01-25 2022-01-25 Program modification support system and program modification support method

Publications (2)

Publication Number Publication Date
JP2023108555A JP2023108555A (en) 2023-08-04
JP7629880B2 true JP7629880B2 (en) 2025-02-14

Family

ID=87475199

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2022009741A Active JP7629880B2 (en) 2022-01-25 2022-01-25 Program modification support system and program modification support method

Country Status (1)

Country Link
JP (1) JP7629880B2 (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2000029741A (en) 1998-07-09 2000-01-28 Fujitsu Ltd Program test item creation device
JP2012248101A (en) 2011-05-30 2012-12-13 Ntt Data Corp Program test support device, program test support method, and program test support program
WO2016170937A1 (en) 2015-04-20 2016-10-27 三菱電機株式会社 Test automation device, test automation method, and test automation program
JP2019029015A (en) 2017-08-03 2019-02-21 富士通株式会社 Interactive software program repair

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2000029741A (en) 1998-07-09 2000-01-28 Fujitsu Ltd Program test item creation device
JP2012248101A (en) 2011-05-30 2012-12-13 Ntt Data Corp Program test support device, program test support method, and program test support program
WO2016170937A1 (en) 2015-04-20 2016-10-27 三菱電機株式会社 Test automation device, test automation method, and test automation program
JP2019029015A (en) 2017-08-03 2019-02-21 富士通株式会社 Interactive software program repair

Also Published As

Publication number Publication date
JP2023108555A (en) 2023-08-04

Similar Documents

Publication Publication Date Title
US10671516B2 (en) Method, device, and computer program product for testing code
US8621441B2 (en) System and method for software immunization based on static and dynamic analysis
CN110532185B (en) Test method, test device, electronic equipment and computer readable storage medium
US11113183B2 (en) Automated device test triaging system and techniques
US11663113B2 (en) Real time fault localization using combinatorial test design techniques and test case priority selection
JP6878707B2 (en) Test equipment, test methods and test programs
US10761962B1 (en) Automated software program repair
US20140047276A1 (en) Model-based testing of a graphical user interface
JP2019029015A (en) Interactive software program repair
JP2015011372A (en) Debug support system, method, program, and recording medium
JP6567212B2 (en) Equivalence verification device and equivalence verification program
WO2025246269A1 (en) Test code repairing method and related device
EP3734460B1 (en) Probabilistic software testing via dynamic graphs
CN110609786A (en) Software testing method and device, computer equipment and storage medium
JP7629880B2 (en) Program modification support system and program modification support method
US10642716B1 (en) Automated software program repair
US10481969B2 (en) Configurable system wide tests
JP4957521B2 (en) Software partial test system, method and program used therefor
US10503854B1 (en) Method and system for generating validation tests
US20120167037A1 (en) Software static testing apparatus and method
CN114253828B (en) Method, device, computing device and storage medium for determining test template
JP2023042058A (en) Information processing apparatus and information processing method
WO2023058611A1 (en) Software failure analysis apparatus and software failure analysis method
US20260003772A1 (en) Method for generating a fuzzing harness
CN119556938B (en) Code checking method, device, equipment and storage medium

Legal Events

Date Code Title Description
A621 Written request for application examination

Free format text: JAPANESE INTERMEDIATE CODE: A621

Effective date: 20240222

A977 Report on retrieval

Free format text: JAPANESE INTERMEDIATE CODE: A971007

Effective date: 20241120

A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20241126

A521 Request for written amendment filed

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20250115

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

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20250203

R150 Certificate of patent or registration of utility model

Ref document number: 7629880

Country of ref document: JP

Free format text: JAPANESE INTERMEDIATE CODE: R150