CN113297064A - Code coverage rate testing method, system, equipment and storage medium - Google Patents

Code coverage rate testing method, system, equipment and storage medium Download PDF

Info

Publication number
CN113297064A
CN113297064A CN202010744868.8A CN202010744868A CN113297064A CN 113297064 A CN113297064 A CN 113297064A CN 202010744868 A CN202010744868 A CN 202010744868A CN 113297064 A CN113297064 A CN 113297064A
Authority
CN
China
Prior art keywords
coverage
code
compiler
coverage rate
information
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202010744868.8A
Other languages
Chinese (zh)
Inventor
李�杰
赵红兵
侯俊
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Alibaba Group Holding Ltd
Original Assignee
Alibaba Group Holding 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 Alibaba Group Holding Ltd filed Critical Alibaba Group Holding Ltd
Priority to CN202010744868.8A priority Critical patent/CN113297064A/en
Publication of CN113297064A publication Critical patent/CN113297064A/en
Pending legal-status Critical Current

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

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 code coverage rate testing method comprises the following steps: copying a source code to a pre-configured compiler, wherein a kernel source code of the pre-configured compiler comprises service architecture compatible configuration information, and configuration parameters of the compiler comprise a code coverage rate parameter; compiling the source code by adopting the compiler to generate a binary executable file; starting and executing the online service by adopting the executable file; in the compiling process, generating first coverage rate information of executed codes in the online service running process based on service architecture compatible configuration information contained in kernel source codes of the compiler and pre-configured code coverage rate parameters of the compiler. By adopting the scheme of the embodiment of the specification, the code coverage rate can be quickly obtained.

Description

Code coverage rate testing method, system, equipment and storage medium
Technical Field
The embodiment of the specification relates to the technical field of software testing, in particular to a code coverage rate testing method, system, equipment and storage medium.
Background
In the testing process of a computer program, code coverage is an index for evaluating test activities to cover product codes and is used for measuring the coverage degree of the test on the program codes. Through the code coverage rate statistics, the method can acquire how many codes in the program are executed and which codes are not enough in test coverage degree.
Currently, for C + + code coverage, the industry is generally based on the capability provided by a GCC (GNU Compiler Collection, GNU compilation software suite) Compiler, this method needs to add parameters in the compilation command, and the flow is tedious and complex, for a complex module such as an engine, there are hundreds of thousands of lines of codes, cpp (suffix name of source code file written in C + + language) file is as many as thousands, and manually modifying the configuration of the compilation building tool (such as makefile, Blade) is extremely complex and difficult to maintain, and there is no mature corresponding scheme.
Therefore, how to obtain the code coverage rate quickly becomes a problem to be solved urgently.
Disclosure of Invention
In view of this, embodiments of the present disclosure provide a code coverage testing method, system, device, and storage medium, which can quickly obtain a code coverage.
An embodiment of the present specification provides a code coverage rate testing method, including:
copying a source code to a pre-configured compiler, wherein a kernel source code of the pre-configured compiler comprises service architecture compatible configuration information, and configuration parameters of the compiler comprise a code coverage rate parameter;
compiling the source code by adopting the compiler to generate a binary executable file;
starting and executing the online service by adopting the executable file;
in the compiling process, generating first coverage rate information of executed codes in the online service running process based on service architecture compatible configuration information contained in kernel source codes of the compiler and pre-configured code coverage rate parameters of the compiler.
Optionally, the performing the compiling operation by using the compiler, and generating first coverage information of an executed code in the online service running process based on service architecture compatible configuration information included in a kernel source code of the compiler and a pre-configured code coverage parameter of the compiler includes:
in the compiling process, responding to a coverage rate obtaining instruction, and a thread monitoring code arranged in the source code obtains first coverage rate data of an executed code in the online service operation process;
and generating first coverage rate information of the executed codes in the online service operation process based on the first coverage rate data of the executed codes acquired by the thread monitoring codes.
Optionally, the starting and executing the online service by using the executable file includes:
copying the executable file to a target path, and starting the online service;
and running the test case and executing the online service.
Optionally, generating first coverage information of an executed code in the online service operation process based on service architecture compatible configuration information included in kernel source code of the compiler and a preconfigured code coverage parameter of the compiler, where the generating includes:
in the compiling process, generating a code overlay to a preset first compiling result directory based on service architecture compatible configuration information contained in kernel source codes of the compiler and a pre-configured code overlay parameter of the compiler, wherein the code overlay is suitable for recombining the executable file;
in the compiling process, responding to a coverage rate obtaining instruction, triggering a thread monitoring code arranged in the source code to obtain second coverage rate data corresponding to the coverage rate obtaining instruction in the online service running process, and outputting the second coverage rate data to a preset second compiling result directory;
generating a code coverage report file based on the code coverage obtained from the first compilation result directory and the second coverage data obtained from the second compilation result directory, wherein the code coverage report file comprises the first coverage information.
Optionally, the generating a code coverage report file of the online service based on the code coverage obtained from the first compilation result directory and the second coverage data obtained from the second compilation result directory includes:
and generating a code coverage report file of the out-of-service based on the code coverage acquired from the first compiling result directory and the second coverage data acquired from the second compiling result directory according to a preset coverage type.
Optionally, the method further comprises: and outputting the first coverage rate information of the online service by adopting a visual page.
Optionally, the method further comprises:
analyzing the first coverage rate information of the source code output by the visual page, and converting the first coverage rate information into second coverage rate data in a preset storage format;
calculating to obtain second coverage rate information of a type corresponding to a preset coverage rate based on the second coverage rate data of the preset storage format;
and outputting the second coverage rate information of the corresponding type according to a preset display format.
Optionally, the calculating, based on the second coverage data in the preset storage format, to obtain second coverage information of a type corresponding to a preset coverage includes:
and calculating at least one of the line coverage, the function coverage, the branch coverage and the path coverage of each file corresponding to the source code, and the hit times and miss times information of the corresponding line level according to a preset coverage type based on the second coverage data of the preset storage format.
An embodiment of the present specification further provides a code coverage testing system, including:
the system comprises a copying unit, a service architecture compatible configuration unit and a service architecture compatible configuration unit, wherein the copying unit is suitable for copying a source code to a pre-configured compiler, the kernel source code of the pre-configured compiler comprises service architecture compatible configuration information, and the configuration parameters of the compiler comprise a code coverage rate parameter;
the compiling unit is suitable for compiling the source code by adopting the pre-configured compiler to generate a binary executable file;
the online service starting and executing unit is suitable for starting and executing the online service by adopting the executable file;
and the first coverage rate information generating unit is suitable for performing compiling operation by adopting the compiler, and generating first coverage rate information of the executed codes in the online service operation process based on service architecture compatible configuration information contained in kernel source codes of the compiler and pre-configured code coverage rate parameters of the compiler.
An embodiment of the present specification further provides a code coverage testing apparatus, including: a memory and a processor, the memory having stored thereon computer instructions executable on the processor, when executing the computer instructions, performing the steps of the method of any of the preceding embodiments.
The present specification also provides a computer readable storage medium, on which computer instructions are stored, wherein the computer instructions are executed to perform the steps of the method of any one of the foregoing embodiments.
By adopting the code coverage rate test scheme of the embodiment of the specification, the service architecture compatible configuration information is contained in the kernel source code of the compiler in advance, the configuration parameters of the compiler including the code coverage rate parameters are configured, the source code is copied to the compiler for compiling to generate a binary executable file, and the executable file is adopted to start and execute the online service.
Further, by setting a thread monitoring code in the source code, and in the compiling process, the thread monitoring code of the source code responds to the coverage rate obtaining instruction to obtain the first coverage rate data of the executed code of the online service in the running process, so that the code coverage rate information can be obtained in real time in the running process of the service without stopping the service.
Further, the first coverage rate information of the source code output by the visual page is analyzed and converted into second coverage rate data in a preset storage format, based on the second coverage rate data in the preset storage format, second coverage rate information of a type corresponding to the predicted coverage rate can be obtained through calculation, the second coverage rate information of the corresponding type can be output according to a preset display format, and through the data format conversion process and based on the converted storage format, more deep analysis processing can be performed on the second coverage rate data, so that more comprehensive, detailed and accurate coverage rate information, namely the second coverage rate information, of the source code in the service execution process can be obtained.
Drawings
Fig. 1 shows a flowchart of a code coverage testing method in an embodiment of the present specification.
FIG. 2 shows an example of code for an increased coverage parameter in a GCC kernel compiler in a display interface in an embodiment of the present specification.
Fig. 3 illustrates an example of instrumentation code shown in a display interface in an embodiment of the present specification.
FIG. 4 is a schematic diagram of a visualization page of coverage information output during operation of an online service;
FIG. 5 shows an example of a test report display interface in an embodiment of the present specification;
FIG. 6 is a schematic structural diagram illustrating a code coverage testing system in an embodiment of the present specification;
fig. 7 shows a schematic structural diagram of a code coverage testing apparatus in an embodiment of the present specification.
Detailed Description
For a software system with huge code quantity, such as a large-scale C + + project, hundreds of thousands of millions of lines of codes are possible, cpp files are thousands of, parameters need to be added manually in a compiling command based on the capability provided by a compiler to obtain code coverage rate information, the process is complicated, the maintenance is difficult, and the code coverage rate cannot be obtained quickly.
In view of the above, the present specification provides a corresponding code coverage testing method, system, device and storage medium.
For a better understanding and enabling disclosure of the embodiments of the present description to those skilled in the art, reference is made to the accompanying drawings and in the following detailed description, which are provided for a specific application scenario.
As shown in fig. 1, the flowchart of the code coverage testing method may specifically include the following steps:
s11, copying a source code to a pre-configured compiler, wherein the kernel source code of the pre-configured compiler comprises service architecture compatible configuration information, and the configuration parameters of the compiler comprise a code coverage rate parameter.
In a specific implementation, the source code may be stored locally or may be stored in a remote version library such as a cloud. Accordingly, the copy may be made directly from the local, and the copy may be pulled from the source code remote version library.
At present, a compiler generally does not support automatic code coverage acquisition, and in order to acquire the code coverage, a compiler command needs to be manually modified item by item, so that for many large software projects, a large amount of time needs to be spent to modify item by item, errors or omissions are easy to occur, along with code modification, the configuration of the compiler command needs to be modified again item by item, the compiler command is very complicated and complex, and is not easy to maintain.
In order to achieve quick and efficient acquisition of the code coverage rate information, service architecture compatible configuration information can be configured in a kernel code of a compiler, and the service architecture compatible configuration information can be specifically achieved through corresponding codes. As shown in fig. 2, an example of code for adding a coverage parameter in a GCC kernel compiler where kernel code can be compiled in assembly language is shown on the display interface 20. In a specific implementation, by configuring the configuration parameter examples shown in fig. 2 such as asm, asm _ debug and the like in the kernel code of the GCC kernel compiler, code coverage information acquisition in corresponding working modes can be realized, where the code coverage information acquisition includes a normal compilation (asm) mode and a debug (debug) mode, and by setting the asm _ final parameter, the created individual object file containing the DWARF debug information can be output to a preset compilation result directory, for example, a gcda. And, for the GCC compiler, the code coverage configuration parameter may be increased, in some optional examples of this specification, the code coverage configuration parameter is increased: -fpprofile-arcs and-ftest-coverage.
In order to achieve coverage of executed codes in the service running process, as an alternative example, compiling and instrumentation may be performed in advance, and thread monitoring codes are set in the source codes. A code coverage tester may select some positions in the source code and set the thread monitoring code, for example, as shown in the example of the instrumented code shown in the display interface 30 in fig. 3, if the instrumented code shown in the display interface 30 is inserted into the source code, when the source code receives a signal with a signal code of 36, the code coverage may be triggered to be obtained.
In specific implementation, any one of the compiling tools such as GCC compiler, Blade, makefile, SCons, etc. may be used for compiling.
And S12, compiling the source code by adopting the compiler to generate a binary executable file.
In a specific implementation, the compiler that is configured as described above is used to compile the source code, and a binary (binary) executable file may be generated, with a file suffix of "bin".
And S13, starting and executing the online service by using the executable file.
In specific implementation, the executable file may be copied to a target path, the online service may be started, and a test case may be run to execute the online service.
For example, the test case is run, and one or more of a smoke test, an online environmental pressure test, a performance test, and the like can be performed. Other types of tests can also be executed through corresponding test cases as required.
And S14, performing compiling operation by using the compiler, and generating first coverage rate information of the online service based on service architecture compatible configuration information contained in kernel source codes of the compiler and pre-configured code coverage rate parameters of the compiler.
In the compiling process, on one hand, based on service architecture compatible configuration information contained in kernel source codes of the compiler and pre-configured code coverage rate parameters of the compiler, a code coverage map can be generated to a preset first compiling result directory, wherein the code coverage map is suitable for recombining the executable file; on the other hand, in response to a coverage rate obtaining instruction, triggering a thread monitoring code set in the source code to obtain second coverage rate data corresponding to the coverage rate obtaining instruction in the online service operation process, and outputting the second coverage rate data to a preset second compiling result directory; then, based on the code coverage map obtained from the first compilation result directory and the second coverage data obtained from the second compilation result directory, a code coverage report file may be generated, where the code coverage report file includes first coverage information of the online service.
As a specific example of implementation in the GCC compiler, due to the service architecture compatible configuration information included in the kernel source code of the compiler and the pre-configured code coverage parameter of the compiler, a binary executable file generated after adding two configuration parameters, namely "-fprofile-arcs" and "-ftest-coverage" can be obtained during compiling and linking. When the user is compiled by GCC, an-fprofile-arcs-ftest-coverage option is added, and when the user is linked, the user also adds the option.
The fprofile-arcs parameter causes the GCC to create a code map of the program, and then find a spanning tree that fits the map. Only arcs not in the spanning tree are manipulated (instrumented): the GCC adds code to count the number of times these arcs are executed. When the arc is the only exit or entry of a block, the manipulation tool code (instrumentation code) is added to the block, otherwise a base block is created to contain the manipulation tool code.
In a specific implementation, gcov (a coverage statistics tool for code execution, published with GCC) can be used, resulting in two files with suffix names ". gcno" and ". gcna". Wherein the file with suffix name ". gcno" is generated by an-ftest-coverage, wherein the code overlay is suitable for reorganizing the executable file and may contain information of the line numbers of the source codes of the reconstructed basic block map and the corresponding blocks; the file with suffix ". gcda" is generated by the GCC compiler adding compiled file runs of the compilation configuration parameter "-fprofile-arcs", which may include the number of arc jumps and other summary information.
For example, in the process of executing the service, if a sudo kill-36pid command is received, which represents that a signal indicating that a termination process with signal number 36 is received, since the instrumentation code shown in fig. 3 has been implanted in the source code, the instrumentation code shown in fig. 3 is triggered to obtain the coverage data of the executed code in the process of operating the service, which is referred to as "first coverage data" for convenience of description and distinguishing from the coverage data described in the following embodiments. The instrumented code creates a gcda file corresponding to the source file one by one when being executed, and the gcda file records the running data of the source code.
Based on the first coverage rate data of the executed code acquired by the thread monitoring code, the first coverage rate information of the executed code in the online service running process can be generated. In a specific implementation, info data may be generated using Icov, as a specific example, the command "lcov xxx. info-d" is executed, and the first coverage data in the folders of ". gcno" and ". gcda" may be obtained, for example, if the preset coverage type includes a line coverage and a Function coverage (Function) coverage, the line coverage and Function coverage information of the online service may be given in a code coverage report file, and the specific coverage of the online service, and the number of hit code lines and the number of covered code lines may also be included. The functional coverage is also called functional coverage.
By adopting the embodiment, the service architecture compatible configuration information is set in the kernel source code of the compiler, and the configuration parameters of the compiler are set to comprise the code coverage rate parameters, so that the automatic acquisition of the code coverage rate data can be realized without knowing the complex bottom layer compiling details and the dependent environment and modifying the compiling instruction one by one, and the code coverage rate information can be quickly and efficiently output.
In a specific implementation, the first coverage information of the online service can be output by using a visualization page. In some embodiments of the present description, a front-end tool LCOV that can be graphical through the GCOV, is based on hypertext Markup Language (HTML) output, and generates a complete HTML tree, and specific output may include a summary, a percentage of coverage, an icon, and the like, so that coverage information can be browsed quickly. As shown in fig. 4, a schematic diagram of a visualization page of coverage information output during the operation of an online service, which uses an ichv-equipped genehtml tool to generate an HTML document according to an information file (. info), i.e., generate a webpage result report, and the coverage information can be browsed through a webpage format, as shown in fig. 4, including row coverage and functional coverage information. Besides outputting the first coverage rate information in the file view mode shown in fig. 4, the first coverage rate information may also be output in other view modes such as a directory view and a source code view. In addition, in the embodiment, in order to distinguish the specific data, highlighting may be performed by different colors, textures, and the like.
In specific implementation, the inventor finds that the first coverage information displayed in the form of the HTML webpage is convenient for a user to view, but is inconvenient for data comparison. For this purpose, in some embodiments of the present specification, first, the first coverage rate information of the source code output by the visual page is parsed and converted into second coverage rate data stored in a preset format; calculating to obtain second coverage rate information of a type corresponding to a preset coverage rate based on the second coverage rate data of the preset storage format; and then, outputting the corresponding second coverage rate information according to a preset display format.
For example, the first coverage rate information output in the html webpage form may be parsed and converted into the JSON format, and then, based on the second coverage rate data in the JSON format, the second coverage rate information of the type corresponding to the preset coverage rate may be obtained through calculation. Specifically, based on the second coverage data of the preset storage format, at least one of a line coverage, a function coverage, a branch coverage, a path coverage, and the like of each file corresponding to the source code, and information such as hit times and miss times of a corresponding line level are calculated according to a preset coverage type.
The code coverage rate is the percentage of the number of the items executed at least once to the whole number of the items. Specifically, different types of code coverage rates are obtained, and if the item number is a statement, the corresponding code line coverage rate is obtained; if the item number is a function, the corresponding function coverage rate is; if the "number of entries" is a path, it corresponds to the path coverage.
In some embodiments of the present specification, the second coverage information may include more detailed coverage information, including some comparative information, for example, as shown in an incremental code test report display example shown in fig. 5, in a test report display interface 50, for a code branch master, a global test data display region 51 corresponding to the incremental code detailed information, a functional test information display region 52 corresponding to the functional test details, and a functional a/B test information display region 53 corresponding to the recommended flow comparative details are respectively given, where, as shown in the functional test information display region 52, the number of online service precise cases is shown to be 46, the total number of functional module test cases is 82, and details corresponding to a column of "functional test report" are clicked, so that more refined test information may be obtained. The function a/B test information display area 53 shows the number of covered code lines, the incremental function code coverage, the recommended traffic number, and the function a/B test report, where the accurate recommended traffic number obtained by statistics is shown to be 273, and the more refined function a/B test report information can be further obtained by clicking the details corresponding to the function a/B test report information.
As can be seen from the above example, by analyzing the first coverage information of the source code output by the visualization page, converting the first coverage information into second coverage data in a preset storage format, and based on the second coverage data in the preset storage format, calculating to obtain second coverage information of a type corresponding to the predicted coverage, and outputting the second coverage information of the corresponding type according to a preset display format, through this data format conversion process and based on the converted storage format, a deeper analysis process can be performed on the second coverage data, so that more comprehensive, detailed, and accurate coverage information, that is, second coverage information, of the source code in the service execution process can be obtained.
Referring to the code coverage test system shown in FIG. 6, in some embodiments of the present description, the code coverage test system 60 may include: a copying unit 61, a compiling unit 62, an online service starting and constructing unit 63, and a first coverage information generating unit 64, as shown in fig. 6, wherein:
the copying unit 61 is adapted to copy a source code to a preconfigured compiler, where a kernel source code of the preconfigured compiler includes service architecture compatible configuration information, and a configuration parameter of the compiler includes a code coverage parameter;
the compiling unit 62 is adapted to compile the source code by using the preconfigured compiler to generate a binary executable file;
the online service starting and executing unit 63 is adapted to start and execute the online service by using the executable file;
the first coverage rate information generating unit 64 is adapted to perform a compiling operation by using the compiler, and generate first coverage rate information of an executed code in the online service running process based on service architecture compatible configuration information included in kernel source code of the compiler and a pre-configured code coverage rate parameter of the compiler.
In specific implementation, the code coverage testing system used in the embodiment of the present specification may be obtained by configuring the kernel code and the configuration information by using existing general code coverage testing software in the manner described in the embodiment of the present specification, or may be a completely new code coverage testing system newly developed and designed, and the code coverage testing system may be run and implemented on a special-purpose or general-purpose computer.
In a specific implementation, as shown in fig. 6, the code coverage testing system 60 may further include an instrumentation unit 65 adapted to set a thread listening code in the source code; accordingly, the first coverage information generating unit 64 is adapted to generate the first coverage information of the executed code during the online service operation process based on the first coverage data of the executed code during the online service operation process, which is acquired by the thread monitoring code in response to the coverage acquiring instruction.
In a specific implementation, the online service starting and executing unit 63 is adapted to copy the executable file to a target path, start the online service, run a test case, and execute the online service.
In some embodiments of the present description, with continued reference to fig. 6, the first coverage information generating unit 64 may include: a code coverage map generating sub-unit 641, a second coverage data acquiring sub-unit 642, and a code coverage report file generating sub-unit 643, wherein:
the code overlay generating subunit 641 is adapted to generate a code overlay to a preset first compilation result directory based on service architecture compatible configuration information included in a kernel source code of the compiler and a pre-configured code overlay parameter of the compiler in a compilation process, where the code overlay is adapted to reassemble the executable file;
the first coverage data obtaining subunit 642 is adapted to, in a compiling process, trigger a thread monitoring code set in the source code to obtain, in response to a coverage obtaining instruction, second coverage data corresponding to the coverage obtaining instruction in the online service running process, and output the second coverage data to a preset second compiling result directory;
the code coverage report file generating subunit 643, configured to generate a code coverage report file based on the code coverage obtained from the first compilation result directory and the second coverage data obtained from the second compilation result directory, where the code coverage report file includes the first coverage information.
In a specific implementation, the code coverage report file generating subunit 643 is adapted to generate the code coverage report file of the out-of-service according to a preset coverage type based on the code coverage map obtained from the first compilation result directory and the first coverage data obtained from the second compilation result directory.
With continued reference to fig. 6, in a specific implementation, the code coverage test system 60 may further include: a first output unit 66 adapted to output the first coverage information of the online service using a visualization page.
To obtain more comprehensive, detailed and accurate coverage information of the source code in the service execution process, i.e. the second coverage information, as shown in fig. 6, the code coverage testing system 60 may further include: a parsing unit 67, a second coverage information obtaining unit 68, and a second output unit 69, wherein:
the analyzing unit 67 is configured to analyze the first coverage rate information of the source code output by the visual page, and convert the first coverage rate information into second coverage rate data in a preset storage format;
the second coverage rate information obtaining unit 68 calculates, based on the second coverage rate data in the preset storage format, second coverage rate information of a type corresponding to a preset coverage rate;
the second output unit 69 outputs the second coverage rate information of the corresponding type according to a preset display format.
As an alternative example, the solution in the present specification may be applied to coverage rate acquisition of C + + code, and may also be applied to code coverage rates of other types of programming languages, for example, C language code and Java language code.
Embodiments of the present specification further provide a code coverage testing apparatus, as shown in fig. 7, the code coverage testing apparatus 70 may include: a memory 71 and a processor 72, where the memory 71 stores computer instructions executable on the processor 72, and the processor 72 executes the steps of the method according to any of the foregoing embodiments when executing the computer instructions.
In particular implementations, with continued reference to fig. 7, the code coverage testing device 70 may further include a communication component 73 adapted to retrieve source code, such as from a remote server over a network or from other storage devices over a USB interface, bluetooth interface, or other transmission interface.
In a specific implementation, as shown in fig. 7, the code coverage testing apparatus 70 may further include a display component adapted to display code coverage testing information, which includes testing information of different forms and different granularities, such as the first coverage testing information and the second coverage testing information described in the foregoing embodiments.
In some embodiments of the present description, the memory, processor, communication component, and display component may communicate over a bus network.
In a specific implementation, as shown in fig. 7, the communication component 73, the display component 74, and the like may be components disposed inside the electronic device 70, or may be external devices connected through an expansion component such as an expansion interface, a docking station, an expansion line, and the like.
In a specific implementation, the code coverage rate testing device may be implemented by various types of computer devices such as a desktop computer and a cloud server.
The embodiments of the present disclosure also provide a computer-readable storage medium, on which computer instructions are stored, and when the computer instructions are executed, the steps of the method according to any of the foregoing embodiments are executed.
In particular implementations, the computer-readable storage medium may be a variety of suitable readable storage media such as an optical disk, a mechanical hard disk, a solid state disk, and so on.
Although the embodiments of the present invention are disclosed above, the present invention is not limited thereto. Various changes and modifications may be effected by one skilled in the art without departing from the spirit and scope of the embodiments of the invention as defined in the appended claims.

Claims (11)

1. A code coverage testing method, comprising:
copying a source code to a pre-configured compiler, wherein a kernel source code of the pre-configured compiler comprises service architecture compatible configuration information, and configuration parameters of the compiler comprise a code coverage rate parameter;
compiling the source code by adopting the compiler to generate a binary executable file;
starting and executing the online service by adopting the executable file;
in the compiling process, generating first coverage rate information of executed codes in the online service running process based on service architecture compatible configuration information contained in kernel source codes of the compiler and pre-configured code coverage rate parameters of the compiler.
2. The method of claim 1, wherein the performing the compiling operation with the compiler, based on service architecture compatible configuration information included in kernel source code of the compiler and pre-configured code coverage parameters of the compiler, generating first coverage information of executed code in the online service running process, comprises:
in the compiling process, responding to a coverage rate obtaining instruction, and a thread monitoring code arranged in the source code obtains first coverage rate data of an executed code in the online service operation process;
and generating first coverage rate information of the executed codes in the online service operation process based on the first coverage rate data of the executed codes acquired by the thread monitoring codes.
3. The method of claim 2, wherein said initiating and executing the online service using the executable file comprises:
copying the executable file to a target path, and starting the online service;
and running the test case and executing the online service.
4. The method according to claim 3, wherein the generating, during the compiling process, first coverage information of executed codes in the online service running process based on service architecture compatible configuration information contained in kernel source codes of the compiler and pre-configured code coverage parameters of the compiler comprises:
in the compiling process, generating a code overlay to a preset first compiling result directory based on service architecture compatible configuration information contained in kernel source codes of the compiler and a pre-configured code overlay parameter of the compiler, wherein the code overlay is suitable for recombining the executable file;
in the compiling process, responding to a coverage rate obtaining instruction, triggering a thread monitoring code arranged in the source code to obtain second coverage rate data corresponding to the coverage rate obtaining instruction in the online service running process, and outputting the second coverage rate data to a preset second compiling result directory;
generating a code coverage report file based on the code coverage obtained from the first compilation result directory and the second coverage data obtained from the second compilation result directory, wherein the code coverage report file comprises the first coverage information.
5. The method of claim 4, wherein the generating a code coverage report file for the online service based on the code coverage map obtained from the first compilation result catalog and the second coverage data obtained from the second compilation result catalog comprises:
and generating a code coverage report file of the online service based on the code coverage acquired from the first compiling result directory and the second coverage data acquired from the second compiling result directory according to a preset coverage type.
6. The method of any of claims 1 to 5, further comprising: and outputting the first coverage rate information of the online service by adopting a visual page.
7. The method of claim 6, further comprising:
analyzing the first coverage rate information of the source code output by the visual page, and converting the first coverage rate information into second coverage rate data in a preset storage format;
calculating to obtain second coverage rate information of a type corresponding to a preset coverage rate based on the second coverage rate data of the preset storage format;
and outputting the second coverage rate information of the corresponding type according to a preset display format.
8. The method according to claim 7, wherein the calculating, based on the second coverage data in the preset storage format, second coverage information of a type corresponding to a preset coverage includes:
and calculating at least one of the line coverage, the function coverage, the branch coverage and the path coverage of each file corresponding to the source code, and the hit times and miss times information of the corresponding line level according to a preset coverage type based on the second coverage data of the preset storage format.
9. A code coverage test system, comprising:
the system comprises a copying unit, a service architecture compatible configuration unit and a service architecture compatible configuration unit, wherein the copying unit is suitable for copying a source code to a pre-configured compiler, the kernel source code of the pre-configured compiler comprises service architecture compatible configuration information, and the configuration parameters of the compiler comprise a code coverage rate parameter;
the compiling unit is suitable for compiling the source code by adopting the pre-configured compiler to generate a binary executable file;
the online service starting and executing unit is suitable for starting and executing the online service by adopting the executable file;
and the first coverage rate information generating unit is suitable for performing compiling operation by adopting the compiler, and generating first coverage rate information of the executed codes in the online service operation process based on service architecture compatible configuration information contained in kernel source codes of the compiler and pre-configured code coverage rate parameters of the compiler.
10. A code coverage test apparatus, comprising: a memory having stored thereon computer instructions executable on the processor, wherein the processor when executing the computer instructions performs the steps of the method of any one of claims 1 to 8.
11. A computer readable storage medium having computer instructions stored thereon, wherein the computer instructions when executed perform the steps of the method of any of claims 1 to 8.
CN202010744868.8A 2020-07-29 2020-07-29 Code coverage rate testing method, system, equipment and storage medium Pending CN113297064A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010744868.8A CN113297064A (en) 2020-07-29 2020-07-29 Code coverage rate testing method, system, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010744868.8A CN113297064A (en) 2020-07-29 2020-07-29 Code coverage rate testing method, system, equipment and storage medium

Publications (1)

Publication Number Publication Date
CN113297064A true CN113297064A (en) 2021-08-24

Family

ID=77318156

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010744868.8A Pending CN113297064A (en) 2020-07-29 2020-07-29 Code coverage rate testing method, system, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN113297064A (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2023208140A1 (en) * 2022-04-27 2023-11-02 中兴通讯股份有限公司 Linux kernel optimization processing method and apparatus, and storage medium and electronic apparatus
CN116991751A (en) * 2023-09-28 2023-11-03 英诺达(成都)电子科技有限公司 Code testing method and device, electronic equipment and storage medium
CN117435440A (en) * 2023-12-20 2024-01-23 麒麟软件有限公司 Dynamic analysis method and system for program heap space

Citations (8)

* 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
CN102222041A (en) * 2011-06-15 2011-10-19 深圳市运通信息技术有限公司 Test analysis system and method based on embedded software
US20120246627A1 (en) * 2011-03-24 2012-09-27 International Business Machines Corporation Adding Instrumentation to a Body of Code to Enable Generation of Code Coverage Data
JP2013008277A (en) * 2011-06-27 2013-01-10 Toshiba Corp Coverage measuring apparatus and method and program
CN103699476A (en) * 2012-09-27 2014-04-02 腾讯科技(深圳)有限公司 Coverage rate testing method and system
CN104239219A (en) * 2014-10-21 2014-12-24 中国科学院软件研究所 Software defect positioning technology on-line evaluating and experimenting platform and method based on coverage
US20160328314A1 (en) * 2015-05-06 2016-11-10 Hcl Technologies Limited System and method for providing code coverage
CN111045927A (en) * 2019-11-07 2020-04-21 平安科技(深圳)有限公司 Performance test evaluation method and device, computer equipment and readable storage medium

Patent Citations (8)

* 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
US20120246627A1 (en) * 2011-03-24 2012-09-27 International Business Machines Corporation Adding Instrumentation to a Body of Code to Enable Generation of Code Coverage Data
CN102222041A (en) * 2011-06-15 2011-10-19 深圳市运通信息技术有限公司 Test analysis system and method based on embedded software
JP2013008277A (en) * 2011-06-27 2013-01-10 Toshiba Corp Coverage measuring apparatus and method and program
CN103699476A (en) * 2012-09-27 2014-04-02 腾讯科技(深圳)有限公司 Coverage rate testing method and system
CN104239219A (en) * 2014-10-21 2014-12-24 中国科学院软件研究所 Software defect positioning technology on-line evaluating and experimenting platform and method based on coverage
US20160328314A1 (en) * 2015-05-06 2016-11-10 Hcl Technologies Limited System and method for providing code coverage
CN111045927A (en) * 2019-11-07 2020-04-21 平安科技(深圳)有限公司 Performance test evaluation method and device, computer equipment and readable storage medium

Non-Patent Citations (4)

* Cited by examiner, † Cited by third party
Title
QIAN YANG: "A survey of coverage based testing tools", 《AST \'06: PROCEEDINGS OF THE 2006 INTERNATIONAL WORKSHOP ON AUTOMATION OF SOFTWARE TEST》, 23 May 2006 (2006-05-23), pages 99, XP058245355, DOI: 10.1145/1138929.1138949 *
YANXIANGYFG: "gcov代码覆盖率测试-原理和实践总结", pages 1 - 10, Retrieved from the Internet <URL:《https://blog.csdn.net/yanxiangyfg/article/details/80989680》> *
姜文 等: "基于持续集成的C/C++软件覆盖率测试", 《计算机技术与发展》, 31 March 2018 (2018-03-31), pages 37 - 46 *
林广栋 等: "BWDSP软件代码覆盖率统计工具实现方案", 《 电脑知识与技术》, vol. 12, no. 5, 29 February 2016 (2016-02-29), pages 66 - 70 *

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2023208140A1 (en) * 2022-04-27 2023-11-02 中兴通讯股份有限公司 Linux kernel optimization processing method and apparatus, and storage medium and electronic apparatus
CN116991751A (en) * 2023-09-28 2023-11-03 英诺达(成都)电子科技有限公司 Code testing method and device, electronic equipment and storage medium
CN116991751B (en) * 2023-09-28 2023-12-22 英诺达(成都)电子科技有限公司 Code testing method and device, electronic equipment and storage medium
CN117435440A (en) * 2023-12-20 2024-01-23 麒麟软件有限公司 Dynamic analysis method and system for program heap space
CN117435440B (en) * 2023-12-20 2024-04-05 麒麟软件有限公司 Dynamic analysis method and system for program heap space

Similar Documents

Publication Publication Date Title
US7530054B2 (en) Program analysis tool presenting object containment and temporal flow information
CN105094783B (en) method and device for testing stability of android application
EP3213217B1 (en) Historical control flow visualization in production diagnostics
Campos et al. Gzoltar: an eclipse plug-in for testing and debugging
US8627290B2 (en) Test case pattern matching
US8276126B2 (en) Determining causes of software regressions based on regression and delta information
CN113297064A (en) Code coverage rate testing method, system, equipment and storage medium
US7900198B2 (en) Method and system for parameter profile compiling
EP1179777B1 (en) Generation of runtime execution traces of applications and error detection
US20180024911A1 (en) Software code debugger for quick detection of error root causes
US7917894B2 (en) Constraining source code and objects for analysis tools
US20090199163A1 (en) Debugger assistance for locating values at runtime
Roehm et al. Monitoring user interactions for supporting failure reproduction
JP2015043198A (en) Analysis system, analysis method and analysis program
CN108595343A (en) The test method and device of application program
US20130179867A1 (en) Program Code Analysis System
Porkoláb et al. Codecompass: an open software comprehension framework for industrial usage
US20080127119A1 (en) Method and system for dynamic debugging of software
US9117020B2 (en) Determining control flow divergence due to variable value difference
US20080127061A1 (en) Method and system for editing code
CN104317580A (en) Integrated development environment for virtual test application (APP)
US20140282414A1 (en) Method and system for debugging of a program
Vierhauser et al. Evolving systems of systems: Industrial challenges and research perspectives
Linford et al. Performance analysis of openshmem applications with tau commander
CN113220586A (en) Automatic interface pressure test execution method, device and 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