CN110580226B - Object code coverage rate testing method, system and medium for operating system level program - Google Patents

Object code coverage rate testing method, system and medium for operating system level program Download PDF

Info

Publication number
CN110580226B
CN110580226B CN201910900844.4A CN201910900844A CN110580226B CN 110580226 B CN110580226 B CN 110580226B CN 201910900844 A CN201910900844 A CN 201910900844A CN 110580226 B CN110580226 B CN 110580226B
Authority
CN
China
Prior art keywords
instruction
executed
coverage rate
monitoring
function
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
CN201910900844.4A
Other languages
Chinese (zh)
Other versions
CN110580226A (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.)
Vision Microsystems Shanghai Co ltd
Original Assignee
Vision Microsystems Shanghai 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 Vision Microsystems Shanghai Co ltd filed Critical Vision Microsystems Shanghai Co ltd
Priority to CN201910900844.4A priority Critical patent/CN110580226B/en
Publication of CN110580226A publication Critical patent/CN110580226A/en
Priority to PCT/CN2020/092359 priority patent/WO2021057057A1/en
Application granted granted Critical
Publication of CN110580226B publication Critical patent/CN110580226B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3676Test management for coverage analysis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3684Test management for test design, e.g. generating new test cases
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3688Test management for test execution, e.g. scheduling of test suites

Abstract

The invention provides a method, a system and a medium for testing the coverage rate of an object code of an operating system level program, comprising the following steps: compiling: registering a monitoring module as a system call function in an operating system source code, and compiling the monitoring module and the operating system source code together; the testing steps are as follows: calling a monitoring module, testing target code information and coverage rate information, and obtaining test information; a calculation step: and calculating the object code coverage rate of the application program at the operating system level according to the test information. The coverage rate obtained by relying on a real physical environment is more credible.

Description

Object code coverage rate testing method, system and medium for operating system level program
Technical Field
The invention relates to the technical field of integrated circuit testing, in particular to a method, a system and a medium for testing the target code coverage rate of an operating system level program. And more particularly, to a method, system and medium for testing object code coverage of an operating system level application based on hardware breakpoints.
Background
Object code testing is performed on operating system level applications without instrumentation of the source code and without resorting to an emulator.
The existing scheme is as follows: and carrying out target code test in a mode of inserting piles into source codes of the application program.
A DO-178B/C A level software object code coverage analysis method (patent application number: 201410717703.6). In contrast, the present invention does not instrumentation the source code.
An embedded C language target code level unit test method based on a CPU simulator (patent application number: 201410381755.0). For the patent, the coverage rate obtained by the invention depending on a real physical environment is more credible.
Patent document 101847119B (application No.: 201010137793.3) discloses a hardware breakpoint circuit for emulation debugging, including: a first breakpoint register for storing first breakpoint condition information; a first breakpoint comparator; a second breakpoint register for storing second breakpoint condition information; a second breakpoint comparator; the first breakpoint counter is used for setting the occurrence frequency of the first breakpoint condition; a first AND gate; a first not gate; the second breakpoint counter is used for setting the occurrence frequency of the second breakpoint condition; a third AND gate; a second not gate; a second AND gate; a fourth AND gate; and the first OR gate is used for sending a breakpoint request signal to the microcontroller.
Disclosure of Invention
In view of the defects in the prior art, an object of the present invention is to provide a method, a system and a medium for testing the object code coverage of an operating system level program.
The invention provides a method for testing the object code coverage rate of an operating system level program, which comprises the following steps:
compiling: registering a monitoring module as a system call function in an operating system source code, and compiling the monitoring module and the operating system source code together;
the testing steps are as follows: calling a monitoring module, testing target code information and coverage rate information, and obtaining test information;
a calculation step: and calculating the object code coverage rate of the application program at the operating system level according to the test information.
Preferably, the operating system provides a plurality of system call functions, and if a user needs to customize the system call functions, the written functions need to be registered or written in a system call function list of the operating system.
Preferably, the monitoring module comprises: monitoring a starting function, a monitoring ending function and an interrupt processing function;
the monitoring start function: mounting an interrupt processing function of a hardware breakpoint in a monitoring module into an interrupt vector table of a processor, enabling debugging interruption of the processor, and enabling the monitoring module to start collecting coverage rate information of a detected target code;
the monitoring end function: turning off the debugging interruption of the processor, and enabling the monitoring module to finish collecting the coverage rate information of the target code to be detected;
the interrupt handling function: and the processor executes the processing function after the hardware breakpoint interruption occurs, and collects and analyzes the execution condition of the current instruction.
Preferably, the testing step comprises the steps of:
step A: calling a monitoring start function of the monitoring module at a coverage rate start point of the tested application program in a system calling mode, calling a monitoring end function at a coverage rate end point, and recompiling the tested application program;
and B: when the target code of the application program to be tested is executed to the coverage rate starting point, calling a monitoring starting function of the monitoring module in a system calling mode, setting a hardware breakpoint behind the coverage rate starting point by the monitoring starting function, and enabling debugging interruption;
and C: after a target code of a tested application program triggers a hardware breakpoint, analyzing a currently executed instruction address of the application program in an interrupt processing function of the hardware breakpoint according to a process control block of an operating system, analyzing whether the current instruction is a branch instruction according to the instruction content of the current instruction, directly marking the instruction to be executed if the current instruction is not the branch instruction, and recording the execution condition of a non-branch instruction; if the current instruction is a branch instruction, analyzing the true and false execution condition of the branch instruction by combining the values of a state register and other related registers of the current processor, recording the execution condition of the branch instruction, analyzing the address of the next characteristic point and setting a hardware breakpoint at the characteristic point; the characteristic points refer to: the next instruction to be executed in the target code to be tested;
step D: when the target code of the application program to be tested is executed to the coverage rate end point, calling a monitoring end function of the monitoring module in a system calling mode, closing debugging interruption by the monitoring end function and deleting a hardware breakpoint, and sending executed target code information and coverage rate information to an upper computer through a communication link for calculating the coverage rate;
the executed object code information and coverage information comprises: the instruction address and instruction execution result to which the instruction is executed;
the execution case comprises the following steps:
execution of non-branch instructions: whether the instruction is executed;
execution of branch instructions: whether the branch instruction is executed, and if the branch instruction is executed, whether the executed branch instruction is a true branch or a false branch.
The process control block is a PCB of an operating system;
the current instruction is an instruction which is being executed or is about to be executed when a hardware breakpoint is triggered;
the state register is a register in the processor and stores the current state information of the processor;
the other relevant registers are a group of registers which are relevant to instruction execution and inside the processor, and the specific names of the registers are different according to the change of the processor.
Preferably, the calculating step: the upper computer combines the tested target code with the received executed target code information and the coverage rate information, so that the statement coverage rate, the branch coverage rate and the call coverage rate of the tested target code are marked and calculated.
The invention provides a system for testing the object code coverage rate of an operating system level program, which comprises:
a compiling module: registering a monitoring module as a system call function in an operating system source code, and compiling the monitoring module and the operating system source code together;
a test module: calling a monitoring module, testing target code information and coverage rate information, and obtaining test information;
a calculation module: and calculating the object code coverage rate of the application program at the operating system level according to the test information.
Preferably, the operating system provides a plurality of system call functions, and if a user needs to customize the system call functions, the written functions need to be registered or written in a system call function list of the operating system.
Preferably, the monitoring module comprises: monitoring a starting function, a monitoring ending function and an interrupt processing function;
the monitoring start function: mounting an interrupt processing function of a hardware breakpoint in a monitoring module into an interrupt vector table of a processor, enabling debugging interruption of the processor, and enabling the monitoring module to start collecting coverage rate information of a detected target code;
the monitoring end function: turning off the debugging interruption of the processor, and enabling the monitoring module to finish collecting the coverage rate information of the target code to be detected;
the interrupt handling function: and the processor executes the processing function after the hardware breakpoint interruption occurs, and collects and analyzes the execution condition of the current instruction.
Preferably, the test module comprises:
a module A: calling a monitoring start function of the monitoring module at a coverage rate start point of the tested application program in a system calling mode, calling a monitoring end function at a coverage rate end point, and recompiling the tested application program;
and a module B: when the target code of the application program to be tested is executed to the coverage rate starting point, calling a monitoring starting function of the monitoring module in a system calling mode, setting a hardware breakpoint behind the coverage rate starting point by the monitoring starting function, and enabling debugging interruption;
and a module C: after a target code of a tested application program triggers a hardware breakpoint, analyzing a currently executed instruction address of the application program in an interrupt processing function of the hardware breakpoint according to a process control block of an operating system, analyzing whether the current instruction is a branch instruction according to the instruction content of the current instruction, directly marking the instruction to be executed if the current instruction is not the branch instruction, and recording the execution condition of a non-branch instruction; if the current instruction is a branch instruction, analyzing the true and false execution condition of the branch instruction by combining the values of a state register and other related registers of the current processor, recording the execution condition of the branch instruction, analyzing the address of the next characteristic point and setting a hardware breakpoint at the characteristic point; the characteristic points refer to: the next instruction to be executed in the target code to be tested;
a module D: when the target code of the application program to be tested is executed to the coverage rate end point, calling a monitoring end function of the monitoring module in a system calling mode, closing debugging interruption by the monitoring end function and deleting a hardware breakpoint, and sending executed target code information and coverage rate information to an upper computer through a communication link for calculating the coverage rate;
the executed object code information and coverage information comprises: the instruction address and instruction execution result to which the instruction is executed;
the execution case comprises the following steps:
execution of non-branch instructions: whether the instruction is executed;
execution of branch instructions: whether the branch instruction is executed, and if the branch instruction is executed, whether the executed branch instruction is a true branch or a false branch.
The process control block is a PCB of an operating system;
the current instruction is an instruction which is being executed or is about to be executed when a hardware breakpoint is triggered;
the state register is a register in the processor and stores the current state information of the processor;
the other relevant registers are a group of registers which are inside the processor and relevant to instruction execution, and the specific names of the registers are different according to the change of the processor;
the calculation module: the upper computer combines the tested target code with the received executed target code information and the coverage rate information, so that the statement coverage rate, the branch coverage rate and the call coverage rate of the tested target code are marked and calculated.
According to the present invention, there is provided a computer-readable storage medium storing a computer program, wherein the computer program, when executed by a processor, implements the steps of any of the methods described above.
Compared with the prior art, the invention has the following beneficial effects:
1. the coverage rate obtained by relying on a real physical environment is more credible.
2. The invention does not instrumentation source code.
Drawings
Other features, objects and advantages of the invention will become more apparent upon reading of the detailed description of non-limiting embodiments with reference to the following drawings:
FIG. 1 is a schematic flow chart of the method of the present invention.
Detailed Description
The present invention will be described in detail with reference to specific examples. The following examples will assist those skilled in the art in further understanding the invention, but are not intended to limit the invention in any way. It should be noted that it would be obvious to those skilled in the art that various changes and modifications can be made without departing from the spirit of the invention. All falling within the scope of the present invention.
The invention provides a method for testing the object code coverage rate of an operating system level program, which comprises the following steps:
compiling: registering a monitoring module as a system call function in an operating system source code, and compiling the monitoring module and the operating system source code together;
the testing steps are as follows: calling a monitoring module, testing target code information and coverage rate information, and obtaining test information;
a calculation step: and calculating the object code coverage rate of the application program at the operating system level according to the test information.
Specifically, the operating system provides a plurality of system call functions, and if a user needs to customize the system call functions, the written functions need to be registered or written in a system call function list of the operating system.
Specifically, the monitoring module comprises: monitoring a starting function, a monitoring ending function and an interrupt processing function;
the monitoring start function: mounting an interrupt processing function of a hardware breakpoint in a monitoring module into an interrupt vector table of a processor, enabling debugging interruption of the processor, and enabling the monitoring module to start collecting coverage rate information of a detected target code;
the monitoring end function: turning off the debugging interruption of the processor, and enabling the monitoring module to finish collecting the coverage rate information of the target code to be detected;
the interrupt handling function: and the processor executes the processing function after the hardware breakpoint interruption occurs, and collects and analyzes the execution condition of the current instruction.
Specifically, the testing step comprises the following steps:
step A: calling a monitoring start function of the monitoring module at a coverage rate start point of the tested application program in a system calling mode, calling a monitoring end function at a coverage rate end point, and recompiling the tested application program;
and B: when the target code of the application program to be tested is executed to the coverage rate starting point, calling a monitoring starting function of the monitoring module in a system calling mode, setting a hardware breakpoint behind the coverage rate starting point by the monitoring starting function, and enabling debugging interruption;
and C: after a target code of a tested application program triggers a hardware breakpoint, analyzing a currently executed instruction address of the application program in an interrupt processing function of the hardware breakpoint according to a process control block of an operating system, analyzing whether the current instruction is a branch instruction according to the instruction content of the current instruction, directly marking the instruction to be executed if the current instruction is not the branch instruction, and recording the execution condition of a non-branch instruction; if the current instruction is a branch instruction, analyzing the true and false execution condition of the branch instruction by combining the values of a state register and other related registers of the current processor, recording the execution condition of the branch instruction, analyzing the address of the next characteristic point and setting a hardware breakpoint at the characteristic point; the characteristic points refer to: the next instruction to be executed in the target code to be tested;
step D: when the target code of the application program to be tested is executed to the coverage rate end point, calling a monitoring end function of the monitoring module in a system calling mode, closing debugging interruption by the monitoring end function and deleting a hardware breakpoint, and sending executed target code information and coverage rate information to an upper computer through a communication link for calculating the coverage rate;
the executed object code information and coverage information comprises: the instruction address and instruction execution result to which the instruction is executed;
the execution case comprises the following steps:
execution of non-branch instructions: whether the instruction is executed;
execution of branch instructions: whether the branch instruction is executed, and if the branch instruction is executed, whether the executed branch instruction is a true branch or a false branch.
The process control block is a PCB of an operating system;
the current instruction is an instruction which is being executed or is about to be executed when a hardware breakpoint is triggered;
the state register is a register in the processor and stores the current state information of the processor;
the other relevant registers are a group of registers which are relevant to instruction execution and inside the processor, and the specific names of the registers are different according to the change of the processor.
Specifically, the calculating step: the upper computer combines the tested target code with the received executed target code information and the coverage rate information, so that the statement coverage rate, the branch coverage rate and the call coverage rate of the tested target code are marked and calculated.
The invention provides a system for testing the object code coverage rate of an operating system level program, which comprises:
a compiling module: registering a monitoring module as a system call function in an operating system source code, and compiling the monitoring module and the operating system source code together;
a test module: calling a monitoring module, testing target code information and coverage rate information, and obtaining test information;
a calculation module: and calculating the object code coverage rate of the application program at the operating system level according to the test information.
Specifically, the operating system provides a plurality of system call functions, and if a user needs to customize the system call functions, the written functions need to be registered or written in a system call function list of the operating system.
Specifically, the monitoring module comprises: monitoring a starting function, a monitoring ending function and an interrupt processing function;
the monitoring start function: mounting an interrupt processing function of a hardware breakpoint in a monitoring module into an interrupt vector table of a processor, enabling debugging interruption of the processor, and enabling the monitoring module to start collecting coverage rate information of a detected target code;
the monitoring end function: turning off the debugging interruption of the processor, and enabling the monitoring module to finish collecting the coverage rate information of the target code to be detected;
the interrupt handling function: and the processor executes the processing function after the hardware breakpoint interruption occurs, and collects and analyzes the execution condition of the current instruction.
Specifically, the test module comprises:
a module A: calling a monitoring start function of the monitoring module at a coverage rate start point of the tested application program in a system calling mode, calling a monitoring end function at a coverage rate end point, and recompiling the tested application program;
and a module B: when the target code of the application program to be tested is executed to the coverage rate starting point, calling a monitoring starting function of the monitoring module in a system calling mode, setting a hardware breakpoint behind the coverage rate starting point by the monitoring starting function, and enabling debugging interruption;
and a module C: after a target code of a tested application program triggers a hardware breakpoint, analyzing a currently executed instruction address of the application program in an interrupt processing function of the hardware breakpoint according to a process control block of an operating system, analyzing whether the current instruction is a branch instruction according to the instruction content of the current instruction, directly marking the instruction to be executed if the current instruction is not the branch instruction, and recording the execution condition of a non-branch instruction; if the current instruction is a branch instruction, analyzing the true and false execution condition of the branch instruction by combining the values of a state register and other related registers of the current processor, recording the execution condition of the branch instruction, analyzing the address of the next characteristic point and setting a hardware breakpoint at the characteristic point; the characteristic points refer to: the next instruction to be executed in the target code to be tested;
a module D: when the target code of the application program to be tested is executed to the coverage rate end point, calling a monitoring end function of the monitoring module in a system calling mode, closing debugging interruption by the monitoring end function and deleting a hardware breakpoint, and sending executed target code information and coverage rate information to an upper computer through a communication link for calculating the coverage rate;
the executed object code information and coverage information comprises: the instruction address and instruction execution result to which the instruction is executed;
the execution case comprises the following steps:
execution of non-branch instructions: whether the instruction is executed;
execution of branch instructions: whether the branch instruction is executed, and if the branch instruction is executed, whether the executed branch instruction is a true branch or a false branch.
The process control block is a PCB of an operating system;
the current instruction is an instruction which is being executed or is about to be executed when a hardware breakpoint is triggered;
the state register is a register in the processor and stores the current state information of the processor;
the other relevant registers are a group of registers which are inside the processor and relevant to instruction execution, and the specific names of the registers are different according to the change of the processor;
the calculation module: the upper computer combines the tested target code with the received executed target code information and the coverage rate information, so that the statement coverage rate, the branch coverage rate and the call coverage rate of the tested target code are marked and calculated.
According to the present invention, there is provided a computer-readable storage medium storing a computer program, wherein the computer program, when executed by a processor, implements the steps of any of the methods described above.
The present invention will be described more specifically below with reference to preferred examples.
Preferred example 1:
the innovative scheme is as follows: the monitoring module is implanted into an operating system in a system kernel mode and provides a system calling function. Calling the system call provided by the monitoring module at the coverage rate starting point of the application program to be tested to enable the monitoring module to debug and break, and setting a hardware breakpoint at the coverage rate starting point; in the debugging interruption corresponding to the hardware breakpoint, analyzing the currently executed instruction address of the application program according to the process control block of the operating system, analyzing the instruction content, analyzing the true and false execution condition of the branch instruction by combining the value of the relevant register, recording the instruction execution result, analyzing the position of the next characteristic point and setting the hardware breakpoint. And when the coverage rate is at the end point, turning off debugging interruption by calling system call, and sending the instruction execution result to the upper computer. And after receiving the instruction execution result, the upper computer combines the tested target code with the received executed target code information and the coverage rate information, thereby marking and calculating the statement coverage rate, the branch coverage rate and the call coverage rate of the tested application program.
The characteristic points are as follows: and the next instruction to be executed in the target code to be tested. If the currently executed instruction is a non-branch instruction and the address is 0x4, then the next characteristic point for the instruction is 0x 8. If the currently executed instruction is a branch instruction and the address is 0x4, if it is analyzed that the instruction executed a true branch and the address of its true branch is 0x20, then the next characteristic point of the instruction is 0x 20.
General description: the method can perform statement, branch, call coverage testing of object code for operating system level applications without instrumentation of source code and without the aid of an emulator. The method comprises the following five steps:
1. registering each function of the monitoring module in the source code of the operating system (registering, namely adding, the operating system provides a plurality of system calling functions, and if a user needs to customize the system calling functions, the user needs to register/write the written functions in a system calling function list of the operating system) to be the system calling functions (system calling: computer-specific wording, which can be queried in a hundred degrees), and compiling the monitoring module and the source code of the operating system together.
2. And calling a monitoring start function of the monitoring module at the coverage rate starting point of the tested application program in a system calling mode, and calling a monitoring end function at the coverage rate end point. Recompile (recompile application is required because the application under test is modified (partial code added) the application under test is recompiled.
3. When the target code of the application program to be tested is executed to the coverage rate starting point, a monitoring starting function of the monitoring module is called in a system calling mode, a hardware breakpoint (hardware breakpoint: computer exclusive term, which can be inquired in hundred degrees) is arranged behind the coverage rate starting point by the monitoring starting function, and debugging interruption is enabled.
4. After a target code of a tested application program triggers a hardware breakpoint, analyzing the address of a currently executed instruction (namely an executing instruction or an instruction to be executed when the hardware breakpoint is triggered, which is also called as a current instruction) of the application program in an interrupt processing function of the hardware breakpoint according to a process control block (a process control block: namely a PCB of an operating system) of the operating system, analyzing whether the current instruction is a branch instruction or not according to the instruction content of the current instruction, and directly marking (recording) that the instruction is executed if the current instruction is not the branch instruction; if the current instruction is a branch instruction, the true and false execution conditions of the branch instruction (the branch instruction executes either a true branch or a false branch) are analyzed by combining the values of a status register of the current processor and other related registers (the status register: a register inside the processor which mainly stores the current status information of the processor; other related registers: a group of registers inside the processor which are related to the execution of the instruction, and the specific names of the registers are different according to the change of the processor), the address of the next characteristic point is analyzed and the hardware breakpoint is set at the characteristic point while the execution results of the instruction (the execution results of the branch instruction and non-branch instructions analyzed in the previous way, such as the execution of the branch instruction and the execution results of the branch instruction, or the execution results of the false branch, are analyzed.
5. And when the target code of the application program to be tested is executed to the coverage rate end point, calling a monitoring end function of the monitoring module in a system calling mode, closing debugging interruption by the monitoring end function and deleting the hardware breakpoint. The executed target code information and the coverage rate information (some instructions in the target code to be detected can be executed, and some instructions can not be executed) are sent to the upper computer through the communication link (the execution condition of the ordinary instruction is that whether the ordinary instruction is executed or not, the execution condition of the branch instruction is that whether the branch instruction is executed or not, and whether a true branch or a false branch is executed if the branch instruction is executed or not).
6. And the upper computer combines the tested target code with the executed target code information and the coverage rate information sent in the step 5, so as to mark and calculate the statement coverage rate, the branch coverage rate and the call coverage rate of the tested target code.
Description of the monitoring module of fig. 1:
the monitoring module is a library of functions including, but not limited to, the following functions: a monitoring start function, a monitoring end function, and an interrupt handling function.
The monitoring start function: the method mainly comprises the steps of mounting an interrupt processing function of a hardware breakpoint in a monitoring module into an interrupt vector table of a processor, and enabling/starting (enabling) debugging interrupt of the processor. The monitoring start function presupposes that the monitoring module starts to collect the coverage rate information of the detected target code.
Monitoring an end function: the method mainly comprises the steps of closing debugging interruption of a processor and finishing collecting coverage rate information of a detected target code.
An interrupt handling function: the processing function executed after the processor generates the hardware breakpoint interruption is mainly used for collecting and analyzing the execution condition of the current instruction.
Those skilled in the art will appreciate that, in addition to implementing the systems, apparatus, and various modules thereof provided by the present invention in purely computer readable program code, the same procedures can be implemented entirely by logically programming method steps such that the systems, apparatus, and various modules thereof are provided in the form of logic gates, switches, application specific integrated circuits, programmable logic controllers, embedded microcontrollers and the like. Therefore, the system, the device and the modules thereof provided by the present invention can be considered as a hardware component, and the modules included in the system, the device and the modules thereof for implementing various programs can also be considered as structures in the hardware component; modules for performing various functions may also be considered to be both software programs for performing the methods and structures within hardware components.
The foregoing description of specific embodiments of the present invention has been presented. It is to be understood that the present invention is not limited to the specific embodiments described above, and that various changes or modifications may be made by one skilled in the art within the scope of the appended claims without departing from the spirit of the invention. The embodiments and features of the embodiments of the present application may be combined with each other arbitrarily without conflict.

Claims (6)

1. A method for testing object code coverage of an operating system level program, comprising:
compiling: registering a monitoring module as a system call function in an operating system source code, and compiling the monitoring module and the operating system source code together;
the testing steps are as follows: calling a monitoring module, testing target code information and coverage rate information, and obtaining test information;
a calculation step: calculating the object code coverage rate of the application program of the operating system level according to the test information;
the operating system provides a plurality of system call functions, and if a user needs to customize the system call functions, the written functions need to be registered or written into a system call function list of the operating system;
the monitoring module comprises: monitoring a starting function, a monitoring ending function and an interrupt processing function;
the monitoring start function: mounting an interrupt processing function of a hardware breakpoint in a monitoring module into an interrupt vector table of a processor, enabling debugging interruption of the processor, and enabling the monitoring module to start collecting coverage rate information of a detected target code;
the monitoring end function: turning off the debugging interruption of the processor, and enabling the monitoring module to finish collecting the coverage rate information of the target code to be detected;
the interrupt handling function: and the processor executes the processing function after the hardware breakpoint interruption occurs, and collects and analyzes the execution condition of the current instruction.
2. The method for object code coverage testing of an operating system level program of claim 1,
the testing step comprises the following steps:
step A: calling a monitoring start function of the monitoring module at a coverage rate start point of the tested application program in a system calling mode, calling a monitoring end function at a coverage rate end point, and recompiling the tested application program;
and B: when the target code of the application program to be tested is executed to the coverage rate starting point, calling a monitoring starting function of the monitoring module in a system calling mode, setting a hardware breakpoint behind the coverage rate starting point by the monitoring starting function, and enabling debugging interruption;
and C: after a target code of a tested application program triggers a hardware breakpoint, analyzing a currently executed instruction address of the application program in an interrupt processing function of the hardware breakpoint according to a process control block of an operating system, analyzing whether the current instruction is a branch instruction according to the instruction content of the current instruction, directly marking the instruction to be executed if the current instruction is not the branch instruction, and recording the execution condition of a non-branch instruction; if the current instruction is a branch instruction, analyzing the true and false execution condition of the branch instruction by combining the values of a state register and other related registers of the current processor, recording the execution condition of the branch instruction, analyzing the address of the next characteristic point and setting a hardware breakpoint at the characteristic point; the characteristic points refer to: the next instruction to be executed in the target code to be tested;
step D: when the target code of the application program to be tested is executed to the coverage rate end point, calling a monitoring end function of the monitoring module in a system calling mode, closing debugging interruption by the monitoring end function and deleting a hardware breakpoint, and sending executed target code information and coverage rate information to an upper computer through a communication link for calculating the coverage rate;
the executed object code information and coverage information comprises: the instruction address and instruction execution result to which the instruction is executed;
the execution case comprises the following steps:
execution of non-branch instructions: whether the instruction is executed;
execution of branch instructions: whether a branch instruction is executed, and if the branch instruction is executed, whether the executed branch instruction is a true branch or a false branch;
the process control block is a PCB of an operating system;
the current instruction is an instruction which is being executed or is about to be executed when a hardware breakpoint is triggered;
the state register is a register in the processor and stores the current state information of the processor;
the other relevant registers are a group of registers which are relevant to instruction execution and inside the processor, and the specific names of the registers are different according to the change of the processor.
3. The method for object code coverage testing of an operating system level program of claim 1, wherein said calculating step comprises: the upper computer combines the tested target code with the received executed target code information and the coverage rate information, so that the statement coverage rate, the branch coverage rate and the call coverage rate of the tested target code are marked and calculated.
4. An object code coverage test system for an operating system level program, comprising:
a compiling module: registering a monitoring module as a system call function in an operating system source code, and compiling the monitoring module and the operating system source code together;
a test module: calling a monitoring module, testing target code information and coverage rate information, and obtaining test information;
a calculation module: calculating the object code coverage rate of the application program of the operating system level according to the test information;
the operating system provides a plurality of system call functions, and if a user needs to customize the system call functions, the written functions need to be registered or written into a system call function list of the operating system;
the monitoring module comprises: monitoring a starting function, a monitoring ending function and an interrupt processing function;
the monitoring start function: mounting an interrupt processing function of a hardware breakpoint in a monitoring module into an interrupt vector table of a processor, enabling debugging interruption of the processor, and enabling the monitoring module to start collecting coverage rate information of a detected target code;
the monitoring end function: turning off the debugging interruption of the processor, and enabling the monitoring module to finish collecting the coverage rate information of the target code to be detected;
the interrupt handling function: and the processor executes the processing function after the hardware breakpoint interruption occurs, and collects and analyzes the execution condition of the current instruction.
5. The system for object code coverage testing of operating system level programs of claim 4,
the test module includes:
a module A: calling a monitoring start function of the monitoring module at a coverage rate start point of the tested application program in a system calling mode, calling a monitoring end function at a coverage rate end point, and recompiling the tested application program;
and a module B: when the target code of the application program to be tested is executed to the coverage rate starting point, calling a monitoring starting function of the monitoring module in a system calling mode, setting a hardware breakpoint behind the coverage rate starting point by the monitoring starting function, and enabling debugging interruption;
and a module C: after a target code of a tested application program triggers a hardware breakpoint, analyzing a currently executed instruction address of the application program in an interrupt processing function of the hardware breakpoint according to a process control block of an operating system, analyzing whether the current instruction is a branch instruction according to the instruction content of the current instruction, directly marking the instruction to be executed if the current instruction is not the branch instruction, and recording the execution condition of a non-branch instruction; if the current instruction is a branch instruction, analyzing the true and false execution condition of the branch instruction by combining the values of a state register and other related registers of the current processor, recording the execution condition of the branch instruction, analyzing the address of the next characteristic point and setting a hardware breakpoint at the characteristic point; the characteristic points refer to: the next instruction to be executed in the target code to be tested;
a module D: when the target code of the application program to be tested is executed to the coverage rate end point, calling a monitoring end function of the monitoring module in a system calling mode, closing debugging interruption by the monitoring end function and deleting a hardware breakpoint, and sending executed target code information and coverage rate information to an upper computer through a communication link for calculating the coverage rate;
the executed object code information and coverage information comprises: the instruction address and instruction execution result to which the instruction is executed;
the execution case comprises the following steps:
execution of non-branch instructions: whether the instruction is executed;
execution of branch instructions: whether a branch instruction is executed, and if the branch instruction is executed, whether the executed branch instruction is a true branch or a false branch;
the process control block is a PCB of an operating system;
the current instruction is an instruction which is being executed or is about to be executed when a hardware breakpoint is triggered;
the state register is a register in the processor and stores the current state information of the processor;
the other relevant registers are a group of registers which are inside the processor and relevant to instruction execution, and the specific names of the registers are different according to the change of the processor;
the calculation module: the upper computer combines the tested target code with the received executed target code information and the coverage rate information, so that the statement coverage rate, the branch coverage rate and the call coverage rate of the tested target code are marked and calculated.
6. A computer-readable storage medium, in which a computer program is stored which, when being executed by a processor, carries out the steps of the method of any one of claims 1 to 3.
CN201910900844.4A 2019-09-23 2019-09-23 Object code coverage rate testing method, system and medium for operating system level program Active CN110580226B (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN201910900844.4A CN110580226B (en) 2019-09-23 2019-09-23 Object code coverage rate testing method, system and medium for operating system level program
PCT/CN2020/092359 WO2021057057A1 (en) 2019-09-23 2020-05-26 Target-code coverage testing method, system, and medium of operating system-level program

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910900844.4A CN110580226B (en) 2019-09-23 2019-09-23 Object code coverage rate testing method, system and medium for operating system level program

Publications (2)

Publication Number Publication Date
CN110580226A CN110580226A (en) 2019-12-17
CN110580226B true CN110580226B (en) 2021-09-14

Family

ID=68813439

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910900844.4A Active CN110580226B (en) 2019-09-23 2019-09-23 Object code coverage rate testing method, system and medium for operating system level program

Country Status (2)

Country Link
CN (1) CN110580226B (en)
WO (1) WO2021057057A1 (en)

Families Citing this family (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110580226B (en) * 2019-09-23 2021-09-14 上海创景信息科技有限公司 Object code coverage rate testing method, system and medium for operating system level program
CN111813672B (en) * 2020-07-03 2022-07-08 北京计算机技术及应用研究所 Non-invasive coverage rate statistical method for various processor architectures
CN112395203A (en) * 2020-11-30 2021-02-23 京东数字科技控股股份有限公司 Program testing method, device and storage medium
CN112597064B (en) * 2021-03-02 2021-06-29 芯华章科技股份有限公司 Method for simulating program, electronic device and storage medium
CN113238973B (en) * 2021-07-13 2021-10-15 统信软件技术有限公司 Method, computing device and storage medium for locating performance bottleneck of operating system
CN113806231B (en) * 2021-09-29 2024-03-19 锐捷网络股份有限公司 Code coverage rate analysis method, device, equipment and medium
CN115017059B (en) * 2022-08-08 2022-11-11 北京北大软件工程股份有限公司 Fuzzy test method and system for graphical user interface program

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1983209A (en) * 2005-12-14 2007-06-20 中兴通讯股份有限公司 System and method for automatically testing software unit
CN103699476A (en) * 2012-09-27 2014-04-02 腾讯科技(深圳)有限公司 Coverage rate testing method and system
CN104657263A (en) * 2015-02-10 2015-05-27 上海创景计算机系统有限公司 System and method for realizing universal type target code coverage rate testing based on JTAG (Joint Test Action Group) debug mode
CN106445803A (en) * 2016-08-17 2017-02-22 中国航空工业集团公司西安飞行自动控制研究所 Security-critical embedded software target code coverage analysis method

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104657264A (en) * 2015-02-10 2015-05-27 上海创景计算机系统有限公司 Testing system for binary code covering rate and testing method thereof
CN104657247B (en) * 2015-02-10 2017-12-15 上海创景计算机系统有限公司 Universal fault injection system and fault filling method are realized based on JTAG debud modes
CN104699605B (en) * 2015-03-02 2017-11-17 清华大学 The code coverage measuring method and device of a kind of driver
US9740585B2 (en) * 2015-06-23 2017-08-22 International Business Machines Corporation Flexible configuration and control of a testing system
US20190108006A1 (en) * 2017-10-06 2019-04-11 Nvidia Corporation Code coverage generation in gpu by using host-device coordination
CN110580226B (en) * 2019-09-23 2021-09-14 上海创景信息科技有限公司 Object code coverage rate testing method, system and medium for operating system level program

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1983209A (en) * 2005-12-14 2007-06-20 中兴通讯股份有限公司 System and method for automatically testing software unit
CN103699476A (en) * 2012-09-27 2014-04-02 腾讯科技(深圳)有限公司 Coverage rate testing method and system
CN104657263A (en) * 2015-02-10 2015-05-27 上海创景计算机系统有限公司 System and method for realizing universal type target code coverage rate testing based on JTAG (Joint Test Action Group) debug mode
CN106445803A (en) * 2016-08-17 2017-02-22 中国航空工业集团公司西安飞行自动控制研究所 Security-critical embedded software target code coverage analysis method

Also Published As

Publication number Publication date
CN110580226A (en) 2019-12-17
WO2021057057A1 (en) 2021-04-01

Similar Documents

Publication Publication Date Title
CN110580226B (en) Object code coverage rate testing method, system and medium for operating system level program
US9152531B2 (en) Post-compile instrumentation of object code for generating execution trace data
US8266608B2 (en) Post-compile instrumentation of object code for generating execution trace data
EP1130518B1 (en) Software analysis system having an apparatus for selectively collecting analysis data from a target system executing software instrumented with tag statements and method for use thereof
US6915416B2 (en) Apparatus and method for microcontroller debugging
JP5430570B2 (en) Method for test suite reduction by system call coverage criteria
US20070079288A1 (en) System and method for capturing filtered execution history of executable program code
US7093165B2 (en) Debugging Method
CN109101416B (en) Kernel fault injection method and electronic equipment
US20110314338A1 (en) Data collisions in concurrent programs
US20080307397A1 (en) Program Analysis by Partial Emulation
Jeong et al. Fifa: A kernel-level fault injection framework for arm-based embedded linux system
CN109783837A (en) Emulator, analogue system, emulation mode and simulated program
CN105550575B (en) A kind of acquisition methods and device of not derived function address and data structural deflection
CN109902001B (en) Method for detecting uninitialized variable and terminal equipment
CN110647467B (en) Target code coverage rate testing method, system and medium based on single step exception
US6546526B2 (en) Active trace debugging for hardware description languages
US9111034B2 (en) Testing of run-time instrumentation
CN109726115A (en) It is a kind of based on Intel processor tracking anti-debug automatically bypass method
CN110727577B (en) Debugging method, system and medium for probability reproduction problem in embedded system software
CN114510429A (en) Debugging method, system and medium based on dynamic symbol execution
CN110554969B (en) Target code coverage rate testing method, system and medium based on preset breakpoints
CN105718375A (en) Restorability testing method of embedded system
KR102421394B1 (en) Apparatus and method for detecting malicious code using tracing based on hardware and software
US20100251213A1 (en) Method for executing debug commands

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant