Code testing method, device, electronic device and storage medium

Through similarity analysis and mutation processing of code test cases, the redundancy problem caused by random fuzz testing is solved, the quality and efficiency of test cases are improved, and efficient automation of code testing is achieved.

CN118260209BActive Publication Date: 2024-08-27MOORE THREADS TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410658534.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-05-24
Publication Date
2024-08-27
Estimated Expiration
2044-05-24

AI Technical Summary

Technical Problem

Among existing code testing methods, the random fuzz testing method leads to redundancy in the test case collection, increases time and labor costs, and has a poor effect on improving the quality of test cases.

Method used

By conducting quantitative similarity analysis on the test case collection, using cosine similarity, Jaccard similarity, Euclidean distance similarity or Pearson similarity calculation formula, identify and delete redundant test cases, and based on the branch hit situation and target The area calculates the number of mutation times of test cases and optimizes the redundancy and quality of the test case collection.

Benefits of technology

It effectively reduces time and labor costs, improves the quality and diversity of test case collections, and ensures the accuracy and efficiency of code testing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118260209B
    Figure CN118260209B
Patent Text Reader

Abstract

This disclosure relates to the field of testing, proposing a code testing method, apparatus, electronic device, and storage medium. The method analyzes and determines the branch hit rate of each test case in the test case set for the code under test. It uses a similarity calculation formula to analyze the similarity between any two test cases in the test case set. Based on the analysis results, redundant test cases in the test case set are objectively identified and deleted, optimizing the reduction of redundancy and the improvement of the quality of the test case set. Furthermore, based on the branch hit rate, multiple indicators are calculated to determine the mutation count of the test cases. After performing the corresponding number of mutations on the test cases, the test case set is used to test the code under test, obtaining the test results. This increases the mutation opportunities for test cases with lower branch hit counts and more hits on long paths, improving the probability of discovering deeper problems in the code under test.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of testing, and in particular to a code testing method, device, electronic device and storage medium. Background Art

[0002] After the code development is completed, it is an essential step to test the code to check whether it has errors. The common method is to write corresponding test cases based on the code to be tested. The test cases include the expected input and expected output of the code to be tested. Use the test cases to test the code to be tested, and observe whether the actual output of the code to be tested is consistent with the expected output to determine whether the code to be tested has errors.

[0003] The code to be tested requires many aspects of testing, and manually writing test cases consumes a lot of time and labor costs. Therefore, the prior art proposes a fuzzy testing method to randomly mutate the initial test cases. The mutation will change the content included in the test cases. The random mutation makes this change random, so as long as there is an initial test case, a test case set including a large number of different test cases can be automatically generated. However, the disadvantage of randomness is that there may be many test cases that actually test similar parts, that is, there is redundancy in the test case set. When the redundancy is too high, the quality of the test case set will be reduced. Most of the prior art still removes redundant test cases manually, which is highly subjective, increases time and labor costs, and has a poor effect on improving the quality of the test case set. Summary of the invention

[0004] In view of this, the present disclosure proposes a code testing method, device, electronic device and storage medium. The code testing method of the embodiment of the present disclosure quantitatively analyzes the similarity of test cases, objectively determines and deletes redundant test cases in a test case set, reduces time and labor costs, and optimizes the effect of reducing the redundancy of the test case set and improving the quality of the test case set.

[0005] According to one aspect of the present disclosure, a code testing method is provided, the method being used to test whether a basic block included in a code to be tested has an error, the code to be tested includes at least one basic block, and any two basic blocks having a jump relationship include at least one branch, the method comprising: analyzing and determining, according to a test case set and the code to be tested, a hit situation of each test case in the test case set on the branch; using a similarity calculation formula according to the hit situation, analyzing the similarity of every two test cases in the test case set, and determining and deleting redundant test cases in the test case set according to the analysis result; determining the number of mutations of each test case in the test case set according to the hit situation, mutating the test case a corresponding number of times, and adding the mutated test case to the test case set; using each test case in the test case set to test the code to be tested respectively to obtain a test result, the test result indicating whether an error occurs in a basic block included in the code to be tested.

[0006] In a possible implementation manner, the similarity calculation formula includes one or more of a cosine similarity calculation formula, a Jaccard similarity calculation formula, a Euclidean distance similarity calculation formula, and a Pearson similarity calculation formula.

[0007] In a possible implementation, the method also includes: determining the basic blocks in the code to be tested in which errors occurred based on historical test results of the code to be tested; determining the target area based on the basic blocks in which errors occurred; determining the number of mutations of each test case in the test case set based on the hit situation, and mutating the test case a corresponding number of times, including: determining the weight of each test case in the test case set based on the hit situation and the target area; determining the first number of mutations of the test case based on the weight of each test case in the test case set, and mutating the test case the first number of mutations.

[0008] In a possible implementation, the method further includes: analyzing and determining the hit situation of the test case set on the branch according to the hit situation of each test case in the test case set on the branch; determining the weight of each test case in the test case set according to the hit situation and the target area, including: for each test case in the test case set, calculating the seed average distance index of the test case according to the hit situation of the test case on the branch and the target area, the seed average distance index indicates the degree of association between the test case and the target area; calculating the first value index of the test case according to the hit situation of the test case on the branch, the first value index indicates the test value of the test case itself; calculating the second value index of the test case according to the hit situation of the test case on the branch and the hit situation of the test case set on the branch, the second value index indicates the test value of the test case in the test case set; determining the weight of the test case according to at least one of the seed average distance index, the first value index, and the second value index of the test case.

[0009] In a possible implementation, the calculating the seed average distance index of the test case according to the hit situation of the test case on the branch and the target area includes: according to the hit situation of the test case on the branch and the target area, counting the paths that have the basic blocks hit by the test case as nodes and pass through the target area, wherein the nodes include the starting point, the end point and the way point of the path; for each basic block in each path counted, calculating the number of branches between the basic block and the target area on the path; taking the ratio of the sum of the number of branches between each basic block in each path and the target area on the path to the total number of basic blocks included in the path as the distance index of the path; and determining the average value of the distance index of the counted paths as the seed average distance index of the test case.

[0010] In one possible implementation, the first value indicator of the test case is calculated based on the hit situation of the test case on the branch, including: determining the variance of the number of hits of the test case on each branch hit by itself and the sum of the number of hits of each branch hit by the test case based on the hit situation of the test case on the branch; and taking the ratio of the variance to the sum as the first value indicator.

[0011] In a possible implementation, the second value index of the test case is calculated according to the hit situation of the test case on the branch and the hit situation of the test case set on the branch, including: according to the hit situation of the test case set on the branch, the branches of the code to be tested are sorted in order of the number of times each branch is hit by the test case set; according to the sorting result of the branches, the rarity threshold corresponding to the test case set is determined; according to the hit situation of the test case on the branch, the total number of branches hit less than the rarity threshold among the branches hit by the test case is determined; according to the hit situation of the test case on the branch, the total number of branches hit by the test case is determined; according to the hit situation of the test case on the branch, the second value index is determined according to the total number of branches hit less than the rarity threshold among the branches hit by the test case and the total number of branches hit by the test case.

[0012] In a possible implementation, the mutation times of each test case in the test case set are determined according to the hit situation, and the test case is mutated a corresponding number of times, including: analyzing the hit situation of the test case on the branch according to any test case that has been mutated a first number of times and the code to be tested; determining a second mutation time of the test case when at least one branch hit by the test case is different from the branches hit by the test case set before mutation; mutating the test case the second number of times, and adding the mutated test case to the test case set.

[0013] In a possible implementation manner, the code to be tested is a compiler code.

[0014] According to another aspect of the present disclosure, a code testing device is provided, the device is used to test whether a basic block included in a code to be tested has an error, the code to be tested includes at least one basic block, and any two basic blocks with a jump relationship include at least one branch, the device includes: a first analysis module, used to analyze and determine, based on a test case set and the code to be tested, a hit situation of each test case in the test case set on the branch; a second analysis module, used to analyze the similarity of every two test cases in the test case set using a similarity calculation formula based on the hit situation, and determine and delete redundant test cases in the test case set based on the analysis result; a mutation module, used to determine the number of mutations of each test case in the test case set based on the hit situation, mutate the test case a corresponding number of times, and add the mutated test case to the test case set; a testing module, used to use each test case in the test case set to test the code to be tested respectively to obtain a test result, wherein the test result indicates whether an error occurs in the basic block included in the code to be tested.

[0015] In a possible implementation manner, the similarity calculation formula includes one or more of a cosine similarity calculation formula, a Jaccard similarity calculation formula, a Euclidean distance similarity calculation formula, and a Pearson similarity calculation formula.

[0016] In a possible implementation, the device also includes: a first determination module, used to determine the basic block in which an error occurred in the code to be tested based on the historical test results of the code to be tested; a second determination module, used to determine the target area based on the basic block in which the error occurred; the determining the number of mutations of each test case in the test case set based on the hit situation, and mutating the test case a corresponding number of times, including: determining the weight of each test case in the test case set based on the hit situation and the target area; determining the first number of mutations of the test case based on the weight of each test case in the test case set, and mutating the test case the first number of mutations.

[0017] In a possible implementation, the device also includes: a third analysis module, which is used to analyze and determine the hit situation of the test case set on the branch according to the hit situation of each test case in the test case set on the branch; determine the weight of each test case in the test case set according to the hit situation and the target area, including: for each test case in the test case set, according to the hit situation of the test case on the branch and the target area, calculate the seed average distance index of the test case, the seed average distance index indicates the degree of association between the test case and the target area; calculate the first value index of the test case according to the hit situation of the test case on the branch, the first value index indicates the test value of the test case itself; calculate the second value index of the test case according to the hit situation of the test case on the branch and the hit situation of the test case set on the branch, the second value index indicates the test value of the test case in the test case set; determine the weight of the test case according to at least one of the seed average distance index, the first value index, and the second value index of the test case.

[0018] In a possible implementation, the calculating the seed average distance index of the test case according to the hit situation of the test case on the branch and the target area includes: according to the hit situation of the test case on the branch and the target area, counting the paths that have the basic blocks hit by the test case as nodes and pass through the target area, wherein the nodes include the starting point, the end point and the way point of the path; for each basic block in each path counted, calculating the number of branches between the basic block and the target area on the path; taking the ratio of the sum of the number of branches between each basic block in each path and the target area on the path to the total number of basic blocks included in the path as the distance index of the path; and determining the average value of the distance index of the counted paths as the seed average distance index of the test case.

[0019] In one possible implementation, the first value indicator of the test case is calculated based on the hit situation of the test case on the branch, including: determining the variance of the number of hits of the test case on each branch hit by itself and the sum of the number of hits of each branch hit by the test case based on the hit situation of the test case on the branch; and taking the ratio of the variance to the sum as the first value indicator.

[0020] In a possible implementation, the second value index of the test case is calculated according to the hit situation of the test case on the branch and the hit situation of the test case set on the branch, including: according to the hit situation of the test case set on the branch, the branches of the code to be tested are sorted in order of the number of times each branch is hit by the test case set; according to the sorting result of the branches, the rarity threshold corresponding to the test case set is determined; according to the hit situation of the test case on the branch, the total number of branches hit less than the rarity threshold among the branches hit by the test case is determined; according to the hit situation of the test case on the branch, the total number of branches hit by the test case is determined; according to the hit situation of the test case on the branch, the second value index is determined according to the total number of branches hit less than the rarity threshold among the branches hit by the test case and the total number of branches hit by the test case.

[0021] In a possible implementation, the mutation times of each test case in the test case set are determined according to the hit situation, and the test case is mutated a corresponding number of times, including: analyzing the hit situation of the test case on the branch according to any test case that has been mutated a first number of times and the code to be tested; determining a second mutation time of the test case when at least one branch hit by the test case is different from the branches hit by the test case set before mutation; mutating the test case the second number of times, and adding the mutated test case to the test case set.

[0022] In a possible implementation manner, the code to be tested is a compiler code.

[0023] According to another aspect of the present disclosure, an electronic device is provided, comprising: a processor; and a memory for storing processor-executable instructions; wherein the processor is configured to implement the above method when executing the instructions stored in the memory.

[0024] According to another aspect of the present disclosure, a non-volatile computer-readable storage medium is provided, on which computer program instructions are stored, wherein the computer program instructions implement the above method when executed by a processor.

[0025] According to another aspect of the present disclosure, a computer program product is provided, including a computer-readable code, or a non-volatile computer-readable storage medium carrying the computer-readable code. When the computer-readable code runs in a processor of an electronic device, the processor in the electronic device executes the above method.

[0026] According to the code testing method of the embodiment of the present disclosure, according to the test case set and the code to be tested, the hit situation of each test case in the test case set on the branch of the code to be tested is analyzed and determined, the code to be tested includes at least one basic block, and any two basic blocks with a jump relationship include at least one branch. According to the hit situation of the branch, the similarity of each two test cases in the test case set is analyzed using a similarity calculation formula, which can improve the accuracy of the similarity analysis of the test case, and the redundant test cases in the test case set are determined and deleted according to the analysis results, so as to optimize the effect of reducing the redundancy of the test case set and improve the quality of the test case set; according to the hit situation of the branch, the number of mutations of each test case in the test case set is determined, the test case is mutated a corresponding number of times, and the mutated test case is added to the test case set to improve the diversity of the test case set. Automatic mutation can reduce labor costs and time costs, and further improve the quality of the test case set; each test case in the test case set is used to test the code to be tested respectively to obtain a test result, and the test result indicates whether an error occurs in the basic block included in the code to be tested, so as to complete the test of the code to be tested. To sum up, the code testing method of the embodiment of the present invention quantitatively analyzes the similarity of test cases, objectively determines and deletes redundant test cases in the test case set, reduces time and labor costs, and optimizes the effect of reducing the redundancy of the test case set and improving the quality of the test case set.

[0027] Further features and aspects of the present disclosure will become apparent from the following detailed description of exemplary embodiments with reference to the attached drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0028] The accompanying drawings, which are incorporated in and constitute a part of the specification, illustrate exemplary embodiments, features, and aspects of the disclosure and, together with the description, serve to explain the principles of the disclosure.

[0029] Figure 1 An exemplary application scenario of the code testing method according to an embodiment of the present disclosure is shown.

[0030] Figure 2 A schematic diagram showing the flow of a code testing method according to an embodiment of the present disclosure.

[0031] Figure 3 An example of basic blocks and branches included in the code to be tested and the direction of each branch according to an embodiment of the present disclosure is shown.

[0032] Figure 4 A schematic diagram showing a hit situation of a test case X on a branch of a code to be tested according to an embodiment of the present disclosure.

[0033] Figure 5 A schematic diagram showing the structure of a code testing device according to an embodiment of the present disclosure.

[0034] Figure 6 A block diagram of an electronic device 1900 according to an embodiment of the present disclosure is shown. DETAILED DESCRIPTION

[0035] Various exemplary embodiments, features and aspects of the present disclosure will be described in detail below with reference to the accompanying drawings. The same reference numerals in the accompanying drawings represent elements with the same or similar functions. Although various aspects of the embodiments are shown in the accompanying drawings, the drawings are not necessarily drawn to scale unless otherwise specified.

[0036] The word “exemplary” is used exclusively herein to mean “serving as an example, example, or illustration.” Any embodiment described herein as “exemplary” is not necessarily to be construed as preferred or advantageous over other embodiments.

[0037] In addition, in order to better illustrate the present disclosure, numerous specific details are given in the following specific embodiments. It should be understood by those skilled in the art that the present disclosure can also be implemented without certain specific details. In some examples, methods, means, components and circuits well known to those skilled in the art are not described in detail in order to highlight the subject matter of the present disclosure.

[0038] The following is an introduction to the terms that appear in this article.

[0039] Basic Block (BB): A code segment with only one entry and one exit. The entry is the first statement in the block, and the exit is the last statement in the block. When a basic block is executed, it is entered only from its entry and exited from its exit. All statements in a basic block are executed the same number of times. A basic block is generally composed of multiple sequential execution statements followed by a jump statement, and the jump destination of the jump statement is the first statement of a basic block. When the jump is conditional, the jump destination can be the first statement of multiple basic blocks, but each jump has only one basic block as the jump destination.

[0040] Branch: When the last statement of a basic block is a jump statement, it will jump to the first statement of a basic block. The more basic blocks it jumps to, the more branches it generates. The direction of the branch is the direction of the jump, that is, there is at least one branch between any two basic blocks that have a jump relationship. For example, between basic blocks a and b that have a jump relationship, the possible branches are branches from basic block a to basic block b and / or branches from basic block b to basic block a.

[0041] Seed: The test cases in a test case set are sorted according to priority. When the order determines the number of mutations of the test case, each test case can be called a seed.

[0042] As artificial intelligence technology accumulates over time, various neural network models are becoming more and more complex. In order to run increasingly complex neural network models, powerful computing support is essential, which also poses a huge challenge to the development of the graphics processor field. As a key part of the graphics processor, the compiler of the graphics processor is becoming more and more important, and its quality assurance is essential.

[0043] The programming language used by compilers is highly structured in nature, with many constraints on the compiler's input and output. Traditional testing methods are mainly aimed at low-structured scenarios with fewer constraints on input and output. Therefore, it is very difficult to test highly structured code such as compilers. Therefore, fuzz testing methods are usually used to test highly structured code. The following introduces two fuzz testing methods in the prior art.

[0044] Prior art 1 proposes a random, generative fuzz testing method. This method establishes a corresponding grammar pool for the grammatical rule constraints of different programming languages, constructs corresponding statements through the grammar pool, generates initial test cases using a combination of statements, and randomly mutates the initial test cases. Mutation will replace some statements included in the test case. Random mutation makes this replacement random, so that the mutated test case is different from the one before mutation, and the mutated test case obtained by the same number of mutations for the same test case is also different. Therefore, as long as there is an initial test case, a test case set including a large number of different test cases can be automatically generated. However, the disadvantage of randomness is that there may be many test cases that actually test similar parts, that is, there is redundancy in the test case set, and when the redundancy is too high, the quality of the test case set will be reduced. Most of the prior art still removes redundant test cases manually, which is highly subjective, increases time and labor costs, and has a poor effect on improving the quality of the test case set.

[0045] In addition, most of the code to be tested is actually error-free. The existing technology tests the entire code to be tested with a uniform probability, and does not perform targeted testing on error-prone areas, which will greatly reduce the efficiency of the entire fuzzy test.

[0046] Prior art 2 proposes a directed fuzz testing method, which extracts the basic blocks and branches of the code to be tested that can be tested (hereinafter also referred to as hits) by the test case through static analysis. When the hit basic blocks include the basic blocks of the target area, it is considered that the test case can test the target area. Then, the distance from the hit basic block to the target area is determined according to the hit branch (that is, the total number of basic blocks on the path (including basic blocks and branches) from the hit basic block to the target area), and a weight value is assigned to the basic block according to the distance. A higher weight value is assigned to the basic block with a small distance from the target area, and a lower weight value is assigned to the basic block with a large distance from the target area. The weight of the test case is determined by calculating the sum of the weight values ​​of the basic blocks hit by the test case. The larger the weight of the test case, the greater the number of mutations of the test case, so that the test case that can test the target area in the mutation set can be generated, so that the generated test case is more targeted.

[0047] This method only uses the distance between the basic block and the target area as the only criterion for determining the number of test case mutations, which will result in many test cases with a large distance between the basic block and the target area but can also test the target area, but the number of mutations is relatively low. Since the smaller the distance from the basic block to the target area, the shorter the path from the basic block to the target area, the greater the probability of the short path being hit by different test cases. Therefore, the short path is easy to be tested. Under the premise of giving the test case that hits the short path a larger number of mutations, the number of tests for the short path may be too many, resulting in a waste of test resources. The larger the distance from the basic block to the target area, the longer the path from the basic block to the target area, the lower the probability of the long path being hit by different test cases. Therefore, the long path is not easy to be tested. Under the premise of giving the test case that hits the long path a smaller number of mutations, the number of tests for the long path may be too small and the test is not deep enough, resulting in the failure to discover the deep-seated errors that may exist in the long path. Therefore, the long path is actually more valuable to test than the short path. This method is not accurate enough in determining the number of test case mutations.

[0048] In view of this, the present disclosure proposes a code testing method, device, electronic device and storage medium. The code testing method of the embodiment of the present disclosure quantitatively analyzes the similarity of test cases, objectively determines and deletes redundant test cases in a test case set, reduces time and labor costs, and optimizes the effect of reducing the redundancy of the test case set and improving the quality of the test case set.

[0049] Furthermore, the code testing method of the embodiment of the present disclosure calculates the weight of the test case through a variety of quantitative indicators, and then determines the number of mutations of the test case based on the weight. The determined number of mutations of the test case is more accurate, thereby achieving better testing results.

[0050] Figure 1 An exemplary application scenario of the code testing method according to an embodiment of the present disclosure is shown.

[0051] like Figure 1 As shown, the scenario may include a processor and a memory, the processor runs the test platform, and the memory stores the code to be tested and the test case set written by the developer. The test case set can be written by the developer or generated using the fuzzy testing method of the prior art.

[0052] The processor executes the code testing method of the embodiment of the present disclosure, obtains the code to be tested and the test case set from the memory, analyzes and optimizes the test case set, and then inputs the optimized test case set into the test platform. The test platform uses each test case in the optimized test case set to test the code to be tested respectively, and obtains the test result. According to the test result, it can be analyzed whether the basic block included in the code to be tested has an error. If the basic block included in the code to be tested has an error, the developer can also modify the code to be tested, and then re-execute the code testing method of the embodiment of the present disclosure until the test result meets the developer's needs.

[0053] Figure 2 A schematic diagram showing the flow of a code testing method according to an embodiment of the present disclosure.

[0054] like Figure 2 As shown, in a possible implementation, the method is used to test whether a basic block included in the code to be tested has an error, the code to be tested includes at least one basic block, and any two basic blocks with a jump relationship include at least one branch. The method includes steps S21-S24:

[0055] Step S21, analyzing and determining the hit status of each test case in the test case set on the branch according to the test case set and the code to be tested;

[0056] Step S22, according to the hit situation, using the similarity calculation formula, analyzing the similarity between every two test cases in the test case set, and determining and deleting redundant test cases in the test case set according to the analysis result;

[0057] Step S23, determining the number of mutations of each test case in the test case set according to the hit situation, mutating the test case a corresponding number of times, and adding the mutated test case to the test case set;

[0058] Step S24, using each test case in the test case set to test the code to be tested, and obtaining a test result, the test result indicating whether an error occurs in a basic block included in the code to be tested.

[0059] For example, step S21 can be implemented based on existing technologies. First, in step S21, the code to be tested can be compiled to analyze which basic blocks and branches the code to be tested includes, as well as information such as the direction of each branch, and then each test case in the test case set can be compiled, and the control flow graph (CFG) of the test case can be determined based on the analysis results of the code to be tested. The hit situation of the test case on the branch can indicate which branches the test case hits, the number of hits of each branch, and optionally, the coverage of the branch.

[0060] Figure 3 An example of basic blocks and branches included in the code to be tested and the direction of each branch according to an embodiment of the present disclosure is shown.

[0061] like Figure 3 As shown, each basic block of the code to be tested is a node, and each branch is an edge connecting the two basic blocks corresponding to the branch. The direction of the edge is also the direction of the branch. Among them, branch a_b is an edge connecting basic block a and basic block b, branch b_c is an edge connecting basic block b and basic block c, branch c_d is an edge connecting basic block c and basic block d, branch d_t is an edge connecting basic block d and basic block t, branch t_e is an edge connecting basic block t and basic block e, branch e_f is an edge connecting basic block e and basic block f, branch f_g is an edge connecting basic block f and basic block g, branch b_h is an edge connecting basic block b and basic block h, branch h_q is an edge connecting basic block h and basic block q, branch q_d is an edge connecting basic block q and basic block d, branch t_j is an edge connecting basic block t and basic block j, and branch j_f is an edge connecting basic block j and basic block f.

[0062] The following describes an exemplary method for analyzing the hits of test cases on branches of the code to be tested.

[0063] For example, the code to be tested can be compiled into assembly language code first, and then the code to be tested can be analyzed based on the existing stub technology to determine which basic blocks and branches the code to be tested includes, as well as the direction of the branches. For example, each basic block can be used as an stub point to insert the stub code, and a random number uniquely corresponding to the basic block is generated while the stub code is inserted, as the identifier of the basic block.

[0064] In order to distinguish two branches with different directions between two specific basic blocks (such as the branch from basic block a to basic block b, and the branch from basic block b to basic block a), and to distinguish branches from different basic blocks that use themselves as the jump destination (such as the branch from basic block a to basic block a, and the branch from basic block b to basic block b), after obtaining and storing the bitwise XOR result, the identifier of the current basic block can be shifted right by one bit. In this case, if the current jump is from basic block a to basic block b, and the next jump is from basic block b to basic block a, the bitwise XOR results of the two basic block identifiers are different, thereby distinguishing the two branches with different directions between the two specific basic blocks. Similarly, if the current jump is from basic block a to basic block a, and the next jump is from basic block b to basic block b, the bitwise XOR results of the two times after the shift are also different, thereby distinguishing the branches from different basic blocks that use themselves as the jump destination.

[0065] The test case itself is also code, so an analysis method similar to that of analyzing the code to be tested can be used to analyze the branches and basic blocks hit by the test case, and analyze the branches and basic blocks belonging to the code to be tested, and count the number of hits of the branches. For example, for the two basic blocks corresponding to each branch hit, the basic block that initiates the jump is used as the previous basic block, the basic block jumped to is used as the current basic block, and the bitwise XOR result of the identifiers of the two basic blocks is used as the identifier of the branch to detect the hit of the test case on the branch. A shared memory can be set to store the number of hits of each branch. If it is detected that the branch is hit once, the value at the corresponding position of the branch in the shared memory is increased by 1. The capacity of the shared memory can be set to 64kb to minimize hash conflicts. The present disclosure does not limit the specific capacity of the shared memory. In this case, the shared memory is actually equivalent to a bitmap, and is used to record the number of hits of the test case on the branches of the code to be tested. The coverage of the branch can be equal to the ratio of the number of branches hit by the test case to the total number of branches included in the code to be tested.

[0066] Figure 4 A schematic diagram showing a hit situation of a test case X on a branch of a code to be tested according to an embodiment of the present disclosure.

[0067] Assume that the code to be tested includes Figure 3 The basic blocks and branches shown in Figure 4 As shown in the figure, test case X hits basic blocks a, b, c, d, t, e, f, g, j and branches a_b, b_c, c_d, d_t, t_e, e_f, f_g, t_j, j_f. Assuming that branches a_b, b_c, c_d, d_t, t_e, e_f, t_j, j_f are all hit once, and branch f_g is hit twice, then the number of branches hit by test case X can be equal to 9. Figure 3 In the example, the total number of branches included in the code to be tested is equal to 12, so the branch coverage of test case X can be equal to 9 / 12=75%.

[0068] Those skilled in the art should understand that as long as step S21 can analyze the hit situation of the test case on the branch of the code to be tested, the present disclosure does not limit the specific implementation method of step S21.

[0069] Next, step S22 and step S23 are executed to optimize the test case set. Since the test case set includes a large number of test cases and redundant test cases will greatly reduce the quality of the entire test case set, it is necessary to streamline the test case set. In step S22, the similarity between every two test cases in the test case set can be analyzed based on the hit situation of the branch using a similarity calculation formula. The similarity that can be analyzed refers to the similarity of the branch hit situation of the two test cases. Therefore, the redundant test cases in the test case set are determined and deleted based on the analysis results. It can be considered that there is a redundant test case in the two test cases with too high similarity, and one of them can be deleted. An example of a similarity calculation formula is shown later.

[0070] In step S23, the number of mutations of each test case in the test case set can be determined according to the hit situation of the branch, the test case is mutated a corresponding number of times, and the mutated test case is added to the test case set. When determining the number of mutations of each test case in the test case set, the weight of the test case can be determined first, and then the number of mutations of the test case can be determined based on the weight. It is also possible to further compare the hit situation of the mutated test case on the branch of the code to be tested with the hit situation of the test case set on the branch of the code to be tested, and determine whether the number of mutations of the test case can be further increased. The weight of the test case can use the calculation method of the prior art two, or the new calculation method proposed in the embodiment of the present disclosure, and its example is shown in the further description of step S23 below. An example of further increasing the number of mutations of the test case is given below. The embodiment of the present disclosure does not limit the specific determination method of the number of mutations of the test case.

[0071] In step S24, the test case set can be input into the test platform, and the test platform uses each test case in the test case set to test the code to be tested and obtain the test results. The test platform can be any test platform that can be implemented by the prior art. The code to be tested can be tested based on the prior art, and the test results can be analyzed to determine whether there are any basic blocks with errors in the code to be tested. If all basic blocks have no errors, it can be considered that the code to be tested has met the requirements and does not need to be modified; if there is an error in at least one basic block, the test results can be further analyzed to determine which basic blocks may have errors, and prompt the developer to modify the corresponding basic blocks. After the modification is completed, step S21 and subsequent steps are re-executed. The analysis of the test results can be implemented based on the prior art, which will not be repeated here.

[0072] According to the code testing method of the embodiment of the present disclosure, according to the test case set and the code to be tested, the hit situation of each test case in the test case set on the branch of the code to be tested is analyzed and determined, the code to be tested includes at least one basic block, and any two basic blocks with a jump relationship include at least one branch. According to the hit situation of the branch, the similarity of each two test cases in the test case set is analyzed using a similarity calculation formula, which can improve the accuracy of the similarity analysis of the test case, and the redundant test cases in the test case set are determined and deleted according to the analysis results, so as to optimize the effect of reducing the redundancy of the test case set and improve the quality of the test case set; according to the hit situation of the branch, the number of mutations of each test case in the test case set is determined, the test case is mutated a corresponding number of times, and the mutated test case is added to the test case set to improve the diversity of the test case set. Automatic mutation can reduce labor costs and time costs, and further improve the quality of the test case set; each test case in the test case set is used to test the code to be tested respectively to obtain a test result, and the test result indicates whether an error occurs in the basic block included in the code to be tested, so as to complete the test of the code to be tested. To sum up, the code testing method of the embodiment of the present invention quantitatively analyzes the similarity of test cases, objectively determines and deletes redundant test cases in the test case set, reduces time and labor costs, and optimizes the effect of reducing the redundancy of the test case set and improving the quality of the test case set.

[0073] In a possible implementation manner, the similarity calculation formula includes one or more of a cosine similarity calculation formula, a Jaccard similarity calculation formula, a Euclidean distance similarity calculation formula, and a Pearson similarity calculation formula.

[0074] For example, in the embodiments of the present disclosure, the closer the hit situations of the branches of the code to be tested by two test cases are, the higher the similarity can be considered. In other words, if the difference in the hit situations of the branches of the code to be tested by the two test cases is, the lower the similarity of the two test cases can be considered. The hit situation of the branch can indicate which branches the test case hits, the number of hits of each branch, and the coverage of the branch. The similarity of the hit situation of the branch can be calculated based on which branches the test case hits, and at least one of the number of hits of each branch and the coverage of the branch. Taking the cosine similarity calculation formula as an example, the following gives an example of using the similarity calculation formula to analyze the similarity of each two test cases in the test case set.

[0075] The cosine similarity calculation formula is shown in formula (1).

[0076] (1)

[0077] In formula (1), Xi represents the number of times test case X hits branch i, Yi represents the number of times test case Y hits branch i, and m represents the total number of the same branches hit by test case X and test case Y. similarity represents the similarity between test case X and test case Y (i.e., the analysis result).

[0078] If the similarity between test case X and test case Y is greater than a preset threshold, such as 0.9, it can be considered that the similarity between test case X and test case Y is high, and one of the test cases is a redundant test case. You can select any one of the test cases to delete. You can also select to delete the test case with a lower branch coverage by comparing the branch coverage of the two. The disclosed embodiment does not limit the specific value of the preset threshold or which test case to delete when the similarity between two test cases is greater than the preset threshold.

[0079] If the similarity between test case X and test case Y is less than or equal to a preset threshold, such as 0.9, it can be considered that the similarity between test case X and test case Y is low, and the similarity of other test cases can be analyzed. After the similarity of each pair of test cases is analyzed and redundant test cases are deleted, a streamlined test case set is obtained.

[0080] It is understandable that other similarity calculation formulas in the prior art, such as the Jaccard similarity calculation formula, the Euclidean distance similarity calculation formula, the Pearson similarity calculation formula, etc., can also be applied to the similarity analysis of test cases, and no further examples are given here.

[0081] In order to further improve the accuracy of the determined similarity, multiple similarity calculation formulas can be used to analyze the similarity of each two test cases in the test case set, and then the calculation results of each similarity calculation formula are weighted and summed, and the weights can be set according to the application scenario requirements. In this case, the analysis result can be the weighted sum of the calculation results of each similarity calculation formula. The embodiment of the present disclosure does not limit the type and number of similarity calculation formulas used.

[0082] The following describes an exemplary method for determining the number of mutations of a test case according to an embodiment of the present disclosure.

[0083] In a possible implementation, the method further includes:

[0084] According to the historical test results of the code to be tested, the basic blocks where errors occurred in the code to be tested are determined;

[0085] Determine the target area based on the basic blocks where errors occurred;

[0086] Step S23 includes:

[0087] Determine the weight of each test case in the test case set based on the hit situation and target area;

[0088] According to the weight of each test case in the test case set, a first mutation number of the test case is determined, and the test case is mutated the first mutation number of times.

[0089] For example, this test may not be the first test for the code to be tested. After the code to be tested was tested before, the erroneous basic blocks may have been analyzed. In this case, the erroneous basic blocks indicated by the historical test results of the code to be tested can be directly tested. That is, first determine the basic blocks in the code to be tested that have errors based on the historical test results of the code to be tested. The basic blocks with errors can be sorted in descending order of error frequency, and the top P basic blocks can be selected and determined as the target area. The value of P can be set according to the application scenario requirements, and the present disclosure does not limit this.

[0090] In step S23, the weight of each test case in the test case set can be determined based on the hit situation of the branch and the target area. When the test case does not hit the target area, it will not hit the branch connecting the target area. The weight of the test case can be equal to the initial value (for example, 0). When the test case hits the target area, it must also hit the branch connecting the basic block in the target area. At this time, the weight of the test case can be greater than the initial value. Its value is related to the average distance of the seed and the value of the test case. Its exemplary calculation method can be found in the relevant description below. Afterwards, the first mutation number of the test case can be determined based on the weight of each test case in the test case set. The first mutation number of the test case with a larger weight is larger. Then, the test case is mutated by the first mutation number, and the mutated test case is added to the test case set.

[0091] In one example, when determining the first number of mutations according to the weights, the weights of each test case can be normalized first. One reason is to summarize the statistical distribution of the unified sample, and the other is that after the weights are normalized, the number of mutations of each test case can be calculated more quickly and conveniently. The weight of each test case is divided by the sum of the weights of each test case according to the current case weight, and then scaled to the interval between 0 and 1. The scaled weight is the mutation probability value of each test case. An interval of mutation number values ​​is preset, and the mutation probability value is mapped to the interval of mutation number values. The mapped mutation number value is also the first mutation number. In this way, the first mutation number corresponding to the test case with a large mutation probability is also large. The interval size of the mutation number value can be set according to the application scenario requirements, and the embodiment of the present disclosure does not limit the interval size of the mutation number value.

[0092] Since in actual applications the number of basic blocks with errors in the code to be tested is often relatively small, far less than the number of correct basic blocks, in this way, the disclosed embodiment can use the error-prone basic blocks as the target area for testing to implement directed fuzzy testing, which is more targeted and can reach the target area of ​​the error more quickly without blindly testing and wasting too much testing time on those correct basic blocks, thereby greatly improving the efficiency of the test.

[0093] The following describes an exemplary method for determining the weight of a test case according to an embodiment of the present disclosure.

[0094] In a possible implementation, the method further includes:

[0095] Analyze and determine the hit status of the test case set on the branch according to the hit status of each test case in the test case set on the branch;

[0096] Determine the weight of each test case in the test case set based on the hit situation and target area, including:

[0097] For each test case in the test case collection,

[0098] According to the hit situation of the test case on the branch and the target area, the seed average distance index of the test case is calculated, and the seed average distance index indicates the correlation degree between the test case and the target area;

[0099] Calculate a first value index of the test case according to the hit condition of the test case on the branch, where the first value index indicates the test value of the test case itself;

[0100] According to the hit situation of the test case on the branch and the hit situation of the test case set on the branch, a second value indicator of the test case is calculated, and the second value indicator indicates the test value of the test case in the test case set;

[0101] The weight of the test case is determined according to at least one of the seed average distance index, the first value index, and the second value index of the test case.

[0102] For example, the embodiments of the present disclosure may determine three indicators that have an impact on the weight of a test case, namely, an average seed distance indicator of the test case, a first value indicator, and a second value indicator.

[0103] Among them, the seed average distance index can be calculated based on the test case's hits on the branch and the target area, and indicates the degree of association between the test case and the target area. The smaller the seed average distance index, the stronger the degree of association between the test case and the target area, and the greater the probability that its test content is tested by multiple test cases. The larger the seed average distance index, the weaker the degree of association between the test case and the target area, and the smaller the probability that its test content is tested by multiple test cases.

[0104] The first value index can be calculated based on the hits of the test case on the branch, and indicates the test value of the test case itself. The larger the first value index, the greater the value of the test case. The fewer times the test case hits the branches it hits, the smaller the probability that these hit branches will be hit by other test cases. The test case itself has a higher value, and the first value index of the test case is larger.

[0105] The second value indicator can be calculated based on the hits of the test case on the branch and the hits of the test case set on the branch, and indicates the test value of the test case in the test case set. In the test case set, when test case X hits more long paths than test case Y, the value of test case X is higher than that of test case Y, and the second value indicator of test case X can be greater than the second value indicator of test case Y.

[0106] The following describes an exemplary method for determining the hit status of a test case set on a branch.

[0107] For example, what is analyzed in step S21 is the hit situation of each test case in the test case set on the branches of the code to be tested. If the test case set is regarded as a whole, then what is obtained in step S21 is essentially the hit situation of the local test case set on the branches of the code to be tested. By integrating the hit situation of each test case in the test case set on the branches of the code to be tested, and taking the union of the branches hit by different test cases, it is possible to obtain which branches of the code to be tested are hit by the global test case set; the number of hits of different test cases on the same branch is accumulated together to obtain the number of hits of the global test case set on each branch of the code to be tested; the total number of branches of the code to be tested hit by the global test case set is calculated, and the total number of branches is divided by the total number of branches of the code to be tested to calculate the branch coverage of the code to be tested by the global test case set, thereby determining the hit situation of the branches of the code to be tested by the global test case set.

[0108] Exemplary determination methods of the seed average distance indicator, the first value indicator, and the second value indicator are given later. The present disclosure can calculate the weight of the test case according to at least one of the above three indicators. When the weight is calculated only according to the seed average distance indicator, the test has a more targeted effect; when the weight is calculated only according to at least one of the first value indicator and the second value indicator, the test depth and the probability of discovering deep-seated problems in the test are increased; when the weight is calculated according to the seed average distance indicator and at least one of the first value indicator and the second value indicator, the test has a more targeted effect, the test depth and the probability of discovering deep-seated problems in the test are increased, and the weight calculation accuracy is higher. Examples of calculating weights using different indicators and different combinations of indicators are given later.

[0109] Those skilled in the art should understand that they can choose which indicators to use to calculate the weights according to the application scenario requirements, and based on this, they can specifically calculate the indicators to be used. Those skilled in the art do not limit the specific indicators used to calculate the weights. Taking test case X as an example, the following introduces exemplary determination methods of the seed average distance indicator, the first value indicator, and the second value indicator of the test case.

[0110] In one possible implementation,

[0111] According to the test case's hits on the branch and the target area, the average seed distance index of the test case is calculated, including:

[0112] According to the hits of the test case on the branch and the target area, the paths with the basic blocks hit by the test case as nodes and passing through the target area are counted, and the nodes include the starting point, the end point and the passing point of the path;

[0113] For each basic block in each path counted, the number of branches between the basic block and the target area on the path is calculated;

[0114] The ratio of the sum of the number of branches between each basic block in each path and the target region on the path to the total number of basic blocks included in the path is used as the distance index of the path;

[0115] The average value of the distance index of the statistically obtained paths is determined as the seed average distance index of the test case.

[0116] In one example, assume that the code to be tested includes basic blocks and branches such as Figure 3 As shown, the hits of test case X on the branches of the code to be tested are as follows Figure 4 As shown, the target area is basic block t. Figure 4, count the paths that pass through the target area with the basic blocks hit by test case X as nodes, and the nodes include the starting point, end point and path point of the path. The paths that meet the above conditions can be path S1: a->b->c->d->t->e->f->g, path S2: a->b->c->d->t->j->f->g.

[0117] Then the number of branches between basic block a and target region t in path S1 may be equal to 4, the number of branches between basic block b and target region t may be equal to 3, the number of branches between basic block c and target region t may be equal to 2, the number of branches between basic block d and target region t may be equal to 1, the number of branches between basic block t and target region t may be equal to 0, the number of branches between basic block e and target region t may be equal to 1, the number of branches between basic block f and target region t may be equal to 2, and the number of branches between basic block g and target region t may be equal to 3. The sum of the number of branches between each basic block in path S1 and target region t is equal to 4+3+2+1+0+1+2+3=16. The total number of basic blocks included in path S1 may be equal to 8, so the distance index of path S1 may be equal to the ratio of the sum of the number of branches between each basic block in path S1 and target region t to the total number of basic blocks included in path S1, that is, 16 / 8=2.

[0118] The number of branches between basic block a and target region t in path S2 may be equal to 4, the number of branches between basic block b and target region t may be equal to 3, the number of branches between basic block c and target region t may be equal to 2, the number of branches between basic block d and target region t may be equal to 1, the number of branches between basic block t and target region t may be equal to 0, the number of branches between basic block j and target region t may be equal to 1, the number of branches between basic block f and target region t may be equal to 2, and the number of branches between basic block g and target region t may be equal to 3. The sum of the number of branches between each basic block in path S2 and target region t is equal to 4+3+2+1+0+1+2+3=16. The total number of basic blocks included in path S2 may be equal to 8, so the distance index of path S2 may be equal to the ratio of the sum of the number of branches between each basic block in path S2 and target region t to the total number of basic blocks included in path S2, that is, 16 / 8=2.

[0119] The average value of the distance index of path S1 and the distance index of path S2 (2+2) / 2=2 is used as the seed average distance index of test case X.

[0120] In another example, suppose the code under test includes basic blocks and branches such as Figure 3 As shown, the hits of test case X on the branches of the code to be tested are as follows Figure 4 As shown, the target area is basic block t and basic block c. Figure 4, count the paths that pass through the target area with the basic blocks hit by test case X as nodes, and the nodes include the starting point, end point and path point of the path. The paths that meet the above conditions can be path S1: a->b->c->d->t->e->f->g, path S2: a->b->c->d->t->j->f->g.

[0121] For each path, a distance index can be calculated for each basic block in the target area. For example, for path S1, a distance index corresponding to basic block t as the target area and a distance index corresponding to basic block c as the target area can be calculated. For path S2, a distance index corresponding to basic block t as the target area can be calculated. The calculation method of the distance index has been described above and will not be repeated here. The average value of the distance index can be used as the seed average distance index of test case X.

[0122] In a possible implementation, calculating the first value indicator of the test case according to the hit status of the test case on the branch includes:

[0123] According to the hit situation of the test case on the branch, determine the variance of the hit times of each branch hit by the test case itself and the sum of the hit times of each branch hit by the test case;

[0124] The ratio of the variance to the sum is used as the first value indicator.

[0125] For example, first, based on the hits of each test case in the test case set on the branches of the code to be tested, the variance of the hit counts of each branch hit by the test case and the sum of the hit counts of each branch hit by the test case can be determined. If the hit counts of all branches hit by test case Y are relatively high and close, and the hit counts of all branches hit by test case X are relatively low and close, a branch has a high hit count in a certain test case, which means that the remaining test cases are likely to hit the branch in large numbers. Therefore, the value of test case X itself is higher than the value of test case Y itself. Therefore, the first value indicator of the test case can be calculated based on formula (2):

[0126] (2)

[0127] In formula (2), V represents the first value indicator, D(X) represents the variance of the number of hits of the test case on each branch hit by itself, F(i) represents the number of hits of the test case on branch i, and n represents the total number of branches hit by the test case.

[0128] In this case, when the hit counts of all branches hit by test case Y are relatively high and close, and the hit counts of all branches hit by test case X are relatively low and close, the denominator of the first value index of test case Y is relatively large, the denominator of the first value index of test case X is relatively small, and the numerators of the first value indexes of test case Y and test case X are similar. At this time, the first value index of test case X can be greater than the first value index of test case Y, so that the first value index can accurately represent the value of the test case itself. That is, the test case with a low branch hit count has a higher value.

[0129] In a possible implementation, calculating the second value indicator of the test case according to the hit condition of the test case on the branch and the hit condition of the test case set on the branch includes:

[0130] According to the hits of the test case set on the branches, the branches of the code to be tested are sorted in the order of the number of times each branch is hit by the test case set;

[0131] According to the sorting results of the branches, determine the rarity threshold corresponding to the test case set;

[0132] According to the hit situation of the test case on the branch, determine the total number of branches hit by the test case and the number of hits is less than the rarity threshold;

[0133] According to the hit situation of the test case on the branch, determine the total number of branches hit by the test case;

[0134] The second value indicator is determined according to the total number of branches hit less than the rarity threshold among the branches hit by the test case and the total number of branches hit by the test case.

[0135] For example, the first value indicator is only related to a single test case. To improve the comprehensiveness of the evaluation of the test case value, a second value indicator that can indicate the test value of the test case in the test case set can be further calculated.

[0136] First, according to the hits of the test case set on the branches of the code to be tested, all branches hit by the test case set can be sorted from high to low according to the hit counts. According to the sorting results of the branches, the rarity threshold corresponding to the test case set is determined.

[0137] For example, suppose the code to be tested includes 5 branches, and the number of times the 1st to 5th branches are hit by the test case set is 1, 2, 3, 4, and 0 respectively. If they are sorted in ascending order, the sorting result of the 5 branches can be: the 5th branch, the 1st branch, the 2nd branch, the 3rd branch, and the 4th branch.

[0138] A probability value can be preset according to the number of branches included in the code to be tested, which is used to calculate the rarity threshold corresponding to the test case set. For example, when the code to be tested includes K branches, the probability value can be set to Q / K, where 0<Q<K, and Q and K are integers. The number of hits of the branches ranked at the top Q / K in the sorting result can be used as the rarity threshold. For example, when K=5 and Q=1, the probability value is equal to 20%. If the branch ranked at the top 20% in the sorting result is the 5th branch, the number of hits of the 5th branch, 0, can be used as the rarity threshold. If K=5 and Q=2, the probability value is equal to 40%. If the branch ranked at the top 40% in the sorting result is the 1st branch, the number of hits of the 1st branch, 1, can be used as the rarity threshold.

[0139] The probability value can be set according to the application scenario requirements. For example, when the code to be tested is the code of a compiler, the probability value can be set according to the type of the compiler. The embodiments of the present disclosure do not limit the specific numerical value of the probability value and the specific method of setting the probability value.

[0140] It is understandable that if the order of sorting is from large to small, the hit count of the branch of Q / K ranked last in the sorting result can be used as the rarity threshold. The embodiment of the present disclosure does not limit the specific order of sorting.

[0141] After determining the rarity threshold corresponding to the test case set, the total number of branches hit less than the rarity threshold can be determined among the branches hit by the test case based on the hits of each test case on the branches of the code to be tested. These branches can be considered rare branches. The total number of branches hit by the test case can be determined based on the hits of the test case on the branches of the code to be tested. The second value index can be calculated using formula (3):

[0142] S=L×r U (3)

[0143] In formula (3), S represents the second value indicator, L represents the total number of branches hit by the test case, U represents the total number of branches hit less than the rarity threshold among the branches hit by the test case (that is, the total number of rare branches hit by the test case), and r can be a constant greater than 1, for example, it can be set to 2.

[0144] According to formula (3), when the total number of branches hit by a test case is constant, the more rare branches are hit, the larger the second value index is. That is, the test case with more rare branches hit has a larger second value index than the test case with fewer rare branches hit. In this way, the second value index can accurately represent the value of the test case in the test case set.

[0145] The following are several examples of calculating weights based on different indicators and different combinations of indicators.

[0146] When only the seed average distance index is used to calculate the weight, the weight may be equal to the product of the inverse of the seed average distance index and the proportional coefficient of the seed average distance index. In this case, the smaller the seed average distance index is, the greater the weight is.

[0147] When only the first value indicator (or the second value indicator) is used to calculate the weight, the weight may be equal to the product of the first value indicator (or the second value indicator) and the proportional coefficient of the first value indicator (or the second value indicator). In this case, the larger the first value indicator (or the second value indicator), the greater the weight.

[0148] When the first value index and the second value index are used to calculate the weight, the weight may be equal to the product of the first value index, the proportional coefficient of the first value index, the second value index, and the proportional coefficient of the second value index. In this case, the larger the first value index / the second value index, the greater the weight.

[0149] When the seed average distance index and the first value index are used to calculate the weight, the weight may be equal to the product of the first value index, the proportional coefficient of the first value index, the inverse of the seed average distance index, and the proportional coefficient of the seed average distance index. At this time, the smaller the seed average distance index is, the greater the weight is, and the larger the first value index is, the greater the weight is.

[0150] When using the seed average distance index and the second value index to calculate the weight, the weight can be equal to the product of the second value index, the proportional coefficient of the second value index, the inverse of the seed average distance index, and the proportional coefficient of the seed average distance index. At this time, the smaller the seed average distance index is, the greater the weight is, and the larger the second value index is, the greater the weight is.

[0151] When the seed average distance index, the first value index and the second value index are used to calculate the weight, the weight may be equal to the product of the first value index, the proportional coefficient of the first value index, the second value index, the proportional coefficient of the second value index, the inverse of the seed average distance index and the proportional coefficient of the seed average distance index. As shown in formula (4):

[0152] W=(x×V)×(y×S)×(z×(1 / D)) (4)

[0153] In formula (4), W represents the weight of the test case, D represents the seed average distance index, V represents the first value index, S represents the second value index, x is the proportional coefficient of the first value index V, y is the proportional coefficient of the second value index S, and z is the proportional coefficient of the inverse of the seed average distance index 1 / D. At this time, the smaller the seed average distance index is, the greater the weight is, the larger the first value index is, and the larger the second value index is, the greater the weight is. The specific values ​​of the proportional coefficients of each indicator in formula (4) can be set according to the application scenario requirements, and this disclosure does not limit this.

[0154] When using at least one of the first value indicator and the second value indicator, and the seed average distance indicator to calculate the weight, the weight W is related to the value of the test case itself, the value of the test case in the test case set, and the degree of association between the test case and the target area. Test cases that are more targeted at testing the target area can get higher weights, and test cases that hit more rare branches can also get more weights, so the mutation effect of the test cases is better.

[0155] An exemplary method for determining the number of mutations of a test case is described below.

[0156] In a possible implementation, step S23 includes:

[0157] According to any test case and the code to be tested that have undergone the first number of mutations, analyzing the hit status of the test case on the branch;

[0158] When at least one branch hit by the test case is different from the branches hit by the test case set before the mutation, determining a second mutation number of the test case;

[0159] The test case is mutated a second number of times, and the mutated test case is added to the test case set.

[0160] For example, due to the randomness of mutation, a test case may hit a branch that has been hit by the test case set, or may hit a new branch that has not been hit by the test case set. When hitting a new branch that has not been hit by the test case set, the test case has a higher value. The test case can continue to mutate, that is, the number of mutations of the test case can be further increased.

[0161] Therefore, after a test case has been mutated for the first number of mutations, the hits of the test case on the branches of the code to be tested can be analyzed based on the test case and the code to be tested. The exemplary analysis method is the same as the analysis method of the hits of the branches of the code to be tested before the test case is mutated, and will not be repeated here.

[0162] Afterwards, based on the hit situation of the test case on the branches of the code to be tested, and the hit situation of each test case in the test case set before mutation on the branches of the code to be tested, it can be analyzed whether the test case hits a new branch that has not been hit by the test case set before mutation. When at least one branch hit by the test case is different from the branches hit by the test case set before mutation, it is considered that the test case hits a new branch that has not been hit by the test case set before mutation, and the second mutation number of the test case can be determined. The second mutation number can be preset as a fixed value, or it can be determined based on the number of the at least one branch, so that the second mutation number is larger when the number of at least one branch is larger. The embodiment of the present disclosure does not limit the specific value of the second mutation number.

[0163] Then, the test case is mutated for a second number of mutations, and the mutated test case is added to the test case set.

[0164] The mutation of the test case can be a random subtree mutation, that is, the test case set is regarded as a complete tree, each test case is regarded as a subtree, and when a test case is selected for mutation, part or all of the content of other test cases is randomly cut and added to the selected test case. Mutation can also be achieved by other methods that can be realized by existing technologies, and the embodiments of the present disclosure do not limit the specific mutation method.

[0165] In this way, the number of mutations can be adjusted dynamically, thereby improving the flexibility of the adjustment method of the number of mutations.

[0166] An example of the differential test method mentioned in step S24 is described below.

[0167] For example, when performing differential testing on a test case, the test can be conducted in a scenario where only one test condition is different and the other test conditions are the same.

[0168] In a possible implementation, the code to be tested is a compiler code. The code to be tested may also be other highly structured codes or low-structured codes. The present disclosure does not limit the degree of structure of the code to be tested.

[0169] Here are some examples of differential testing when the code to be tested is compiler code.

[0170] For example, different test conditions may be such that the compiler types corresponding to the code to be tested are different.

[0171] For another example, different test conditions can be optimized at different levels, and the compiler type is the same. Different optimization levels can have different degrees of optimization for the code under test. For example, the first level may not perform any optimization, which is also the default optimization method of the compiler. The second level can mainly optimize the branches, constants used, and expressions of the code under test, which will increase the compilation time cost less; the third level can optimize the register transfer level and the instruction transfer level based on the optimization of the second level, which will occupy more memory and further increase the compilation time cost; the fourth level can continue to optimize the pseudo-register network, the inlining of ordinary functions, the loop function, etc. based on the optimization of the third level, which will further increase the memory usage and compilation time cost.

[0172] For another example, different test conditions may be different versions of the compiler, while the types of the compilers are the same.

[0173] Those skilled in the art should understand that there are more options for differential testing, and other testing methods other than differential testing may also be used for testing. The embodiments of the present disclosure do not limit the specific testing method.

[0174] After the test results are obtained, the hash checksum of the global variables can be calculated and compared with the expected value to determine whether the code to be tested is wrong, and then the cause of the compiler error can be located by analyzing the basic block where the error occurs, etc. This step can be implemented based on the existing technology and will not be repeated here.

[0175] Figure 5 A schematic diagram showing the structure of a code testing device according to an embodiment of the present disclosure.

[0176] like Figure 5 As shown, in a possible implementation, the present disclosure further proposes a code testing device, the device is used to test whether a basic block included in the code to be tested has an error, the code to be tested includes at least one basic block, and any two basic blocks with a jump relationship include at least one branch, the device includes:

[0177] A first analysis module 51 is used to analyze and determine the hit status of each test case in the test case set on the branch according to the test case set and the code to be tested;

[0178] A second analysis module 52 is used to analyze the similarity of every two test cases in the test case set according to the hit situation using a similarity calculation formula, and determine and delete redundant test cases in the test case set according to the analysis result;

[0179] A mutation module 53, used to determine the mutation times of each test case in the test case set according to the hit situation, mutate the test case a corresponding number of times, and add the mutated test case to the test case set;

[0180] The testing module 54 is used to use each test case in the test case set to test the code to be tested respectively to obtain a test result, wherein the test result indicates whether an error occurs in a basic block included in the code to be tested.

[0181] In a possible implementation manner, the similarity calculation formula includes one or more of a cosine similarity calculation formula, a Jaccard similarity calculation formula, a Euclidean distance similarity calculation formula, and a Pearson similarity calculation formula.

[0182] In a possible implementation manner, the device further includes:

[0183] A first determining module, configured to determine a basic block in which an error has occurred in the code to be tested according to a historical test result of the code to be tested;

[0184] A second determination module is used to determine a target area according to the basic block where an error occurred;

[0185] The step of determining the number of mutations of each test case in the test case set according to the hit situation, and performing a corresponding number of mutations on the test case, comprises:

[0186] Determining a weight of each test case in the test case set according to the hit situation and the target area;

[0187] According to the weight of each test case in the test case set, a first mutation number of the test case is determined, and the test case is mutated the first mutation number of times.

[0188] In a possible implementation manner, the device further includes:

[0189] A third analysis module, configured to analyze and determine the hit situation of the test case set on the branch according to the hit situation of each test case in the test case set on the branch;

[0190] Determining the weight of each test case in the test case set according to the hit situation and the target area includes:

[0191] For each test case in the test case set,

[0192] Calculating a seed average distance index of the test case according to the hit status of the test case on the branch and the target area, wherein the seed average distance index indicates the degree of association between the test case and the target area;

[0193] Calculating a first value indicator of the test case according to the hit status of the test case on the branch, wherein the first value indicator indicates the test value of the test case itself;

[0194] According to the hit situation of the test case on the branch and the hit situation of the test case set on the branch of the code to be tested, a second value indicator of the test case is calculated, wherein the second value indicator indicates the test value of the test case in the test case set;

[0195] The weight of the test case is determined according to at least one of the seed average distance index, the first value index, and the second value index of the test case.

[0196] In a possible implementation, calculating the seed average distance index of the test case according to the hit status of the test case on the branch and the target area includes:

[0197] According to the hit status of the test case on the branch and the target area, counting the paths that have the basic blocks hit by the test case as nodes and pass through the target area, wherein the nodes include the starting point, the end point and the passing point of the path;

[0198] For each basic block in each path counted, the number of branches between the basic block and the target area on the path is calculated;

[0199] The ratio of the sum of the number of branches between each basic block in each path and the target region on the path to the total number of basic blocks included in the path is used as the distance index of the path;

[0200] The average value of the distance index of the statistically obtained paths is determined as the seed average distance index of the test case.

[0201] In a possible implementation, calculating the first value indicator of the test case according to the hit status of the test case on the branch includes:

[0202] According to the hit situation of the test case on the branch, determine the variance of the hit times of each branch hit by the test case itself and the sum of the hit times of each branch hit by the test case;

[0203] The ratio of the variance to the sum is used as the first value indicator.

[0204] In a possible implementation, calculating the second value indicator of the test case according to the hit condition of the test case on the branch and the hit condition of the test case set on the branch includes:

[0205] According to the hit status of the test case set on the branches, the branches of the code to be tested are sorted in the order of the number of times each branch is hit by the test case set;

[0206] Determining a rarity threshold corresponding to the test case set according to the sorting results of the branches;

[0207] According to the hit situation of the test case on the branch, determine the total number of branches hit by the test case and the number of hits is less than the rarity threshold;

[0208] According to the hit situation of the test case on the branches, determining the total number of branches hit by the test case;

[0209] The second value indicator is determined according to the total number of branches hit less than the rarity threshold among the branches hit by the test case and the total number of branches hit by the test case.

[0210] In a possible implementation, determining the number of mutations of each test case in the test case set according to the hit situation, and mutating the test case a corresponding number of times includes:

[0211] According to any test case that has undergone a first number of mutations and the code to be tested, analyzing the hit status of the test case on the branch;

[0212] When at least one branch hit by the test case is different from the branches hit by the test case set before the mutation, determining a second mutation number of the test case;

[0213] The test case is mutated a second number of times, and the mutated test case is added to the test case set.

[0214] In a possible implementation manner, the code to be tested is a compiler code.

[0215] In some embodiments, the functions or modules included in the device provided by the embodiments of the present disclosure can be used to execute the method described in the above method embodiments. The specific implementation can refer to the description of the above method embodiments, and for the sake of brevity, it will not be repeated here.

[0216] The embodiment of the present disclosure also provides a computer-readable storage medium on which computer program instructions are stored, and the computer program instructions implement the above method when executed by a processor. The computer-readable storage medium can be a volatile or non-volatile computer-readable storage medium.

[0217] An embodiment of the present disclosure further proposes an electronic device, comprising: a processor; and a memory for storing instructions executable by the processor; wherein the processor is configured to implement the above method when executing the instructions stored in the memory.

[0218] The embodiments of the present disclosure also provide a computer program product, including a computer-readable code, or a non-volatile computer-readable storage medium carrying the computer-readable code. When the computer-readable code runs in a processor of an electronic device, the processor in the electronic device executes the above method.

[0219] Figure 6 1 is a block diagram of an electronic device 1900 according to an embodiment of the present disclosure. For example, the electronic device 1900 may be provided as a server or a terminal device. Figure 6 , the electronic device 1900 includes a processing component 1922, which further includes one or more processors, and a memory resource represented by a memory 1932 for storing instructions executable by the processing component 1922, such as an application. The application stored in the memory 1932 may include one or more modules, each corresponding to a set of instructions. In addition, the processing component 1922 is configured to execute instructions to perform the above method.

[0220] The electronic device 1900 may also include a power supply component 1926 configured to perform power management of the electronic device 1900, a wired or wireless network interface 1950 configured to connect the electronic device 1900 to a network, and an input / output interface 1958 (I / O interface). The electronic device 1900 may operate based on an operating system stored in the memory 1932, such as Windows Server 2000. TM , Mac OS X TM , Unix TM , Linux TM , FreeBSD TM or similar.

[0221] In an exemplary embodiment, a non-volatile computer-readable storage medium is also provided, such as a memory 1932 including computer program instructions, which can be executed by the processing component 1922 of the electronic device 1900 to perform the above method.

[0222] The present disclosure may be a system, a method and / or a computer program product. The computer program product may include a computer-readable storage medium carrying computer-readable program instructions for causing a processor to implement various aspects of the present disclosure.

[0223] A computer-readable storage medium may be a tangible device that can hold and store instructions used by an instruction execution device. A computer-readable storage medium may be, for example, but not limited to, an electrical storage device, a magnetic storage device, an optical storage device, an electromagnetic storage device, a semiconductor storage device, or any suitable combination of the above. More specific examples (a non-exhaustive list) of computer-readable storage media include: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a static random access memory (SRAM), a portable compact disk read-only memory (CD-ROM), a digital versatile disk (DVD), a memory stick, a floppy disk, a mechanical encoding device, such as a punch card or a raised structure in a groove on which instructions are stored, and any suitable combination of the above. The computer-readable storage medium used herein is not to be interpreted as a transient signal itself, such as a radio wave or other freely propagating electromagnetic wave, an electromagnetic wave propagating through a waveguide or other transmission medium (e.g., a light pulse through a fiber optic cable), or an electrical signal transmitted through a wire.

[0224] The computer-readable program instructions described herein can be downloaded from a computer-readable storage medium to each computing / processing device, or downloaded to an external computer or external storage device via a network, such as the Internet, a local area network, a wide area network, and / or a wireless network. The network can include copper transmission cables, optical fiber transmissions, wireless transmissions, routers, firewalls, switches, gateway computers, and / or edge servers. The network adapter card or network interface in each computing / processing device receives the computer-readable program instructions from the network and forwards the computer-readable program instructions for storage in the computer-readable storage medium in each computing / processing device.

[0225] The computer program instructions for performing the operations of the present disclosure may be assembly instructions, instruction set architecture (ISA) instructions, machine instructions, machine-dependent instructions, microcode, firmware instructions, state setting data, or source code or object code written in any combination of one or more programming languages, including object-oriented programming languages, such as Smalltalk, C++, etc., and conventional procedural programming languages, such as "C" language or similar programming languages. The computer-readable program instructions may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer, partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., using an Internet service provider to connect through the Internet). In some embodiments, by using the state information of the computer-readable program instructions to personalize an electronic circuit, such as a programmable logic circuit, a field programmable gate array (FPGA), or a programmable logic array (PLA), the electronic circuit may execute the computer-readable program instructions, thereby implementing various aspects of the present disclosure.

[0226] Various aspects of the present disclosure are described herein with reference to flowcharts and / or block diagrams of methods, devices (systems) and computer program products according to embodiments of the present disclosure. It should be understood that each box in the flowchart and / or block diagram and the combination of boxes in the flowchart and / or block diagram can be implemented by computer-readable program instructions.

[0227] These computer-readable program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, thereby producing a machine, so that when these instructions are executed by the processor of the computer or other programmable data processing device, a device that implements the functions / actions specified in one or more boxes in the flowchart and / or block diagram is generated. These computer-readable program instructions can also be stored in a computer-readable storage medium, and these instructions cause the computer, programmable data processing device, and / or other equipment to work in a specific manner, so that the computer-readable medium storing the instructions includes a manufactured product, which includes instructions for implementing various aspects of the functions / actions specified in one or more boxes in the flowchart and / or block diagram.

[0228] Computer-readable program instructions may also be loaded onto a computer, other programmable data processing apparatus, or other device so that a series of operating steps are performed on the computer, other programmable data processing apparatus, or other device to produce a computer-implemented process, thereby causing the instructions executed on the computer, other programmable data processing apparatus, or other device to implement the functions / actions specified in one or more boxes in the flowchart and / or block diagram.

[0229] The flow chart and block diagram in the accompanying drawings show the possible architecture, function and operation of the system, method and computer program product according to multiple embodiments of the present disclosure. In this regard, each square box in the flow chart or block diagram can represent a part of a module, program segment or instruction, and a part of the module, program segment or instruction includes one or more executable instructions for realizing the specified logical function. In some alternative implementations, the function marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two continuous square boxes can actually be executed substantially in parallel, and they can sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs the specified function or action, or can be implemented with a combination of special hardware and computer instructions.

[0230] The embodiments of the present disclosure have been described above, and the above description is exemplary, not exhaustive, and is not limited to the disclosed embodiments. Many modifications and changes will be apparent to those of ordinary skill in the art without departing from the scope and spirit of the described embodiments. The selection of terms used herein is intended to best explain the principles of the embodiments, practical applications, or technical improvements in the market, or to enable other persons of ordinary skill in the art to understand the embodiments disclosed herein.

Claims

1. A code testing method, It is characterized in that The method is used to test whether a basic block included in a code to be tested has an error, the code to be tested includes at least one basic block, and at least one branch is included between any two basic blocks that have a jump relationship, and the method includes: According to the test case set and the code to be tested, analyzing and determining the hit status of each test case in the test case set on the branch; According to the hit situation, using a similarity calculation formula, analyzing the similarity of every two test cases in the test case set, and determining and deleting redundant test cases in the test case set according to the analysis result; According to the hit situation, determining the number of mutations of each test case in the test case set, mutating the test case a corresponding number of times, and adding the mutated test case to the test case set; Using each test case in the test case set to test the code to be tested respectively, to obtain a test result, wherein the test result indicates whether an error occurs in a basic block included in the code to be tested; The step of determining the number of mutations of each test case in the test case set according to the hit situation, and performing a corresponding number of mutations on the test case, comprises: Determine the weight of each test case in the test case set according to the hit situation and the target area, wherein the target area is determined according to the basic block in which an error occurred in the code to be tested; Determine a first mutation number of the test case according to the weight of each test case in the test case set, and mutate the test case the first mutation number; The weight is determined based on at least one of a seed average distance index indicating the degree of association between the test case and the target area, a first value index indicating the test value of the test case itself, and a second value index indicating the test value of the test case in the test case set. When the weight is determined based on the first value index, the fewer the number of hits of the test case on the branches it hits, the greater the first value index of the test case, and the greater the weight of the test case. The first value indicator is equal to the ratio of the variance to the sum, the variance is the variance of the number of hits of the test case on each branch hit by itself, and the sum is the sum of the number of hits of each branch hit by the test case; The second value indicator is determined based on the total number of branches hit less than the rarity threshold among the branches hit by the test case and the total number of branches hit by the test case.

2. The method according to claim 1, It is characterized in that The similarity calculation formula includes one or more of a cosine similarity calculation formula, a Jaccard similarity calculation formula, a Euclidean distance similarity calculation formula, and a Pearson similarity calculation formula.

3. The method according to claim 1, It is characterized in that The method further comprises: Determine, based on historical test results of the code to be tested, a basic block in which an error occurred in the code to be tested; The target area is determined according to the basic block where an error occurred.

4. The method according to claim 3, It is characterized in that The method further comprises: Analyze and determine the hit status of the test case set on the branch according to the hit status of each test case in the test case set on the branch; Determining the weight of each test case in the test case set according to the hit situation and the target area, including: For each test case in the test case set, Calculate the seed average distance index of the test case according to the hit status of the test case on the branch and the target area; Calculate a first value indicator of the test case according to the hit status of the test case on the branch; Calculate a second value indicator of the test case according to the hit condition of the test case on the branch and the hit condition of the test case set on the branch; The weight of the test case is determined according to at least one of the seed average distance index, the first value index, and the second value index of the test case.

5. The method according to claim 4, It is characterized in that The step of calculating the average seed distance index of the test case according to the hit status of the test case on the branch and the target area includes: According to the hit status of the test case on the branch and the target area, counting the paths that have the basic blocks hit by the test case as nodes and pass through the target area, wherein the nodes include the starting point, the end point and the passing point of the path; For each basic block in each path counted, the number of branches between the basic block and the target area on the path is calculated; The ratio of the sum of the number of branches between each basic block in each path and the target region on the path to the total number of basic blocks included in the path is used as the distance index of the path; The average value of the distance index of the statistically obtained paths is determined as the seed average distance index of the test case.

6. The method according to claim 4, It is characterized in that The calculating the first value index of the test case according to the hit condition of the test case on the branch includes: According to the hit situation of the test case on the branch, determine the variance of the hit times of each branch hit by the test case itself and the sum of the hit times of each branch hit by the test case; The ratio of the variance to the sum is used as the first value indicator.

7. The method according to claim 4, It is characterized in that The calculating the second value index of the test case according to the hit condition of the test case on the branch and the hit condition of the test case set on the branch includes: According to the hit status of the test case set on the branches, the branches of the code to be tested are sorted in the order of the number of times each branch is hit by the test case set; Determining a rarity threshold corresponding to the test case set according to the sorting result of the branches; According to the hit situation of the test case on the branch, determine the total number of branches hit by the test case and the number of hits is less than the rarity threshold; According to the hit situation of the test case on the branches, determining the total number of branches hit by the test case; The second value indicator is determined according to the total number of branches hit less than the rarity threshold among the branches hit by the test case and the total number of branches hit by the test case.

8. The method according to claim 3, It is characterized in that The step of determining the number of mutations of each test case in the test case set according to the hit situation, and performing a corresponding number of mutations on the test case, comprises: According to any test case that has undergone a first number of mutations and the code to be tested, analyzing the hit status of the test case on the branch; When at least one branch hit by the test case is different from the branches hit by the test case set before the mutation, determining a second mutation number of the test case; The test case is mutated a second number of times, and the mutated test case is added to the test case set.

9. The method according to claim 1, It is characterized in that The code to be tested is a compiler code.

10. A code testing device, It is characterized in that The device is used to test whether a basic block included in a code to be tested has an error, the code to be tested includes at least one basic block, and any two basic blocks having a jump relationship include at least one branch, and the device includes: A first analysis module is used to analyze and determine the hit status of each test case in the test case set on the branch according to the test case set and the code to be tested; A second analysis module is used to analyze the similarity between every two test cases in the test case set according to the hit situation and using a similarity calculation formula, and to determine and delete redundant test cases in the test case set according to the analysis result; A mutation module, used to determine the number of mutations of each test case in the test case set according to the hit situation, mutate the test case a corresponding number of times, and add the mutated test case to the test case set; A testing module, used to test the code to be tested using each test case in the test case set to obtain a test result, wherein the test result indicates whether an error occurs in a basic block included in the code to be tested; The step of determining the number of mutations of each test case in the test case set according to the hit situation, and performing a corresponding number of mutations on the test case, comprises: Determine the weight of each test case in the test case set according to the hit situation and the target area, wherein the target area is determined according to the basic block in which an error occurred in the code to be tested; Determine a first mutation number of the test case according to the weight of each test case in the test case set, and mutate the test case the first mutation number; The weight is determined based on at least one of a seed average distance index indicating the degree of association between the test case and the target area, a first value index indicating the test value of the test case itself, and a second value index indicating the test value of the test case in the test case set. When the weight is determined based on the first value index, the fewer the number of hits of the test case on the branches it hits, the greater the first value index of the test case, and the greater the weight of the test case. The first value indicator is equal to the ratio of the variance to the sum, the variance is the variance of the number of hits of the test case on each branch hit by itself, and the sum is the sum of the number of hits of each branch hit by the test case; The second value indicator is determined based on the total number of branches hit less than the rarity threshold among the branches hit by the test case and the total number of branches hit by the test case.

11. An electronic device, It is characterized in that include: processor; a memory for storing processor-executable instructions; Wherein, the processor is configured to implement the method described in any one of claims 1 to 9 when executing the instructions stored in the memory.

12. A non-volatile computer-readable storage medium having computer program instructions stored thereon, It is characterized in that When the computer program instructions are executed by a processor, the method according to any one of claims 1 to 9 is implemented.