A method and system for determining source code coverage

By inserting probe code into the source code and statically analyzing the MC/DC truth table, combined with bit vector and truth table compression technology, the problems of slow execution speed, high code expansion rate and inaccurate coverage rate of the traditional instrumentation method are solved. problem, enabling efficient and accurate source code coverage analysis.

CN114817045BActive Publication Date: 2024-10-25BEIJING XUANYU INFORMATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202210472030.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-04-29
Publication Date
2024-10-25
Estimated Expiration
2042-04-29

AI Technical Summary

Technical Problem

The traditional instrumentation method has problems such as slow execution speed, high code expansion rate, and inaccurate coverage calculation results.

Method used

By inserting probe code into the source code, static analysis calculates the MC/DC truth table, and updates and records the stub execution in real time during the code execution process. It uses bit vector and truth table compression technology to perform coverage calculations and generate After instrumentation, the code, instrumentation information file and function control flow chart are calculated to calculate statement, branch and function call coverage.

Benefits of technology

It achieves coverage analysis with high accuracy, low expansion rate and fast execution speed, avoids additional auxiliary instrumentation points and frequent I/O operations, and reduces memory usage and compilation time.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114817045B_ABST
    Figure CN114817045B_ABST
Patent Text Reader

Abstract

The present invention relates to an efficient source code coverage determination method and system. The method calculates the MC / DC truth table during the insertion, compresses the truth table using bit vectors, and calculates the truth table coverage in real time during the acquisition process, which has the advantages of high precision, low expansion rate, and fast execution speed. At the same time, the method does not require additional auxiliary insertion points, frequent I / O, and output of a large amount of information, and the amount of data generated is comparable to the existing execution marking method, thereby achieving low expansion rate and fast accurate coverage analysis.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to an efficient source code coverage determination method and system, belonging to the technical field of program testing. Background Art

[0002] Code coverage is a measure of software testing integrity, describing the proportion and degree of source code testing in a program, and belongs to the category of white box testing. Code coverage can be counted in unit testing, integration (assembly) testing, or system testing. Common coverage indicators include statement (instruction) coverage, branch (decision) coverage, MC / DC coverage, and function call coverage. MC / DC coverage has the highest coverage level, and is required to reach 100% for software in safety-critical areas.

[0003] There are generally two ways to obtain source code coverage:

[0004] One method is to calculate the coverage of the source code by combining the coverage of the target code and the mapping relationship between the target code and the source code. This method does not require stubs and does not increase the running overhead of the program. Patent CN112799942A discloses a method and system for analyzing the source code and target code coverage of Keil C51 software. The invention uses Keil's own functions to generate target code coverage, infers the source code coverage through the M51 file, and then colors the source file according to the result; Patent CN112540913A discloses a method for generating a corresponding CPU instruction execution flow file based on the CPU instruction waveform, and then infers the source code coverage based on the correspondence between the instruction and the source code. The method of calculating the source code coverage through the target code coverage is limited to the case where there is a target code coverage and a source code-target code correspondence. At the same time, it is affected by compiler optimization, the calculation result may be inaccurate, and it is difficult to support MC / DC coverage.

[0005] Another method is coverage analysis based on source code instrumentation: insert probe code at function entry and exit, branches, conditions, and function calls, and calculate coverage based on probe execution. The advantage of this method is that the results are accurate, it can support analysis of any coverage, and the source code after instrumentation can be compiled under multiple compilers. This method is further divided into two modes: execution tracking and execution marking: ① Execution tracking refers to the complete recording of the running sequence of the insertion point during the execution process. Patent CN101408862B discloses an embedded program coverage analysis method. After the code is inserted, the signal of the insertion point is collected by hardware to calculate the coverage. The signal collection process uses the execution tracking method. The advantage of this method is that the information is complete, but the disadvantage is that the frequent calls to the operating system I / O lead to a significant reduction in the execution speed and a large amount of space occupied by the recorded data; ② The execution marking method only records whether the insertion point is executed. Foreign white box testing tools such as Cantata use this method. The advantages are fast execution speed and small space occupied by recorded data. The disadvantage is that only the final state can be recorded. In order to calculate the MC / DC coverage, additional auxiliary piles need to be inserted, resulting in a high code expansion rate. For example, when the judgment statement contains 10 conditions, the expansion rate of the compiled target code is more than 2 times. In extreme cases, there is even a problem of excessive expansion rate leading to compilation failure. Summary of the invention

[0006] The technical problem solved by the present invention is: to overcome the deficiencies of the prior art, to provide an efficient source code coverage determination method and system, and to solve the problems of slow execution speed, high code expansion rate and inaccurate coverage calculation results of traditional plugging methods.

[0007] The technical solution of the present invention is:

[0008] An efficient source code coverage determination method includes the following steps:

[0009] (1) Instrument source code coverage by inserting probe code at function entry, exit, branch, condition, and function call, and performing corresponding recording operations when the probe code is executed;

[0010] (2) Calculate the MC / DC truth table of each decision node through static analysis during instrumentation;

[0011] (3) Generate the post-instrumentation code, the instrumentation information file, and the function control flow graph CFG file;

[0012] (4) After the stub is inserted, the stub execution record table is used in the code to record the execution status of each stub probe;

[0013] (5) During the execution of the code after the stub is inserted, the stub execution record table is updated. When a decision node is about to end, the number of the covering combination in the corresponding truth table is found according to the state of each condition inside it, and the corresponding State part in the map is updated;

[0014] (6) Repeat step (5) during the execution of the code after the instrumentation;

[0015] (7) After the code execution is completed, the execution record table and map of the stub point are output;

[0016] (8) According to the stub execution record table and the stub information file, the function call coverage is calculated by the execution of the function entry stub; the branch coverage is calculated by judging the stub record; the map data is traversed, and the MC / DC coverage of each judgment node is calculated according to the truth table coverage record;

[0017] (9) Calculating statement coverage with the help of the function control flow graph CFG file: Each source code statement corresponds to a general node in the function control flow graph CFG file, and the judgment statement corresponds to a branch node in the function control flow graph CFG file. The statement execution status is determined according to the branch coverage, and then the statement coverage is obtained; the general node refers to the function entry, exit and function call;

[0018] (10) Perform data integration to obtain the final result.

[0019] Furthermore, the MC / DC truth table includes all possible condition combinations that satisfy 100% coverage of MC / DC, and also includes the pairing relationship between the condition combinations, and then the condition combinations are numbered from 0 to N; N is a positive integer.

[0020] Furthermore, the MC / DC truth table of each decision node is calculated by static analysis during the insertion, specifically: the multi-condition decision is equivalently transformed into a combination of multiple single-condition decisions by means of a control flow chart, and then the set of condition state (T or F) sequences on all paths from the entry (A) to the exit (statement 1 or statement 2) is obtained by traversal, which is the truth table; other condition nodes that do not appear on the path are occupied by X, indicating that the condition has no effect on this path.

[0021] Furthermore, the instrumented code records whether the instrumentation point is executed during execution, and embeds a compressed MC / DC truth table for real-time calculation of MC / DC coverage; the instrumentation information file records the meaning of each instrumentation point and the MC / DC truth table to assist in calculating coverage; the function control flow graph CFG file is used to infer statement coverage based on branch coverage.

[0022] Furthermore, the stub execution record table is in the form of a bit array.

[0023] Furthermore, the post-insertion code uses a stub execution record table to record the execution status of each stub probe, specifically:

[0024] The function entry, exit and function call insertion points use 1 bit to record the status, and the branch and conditional insertion points use 2 bits to record;

[0025] In binary, 0b00 means it has not been executed, 0b01 means the result of the execution is False, 0b10 means the result of the execution is True, and 0b11 means both True and False have been executed.

[0026] Use map to record the coverage of the truth table. The map includes two parts: DecisionID and State. The DecisionID of the map represents the number of the decision node, and State represents the numbered set of covered condition combinations. It uses a bit array type, in which the bits record in sequence whether the 0th, 1st, ..., Nth numbered combinations are covered; multi-branch node switches are treated as decisions containing MC / DC.

[0027] Furthermore, the present invention also proposes an efficient source code coverage determination system, comprising:

[0028] Instrumentation module: Instruments source code coverage by inserting probe codes at function entry, exit, branch, condition and function call, and performs corresponding recording operations when the probe codes are executed;

[0029] MC / DC truth table generation module: calculates the MC / DC truth table of each decision node through static analysis during instrumentation; generates post-instrumentation code, instrumentation information file, and function control flow graph CFG file;

[0030] Probe execution record module: After the stub is inserted, the stub execution record table is used in the code to record the execution status of each stub probe.

[0031] Stub execution record table update module: update the stub execution record table during the execution of the code after the stub is inserted. When a decision node is about to end, find the number of the covering combination in the corresponding truth table according to the state of each condition inside it, and update the corresponding State part in the map. Repeat the stub execution record table update module during the execution of the code after the stub is inserted.

[0032] Output module: After the code execution is completed, the execution record table and map of the stub point are output;

[0033] Coverage calculation module: according to the pile point execution record table and the pile information file, the function call coverage is calculated through the execution of the function entry pile point; the branch coverage is calculated by judging the pile point record; the map data is traversed, and the MC / DC coverage of each judgment node is calculated according to the truth table coverage record; the statement coverage is calculated with the help of the function control flow graph CFG file: each source code statement corresponds to a general node in the function control flow graph CFG file, and the judgment statement corresponds to a branch node in the function control flow graph CFG file. The statement execution is determined according to the branch coverage, and then the statement coverage is obtained; the general node refers to the function entry, exit and function call;

[0034] Integration module: integrates data to obtain the final result.

[0035] The beneficial effects of the present invention compared with the prior art are:

[0036] (1) The present invention calculates the MC / DC truth table during the insertion, compresses the truth table using bit vectors, and calculates the truth table coverage in real time during the acquisition process, which has the advantages of high accuracy, low expansion rate, and fast execution speed.

[0037] (2) The tool kit of the present invention can perform normal instrumentation, compilation execution and coverage analysis, and the memory usage and execution speed are within an acceptable range.

[0038] (3) This method does not require additional auxiliary instrumentation points, nor does it require frequent I / O and output of large amounts of information. The amount of data generated is comparable to that of existing execution marking methods, thus achieving low expansion rate and fast and accurate coverage analysis. BRIEF DESCRIPTION OF THE DRAWINGS

[0039] Figure 1 It is a flow chart of the present invention;

[0040] Figure 2 This is the schematic diagram for calculating the MC / DC truth table, where: Figure 2 a is a multi-condition judgment, Figure 2 b is a combination of single condition judgments. DETAILED DESCRIPTION

[0041] The specific embodiments of the present invention are further described in detail below with reference to the accompanying drawings.

[0042] Patent CN112799942A discloses a software source code and target code coverage analysis method and system based on Keil C51, the principle of which is to infer the target code coverage through the target code, which is different from the present method; Patent CN112540913A discloses a method of generating a corresponding CPU instruction execution flow file according to the CPU instruction waveform, and then calculating the source code coverage according to the corresponding relationship between the instruction and the source code, which is different from the present method; Patent CN101408862B discloses an embedded system testing method, which uses hardware-assisted software to first perform coverage plugging, download it to the target board after compilation, collect the plugging point signal through the hardware, and then package and send the collection point information to the test result analysis software for result analysis and processing. Currently, there is no patent or technology disclosed that simultaneously uses bit vector and truth table compression to calculate coverage.

[0043] This method is improved on the basis of the execution marking method. During the insertion, all MC / DC truth tables are calculated through static analysis, and a buffer for recording the coverage of the MC / DC truth tables is inserted into the code. During the program execution, the coverage of the truth tables is calculated and updated in real time, and finally the insertion point record table and the truth table coverage record table are generated. After analysis, the final coverage is obtained. This method does not require additional auxiliary insertion points, frequent I / O and output of large amounts of information. The amount of data generated is comparable to the existing execution marking method, thus achieving low expansion rate and fast and accurate coverage analysis.

[0044] like Figure 1 As shown, the efficient source code coverage determination method proposed by the present invention comprises the following steps:

[0045] 1) For source code coverage instrumentation, probe code is inserted at the function entry, exit, branch, condition (for example, if(A&&(B||C)) where A, B and C are each a condition) and function call, and corresponding recording operations are performed when the probe code is executed;

[0046] 2) During the instrumentation, the MC / DC truth table of each decision node is calculated through static analysis technology. The truth table contains all possible condition combinations that meet 100% coverage of MC / DC, as well as the pairing relationship between the condition combinations. The condition combinations are then numbered from 0 to N.

[0047] like Figure 2 As shown, the calculation principle of the MC / DC truth table is: put the multi-condition judgment ( Figure 2 (a)) is equivalently transformed into a combination of multiple single condition judgments through the control flow chart ( Figure 2(b)), and then traverse to obtain the set of conditional state (T or F) sequences on all paths from the entry (A) to the exit (statement 1 or statement 2), which is the truth table; other conditional nodes that do not appear on the path are occupied by X, indicating that the condition has no effect on this path.

[0048] 3) Generate post-instrumentation code, instrumentation information file and function control flow graph (CFG) file: The post-instrumentation code records whether the instrumentation point is executed during execution, and embeds a compressed truth table for real-time calculation of MC / DC coverage; the instrumentation information file records the meaning and truth table of each instrumentation point to assist in calculating coverage; the CFG information is used to infer statement coverage based on branch coverage;

[0049] 4) After the stub is inserted, the code uses a stub execution record table (in the form of a bit array) to record the execution status of each stub probe. Generally, stubs (such as entry, exit, and function call) use 1 bit to record the status, while branches and conditional stubs require 2 bits to record;

[0050] In binary, 0b00 means not executed (N), 0b01 means the execution result is False (F), 0b10 means the execution result is True (T), and 0b11 means both True and False have been executed (P).

[0051] Using map<DecisionID,State> Record the coverage of the truth table. The DecisionID of the map represents the number of the decision node such as if and for. State represents the numbered set of the covered condition combinations. The bit array type is used, and the bits in it record whether the 0th, 1st, ..., Nth numbered combinations are covered. The multi-branch node switch is treated as a decision containing MC / DC, and one case is analogous to one condition.

[0052] 5) Update the execution record table of the stub point during the execution process. Next, when a decision node is about to end, find the number of the corresponding covering combination in the truth table according to the state of each condition inside it, and update the corresponding State in the map;

[0053] 6) Repeat step 5) during execution;

[0054] 7) After the execution is completed, the stub execution record table and map are output;

[0055] 8) According to the pile point execution record table and the pile point information file, the function call coverage is calculated through the execution of the function entry pile point; the total number of branches can be known according to the pile point information, and the number of covered branches can be obtained according to the judgment pile point record, and then the branch coverage is obtained; the map data is traversed, and the MC / DC coverage of each judgment node is calculated according to the truth table coverage record.

[0056] The calculation principle is as follows: ① Obtain the set of covered condition combinations based on the truth table coverage records; ② Select any two combinations with different judgment results (one combination with result T and one combination with result F), and compare the state of each condition in turn. If and only if the corresponding condition state is consistent with the judgment state, the condition is considered to be covered by MC / DC; ③ Repeat step ② until the set traversal is completed or all conditions have been covered.

[0057] 9) Then calculate the statement coverage with the help of CFG: the general nodes in CFG correspond to source code statements, so the total number of statements can be known. The branch nodes in CFG correspond to decision statements. According to the branch coverage, traverse CFG to get the covered nodes, and then get the number of covered statements, and finally get the statement coverage;

[0058] 10) Finally, data integration is performed to obtain the final result.

[0059] Furthermore, the present invention also proposes an efficient source code coverage determination system, comprising:

[0060] Instrumentation module: Instruments source code coverage by inserting probe codes at function entry, exit, branch, condition and function call, and performs corresponding recording operations when the probe codes are executed;

[0061] MC / DC truth table generation module: calculates the MC / DC truth table of each decision node through static analysis during instrumentation; generates post-instrumentation code, instrumentation information file, and function control flow graph CFG file;

[0062] Probe execution record module: After the stub is inserted, the stub execution record table is used in the code to record the execution status of each stub probe.

[0063] Stub execution record table update module: update the stub execution record table during the execution of the code after the stub is inserted. When a decision node is about to end, find the number of the covering combination in the corresponding truth table according to the state of each condition inside it, and update the corresponding State part in the map. Repeat the stub execution record table update module during the execution of the code after the stub is inserted.

[0064] Output module: After the code execution is completed, the execution record table and map of the stub point are output;

[0065] Coverage calculation module: according to the pile point execution record table and the pile information file, the function call coverage is calculated through the execution of the function entry pile point; the branch coverage is calculated by judging the pile point record; the map data is traversed, and the MC / DC coverage of each judgment node is calculated according to the truth table coverage record; the statement coverage is calculated with the help of the function control flow graph CFG file: each source code statement corresponds to a general node in the function control flow graph CFG file, and the judgment statement corresponds to a branch node in the function control flow graph CFG file. The statement execution is determined according to the branch coverage, and then the statement coverage is obtained; the general node refers to the function entry, exit and function call;

[0066] Integration module: integrates data to obtain the final result.

[0067] Example:

[0068] This embodiment takes the sample program code test as an example to verify the source code coverage determination method.

[0069]

[0070] (1) Instrument source code coverage by inserting probe code at function entry, exit, branch, and condition, and performing corresponding recording operations when the probe code is executed;

[0071] (2) During the instrumentation, the MC / DC truth table of each decision node is calculated through static analysis technology. The truth table contains all possible condition combinations that meet 100% MC / DC coverage, and also contains the pairing relationship between condition combinations. The condition combinations are then numbered from 0 to N. As shown in Table 1, there are 4 condition combinations in the truth table, indicating that 3 conditions (C0, C1, and C2) can achieve 100% MC / DC coverage through these 4 combinations.

[0072] serial number C0 C1 C2 result Matching conditions 0 T T N T 3[C1],2[C0] 1 T F T T 2[C0],3[C2] 2 F N N F 1[C0],0[C0] 3 T F F F 1[C2],0[C1]

[0073] Table 1 if(A&&(B||C)) MC / DC truth table

[0074] (3) Generate the post-instrumentation code, the instrumentation information file, and the function control flow graph (CFG) file: When the post-instrumentation code is executed, it records whether the instrumentation point is executed, and embeds the compressed truth table for real-time calculation of MC / DC coverage; the instrumentation information file records the meaning of each instrumentation point and the truth table to assist in analyzing the coverage rate; the CFG information is used to infer the statement coverage rate based on the branch coverage rate; the post-instrumentation code is as follows:

[0075]

[0076]

[0077] (4) The post-instrumentation code uses a bit array (bit_array) to record the execution status of each instrumentation point probe. Branch and conditional instrumentation points require 2 bits to record. Binary 0b00 indicates not executed (N), 0b01 indicates the execution result is False (F), 0b10 indicates the execution result is True (T), and 0b11 indicates that both True and False have been executed (P). N, F, T, and P are used below to represent the coverage status. As described in the post-instrumentation code above, the if instrumentation point uses numbers 1 and 2 to indicate that the 1st and 2nd bits of bit_array record the if judgment result. Similarly, the condition a<0 uses the 3rd and 4th bits to indicate the condition judgment result. In addition, 1 and 3 also represent the unique numbers of if and a<0, respectively, which are used to calculate the coverage rate based on the instrumentation information file. In this example, the truth table of if has only 4 combinations, and map is used.<int,char[1]> Record the coverage of the truth table. The int of the map represents the number of the if node. In this example, there is only one if node (numbered 1). char[1] records the number set of the covered condition combinations. From low to high, bits are used to indicate whether the combinations of the 0th, 1st, 2nd, and 3rd numbers are covered.

[0078] (5) Update bit_array during the test execution process. When entering the test function, the probe with the insertion point 0 is triggered, and the 0th bit of bit_array is updated to the value after being ORed with the 1st bit (i.e., '|'). When a decision node is about to end, the number of the combination covered this time is found according to the status of each of its conditions, and the map is updated. For example, when entering if for the first time, the status of the three conditions is TTN respectively. If the judgment of if is T, then the 1st and 2nd bits of bit_array are updated to the value after being ORed with 0b10 (T). TTN corresponds to the combination numbered 0 in the truth table, so in The 0th bit of char[1] is updated to the value after being ORed with the 1st bit, and the map content is {(1,0b0001)} at this time. For another example, when entering if for the second time, the state changes to FNN, and if is judged as F, then the 1st and 2nd bits of bit_array are updated to the value after being ORed with the 0b01(F) bit, that is, 0b11. FNN corresponds to the combination numbered 2 in the truth table, so the 2nd bit of char[1] is updated to the value after being ORed with the 1st bit, and the map content is {(1,0b0101)} at this time. When the function exits, the probe with the number 9 of the insertion point is triggered to make the corresponding record.

[0079] (6) Repeat step (5) until the program ends;

[0080] (7) Output the contents of bit_array and map to a file;

[0081] (8) According to bit_array, the function call coverage is calculated by the execution of the function entry plug-in point, and the branch coverage is calculated by the judgment plug-in point record; traverse the map and calculate the MC / DC coverage of each judgment node according to the truth table coverage and condition pairing relationship;

[0082] (9) Then, the statement coverage is calculated with the help of CFG: each source code statement corresponds to a general node on the CFG, and the judgment statement corresponds to a branch node in the CFG. The statement execution is determined based on the branch coverage, and then the statement coverage is obtained;

[0083] (10) Finally, data integration is performed to obtain the final result.

[0084] The present invention calculates the MC / DC truth table during the insertion, compresses the truth table using bit vectors, and calculates the truth table coverage in real time during the acquisition process, which has the advantages of high accuracy, low expansion rate, and fast execution speed. The method has been verified in a component test tool, and the execution time of the code test after the insertion is reduced from 71769ms to 452ms, while the execution time without the insertion is 380ms, and the speed reduction does not exceed 25%.

[0085] It is verified in actual projects that the method of the present invention can cope with various complex cases. When encountering 33 conditions in if in actual projects, the code expansion rate of the well-known foreign white box testing tool Cantata is too large after plugging in and cannot be compiled. However, the method of the present invention can be used for normal plugging, compilation, execution and coverage analysis, and the memory usage and execution speed are within an acceptable range.

[0086] Parts of the present invention that are not described in detail belong to common knowledge among those skilled in the art.

Claims

1. An efficient method for determining source code coverage, characterized in that include: For source code coverage instrumentation, probe codes are inserted at function entry, exit, branch, condition and function call, and corresponding recording operations are performed when the probe code is executed; During the instrumentation, the MC / DC truth table of each decision node is calculated through static analysis; Generate the post-instrumentation code, the instrumentation information file and the function control flow graph CFG file; After the stub is inserted, the stub execution record table is used in the code to record the execution status of each stub probe. Repeated execution during the code execution after the stub is inserted: update the stub execution record table, find the number of the covering combination in the corresponding truth table according to the state of each condition inside the stub when a decision node is about to end, and update the corresponding State part in the map; After the code execution is completed, the execution record table and map of the stub point are output; According to the stub execution record table and the stub information file, the function call coverage is calculated through the execution of the function entry stub; the branch coverage is calculated through the judgment stub record; the map data is traversed, and the MC / DC coverage of each judgment node is calculated according to the truth table coverage record; Calculate statement coverage with the help of function control flow graph CFG file: each source code statement corresponds to a general node in the function control flow graph CFG file, determine the statement execution status according to the branch coverage, and then get the statement coverage; the general node refers to the function entry, exit and function call; The data is integrated to obtain the final result.

2. The efficient source code coverage determination method according to claim 1, characterized in that: The MC / DC truth table includes all possible condition combinations that satisfy 100% coverage of MC / DC, and also includes the pairing relationship between the condition combinations, and then the condition combinations are numbered from 0 to N; N is a positive integer.

3. The efficient source code coverage determination method according to claim 1, characterized in that: The MC / DC truth table of each decision node is calculated by static analysis during the insertion. The working principle is as follows: the multi-condition decision is equivalently transformed into a combination of multiple single-condition decisions by means of a control flow chart, and then the set of condition state sequences on all paths from the entrance to the exit is obtained by traversal, which is the truth table; other condition nodes that do not appear on the path are occupied by X, indicating that the condition has no effect on this path.

4. The efficient source code coverage determination method according to claim 1, characterized in that: When the instrumented code is executed, it records whether the instrumentation point is executed, and embeds the compressed MC / DC truth table for real-time calculation of MC / DC coverage; the instrumentation information file records the meaning of each instrumentation point and the MC / DC truth table to assist in calculating the coverage rate; the function control flow graph CFG file is used to infer the statement coverage rate based on the branch coverage rate.

5. The efficient source code coverage determination method according to claim 1, characterized in that: The stub execution record table is in the form of a bit array.

6. The efficient source code coverage determination method according to claim 4, characterized in that: The post-instrumentation code uses a pile point execution record table to record the execution status of each pile point probe, specifically: The function entry, exit and function call insertion points use 1 bit to record the status, and the branch and conditional insertion points use 2 bits to record; In binary, 0b00 means it has not been executed, 0b01 means the result of the execution is False, 0b10 means the result of the execution is True, and 0b11 means both True and False have been executed. Use map to record the coverage of the truth table. The map includes two parts: DecisionID and State. The DecisionID of the map represents the number of the decision node, and State represents the numbered set of covered condition combinations. It uses a bit array type, in which the bits record in sequence whether the 0th, 1st, ..., Nth numbered combinations are covered; multi-branch node switches are treated as decisions containing MC / DC.

7. An efficient source code coverage determination system, characterized by include: Instrumentation module: Instruments source code coverage by inserting probe codes at function entry, exit, branch, condition and function call, and performs corresponding recording operations when the probe codes are executed; MC / DC truth table generation module: calculates the MC / DC truth table of each decision node through static analysis during instrumentation; generates post-instrumentation code, instrumentation information file, and function control flow graph CFG file; Probe execution record module: After the stub is inserted, the stub execution record table is used in the code to record the execution status of each stub probe. Stub execution record table update module: update the stub execution record table during the execution of the code after the stub is inserted. When a decision node is about to end, find the number of the covering combination in the corresponding truth table according to the state of each condition inside it, and update the corresponding State part in the map. Repeat the stub execution record table update module during the execution of the code after the stub is inserted. Output module: After the code execution is completed, the execution record table and map of the stub point are output; Coverage calculation module: According to the stub execution record table and the stub information file, the function call coverage is calculated through the execution of the function entry stub; the branch coverage is calculated by judging the stub record; the map data is traversed, and the MC / DC coverage of each judgment node is calculated according to the truth table coverage record; Calculate statement coverage with the help of function control flow graph CFG file: each source code statement corresponds to a general node in the function control flow graph CFG file, determine the statement execution status according to the branch coverage, and then get the statement coverage; the general node refers to the function entry, exit and function call; Integration module: integrates data to obtain the final result.

8. The efficient source code coverage determination system according to claim 7, characterized in that: The MC / DC truth table includes all possible condition combinations that satisfy 100% coverage of MC / DC, and also includes the pairing relationship between the condition combinations, and then the condition combinations are numbered from 0 to N; N is a positive integer; The MC / DC truth table of each decision node is calculated by static analysis during the insertion, specifically: the multi-condition decision is equivalently transformed into a combination of multiple single-condition decisions by means of a control flow chart, and then the set of condition state sequences on all paths from the entrance to the exit is obtained by traversal, which is the truth table; other condition nodes that do not appear on the path are occupied by X, indicating that the condition has no effect on this path.

9. The efficient source code coverage determination system according to claim 8, characterized in that: When the instrumented code is executed, it records whether the instrumentation point is executed, and embeds the compressed MC / DC truth table for real-time calculation of MC / DC coverage; the instrumentation information file records the meaning of each instrumentation point and the MC / DC truth table to assist in calculating the coverage rate; the function control flow graph CFG file is used to infer the statement coverage rate based on the branch coverage rate.

10. The efficient source code coverage determination system according to claim 8, characterized in that: The pile point execution record table adopts the bit array form; The post-instrumentation code uses a pile point execution record table to record the execution status of each pile point probe, specifically: The function entry, exit and function call insertion points use 1 bit to record the status, and the branch and conditional insertion points use 2 bits to record; In binary, 0b00 means it has not been executed, 0b01 means the result of the execution is False, 0b10 means the result of the execution is True, and 0b11 means both True and False have been executed. Use map to record the coverage of the truth table. The map includes two parts: DecisionID and State. The DecisionID of the map represents the number of the decision node, and State represents the numbered set of covered condition combinations. It uses a bit array type, in which the bits record in sequence whether the 0th, 1st, ..., Nth numbered combinations are covered; multi-branch node switches are treated as decisions containing MC / DC.