Code coverage determination methods, apparatus, computer equipment and storage media

By mapping the execution information of the basic block file and source code file to the host cache during the execution of the executable file on the RAID card, and generating the execution information file using the host-side file system, the problem of the lack of file system support in RAID cards is solved, code coverage is obtained, and the security of RAID cards is improved.

CN119322747BActive Publication Date: 2025-10-31SHANDONG YUNHAI GUOCHUANG CLOUD COMPUTING EQUIP IND INNOVATION CENT CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411336478.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-09-24
Publication Date
2025-10-31
Estimated Expiration
2044-09-24

AI Technical Summary

Technical Problem

The lack of file system support in RAID cards prevents them from generating and saving coverage data files, resulting in the inability to obtain software code coverage and affecting their security.

Method used

By mapping the execution information of the basic block file and source code file to the host cache during the execution of the executable file on the RAID card, and using the host file system to generate the execution information file, the code coverage of the RAID card can be obtained.

Benefits of technology

This technology enables the acquisition of RAID card code coverage, improves the evaluation and refinement of RAID card software code, and enhances its security.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119322747B_ABST
    Figure CN119322747B_ABST
Patent Text Reader

Abstract

This invention relates to the field of software testing technology, and discloses a method, apparatus, computer device, and storage medium for determining code coverage. The method includes: acquiring multiple source code files of the firmware module of a disk array card and compiling them into an executable file; during the compilation process, instrumenting the multiple source code files to update the execution information of each source code file when the executable file is run; generating basic block files corresponding to the multiple source code files, each basic block file including pointers to the execution information of the corresponding source code file; running the executable file to cause the disk array card to map the execution information of the basic block files and source code files to the host cache; after the executable file finishes running, acquiring the execution information of each source code file and writing it to an execution information file; and analyzing the execution information file and the basic block files to obtain the code coverage of each source code file. This invention can obtain the software code coverage of a disk array card.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of software testing technology, and more specifically to a method, apparatus, computer equipment, and storage medium for determining code coverage. Background Technology

[0002] In the era of massive storage, users' demands for storage capacity and data importance are constantly increasing, and their requirements for data reliability and availability are also becoming more stringent. Redundant Arrays of Independent Disks (RAID) cards, based on disk array technology, can help solve the problems faced by users, and high-quality software code is the key to ensuring the high reliability and stability of RAID cards.

[0003] In related technologies, the quality of software code can be determined by its code coverage; higher code coverage generally indicates higher software code quality. Coverage data is collected during program runtime and output to a specific file system for processing by coverage analysis tools to obtain the software code coverage.

[0004] However, for RAID cards, the lack of file system support prevents them from generating and saving coverage data files, obtaining coverage of their software code, and resolving potential problems in the software code, resulting in lower security for RAID cards. Summary of the Invention

[0005] In view of this, the present invention provides a code coverage determination method to solve the problem in related technologies where the lack of file system support in RAID cards leads to the inability to generate and save coverage data files, the inability to obtain the coverage of their software code, the inability to solve potential problems in the software code, and the low security of RAID.

[0006] In a first aspect, the present invention provides a code coverage determination method, applied to a server host, the method comprising:

[0007] Obtain multiple source code files of the firmware module of the disk array card;

[0008] Multiple source code files are compiled into an executable file. During the compilation process, the multiple source code files are instrumented to update the execution information of each source code file when the executable file is run. Basic block files corresponding to the multiple source code files are generated, wherein the basic block files include pointers to the execution information of the corresponding source code files.

[0009] The executable file is run so that the disk array card maps the execution information of the base block file and the source code file to the host cache.

[0010] After the executable file finishes running, the execution information of each source code file in the host cache is obtained, and the execution information is written into the corresponding execution information file.

[0011] The execution information file and the basic block file are analyzed to obtain the code coverage of each source code file.

[0012] The code coverage determination method provided in this embodiment maps the execution information of the basic block file and source code file to the host cache when the executable file is running. After the executable file finishes running, the execution information of each source code file in the host cache is obtained and written to the corresponding execution information file. The execution information file and the basic block file are analyzed to obtain the code coverage of each source code file. By mapping the execution information of the basic block file and the source code file to the host cache and using the host file system to generate the execution information file corresponding to the execution information, the code coverage of each source code file of the disk array card can be obtained. This realizes the acquisition of the code coverage of the RAID card, thereby enabling the evaluation and improvement of the software code of the RAID card and improving the security of the RAID card.

[0013] In one optional implementation, the instrumentation process performed on the multiple source code files during the compilation of the multiple source code files into an executable file includes:

[0014] During the process of compiling multiple source code files into an executable file, update coverage code is appended after each line of code in the source code file. The update coverage code is a stub.

[0015] A static array is inserted into the source code file. The size of the static array is the number of stubs in the source code file, and the value of the static array corresponds to the number of times each stub is executed.

[0016] The code coverage determination method provided in this embodiment appends update coverage code after each line of code in the source code file and inserts a static array into the source code file to obtain the execution information, i.e., coverage information, of each source code file when the executable file is run, thus ensuring the accuracy of the code coverage of each source code file.

[0017] In one optional implementation, generating the basic block files corresponding to the plurality of source code files includes:

[0018] For any source code file, the basic block file corresponding to the source code file is set to include a pointer to the static array corresponding to the source code file, the number of stubs included in the source code file, and the name of the source code file, wherein the execution information of the source code file includes the static array corresponding to the source code file.

[0019] The code coverage determination method provided in this embodiment generates a corresponding basic block file for each source code file, which can obtain the correspondence between the source code files and the execution information of the source code files, making the code coverage statistics clearer and more independent, and improving the efficiency of code coverage acquisition.

[0020] In one optional implementation, running the executable file to cause the disk array card to map the execution information of the base block file and the source code file to the host cache includes:

[0021] During the execution of the executable file, the basic block files corresponding to multiple source code files are linked to form a basic block file linked list, so that the disk array card maps the basic block file linked list and the execution information of the source code files to the host cache area.

[0022] The code coverage determination method provided in this embodiment links the basic block files corresponding to multiple source code files to form a basic block file linked list. This allows the disk array card to map the execution information of the basic block file linked list and the source code files to the host cache. The linked list structure provides an efficient and flexible access method, improving the efficiency of obtaining the execution information of the basic block files and source code files, and thus improving the efficiency of obtaining the code coverage of the RAID card's software code.

[0023] Secondly, the present invention provides a code coverage determination method applied to a disk array card, the method comprising:

[0024] When the executable file is run on the server host, the execution information of the basic block file and the source code file is mapped to the host cache. This allows the server host to obtain the execution information of each source code file in the host cache after the executable file finishes running, and write the execution information into the corresponding execution information file. The execution information file and the basic block file are then analyzed to obtain the code coverage of each source code file.

[0025] The server host obtains multiple source code files of the firmware module of the disk array card; compiles the multiple source code files into an executable file, wherein, during the compilation of the multiple source code files into an executable file, the multiple source code files are instrumented so that the execution information of each source code file is updated when the executable file is run; and generates basic block files corresponding to the multiple source code files, wherein the basic block files include pointers to the execution information of the corresponding source code files.

[0026] The code coverage determination method provided in this embodiment maps the execution information of basic block files and source code files to the host cache when the executable file is run on the server host. This allows the server host to obtain the execution information of each source code file in the host cache after the executable file finishes running, write the execution information to the corresponding execution information file, and analyze the execution information file and basic block files to obtain the code coverage of each source code file. By mapping the execution information of basic block files and source code files to the host cache and using the host file system to generate the execution information file corresponding to the execution information, the code coverage of each source code file of the disk array card can be obtained. This enables the acquisition of the code coverage of the RAID card, thereby enabling the evaluation and improvement of the RAID card's software code and improving the security of the RAID card.

[0027] In one optional implementation, mapping the execution information of the base block file and source code file to the host cache includes:

[0028] Obtain the address of the host cache sent by the server host, wherein the server host requests a host cache in memory during the disk array card initialization process and sends the address of the host cache to the disk array card;

[0029] Get the number of basic block files in the basic block file linked list;

[0030] For any given basic block file, obtain the sort order of that basic block file in the linked list of basic block files;

[0031] Based on the number of basic block files in the basic block file linked list, the order of the basic block files in the basic block file linked list, and the address of the host cache, a corresponding address to be written is allocated to the basic block file;

[0032] Based on the address to be written, the basic block file is mapped to the host cache area;

[0033] Based on the linking relationship of the basic block files in the basic block file linked list, the linking relationship of the basic block files in the host cache is set;

[0034] Obtain information about the static array of the source code file corresponding to the basic block file;

[0035] Based on the address to be written, the information of the static array of the source code file corresponding to the basic block file is mapped to the host cache.

[0036] Based on the pointer relationship between the basic block file and the static array of the source code file corresponding to the basic block file, the corresponding pointer relationship is set in the host cache.

[0037] The code coverage determination method provided in this embodiment maps the execution information of basic block files and source code files to a host cache area allocated from memory, and uses the host file system to generate the execution file corresponding to the execution information, thereby obtaining the code coverage of each source code file of the disk array card. This reduces the multiple copies of execution information during transmission, improves data transmission speed, and thus improves the efficiency of code coverage acquisition.

[0038] Thirdly, the present invention provides a code coverage determination device, applied to a server host, the device comprising:

[0039] The first acquisition module is used to acquire multiple source code files of the firmware module of the disk array card;

[0040] A compilation module is used to compile multiple source code files into an executable file. During the compilation process, the multiple source code files are instrumented to update the execution information of each source code file when the executable file is run. A basic block file corresponding to the multiple source code files is generated, wherein the basic block file includes pointers to the execution information of the corresponding source code file.

[0041] The execution module is used to run the executable file so that the disk array card maps the execution information of the basic block file and the source code file to the host cache.

[0042] The second acquisition module is used to acquire the execution information of each source code file in the host cache after the executable file finishes running, and write the execution information into the corresponding execution information file;

[0043] The third acquisition module is used to analyze the execution information file and the basic block file to obtain the code coverage of each source code file.

[0044] Fourthly, the present invention provides a code coverage determination device applied to a disk array card, the device comprising:

[0045] The mapping module is used to map the execution information of the basic block files and source code files to the host cache when the executable file is running on the server host. This allows the server host to obtain the execution information of each source code file in the host cache after the executable file finishes running, and write the execution information into the corresponding execution information file. The execution information file and the basic block files are then analyzed to obtain the code coverage of each source code file.

[0046] The server host obtains multiple source code files of the firmware module of the disk array card; compiles the multiple source code files into an executable file, wherein, during the compilation of the multiple source code files into an executable file, the multiple source code files are instrumented so that the execution information of each source code file is updated when the executable file is run; and generates basic block files corresponding to the multiple source code files, wherein the basic block files include pointers to the execution information of the corresponding source code files.

[0047] Fifthly, the present invention provides a computer device, comprising: a memory and a processor, the memory and the processor being communicatively connected to each other, the memory storing computer instructions, and the processor executing the computer instructions to perform the code coverage determination method of the first aspect or any corresponding embodiment thereof, or the code coverage determination method of the second aspect or any corresponding embodiment thereof.

[0048] In a sixth aspect, the present invention provides a computer-readable storage medium storing computer instructions for causing a computer to perform the code coverage determination method of the first aspect or any corresponding embodiment thereof, or the code coverage determination method of the second aspect or any corresponding embodiment thereof.

[0049] In a seventh aspect, the present invention provides a computer program product, including computer instructions, which are used to cause a computer to execute the code coverage determination method of the first aspect or any corresponding embodiment thereof, or the code coverage determination method of the second aspect or any corresponding embodiment thereof. Attached Figure Description

[0050] To more clearly illustrate the technical solutions in the specific embodiments or related technologies of the present invention, the drawings used in the description of the specific embodiments or related technologies will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.

[0051] Figure 1This is a flowchart illustrating the code coverage determination method according to an embodiment of the present invention;

[0052] Figure 2 This is a structural diagram for determining code coverage when there is file system support in the relevant technologies;

[0053] Figure 3 This is a flowchart illustrating the process of determining code coverage when file system support is available in the relevant technologies.

[0054] Figure 4 This is a flowchart illustrating another code coverage determination method according to an embodiment of the present invention;

[0055] Figure 5 This is a structural block diagram of determining code coverage according to an embodiment of the present invention;

[0056] Figure 6 This is a schematic diagram illustrating the mapping of the basic block file linked list and the execution information of the source code file to the host cache area according to an embodiment of the present invention;

[0057] Figure 7 This is a structural block diagram of a code coverage determination device according to an embodiment of the present invention;

[0058] Figure 8 This is a schematic diagram of the hardware structure of a computer device according to an embodiment of the present invention. Detailed Implementation

[0059] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0060] In the era of massive storage, users' demands for storage capacity and data importance are constantly increasing, and their requirements for data reliability and availability are also becoming more stringent. RAID cards based on disk array technology can help solve the problems faced by users.

[0061] To ensure user data reliability, RAID cards require high reliability and stability. To guarantee long-term stable operation, the software code of the RAID card must be of high quality. Code coverage is a key software quality metric, measuring the proportion of executed source code to the total source code during software testing. It indirectly measures software quality by calculating the percentage of executed lines (or other code elements) out of the total number of lines (or other code elements) during testing. Higher code coverage indicates more comprehensive testing, higher code quality, and thus ensures software quality and reliability. This helps ensure the RAID card software functions correctly in various scenarios, reducing potential software defects and errors.

[0062] It should be noted that code coverage of the software code can also be used to predict and diagnose potential problems in the software related to the RAID card device. By timely detection and resolution of these problems, the possibility of RAID card device failure in actual use can be reduced, and the stability and reliability of the system can be improved.

[0063] It is evident that code coverage is of significant reference value for the software development and testing of RAID card devices. By focusing on code coverage, the quality and performance of RAID card device software can be improved, thereby enhancing the stability and reliability of the entire RAID system.

[0064] In related technologies, coverage data is collected during program runtime and output to a specific file system for coverage analysis tools to process, thereby obtaining the coverage of the software code.

[0065] However, due to the lack of file system support, RAID cards cannot generate and save coverage data files. Consequently, they cannot analyze the coverage of software code using these data files, and therefore cannot resolve potential problems in the software code, resulting in lower security for RAID cards.

[0066] This invention provides a method for determining code coverage. When an executable file is running, the disk array card maps the execution information of the basic block file and the source code file to the host cache. After the executable file finishes running, the execution information of each source code file in the host cache is obtained and written to the corresponding execution information file. The execution information file and the basic block file are analyzed to obtain the code coverage of each source code file. By mapping the execution information of the basic block file and the source code file to the host cache, and using the host-side file system to generate the execution information file corresponding to the execution information, the code coverage of each source code file of the disk array card can be obtained, thus achieving the acquisition of the RAID card's code coverage. This enables the evaluation and improvement of the RAID card's software code, thereby enhancing the RAID card's security.

[0067] According to an embodiment of the present invention, a code coverage determination method embodiment is provided. It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. Furthermore, although a logical order is shown in the flowchart, in some cases, the steps shown or described may be executed in a different order than that shown here.

[0068] This embodiment provides a code coverage determination method that can be used on the server host. Figure 1 This is a flowchart of a code coverage determination method according to an embodiment of the present invention, such as... Figure 1 As shown, the process includes the following steps:

[0069] Step S101: Obtain multiple source code files of the firmware module of the disk array card.

[0070] The disk array card is a RAID card. The server host obtains multiple source code files corresponding to the firmware of the RAID card; the firmware module is the firmware within the RAID card.

[0071] Step S102: Compile multiple source code files into an executable file. During the compilation process, instrumentation is performed on the multiple source code files to update the execution information of each source code file when the executable file is run. Generate basic block files corresponding to the multiple source code files. The basic block files include pointers to the execution information of the corresponding source code files.

[0072] This process utilizes the GNU Compiler Collection (GCC) to compile multiple source code files into an executable file. Basic block files facilitate the accurate association of execution information with the source code files.

[0073] It's worth noting that when compiling multiple source code files, use GCC's `-fprofile-arcs` and `-ftest-coverage` options to enable coverage testing. These two options tell GCC to insert additional code and generate necessary files during the compilation process to support coverage analysis.

[0074] It should be noted that during the process of compiling multiple source code files into an executable file, GCC generates a file named *.gcno (corresponding to the source code file name), which is the basic block file. This basic block file includes the reconstructed basic block diagram and the source code line number information of the corresponding basic blocks, which forms the basis for subsequent analysis.

[0075] In this context, the reconstructed basic block diagram is called a basic block. A basic block (BB) is defined as follows: if the first statement of a program is executed once, every statement in that program must be executed once, forming a basic block. All statements within a BB must be executed the same number of times. A BB typically consists of multiple sequentially executed statements followed by a jump statement. Therefore, the last statement of a BB is usually a jump statement, with the jump destination being the first statement of another BB. If the jump is conditional, a branch is created, and the BB will have two BBs as destinations.

[0076] It should be noted that this embodiment uses one source code file corresponding to one BB as an example for illustration. The data structure of the basic block is as follows:

[0077] struct bb

[0078] {

[0079] long zero_word; / / Whether it has been inserted into the linked list

[0080] const char* file_name; / / The filename of the current test file

[0081] long*count; / / Pointer to BX2

[0082] long ncounts; / / Number of stakers

[0083] struct bb*next; / / BX2 information for the next file

[0084] }

[0085] BX2 is a static array.

[0086] Step S103: Run the executable file so that the disk array card maps the execution information of the basic block file and the source code file to the host cache.

[0087] Figure 2 This is a structural diagram for determining code coverage when there is file system support in the relevant technologies. Figure 3 This is a flowchart for determining code coverage when file system support is available in the relevant technologies. Combined with... Figure 2 and Figure 3 When file system support is available in the relevant technologies, describe the process for determining code coverage, such as... Figure 2 and Figure 3 As shown, related technologies utilize GCC and gcov to determine code coverage. gcov is a tool for C / C++ code coverage testing. It is tightly integrated with the GCC compiler and can collect the execution status of each line of code during program execution and generate a code coverage report.

[0088] Specifically, obtain the source code file (APP SRC) of the application under test. This source code file is either a *.c or *.cpp file. Compile the source code file using GCC, enabling coverage testing by adding the `-fprofile-arcs` and `-ftest-coverage` parameters. During compilation, GCC appends code that updates coverage statistics to the code generated after each line of executable statements in the source code file; this process is called instrumentation. This additional code updates the coverage data during program execution. During compilation, GCC generates a file named *.gcno (corresponding to the source code file name), which is the data file *.gcdo. This file is consistent with the basic block file described above; see the description above for details, which will not be repeated here.

[0089] During instrumentation, GCC inserts a static array BX2 at the end of the source file. The size of this array is the number of stubs in the source file. BX2+0 represents the position of the 0th stub, BX2+n represents the position of the nth stub, and the value of the array is the execution count of the stub, which is the number of times the code line containing that stub has been executed.

[0090] During instrumentation, GCC inserts the assembly statement inc$(BX2+n) at each stub to update the execution count of each stub during code execution.

[0091] To facilitate subsequent statistics, GCC also links the BX2 arrays of each source file into a linked list. This linked list structure is generated before testing the main function. The function that sets the type constructor before calling main is used to link the BX2 arrays of each source file into a linked list. This function also calls the exit function to calculate the number of executions and generate the .gcda file when the program exits.

[0092] After compilation, an executable file (*.elf) is obtained. Running the executable file, that is, running the compiled program, will cause the instrumentation code to record the execution of each line of code and each branch in the source code file during program execution, and store the data in memory.

[0093] When the program finishes execution (e.g., by calling the exit function), the gcov initialization function triggers the cleanup process. Thanks to the support of the file system, the coverage data stored in memory can be directly written to a file named *.gcda, resulting in the data file *.gcda, which contains the actual coverage data at the time of program execution.

[0094] The `gcov` command analyzes data files *.gcdo and *.gcda to generate a detailed code coverage report. The basic format of the `gcov` command is `gcov [source file]`. After analyzing the *.gcdo and *.gcda data files, this command generates a file named *.c.gcov (corresponding to the source file name), which contains information such as the number of times each line of code was executed and the code that was not executed. It should be noted that `gcov` uses basic block counts (BBs) and jump ARC counts, combined with the program flowchart, to achieve code coverage statistics.

[0095] By interpreting this code coverage report, you can obtain the code coverage, specifically:

[0096] This code coverage report includes a coverage summary, detailed coverage data, and coverage for functions and branches. The coverage summary displays the overall line coverage, branch coverage, and function coverage of the source files. Detailed coverage data provides the execution count for each line of code in each source file; unexecuted code is marked in a specific way. Function and branch coverage displays the execution count and coverage of each function, as well as the execution status of each branch.

[0097] Since RAID cards do not have a file system, they cannot save coverage information data by writing files. Therefore, in this embodiment, to solve the problem that RAID cards do not support a file system, when the executable file is running, the disk array card is used to map the execution information of the basic block file and the source code file to the host cache, so as to use the host file system to generate the execution information file of the RAID card's source code file.

[0098] Understandably, during the execution of the executable file, the disk array card synchronously maps the updates to the execution information of the basic block file and source code file to the host cache.

[0099] Step S104: After the executable file finishes running, obtain the execution information of each source code file in the host cache and write the execution information into the corresponding execution information file.

[0100] After the executable file finishes running, the server retrieves the execution information of each source code file from the host cache and uses the host file system to write the execution information into the corresponding execution information file, that is, into the corresponding .gcda file.

[0101] Step S105: Analyze the execution information file and the basic block file to obtain the code coverage of each source code file.

[0102] After obtaining the execution information file, the server host uses the gcov tool to analyze the execution file and basic block files to obtain the code coverage of each source code file, i.e., to obtain a code coverage report for each source code file. It should be noted that this code coverage report is consistent with code coverage reports in related technologies, and will not be elaborated upon here.

[0103] Understandably, after obtaining the code coverage report, code quality analysis can be performed based on it.

[0104] The code coverage determination method provided in this embodiment maps the execution information of the basic block file and source code file to the host cache when the executable file is running. After the executable file finishes running, the execution information of each source code file in the host cache is obtained and written to the corresponding execution information file. The execution information file and the basic block file are analyzed to obtain the code coverage of each source code file. By mapping the execution information of the basic block file and the source code file to the host cache and using the host file system to generate the execution information file corresponding to the execution information, the code coverage of each source code file of the disk array card can be obtained. This realizes the acquisition of the code coverage of the RAID card, thereby enabling the evaluation and improvement of the software code of the RAID card and improving the security of the RAID card.

[0105] This embodiment provides a code coverage determination method that can be used on the server host. Figure 4 This is a flowchart of a code coverage determination method according to an embodiment of the present invention, such as... Figure 4 As shown, the process includes the following steps:

[0106] Step S401: Obtain multiple source code files for the firmware module of the disk array card. For details, please refer to [link to relevant documentation]. Figure 1 Step S101 of the illustrated embodiment will not be described again here.

[0107] Step S402: Compile multiple source code files into an executable file. During the compilation process, instrumentation is performed on the multiple source code files to update the execution information of each source code file when the executable file is run. Generate basic block files corresponding to the multiple source code files. The basic block files include pointers to the execution information of the corresponding source code files.

[0108] Specifically, step S402 includes:

[0109] Step S4021: During the process of compiling multiple source code files into an executable file, update coverage code is appended after each line of code in the source code file. The update coverage code is a stub.

[0110] Figure 5 This is a structural block diagram of determining code coverage according to an embodiment of the present invention, such as... Figure 5 As shown, the server host compiles multiple source code files (FW SRC) of the firmware module of the RAID card into an executable file FW using a cross-compilation chain (ARM-GCC), and then runs it in the RAID card.

[0111] In the process of compiling multiple source code files into an executable file, instrumentation is performed on these files to update and retrieve execution information for each file. This instrumentation involves appending coverage update code to each line of code in the source code files. This coverage update code updates the coverage data (execution information) during program execution. This coverage update code is called a stub.

[0112] Step S4022: Insert a static array into the source code file. The size of the static array is the number of stubs in the source code file, and the value of the static array is the number of times each stub is executed.

[0113] The instrumentation process also includes inserting a static array, BX2, into the source code file, which is the same as the static array in related technologies and will not be described in detail here.

[0114] Step S403: Run the executable file to allow the disk array card to map the execution information of the basic block files and source code files to the host cache. See details below. Figure 1 Step S103 of the illustrated embodiment will not be described again here.

[0115] Step S404: After the executable file finishes running, obtain the execution information of each source code file in the host cache and write the execution information to the corresponding execution information file. For details, please refer to [link to relevant documentation]. Figure 1 Step S104 of the illustrated embodiment will not be described again here.

[0116] Step S405 involves analyzing the execution information file and basic block files to obtain the code coverage of each source code file. For details, please refer to [link to relevant documentation]. Figure 1 Step S105 of the illustrated embodiment will not be described again here.

[0117] The code coverage determination method provided in this embodiment appends update coverage code after each line of code in the source code file and inserts a static array into the source code file to obtain the execution information, i.e., coverage information, of each source code file when the executable file is run, thus ensuring the accuracy of the code coverage of each source code file.

[0118] In some optional implementations, step S402 above includes:

[0119] Step a1: For any source code file, set the basic block file corresponding to the source code file to include a pointer to the static array corresponding to the source code file, the number of stubs included in the source code file, and the name of the source code file. The execution information of the source code file includes the static array corresponding to the source code file.

[0120] The static array corresponding to the source code file contains the execution count of each stub. In other words, the execution information of the source code file includes the execution count of each line of code in the source code file.

[0121] The code coverage determination method provided in this embodiment generates a corresponding basic block file for each source code file, which can obtain the correspondence between the source code files and the execution information of the source code files, making the code coverage statistics clearer and more independent, and improving the efficiency of code coverage acquisition.

[0122] In some optional implementations, step S403 above includes:

[0123] Step b1: During the execution of the executable file, the basic block files corresponding to multiple source code files are linked to form a basic block file linked list, so that the disk array card can map the basic block file linked list and the execution information of the source code files to the host cache area.

[0124] Figure 6 This is a schematic diagram illustrating the mapping of execution information from basic block file linked lists and source code files to the host cache according to an embodiment of the present invention. Figure 6As shown, during the execution of the executable file, the `gcov_init` function is called to initialize the statistics area. This means that `gcov_init` initializes the basic block files for each source code file. Simultaneously, the `gcov_info` structure of each source code file is organized, linking the basic block files corresponding to multiple source code files to form a basic block file linked list. This allows the disk array card to map the basic block file linked list and the execution information of the source code files to the host cache. The basic block file linked list and the execution information of the source code files exist in the host cache in the form of `gcda pck`.

[0125] Understandably, during the execution of the executable file, the instrumented code records the execution status of each line of code and each branch, generating execution information for each source code file. The disk array card maps this execution information to the host cache.

[0126] When the code finishes execution and exits normally, the gcov_exit function is called, and then the gcov_flush function is called to write the statistics of the host cache to the corresponding *.gcda file.

[0127] The code coverage determination method provided in this embodiment links the basic block files corresponding to multiple source code files to form a basic block file linked list. This allows the disk array card to map the execution information of the basic block file linked list and the source code files to the host cache. The linked list structure provides an efficient and flexible access method, improving the efficiency of obtaining the execution information of the basic block files and source code files, and thus improving the efficiency of obtaining the code coverage of the RAID card's software code.

[0128] In some alternative implementations, the code coverage determination method further includes:

[0129] Monitor the connection status between the server host and the disk array card.

[0130] Obtaining multiple source code files of the firmware module of the disk array card includes: obtaining multiple source code files of the firmware module of the disk array card under normal connection status.

[0131] If the connection status is abnormal, the connection error information will be recorded in the log file and an alarm will be triggered so that users can analyze, troubleshoot and resolve connection error issues based on the log file.

[0132] Understandably, alerts can be displayed on the user interface to show connection error information, allowing users to promptly identify and resolve the issue.

[0133] Running the executable file includes: if multiple source code files are successfully compiled into an executable file, running the executable file; if multiple source code files are not successfully compiled into an executable file, logging compilation exception information to a log file and issuing an alert, so that users can analyze, troubleshoot, and resolve compilation exception issues based on the log file.

[0134] The code coverage determination method provided in this embodiment monitors the connection status between the server host and the disk array card to ensure that multiple source code files are obtained under normal connection conditions, avoiding the inefficiency and low accuracy of code coverage determination caused by connection anomalies. By successfully compiling multiple source code files into executable files and running the executable files, the accuracy of the determined code coverage is ensured. Detailed information on connection and compilation anomalies is recorded in log files, allowing users to analyze, troubleshoot, and resolve problems based on the log files, improving the efficiency and accuracy of problem solving, and thus improving the efficiency of code coverage acquisition.

[0135] This embodiment provides a code coverage determination method, which can be used for disk array cards. The code coverage determination method includes the following steps:

[0136] When the executable file is run on the server host, the execution information of the basic block file and the source code file is mapped to the host cache. This allows the server host to obtain the execution information of each source code file in the host cache after the executable file finishes running, and write the execution information into the corresponding execution information file. The execution information file and the basic block file are analyzed to obtain the code coverage of each source code file.

[0137] The process involves the server host acquiring multiple source code files from the firmware module of the disk array card; compiling these source code files into an executable file, wherein instrumentation is performed on the source code files during the compilation process to update the execution information of each source code file when the executable file is run; and generating basic block files corresponding to the multiple source code files, wherein the basic block files include pointers to the execution information of the corresponding source code files.

[0138] The further description of this step is the same as the specific description of the code coverage determination method applied to the server host side described above, and will not be repeated here.

[0139] The code coverage determination method provided in this embodiment maps the execution information of basic block files and source code files to the host cache when the executable file is run on the server host. This allows the server host to obtain the execution information of each source code file in the host cache after the executable file finishes running, write the execution information to the corresponding execution information file, and analyze the execution information file and basic block files to obtain the code coverage of each source code file. By mapping the execution information of basic block files and source code files to the host cache and using the host file system to generate the execution information file corresponding to the execution information, the code coverage of each source code file of the disk array card can be obtained. This enables the acquisition of the code coverage of the RAID card, thereby enabling the evaluation and improvement of the RAID card's software code and improving the security of the RAID card.

[0140] In some alternative implementations, execution information for base block files and source code files is mapped to the host cache, including:

[0141] Step c1: Obtain the address of the host cache sent by the server host. During the disk array card initialization process, the server host requests a host cache in memory and sends the address of the host cache to the disk array card.

[0142] The memory is Double Data Rate (DDR). The host cache is the Host Memory Buffer (HMB). HMB is a fundamental feature of Non-Volatile Memory Express (NVMe), a storage protocol specifically designed for solid-state drives (SSDs). It allows NVMe devices to improve performance by sharing system memory (host memory) as a cache, even without an independent cache. NVMe fully utilizes the low latency and high concurrency characteristics of SSDs and is an interface standard for the PCIe bus.

[0143] After the server host requests a host cache in memory, it issues an NVMe set Feature command to inform the RAID card of the address of the HMB requested by the host. As a PCIe device, the RAID card can transfer the internal data of the RAID card to the host-side HMB through the address of the HMB via Direct Memory Access (DMA).

[0144] Step c2: Obtain the number of basic block files in the basic block file linked list.

[0145] After obtaining the address of the requested host cache area, the number of basic block files in the basic block file linked list is obtained in order to implement the mapping of basic block files.

[0146] Step c3: For any given basic block file, obtain the sort order of that basic block file in the basic block file linked list.

[0147] To implement the mapping of basic block files, it is also necessary to obtain the order of each basic block file in the basic block file linked list.

[0148] Step c4: Based on the number of basic block files in the basic block file linked list, the order of the basic block files in the basic block file linked list, and the address of the host cache, allocate the corresponding address to be written to the basic block file.

[0149] Specifically, after obtaining the number of basic block files in the basic block file linked list and their order within the list, the system allocates corresponding write addresses to each basic block file based on these factors and the host cache address. In detail, the host cache address is divided into multiple addresses according to the number of basic block files in the linked list, and these addresses are then allocated to the corresponding basic block files according to their order within the linked list; that is, the system assigns write addresses to each basic block file.

[0150] Step c5: Based on the address to be written, map the basic block file to the host cache.

[0151] Specifically, after allocating the corresponding write address to the basic block file, for any basic block file, it is mapped to the host cache according to the write address it was allocated.

[0152] Step c6: Based on the linking relationship of the basic block files in the basic block file linked list, set the linking relationship of the basic block files in the host cache.

[0153] After mapping the basic block files to the host cache, the linking relationships of the basic block files in the host cache are set. Specifically, the linking relationships between basic block files in the host cache are set to be consistent with the linking relationships of the basic block files in the basic block file linked list.

[0154] Step c7: Obtain information about the static array of the source code file corresponding to the basic block file.

[0155] The execution information of the source code file includes information about the static array corresponding to the source code file. To map the execution information of the source code to the host cache, for any basic block file, the information about the static array of the source code file corresponding to that basic block file is obtained.

[0156] Step c8: Based on the address to be written, map the information of the static array of the source code file corresponding to the basic block file to the host cache.

[0157] Based on the address to be written to the basic block file, the information of the static array of the source code file corresponding to the basic block file is mapped to the host cache.

[0158] Step c9: Based on the pointer relationship between the basic block file and the static array of the source code file corresponding to the basic block file, set the corresponding pointer relationship in the host cache.

[0159] To map the execution information of the source code to the host cache, after mapping the static array information of the source code file corresponding to the basic block file to the host cache, it is also necessary to set the corresponding pointer relationship in the host cache based on the pointer relationship between the basic block file and the static array information of the source code file corresponding to the basic block file in the host cache. Specifically, the pointer relationship between the basic block file and the static array information of the source code file corresponding to the basic block file in the host cache will be set to be consistent with the pointer relationship between the basic block file and the static array information of the source code file corresponding to the basic block file in the disk array card.

[0160] The code coverage determination method provided in this embodiment directly transmits the execution information generated during the execution of the executable file to the host side by writing to the HMB memory address, and uses the host-side file system to generate the executable file corresponding to the execution information, thereby obtaining the code coverage of each source code file of the disk array card, reducing the use of RAID card memory resources.

[0161] By employing DMA, the number of copies of execution information during transmission is reduced, improving data transmission speed and efficiency, enhancing the performance of RAID card execution information export, and thus improving the efficiency of code coverage acquisition.

[0162] This embodiment also provides a code coverage determination device for implementing the above embodiments and preferred embodiments; details already described will not be repeated. As used below, the term "module" can be a combination of software and / or hardware that implements a predetermined function. Although the device described in the following embodiments is preferably implemented in software, hardware implementation, or a combination of software and hardware, is also possible and contemplated.

[0163] This embodiment provides a code coverage determination device, such as... Figure 7 As shown, it is applied to the server host side and includes:

[0164] The first acquisition module 701 is used to acquire multiple source code files of the firmware module of the disk array card.

[0165] The compilation module 702 is used to compile multiple source code files into an executable file. During the compilation process, the multiple source code files are instrumented to update the execution information of each source code file when the executable file is run. The module generates basic block files corresponding to the multiple source code files, wherein the basic block files include pointers to the execution information of the corresponding source code files.

[0166] The execution module 703 is used to run executable files so that the disk array card maps the execution information of the basic block files and source code files to the host cache.

[0167] The second acquisition module 704 is used to acquire the execution information of each source code file in the host cache after the executable file finishes running, and write the execution information into the corresponding execution information file.

[0168] The third acquisition module 705 is used to analyze the execution information file and the basic block file to obtain the code coverage of each source code file.

[0169] In some alternative implementations, the compilation module 702 includes:

[0170] The append unit is used to append update coverage code after each line of code in the source code file during the compilation of multiple source code files into an executable file. The update coverage code is a stub.

[0171] The insertion unit is used to insert a static array into the source code file. The size of the static array is the number of stubs in the source code file, and the value of the static array is the number of times each stub is executed.

[0172] In some alternative implementations, the compilation module 702 includes:

[0173] The first setting unit is used to set the basic block file corresponding to any source code file, including a pointer to the static array corresponding to the source code file, the number of stubs in the source code file, and the name of the source code file. The execution information of the source code file includes the static array corresponding to the source code file.

[0174] In some alternative implementations, the execution module 703 includes:

[0175] The linking unit is used to link the basic block files corresponding to multiple source code files during the execution of the executable file, forming a basic block file linked list, so that the disk array card can map the basic block file linked list and the execution information of the source code files to the host cache.

[0176] Further functional descriptions of the above modules and units are the same as those in the corresponding embodiments described above, and will not be repeated here.

[0177] This embodiment also provides a code coverage determination device, applied to a disk array card, the code coverage determination device comprising:

[0178] The mapping module is used to map the execution information of the basic block files and source code files to the host cache when the executable file is run on the server host. This allows the server host to obtain the execution information of each source code file in the host cache after the executable file finishes running, and write the execution information to the corresponding execution information file. The execution information file and the basic block files are analyzed to obtain the code coverage of each source code file.

[0179] The process involves the server host acquiring multiple source code files from the firmware module of the disk array card; compiling these source code files into an executable file, wherein instrumentation is performed on the source code files during the compilation process to update the execution information of each source code file when the executable file is run; and generating basic block files corresponding to the multiple source code files, wherein the basic block files include pointers to the execution information of the corresponding source code files.

[0180] In some alternative implementations, the mapping module includes:

[0181] The first acquisition unit is used to acquire the address of the host cache sent by the server host. During the disk array card initialization process, the server host requests a host cache in memory and sends the address of the host cache to the disk array card.

[0182] The second acquisition unit is used to acquire the number of basic block files in the basic block file linked list.

[0183] The third acquisition unit is used to acquire the sorting order of any basic block file in the basic block file linked list.

[0184] The allocation unit is used to allocate a corresponding write address to a basic block file based on the number of basic block files in the basic block file linked list, the order of the basic block files in the basic block file linked list, and the address of the host cache.

[0185] The first mapping unit is used to map the basic block file to the host cache based on the address to be written.

[0186] The second setting unit is used to set the linking relationship of basic block files in the host cache based on the linking relationship of basic block files in the basic block file linked list.

[0187] The fourth acquisition unit is used to acquire information about the static array of the source code file corresponding to the basic block file.

[0188] The second mapping unit is used to map the information of the static array of the source code file corresponding to the basic block file to the host cache based on the address to be written.

[0189] The third setting unit is used to set the corresponding pointer relationship in the host cache based on the pointer relationship between the basic block file and the static array of the source code file corresponding to the basic block file.

[0190] Further functional descriptions of the above modules and units are the same as those in the corresponding embodiments described above, and will not be repeated here.

[0191] In this embodiment, the code coverage determination device is presented in the form of a functional unit. Here, a unit refers to an ASIC (Application Specific Integrated Circuit) circuit, a processor and memory that execute one or more software or fixed programs, and / or other devices that can provide the above functions.

[0192] This invention also provides a computer device having the above-described code coverage determination apparatus.

[0193] Please see Figure 8 , Figure 8 This is a schematic diagram of the structure of a computer device provided in an optional embodiment of the present invention, such as... Figure 8 As shown, the computer device includes one or more processors 801, memory 802, and interfaces for connecting the components, including high-speed interfaces and low-speed interfaces. The components communicate with each other via different buses and can be mounted on a common motherboard or otherwise installed as needed. The processors can process instructions executed within the computer device, including instructions stored in or on memory to display graphical information of a GUI on external input / output devices (such as display devices coupled to the interfaces). In some alternative implementations, multiple processors and / or multiple buses can be used with multiple memories and multiple memory modules, if desired. Similarly, multiple computer devices can be connected, each providing some of the necessary operations (e.g., as a server array, a group of blade servers, or a multiprocessor system). Figure 8 Take the 801 processor as an example.

[0194] Processor 801 may be a central processing unit, a network processor, or a combination thereof. Processor 801 may further include a hardware chip. The hardware chip may be an application-specific integrated circuit (ASIC), a programmable logic device (PLD), or a combination thereof. The programmable logic device may be a complex programmable logic device (CAMP), a field-programmable gate array (FPGA), a general-purpose array logic (GDA), or any combination thereof.

[0195] The memory 802 stores instructions executable by at least one processor 801 to cause at least one processor 801 to perform the method shown in the above embodiments.

[0196] The memory 802 may include a program storage area and a data storage area. The program storage area may store the operating system and applications required for at least one function; the data storage area may store data created based on the use of the computer device. Furthermore, the memory 802 may include high-speed random access memory and may also include non-transitory memory, such as at least one disk storage device, flash memory device, or other non-transitory solid-state storage device. In some alternative embodiments, the memory 802 may optionally include memory remotely located relative to the processor 801, and these remote memories may be connected to the computer device via a network. Examples of such networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof.

[0197] The memory 802 may include volatile memory, such as random access memory; the memory may also include non-volatile memory, such as flash memory, hard disk or solid-state drive; the memory 802 may also include a combination of the above types of memory.

[0198] The computer device also includes a communication interface 803 for communicating with other devices or communication networks.

[0199] This invention also provides a computer-readable storage medium. The methods described above according to embodiments of the invention can be implemented in hardware or firmware, or implemented as computer code that can be recorded on a storage medium, or implemented as computer code downloaded via a network and originally stored on a remote storage medium or a non-transitory machine-readable storage medium and then stored on a local storage medium. Thus, the methods described herein can be processed by software stored on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware. The storage medium can be a magnetic disk, optical disk, read-only memory, random access memory, flash memory, hard disk, or solid-state drive, etc.; further, the storage medium can also include combinations of the above types of memory. It is understood that computers, processors, microprocessor controllers, or programmable hardware include storage components capable of storing or receiving software or computer code, which, when accessed and executed by the computer, processor, or hardware, implements the methods shown in the above embodiments.

[0200] A portion of this invention can be applied as a computer program product, such as computer program instructions, which, when executed by a computer, can invoke or provide the methods and / or technical solutions according to the invention through the operation of the computer. Those skilled in the art will understand that the forms in which computer program instructions exist in a computer-readable medium include, but are not limited to, source files, executable files, installation package files, etc. Correspondingly, the ways in which computer program instructions are executed by a computer include, but are not limited to: the computer directly executing the instructions, or the computer compiling the instructions and then executing the corresponding compiled program, or the computer reading and executing the instructions, or the computer reading and installing the instructions and then executing the corresponding installed program. Here, the computer-readable medium can be any available computer-readable storage medium or communication medium accessible to a computer.

[0201] Although embodiments of the invention have been described in conjunction with the accompanying drawings, those skilled in the art can make various modifications and variations without departing from the spirit and scope of the invention, and such modifications and variations all fall within the scope defined by the appended claims.

Claims

1. A method for determining code coverage, characterized in that, Applied to the server host, the method includes: Obtain multiple source code files of the firmware module of the disk array card; Multiple source code files are compiled into an executable file. During the compilation process, the multiple source code files are instrumented to update the execution information of each source code file when the executable file is run. Basic block files corresponding to the multiple source code files are generated, wherein the basic block files include pointers to the execution information of the corresponding source code files. The executable file is run so that the disk array card maps the execution information of the base block file and the source code file to the host cache. After the executable file finishes running, the execution information of each source code file in the host cache is obtained, and the execution information is written into the corresponding execution information file. The execution information file and the basic block file are analyzed to obtain the code coverage of each source code file.

2. The method according to claim 1, characterized in that, The process of compiling multiple source code files into an executable file, including instrumentation of the multiple source code files, includes: During the process of compiling multiple source code files into an executable file, update coverage code is appended after each line of code in the source code file. The update coverage code is a stub. A static array is inserted into the source code file. The size of the static array is the number of stubs in the source code file, and the value of the static array corresponds to the number of times each stub is executed.

3. The method according to claim 1, characterized in that, The generation of multiple basic block files corresponding to the source code files includes: For any source code file, the basic block file corresponding to the source code file is set to include a pointer to the static array corresponding to the source code file, the number of stubs included in the source code file, and the name of the source code file, wherein the execution information of the source code file includes the static array corresponding to the source code file.

4. The method according to claim 1, characterized in that, Running the executable file to enable the disk array card to map the execution information of the base block file and the source code file to the host cache includes: During the execution of the executable file, the basic block files corresponding to multiple source code files are linked to form a basic block file linked list, so that the disk array card maps the basic block file linked list and the execution information of the source code files to the host cache area.

5. A method for determining code coverage, characterized in that, Applied to a disk array card, the method includes: When the executable file is run on the server host, the execution information of the basic block file and the source code file is mapped to the host cache. This allows the server host to obtain the execution information of each source code file in the host cache after the executable file finishes running, and write the execution information into the corresponding execution information file. The execution information file and the basic block file are then analyzed to obtain the code coverage of each source code file. The server host obtains multiple source code files of the firmware module of the disk array card; compiles the multiple source code files into an executable file, wherein, during the compilation of the multiple source code files into an executable file, the multiple source code files are instrumented so that the execution information of each source code file is updated when the executable file is run; and generates basic block files corresponding to the multiple source code files, wherein the basic block files include pointers to the execution information of the corresponding source code files.

6. The method according to claim 5, characterized in that, The process of mapping execution information of basic block files and source code files to the host cache includes: Obtain the address of the host cache sent by the server host, wherein the server host requests a host cache in memory during the disk array card initialization process and sends the address of the host cache to the disk array card; Get the number of basic block files in the basic block file linked list; For any given basic block file, obtain the sort order of that basic block file in the linked list of basic block files; Based on the number of basic block files in the basic block file linked list, the order of the basic block files in the basic block file linked list, and the address of the host cache, a corresponding address to be written is allocated to the basic block file; Based on the address to be written, the basic block file is mapped to the host cache area; Based on the linking relationship of the basic block files in the basic block file linked list, the linking relationship of the basic block files in the host cache is set; Obtain information about the static array of the source code file corresponding to the basic block file; Based on the address to be written, the information of the static array of the source code file corresponding to the basic block file is mapped to the host cache. Based on the pointer relationship between the basic block file and the static array of the source code file corresponding to the basic block file, the corresponding pointer relationship is set in the host cache.

7. A code coverage determination device, characterized in that, The device, applied to a server host, includes: The first acquisition module is used to acquire multiple source code files of the firmware module of the disk array card; A compilation module is used to compile multiple source code files into an executable file. During the compilation process, the multiple source code files are instrumented to update the execution information of each source code file when the executable file is run. A basic block file corresponding to the multiple source code files is generated, wherein the basic block file includes pointers to the execution information of the corresponding source code file. The execution module is used to run the executable file so that the disk array card maps the execution information of the basic block file and the source code file to the host cache. The second acquisition module is used to acquire the execution information of each source code file in the host cache after the executable file finishes running, and write the execution information into the corresponding execution information file; The third acquisition module is used to analyze the execution information file and the basic block file to obtain the code coverage of each source code file.

8. A code coverage determination device, characterized in that, The device, applied to a disk array card, includes: The mapping module is used to map the execution information of the basic block files and source code files to the host cache when the executable file is running on the server host. This allows the server host to obtain the execution information of each source code file in the host cache after the executable file finishes running, and write the execution information into the corresponding execution information file. The execution information file and the basic block files are then analyzed to obtain the code coverage of each source code file. The server host obtains multiple source code files of the firmware module of the disk array card; compiles the multiple source code files into an executable file, wherein, during the compilation of the multiple source code files into an executable file, the multiple source code files are instrumented so that the execution information of each source code file is updated when the executable file is run; and generates basic block files corresponding to the multiple source code files, wherein the basic block files include pointers to the execution information of the corresponding source code files.

9. A computer device, characterized in that, include: A memory and a processor are communicatively connected, the memory stores computer instructions, and the processor executes the computer instructions to perform the code coverage determination method of any one of claims 1 to 4 or any one of claims 5 to 6.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions for causing a computer to perform the code coverage determination method of any one of claims 1 to 4 or any one of claims 5 to 6.

Citation Information

Patent Citations

  • Memory executing method for executable file

    CN104820612A

  • Coverage rate data processing method and device, computer equipment and storage medium

    CN115437905A