CN-121996543-A - Kernel-driven test method, device, equipment and readable storage medium
Abstract
The embodiment of the application provides a method and a device for testing kernel drive, electronic equipment and a computer readable storage medium. The method comprises the steps of obtaining a first image file, a second image file and kernel and driving first version parameters input by a user, wherein the first image file is an image file of a test environment container obtained after the test environment is packaged in a container mode, the test environment is an operation environment of a test tool in a test kernel driving process, the second image file is an image file of a container corresponding to a device to be tested, the kernel driving process is operated in the device to be tested, when the first version parameters are inconsistent with the kernel driving version parameters in the second image file, a target kernel driving process is generated according to the first version parameters, the kernel driving process corresponding to the device to be tested is switched into the target kernel driving process, and the device to be tested is tested according to the first image file and the target kernel driving process to obtain a test result. The test efficiency of the kernel driver can be improved.
Inventors
- Request for anonymity
- Request for anonymity
- Request for anonymity
Assignees
- 摩尔线程智能科技(北京)股份有限公司
Dates
- Publication Date
- 20260508
- Application Date
- 20251226
Claims (11)
- 1. A method for testing a kernel driver, the method comprising: The method comprises the steps of obtaining a first image file, a second image file and a test requirement, wherein the first image file is an image file of a container of a test environment obtained after the test environment is packaged in a container mode, the test environment is an operation environment of a test tool when a kernel driver is tested, the second image file is an image file of a container corresponding to a device to be tested, the kernel driver operates in the device to be tested, and the test requirement is used for indicating a test intention aiming at the device to be tested; Under the condition that the kernel driver in the second image file is not matched with the test requirement, generating a target kernel driver matched with the test requirement according to the test requirement, and switching the kernel driver corresponding to the device to be tested into the target kernel driver; And testing the equipment to be tested according to the first image file and the target kernel driver to obtain a test result of the equipment to be tested.
- 2. The method of claim 1, wherein the test requirements comprise a first version of a kernel driven parameter entered by a user; Under the condition that the kernel driver in the second image file is not matched with the test requirement, generating a target kernel driver matched with the test requirement according to the test requirement, and switching the kernel driver corresponding to the device to be tested into the target kernel driver, wherein the method comprises the following steps: Acquiring a kernel-driven source code file corresponding to the first version parameter under the condition that the first version parameter is inconsistent with the kernel-driven version parameter in the second image file; converting the kernel-driven source code file corresponding to the first version parameter into the target kernel-driven test file; And switching the kernel driver corresponding to the device to be tested into the target kernel driver according to the test file of the target kernel driver.
- 3. The method according to claim 1, wherein, in the case that the kernel driver in the second image file does not match the test requirement, generating a target kernel driver matching the test requirement according to the test requirement, and switching the kernel driver corresponding to the device under test to the target kernel driver, includes: Retrieving a test file of the target kernel driver matching the test requirement from a history test file under the condition that the kernel driver in the second image file is not matched with the test requirement; If the search is successful, switching the kernel driver corresponding to the device to be tested into the target kernel driver according to the test file of the target kernel driver; If the search fails, acquiring a source code file of the kernel driver corresponding to the first version parameter, converting the source code file of the kernel driver corresponding to the first version parameter into a test file of the target kernel driver, and switching the kernel driver corresponding to the device to be tested into the target kernel driver according to the test file of the target kernel driver.
- 4. The method of claim 1, wherein the test requirements include a first version parameter of a kernel driver input by a user, the first version parameter including at least two sets of version parameters, each set of version parameters corresponding to a respective one of the devices under test; Under the condition that the kernel driver in the second image file is not matched with the test requirement, generating a target kernel driver matched with the test requirement according to the test requirement, and switching the kernel driver corresponding to the device to be tested into the target kernel driver, wherein the method comprises the following steps: And under the condition that at least one group of version parameters in the first version parameters are inconsistent with the version parameters of the kernel driver in the second image file, generating the target kernel driver corresponding to the at least one group of version parameters according to the at least one group of version parameters, and switching the kernel driver of the device to be tested corresponding to the at least one group of version parameters into the target kernel driver corresponding to the at least one group of version parameters.
- 5. The method according to claim 1, wherein the method further comprises: And under the condition that the kernel driver in the second image file is matched with the test requirement, testing the equipment to be tested according to the first image file and the second image file to obtain a test result of the equipment to be tested.
- 6. The method according to claim 5, wherein, in the case that the kernel driver in the second image file matches the test requirement, testing the device under test according to the first image file and the second image file to obtain a test result of the device under test, including: Under the condition that the kernel driver in the second image file is matched with the test requirement, starting a container of the test environment and a container of the equipment to be tested according to the test requirement, the first image file and the second image file; controlling a container of the test environment to generate a secret key, and sending the secret key to a container of the equipment to be tested; and responding to the receiving of the secret key by the container of the equipment to be tested, and testing the equipment to be tested according to the first image file and the second image file to obtain a test result of the equipment to be tested.
- 7. The method of claim 1, wherein the test results comprise at least one of a test log file, a fault index file; The method further comprises the steps of: determining a fault code position corresponding to the identifier of the device to be tested in the fault index file according to the identifier of the device to be tested; Extracting a fault code sequence from the test log file according to the fault code position; and generating a fault code file of the equipment to be tested based on the fault code sequence.
- 8. The method of claim 1, wherein the obtaining the second image file comprises: converting the source code of the kernel in the kernel driver into a kernel file; Carrying the kernel file in a preset virtual machine, and generating a third image file based on the preset virtual machine and the kernel file; In a container started based on the third image file, converting source codes driven in the kernel driver into a driving file; And installing the driving file in a container started based on the third image file to obtain a container of the device to be tested corresponding to the kernel driver, and storing the container of the device to be tested corresponding to the kernel driver as the second image file.
- 9. A core-driven test apparatus, the apparatus comprising: The device comprises an acquisition module, a test module and a test module, wherein the acquisition module is used for acquiring a first image file, a second image file and a test requirement, the first image file is an image file of a container of a test environment obtained after the test environment is packaged in a container mode, the test environment is an operation environment of a test tool during the test of the kernel driver, the second image file is an image file of a container corresponding to a device to be tested, the kernel driver operates in the device to be tested, and the test requirement is used for indicating the test intention aiming at the device to be tested; The switching module is used for generating a target kernel driver matched with the test requirement according to the test requirement under the condition that the kernel driver in the second image file is not matched with the test requirement, and switching the kernel driver corresponding to the device to be tested into the target kernel driver; and the test module is used for testing the equipment to be tested according to the first image file and the target kernel driver to obtain a test result of the equipment to be tested.
- 10. An electronic device is characterized by comprising a processor; a memory for storing the processor-executable instructions; Wherein the processor is configured to execute the instructions to implement the method of any one of claims 1 to 8.
- 11. A computer readable storage medium, characterized in that instructions in the computer readable storage medium, when executed by a processor of an electronic device, enable the electronic device to perform the method of any one of claims 1 to 8.
Description
Kernel-driven test method, device, equipment and readable storage medium Technical Field The present application relates to the field of network security technologies, and in particular, to a method and apparatus for testing a kernel driver, an electronic device, and a computer readable storage medium. Background With the increasing complexity of modern operating systems, the security and stability of kernel drivers has become particularly important. Fuzzy testing is an automated software testing technique that can detect potential flaws and security vulnerabilities in kernel drivers by random variation of input data. In the related art, when the kernel driver is subjected to fuzzy test, a test environment can be manually built, including compiling a kernel of a specified version, compiling the driver to be tested, configuring a virtual machine environment and the like, and then the fuzzy test tool is operated to perform fuzzy test. However, in the related art, the method for performing the fuzzy test on the kernel driver of the operating system needs to manually build a test environment for testing, and when the kernel drivers of different versions need to be switched in the test process, the test environment needs to be built again, so that a great amount of resources and time are consumed, and the test efficiency is low. Content of the application The embodiment of the application provides a method and a device for testing a kernel driver, electronic equipment and a computer readable storage medium, which can reduce the resources and time consumed by testing the kernel driver and improve the testing efficiency of the kernel driver. In a first aspect, the present application provides a method for testing a kernel driver, the method comprising: The method comprises the steps of obtaining a first image file, a second image file and a test requirement, wherein the first image file is an image file of a container of a test environment obtained after the test environment is packaged in a container mode, the test environment is an operation environment of a test tool when a kernel driver is tested, the second image file is an image file of a container corresponding to a device to be tested, the kernel driver operates in the device to be tested, and the test requirement is used for indicating a test intention aiming at the device to be tested; Under the condition that the kernel driver in the second image file is not matched with the test requirement, generating a target kernel driver matched with the test requirement according to the test requirement, and switching the kernel driver corresponding to the device to be tested into the target kernel driver; And testing the equipment to be tested according to the first image file and the target kernel driver to obtain a test result of the equipment to be tested. In a second aspect, the present application provides a kernel-driven test apparatus, the apparatus comprising: The device comprises an acquisition module, a test module and a test module, wherein the acquisition module is used for acquiring a first image file, a second image file and a test requirement, the first image file is an image file of a container of a test environment obtained after the test environment is packaged in a container mode, the test environment is an operation environment of a test tool during the test of the kernel driver, the second image file is an image file of a container corresponding to a device to be tested, the kernel driver operates in the device to be tested, and the test requirement is used for indicating the test intention aiming at the device to be tested; The switching module is used for generating a target kernel driver matched with the test requirement according to the test requirement under the condition that the kernel driver in the second image file is not matched with the test requirement, and switching the kernel driver corresponding to the device to be tested into the target kernel driver; And the test module is used for testing the equipment to be tested according to the first image file and the target kernel drive to obtain a test result of the equipment to be tested. In a third aspect, the present application provides an electronic device comprising a memory, and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by one or more processors as described above for a kernel-driven test method. In a fourth aspect, the present application provides a readable storage medium which, when executed by a processor of an electronic device, enables the electronic device to perform a kernel-driven test method as previously described. The embodiment of the application has the following advantages: The method comprises the steps of obtaining a first image file, a second image file and a test requirement, limiting the first image file to be an image file of a container of a test environment obtained after the test environ