CN103019944A - Device and method for testing based on code injection mode - Google Patents

Device and method for testing based on code injection mode Download PDF

Info

Publication number
CN103019944A
CN103019944A CN2013100100683A CN201310010068A CN103019944A CN 103019944 A CN103019944 A CN 103019944A CN 2013100100683 A CN2013100100683 A CN 2013100100683A CN 201310010068 A CN201310010068 A CN 201310010068A CN 103019944 A CN103019944 A CN 103019944A
Authority
CN
China
Prior art keywords
module
dynamic link
link library
under test
unit under
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
Application number
CN2013100100683A
Other languages
Chinese (zh)
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.)
Dawning Information Industry Beijing Co Ltd
Original Assignee
Dawning Information Industry Beijing Co 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 Dawning Information Industry Beijing Co Ltd filed Critical Dawning Information Industry Beijing Co Ltd
Priority to CN2013100100683A priority Critical patent/CN103019944A/en
Publication of CN103019944A publication Critical patent/CN103019944A/en
Pending legal-status Critical Current

Links

Images

Abstract

The invention provides a method for testing based on a code injection mode. The method includes the steps: compiling a driving module and a stud module to form a dynamic link library; after operation of a tested unit, using an injection tool to load the dynamic link library into the test unit; using the injection tool to appoint functions, replaced by the driving module and the stud module, in the tested unit; and testing the tested unit.

Description

Method of testing and device based on the code injection mode
Technical field
Present invention relates in general to computer realm, more specifically, relate to method of testing and device based on the code injection mode.
Background technology
Software test is the important means of software quality assurance, is an indivisible important component part in the soft project.Software test is the implementation of a program or system, and this process is not only the discovery mistake, and is main, is quality and performance all activities to judge whether it conforms to quality requirements of program of evaluation and test or system.Along with test process progressively deeply, the progressively reparation of defective, software quality is also in progressively raising and improvement.
Can be summarized as follows from the test grades software test: unit testing, module testing, integration testing and system testing.
Unit testing is for program element, and program element is not a program that independence can be moved, and therefore, when considering test module, will consider simultaneously and the contact of other modules, goes to simulate other modules related with tested module with some supplementary modules.These modules are divided into two kinds: driver module and stubs.Unit testing need to the correlation module in these module replacement programs, all need to recompilate when therefore testing at every turn.
Summary of the invention
For this reason, the invention provides a kind of method of testing based on the code injection mode, may further comprise the steps: driver module and stubs are compiled into dynamic link library; After the unit under test operation, use implantation tool that dynamic link library is loaded in the unit under test; Function in the unit under test that use implantation tool appointment driver module and stubs will be replaced; And unit under test tested.
Wherein, dynamic link library is to comprise the code that used simultaneously by a plurality of programs and the storehouse of data.
Wherein, method of testing is based on the Windows system.
Wherein, method of testing is based on the linux system.
In addition, also provide a kind of proving installation based on the code injection mode, having comprised: collector is used for driver module and stubs are compiled into dynamic link library; Load-on module is used for using implantation tool that dynamic link library is loaded on unit under test after the unit under test operation; Designated module is for the function of the unit under test that uses implantation tool appointment driver module and stubs to replace; And test module, be used for unit under test is tested.
Wherein, dynamic link library is to comprise the code that used simultaneously by a plurality of programs and the storehouse of data.
Wherein, proving installation is based on the Windows system.
Wherein, proving installation is based on the linux system.
Description of drawings
When reading in conjunction with the accompanying drawings, the present invention may be better understood according to the following detailed description.Should be emphasized that according to the standard practices in the industry, various parts are not drawn in proportion.In fact, in order clearly to discuss, the size of various parts can be increased arbitrarily or be reduced
Fig. 1 shows the process flow diagram based on the method for testing of code injection mode according to exemplary embodiment of the present invention; And
Fig. 2 shows the block diagram based on the proving installation of code injection mode according to exemplary embodiment of the present invention.
Embodiment
In order to implement different parts of the present invention, below describe many different embodiment or example are provided.The particular example of element and layout is below described to simplify the present invention.Certainly these only are that example does not plan to limit.Moreover, first component is formed on and can comprises on the second component that wherein the first and second parts are with the embodiment of direct contact formation in below describing, and can comprise that also wherein extra parts form the embodiment that is inserted in the first and second parts, so that not directly contact of the first and second parts.With clear, can at random draw various parts with different sizes for the sake of simplicity.
About the first embodiment, a kind of method of testing based on the code injection mode is provided, as shown in Figure 1, may further comprise the steps: S101 is compiled into dynamic link library with driver module and stubs; S103 after the unit under test operation, uses implantation tool that dynamic link library is loaded in the unit under test; S105, the function in the unit under test that use implantation tool appointment driver module and stubs will be replaced; And S107, unit under test is tested.
Preferably, dynamic link library is to comprise the code that used simultaneously by a plurality of programs and the storehouse of data.
Preferably, method of testing is based on the Windows system.
Preferably, method of testing is based on the linux system.
About the second embodiment, a kind of proving installation based on the code injection mode is provided, as shown in Figure 2, comprising: collector 201 is used for driver module and stubs are compiled into dynamic link library; Load-on module 203 is used for using implantation tool that dynamic link library is loaded on unit under test after the unit under test operation; Designated module 205 is for the function of the unit under test that uses implantation tool appointment driver module and stubs to replace; And test module 207, be used for unit under test is tested.
Preferably, dynamic link library is to comprise the code that used simultaneously by a plurality of programs and the storehouse of data.
Wherein, dynamic link library English is DLL under the windows platform, is the abbreviated form of Dynamic Link Library, and dynamic link library English is SO under the Linux platform, is the abbreviated form of Shared Object.Dynamic link library is one and comprises the code that can be used simultaneously by a plurality of programs and the storehouse of data that dynamic link library (DLL) is not executable file.Dynamic link provides a kind of method, makes process can call the function that does not belong to its executable code.The executable code of function is arranged in a dynamic link library (DLL), and this dynamic link library (DLL) comprises and one or morely is compiled, links and separate the function of storing with the process of using them.Dynamic link library (DLL) also helps to share data and resource.A plurality of application programs are the content of single dynamic link library (DLL) copy in the access memory simultaneously.Dynamic link library (DLL) is one and comprises the code that can be used simultaneously by a plurality of programs and the storehouse of data.
Driver module is the upper level module of simulating tested module, is equivalent to the master routine of tested module.Its receive data sends related data to tested module, enables tested module, and prints corresponding result.
Stubs (Stub) refers to simulate the module that tested module is called, rather than the part of the composition of software product.Primary module is as driver module, and the module that directly links to each other with it replaces with stubs.Will work out " scapegoat " module that some simulate its subordinate's functions of modules for tested module before integration testing, to replace the interface of tested module, accept or transmit the data of tested module, these " vacation " modules of specializing in test usefulness are called the stubs of tested module.
Particularly, can implement as follows the present invention:
(1) driver module and stubs are compiled into dynamic link library
(2) after the tested program operation, use the Inject instrument that dynamic link library is loaded in the tested program.
(3) use the Inject instrument, the function in the tested program that appointment driver module and stubs will be replaced.
(4) tested program is tested.
The present invention uses the mode of code injection, carries out dynamically module and replaces, and need not to recompilate, and can test at any time in program operation process, has improved testing efficiency.
Key point of the present invention is to use the code injection mode, and the dynamic replacement module is tested in program operation process.
The above has discussed the parts of some embodiment, so that those of ordinary skills' various aspects that the present invention may be better understood.It will be understood by those skilled in the art that and can be at an easy rate design or change other are used for reaching with the embodiment that introduces of institute is identical purpose and/or processing and the structure of realization same advantage here as the basis with the present invention.Those of ordinary skills should be appreciated that also this equivalent constructions does not deviate from the spirit and scope of the present invention, and in the situation that does not deviate from the spirit and scope of the present invention, can carry out multiple variation, replacement and change.

Claims (8)

1. the method for testing based on the code injection mode is characterized in that, may further comprise the steps:
Driver module and stubs are compiled into dynamic link library;
After the unit under test operation, use implantation tool that described dynamic link library is loaded in the described unit under test;
Use described implantation tool to specify function in the described unit under test that described driver module and described stubs will replace; And
Described unit under test is tested.
2. method according to claim 1 is characterized in that, described dynamic link library is to comprise the code that used simultaneously by a plurality of programs and the storehouse of data.
3. method according to claim 1 is characterized in that, described method of testing is based on the Windows system.
4. method according to claim 1 is characterized in that, described method of testing is based on the linux system.
5. the proving installation based on the code injection mode is characterized in that, comprising:
Collector is used for driver module and stubs are compiled into dynamic link library;
Load-on module is used for using implantation tool that described dynamic link library is loaded on described unit under test after the unit under test operation;
Designated module is used for using described implantation tool to specify the function of the described unit under test that described driver module and described stubs will replace; And
Test module is used for described unit under test is tested.
6. method according to claim 5 is characterized in that, described dynamic link library is to comprise the code that used simultaneously by a plurality of programs and the storehouse of data.
7. method according to claim 5 is characterized in that, described proving installation is based on the Windows system.
8. method according to claim 5 is characterized in that, described proving installation is based on the linux system.
CN2013100100683A 2013-01-10 2013-01-10 Device and method for testing based on code injection mode Pending CN103019944A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN2013100100683A CN103019944A (en) 2013-01-10 2013-01-10 Device and method for testing based on code injection mode

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN2013100100683A CN103019944A (en) 2013-01-10 2013-01-10 Device and method for testing based on code injection mode

Publications (1)

Publication Number Publication Date
CN103019944A true CN103019944A (en) 2013-04-03

Family

ID=47968569

Family Applications (1)

Application Number Title Priority Date Filing Date
CN2013100100683A Pending CN103019944A (en) 2013-01-10 2013-01-10 Device and method for testing based on code injection mode

Country Status (1)

Country Link
CN (1) CN103019944A (en)

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104978227A (en) * 2014-04-08 2015-10-14 腾讯科技(深圳)有限公司 Process control method, process control device and process control system
CN105095071A (en) * 2015-06-30 2015-11-25 百度在线网络技术(北京)有限公司 Method, device and system used to obtain scene performance information of application
CN106371940A (en) * 2015-07-21 2017-02-01 腾讯科技(深圳)有限公司 Solution method and device for program crash
CN111625296A (en) * 2020-05-27 2020-09-04 重庆夏软科技有限公司 Method for protecting program by constructing code copy
CN113010181A (en) * 2021-03-24 2021-06-22 北京百度网讯科技有限公司 Deployment method and device of operators in deep learning framework and electronic equipment

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1710547A (en) * 2004-06-16 2005-12-21 华为技术有限公司 Software detection method and system
US20060277539A1 (en) * 2005-06-07 2006-12-07 Massachusetts Institute Of Technology Constraint injection system for immunizing software programs against vulnerabilities and attacks
CN102243609A (en) * 2011-06-15 2011-11-16 惠州运通信息技术有限公司 Embedded software-based test analysis method and system

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1710547A (en) * 2004-06-16 2005-12-21 华为技术有限公司 Software detection method and system
US20060277539A1 (en) * 2005-06-07 2006-12-07 Massachusetts Institute Of Technology Constraint injection system for immunizing software programs against vulnerabilities and attacks
CN102243609A (en) * 2011-06-15 2011-11-16 惠州运通信息技术有限公司 Embedded software-based test analysis method and system

Cited By (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104978227A (en) * 2014-04-08 2015-10-14 腾讯科技(深圳)有限公司 Process control method, process control device and process control system
CN104978227B (en) * 2014-04-08 2019-04-26 腾讯科技(深圳)有限公司 A kind of course control method, device and system
CN105095071A (en) * 2015-06-30 2015-11-25 百度在线网络技术(北京)有限公司 Method, device and system used to obtain scene performance information of application
CN105095071B (en) * 2015-06-30 2018-03-23 百度在线网络技术(北京)有限公司 A kind of scene performance information methods, devices and systems for being used to obtain application
CN106371940A (en) * 2015-07-21 2017-02-01 腾讯科技(深圳)有限公司 Solution method and device for program crash
CN106371940B (en) * 2015-07-21 2020-02-11 腾讯科技(深圳)有限公司 Method and device for solving program crash
CN111625296A (en) * 2020-05-27 2020-09-04 重庆夏软科技有限公司 Method for protecting program by constructing code copy
CN111625296B (en) * 2020-05-27 2023-03-14 重庆夏软科技有限公司 Method for protecting program by constructing code copy
CN113010181A (en) * 2021-03-24 2021-06-22 北京百度网讯科技有限公司 Deployment method and device of operators in deep learning framework and electronic equipment
CN113010181B (en) * 2021-03-24 2022-05-27 北京百度网讯科技有限公司 Deployment method and device of operators in deep learning framework and electronic equipment
US11531529B2 (en) 2021-03-24 2022-12-20 Beijing Baidu Netcom Science Technology Co., Ltd. Method and electronic device for deploying operator in deep learning framework

Similar Documents

Publication Publication Date Title
US8935573B2 (en) Reliable unit testing through cached mocking
CN103186460B (en) A kind of method, Apparatus and system of generating test use case script
CN103577308B (en) Method for obtaining log files of mobile device
CN107239392B (en) Test method, test device, test terminal and storage medium
CN103019944A (en) Device and method for testing based on code injection mode
CN101719095A (en) Method and device for managing regression testing
CN102662846A (en) Testing method combining automatic tool and testing case
CN105448348B (en) A kind of chip restorative procedure and device
CN102650984A (en) Test report generation system and method
CN103488482A (en) Method and device for generating test cases
CN105426309A (en) Test case automatic generation method and apparatus
CN105653268A (en) Rule engine debugging method and rule engine debugging system
CN105279092A (en) Software testing method and apparatus
CN104021251A (en) PCB check method and device
CN105302679B (en) A kind of detection method and system of intelligent terminal storage stability
CN103885804A (en) System and method for dynamically loading multiple function items of FPGA
CN103646031B (en) The coordinate data control methods of DRC files
US10592703B1 (en) Method and system for processing verification tests for testing a design under test
CN102799479A (en) Mainboard with multifunctional basic input output system (BIOS) and test method thereof
CN105205019A (en) Qualcomm platform mobile phone-based NV (Nonvolatile Random Access Memory) parameter reading and writing system and method
CN103902445B (en) A kind of regression test object determines method and device
CN104753741A (en) Network card test performance adjustment method and device
US20140281719A1 (en) Explaining excluding a test from a test suite
CN105893233A (en) Method and system used for automatically testing firmware
CN110134598B (en) Batch processing method, device and system

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C12 Rejection of a patent application after its publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20130403