Code testing method and device
By selecting the target code sequence from the code pool and determining the change execution strategy based on the preset target test location, the test code is focused on testing, and the problem of lack of perception and key testing capabilities in the existing technology is solved, and the testing efficiency and targeting are improved sex.
Patent Information
- Application Number
- CN202110183423.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-02-10
- Publication Date
- 2024-12-13
- Estimated Expiration
- 2041-02-10
AI Technical Summary
The existing kernel fuzz testing technology lacks the ability to perceive the target location and focus on testing, resulting in the inability to timely discover kernel defects related to the location to be tested.
By selecting the target code sequence from the code pool, determining its coverage position in the code to be tested, and determining a targeted change execution strategy based on the preset target test location, the target code sequence is changed to implement the test code Focus on testing.
It improves the perception ability and testing efficiency of code location during the test code, implements targeted testing strategies, and can promptly detect kernel defects related to the location to be tested.
Smart Images

Figure CN113297066B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of software testing technology, and more particularly to a code testing method. The present invention also relates to a code testing device, a computing device, and a computer-readable storage medium. Background Art
[0002] At present, system kernels are widely deployed in applications and cloud computing fields, responsible for the safe and stable operation of applications, and their code quality must be guaranteed. Therefore, effective methods are needed to test defects in the operating system kernel. Kernel fuzz testing technology, as a software testing technology, is widely used in the kernel defect testing process. However, the current fuzz testing simply maximizes the overall kernel code coverage as the test goal, lacks the ability to perceive the location of the target to be tested and the ability to focus on testing. Therefore, a code testing method that solves the above problems is urgently needed. Summary of the invention
[0003] In view of this, the embodiment of this specification provides a code testing method. This specification also relates to a code testing device, a computing device, and a computer-readable storage medium to solve the technical defects existing in the prior art.
[0004] According to a first aspect of an embodiment of this specification, a code testing method is provided, including:
[0005] According to a preset selection rule, a target code sequence is selected from a code sequence in a code pool, wherein the code pool is constructed according to the code to be tested;
[0006] Determining the code position covered by the target code sequence in the code to be tested by executing the target code sequence;
[0007] In the case where the code position is located at a tested position and at a preset target test position, determining a target change execution strategy for the target code sequence, wherein the tested position is a position covered by the executed code sequence in the code to be tested;
[0008] The code to be tested is tested by changing and executing the target code sequence based on the target change execution strategy.
[0009] According to a second aspect of an embodiment of this specification, a code testing device is provided, including:
[0010] A selection module is configured to select a target code sequence from a code sequence in a code pool according to a preset selection rule, wherein the code pool is constructed according to the code to be tested;
[0011] A position determination module, configured to determine the code position covered by the target code sequence in the code to be tested by executing the target code sequence;
[0012] a determination strategy module, configured to determine a target change execution strategy for the target code sequence when the code position is located at a tested position and at a preset target test position, wherein the tested position is a position covered by the executed code sequence in the code to be tested;
[0013] The execution module is configured to test the code to be tested by changing the execution of the target code sequence based on the target change execution strategy.
[0014] According to a third aspect of an embodiment of this specification, a computing device is provided, including:
[0015] Memory and processor;
[0016] The memory is used to store computer executable instructions, and the processor is used to execute the computer executable instructions:
[0017] According to a preset selection rule, a target code sequence is selected from a code sequence in a code pool, wherein the code pool is constructed according to the code to be tested;
[0018] Determining the code position covered by the target code sequence in the code to be tested by executing the target code sequence;
[0019] In the case where the code position is located at a tested position and at a preset target test position, determining a target change execution strategy for the target code sequence, wherein the tested position is a position covered by the executed code sequence in the code to be tested;
[0020] The code to be tested is tested by changing and executing the target code sequence based on the target change execution strategy.
[0021] According to a fourth aspect of the embodiments of this specification, a computer-readable storage medium is provided, which stores computer-executable instructions, and when the instructions are executed by a processor, the steps of any of the code testing methods are implemented.
[0022] The code testing method provided in the present specification selects a target code sequence from a code sequence in a code pool according to a preset selection rule, wherein the code pool is constructed according to the code to be tested; determines the code position covered by the target code sequence in the code to be tested by executing the target code sequence; determines a target change execution strategy for the target code sequence when the code position is located at a tested position and a preset target test position, wherein the tested position is a position covered by the executed code sequence in the code to be tested; tests the code to be tested by changing the execution of the target code sequence based on the target change execution strategy, thereby achieving a targeted test strategy (target change execution strategy) for a specified position in the code to be tested (such as a position that needs to be tested in particular), and tests the code to be tested by executing the target code sequence according to the targeted test strategy, thereby improving the ability to perceive the code position during the testing of the code to be tested, and improving the test efficiency and targeting. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] Figure 1 is a schematic flow chart of a code testing method provided in an embodiment of this specification;
[0024] Figure 2 is a flow chart of a code testing method provided in an embodiment of this specification;
[0025] Figure 3 This is a processing flow chart of a code testing method applied to Linux kernel testing provided by an embodiment of this specification;
[0026] Figure 4 It is a structural schematic diagram of a code testing device provided in an embodiment of this specification;
[0027] Figure 5 It is a structural block diagram of a computing device provided in an embodiment of this specification. DETAILED DESCRIPTION
[0028] Many specific details are described in the following description to facilitate a full understanding of this specification. However, this specification can be implemented in many other ways than those described herein, and those skilled in the art can make similar generalizations without violating the connotation of this specification, so this specification is not limited to the specific implementation disclosed below.
[0029] The terms used in one or more embodiments of this specification are only for the purpose of describing specific embodiments, and are not intended to limit one or more embodiments of this specification. The singular forms of "a", "said" and "the" used in one or more embodiments of this specification and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings. It should also be understood that the term "and / or" used in one or more embodiments of this specification refers to and includes any or all possible combinations of one or more associated listed items.
[0030] It should be understood that although the terms first, second, etc. may be used to describe various information in one or more embodiments of this specification, this information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of one or more embodiments of this specification, the first may also be referred to as the second, and similarly, the second may also be referred to as the first. Depending on the context, the word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining".
[0031] First, the terms involved in one or more embodiments of this specification are explained.
[0032] Linux: is a monolithic kernel system. "Kernel" refers to a system software that provides hardware abstraction layer, disk and file system control, multitasking and other functions. A kernel is not a complete operating system. A complete operating system based on the Linux kernel is called the Linux operating system, or GNU / Linux. Device drivers have full access to hardware. Device drivers in Linux can be easily set up in a modularized form and can be directly loaded or unloaded during system operation.
[0033] FreeBSD: is a UNIX-like operating system.
[0034] System call: It is when a program enters the kernel to perform tasks. Programs use system calls to perform a series of operations such as: creating processes, network and file I / O, etc.
[0035] Kernel: The core of an operating system. It is the first layer of software expansion based on hardware, providing the most basic functions of the operating system and the basis of the operating system. It is responsible for managing the system's processes, memory, device drivers, files and network systems, and determines the system's performance and stability. In modern operating system design, in order to reduce the system's own overhead, some modules that are closely related to hardware (such as interrupt handlers, device drivers, etc.), basic, public, and high-frequency modules (such as clock management, process scheduling, etc.) and key data structures are often separated to make them resident in memory and protect them. This part is usually called the kernel of the operating system.
[0036] Fuzz testing is a method of discovering software vulnerabilities by providing unexpected inputs to the target system and monitoring abnormal results.
[0037] Kernel fuzz testing: An automated operating system kernel defect testing method. This method first randomly generates a system call sequence, and then makes the operating system execute the randomly generated system call sequence, in order to trigger operating system anomalies during the execution of the system call, thereby discovering kernel defects.
[0038] Seed: The test case used during fuzz testing. For kernel fuzz testing, the seed consists of a sequence of system calls and the specific parameters in each system call.
[0039] Seed Cover: The set of kernel positions covered during kernel execution seeding.
[0040] Corpus: A collection of high-quality seeds generated during the test run, read by the fuzzer at the beginning of the test run and updated by the fuzzer during the test process.
[0041] Seed mutation execution: The fuzz testing process changes the seed sequence order, parameters, etc. and then sends it to the operating system for execution. The operation of changing the seed is called seed mutation operation.
[0042] Seed scheduling method: a method to determine the order in which seeds participate in mutation execution, the number of seed mutation executions, and the type of mutation operation during fuzz testing.
[0043] In actual applications, in the design of test mechanisms, in order to maximize the proportion and degree of code testing, Figure 1 A schematic flow chart of a code testing method provided according to an embodiment of the present specification is shown.
[0044] Taking the design of the kernel fuzz testing mechanism as an example, the fuzz testing process is mainly guided by the overall kernel code coverage. Fuzz testing evaluates seed quality and schedules seeds based on the basic principle of "whether the seed adds a new overall coverage position during execution". The main process of fuzz testing includes the following steps:
[0045] Step 102: Read the corpus.
[0046] Specifically, after the fuzz test starts, the corpus is read. The corpus refers to a collection of high-quality seeds generated during the test process, which can also be understood as a code pool. It is built based on the code to be tested (such as the kernel), read by the test program at the beginning of the test, and updated by the test program during the test. Among them, the seed is the test case used in the test process, which can also be understood as a code sequence composed of callable executable code or functions; for kernel fuzz testing, its seed consists of a system call sequence and specific parameters in each system call.
[0047] Step 104: Randomly select a seed in the corpus.
[0048] Specifically, the purpose of randomly selecting seeds from the corpus is to test the kernel code by performing mutation execution on the selected seeds, and mutation execution can be understood as changing (i.e., mutating) the selected seeds and executing the changed (mutated) seeds.
[0049] Step 106: Execute the seed and collect the coverage position in the kernel during the seed execution process.
[0050] Specifically, the kernel is the core of an operating system, which can be understood as the code to be tested. The coverage position can be understood as the kernel code position covered by the seed in the kernel (code to be tested) during the execution process.
[0051] Step 108: Evaluate the seed quality based on the coverage position of the seed after execution: determine whether the current seed has added an overall coverage position to the kernel?
[0052] Specifically, to determine whether the current seed has added a new overall coverage position for the kernel is to determine whether the kernel code position that has not been covered by the seed in the current corpus is covered during the seed execution process (which can be understood as a tested code position); if the seed has added a new overall coverage for the kernel, execute the following step 110: mutate the execution seed according to the seed scheduling method; if the seed has no new overall coverage position for the kernel, discard the seed.
[0053] Step 110: mutate the execution seed according to the seed scheduling method.
[0054] Among them, the seed scheduling method includes: determining the order, number of times, and mutation operation strategy of seed execution, and mutating the execution seeds based on the determined order, number of times, and mutation operation strategy. Specifically, the seed scheduling method includes: randomly selecting seeds, defaulting to a fixed number of execution times, and randomly selecting a mutation operation strategy, etc. In actual applications, randomly selecting seeds to participate in mutation execution, the probability of seeds in the corpus participating in mutation execution is the same; and the number of times in seed scheduling uses the default value, that is, the number of mutation executions of seeds in the corpus is a fixed value. For example, if the seed adds a new overall coverage position for the kernel, a fixed 100 seed mutation executions are performed, otherwise a single seed mutation execution is performed.
[0055] Step 112: Determine whether to end the test.
[0056] Specifically, whether the test needs to be ended can be determined based on whether a test end instruction is received. If no test end instruction is received, the corpus is updated with the mutated seeds, and seeds are randomly selected from the corpus for the next round of mutation execution. If a test end instruction is received, the test ends.
[0057] According to the above test process, it can be seen that the current seed scheduling is guided by whether the seed has added overall kernel coverage to determine the order, number of times, and mutation strategy of the seed participating in the mutation execution.
[0058] According to the current kernel test seed scheduling design, it can be seen that the current scheduling mechanism lacks attention and mechanism design for the purpose of focusing on testing the target location, resulting in the current kernel test lack of targeting, limited target coverage speed and target-related defect testing capabilities, and unable to timely discover kernel defects related to the location to be tested.
[0059] In order to solve the above problems, further, in this specification, a code testing method is provided. This specification also involves a code testing device, a computing device, and a computer-readable storage medium, which are described in detail one by one in the following embodiments.
[0060] Figure 2 A flowchart of a code testing method provided according to an embodiment of this specification is shown, which specifically includes the following steps:
[0061] Step 202: According to a preset selection rule, a target code sequence is selected from a code sequence in a code pool, wherein the code pool is constructed according to the code to be tested.
[0062] Specifically, the preset selection rule refers to a pre-set rule for selecting a code sequence to be executed (i.e., a target code sequence) in a code pool. The rule can be a random selection or a selection according to the arrangement order of the code sequence in the code pool. In addition, it can also be other selection rules, which are not limited here.
[0063] The code sequence can be understood as a test case for testing the code to be tested. Specifically, it can be understood as consisting of executable call functions randomly selected from the code to be tested and call parameters corresponding to the call functions. The code to be tested can be an operating system kernel, a software program, etc., wherein the operating system kernel includes: Linux kernel, FreeBSD kernel, etc., which are not limited here; the code pool is a collection of code sequences selected from the code to be tested, and the target code sequence refers to the code sequence to be executed selected from the code pool. In actual applications, the code to be tested is tested by selecting a target code sequence from the code pool and scheduling the target code sequence.
[0064] Step 204: Determine the code position covered by the target code sequence in the code to be tested by executing the target code sequence.
[0065] Among them, the code position can be understood as the position of the code executed by the target code sequence during the execution process in the code to be tested. And through the code position covered by the target code sequence in the code to be tested, it can be clear which codes in the code to be tested (such as function name / function name / code line, etc.) are tested, and the number of functions tested during the execution process can be clear. In specific implementation, the code position can be a string, a coded value, etc. formed by encoding the covered code path, code line, function name, etc., such as using 64-bit binary code to represent the code position.
[0066] Step 206: When the code position is located at a tested position and at a preset target test position, determine a target change execution strategy for the target code sequence.
[0067] The tested positions are positions covered by the executed code sequences in the code to be tested.
[0068] The preset target test location refers to a pre-set location that needs to be tested. Specifically, the preset target test location can be understood as the folder where the code that needs to be tested is located (it can also be understood as a test module), which can be represented by a folder name, or the file where the code that needs to be tested is located, which can be represented by a file name. In addition, it can also be a function name corresponding to the code that needs to be tested, etc., which is not limited here.
[0069] In actual applications, if the code position covered by the execution target code sequence is located at a tested position, it means that the position has been tested, and the code position is located at a tested position and at a preset target test position, indicating that on the basis that the position has been tested, this position is also a designated key test area, then it is necessary to perform a key test on this position, that is, to determine the target change execution strategy for testing the key test area.
[0070] Correspondingly, the change execution strategy refers to the strategy of how to change and execute the target code sequence, such as the change method and / or execution number of strategies. On the basis of determining the target change execution strategy, the target code sequence can be changed and executed according to the target change execution strategy to focus on testing the preset target test position of the code to be tested.
[0071] In a specific implementation, when the code position is located at a tested position and at a preset target test position, determining a target change type and a target change execution number for changing the target code sequence;
[0072] The target change type and the target change execution times are used as the target change execution strategy.
[0073] Specifically, the change type can be understood as the way the code sequence is changed, such as the coarse-grained change type or the fine-grained change type; among them, the coarse-grained change type can be understood as the change type of making a large change to the code sequence, and the fine-grained change type can be understood as the change type of making a small change to the code sequence. The number of executions can be understood as the number of times the code sequence is changed and executed. In actual applications, each time a change is made to the code sequence, the changed code sequence is executed to test the code to be tested.
[0074] Furthermore, the target change type refers to the type of change to the target code sequence when the code position is located at a tested position and a preset target test position, and the target execution count refers to the number of times the target code sequence is changed and executed when the code position is located at a tested position and a preset target test position. In specific implementation, the target change type and the target change execution count are used as the target change execution strategy to indicate how to test the code to be tested based on the target code sequence when the code position is located at a tested position and a preset target test position.
[0075] Further, the determining of the target change type and the target change execution times of the target code sequence includes: determining the change number algorithm corresponding to the target priority and the target change type of the target code sequence;
[0076] Based on the change number algorithm and the code position, the target change execution number is determined.
[0077] Among them, the change count algorithm refers to a preset algorithm for calculating the change count. In actual applications, the change execution count is dynamically determined based on the change count algorithm and the execution status of the code sequence (such as the code positions covered in the code to be tested during the execution process, the number of calling functions covered in the code to be tested, or the number of times a tested position is hit, etc.), thereby improving the flexibility and adaptability of the change execution target code sequence.
[0078] In specific implementation, the change count algorithm can calculate the number of changes based on the execution of the code sequence, for example, the target change execution count = N / target coverage number of the target code sequence, where N is the maximum execution count, and the target coverage number of the target code sequence is: the coverage number of a certain position in the preset target test position (such as a function call) during the execution of the target code sequence. Specifically, the more target coverage numbers, the more times a certain position in the preset key test area is covered (tested), and the number of change executions of the target code sequence can be reduced. Conversely, the fewer target coverage numbers, the fewer times a certain position in the preset key test area is covered (tested), and the number of change executions of the target code sequence needs to be increased.
[0079] In addition, the correspondence between the target coverage quantity interval and the number of changes can be preset. Then, based on the target coverage quantity, the target coverage quantity interval in which the target coverage quantity is located is determined according to this correspondence, and based on the target coverage quantity interval and this correspondence, the number of changes corresponding to the target code sequence is determined.
[0080] Further, in order to speed up the testing efficiency of the code to be tested, multiple processes may be used to select the code sequence to be executed, and the selected code sequence may be changed for execution. In this case, the code sequence to be executed may be divided into execution priorities, so that the code sequence to be executed may be changed for execution in order of priority, so as to reduce the randomness of the execution of the code sequence to be executed, and also enhance the pertinence of the preset target test position during the testing process. In an optional implementation manner provided by the embodiment of this specification, the determination of the target change execution strategy for the target code sequence is specifically implemented in the following manner:
[0081] Determining the execution priority corresponding to the target code sequence as the target priority;
[0082] Based on the target priority, determining a target change type and a target change execution number for changing the target code sequence;
[0083] The target priority, the target change type, and the target change execution times are used as the target change execution strategy.
[0084] Specifically, the target priority can be a medium priority, and the target change type can be a fine-grained change type. The number of change executions can be a preset number of executions for a code sequence corresponding to the target priority, such as one hundred times, one thousand times, etc., and there is no limitation here.
[0085] In the embodiments of the present specification, by determining the corresponding change execution strategy for the code sequence whose code positions covered in the code to be tested during the execution process are located at the tested positions and at the preset target test positions, the focus test on the preset key positions is improved.
[0086] Furthermore, when the code position is located at a tested position and at a preset target test position, the change execution times can also be dynamically determined according to the execution status of the code sequence through a change times algorithm, thereby improving the flexibility and adaptability of changing the target code sequence for execution. In an optional implementation manner provided by an embodiment of this specification, the target change type and the target change execution times for changing the target code sequence are determined based on the target priority, which is specifically implemented in the following manner:
[0087] Based on the target priority, determining a change number algorithm corresponding to the target priority and a target change type of the target code sequence;
[0088] Based on the change number algorithm and the code position, the target change execution number is determined.
[0089] Specifically, the change number algorithm can also be: target change execution times = 10*[target coverage number of target code sequence / average target coverage number of code sequence in the queue], and the change number calculation result is rounded down. Among them, the target coverage number of the target code sequence is: the coverage number of the code or a certain position (such as calling function) in the preset target test position area during the execution of the target code sequence, and the average target coverage number of the code sequence in the queue is: the average value of the coverage number of the code sequence in the priority queue where the target code sequence is located during the execution of the code or a certain position (such as calling function) in the preset target test position area.
[0090] Based on this, when the target coverage number of the target code sequence is the number of coverage times for the code in the preset target test position area, it can be determined based on the number of position entries corresponding to the code position in the preset target test area. For example, the code position contains 3 64-bit binary position codes, each position code represents one of the code positions covered by the target code sequence during execution, where two position codes are in the preset target test position area, and the target coverage number is 2.
[0091] In specific implementation, the execution strategy corresponding to the target code sequence may also be determined for the case where the code position is not located at a tested position. In an optional implementation manner provided by the embodiment of this specification, after determining the code position covered by the target code sequence in the code to be tested, the method further includes:
[0092] In a case where the code position is not located at the tested position, determining that the execution priority corresponding to the target code sequence is a first priority;
[0093] Based on the first priority, determining a first change type and a first change execution number for changing the target code sequence;
[0094] The code to be tested is tested by performing a change execution on the target code sequence based on the first priority, the first change type, and the first change execution count.
[0095] Specifically, if the code position is not located at the tested position, it indicates that the code corresponding to the code position has not been tested during the testing of the code to be tested. In order to improve the comprehensive testing of the code to be tested, the execution priority corresponding to the target code sequence is determined as a high priority (i.e., the first priority).
[0096] Furthermore, based on the first priority, there are various ways to determine the specific implementation of the first change type for changing the target code sequence. Specifically, one change type may be randomly selected from multiple preset change types as the first change type, for example, one change type may be randomly selected from coarse-grained change types and fine-grained change types as the first change type. Based on the first priority, there are also various ways to determine the number of executions of the first change for changing the target code sequence. Specifically, it may be determined based on the first priority and the corresponding relationship between the preset priority and the number of executions of the change. For example, if the number of executions corresponding to the first priority in the corresponding relationship is one hundred times, then the number of executions of the first change is determined to be one hundred times, and the number of executions is one hundred times, indicating that the target code sequence needs to be changed and executed one hundred times, that is, the target code sequence needs to be changed one hundred times, and the target code sequence after each change is executed.
[0097] On the basis of determining the first priority, the first change type and the first change execution number, the first priority, the first change type and the first change execution number are used as the execution strategy for changing the execution of the target code sequence, so that the target code sequence is executed based on the execution strategy to test the code to be tested, thereby determining the corresponding test strategy for the untested code in the code to be tested, so as to perform targeted testing on the untested code.
[0098] In addition, for a case where the code position is located at a tested position and not at a preset target test position, an execution strategy corresponding to the target code sequence may be determined. In an optional implementation manner provided by an embodiment of this specification, after determining the code position covered by the target code sequence in the code to be tested, the following further comprises:
[0099] When the code position is located at the tested position and not at the preset target test position, determining that the execution priority corresponding to the target code sequence is a second priority;
[0100] Based on the second priority, determining a second change type and a second change execution number for changing the target code sequence;
[0101] The code to be tested is tested by performing a change execution on the target code sequence based on the second priority level, the second change type, and the second change execution number.
[0102] Specifically, if the code position is located at the tested position, it indicates that during the testing of the code to be tested, the code corresponding to the code position has been tested, and the code position is not located at the preset target test position, indicating that the code position is not the designated key test position, then the execution priority corresponding to the target code sequence is determined as a low priority (i.e., the second priority).
[0103] Furthermore, based on the second priority, there are various ways to implement the second change type for determining the target code sequence to be changed. Specifically, one change type may be randomly selected from a plurality of preset change types as the second change type, for example, a change type may be randomly selected from a coarse-grained change type and a fine-grained change type as the second change type. In addition, the second change type may also be directly determined to be a coarse-grained change type. Based on the second priority, there are also various ways to determine the number of executions of the second change for changing the target code sequence. Specifically, it may be determined based on the second priority and the corresponding relationship between the preset priority and the number of executions of the change. For example, if the number of executions corresponding to the second priority in the corresponding relationship is 1, then the number of executions of the second change is determined to be 1.
[0104] On the basis of determining the second priority, the second change type and the second change execution number, the second priority, the second change type and the second change execution number are used as the execution strategy for changing the execution of the target code sequence, so that the target code sequence is executed based on the execution strategy to test the code to be tested, thereby determining the corresponding test strategy for the code to be tested that has been tested in the code to be tested but is not in the specified location area, so as to perform targeted testing on these codes.
[0105] Step 208: Testing the code to be tested by performing a change execution on the target code sequence based on the target change execution strategy.
[0106] Specifically, performing a change and execution on the target code sequence based on the target change execution strategy refers to performing a change and executing the target code sequence based on the target change execution strategy.
[0107] In specific implementation, the target code sequence is changed and executed based on the target change execution strategy. The target code sequence can be changed and executed according to the target priority, target change type and the target change execution number determined above, so as to implement the key test of the code in the preset target test location area. In an optional implementation manner provided in the embodiment of this specification, the target code sequence is changed and executed based on the target change execution strategy, including:
[0108] adding the target code sequence to a target priority queue corresponding to the target priority;
[0109] Obtaining a code sequence to be executed from each priority queue in descending order of priority corresponding to each priority queue, wherein the priority queue comprises: a target priority queue, and the code sequence to be executed comprises: a target code sequence;
[0110] On the basis that the acquired code sequence to be executed is a target code sequence, determining a change operation for changing the target code sequence each time according to the target change type and the target change execution number;
[0111] Based on the change operation, the target code sequence is changed, and the changed target code sequence is executed.
[0112] In actual applications, each execution priority has a corresponding priority queue, and the target priority corresponds to the target priority queue. On the basis of determining that the corresponding priority of the target code sequence is the target priority, the target code sequence is added to the target priority queue corresponding to the target priority. For example, if the target priority is medium priority, the target code sequence is added to the medium priority queue corresponding to the medium priority.
[0113] In a specific implementation, when there are multiple priority queues, for example, in addition to the medium priority queue, there are also high priority queues and low priority queues, wherein the high priority queue corresponds to a high priority, and the low priority queue corresponds to a low priority, then the code sequence to be executed is obtained from each priority queue in order from high to low, and executed, wherein the code sequence to be executed includes a target code sequence, and when the target code sequence is obtained, the corresponding change operation is selected according to the target change type pre-determined for the target code sequence, for example, the change operation corresponding to the coarse-grained change type includes: adjusting the order of calling functions in the sequence, adding a calling function to the code sequence, deleting a calling function in the code sequence, etc., and the change operation corresponding to the fine-grained change type includes: changing the calling parameters of the calling function, etc.;
[0114] Furthermore, according to the target change type and the number of target change executions, the change operation for changing the target code sequence each time is determined. This can be understood as determining the change operation for changing the target code sequence each time according to the target change type in the number of target change executions, changing the target code sequence based on the change operation, and executing the changed target code sequence.
[0115] In specific implementation, in the process of changing and executing the target code sequence, the code pool can also be updated according to the execution status of the changed code to be tested, thereby improving the test quality of the code sequence in the code pool. In an optional implementation manner provided by the embodiment of this specification, the code testing method further includes:
[0116] Determine a second code position covered by the target code sequence after executing the change in the code to be tested;
[0117] Based on the second code position, evaluating the changed target code sequence;
[0118] When the evaluation result meets the preset condition, the code pool is updated according to the changed target code sequence.
[0119] In specific implementation, by executing the changed target code sequence, the code position covered by the execution of the changed target code sequence in the code to be tested, that is, the second code position, is determined, and based on the second code position, the changed target code sequence is evaluated. Specifically, the second code position can be compared with the tested position to evaluate the number of newly covered positions of the updated target code sequence. The evaluation result obtained is the number of newly covered positions after the execution of the updated target code sequence. If the number of newly covered positions is greater than the preset number, it indicates that the quality of the updated target code sequence is higher, that is, it is more helpful for testing the code to be tested, and the changed target code sequence is added to the code pool.
[0120] In addition, based on the second code position, the number of positions covered by the updated target code sequence in the code to be tested can be evaluated. If the number of covered positions is greater than a preset number, it indicates that the quality of the updated target code sequence is higher, that is, it is more helpful in testing the code to be tested. In this case, the updated target code sequence is added to the code pool. In addition, other evaluation methods can also be used, which are not limited here.
[0121] Accordingly, the preset condition is determined based on the evaluation method adopted above. Specifically, it may be that the number of newly covered locations is greater than the preset number. In addition, the number of covered locations may be greater than the preset number, etc., which is not limited here.
[0122] On the basis of evaluating the updated target code sequence, there is still a situation where the evaluation result does not meet the preset condition. In an optional implementation manner provided in the embodiment of this specification, after evaluating the changed target code sequence, the method further includes:
[0123] When the evaluation result does not satisfy the preset condition, the changed target code sequence is deleted.
[0124] Specifically, when the evaluation result does not meet the preset conditions, it indicates that the quality of the updated target code sequence is low, that is, it is not very helpful for testing the test code. In this case, there is no need to retain the changed target code sequence, and the changed target code sequence is deleted to avoid wasting storage.
[0125] Further, on the basis of testing the code to be tested, the test of the code to be tested may also be ended. In practical applications, there are various reasons for ending the test of the code to be tested. In an optional implementation manner provided in the embodiment of this specification, after testing the code to be tested, the following steps are further included:
[0126] Receiving a test end instruction submitted by a user for the code to be tested;
[0127] Based on the test end instruction, the test on the code to be tested is ended.
[0128] Specifically, the user may be a tester of the code to be tested, and there is no limitation here. The test end instruction is an instruction to indicate the end of testing the code to be tested. In the embodiment of this specification, the user manually submits the test end instruction to end the test of the code to be tested, thereby increasing the flexibility of ending the test of the code to be tested.
[0129] In addition to the above method for ending the test of the code to be tested, in an optional implementation manner provided in the embodiment of this specification, after the test of the code to be tested, the method further includes:
[0130] When it is detected that a preset test end condition is met, the test on the code to be tested is ended.
[0131] The test end condition refers to a pre-set condition for ending the test, specifically, the test time may reach 100 hours, the set test code positions have all been tested, or the test is 80% completed, etc., and there is no limitation here.
[0132] The embodiments of the present specification pre-set the test end conditions and end the test of the code to be tested based on the monitoring that the test end conditions are met, thereby automatically ending the test of the code to be tested according to the test situation, that is, ending the test when the test objectives are met, thereby increasing the test efficiency and avoiding wasting test resources.
[0133] In summary, the code testing method provided in the present specification selects a target code sequence from a code sequence in a code pool according to a preset selection rule, wherein the code pool is constructed according to the code to be tested; by executing the target code sequence, the code position covered by the target code sequence in the code to be tested is determined; when the code position is located at a tested position and at a preset target test position, a target change execution strategy for the target code sequence is determined, wherein the tested position is a position covered by the executed code sequence in the code to be tested; the code to be tested is tested by changing the execution of the target code sequence based on the target change execution strategy, thereby achieving a targeted test strategy (target change execution strategy) for a specified position in the code to be tested (such as a position that needs to be tested in particular), and testing the code to be tested by executing the target code sequence according to the targeted test strategy, thereby improving the perception of the position during the test, and improving the test efficiency and targeting.
[0134] The following combination Figure 3, taking the application of the code testing method provided in this specification in Linux kernel testing as an example, the code testing method is further described. Figure 3 A processing flow chart of a code testing method applied to Linux kernel testing provided by an embodiment of this specification is shown, which specifically includes the following steps:
[0135] Step 302: Read the corpus and the target position.
[0136] After the test starts, the corpus is read, wherein the corpus can be understood as the code pool in the above embodiment, specifically, a set of system call sequences composed of system calls selected according to a selection rule (such as random) in the Linux kernel, and the target position can be understood as the preset target test position in the above embodiment, that is, the preset list of positions to be tested, and the positions to be tested in the list of positions to be tested can be represented by the target module name (folder name), file name, function name, and line number of the code.
[0137] Step 304: Randomly select seeds from the corpus to participate in the mutation execution.
[0138] Specifically, the selected seed can be understood as the target code sequence in the above embodiment, and the variant execution can be understood as the changed execution in the above embodiment.
[0139] Step 306: Execute the seed and collect the seed coverage.
[0140] The seed coverage can be understood as the code position in the above embodiment, that is, the set of kernel code positions covered in the kernel code during the kernel execution seed process.
[0141] Step 308: Compare the seed coverage with the current corpus distribution.
[0142] The comparison of the seed coverage with the current corpus distribution can be understood as a distribution comparison of the seed coverage with the coverage of the executed seeds in the current corpus, that is, a position comparison.
[0143] Step 310: Determine seed priorities according to a targeted prioritization algorithm.
[0144] Among them, the targeted priority sorting algorithm can be understood as an algorithm for determining the seed priority sorting based on the seed coverage. When it is implemented specifically, by comparing the seed coverage with the preset target position (which can be understood as the preset target test position in the above embodiment), and comparing the seed coverage with other seed coverage in the corpus (tested position), a seed targeted scheduling queue is constructed, wherein the seed targeted scheduling queue is divided into three priorities: high, medium and low. In the specific test process, the type of targeted scheduling queue that the seed enters is determined based on whether the seed has added an overall coverage position for the kernel and covered the target position, that is, the targeted priority sorting algorithm: if the seed has added an overall coverage position for the kernel, it enters the high priority queue; if the seed has no new overall coverage position for the kernel but covers the target position, it enters the medium priority queue; otherwise, it enters the low priority queue. During the test process, seeds are selected from the high, medium and low priority queues for mutation execution, and seeds in the same priority queue are selected for mutation execution according to the first-in-first-out rule.
[0145] Step 312: The seed targeted mutation number determination algorithm determines the mutation number.
[0146] Specifically, the seed targeted mutation number determination algorithm can be understood as an algorithm for determining the number of mutations of the code positions covered in the process of executing the seed, and the seed targeted mutation number determination algorithm includes the change number algorithm in the above embodiment; in actual applications, the seed mutation number is determined according to the seed targeted mutation number determination algorithm, which can be: after the seeds in the high priority queue are selected, the mutation execution is fixed to 100 times; after the seeds in the medium priority queue are selected, the mutation execution is performed 10*[the target coverage number of the target code sequence / the average target coverage number of the code sequence in the queue] times; after the seeds in the low priority queue are selected, the mutation execution is performed once.
[0147] Step 314: Determine a seed mutation strategy according to the seed targeted mutation strategy.
[0148] Specifically, the seed targeted mutation strategy can be understood as the change type (mutation type) in the above embodiment, and the seed mutation strategy can be understood as the change operation (i.e., mutation operation) in the above embodiment. In practical applications, the mutation operation is divided into two types of mutations, fine-grained and coarse-grained, and a biased mutation strategy is selected according to the queue where the seed is located, so that the seeds covering the target position are more likely to use fine-grained mutations, and the seeds that do not cover the target position are more likely to use coarse-grained mutations. Among them, coarse-grained mutation operations include sequence cross-splicing and adding and deleting system calls, which will change the seed coverage position to a large extent; fine-grained mutation operations include call parameter modification, which will change the seed coverage position to a small extent. When selecting the seed mutation strategy, the probability of using coarse-grained and fine-grained mutation strategies for seeds in the high priority queue is equal; the fine-grained mutation strategy is adopted for seeds in the medium priority queue; and the coarse-grained mutation strategy is adopted for seeds in the low priority queue.
[0149] Step 316: Determine whether to end the test.
[0150] Specifically, it can be determined whether to end the test according to whether a test end instruction is received. If yes, the test is ended; if not, the following step 318 is executed.
[0151] Step 318: Seed selection based on priority queue.
[0152] Specifically, the seed selection based on the priority queue is to select seeds from the targeted priority queue according to priority to participate in the next round of mutation execution.
[0153] In summary, the code testing method provided in the present specification selects a target code sequence from a code sequence in a code pool according to a preset selection rule, wherein the code pool is constructed according to the code to be tested; determines the code position covered by the target code sequence in the code to be tested by executing the target code sequence; determines a target change execution strategy for the target code sequence when the code position is located at a tested position and a preset target test position, wherein the tested position is a position covered by the executed code sequence in the code to be tested; tests the code to be tested by changing the execution of the target code sequence based on the target change execution strategy, thereby achieving a targeted test strategy (target change execution strategy) for a specified position in the code to be tested (such as a position that needs to be tested in particular), and tests the code to be tested by executing the target code sequence according to the targeted test strategy, thereby improving the ability to perceive the code position during the testing of the code to be tested, and improving the test efficiency and targeting.
[0154] Corresponding to the above method embodiment, this specification also provides a code testing device embodiment, Figure 4 FIG. 1 shows a schematic diagram of the structure of a code testing device provided in an embodiment of the present specification. Figure 4 As shown, the device comprises:
[0155] A selection module 402 is configured to select a target code sequence from a code sequence in a code pool according to a preset selection rule, wherein the code pool is constructed according to the code to be tested;
[0156] A position determination module 404 is configured to determine the code position covered by the target code sequence in the code to be tested by executing the target code sequence;
[0157] A determination strategy module 406 is configured to determine a target change execution strategy for the target code sequence when the code position is located at a tested position and a preset target test position, wherein the tested position is a position covered by the executed code sequence in the code to be tested;
[0158] The execution module 408 is configured to test the code to be tested by performing a change execution on the target code sequence based on the target change execution strategy.
[0159] Optionally, the strategy determination module 406 is further configured to:
[0160] Determining a target change type and a target change execution number for changing the target code sequence;
[0161] The target change type and the target change execution times are used as the target change execution strategy.
[0162] Optionally, the strategy determination module 406 is further configured to:
[0163] The determining of the target change type and the target change execution times of the target code sequence includes: determining the change times algorithm corresponding to the target priority and the target change type of the target code sequence;
[0164] Based on the change number algorithm and the code position, the target change execution number is determined.
[0165] Optionally, the strategy determination module 406 is further configured to:
[0166] Determining the execution priority corresponding to the target code sequence as the target priority;
[0167] Based on the target priority, determining a target change type and a target change execution number for changing the target code sequence;
[0168] The target priority, the target change type, and the target change execution times are used as the target change execution strategy.
[0169] Optionally, the strategy determination module 406 is further configured to:
[0170] Based on the target priority, determining a change number algorithm corresponding to the target priority and a target change type of the target code sequence;
[0171] Based on the change number algorithm and the code position, the target change execution number is determined.
[0172] Optionally, the execution module 408 is further configured to:
[0173] adding the target code sequence to a target priority queue corresponding to the target priority;
[0174] Obtaining a code sequence to be executed from each priority queue in descending order of priority corresponding to each priority queue, wherein the priority queue comprises: a target priority queue, and the code sequence to be executed comprises: a target code sequence;
[0175] On the basis that the acquired code sequence to be executed is a target code sequence, determining a change operation for changing the target code sequence each time according to the target change type and the target change execution number;
[0176] Based on the change operation, the target code sequence is changed, and the changed target code sequence is executed.
[0177] Optionally, the code testing device further includes:
[0178] A first priority determination module is configured to determine, when the code position is not located at the tested position, that the execution priority corresponding to the target code sequence is a first priority;
[0179] A first determination number module is configured to determine a first change type and a first change execution number for changing the target code sequence based on the first priority;
[0180] The first execution module is configured to test the code to be tested by performing a change execution on the target code sequence based on the first priority, the first change type, and the first change execution count.
[0181] Optionally, the code testing device further includes:
[0182] A second priority determination module is configured to determine that the execution priority corresponding to the target code sequence is a second priority when the code position is located at the tested position and not at the preset target test position;
[0183] A second determination number module is configured to determine a second change type and a second change execution number for changing the target code sequence based on the second priority;
[0184] The second execution module is configured to test the code to be tested by performing a change execution on the target code sequence based on the second priority level, the second change type and the second change execution number.
[0185] Optionally, the code testing device further includes:
[0186] A receiving module is configured to receive a test end instruction submitted by a user for the code to be tested;
[0187] The first ending module is configured to end the test on the code to be tested based on the test ending instruction.
[0188] Optionally, the code testing device further includes:
[0189] The second ending module is configured to end the test on the code to be tested when it is detected that a preset test ending condition is met.
[0190] Optionally, the code testing device further includes:
[0191] A second position determination module is configured to determine a second code position covered by the target code sequence after executing the change in the code to be tested;
[0192] an evaluation module, configured to evaluate the changed target code sequence based on the second code position;
[0193] The updating module is configured to update the code pool according to the changed target code sequence when the evaluation result meets the preset condition.
[0194] Optionally, the code testing device further includes:
[0195] The deletion module is configured to delete the changed target code sequence when the evaluation result does not meet the preset conditions.
[0196] In summary, the code testing device provided in the present specification selects a target code sequence from a code sequence in a code pool according to a preset selection rule, wherein the code pool is constructed according to the code to be tested; determines the code position covered by the target code sequence in the code to be tested by executing the target code sequence; determines a target change execution strategy for the target code sequence when the code position is located at a tested position and at a preset target test position, wherein the tested position is a position covered by the executed code sequence in the code to be tested; tests the code to be tested by changing the execution of the target code sequence based on the target change execution strategy, thereby achieving a targeted test strategy (target change execution strategy) for a specified position in the code to be tested (such as a position that needs to be tested in particular), and tests the code to be tested by executing the target code sequence according to the targeted test strategy, thereby improving the ability to perceive the code position during the testing of the code to be tested, and improving the test efficiency and targeting.
[0197] The above is a schematic scheme of a code testing device of this embodiment. It should be noted that the technical scheme of the code testing device and the technical scheme of the above code testing method belong to the same concept, and the details not described in detail in the technical scheme of the code testing device can be referred to the description of the technical scheme of the above code testing method.
[0198] Figure 5 The structure block diagram of a computing device 500 provided according to an embodiment of the present specification is shown. The components of the computing device 500 include but are not limited to a memory 510 and a processor 520. The processor 520 is connected to the memory 510 via a bus 530, and the database 550 is used to store data.
[0199] The computing device 500 also includes an access device 540 that enables the computing device 500 to communicate via one or more networks 560. Examples of these networks include a public switched telephone network (PSTN), a local area network (LAN), a wide area network (WAN), a personal area network (PAN), or a combination of communication networks such as the Internet. The access device 540 may include one or more of any type of network interface (e.g., a network interface card (NIC)) whether wired or wireless, such as an IEEE 802.11 wireless local area network (WLAN) wireless interface, a World Wide Interoperability for Microwave Access (Wi-MAX) interface, an Ethernet interface, a universal serial bus (USB) interface, a cellular network interface, a Bluetooth interface, a near field communication (NFC) interface, and the like.
[0200] In one embodiment of the present specification, the above components of the computing device 500 and Figure 5Other components not shown in the figure may also be connected to each other, for example, via a bus. It should be understood that Figure 5 The computing device structure block diagram shown is only for the purpose of illustration, and is not intended to limit the scope of this specification. Those skilled in the art can add or replace other components as needed.
[0201] The computing device 500 may be any type of stationary or mobile computing device, including a mobile computer or mobile computing device (e.g., a tablet computer, a personal digital assistant, a laptop computer, a notebook computer, a netbook, etc.), a mobile phone (e.g., a smart phone), a wearable computing device (e.g., a smart watch, smart glasses, etc.), or other types of mobile devices, or a stationary computing device such as a desktop computer or PC. The computing device 500 may also be a mobile or stationary server.
[0202] The processor 520 is used to execute the following computer executable instructions:
[0203] According to a preset selection rule, a target code sequence is selected from a code sequence in a code pool, wherein the code pool is constructed according to the code to be tested;
[0204] Determining the code position covered by the target code sequence in the code to be tested by executing the target code sequence;
[0205] In the case where the code position is located at a tested position and at a preset target test position, determining a target change execution strategy for the target code sequence, wherein the tested position is a position covered by the executed code sequence in the code to be tested;
[0206] The code to be tested is tested by changing and executing the target code sequence based on the target change execution strategy.
[0207] The above is a schematic scheme of a computing device of this embodiment. It should be noted that the technical scheme of the computing device and the technical scheme of the above code testing method belong to the same concept, and the details not described in detail in the technical scheme of the computing device can be referred to the description of the technical scheme of the above code testing method.
[0208] An embodiment of the present specification further provides a computer-readable storage medium storing computer instructions, which are used when executed by a processor to:
[0209] According to a preset selection rule, a target code sequence is selected from a code sequence in a code pool, wherein the code pool is constructed according to the code to be tested;
[0210] Determining the code position covered by the target code sequence in the code to be tested by executing the target code sequence;
[0211] In the case where the code position is located at a tested position and at a preset target test position, determining a target change execution strategy for the target code sequence, wherein the tested position is a position covered by the executed code sequence in the code to be tested;
[0212] The code to be tested is tested by changing and executing the target code sequence based on the target change execution strategy.
[0213] The above is a schematic scheme of a computer-readable storage medium of this embodiment. It should be noted that the technical scheme of the storage medium and the technical scheme of the above-mentioned code testing method belong to the same concept, and the details not described in detail in the technical scheme of the storage medium can be referred to the description of the technical scheme of the above-mentioned code testing method.
[0214] The above is a description of a specific embodiment of the specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0215] The computer instructions include computer program codes, which may be in source code form, object code form, executable files or some intermediate forms, etc. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium, etc. It should be noted that the content contained in the computer-readable medium may be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media do not include electric carrier signals and telecommunication signals.
[0216] It should be noted that, for the convenience of description, the aforementioned method embodiments are all described as a series of action combinations, but those skilled in the art should be aware that this specification is not limited by the order of the actions described, because according to this specification, some steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by this specification.
[0217] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0218] The preferred embodiments of this specification disclosed above are only used to help explain this specification. The optional embodiments do not describe all the details in detail, nor do they limit the invention to only the specific implementation methods described. Obviously, many modifications and changes can be made according to the content of this specification. This specification selects and specifically describes these embodiments in order to better explain the principles and practical applications of this specification, so that technicians in the relevant technical field can well understand and use this specification. This specification is limited only by the claims and their full scope and equivalents.
Claims
1. A code testing method, comprising: According to a preset selection rule, a target code sequence is selected from a code sequence in a code pool, wherein the code pool is constructed according to the code to be tested; Determining the code position covered by the target code sequence in the code to be tested by executing the target code sequence; In the case where the code position is located at a tested position and at a preset target test position, a target change execution strategy for the target code sequence is determined, wherein the tested position is a position covered by the executed code sequence in the code to be tested, and the determination of the target change execution strategy for the target code sequence includes: determining the execution priority corresponding to the target code sequence as the target priority; based on the target priority, determining the target change type and the target change execution number of changes to the target code sequence; using the target priority, the target change type and the target change execution number as the target change execution strategy; The code to be tested is tested by changing and executing the target code sequence based on the target change execution strategy.
2. The code testing method according to claim 1, wherein determining a target change execution strategy for the target code sequence comprises: Determining a target change type and a target change execution number for changing the target code sequence; The target change type and the target change execution times are used as the target change execution strategy.
3. The code testing method according to claim 2, wherein determining the target change type and the target change execution times of the target code sequence comprises: Determine the change number algorithm corresponding to the target priority and the target change type of the target code sequence; Based on the change number algorithm and the code position, the target change execution number is determined.
4. The code testing method according to claim 1, wherein determining the target change type and the target change execution times of the target code sequence based on the target priority comprises: Based on the target priority, determining a change number algorithm corresponding to the target priority and a target change type of the target code sequence; Based on the change number algorithm and the code position, the target change execution number is determined.
5. The code testing method according to claim 1, wherein the step of performing a change execution on the target code sequence based on the target change execution strategy comprises: adding the target code sequence to a target priority queue corresponding to the target priority; Obtaining a code sequence to be executed from each priority queue in descending order of priority corresponding to each priority queue, wherein the priority queue comprises: a target priority queue, and the code sequence to be executed comprises: a target code sequence; On the basis that the acquired code sequence to be executed is a target code sequence, determining a change operation for changing the target code sequence each time according to the target change type and the target change execution number; Based on the change operation, the target code sequence is changed, and the changed target code sequence is executed.
6. The code testing method according to claim 1, after determining the code position covered by the target code sequence in the code to be tested, further comprising: In a case where the code position is not located at the tested position, determining that the execution priority corresponding to the target code sequence is a first priority; Based on the first priority, determining a first change type and a first change execution number for changing the target code sequence; The code to be tested is tested by performing a change execution on the target code sequence based on the first priority, the first change type, and the first change execution count.
7. The code testing method according to claim 1, after determining the code position covered by the target code sequence in the code to be tested, further comprising: When the code position is located at the tested position and not at the preset target test position, determining that the execution priority corresponding to the target code sequence is a second priority; Based on the second priority, determining a second change type and a second change execution number for changing the target code sequence; The code to be tested is tested by performing a change execution on the target code sequence based on the second priority level, the second change type, and the second change execution number.
8. The code testing method according to claim 1, after testing the code to be tested, further comprising: Receiving a test end instruction submitted by a user for the code to be tested; Based on the test end instruction, the test on the code to be tested is ended.
9. The code testing method according to claim 1, after testing the code to be tested, further comprising: When it is detected that a preset test end condition is met, the test on the code to be tested is ended.
10. The code testing method according to claim 1, further comprising: Determine a second code position covered by the target code sequence after executing the change in the code to be tested; Based on the second code position, evaluating the changed target code sequence; When the evaluation result meets the preset condition, the code pool is updated according to the changed target code sequence.
11. The code testing method according to claim 10, after evaluating the changed target code sequence, further comprising: When the evaluation result does not satisfy the preset condition, the changed target code sequence is deleted.
12. A code testing device, comprising: A selection module is configured to select a target code sequence from a code sequence in a code pool according to a preset selection rule, wherein the code pool is constructed according to the code to be tested; A position determination module, configured to determine the code position covered by the target code sequence in the code to be tested by executing the target code sequence; A determination strategy module is configured to determine a target change execution strategy for the target code sequence when the code position is located at a tested position and a preset target test position, wherein the tested position is a position covered by the executed code sequence in the code to be tested, and the determination of the target change execution strategy for the target code sequence includes: determining the execution priority corresponding to the target code sequence as the target priority; based on the target priority, determining the target change type and the target change execution number of changes to the target code sequence; and using the target priority, the target change type and the target change execution number as the target change execution strategy; The execution module is configured to test the code to be tested by changing the execution of the target code sequence based on the target change execution strategy.
13. A computing device comprising: Memory and processor; The memory is used to store computer-executable instructions, and the processor is used to execute the computer-executable instructions to implement the following method: According to a preset selection rule, a target code sequence is selected from a code sequence in a code pool, wherein the code pool is constructed according to the code to be tested; Determining the code position covered by the target code sequence in the code to be tested by executing the target code sequence; In the case where the code position is located at a tested position and at a preset target test position, a target change execution strategy for the target code sequence is determined, wherein the tested position is a position covered by the executed code sequence in the code to be tested, and the determination of the target change execution strategy for the target code sequence includes: determining the execution priority corresponding to the target code sequence as the target priority; based on the target priority, determining the target change type and the target change execution number of changes to the target code sequence; using the target priority, the target change type and the target change execution number as the target change execution strategy; The code to be tested is tested by changing and executing the target code sequence based on the target change execution strategy.
14. A computer-readable storage medium storing computer instructions, which, when executed by a processor, implement the steps of the code testing method according to any one of claims 1 to 11.
