Construction method and device of test case template library, electronic equipment and storage medium

By automatically selecting and correcting the test case template collection, the test case template library is built, which solves the complex construction process in the existing technology and improves the efficiency of kernel fuzz testing.

CN120104489APending Publication Date: 2025-06-06TSINGHUA UNIVERSITY +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510174645.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-02-17
Publication Date
2025-06-06

AI Technical Summary

Technical Problem

In the prior art, the process threshold for building a test case template library is high and the configuration process is cumbersome, making it difficult to improve the efficiency of kernel fuzz testing.

Method used

By compiling the configuration file based on the target test kernel, the test case template collection is automatically selected from the preset kernel template library and compiled. When compilation fails, correct the template collection based on the error message until the test case template library is successfully built.

Benefits of technology

The automated test case template library construction process is implemented, which reduces the complexity and threshold of user operations and improves the efficiency of kernel fuzz testing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120104489A_ABST
    Figure CN120104489A_ABST
Patent Text Reader

Abstract

The invention discloses a construction method and device for a test case template library, electronic equipment and a computer storage medium, and the method comprises the steps: selecting a test case template set from a preset kernel template library based on a kernel compiling configuration file of a target test kernel; each test case template in the test case template set is used for guiding generation and variation of kernel test cases; compiling the test case template set; under the condition that compiling of the test case template set fails, correcting the test case template set according to error reporting information generated when compiling fails; and constructing a test case template library according to the corrected test case template set. In the whole construction process of the test case template library, construction of the test case template library can be automatically completed without manual intervention, a more convenient construction scheme of the test case template library is provided for a user, and then the kernel fuzzy testing efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of kernel fuzz testing technology, and in particular to a method, device, electronic device and storage medium for constructing a test case template library. Background Art

[0002] At present, the mainstream Linux kernel fuzz testing tool is syzkaller. In order to effectively use syzkaller for testing, users need to select test case templates from many systems one by one according to different test targets, or write test case templates by themselves to build a test case template library for kernel fuzz testing.

[0003] The test case template library construction solution in the related technology has a high threshold for users to use and the entire configuration process is relatively cumbersome. It is necessary to provide a more convenient test case template library construction solution to improve the efficiency of kernel fuzz testing. Summary of the invention

[0004] The embodiments of the present application provide a method, device, electronic device and computer storage medium for constructing a test case template library, which can provide a more convenient solution for constructing a test case template library to improve the efficiency of kernel fuzz testing.

[0005] In a first aspect, an embodiment of the present application provides a method for constructing a test case template library, the method comprising:

[0006] Based on the kernel compilation configuration file of the target test kernel, a test case template set is selected from a preset kernel template library; each test case template in the test case template set is used to guide the generation and mutation of kernel test cases;

[0007] Compile the test case template collection;

[0008] In the case where the test case template set fails to compile, the test case template set is corrected according to the error message generated when the compilation fails;

[0009] Build a test case template library based on the revised test case template set.

[0010] In a possible implementation, based on the kernel compilation configuration file of the target test kernel, a test case template set is selected from a preset kernel template library, including:

[0011] Based on the kernel compilation configuration file, determining at least one target functional module enabled by the target test kernel;

[0012] According to the preset mapping file and each target functional module, a test case template set is selected from the preset kernel template library.

[0013] In a possible implementation, according to a preset mapping file and each target functional module, a test case template set is selected from a preset kernel template library, including:

[0014] According to the preset mapping file and the target functional module, determine each test case template identifier associated with each target functional module;

[0015] According to each test case template identifier, a test case template set is selected from a preset kernel template library.

[0016] In a possible implementation, the error message includes information about missing template dependencies;

[0017] When the test case template set fails to compile, the test case template set is corrected according to the error message generated when the compilation fails, including:

[0018] In the case where the compilation of the test case template set fails, a dependency completion test case template is selected from a preset kernel template library according to the template dependency missing information generated when the compilation fails;

[0019] Add the dependency completion test case template to the test case template collection to update the test case template collection, and execute the step of compiling the test case template collection again until the compilation is successful.

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

[0021] When the test case template set is compiled successfully, a test case template library is constructed according to the test case template set.

[0022] In a possible implementation, before selecting a test case template set from a preset kernel template library based on the kernel compilation configuration file, the method further includes:

[0023] In response to the template library automatic construction request, sending a kernel compile configuration file upload prompt message to the user terminal, so that the user terminal displays the kernel compile configuration file upload prompt message;

[0024] Receive the kernel compilation configuration file uploaded by the user terminal.

[0025] In a possible implementation, after building a test case template library according to the revised test case template set, the method further includes:

[0026] The test case template library is called by the fuzz testing engine to perform kernel fuzz testing.

[0027] In a second aspect, an embodiment of the present application provides a device for constructing a test case template library, the device comprising:

[0028] A selection module is used to select a test case template set from a preset kernel template library based on a kernel compilation configuration file; each test case template in the test case template set is used to guide the generation and mutation of kernel test cases;

[0029] Compilation module, used to compile the test case template set;

[0030] A correction module, used to correct the test case template set according to the error message generated when the compilation fails, when the test case template set fails to compile;

[0031] The building module is used to build a test case template library according to the revised test case template set.

[0032] In a third aspect, an embodiment of the present application provides an electronic device, comprising: a processor and a memory; wherein the memory stores a computer program, and the computer program is suitable for being loaded by the processor and executing the method steps provided in the first aspect of the embodiment of the present application.

[0033] In a fourth aspect, an embodiment of the present application provides a computer storage medium, wherein the computer storage medium stores a plurality of instructions, wherein the instructions are suitable for being loaded by a processor and executing the method steps provided in the first aspect of the embodiment of the present application.

[0034] The construction method, device, electronic device and computer storage medium of the test case template library described above can automatically select a test case template set from a preset kernel template library based on the kernel compilation configuration file of the target test kernel, and can determine the test case template matching the target test kernel based on the automated process to guide the generation and mutation of kernel test cases; by compiling the test case template set, in the case where the compilation of the test case template set fails, the test case template set is automatically corrected according to the error message generated when the compilation fails, and a test case template library is constructed according to the corrected test case template set, which can ensure the availability of the automatically constructed test case template library. The entire test case template library construction process can automatically complete the construction of the test case template library without manual intervention by automatically selecting the test case template set and automatically correcting the test case template set according to the error message generated when the compilation fails, providing users with a more convenient test case template library construction solution, thereby improving the efficiency of kernel fuzz testing. BRIEF DESCRIPTION OF THE DRAWINGS

[0035] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0036] Figure 1 A schematic diagram of an application environment of a method for constructing a test case template library provided by an exemplary embodiment of the present application;

[0037] Figure 2 A flowchart of a method for constructing a test case template library provided by an exemplary embodiment of the present application;

[0038] Figure 3 A flowchart of another method for constructing a test case template library provided by an exemplary embodiment of the present application;

[0039] Figure 4 A schematic diagram of the architecture of a method for constructing a test case template library provided by an exemplary embodiment of the present application;

[0040] Figure 5 A schematic diagram of a structure of a device for constructing a test case template library is provided for an exemplary embodiment of the present application;

[0041] Figure 6 A structural schematic diagram of an electronic device is provided for an exemplary embodiment of the present application. DETAILED DESCRIPTION

[0042] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0043] In the description of the present application, it should be understood that the terms "first", "second", etc. are used for descriptive purposes only and should not be understood as indicating or implying relative importance. For those of ordinary skill in the art, the specific meanings of the above terms in the present application can be understood according to the specific circumstances. In addition, in the description of the present application, unless otherwise specified, "multiple" refers to two or more. "And / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the objects associated before and after are in an "or" relationship.

[0044] The method for constructing a test case template library provided in the embodiment of the present application can be applied to Figure 1In the application environment shown. Among them, the user terminal 10 communicates with the management node server 20 through the network, and the management node server 20 communicates with at least one test node server (shown as test node servers 31-33) through the network. The management node server 20 is used to send kernel fuzzy test tasks to each test node server, and collect kernel fuzzy test data uploaded by each test node server for analysis and storage. The data storage system 40 can store data that the management node server 20 needs to process. The data storage system 40 can be integrated on the management node server 20, or it can be placed on the cloud or other network servers. In the embodiment of the present application, the management node server 20 selects a test case template set from a preset kernel template library based on the kernel compilation configuration file of the target test kernel; each test case template in the test case template set is used to guide the generation and mutation of kernel test cases; the test case template set is compiled; in the case where the test case template set fails to compile, the test case template set is corrected according to the error information generated when the compilation fails; according to the corrected test case template set, a test case template library is constructed.

[0045] It is worth noting that the user terminal 10 can be implemented as an independent terminal or a terminal cluster composed of multiple terminals. The user terminal 10 can be, but is not limited to, various personal computers, laptops, smart phones, tablet computers, Internet of Things devices and portable wearable devices. The Internet of Things devices can be smart speakers, smart TVs, smart air conditioners, smart car devices, etc. Portable wearable devices can be smart watches, smart bracelets, head-mounted devices, etc. The management node server 20 can be implemented as an independent server or a server cluster composed of multiple servers.

[0046] In one embodiment, Figure 2 As shown, a method for constructing a test case template library is provided, and this method is applied to Figure 1 Taking the management node server 20 in the example as an example, the following steps are included:

[0047] S201: Based on the kernel compilation configuration file of the target test kernel, a test case template set is selected from a preset kernel template library.

[0048] The target test kernel is the kernel selected by the user for performing kernel fuzz testing. The kernel compilation configuration file (config file) contains various configuration options for compiling the target test kernel, which define at least one target function module enabled by the target test kernel. Each target function module will be compiled into the kernel before performing kernel fuzz testing. The test case template set includes at least one test case template, and each test case template is used to guide the generation and mutation of kernel test cases.

[0049] Optionally, when the user issues a template library automatic construction request through the user terminal, the management node server responds to the template library automatic construction request and sends a kernel compilation configuration file upload prompt message to the user terminal, so that the user terminal displays the kernel compilation configuration file upload prompt message. After the user uploads the kernel compilation configuration file of the target test kernel through the user terminal, the management node server receives the kernel compilation configuration file uploaded by the user terminal, and based on the kernel compilation configuration file, selects a test case template library set from a preset kernel template library, and each test case template in the test case template set is used to guide the generation and mutation of kernel test cases.

[0050] Specifically, the management node server determines at least one target function module enabled by the target test kernel based on the kernel compilation configuration file. Then, according to the preset mapping file and the target function module, each test case template identifier associated with each target function module is determined. Finally, according to each test case template identifier, a test case template set is selected from a preset kernel template library.

[0051] In this embodiment, the management node server automatically selects a set of test case templates from a preset kernel template library based on the kernel compilation configuration file of the target test kernel, and can determine the test case template that matches the target test kernel based on an automated process, thereby effectively improving the convenience of test case template construction and thereby improving the efficiency of kernel fuzz testing.

[0052] S202: Compile the test case template set.

[0053] Optionally, the management node server compiles the selected test case template set to promptly discover and correct potential errors in the test case template set, ensuring that an executable kernel image can be generated subsequently to start the kernel in the test environment.

[0054] In this embodiment, after the management node server selects a test case template set from a preset kernel template library, it automatically compiles the test case template set without the user having to manually issue compilation commands through the user terminal, effectively improving the convenience of test case template construction and thereby improving the efficiency of kernel fuzz testing.

[0055] S203: When the compilation of the test case template set fails, the test case template set is corrected according to the error message generated when the compilation fails.

[0056] The error information includes, but is not limited to, missing information about template dependencies.

[0057] Optionally, when the compilation of the test case template set fails, the management node server selects a dependency completion test case template from a preset kernel template library according to the template dependency missing information generated when the compilation fails. Then, the dependency completion test case template is added to the test case template set to update the test case template set, and the test case template set is compiled again until the compilation succeeds.

[0058] In this embodiment, when the compilation of the test case template set fails, the management node server automatically corrects the test case template set according to the error information generated when the compilation fails to update the test case template set, and compiles the test case template set again until the compilation is successful, thereby effectively improving the convenience of test case template construction and thereby improving the efficiency of kernel fuzz testing.

[0059] S204: Construct a test case template library according to the revised test case template set.

[0060] The revised test case template set is a revised test case template set that can be compiled successfully.

[0061] It can be understood that each test case template in the revised test case template set is stored in the same designated directory of the management node server. When the revised test case template set is compiled successfully, the management node server builds a test case template library based on all the test case templates stored in the designated directory, that is, integrates all the test case templates stored in the designated directory into the test case template library.

[0062] In this embodiment, the management node server constructs a test case template library based on the revised test case template set, which can ensure the availability of the automatically constructed test case template library, effectively improve the convenience of test case template construction, and thus improve the efficiency of kernel fuzz testing.

[0063] The method for constructing the test case template library is applied to the management node server. The management node server automatically selects a test case template set from a preset kernel template library based on the kernel compilation configuration file of the target test kernel, and can determine the test case template matching the target test kernel based on the automated process to guide the generation and mutation of the kernel test case; by compiling the test case template set, in the case where the compilation of the test case template set fails, the test case template set is automatically corrected according to the error message generated when the compilation fails, and the test case template library is constructed according to the corrected test case template set, which can ensure the availability of the automatically constructed test case template library. The entire test case template library construction process automatically selects the test case template set and automatically corrects the test case template set according to the error message generated when the compilation fails, and the test case template library can be automatically constructed without manual intervention, providing users with a more convenient test case template library construction solution, thereby improving the efficiency of kernel fuzz testing.

[0064] In one embodiment, Figure 3 As shown in the figure, another method for constructing a test case template library is provided. This method is applied to Figure 1 Taking the management node server 20 in the example as an example, the following steps are included:

[0065] S301: In response to a template library automatic construction request, sending a kernel compile configuration file upload prompt message to a user terminal, so that the user terminal displays the kernel compile configuration file upload prompt message.

[0066] Optionally, when a user issues a template library automatic construction request through a user terminal, the template library construction module running on the management node server responds to the template library automatic construction request and sends a kernel compilation configuration file upload prompt message to the user terminal, so that the Web UI interface of the user terminal displays the kernel compilation configuration file upload prompt message, thereby facilitating the user to upload the kernel compilation configuration file of the target test kernel through the user terminal after seeing the kernel compilation configuration file upload prompt message displayed on the Web UI interface.

[0067] S302: Receive a kernel compilation configuration file uploaded by a user terminal.

[0068] The kernel compilation configuration file is a text file containing various configuration options for compiling the target test kernel. These configuration options define at least one target function module enabled by the target test kernel. Each target function module will be compiled into the kernel before performing kernel fuzz testing. For example, if the "CONFIG_IO_URING=y" field appears in the kernel compilation configuration file, it means that the target test kernel enables the io_uring subsystem. The template library construction module running on the subsequent management node server will select the test case template associated with the io_uring subsystem to guide the generation and mutation of kernel test cases.

[0069] Optionally, the template library construction module running on the management node server receives the kernel compilation configuration file uploaded by the user terminal, parses the kernel compilation configuration file, obtains various configuration options for compiling the target test kernel contained in the kernel compilation configuration file, and then selects a test case template set from the preset kernel template library based on the various configuration options of the target test kernel.

[0070] In this embodiment, the template library construction module running on the management node server responds to the user's template library automatic construction request, sends a kernel compilation configuration file upload prompt message to the user terminal, and after receiving the kernel compilation configuration file uploaded by the user terminal, starts the automatic construction process of the test case template library, providing the user with a more convenient test case template library construction plan, thereby improving the efficiency of kernel fuzz testing.

[0071] S303: Determine at least one target functional module enabled by the target test kernel based on the kernel compilation configuration file.

[0072] The at least one target functional module enabled by the target test kernel includes but is not limited to a subsystem enabled by the target test kernel, a device module enabled by the target test kernel, and the like.

[0073] Optionally, the template library construction module running on the management node server determines at least one target functional module enabled by the target test kernel based on various configuration options used to compile the target test kernel in the kernel compilation configuration file. For example, if the "CONFIG_IO_URING=y" field appears in the kernel compilation configuration file, it means that the target test kernel has enabled the io_uring subsystem, and the template library construction module running on the management node server will select the test case template associated with the io_uring subsystem as one of the test case templates in the test case template set.

[0074] S304: Select a test case template set from a preset kernel template library according to a preset mapping file and each target functional module.

[0075] The preset mapping file is a text file that associates and stores each functional module of the test kernel with each test case template in the preset kernel template library. Each line in the mapping file is used to associate and store a functional module identifier of the test kernel with a test case template identifier of the preset kernel template library. The preset kernel template library pre-stores multiple kernel template files, from which the template library construction module running on the management node server can select a test case template set to automatically construct a test case template library.

[0076] It is worth noting that the preset kernel template library is a kernel template library pre-configured under the user account, and the preset kernel template library is editable. Specifically, the template library management module running on the management node server can respond to the template editing request sent by the user through the user terminal to perform personalized editing on the preset kernel template library. For example, add the test case template written by the user to the preset kernel template library, or delete the test case template specified by the user in the preset kernel template library, or perform personalized editing on the test case template specified by the user in the preset kernel template library, etc. In addition, the template library management module running on the management node server can also respond to the template selection request sent by the user through the user terminal, and select the test case template specified by the user from the preset kernel template library to manually construct the test case template library.

[0077] In this embodiment, the template library construction module running on the management node server automatically determines at least one target functional module enabled by the target test kernel based on the various configuration options in the kernel compilation configuration file used to compile the target test kernel, and automatically selects a set of test case templates from the preset kernel template library according to the preset mapping file and each target functional module to construct a test case template library, thereby improving the level of automation in the construction of the test case template library and thereby improving the efficiency of kernel fuzz testing.

[0078] In one embodiment, a test case template set is selected from a preset kernel template library according to a preset mapping file and each target functional module, including: determining each test case template identifier associated with each target functional module according to the preset mapping file and the target functional module; and selecting a test case template set from the preset kernel template library according to each test case template identifier.

[0079] It can be understood that the preset mapping file is a text file that associates and stores each functional module of the test kernel with each test case template in the preset kernel template library. Each line in the mapping file is used to associate and store a functional module identifier of the test kernel with a test case template identifier of the preset kernel template library. The template library construction module running on the management node server matches each target functional module identifier corresponding to each target functional module enabled by the target test kernel line by line in the preset mapping file to determine each test case template identifier stored in association with each target functional module identifier. Then, according to each test case template identifier, a test case template set is selected from the preset kernel template library.

[0080] In this embodiment, the template library construction module running on the management node server determines each test case template identifier based on the preset mapping file and the target function module identifiers corresponding to each target function module, and then selects a test case template set from the preset kernel template library based on each test case template identifier to construct a test case template library. The entire process determines the test case template that matches the target test kernel based on the automated process, effectively improving the convenience of test case template construction, thereby improving the efficiency of kernel fuzz testing.

[0081] S305: Compile the test case template set.

[0082] Optionally, the template library construction module running on the management node server compiles the selected test case template set to promptly discover and correct potential errors in the test case template set, ensuring that an executable kernel image can be generated subsequently to start the kernel in the test environment.

[0083] In this embodiment, after the management node server selects a test case template set from a preset kernel template library, it automatically compiles the test case template set without the user having to manually issue compilation commands through the user terminal, effectively improving the convenience of test case template construction and thereby improving the efficiency of kernel fuzz testing.

[0084] S306: Determine whether the compilation of the test case template set is successful. If yes, execute S307; if no, execute S309.

[0085] Optionally, after compiling the test case template set, the template library construction module running on the management node server determines whether the compilation of the test case template set is successful. If the compilation of the test case template set is successful, it means that there is no dependency problem between the test case templates in the test case template set. At this time, the test case template library is directly constructed based on the current test case template set; if the compilation of the test case template set fails, it means that there may be a dependency problem between the test case templates in the test case template set. At this time, according to the error information generated when the compilation fails, the current test case template set is corrected, and then the test case template library is constructed based on the corrected test case template set.

[0086] S307: Construct a test case template library according to the test case template set.

[0087] It can be understood that each test case template in the test case template set is stored in the same designated directory of the management node server. When the test case template set is compiled successfully, the template library construction module running on the management node server builds a test case template library based on the test case template set stored in the designated directory.

[0088] In this embodiment, when the test case template set is compiled successfully, the template library construction module running on the management node server can directly build a test case template library based on the current test case template set without human intervention, which effectively improves the convenience of test case template construction and thereby improves the efficiency of kernel fuzz testing.

[0089] S308: Calling the test case template library through the fuzz testing engine to perform kernel fuzz testing.

[0090] Optionally, after the test case template library is constructed, the task management module running on the management node server calls the test case template library through the fuzz testing engine to perform kernel fuzz testing on each test node server.

[0091] Specifically, the management node server sends the test resources of the kernel fuzz test to each test node server in advance, and then starts the fuzz test engine on the management node. After startup, the fuzz test engine connects to each test node according to the IP address of each test node server in the engine configuration file, and calls the test case template library on the management node server to perform kernel fuzz testing on each test node server.

[0092] In this embodiment, the fuzz test engine running on the management node server calls the test case template library through the fuzz test engine to perform kernel fuzz testing on each test node server, which can effectively improve the efficiency of kernel fuzz testing.

[0093] S309: According to the template dependency missing information generated when the compilation fails, a dependency completion test case template is selected from a preset kernel template library.

[0094] The template dependency missing information is used to describe the missing dependency between the test case templates in the test case template set. The dependency completion test case template is a test case template used to complete the template dependency in the test case template set.

[0095] Optionally, in the event that compilation of a test case template set fails, the template library construction module running on the management node server selects a test case template from a preset kernel template library to complete the template dependencies in the test case template set based on the missing template dependency information generated when the compilation fails.

[0096] S310: Add the dependency completion test case template to the test case template set to update the test case template set, and execute S305 again.

[0097] Optionally, the template library construction module running on the management node server selects a test case template for completing the template dependency in the test case template set from the preset kernel template library according to the missing information of the template dependency generated when the compilation fails, and then adds the dependency completion test case template to the test case template set to update the test case template set, and compiles the test case template set again to determine whether the compilation of the test case template set is successful. If the compilation of the test case template set is successful, the test case template library is constructed according to the current test case template set; if the compilation of the test case template set fails, according to the error information generated when the compilation fails, the dependency completion test case template is selected again from the preset kernel template library, and the dependency completion test case template is added to the test case template set again to update the test case template set again, and the test case template set is compiled again until the test case template set is compiled successfully, and if the compilation of the test case template set is successful, the test case template library is constructed according to the test case template set.

[0098] In this embodiment, when the compilation of the test case template set fails, the template library construction module running on the management node server automatically corrects the test case template set according to the missing template dependency information generated when the compilation fails, until the test case template set is compiled successfully, and constructs a test case template library based on the corrected test case template set that can be compiled successfully. Through repeated compilation, the availability of the automatically constructed test case template library can be ensured, which effectively improves the convenience of test case template construction, thereby improving the efficiency of kernel fuzz testing.

[0099] See also Figure 4, is a schematic diagram of the architecture of the construction method of the test case template library. The user sends a template library automatic construction request through the user terminal, and the template library construction module running on the management node server (such as the HTTP server) responds to the template library automatic construction request, starts the template automatic construction process, and sends a kernel compilation configuration file upload prompt message to the user terminal, so that the Web UI interface of the user terminal displays the kernel compilation configuration file upload prompt message. After the user uploads the kernel compilation configuration file of the target test kernel through the user terminal, the template library construction module running on the management node server selects a test case template set from the kernel template library according to the kernel compilation configuration file. It can be understood that when the test case template set is compiled for the first time, the test case template set may be compiled successfully or may fail to compile. In the case where the test case template set is compiled successfully, the test case template library is automatically constructed directly according to the test case template set. In the case where the test case template set fails to compile, the dependency completion test case template is added to the test case template set to correct the test case template set until the test case template set is compiled successfully, and in the case where the test case template set is compiled successfully, the test case template library is automatically constructed according to the test case template set that is compiled successfully.

[0100] The above-mentioned test case template library construction method is applied to the management node server. Specifically, the template library construction module running on the management node server responds to the user's template library automatic construction request, sends a kernel compilation configuration file upload prompt message to the user terminal, and after receiving the kernel compilation configuration file uploaded by the user terminal, starts the automatic construction process of the test case template library, providing users with a more convenient test case template library construction plan; by determining each test case template identifier according to the preset mapping file and each target function module corresponding to each target function module, and then selecting a test case template set from the preset kernel template library according to each test case template identifier to construct the test case template library, it can automatically and efficiently determine the test case template that matches the target test kernel, effectively improving the test efficiency. The efficiency of test case template construction is improved; by automatically compiling the test case template set, when the test case template set is compiled successfully, a test case template library is built according to the test case template set, and the test case template library is called by the fuzz test engine to perform kernel fuzz testing, so that the test case template can be quickly built without human intervention; when the test case template set fails to compile, according to the missing information of the template dependency generated when the compilation fails, the dependency completion test case template is selected from the preset kernel template library, and the dependency completion test case template is added to the test case template set to update the test case template set until the test case template set is compiled successfully, so as to ensure the availability of the automatically constructed test case template library. The entire test case template library construction process automatically selects the test case template set, and automatically corrects the test case template set according to the error information generated when the compilation fails. The test case template library construction can be automatically completed without human intervention, providing users with a more convenient test case template library construction solution, thereby improving the efficiency of kernel fuzz testing.

[0101] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.

[0102] Based on the inventive concept of the method for constructing the test case template library, Figure 5As shown, the embodiment of the present application also provides a test case template library construction device 500 for implementing the test case template library construction method involved above. The test case template library construction device 500 includes:

[0103] A selection module 501 is used to select a test case template set from a preset kernel template library based on a kernel compilation configuration file of a target test kernel; each test case template in the test case template set is used to guide the generation and mutation of kernel test cases;

[0104] Compilation module 502, used to compile the test case template set;

[0105] A correction module 503 is used to correct the test case template set according to the error information generated when the compilation fails when the test case template set fails;

[0106] The construction module 504 is used to construct a test case template library according to the revised test case template set.

[0107] In one possible implementation, the selection module 501 is specifically used to determine at least one target functional module enabled by the target test kernel based on the kernel compilation configuration file; and select a test case template set from a preset kernel template library according to a preset mapping file and each target functional module.

[0108] In a possible implementation, the selection module 501 is specifically used to determine each test case template identifier associated with each target functional module according to a preset mapping file and target functional module; and select a test case template set from a preset kernel template library according to each test case template identifier.

[0109] In one possible implementation, the error information includes template dependency missing information; the correction module 503 is specifically used to select a dependency completion test case template from a preset kernel template library based on the template dependency missing information generated when the compilation fails when the test case template set fails to compile; the dependency completion test case template is added to the test case template set to update the test case template set, and the step of compiling the test case template set is executed again until the compilation is successful.

[0110] In a possible implementation, the construction module 504 is further configured to construct a test case template library according to the test case template set when the test case template set is compiled successfully.

[0111] In a possible implementation, the test case template library construction device 500 also includes a response module and a receiving module. The response module is used to respond to the template library automatic construction request, send a kernel compilation configuration file upload prompt message to the user terminal, so that the user terminal displays the kernel compilation configuration file upload prompt message; the receiving module is used to receive the kernel compilation configuration file uploaded by the user terminal.

[0112] In a possible implementation, the test case template library construction device 500 further includes an execution module, which is used to call the test case template library through the fuzzy test engine to perform kernel fuzz testing.

[0113] Each module in the test case template library construction device 500 can be implemented in whole or in part by software, hardware, or a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute operations corresponding to each module.

[0114] The embodiment of the present application also provides an electronic device, which may be a server, and its internal structure diagram may be as follows: Figure 6 As shown. The electronic device includes a processor, a memory, an input / output interface (Input / Output, referred to as I / O) and a communication interface. Among them, the processor, the memory and the input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. Among them, the processor of the electronic device is used to provide computing and control capabilities. The memory of the electronic device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the electronic device is used to store test case template library construction data. The input / output interface of the electronic device is used to exchange information between the processor and an external device. The communication interface of the electronic device is used to communicate with an external terminal through a network connection. The processor of the electronic device executes a computer program to implement a method for generating a server image.

[0115] Those skilled in the art will understand that Figure 6 The structure shown in the figure is merely a block diagram of a partial structure related to the scheme of the present application, and does not constitute a limitation on the electronic device to which the scheme of the present application is applied. The specific electronic device may include more or fewer components than shown in the figure, or combine certain components, or have a different arrangement of components.

[0116] In a possible implementation, an electronic device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and when the processor executes the computer program, the following steps are implemented:

[0117] Based on the kernel compilation configuration file of the target test kernel, a test case template set is selected from a preset kernel template library; each test case template in the test case template set is used to guide the generation and mutation of kernel test cases;

[0118] Compile the test case template collection;

[0119] In the case where the test case template set fails to compile, the test case template set is corrected according to the error message generated when the compilation fails;

[0120] Build a test case template library based on the revised test case template set.

[0121] In one possible implementation, the processor also implements the following steps when executing the computer program: based on the kernel compilation configuration file, determining at least one target functional module enabled by the target test kernel; and selecting a test case template set from a preset kernel template library according to a preset mapping file and each target functional module.

[0122] In a possible implementation, the processor also implements the following steps when executing the computer program: determining each test case template identifier associated with each target functional module based on a preset mapping file and target functional module; and selecting a test case template set from a preset kernel template library based on each test case template identifier.

[0123] In one possible implementation, the error information includes template dependency missing information; when the processor executes the computer program, the following steps are also implemented: in the event that the compilation of the test case template set fails, a dependency completion test case template is selected from a preset kernel template library based on the template dependency missing information generated when the compilation fails; the dependency completion test case template is added to the test case template set to update the test case template set, and the step of compiling the test case template set is performed again until the compilation is successful.

[0124] In a possible implementation, the processor further implements the following steps when executing the computer program: when the test case template set is compiled successfully, construct a test case template library according to the test case template set.

[0125] In a possible implementation, the processor further implements the following steps when executing the computer program: in response to a template library automatic construction request, sending a kernel compilation configuration file upload prompt message to a user terminal so that the user terminal displays the kernel compilation configuration file upload prompt message; and receiving the kernel compilation configuration file uploaded by the user terminal.

[0126] In a possible implementation, when the processor executes the computer program, it further implements the following steps: calling a test case template library through a fuzz testing engine to perform kernel fuzz testing.

[0127] The present application also provides a computer storage medium, which stores instructions, and when the instructions are executed on a computer or a processor, the computer or the processor executes one or more steps in the above embodiment. If the components of the above electronic device are implemented in the form of software functional units and sold or used as independent products, they can be stored in the above computer readable storage medium.

[0128] In a possible implementation, a computer storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the following steps are implemented:

[0129] Based on the kernel compilation configuration file of the target test kernel, a test case template set is selected from a preset kernel template library; each test case template in the test case template set is used to guide the generation and mutation of kernel test cases;

[0130] Compile the test case template collection;

[0131] In the case where the test case template set fails to compile, the test case template set is corrected according to the error message generated when the compilation fails;

[0132] Build a test case template library based on the revised test case template set.

[0133] In one possible implementation, when the computer program is executed by the processor, the following steps are also implemented: based on the kernel compilation configuration file, determining at least one target functional module enabled by the target test kernel; and selecting a test case template set from a preset kernel template library according to a preset mapping file and each target functional module.

[0134] In one possible implementation, when the computer program is executed by the processor, the following steps are also implemented: based on a preset mapping file and target functional modules, each test case template identifier associated with each target functional module is determined; based on each test case template identifier, a test case template set is selected from a preset kernel template library.

[0135] In one possible implementation, the error information includes template dependency missing information; when the computer program is executed by the processor, the following steps are also implemented: in the event that the compilation of the test case template set fails, a dependency completion test case template is selected from a preset kernel template library based on the template dependency missing information generated when the compilation fails; the dependency completion test case template is added to the test case template set to update the test case template set, and the step of compiling the test case template set is executed again until the compilation is successful.

[0136] In a possible implementation, when the computer program is executed by the processor, the following steps are further implemented: when the test case template set is compiled successfully, a test case template library is constructed according to the test case template set.

[0137] In one possible implementation, when the computer program is executed by the processor, the following steps are also implemented: in response to the template library automatic construction request, a kernel compilation configuration file upload prompt message is sent to the user terminal so that the user terminal displays the kernel compilation configuration file upload prompt message; and the kernel compilation configuration file uploaded by the user terminal is received.

[0138] In a possible implementation, when the computer program is executed by the processor, the following steps are also implemented: calling the test case template library through the fuzz testing engine to perform kernel fuzz testing.

[0139] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer storage medium or transmitted through the computer storage medium. The computer instructions can be transmitted from a website site, computer, server or data center to another website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (Digital Subscriber Line, DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode. The computer storage medium can be any available medium that a computer can access or a data storage device such as a server, data center, etc. that contains one or more available media integrated. The available medium may be a magnetic medium (eg, a floppy disk, a hard disk, a magnetic tape), an optical medium (eg, a digital versatile disc (DVD)), or a semiconductor medium (eg, a solid state disk (SSD)).

[0140] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a computer program, and the program can be stored in a computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above-mentioned methods. The aforementioned storage medium includes: ROM, RAM, magnetic disk or optical disk and other media that can store program codes. In the absence of conflict, the technical features in this embodiment and the implementation scheme can be combined arbitrarily.

[0141] The embodiments described above are merely preferred embodiments of the present application and are not intended to limit the scope of the present application. Without departing from the design spirit of the present application, various modifications and improvements made to the technical solutions of the present application by ordinary technicians in this field should fall within the protection scope determined by the claims.

[0142] The above describes a specific embodiment of the present application. 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 accompanying 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.

Claims

1. A method for constructing a test case template library, characterized in that: The method comprises: Based on the kernel compilation configuration file of the target test kernel, a test case template set is selected from a preset kernel template library; each test case template in the test case template set is used to guide the generation and mutation of kernel test cases; Compiling the test case template set; In the case where the compilation of the test case template set fails, the test case template set is corrected according to the error message generated when the compilation fails; A test case template library is constructed based on the revised test case template set.

2. The method according to claim 1, characterized in that The kernel compilation configuration file based on the target test kernel selects a test case template set from a preset kernel template library, including: Based on the kernel compilation configuration file, determining at least one target functional module enabled by the target test kernel; According to the preset mapping file and each of the target functional modules, a test case template set is selected from the preset kernel template library.

3. The method according to claim 2, characterized in that The step of selecting a test case template set from the preset kernel template library according to the preset mapping file and each of the target function modules comprises: Determine, according to the preset mapping file and the target functional module, each test case template identifier associated with each target functional module; According to the test case template identifiers, a test case template set is selected from the preset kernel template library.

4. The method according to claim 1, characterized in that The error message includes template dependency missing information; In the case where the compilation of the test case template set fails, the test case template set is corrected according to the error information generated when the compilation fails, including: In the case where the compilation of the test case template set fails, selecting a dependency completion test case template from the preset kernel template library according to the template dependency missing information generated when the compilation fails; The dependency completion test case template is added to the test case template set to update the test case template set, and the step of compiling the test case template set is performed again until the compilation is successful.

5. The method according to claim 1, characterized in that The method further comprises: When the test case template set is compiled successfully, the test case template library is constructed according to the test case template set.

6. The method according to claim 1, characterized in that Before selecting a test case template set from a preset kernel template library based on the kernel compilation configuration file, the method further includes: In response to the template library automatic construction request, sending a kernel compile configuration file upload prompt message to the user terminal, so that the user terminal displays the kernel compile configuration file upload prompt message; Receive a kernel compilation configuration file uploaded by the user terminal.

7. The method according to claim 1, characterized in that After constructing a test case template library according to the modified test case template set, the method further includes: The test case template library is called by a fuzz testing engine to perform kernel fuzz testing.

8. A device for constructing a test case template library, characterized in that: The device comprises: A selection module is used to select a test case template set from a preset kernel template library based on a kernel compilation configuration file of a target test kernel; each test case template in the test case template set is used to guide the generation and mutation of kernel test cases; A compiling module, used for compiling the test case template set; A correction module, used for correcting the test case template set according to the error information generated when the compilation fails, when the compilation of the test case template set fails; A construction module is used to construct a test case template library according to the revised test case template set.

9. An electronic device, characterized in that: include: A processor and a memory; the memory stores a computer program, and the processor implements the method steps of any one of claims 1 to 7 when executing the computer program.

10. A computer storage medium, characterized in that: The computer storage medium stores a plurality of instructions, which are suitable for being loaded by a processor and executing the method steps according to any one of claims 1 to 7.