JP2021103354A - Program testing method - Google Patents
Program testing method Download PDFInfo
- Publication number
- JP2021103354A JP2021103354A JP2019233279A JP2019233279A JP2021103354A JP 2021103354 A JP2021103354 A JP 2021103354A JP 2019233279 A JP2019233279 A JP 2019233279A JP 2019233279 A JP2019233279 A JP 2019233279A JP 2021103354 A JP2021103354 A JP 2021103354A
- Authority
- JP
- Japan
- Prior art keywords
- program
- test
- test target
- main body
- target portion
- 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
Abstract
Description
本開示は、プログラムの試験方法に関する。 The present disclosure relates to test methods for programs.
プログラムの動作試験を行う試験方法として、ホワイトボックステストがある。ホワイトボックステストでは、テスト対象のプログラムの設計仕様に応じたテストパターンを網羅的に該プログラムに入力し、該プログラムが上記設計仕様を満たすか否かを試験する(例えば特許文献1)。 There is a white box test as a test method for performing an operation test of a program. In the white-box test, a test pattern corresponding to the design specifications of the program to be tested is comprehensively input to the program, and whether or not the program satisfies the above design specifications is tested (for example, Patent Document 1).
上記ホワイトボックステストは、テスト対象のプログラムの規模が大きくほど、あるいはプログラムの構造が複雑になるほど、テスト対象へのテストパターンの入力が困難となる。例えば、ローカルシンボルとして定義された関数に関し、シンボルが定義されたオブジェクトファイルの外部からは当該関数を直接呼び出すことができない。この課題に対して、例えば、テスト対象のプログラムにテスト用機能を追加し、又はデバッガを用いてテストする等の手法が考えられる。しかしこの場合、テスト対象へテストパターンを入力するまでの前作業が複雑になってしまい、効率的にテストが進められない。 In the above white-box test, the larger the scale of the program to be tested or the more complicated the structure of the program, the more difficult it becomes to input the test pattern to the test target. For example, for a function defined as a local symbol, the function cannot be called directly from outside the object file in which the symbol is defined. To solve this problem, for example, a method of adding a test function to the program to be tested or testing using a debugger can be considered. However, in this case, the preparatory work until the test pattern is input to the test target becomes complicated, and the test cannot proceed efficiently.
かかる事情に鑑みてなされた本開示の目的は、ホワイトボックステストの効率化を図ることにある。 The purpose of the present disclosure made in view of such circumstances is to improve the efficiency of the white box test.
本開示の一実施形態に係るプログラムの試験方法は、
試験対象のプログラムの本体コードからテスト対象部分と、該テスト対象部分の依存部分を抽出するステップと、
前記テスト対象部分と前記依存部分とに基づき差分コードを生成するステップと、
前記差分コードに基づきテストを行い、前記差分コードに係る文字列から算出したハッシュ値を記憶するステップと、
を含む。
The test method of the program according to the embodiment of the present disclosure is as follows.
A step of extracting the test target part and the dependent part of the test target part from the main body code of the test target program, and
A step of generating a difference code based on the test target part and the dependent part,
A step of performing a test based on the difference code and storing a hash value calculated from the character string related to the difference code, and
including.
本開示の一実施形態に係るプログラムの試験方法によれば、ホワイトボックステストの効率化を図ることができる。 According to the test method of the program according to the embodiment of the present disclosure, the efficiency of the white box test can be improved.
以下、本開示の実施形態に係るプログラムの試験方法について、図面を参照して説明する。 Hereinafter, the test method of the program according to the embodiment of the present disclosure will be described with reference to the drawings.
各図中、同一又は相当する部分には、同一符号を付している。本実施形態の説明において、同一又は相当する部分については、説明を適宜省略又は簡略化する。 In each figure, the same or corresponding parts are designated by the same reference numerals. In the description of the present embodiment, the description will be omitted or simplified as appropriate for the same or corresponding parts.
図1を参照して、本実施形態に係るプログラムの差分テストシステム1の構成を説明する。
The configuration of the
プログラムの差分テストシステム1(以下、単にシステム1ともいう)は、本実施形態に係るプログラムの試験方法を実施するシステムであり、差分コード生成部11と、同一性担保代表情報記憶部12と、同一性確認部13とを備える。システム1は概略として、プログラムである本体コード2の試験を行う。試験対象のプログラムの本体コード2は、複数の本体コード構成ファイル21を含む。システム1は、本体コード構成ファイル21のテスト対象部分211の試験を行う。テスト対象部分211は、テスト対象とするプログラムの機能(関数及びメソッド)を含む。このようにシステム1は、本体コード構成ファイル21の各部分をそれぞれ個別にテストすることにより、規模の大きなプログラムであったとしても各機能の設計仕様を網羅的に検証することができる。ここで当該テスト対象部分211は、テスト対象部分211が記述された本体コード構成ファイル21とは別の本体コード構成ファイル21に含まれる依存部分212に依存しているとする。換言すると当該テスト対象部分211は、テスト対象部分211が記述された本体コード構成ファイル21とは別の本体コード構成ファイル21に含まれる依存部分212が無ければ、コンパイル等、テストに必要な処理が行えないものとする。
The program difference test system 1 (hereinafter, also simply referred to as system 1) is a system that implements the program test method according to the present embodiment, and includes a difference
システム1の差分コード生成部11は、依存箇所探索部110を含む。依存箇所探索部110は、本体コード2を解析し、テスト対象部分211とその依存部分212を抽出する。また差分コード生成部11は、抽出したテスト対象部分211と依存部分212とに基づき差分コード3を生成する。換言すると差分コード生成部11は、テスト対象部分211をテストするために最小限必要なコード(差分コード3)を生成する機能を有する。
The difference
差分コード3は、単体でコンパイル及びリンク可能なコードである。差分コード3は、テスト対象部分211のコピー31と、依存部分のスタブ・ドライバ32とを含む。つまり当該差分コード3をビルドすることで生成されたバイナリ(実行ファイル)を用いて、ユーザは本体コード2のテスト対象部分211の動作をテストすることができる。
The difference code 3 is a code that can be compiled and linked by itself. The difference code 3 includes a
同一性担保代表情報記憶部12は、データベース120を備える。同一性担保代表情報記憶部12は、コピー31の内容が、本体コード2のテスト対象部分211の内容と同一であることを担保する情報(以下、同一性担保情報)をデータベース120に記憶する。同一性担保情報は、差分コード3に含まれる、コピー31を構成する全文字列から生成されたハッシュ値と、当該差分コード3に係るテスト結果とを含む。
The identity guarantee representative
同一性確認部13は、差分コード3を用いて行ったテスト結果と、本体コード2を用いて行ったテスト結果が論理的に同一であることを保証する。具体的には同一性確認部13は、本体コード2から全ての関数及びメソッドを抽出し、それぞれの関数及びメソッドに対し、構成する文字列からハッシュ値を計算する。同一性確認部13は、算出したハッシュ値をキーにデータベース120を検索し、当該ハッシュ値が記憶されている場合、当該関数がテストされたものとする。これにより、同一性確認部13は、本体コード2のテストの検証網羅度を確認することができる。
The
図2に、テスト対象のコードの具体例を示す。ここではテスト対象部分211が、関数mms()であるとする。テスト対象部分211の指定は、システム1が設定ファイルにおけるユーザの入力データを受け付けることにより行う。例えばシステム1は、本体コード2が格納されたディレクトリと、テスト対象部分211の開始行番号と、終了行番号とを含む設定ファイルを受け付け、テスト対象部分211を特定する。ここでは、テスト対象部分211が関数mms()であるとする。設定ファイルでは、関数mms()が記述されたファイルのディレクトリと、関数mms()の開始行番号と、終了行番号とが指定されている。なおテスト対象部分211の指定方法として設定ファイルを用いる例を示したがこれに限られず、テスト対象部分211を指定できる方法であれば任意の方法を採用可能である。
FIG. 2 shows a specific example of the code to be tested. Here, it is assumed that the
差分コード生成部11は、設定ファイルで指定されたテスト対象部分211を探索し構文解析を行う。また依存箇所探索部110は、テスト対象部分211が依存する依存部分212の探索を行う。図2に示すように、ここでは関数mms()の引数として、シンボルstruct resultの*rが特定されている。したがって関数mms()を呼び出す前提として、struct resultの宣言をする必要がある。また関数mms()において、関数calc_A()とcalc_B()とを呼び出している。すなわち関数mms()を用いるために、関数calc_A()とcalc_B()とを定義する必要がある。依存箇所探索部110は、これらの依存関係を探索し、関数mms()が記述されているソースファイルとは別のソースファイルに記述されているstruct resultと、calc_A()と、calc_B()とを、依存部分212として抽出する。なおここではstruct resultと、calc_A()及びcalc_B()とが、それぞれ別のソースファイルに記述されている例を示しているがこれに限られず、これらが同一のソースファイルに記述されていてもよい。またここでは、calc_A()及びcalc_B()が同一のソースファイルに記述されている例を示したが、これに限られず、calc_A()及びcalc_B()がそれぞれ異なるソースファイルに記述されていてもよい。
The difference
差分コード生成部11は、テスト対象部分211と、抽出した依存部分212とに基づき差分コード3を生成する。関数mms()に対応する差分コード3の具体例を図3に示す。関数mms()の差分コード3は、本体コード2を複製して生成したコピー31と、依存部分のスタブ・ドライバ32とを含む。依存部分のスタブ・ドライバ32は、差分コード生成部11が自動的に生成する。差分コード3をビルドしてバイナリが生成される。当該バイナリを用いてテストを行うことができる。なお、依存部分のスタブ・ドライバ32の内容を改変することで、様々なテストケースを実装することができる。コピー31のハッシュ値及びテスト結果は、図4に示すように同一性担保代表情報記憶部12によりデータベース120に記憶される。図5は、同一性確認部13による動作の概要を示す図である。同一性確認部13は、本体コード2から、関数mms()を含む全関数を構成する文字列からハッシュ値を計算する。図5では、同一性確認部13が、本体コード2に記述されている関数mms()の文字列からハッシュ値を計算し、同一性担保代表情報記憶部12のデータベース120に記憶されているレコードと比較している。ハッシュ値がデータベース120のいずれかのレコードと一致すれば、関数mms()はテスト済みと判断できる。他方でハッシュ値がデータベース120のいずれのレコードとも一致しない場合、関数mms()はテストしていないと判断できる。ここで、例えば本体コード2の関数mms()のテストをした後に、当該関数を改変した場合等は、ハッシュ値が異なることになる。同一性確認部13は、本体コード2の文字列から計算したハッシュ値を用いてテスト済みか否かを判断するため、このように改変が加えられたような場合も確実に検知し、本体コード2の各関数等がテスト済みであるか否かを正確に確認することができる。
The difference
上述のように、本実施形態に係るプログラムの試験方法は、本体コード2からテスト対象部分211と、その依存部分212とを抽出し、これらに基づき差分コード3を生成する。差分コード3は、依存部分212を含むため、単体でビルド可能である。そのためユーザは、差分コード3のみでホワイトボックステストを行うことができる。またテスト結果及びテスト対象部分のコピー31のハッシュ値を記憶し、当該ハッシュ値に基づき本体コード2との同一性が担保されるため、本実施形態に係るプログラムの試験方法によれば、本体コード2の内容でテストが行われたこと、及び本体コード2のテストの検証網羅度を確認することができる。なおシステム1は、データベース120に格納された複数のハッシュ値と、本体コード2の各機能のハッシュ値に基づき、テストの検証網羅度を自動的に算出して出力してもよい。このように本実施形態に係るプログラムの試験方法によれば、ホワイトボックステストの効率化を図ることができる。
As described above, in the test method of the program according to the present embodiment, the
ここで、システム1としては任意の情報処理装置を用いることができ、例えば当該情報処理装置は適宜、制御部、記憶部、入力部、出力部を備える。システム1の差分コード生成部11、依存箇所探索部110、及び同一性確認部13は、情報処理装置の制御部の機能により実現してもよい。当該制御部には、少なくとも1つのプロセッサ、少なくとも1つの専用回路、又はこれらの組み合わせが含まれる。プロセッサは、CPU(central processing unit)若しくはGPU(graphics processing unit)などの汎用プロセッサ、又は特定の処理に特化した専用プロセッサである。専用回路は、例えば、FPGA(field-programmable gate array)又はASIC(application specific integrated circuit)である。制御部は、情報処理装置の各部を制御しながら、情報処理装置の動作に関わる処理を実行する。
Here, any information processing device can be used as the
また同一性担保代表情報記憶部12は、情報処理装置の記憶部で実現してもよい。当該記憶部には、少なくとも1つの半導体メモリ、少なくとも1つの磁気メモリ、少なくとも1つの光メモリ、又はこれらのうち少なくとも2種類の組み合わせが含まれる。半導体メモリは、例えば、RAM(random access memory)又はROM(read only memory)である。RAMは、例えば、SRAM(static random access memory)又はDRAM(dynamic random access memory)である。ROMは、例えば、EEPROM(electrically erasable programmable read only memory)である。記憶部は、例えば、主記憶装置、補助記憶装置、又はキャッシュメモリとして機能する。
Further, the identity guarantee representative
情報処理装置の入力部には、少なくとも1つの入力用インタフェースが含まれる。入力用インタフェースは、例えば、物理キー、静電容量キー、ポインティングデバイス、ディスプレイと一体的に設けられたタッチスクリーン、又はマイクである。入力部は、システム1の動作に用いられるデータを入力する操作を受け付ける。入力部は、情報処理装置に備えられる代わりに、外部の入力機器として情報処理装置に接続されてもよい。接続方式としては、例えば、USB(Universal Serial Bus)、HDMI(登録商標)(High-Definition Multimedia Interface)、又はBluetooth(登録商標)などの任意の方式を用いることができる。
The input unit of the information processing apparatus includes at least one input interface. The input interface is, for example, a physical key, a capacitive key, a pointing device, a touch screen integrated with the display, or a microphone. The input unit accepts an operation for inputting data used for the operation of the
出力部には、少なくとも1つの出力用インタフェースが含まれる。出力用インタフェースは、例えば、ディスプレイ又はスピーカである。ディスプレイは、例えば、LCD(liquid crystal display)又は有機EL(electro luminescence)ディスプレイである。出力部は、システム1の動作によって得られるデータを出力する。出力部は、情報処理装置に備えられる代わりに、外部の出力機器として情報処理装置に接続されてもよい。接続方式としては、例えば、USB、HDMI(登録商標)、又はBluetooth(登録商標)などの任意の方式を用いることができる。
The output unit includes at least one output interface. The output interface is, for example, a display or a speaker. The display is, for example, an LCD (liquid crystal display) or an organic EL (electroluminescence) display. The output unit outputs the data obtained by the operation of the
情報処理装置の機能は、本実施形態に係るプログラムを、制御部に相当するプロセッサで実行することにより実現される。本実施形態においてプログラムは、コンピュータで読取り可能な記録媒体に記録しておくことができる。コンピュータで読取り可能な記録媒体は、非一時的なコンピュータ読取可能な媒体を含み、例えば、磁気記録装置、光ディスク、光磁気記録媒体、又は半導体メモリである。プログラムの流通は、例えば、プログラムを記録したDVD(digital versatile disc)又はCD−ROM(compact disc read only memory)などの可搬型記録媒体を販売、譲渡、又は貸与することによって行う。またプログラムの流通は、プログラムをサーバのストレージに格納しておき、サーバから他のコンピュータにプログラムを送信することにより行ってもよい。またプログラムはプログラムプロダクトとして提供されてもよい。 The function of the information processing device is realized by executing the program according to the present embodiment on a processor corresponding to the control unit. In this embodiment, the program can be recorded on a computer-readable recording medium. Computer-readable recording media include non-temporary computer-readable media, such as magnetic recording devices, optical discs, opto-magnetic recording media, or semiconductor memories. The distribution of the program is carried out, for example, by selling, transferring, or renting a portable recording medium such as a DVD (digital versatile disc) or a CD-ROM (compact disc read only memory) on which the program is recorded. Further, the distribution of the program may be performed by storing the program in the storage of the server and transmitting the program from the server to another computer. The program may also be provided as a program product.
本実施形態においてコンピュータは、例えば、可搬型記録媒体に記録されたプログラム又はサーバから送信されたプログラムを、一旦、主記憶装置に格納する。そして、コンピュータは、主記憶装置に格納されたプログラムをプロセッサで読み取り、読み取ったプログラムに従った処理をプロセッサで実行する。コンピュータは、可搬型記録媒体から直接プログラムを読み取り、プログラムに従った処理を実行してもよい。コンピュータは、サーバからプログラムを受信する度に、逐次、受け取ったプログラムに従った処理を実行してもよい。サーバからコンピュータへのプログラムの送信は行わず、実行指示及び結果取得のみによって機能を実現する、いわゆるASP(application service provider)型のサービスによって処理を実行してもよい。プログラムには、電子計算機による処理の用に供する情報であってプログラムに準ずるものが含まれる。例えば、コンピュータに対する直接の指令ではないがコンピュータの処理を規定する性質を有するデータは、「プログラムに準ずるもの」に該当する。 In the present embodiment, for example, the computer temporarily stores the program recorded on the portable recording medium or the program transmitted from the server in the main storage device. Then, the computer reads the program stored in the main storage device by the processor, and executes the processing according to the read program by the processor. The computer may read the program directly from the portable recording medium and perform processing according to the program. Each time the computer receives a program from the server, the computer may sequentially execute processing according to the received program. The process may be executed by a so-called ASP (application service provider) type service that realizes the function only by the execution instruction and the result acquisition without transmitting the program from the server to the computer. The program includes information used for processing by a computer and equivalent to the program. For example, data that is not a direct command to a computer but has the property of defining the processing of a computer corresponds to "a program-like data".
システム1の一部又は全ての機能が、情報処理装置の制御部に相当する専用回路により実現されてもよい。すなわち、システム1の一部又は全ての機能が、ハードウェアにより実現されてもよい。
A part or all the functions of the
1 プログラムの差分テストシステム(システム)
11 差分コード生成部
110 依存箇所探索部110
12 同一性担保代表情報記憶部
120 データベース
13 同一性確認部
2 本体コード
21 本体コード構成ファイル
211 テスト対象部分
212 依存部分
3 差分コード
31 テスト対象部分のコピー
32 依存部分のスタブ・ドライバ
1 Program difference test system (system)
11 Difference
12 Identity guarantee representative
Claims (1)
前記テスト対象部分と前記依存部分とに基づき差分コードを生成するステップと、
前記差分コードに基づきテストを行い、前記テスト対象部分のコピーに係る文字列から算出したハッシュ値を記憶するステップと、
を含むプログラムの試験方法。 A step of extracting the test target part and the dependent part of the test target part from the main body code of the test target program, and
A step of generating a difference code based on the test target part and the dependent part,
A step of performing a test based on the difference code and storing a hash value calculated from a character string related to a copy of the test target portion, and a step of storing the hash value.
How to test the program, including.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2019233279A JP2021103354A (en) | 2019-12-24 | 2019-12-24 | Program testing method |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2019233279A JP2021103354A (en) | 2019-12-24 | 2019-12-24 | Program testing method |
Publications (1)
Publication Number | Publication Date |
---|---|
JP2021103354A true JP2021103354A (en) | 2021-07-15 |
Family
ID=76755199
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
JP2019233279A Pending JP2021103354A (en) | 2019-12-24 | 2019-12-24 | Program testing method |
Country Status (1)
Country | Link |
---|---|
JP (1) | JP2021103354A (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2023162272A1 (en) * | 2022-02-28 | 2023-08-31 | 日本電気株式会社 | Test assistance device, system, and method, and computer-readable medium |
-
2019
- 2019-12-24 JP JP2019233279A patent/JP2021103354A/en active Pending
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2023162272A1 (en) * | 2022-02-28 | 2023-08-31 | 日本電気株式会社 | Test assistance device, system, and method, and computer-readable medium |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US10586026B2 (en) | Simple obfuscation of text data in binary files | |
CN106203006A (en) | Android application reinforcement means based on dex Yu so file Dynamic Execution | |
EP2677451B1 (en) | License verification method and apparatus, and computer readable storage medium storing program therefor | |
WO2015035827A1 (en) | Method and apparatus for providing string encryption and decryption in program files | |
CN108197440A (en) | A kind of Code obfuscation method, equipment and computer readable storage medium | |
WO2022100063A1 (en) | Method and apparatus for generating and storing logs of smart contract, device, and storage medium | |
US7822615B2 (en) | Translating expressions in a computing environment | |
JP5845888B2 (en) | Software correction apparatus, software correction system, software correction method, and software correction program | |
JP7409197B2 (en) | Elaboration of repair patterns for static analysis violations in software programs | |
CN108228312A (en) | The system and method that code is performed by interpreter | |
JP2021103354A (en) | Program testing method | |
CN113626773B (en) | Code protection method based on intermediate language | |
KR101823226B1 (en) | Method and system for code protection | |
US9417871B2 (en) | Automatic generation of certificate of origin (COO) for software systems | |
JP6597356B2 (en) | Control program, control device, and control method | |
KR101534493B1 (en) | Source code security weakness detection apparatus and method based on structure conversion | |
JP2013145443A (en) | Test code generation device, test code generation method and test code generation program | |
JP5550578B2 (en) | Entry rewriting device and entry rewriting program | |
US9965621B2 (en) | Program protection device | |
CN112541188B (en) | Method and device for preventing application program code from being statically analyzed | |
JP2007041777A (en) | Language processing method | |
JP6556091B2 (en) | System specification verification support apparatus and system specification verification support method | |
Kim et al. | Future of Kernel Object-Based Memory Forensics | |
JP2016173756A (en) | Test case generation program, test case generation method, and test case generation device | |
JP2015069220A (en) | Device, method, and program for generating performance evaluation program |