CN110580226A - 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
CN110580226A
CN110580226A CN201910900844.4A CN201910900844A CN110580226A CN 110580226 A CN110580226 A CN 110580226A CN 201910900844 A CN201910900844 A CN 201910900844A CN 110580226 A CN110580226 A CN 110580226A
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.)
Granted
Application number
CN201910900844.4A
Other languages
Chinese (zh)
Other versions
CN110580226B (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.)
Shanghai Chuangjing Information Technology Co ltd
Original Assignee
Shanghai Chuangkin Mdt Infotech 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 Shanghai Chuangkin Mdt Infotech Ltd filed Critical Shanghai Chuangkin Mdt Infotech 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

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

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Debugging And Monitoring (AREA)

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 (10)

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: and calculating the object code coverage rate of the application program at the operating system level according to the test information.
2. The method of claim 1, wherein the operating system provides a plurality of system call functions, and the user needs to register or write the written functions into the list of system call functions of the operating system if the user needs to customize the system call functions.
3. The method of claim 1, wherein the monitor 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.
4. The method of claim 1, wherein the step of testing 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.
5. 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.
6. 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: and calculating the object code coverage rate of the application program at the operating system level according to the test information.
7. the system for object code coverage testing of operating system level programs of claim 6, wherein said operating system provides a plurality of system call functions, and wherein a user needs to register or write a written function into a list of system call functions of the operating system if the user needs to customize the system call functions.
8. the system for object code coverage testing of operating system level programs of claim 6, wherein said monitor 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.
9. the system for object code coverage testing of operating system level programs of claim 6, wherein said 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.
10. 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 according to any one of claims 1 to 5.
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 true CN110580226A (en) 2019-12-17
CN110580226B 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)

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111240856A (en) * 2020-01-03 2020-06-05 北京小米移动软件有限公司 Message processing method and device and storage medium
CN111813672A (en) * 2020-07-03 2020-10-23 北京计算机技术及应用研究所 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
WO2021057057A1 (en) * 2019-09-23 2021-04-01 上海创景信息科技有限公司 Target-code coverage testing method, system, and medium of operating system-level program
CN112597064A (en) * 2021-03-02 2021-04-02 芯华章科技股份有限公司 Method for simulating program, electronic device and storage medium
CN113778892A (en) * 2021-07-13 2021-12-10 统信软件技术有限公司 Method, computing device and storage medium for locating performance bottleneck of operating system
CN115017059A (en) * 2022-08-08 2022-09-06 北京北大软件工程股份有限公司 Fuzzy test method and system for graphical user interface program

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113806231B (en) * 2021-09-29 2024-03-19 锐捷网络股份有限公司 Code coverage rate analysis method, device, equipment and medium
CN114490314B (en) * 2021-12-08 2024-07-16 中国科学院信息工程研究所 Coverage rate guided virtual network equipment fuzzy test method and coverage rate guided virtual network equipment fuzzy test device
CN114817045B (en) * 2022-04-29 2024-10-25 北京轩宇信息技术有限公司 Source code coverage rate determining method and system
CN118394658A (en) * 2024-05-30 2024-07-26 上海安般信息科技有限公司 Frida-based multithreaded application dynamic instrumentation and coverage rate collection method

Citations (5)

* 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
US20170308451A1 (en) * 2015-06-23 2017-10-26 International Business Machines Corporation Flexible configuration and control of a testing system

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104657247B (en) * 2015-02-10 2017-12-15 上海创景计算机系统有限公司 Universal fault injection system and fault filling method are realized based on JTAG debud modes
CN104657264A (en) * 2015-02-10 2015-05-27 上海创景计算机系统有限公司 Testing system for binary code covering rate and testing method thereof
CN104699605B (en) * 2015-03-02 2017-11-17 清华大学 The code coverage measuring method and device of a kind of driver
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 (5)

* 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
US20170308451A1 (en) * 2015-06-23 2017-10-26 International Business Machines Corporation Flexible configuration and control of a testing system
CN106445803A (en) * 2016-08-17 2017-02-22 中国航空工业集团公司西安飞行自动控制研究所 Security-critical embedded software target code coverage analysis method

Cited By (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2021057057A1 (en) * 2019-09-23 2021-04-01 上海创景信息科技有限公司 Target-code coverage testing method, system, and medium of operating system-level program
CN111240856A (en) * 2020-01-03 2020-06-05 北京小米移动软件有限公司 Message processing method and device and storage medium
CN111240856B (en) * 2020-01-03 2024-04-23 北京小米移动软件有限公司 Message processing method and device and storage medium
CN111813672A (en) * 2020-07-03 2020-10-23 北京计算机技术及应用研究所 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
CN112597064A (en) * 2021-03-02 2021-04-02 芯华章科技股份有限公司 Method for simulating program, electronic device and storage medium
CN112597064B (en) * 2021-03-02 2021-06-29 芯华章科技股份有限公司 Method for simulating program, electronic device and storage medium
CN113778892A (en) * 2021-07-13 2021-12-10 统信软件技术有限公司 Method, computing device and storage medium for locating performance bottleneck of operating system
CN113778892B (en) * 2021-07-13 2024-05-07 统信软件技术有限公司 Method for locating performance bottleneck of operating system, computing device and storage medium
CN115017059A (en) * 2022-08-08 2022-09-06 北京北大软件工程股份有限公司 Fuzzy test method and system for graphical user interface program
CN115017059B (en) * 2022-08-08 2022-11-11 北京北大软件工程股份有限公司 Fuzzy test method and system for graphical user interface program

Also Published As

Publication number Publication date
WO2021057057A1 (en) 2021-04-01
CN110580226B (en) 2021-09-14

Similar Documents

Publication Publication Date Title
CN110580226B (en) Object code coverage rate testing method, system and medium for operating system level program
CN109800159B (en) Program debugging method, program debugging device, terminal device, and storage medium
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
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
CN109101416B (en) Kernel fault injection method and electronic equipment
US7093165B2 (en) Debugging Method
EP2615552A1 (en) System testing method
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
CN105550575B (en) A kind of acquisition methods and device of not derived function address and data structural deflection
US20240289257A1 (en) Method for testing a computer program
CN109783837A (en) Emulator, analogue system, emulation mode and simulated program
CN105027089A (en) Kernel functionality checker
US9111034B2 (en) Testing of run-time instrumentation
CN110647467B (en) Target code coverage rate testing method, system and medium based on single step exception
CN109902001B (en) Method for detecting uninitialized variable and terminal equipment
CN110554969B (en) Target code coverage rate testing method, system and medium based on preset breakpoints
CN114510429B (en) Debugging method, system and medium based on dynamic symbol execution
US20020100001A1 (en) Active trace debugging for hardware description languages
CN110727577B (en) Debugging method, system and medium for probability reproduction problem in embedded system software
CN105718375A (en) Restorability testing method of embedded system

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
CP03 Change of name, title or address

Address after: Block 22301-985, Building 14, No. 498 Guo Shoujing Road, China (Shanghai) Pilot Free Trade Zone, Pudong New Area, Shanghai, March 2012

Patentee after: Shanghai Chuangjing Information Technology Co.,Ltd.

Country or region after: China

Address before: 200135 block 22301-985, building 14, No. 498, GuoShouJing Road, pilot Free Trade Zone, Pudong New Area, Shanghai

Patentee before: VISION MICROSYSTEMS (SHANGHAI) Co.,Ltd.

Country or region before: China

CP03 Change of name, title or address