System testing method, device, electronic device and readable medium
By obtaining the address alignment unit and performing address alignment detection, it solves the problem of system call alignment testing in the operating system, improves test coverage and memory access efficiency, and ensures the normal execution of system calls in various scenarios.
Patent Information
- Application Number
- CN202410943695.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-15
- Publication Date
- 2024-10-01
- Estimated Expiration
- 2044-07-15
AI Technical Summary
In various test scenarios, how to ensure that system calls in the operating system can be executed normally, especially how to test whether the original address can be aligned normally to ensure the effectiveness of the memory mapping mechanism.
By obtaining the address alignment unit, performing an address alignment operation, the target address is obtained, and the target address is detected based on the address alignment unit to ensure that it meets the preset alignment requirements, thereby determining whether the operating system corresponding to the target system call passes the test.
It improves the test coverage, enables testing in multi-page alignment scenarios, ensures that system calls can be executed normally in various test scenarios, improves memory access efficiency and avoids performance problems.
Smart Images

Figure CN118484402B_ABST
Abstract
Description
Technical Field
[0001] Embodiments of the present invention relate to the field of computer technology, and in particular to a system testing method, device, electronic device, and readable medium. Background Art
[0002] Currently, memory mapping is a mechanism that maps files or other objects in the disk address space directly to the virtual address space. This mechanism can be implemented through system calls related to memory mapping. The memory mapping mechanism is equivalent to establishing a one-to-one correspondence between the virtual address space and the disk address space, mapping the disk file from its original address on the disk directly to the target address in the virtual address space. This allows users to operate on disk files as if they were operating in memory, thereby reducing actual disk input / output (I / O) operations.
[0003] Operating systems provide a variety of system calls related to memory mapping. When using these system calls for mapping, the original addresses corresponding to the system call parameters must be aligned to complete memory mapping testing. To ensure that system calls in the operating system can execute properly, it is necessary to test whether the original addresses are properly aligned. Therefore, how to implement testing in various test scenarios has become a pressing technical challenge. Summary of the Invention
[0004] The embodiments of the present invention provide a system testing method, device, electronic device and readable medium, which can implement testing in multiple testing scenarios and improve test coverage.
[0005] In order to solve the above problems, an embodiment of the present invention discloses a system testing method, which includes:
[0006] Obtaining the address alignment unit corresponding to this test; the address alignment unit is used to represent the number of pages corresponding to the address alignment operation;
[0007] Performing the address alignment operation on the original address of the target system call according to the address alignment unit to obtain a target address; the target address is used to represent the original address after alignment;
[0008] detecting the target address based on the address alignment unit to implement system testing;
[0009] When it is detected that the target address meets the preset alignment requirement, it is determined that the operating system corresponding to the target system call passes the test.
[0010] Optionally, the method further includes: obtaining a mapping status value of the target system call; and detecting the target address based on the address alignment unit includes:
[0011] detecting whether the target address is correct based on the address alignment unit;
[0012] If the target address is correct and the mapping status value indicates that the mapping is successful, determining that the target address meets the preset alignment requirement;
[0013] If the target address is incorrect or the mapping status value indicates a mapping failure, it is determined that the target address does not meet the preset alignment requirement.
[0014] Optionally, if the target address is correct and the mapping status value indicates that the mapping is successful, determining that the target address meets the preset alignment requirement includes:
[0015] If the target address is correct and the mapping status value indicates successful mapping, detecting whether the target system call is for memory remapping;
[0016] In a case where the target system call is not used for memory remapping, it is determined that the target address is detected to meet the preset alignment requirement.
[0017] Optionally, the target address includes a first address and a second address; and the method further includes:
[0018] In a case where the target system call is for memory remapping, detecting whether the storage content of the first address is consistent with the storage content of the second address; the first address is obtained by aligning the old mapping address in the original address, and the second address is obtained by aligning the new mapping address in the original address;
[0019] If the storage content of the first address is consistent with the storage content of the second address, it indicates that the stored content before and after remapping is consistent, and the target address is determined to meet the preset alignment requirement; otherwise, it is determined that the target address does not meet the preset alignment requirement.
[0020] Optionally, detecting whether the storage content of the first address is consistent with the storage content of the second address includes:
[0021] Obtaining content in a memory page with a specified page number starting from the first address as the first content; the specified page number is an integer multiple of the address alignment unit;
[0022] Obtain the content of the memory page with the specified page number starting from the second address as the second content;
[0023] If the first content is consistent with the second content, it is determined that the storage content of the first address is consistent with the storage content of the second address; otherwise, it is determined that the storage content of the first address is inconsistent with the storage content of the second address.
[0024] Optionally, obtaining the address alignment unit corresponding to the current test includes:
[0025] Reading a specific parameter configured from the kernel of the operating system; the specific parameter is configured based on a default parameter value of the kernel; or the specific parameter is configured based on a specified value carried in a value setting instruction sent by a user;
[0026] The address alignment unit is determined based on the specific parameter and a single page size of the operating system.
[0027] Optionally, performing the address alignment operation on the original address of the target system call according to the address alignment unit to obtain the target address includes:
[0028] Calculating an address alignment size based on the number of pages represented by the address alignment unit and a single page size of the operating system;
[0029] According to the address alignment size, an address whose proximity to the original address meets a preset proximity requirement and is an integer multiple of the address alignment size is determined as the target address.
[0030] On the other hand, an embodiment of the present invention discloses a system testing device, comprising:
[0031] The first acquisition module is used to acquire the address alignment unit corresponding to this test; the address alignment unit is used to represent the number of pages corresponding to the address alignment operation;
[0032] an alignment module, configured to perform the address alignment operation on the original address of the target system call according to the address alignment unit to obtain a target address; the target address is used to represent the original address after alignment;
[0033] A detection module, configured to detect the target address based on the address alignment unit to implement system testing;
[0034] The determination module is configured to determine whether the operating system corresponding to the target system call passes the test when it is detected that the target address meets the preset alignment requirement.
[0035] Optionally, the device further includes: a second acquisition module, configured to acquire a mapping state value of the target system call; and the detection module, specifically configured to:
[0036] detecting whether the target address is correct based on the address alignment unit;
[0037] If the target address is correct and the mapping status value indicates that the mapping is successful, determining that the target address meets the preset alignment requirement;
[0038] If the target address is incorrect or the mapping status value indicates a mapping failure, it is determined that the target address does not meet the preset alignment requirement.
[0039] Optionally, the detection module is further configured to:
[0040] If the target address is correct and the mapping status value indicates successful mapping, detecting whether the target system call is for memory remapping;
[0041] In a case where the target system call is not used for memory remapping, it is determined that the target address is detected to meet the preset alignment requirement.
[0042] Optionally, the target address includes a first address and a second address, and the detection module is further configured to:
[0043] In a case where the target system call is for memory remapping, detecting whether the storage content of the first address is consistent with the storage content of the second address; the first address is obtained by aligning the old mapping address in the original address, and the second address is obtained by aligning the new mapping address in the original address;
[0044] If the storage content of the first address is consistent with the storage content of the second address, it indicates that the stored content before and after remapping is consistent, and the target address is determined to meet the preset alignment requirement; otherwise, it is determined that the target address does not meet the preset alignment requirement.
[0045] Optionally, the detection module is further configured to:
[0046] Obtaining content in a memory page with a specified page number starting from the first address as the first content; the specified page number is an integer multiple of the address alignment unit;
[0047] Obtain the content of the memory page with the specified page number starting from the second address as the second content;
[0048] If the first content is consistent with the second content, it is determined that the storage content of the first address is consistent with the storage content of the second address; otherwise, it is determined that the storage content of the first address is inconsistent with the storage content of the second address.
[0049] Optionally, the first acquisition module is specifically configured to:
[0050] Reading a specific parameter configured from the kernel of the operating system; the specific parameter is configured based on a default parameter value of the kernel; or the specific parameter is configured based on a specified value carried in a value setting instruction sent by a user;
[0051] The address alignment unit is determined based on the specific parameter and a single page size of the operating system.
[0052] Optionally, the alignment module is specifically configured to:
[0053] Calculating an address alignment size based on the number of pages represented by the address alignment unit and a single page size of the operating system;
[0054] According to the address alignment size, an address whose proximity to the original address meets a preset proximity requirement and is an integer multiple of the address alignment size is determined as the target address.
[0055] On the other hand, an embodiment of the present invention discloses an electronic device, comprising: a processor, a memory, a communication interface and a communication bus, wherein the processor, the memory and the communication interface communicate with each other through the communication bus; the memory is used to store at least one executable instruction, and the executable instruction enables the processor to execute the aforementioned method.
[0056] An embodiment of the present invention further discloses a machine-readable medium having instructions stored thereon. When executed by one or more processors, the processors are enabled to execute the method described above.
[0057] The embodiment of the present invention includes the following advantages: In the system testing method provided in the embodiment of the present invention, the address alignment unit corresponding to this test is first obtained, and then the original address of the target system call is subjected to address alignment according to the address alignment unit to obtain the target address, and the target address is detected based on the address alignment unit to implement system testing. When the target address obtained by alignment according to the address alignment unit meets the preset alignment requirements, it is determined that the operating system corresponding to the target system call has passed the test. In the embodiment of the present invention, the address alignment unit corresponding to this test is first obtained in the test process, and address alignment is performed according to the address alignment unit. When the number of pages represented by the address alignment unit is greater than 1, it is equivalent to implementing a test for the case of multi-page alignment, that is, testing is performed in a multi-page alignment scenario. In this way, testing in a variety of test scenarios is implemented, thereby improving the test coverage. BRIEF DESCRIPTION OF THE DRAWINGS
[0058] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments of the present invention. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0059] Figure 1 This is a flowchart of the steps of a system testing method provided by an embodiment of the present invention;
[0060] Figure 2 This is a schematic diagram of a processing flow provided by an embodiment of the present invention;
[0061] Figure 3 is a block diagram of a system testing device provided by an embodiment of the present invention;
[0062] Figure 4 It is a structural diagram of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0063] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of them. All other embodiments obtained by ordinary technicians in this field based on the embodiments of the present invention without making any creative efforts shall fall within the scope of protection of the present invention.
[0064] Reference Figure 1 , shows a flow chart of the steps of a system testing method provided by an embodiment of the present invention, such as Figure 1 As shown, the method may specifically include the following steps:
[0065] Step 101: Obtain an address alignment unit corresponding to this test; the address alignment unit is used to represent the number of pages corresponding to the address alignment operation.
[0066] Step 102: Perform the address alignment operation on the original address of the target system call according to the address alignment unit to obtain a target address; the target address is used to represent the aligned original address.
[0067] Step 103: Detect the target address based on the address alignment unit to implement system testing.
[0068] Step 104: When it is detected that the target address meets the preset alignment requirement, determine whether the operating system corresponding to the target system call passes the test.
[0069] The testing method provided in the embodiment of the present invention can be applied to electronic devices, and the electronic devices can be computers, servers and other devices. The operating system corresponding to the target system call can be the operating system that provides the target system call, and the operating system corresponding to the target system call can be the operating system under test this time. The kernel of the operating system serves as the core component of the operating system under test. It can manage the hardware resources of the system and provide various system services so that application programs can easily access hardware resources. The electronic device can run the operating system under test. Specifically, the operating system under test can run locally on the electronic device, or it can run on a virtual machine installed in the electronic device. The embodiment of the present invention does not limit this. The specific type of the operating system under test can be determined according to actual needs. For example, the operating system under test can be a Windows system, or the operating system under test can also be a Linux system.
[0070] Among them, the address alignment unit corresponding to this test can indicate the minimum number of aligned pages required in this test. The number of pages represented by the address alignment unit is the minimum number of aligned pages required in this test. Among them, the number of pages represented by the address alignment unit is the number of pages corresponding to when performing the address alignment operation. The number of pages can be a positive integer. The address alignment unit can be set as needed. For example, the address alignment unit can represent an integer greater than 1, that is, the required minimum alignment granularity is greater than the size of a single page. The target system call can be a system call that requires the address alignment of the original address corresponding to the parameter in the system call. Among them, the system call refers to an interface provided by the operating system to the user program, which allows the user program to request the service provided by the kernel of the operating system. The system call serves as a bridge between the user space and the kernel space, allowing the application to safely and efficiently access system resources such as files, networks, hardware devices, etc.
[0071] In the test method provided by the embodiment of the present invention, the address alignment unit will be obtained first, and when the address alignment operation is performed accordingly, the address alignment operation is performed on the original address according to the number of pages represented by the address alignment unit, and the address obtained after the address alignment operation is the target address. With G representing the address alignment unit, assuming G=2, that is, the number of pages represented by the address alignment unit is 2, then the operating system kernel can use two pages as a unit and perform an address alignment operation on the original address of the target system call according to the size of two memory pages. Among them, the address alignment operation can refer to the requirement that the storage address of the control data in the memory meets the integer multiple of the address alignment size, that is, the original address is aligned to an integer multiple address of the address alignment size. In this way, by performing the address alignment operation in the form of an integer multiple of the address alignment size, the efficiency of memory access can be improved, ensuring that data access meets the requirements of the hardware, and avoiding performance problems caused by unaligned access.
[0072] Furthermore, a target system call can be executed. During the execution of the target system call, the kernel of the operating system corresponding to the target system call can perform the aforementioned address alignment operation. After executing the target system call, the target system call can generate a return value. Accordingly, the kernel can obtain the return value of the target system call. The return value can include the aforementioned target address and a mapping status value. The mapping status value indicates whether the target system call was successfully executed. The target address obtained by the address alignment operation can affect the execution of the target system call. For example, if the address alignment operation is not performed properly and the target address contains an error, the execution of the target system call may be affected and fail. For example, assuming that the address space of process A is 0x0000 to 0x1FFF, if the address alignment operation is not performed properly and a target address of 0x4000 is generated that exceeds the address space, the memory mapping system call will fail. Therefore, embodiments of the present invention can obtain the return value and use it as a judgment basis. At the same time, since the target address is aligned according to the number of pages represented by the address alignment unit, it is possible to detect whether the target address meets the preset alignment requirements based on the address alignment unit representation to determine whether there is an abnormality in the target address, that is, to test whether the kernel can normally perform address alignment according to the number of pages represented by the address alignment unit to ensure that the target system call can be executed normally.
[0073] In summary, in the system testing method provided by the embodiment of the present invention, the address alignment unit corresponding to this test is first obtained, and then the original address of the target system call is subjected to address alignment according to the address alignment unit to obtain the target address, and the target address is detected based on the address alignment unit to implement system testing. When the target address obtained by alignment according to the address alignment unit meets the preset alignment requirements, it is determined that the operating system corresponding to the target system call has passed the test. In the embodiment of the present invention, the address alignment unit corresponding to this test is first obtained in the test process, and address alignment is performed according to the address alignment unit. Accordingly, when the number of pages represented by the address alignment unit is not greater than 1, it is equivalent to implementing a test for a single-page alignment situation, and when the number of pages represented by the address alignment unit is greater than 1, it is equivalent to implementing a test for a multi-page alignment situation, that is, testing is performed in a multi-page alignment scenario. In this way, testing is implemented in a variety of test scenarios, thereby improving the test coverage.
[0074] Optionally, the step of calculating the target address can be specifically performed by the kernel of an operating system. Other steps can also be performed by the kernel of the operating system, or by other components in the electronic device, such as a test program. Accordingly, the test program can be initialized first, and then the above steps are performed.
[0075] Optionally, the step of obtaining the address alignment unit corresponding to the current test may specifically include:
[0076] Step 1011: Read a specific parameter configured from the kernel of the operating system; the specific parameter is configured based on a default parameter value of the kernel of the operating system; or, the specific parameter is configured based on a specified value carried in a value setting instruction sent by a user.
[0077] Step 1012: Determine the address alignment unit based on the specific parameter and the single page size of the operating system.
[0078] In an embodiment of the present invention, a specific parameter value may be determined first, and then the address alignment unit may be calculated based on the specific parameter value and the single page size of the operating system. In one implementation, the specific value of the specific parameter may be the default parameter value of the operating system kernel, i.e., the specific parameter value may be a fixed value configured in the kernel. Accordingly, the default parameter value may be read as the specific parameter value. Exemplarily, the default parameter value may be the value of SHMLBA. The default parameter value may be calculated based on the default number of pages used when the operating system kernel performs address alignment. The default parameter value may be the default address alignment size used when the operating system kernel performs address alignment. The specific size of the default parameter value may be determined by the characteristics of the operating system itself. The default parameter value may be m times the page size. Here, m represents the default number of pages used when performing address alignment. The default number of pages used by the operating system kernel when performing address alignment refers to the number of pages used by the operating system kernel when performing address alignment on any address. For example, if the operating system kernel defaults to address alignment based on two pages, the default number of pages used may be 2. In this way, the subsequently determined address alignment unit can be made to better match the default alignment behavior of the operating system kernel, thereby making the test scenario closer to the characteristics of the operating system itself and improving the reference value of the test results.
[0079] In another implementation, the specific value of a specific parameter can be a specified value carried in a value setting instruction sent by the user. That is, the user can customize the specific parameter using the value setting instruction. For example, the value setting instruction can be expressed as set SHMLBA(X), where X represents the specified value carried in the value setting instruction. The electronic device can receive the value setting instruction sent by the user, extract the content of the specified bit of the value setting instruction, use the value represented by the content of the specified bit as the specified value, and set the specified value as the specific value of the specific parameter. For example, the specified bit can be the lower two bits of the instruction. The value carried in the value setting instruction can be set according to a preset rule file. For example, the preset rule file can define the rules that the specified value must follow, such as requiring it to be an integer multiple of the single page size or to comply with the page alignment supported by the operating system, such as an integer multiple of the specified number of pages. In this approach, settings can be made based on the value setting instruction, thereby increasing the flexibility of the testing method. It should be noted that, when the user customizes the address, the specified value may be set according to the number of pages required by the kernel, that is, the number of pages used by default when performing address alignment. For example, the specified value may be set to m times the page size. This is not limited in the embodiment of the present invention. Where m represents the number of pages used by default when performing address alignment.
[0080] Furthermore, the single page size of the operating system can be obtained, and then the ratio of the specific parameter to the single page size of the operating system can be calculated. The ratio is used as the address alignment unit. It should be noted that when the ratio is not an integer, the ratio can be rounded up, and the value after rounding up can be used as the address alignment unit, thereby ensuring that the number of pages represented by the address alignment unit is an integer. Of course, the comparison value can also be rounded down. In this way, by rounding down, the situation where the address after subsequent alignment exceeds the original address can be reduced to a certain extent, which is conducive to maintaining the continuity of the memory address and avoiding memory waste.
[0081] For example, the operating system's single page size can be obtained based on a preset acquisition command. For example, the preset acquisition command can be the getpagesize command provided by the operating system, which can obtain the system page size. The specific parameter can be expressed as SHMLBA, and the address alignment unit can be expressed as G = SHMLBA / getpagesize(). getpagesize() represents the obtained single page size of the operating system.
[0082] In an embodiment of the present invention, the address alignment unit is determined by reading a specific parameter SHMLBA configured from the operating system kernel and calculating based on the specific parameter and the single page size of the operating system obtained by the getpagesize command. For example, the ratio of SHMLBA to the single page size of the operating system can be calculated to obtain the address alignment unit. The specific parameter can be a specified numerical configuration based on the default parameter value of the operating system kernel or a numerical setting instruction sent by the user. In this way, it can be ensured to a certain extent that the address alignment unit complies with the default alignment behavior of the kernel of the operating system or the set numerical value, thereby improving the flexibility of the test method.
[0083] Optionally, the step of performing the address alignment operation on the original address of the target system call according to the address alignment unit to obtain the target address may specifically include:
[0084] Step 1021 : Calculate the address alignment size based on the number of pages represented by the address alignment unit and the single page size of the operating system.
[0085] Step 1022: According to the address alignment size, determine an address whose proximity to the original address meets a preset proximity requirement and is an integer multiple of the address alignment size, as the target address.
[0086] The number of pages represented by the address alignment unit can be an integer. The number of pages represented by the address alignment unit is the number of pages corresponding to the address alignment operation, i.e., the number of pages used when performing the address alignment operation. The address alignment size can be calculated by multiplying the number of pages represented by the address alignment unit by the single page size of the operating system. Aligning the original address according to the address alignment size is equivalent to aligning the address according to the number of pages represented by the address alignment unit. The preset proximity requirement can be the closest to the original address. Specifically, the address closest to the original address among the addresses that are integer multiples of the address alignment size and less than or equal to the original address can be determined as the target address, i.e., rounding down is used when performing address alignment. Specifically, if the original address itself is an integer multiple of the address alignment size, the target address is equal to the original address. Conversely, if the original address is not an integer multiple of the address alignment size, the target address can be an address that is smaller than the original address, is an integer multiple of the address alignment size, and is closest to the original address. This ensures that the target address does not exceed the original address, which helps maintain memory address continuity and avoids memory waste.
[0087] G represents the number of pages represented by the address alignment unit, and n represents the operating system's single page size. G × n represents the address alignment size. An alignment mask is created based on the address alignment size. Specifically, the alignment mask can be calculated based on G × n - 1. The original address is then bitwise ANDed with the alignment mask to obtain the target address. For example, if G = 2 and n = 4KB, the address alignment size is 8KB (i.e., 0x2000). The alignment mask is created by first calculating the address alignment size - 1 to obtain 0x1FFF (i.e., 8KB - 1). Then, the bitwise inversion of 0x1FFF results in the alignment mask 0xE000 (binary representation: 11100000 0000 0000). Finally, the original address is bitwise ANDed with the alignment mask. For example, assuming the original address is 0x4A3B (binary representation is 0100 1010 00111011), after a bitwise AND operation, the target address can be obtained as: 0x4000 (binary representation is 0100 0000 0000 0000).
[0088] Let aligned_address represent the target address, original_address represents the original address, and aligned_address = (original_address & ~(G×n-1)). Here, & represents the bitwise AND operator, and ~ represents the bitwise inversion operator. The alignment mask is used to clear all bits that are less than an integer multiple of the address alignment size. This bitwise AND operation clears all bits in original_address that are less than an integer multiple of the address alignment size, thus achieving address alignment and obtaining a target address that is closest to the original address, smaller than the original address, and an integer multiple of the address alignment size.
[0089] It should be noted that in one implementation, the address closest to the original address among those that are integer multiples of the address alignment size and greater than or equal to the original address can be determined as the target address. That is, address alignment can also be performed using rounding up. For example, in the rounding up method, aligned_address = (original_address + (G×n-1)) & ~(G×n-1). In this method, adding G×n-1 to original_address and then performing a bitwise AND operation can yield the target address that is closest to the original address, greater than the original address, and an integer multiple of the address alignment size.
[0090] Compared to the method of directly aligning to a single page, in an embodiment of the present invention, the address alignment size is first calculated based on the number of pages represented by the address alignment unit and the single page size of the operating system. Then, according to the address alignment size, an address whose proximity to the original address meets the preset proximity requirement and is an integer multiple of the address alignment size is determined as the target address. In this way, address alignment can be achieved according to the number of pages represented by the address alignment unit, thereby facilitating testing of scenarios in which address alignment is performed according to the number of pages represented by the address alignment unit.
[0091] Optionally, the target system call is a system call related to memory mapping, such as an mmap system call, an mremap system call, a remap_file_pages system call, etc. The return value may include the target address and a mapping status value. Accordingly, in an embodiment of the present invention, the following step may be further included: obtaining the mapping status value of the target system call. The step of detecting the target address based on the mapping status value of the target system call and the address alignment unit may specifically include:
[0092] Step 1031: Detect whether the target address is correct based on the address alignment unit.
[0093] Step 1032: If the target address is correct and the mapping status value indicates that the mapping is successful, it is determined that the target address meets the preset alignment requirement.
[0094] Step 1033: If the target address is incorrect or the mapping status value indicates a mapping failure, it is determined that the target address does not meet the preset alignment requirement.
[0095] In an embodiment of the present invention, the return value may be returned to the operating system kernel after the target system call is executed. The target address can be extracted from the return value, and then the target address can be checked for correctness. A detection mask can be calculated based on the number of pages represented by the address alignment unit. Specifically, the product of the address alignment unit and the operating system's page size can be calculated, and then the product minus 1 is used as the detection mask. Next, a bitwise AND operation is performed on the target address in the return value and the detection mask to obtain a detection result. If the target address is aligned to the number of pages represented by the address alignment unit, the detection result is 0. Conversely, if the target address is incorrect and not aligned to the number of pages represented by the address alignment unit, the bitwise AND operation will result in a detection result different from 0. For example, a bitwise AND operation is performed on the target address 0x4000 (binary representation: 0100 00000000 0000) using the detection mask 0x1FFF (binary representation: 000111111111111111, resulting in a detection result of 0. In actual application scenarios, the target address may be incorrect due to an operation error or a fault in the operating system. Accordingly, in an embodiment of the present invention, a check is performed according to the number of pages represented by the address alignment unit. If the test result is equal to 0, it can be determined that the target address is normally aligned according to the number of pages represented by the address alignment unit, that is, the target address is correct. Conversely, if the test result is not equal to 0, it can be determined that the target address is incorrect.
[0096] Furthermore, the mapping status value can represent whether the target system call is mapped successfully, that is, whether the target system call is executed normally. Accordingly, different mapping status values can represent different states. For example, the mapping status value can include two values 0 and 1. When the mapping status value is equal to 0, it is determined that the mapping status value represents a mapping failure. When the mapping status value is equal to 1, it is determined that the mapping status value represents a mapping success. Exemplarily, when the target address is not an integer multiple of the address alignment size, or the target address exceeds the address space, the mapping will fail. Accordingly, in the case of a mapping failure, an exception handling process can be triggered, for example, a failure prompt is issued to the user to remind the user to check.
[0097] If the target address is correct and the mapping status value indicates a successful mapping, then the operating system kernel can normally perform address alignment according to the number of pages represented by the address alignment unit, and the aligned target address can be successfully mapped. In other words, the operating system kernel can ensure the legality of the address of the target system call. Specifically, detecting whether the target address is correct and whether the memory mapping operation performed at the target address is successfully mapped is equivalent to detecting the legality of the target address to ensure that the mapped address meets the requirements. Accordingly, the preset alignment requirements may include: the target address is correct and the memory mapping operation performed at the target address is successfully mapped.
[0098] Conversely, if the target address is incorrect and / or the mapping status value indicates a mapping failure, this indicates that the operating system kernel is unable to properly perform address alignment according to the number of pages represented by the address alignment unit, and / or the aligned target address cannot be successfully mapped. This means that the operating system kernel cannot ensure the address legitimacy of the target system call. For example, the target address may be correct, but the target address exceeds the available range, resulting in a mapping failure. Exemplarily, a mapping failure may mean that the target address exceeds the available range, while a mapping success may mean that the target address does not exceed the available range. A target address exceeding the available range may mean that the continuous memory space starting with the target address cannot accommodate the mapping size represented by the size parameter (e.g., the size parameter) in the system call parameters, i.e., the size of the continuous available memory space starting with the target address is smaller than the size represented by the size parameter in the system call parameters. Alternatively, if the mapping is successful but the target address is not an integer multiple of the address alignment size, this indicates a target address error. Alternatively, if the target address is not an integer multiple of the address alignment size and the target address is outside the available range, mapping fails. For example, assuming that the address space of process A is: 0x0000 to 0x1FFF, the target address is 0x1000, and the size parameter in the system call parameter is 0x2000, then the continuous memory space formed with the target address as the starting address will exceed 0x1FFF, which will cause the mapping to fail. Alternatively, assuming the address alignment size is 0x1000, the target address is 0x10A0, and the size parameter in the system call parameter is 0x2000, since the continuous memory space formed with the target address as the starting address does not exceed 0x1FFF, the target address is not an integer multiple of the address alignment size, and therefore, the mapping fails. These situations can determine that the target address does not meet the preset alignment requirements. In other words, as long as the target address is incorrect, or the mapping status value indicates a mapping failure, it can be directly determined that the target address does not meet the preset alignment requirements.
[0099] Accordingly, when the detection result is equal to the target address and the mapping status value is 1, it can be determined that the target address is detected to meet the preset alignment requirement. Conversely, when the detection result is not equal to the target address and / or the mapping status value is 0, it is determined that the target address is detected to meet the non-preset alignment requirement.
[0100] In an embodiment of the present invention, by detecting whether the target address is correct and detecting whether the mapping status value indicates successful mapping, only when both conditions are met, that is, the target address is correct and the mapping status value indicates successful mapping, is it determined that the target address meets the preset alignment requirement. In this way, it can be ensured to a certain extent that the target system call that passes the test can be successfully mapped subsequently. That is, the operating system kernel can ensure that the address is aligned to the address alignment unit page when making the target system call, ensuring that the target system call that passes the test can be executed normally subsequently, ensuring that the target system call that passes the test is normal, and thus ensuring the reliability of the test results.
[0101] In another implementation, the return value may include a target address. Accordingly, based on the return value and the number of pages represented by the address alignment unit, the step of detecting the target address may be to extract the target address from the return value, and then detect whether the target address in the return value is correct based on the number of pages represented by the address alignment unit, that is, to detect whether the target address is the address obtained after aligning the original address by the address alignment unit. If so, it is determined that the detected target address meets the preset alignment requirements, and this test passes. That is, the above-mentioned preset alignment requirements may include: the target address is correct. Otherwise, it can be determined that the detected target address does not meet the preset alignment requirements, and this test fails. In this way, only the target address itself is detected to determine whether the test passes, thereby improving the detection efficiency to a certain extent.
[0102] Optionally, if the target address is correct and the mapping status value indicates successful mapping, the step of determining that the target address meets the preset alignment requirement may specifically include:
[0103] Step 1032a: If the target address is correct and the mapping status value indicates successful mapping, then detect whether the target system call is for memory remapping.
[0104] Step 1032b: When the target system call is not used for memory remapping, determine that the target address is detected to meet the preset alignment requirement.
[0105] It should be noted that the detection of whether the target system call is used for memory remapping is performed when it is detected that the target address is correct and the mapping status value indicates that the mapping is successful. In this way, unnecessary detection operations can be avoided. Alternatively, it can be performed before it is detected that the target address is correct and the mapping status value indicates that the mapping is successful. For example, it can be performed synchronously with the above-mentioned step 1031, or it can be performed successively with the above-mentioned step 1031. The embodiment of the present invention does not limit this. Accordingly, when it is detected that the target address is correct and the mapping status value indicates that the mapping is successful, it is directly judged that the target address meets the preset alignment requirements based on the previously detected detection result for indicating whether the target system call is used for remapping.
[0106] Furthermore, the function name of the target system call can be detected and identified, and then it can be determined whether the target system call is used for memory remapping. If the function name of the target system call is a function name that represents memory remapping, then it can be determined that the target system call is used for memory remapping. Conversely, if the function name of the target system call is not a function name that represents memory remapping, then it can be determined that the target system call is not used for memory remapping. Among them, the function name that represents memory remapping can be mremap. Accordingly, the function name of the target system call can be obtained. If the function name of the target system call is mremap, then it is determined that the target system call is used for memory remapping, and the target system call is an mremap system call. Conversely, if the function name of the target system call is not mremap, then it is determined that the target system call is not used for memory remapping. Among them, the mremap system call is used to modify an existing memory mapping area.
[0107] Memory remapping is the process of changing the address or size of an existing memory mapping. The mremap system call can be used to adjust the size or address of an existing memory mapping. If a process requires more memory or no longer requires the amount of memory previously allocated, memory remapping can be used to increase or decrease the size of the mapped memory. Alternatively, if an address conflict occurs or memory layout needs to be reorganized for other reasons, the process needs to move the mapped memory segment to another location in its virtual address space, thereby changing the mapping address.
[0108] If the target system call is for memory remapping, the original address of the target system call includes the old mapping address and the new mapping address. The old mapping address represents the starting address used during the previous mapping. The new mapping address represents the starting address of the memory area after remapping. The new mapping address can be user-specified or selected by the operating system kernel.
[0109] Specifically, the operating system kernel can read the new mapping address specified by the user when the preset flag parameter of the target system call is a specified value, such as the MREMAP_FIXED flag. When the preset flag parameter is not a specified value, the kernel selects an available address as the new mapping address. The old mapping address can be expressed as oldaddress, and the new mapping address can be expressed as newaddress. The system call parameters can also include other parameters, such as an old mapping size parameter and a new mapping size parameter. The old mapping size parameter can be expressed as oldsize, and the new mapping size parameter can be expressed as newsize. When the target system call is not used for memory remapping, the system call parameters can include a mapping address and a size parameter.
[0110] In this embodiment of the present invention, if the target system call is not used for memory remapping, then if the target address is correct and the mapping status value indicates successful mapping, it can be directly determined that the target address meets the preset alignment requirements. If the target system call is used for memory remapping, further testing is performed. This ensures the accuracy of the test results to a certain extent.
[0111] Optionally, in the case where the target system call is used for memory remapping, the target address may include a first address and a second address. The embodiment of the present invention may further include the following steps:
[0112] Step S21: When the target system call is used for memory remapping, detect whether the storage content of the first address is consistent with the storage content of the second address; the first address is obtained after aligning the old mapping address in the original address, and the second address is obtained after aligning the new mapping address in the original address.
[0113] Step S22: When the storage content of the first address is consistent with the storage content of the second address, it indicates that the stored content before and after remapping is consistent, and it is determined that the target address meets the preset alignment requirement.
[0114] Step S23: Otherwise, determine that the target address does not meet the preset alignment requirement.
[0115] Specifically, when the target system call is for memory remapping, an address alignment operation is performed on the original address according to the address alignment unit. Specifically, the address alignment operation can be performed on the old mapping address and the new mapping address respectively according to the address alignment unit to obtain the first address and the second address. Accordingly, the target address can include the first address and the second address. It should be noted that in the above step 1031, it can be checked whether the second address in the target address is correct.
[0116] Furthermore, if the target address is correct and the mapping status value indicates successful mapping, then the second address is correct (i.e., the operating system kernel can properly align the new mapping address according to the number of pages represented by the address alignment unit), and the size of the continuous available memory space starting with the second address is not less than the size represented by the new mapping size parameter in the system call parameters. However, because the target system call is specifically for remapping, it is also necessary to check whether the contents stored in the area before and after remapping are consistent.
[0117] Specifically, the storage content of the first address may refer to the content of all or part of the memory pages in the region before remapping. The storage content of the second address may refer to the content of all or part of the memory pages in the region after remapping. The storage content of the first address and the storage content of the second address can be compared to detect whether they are consistent. If the two contents are consistent, it can be determined that the target address meets the preset alignment requirements. That is, when the target system call is used for memory remapping, the preset alignment requirements may include whether the target address is correct, the mapping status value indicates successful mapping, and whether the storage content of the first address and the second address in the target address are consistent (i.e., the content before and after remapping is consistent). The target address can be determined to meet the preset alignment requirements if the target address is correct, the mapping status value indicates successful mapping, and the storage content of the first address and the second address in the target address are consistent. Conversely, if the storage content of the first address and the second address are inconsistent, even if the target address is correct and the mapping status value indicates successful mapping, it can be determined that the target address does not meet the preset alignment requirements.
[0118] In this embodiment of the present invention, when a target system call is used for memory remapping, the first address and the second address are further tested for consistency. Only if they are consistent is the target address determined to meet the preset alignment requirements, i.e., the target system call is determined to have passed the test. This ensures, to a certain extent, that the content of the target system call that has passed the test will be consistent before and after remapping when it is subsequently used.
[0119] Optionally, the step of detecting whether the storage content of the first address is consistent with the storage content of the second address may specifically include:
[0120] Step S211 , starting from the first address, obtaining the content of the memory page with the specified page number as the first content; the specified page number is an integer multiple of the address alignment unit.
[0121] Step S212: Obtain the content of the memory page with the specified page number starting from the second address as the second content.
[0122] Step S213: If the first content is consistent with the second content, determine that the storage content of the first address is consistent with the storage content of the second address.
[0123] Step S214: Otherwise, determine that the storage content of the first address is inconsistent with the storage content of the second address.
[0124] In an embodiment of the present invention, the designated page number may include multiple page numbers that are integer multiples of the address alignment unit. The number of designated page numbers may be set according to actual needs. For example, the designated page number may include four page numbers, or six page numbers. Furthermore, when setting the designated page number, 1, 2, ..., i may be multiplied by the address alignment unit, respectively, to obtain i designated page numbers. Where i represents the number of designated page numbers.
[0125] With the first content as the storage content of the first address and the second content as the storage content of the second address, G represents the address alignment unit. Starting from the first address, the content of the Gth page, the 2×Gth content page, ... the i×Gth page can be obtained as the first content. Starting from the second address, the content of the Gth page, the 2×Gth content page, ... the i×Gth page can be obtained as the second content. The order of operations for obtaining the first content and the second content is not unique. For example, both can be performed simultaneously, or they can be performed one after another. The embodiment of the present invention does not limit this. When remapping is performed, the contents of all memory pages in the first address can be remapped. When performing a comparison to verify whether the contents before and after remapping are consistent, only the contents of the memory pages with the specified page number can be compared. Specifically, the first address of the area indicated by the first address / the first address of the area indicated by the second address can be used as the base address. For any specified page number, the address offset from the base address to the memory page indicated by the specified page number can be calculated based on the specified page number and the size of a single page. Then, based on the base address and the address offset of the specified page number, the memory page indicated by the specified page number is located and data is read from it. For the first content and the second content read, the first content and the second content can be stored in a preset designated area respectively. Based on a preset comparison instruction, the first content and the second content in the designated area are compared to determine whether the two are the same. The preset comparison instruction can be a memcmp instruction.
[0126] Furthermore, if the first content is consistent with the second content, that is, the content of page G starting from the first address, the 2×G content page, ... the i×G content page are consistent with the content of page G starting from the second address, the 2×G content page, ... the i×G content page, respectively, then it can be determined that the data before and after remapping are consistent, that is, the storage content of the first address and the second address are consistent. If the first content is inconsistent with the second content, that is, the content of page G starting from the first address, the 2×G content page, ... the i×G content page are inconsistent with the content of page G starting from the second address, the 2×G content page, ... the i×G content page, then it can be determined that the data before and after remapping are inconsistent, that is, the storage content of the first address and the second address are inconsistent. If the first content is consistent with the second content, it means that the old address and the new address are correctly aligned according to G pages. If the first content is inconsistent with the second content, it means that there is an address offset and a problem with the second address, resulting in data page deviation.
[0127] In the implementation of the present invention, the contents of the memory pages with the specified page numbers are obtained respectively from the first address and the second address, and a comparison is performed. Since the specified page number is an integer multiple of the address alignment unit, only the contents of some pages can be compared, thereby reducing the amount of comparison to a certain extent and improving the comparison efficiency. At the same time, when the operating system performs memory mapping according to G pages, when detecting the correctness of the aligned numerical values, the comparison is performed according to G pages as a unit, which can ensure the correctness of the data in each minimum mapping unit. The method of performing the comparison according to G pages as a unit is more in line with the mapping requirements of the kernel, thereby facilitating implementation to a certain extent.
[0128] The test method provided in the embodiments of the present invention can be implemented in the form of a test case. For example, it can be implemented in the form of a test case in the LTP (Linux Test Project) test suite. This allows the test method to be easily reused for multiple tests. In some architectures, the operating system itself needs to perform address alignment according to multiple pages. Specifically, address alignment according to multiple pages means address alignment according to at least two pages. In this way, if a page fault is detected during an access operation, multiple pages can be filled at once, thereby ensuring filling efficiency. Accordingly, there is a need for address alignment according to multiple pages in these architectures. However, existing test cases can only test whether address alignment is performed normally according to a single page. If the minimum alignment address required by the memory mapping is greater than the page size (i.e., when alignment according to multiple pages is required), the test will return a test failure, making it impossible to correctly test this situation.
[0129] Figure 2 This is a schematic diagram of a processing flow provided by an embodiment of the present invention. Figure 2 As shown, the single page size of the operating system can be obtained first, and then the address alignment unit G can be calculated based on the single page size and specific parameters. Then, the address alignment operation is performed on the original address according to G pages. Then, it is determined whether the memory mapping is returned correctly, that is, whether the target address is correct and whether the mapping status value indicates that the mapping is successful. If not (that is, the target address is incorrect and / or the mapping status value indicates that the mapping failed), it is determined that the test has not passed, that is, the test has failed. If it is (that is, the target address is correct and the mapping status value indicates that the mapping is successful), it is further detected whether the target system call is used for memory remapping. If it is not used, it can be determined that the test has passed. On the contrary, if it is used, the content before and after remapping can be further compared according to G pages as a unit, and it can be determined whether the content is consistent. That is, the above-mentioned detection is whether the storage content of the first address is consistent with the storage content of the second address. If they are consistent, it is determined that the test has passed. If they are inconsistent, it is determined that the test has not passed, that is, the test has failed.
[0130] In the implementation of the present invention, an address alignment unit, G, is introduced. During the testing phase, G is first calculated and address alignment is performed based on G pages. Simultaneously, during testing, testing is performed based on G pages. G can be set as needed, i.e., it can be an integer greater than 1. This ensures correct testing of the operating system kernel when the memory mapping alignment requirement is greater than the page size (i.e., when the number of pages represented by the address alignment unit is not less than 2).
[0131] Reference Figure 3 , shows a block diagram of a system testing device provided by an embodiment of the present invention, such as Figure 3 As shown, the device may specifically include:
[0132] The first acquisition module 301 is used to acquire the address alignment unit corresponding to this test; the address alignment unit is used to represent the page number corresponding to the address alignment operation;
[0133] An alignment module 302 is configured to perform the address alignment operation on the original address of the target system call according to the address alignment unit to obtain a target address; the target address is used to represent the original address after alignment;
[0134] A detection module 303 is configured to detect the target address based on the address alignment unit to implement system testing;
[0135] The determination module 304 is configured to determine whether the operating system corresponding to the target system call passes the test when it is detected that the target address meets the preset alignment requirement.
[0136] Optionally, the detection module 303 is specifically configured to:
[0137] detecting whether the target address is correct based on the address alignment unit;
[0138] If the target address is correct and the mapping status value indicates that the mapping is successful, determining that the target address meets the preset alignment requirement;
[0139] If the target address is incorrect or the mapping status value indicates a mapping failure, it is determined that the target address does not meet the preset alignment requirement.
[0140] Optionally, the apparatus further includes: a second acquisition module, configured to acquire a mapping state value of the target system call; and the detection module 303 is further configured to:
[0141] If the target address is correct and the mapping status value indicates successful mapping, detecting whether the target system call is for memory remapping;
[0142] In a case where the target system call is not used for memory remapping, it is determined that the target address is detected to meet the preset alignment requirement.
[0143] Optionally, the target address includes a first address and a second address, and the detection module 303 is further configured to:
[0144] In a case where the target system call is for memory remapping, detecting whether the storage content of the first address is consistent with the storage content of the second address; the first address is obtained by aligning the old mapping address in the original address, and the second address is obtained by aligning the new mapping address in the original address;
[0145] If the storage content of the first address is consistent with the storage content of the second address, it indicates that the stored content before and after remapping is consistent, and the target address is determined to meet the preset alignment requirement; otherwise, it is determined that the target address does not meet the preset alignment requirement.
[0146] Optionally, the detection module 303 is further configured to:
[0147] Obtaining content in a memory page with a specified page number starting from the first address as the first content; the specified page number is an integer multiple of the address alignment unit;
[0148] Obtain the content of the memory page with the specified page number starting from the second address as the second content;
[0149] If the first content is consistent with the second content, it is determined that the storage content of the first address is consistent with the storage content of the second address; otherwise, it is determined that the storage content of the first address is inconsistent with the storage content of the second address.
[0150] Optionally, the first acquisition module 301 is specifically configured to:
[0151] Reading a specific parameter configured from the kernel of the operating system; the specific parameter is configured based on a default parameter value of the kernel; or the specific parameter is configured based on a specified value carried in a value setting instruction sent by a user;
[0152] The address alignment unit is determined based on the specific parameter and a single page size of the operating system.
[0153] Optionally, the alignment module 302 is specifically configured to:
[0154] Calculating an address alignment size based on the number of pages represented by the address alignment unit and a single page size of the operating system;
[0155] According to the address alignment size, an address whose proximity to the original address meets a preset proximity requirement and is an integer multiple of the address alignment size is determined as the target address.
[0156] In summary, in the system testing device provided by the embodiment of the present invention, the address alignment unit corresponding to this test is first obtained, and then the address alignment operation is performed according to the number of pages represented by the address alignment unit to obtain the target address, and the target address is detected based on the return value corresponding to the target system call and the number of pages represented by the address alignment unit. When the target address obtained by aligning the number of pages represented by the address alignment unit meets the preset alignment requirements, it is determined that the operating system kernel has passed the test, so that the test for the kernel can be implemented. In the embodiment of the present invention, the address alignment unit corresponding to this test is first obtained in the test process, and the address alignment is performed according to the number of pages represented by the address alignment unit. Accordingly, when the number of pages represented by the address alignment unit is greater than 1, it is equivalent to implementing a test for the case of multi-page alignment, and thus the coverage of the test method can be ensured to a certain extent.
[0157] Reference Figure 4 , is a schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. Figure 4 As shown, the electronic device includes: a processor, a memory, a communication interface, and a communication bus. The processor, the memory, and the communication interface communicate with each other via the communication bus. The memory is used to store at least one executable instruction, which enables the processor to execute the system testing method of the aforementioned embodiment. The executable instructions can constitute a program.
[0158] An embodiment of the present invention provides a machine-readable medium having instructions stored thereon. When executed by one or more processors, the processors are enabled to execute the system testing method of the aforementioned embodiment.
[0159] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.
[0160] Those skilled in the art will appreciate that the embodiments of the present invention may be provided as methods, devices, or computer program products. Therefore, the embodiments of the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the embodiments of the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code. It should be noted that all actions of acquiring signals, information, or data in this application are performed in compliance with the relevant data protection laws and policies of the country of residence and with authorization from the owner of the corresponding device. The embodiments of the present invention are described with reference to the flowcharts and / or block diagrams of the methods, terminal devices (systems), and computer program products according to the embodiments of the present invention. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing terminal device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal device generate instructions for implementing the processes in the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0161] These computer program instructions may also be stored in a computer readable memory capable of directing a computer or other programmable data processing terminal device to operate in a predictable manner, so that the instructions stored in the computer readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.
[0162] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal device so that a series of operating steps are executed on the computer or other programmable terminal device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable terminal device to implement the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.
[0163] Although the preferred embodiments of the present invention have been described, those skilled in the art may make additional changes and modifications to these embodiments once they become aware of the basic creative concepts. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the embodiments of the present invention.
[0164] Finally, it should be noted that, in this document, relational terms such as first and second, etc., are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or terminal device that includes a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or terminal device. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of additional identical elements in the process, method, article, or terminal device that includes the element.
[0165] The above is a detailed introduction to a system testing method, a system testing device, an electronic device and a machine-readable medium provided by the present invention. Specific examples are used herein to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea. At the same time, for those skilled in the art, according to the idea of the present invention, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on the present invention.
Claims
1. A system testing method, It is characterized in that The method comprises: Obtaining the address alignment unit corresponding to this test; the address alignment unit is used to represent the number of pages corresponding to the address alignment operation; Performing the address alignment operation on the original address of the target system call according to the address alignment unit to obtain a target address; the target address is used to represent the original address after alignment; Detecting the target address based on the address alignment unit to implement system testing; In the case where it is detected that the target address meets the preset alignment requirement, determining that the operating system corresponding to the target system call passes the test; The method further includes: obtaining a mapping state value of the target system call; and detecting the target address based on the address alignment unit, including: Detecting whether the target address is correct based on the address alignment unit; If the target address is correct and the mapping status value indicates that the mapping is successful, then when the target system call is not used for memory remapping, it is determined that the target address is detected to meet the preset alignment requirement.
2. The method according to claim 1, It is characterized in that The method further comprises: If the target address is incorrect or the mapping status value indicates a mapping failure, it is determined that the target address is detected to not meet the preset alignment requirement.
3. The method according to claim 1, It is characterized in that The target address includes a first address and a second address; the method further includes: In the case where the target system call is used for memory remapping, detecting whether the storage content of the first address is consistent with the storage content of the second address; the first address is obtained by aligning the old mapping address in the original address, and the second address is obtained by aligning the new mapping address in the original address; When the storage content of the first address is consistent with the storage content of the second address, it indicates that the content stored before and after remapping is consistent, and it is determined that the target address meets the preset alignment requirement; otherwise, it is determined that the target address does not meet the preset alignment requirement.
4. The method according to claim 3, It is characterized in that The detecting whether the storage content of the first address is consistent with the storage content of the second address includes: Acquire the content of the memory page with the specified page number starting from the first address as the first content; the specified page number is an integer multiple of the address alignment unit; Acquire the content of the memory page with the specified page number starting from the second address as the second content; If the first content is consistent with the second content, it is determined that the storage content of the first address is consistent with the storage content of the second address; otherwise, it is determined that the storage content of the first address is inconsistent with the storage content of the second address.
5. The method according to any one of claims 1 to 4, It is characterized in that The step of obtaining the address alignment unit corresponding to the test includes: Reading a specific parameter configured from the kernel of the operating system; the specific parameter is configured based on a default parameter value of the kernel; or the specific parameter is configured based on a specified value carried in a value setting instruction sent by a user; The address alignment unit is determined based on the specific parameter and a single page size of the operating system.
6. The method according to any one of claims 1 to 4, It is characterized in that The step of performing the address alignment operation on the original address of the target system call according to the address alignment unit to obtain the target address includes: Calculate the address alignment size based on the number of pages represented by the address alignment unit and the single page size of the operating system; According to the address alignment size, an address that is closest to the original address and is an integer multiple of the address alignment size is determined as the target address.
7. A system testing device, It is characterized in that The device comprises: A first acquisition module is used to acquire an address alignment unit corresponding to this test; the address alignment unit is used to represent the number of pages corresponding to the address alignment operation; an alignment module, used for performing the address alignment operation on the original address of the target system call according to the address alignment unit to obtain a target address; the target address is used to represent the original address after alignment; A detection module, used for detecting the target address based on the address alignment unit to implement system testing; A determination module, configured to determine that the operating system corresponding to the target system call passes the test when it is detected that the target address meets the preset alignment requirement; The device further comprises: a second acquisition module, configured to acquire a mapping state value of the target system call; The detection module is specifically used for: Detecting whether the target address is correct based on the address alignment unit; If the target address is correct and the mapping status value indicates that the mapping is successful, then when the target system call is not used for memory remapping, it is determined that the target address is detected to meet the preset alignment requirement.
8. An electronic device, It is characterized in that include: A processor, a memory, a communication interface and a communication bus, wherein the processor, the memory and the communication interface communicate with each other via the communication bus; The memory is used to store executable instructions, and the executable instructions enable the processor to execute the method according to any one of claims 1 to 6.
9. A machine-readable medium, It is characterized in that Instructions are stored thereon, which, when executed by one or more processors, cause the processors to perform the method according to any one of claims 1 to 6.
