A method and apparatus for testing floating-point data interfaces
The floating-point data interface testing method and apparatus solve the problem of insufficient floating-point data interface testing, improve the quality and efficiency of software testing, and enhance software security, especially the ability to process special floating-point data in aerospace systems.
Patent Information
- Application Number
- CN202411712489.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-27
- Publication Date
- 2025-10-31
- Estimated Expiration
- 2044-11-27
AI Technical Summary
Existing software interface testing techniques are insufficient for testing floating-point data interfaces, leading to abnormal calculation results and failing to detect defects in software security protection measures. This is especially true in aerospace systems where floating-point special data occurs frequently, potentially causing serious consequences.
A method and apparatus for testing floating-point data interfaces are provided. The method involves receiving data frame description information, generating floating-point field test data (including floating-point dedicated data and ordinary data), calculating checksums, assembling data frames, and implementing testing using a receiving and analysis module, a test data generation module, a checksum module, and a framing module.
It improves the quality and efficiency of software testing, enhances software security, and avoids the impact of floating-point special data on the software under test.
Smart Images

Figure CN119829420B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of software interface testing, specifically relating to a floating-point data interface testing method and apparatus. Background Technology
[0002] Interface testing is a typical type of software testing. The interfaces of a test object are divided into internal interfaces and external interfaces. Internal interfaces are usually tested along with the functionality and performance of the test object. External interfaces focus on testing whether the information format, content, and timing characteristics meet requirements, as well as testing for abnormal situations to verify the security of the software data interface.
[0003] Software interface testing typically involves testers writing test cases based on the software interface communication protocol, designing normal and abnormal interface data, injecting it into the interface, testing whether the software can correctly receive and parse normal data input from the interface, whether it can identify errors and handle abnormal data input from the interface accordingly, and testing whether the data output by the software interface meets the requirements.
[0004] Software interface data mainly includes two types of data: integer and floating-point. When testing the input interface of the software under test, in existing testing techniques, testers generally use equivalence class partitioning and boundary value analysis to design normal and abnormal data, which include three categories: the first category is normal data whose values are within the range of the fields specified in the protocol; the second category is boundary data whose values are above or below the boundary of the range of the fields specified in the protocol; and the third category is abnormal data that exceeds the range of the fields specified in the protocol.
[0005] However, due to the different data storage methods of floating-point data compared to integer data, testing floating-point data interfaces using the aforementioned three types of data is insufficient. The inventors discovered that existing testing techniques have flaws. In practical applications, when the floating-point data received by the software input interface is a special type of data, the software will experience anomalies during storage and processing. Furthermore, this special data is transitive, leading to incorrect calculation results or errors exceeding expectations. Existing testing techniques do not design tests for special data specific to the characteristics of floating-point data storage, making it impossible to test the software under test's ability to process such special data, and therefore failing to detect deficiencies in the software's security protection measures.
[0006] In aerospace systems, there are a large number of high-precision calculations, and it is very common for software to exchange information through floating-point data. Various complex environmental conditions increase the possibility of special floating-point data. Therefore, when testing software interfaces, in addition to designing normal data, boundary data, and abnormal data, it is also necessary to design the special data for floating-point data interfaces to test whether the software under test has the ability to process the special data in a special way, so as to avoid serious adverse consequences.
[0007] The purpose of this invention is to provide a floating-point data interface testing method and apparatus to address the shortcomings of insufficient testing of software floating-point data interfaces, improve software testing quality and efficiency, and thereby enhance software security. Summary of the Invention
[0008] (a) Technical problems to be solved
[0009] The technical problem to be solved by the present invention is how to provide a floating-point data interface testing method and apparatus to solve the defect of insufficient testing of software floating-point data interfaces.
[0010] (II) Technical Solution
[0011] To address the aforementioned technical problems, this invention proposes a floating-point data interface testing method, which includes:
[0012] S1. Description of steps for receiving data frames
[0013] The system receives data frame description information, analyzes and processes it to obtain the data frame format; the data frame description information includes field sequence number, field type, field length, field value range, field content, multi-byte transmission order, and checksum calculation method;
[0014] S2, Test Data Generation Steps
[0015] Determine whether the field type is a floating-point field; if the field type is a floating-point field, generate floating-point field test data according to the field length and the field value range; if the field type is not a floating-point field, generate other field test data according to the field length and the field content.
[0016] S3. Steps for calculating the checksum
[0017] Calculate and generate a checksum according to the checksum calculation method;
[0018] S4, Frame Assembly Steps
[0019] According to the field sequence number and the multi-byte transmission order, the fields are combined into a data frame.
[0020] This invention provides a floating-point data interface testing device, the device comprising a receiving and analysis module, a test data generation module, a checksum module, and a framing module;
[0021] The receiving and analysis module is used to receive data frame description information and obtain field sequence number, field type, field length, field value range, field content, multi-byte transmission order, and checksum calculation method;
[0022] The test data generation module is used to determine whether the field type is a floating-point field; if the field type is a floating-point field, it generates floating-point field test data according to the field length and the field value range; if the field type is not a floating-point field, it generates test data for other fields according to the field length and the field content.
[0023] The checksum calculation module is used to calculate and generate a checksum according to the checksum calculation method.
[0024] The framing module is used to assemble data frames according to the field sequence number and the multi-byte transmission order.
[0025] (III) Beneficial Effects
[0026] This invention proposes a floating-point data interface testing method and apparatus. The floating-point data interface testing method and apparatus provided by this invention solve the problem caused by insufficient floating-point data interface testing in related technologies, improve software testing quality and efficiency, and thus enhance software security. Attached Figure Description
[0027] Figure 1 This is a flowchart of the method of the present invention;
[0028] Figure 2 This is a structural diagram of the device of the present invention. Detailed Implementation
[0029] To make the objectives, contents, and advantages of the present invention clearer, the specific embodiments of the present invention will be described in further detail below with reference to the accompanying drawings and examples.
[0030] This invention provides a method and apparatus for testing floating-point data interfaces, solving the problem caused by insufficient testing of floating-point data interfaces in related technologies.
[0031] According to one aspect of the present invention, a method for testing floating-point data interfaces is provided, comprising the following steps:
[0032] S1. Description of steps for receiving data frames
[0033] The system receives data frame description information, analyzes and processes it to obtain the data frame format. The data frame description information includes field sequence number, field type, field length, field value range, field content, multi-byte transmission order, and checksum calculation method.
[0034] S2, Test Data Generation Steps
[0035] Determine whether the field type is a floating-point field; if the field type is a floating-point field, generate floating-point field test data according to the field length and the field value range; if the field type is not a floating-point field, generate other field test data according to the field length and the field content.
[0036] The test data for floating-point fields includes floating-point special data and floating-point ordinary data.
[0037] The floating-point special data includes: the floating-point special value NaN (Not a Number), the floating-point special value Inf (Infinite), special data whose value is within the field's value range and will result in NaN after conversion of high and low byte order, and the floating-point number 0.
[0038] S3. Steps for calculating the checksum
[0039] Calculate and generate a checksum according to the checksum calculation method.
[0040] S4, Frame Assembly Steps
[0041] According to the field sequence number and the multi-byte transmission order, the fields are combined into a data frame.
[0042] Furthermore, the special data that will generate NaN after the value is within the field value range and after conversion of high and low byte order includes: special data that will generate qNaN (quietNaN) after the value is within the field value range and after conversion of high and low byte order, and special data that will generate sNaN (signalingNaN) after the value is within the field value range and after conversion of high and low byte order.
[0043] Furthermore, the floating-point special value NaN includes: floating-point special value qNaN (quietNaN) and floating-point special value sNaN (signalingNaN).
[0044] Furthermore, the floating-point special value Inf includes: floating-point special value +Inf and floating-point special value -Inf.
[0045] Furthermore, the floating-point number 0 value includes: floating-point number +0 and floating-point number -0.
[0046] Furthermore, the floating-point ordinary data includes: abnormal data whose values exceed the range of the field, boundary data whose values are above and away from the boundary of the field's value range, and normal data whose values are within the range of the field's value range.
[0047] According to another aspect of the present invention, a floating-point data interface testing device is provided, the device comprising a receiving and analysis module, a test data generation module, a checksum module, and a framing module.
[0048] The receiving and analysis module is used to receive data frame description information and obtain field sequence number, field type, field length, field value range, field content, multi-byte transmission order, and checksum calculation method.
[0049] The test data generation module is used to determine whether the field type is a floating-point field; if the field type is a floating-point field, it generates floating-point field test data according to the field length and the field value range; if the field type is not a floating-point field, it generates test data for other fields according to the field length and the field content.
[0050] The checksum calculation module is used to calculate and generate a checksum according to the checksum calculation method.
[0051] The framing module is used to assemble data frames according to the field sequence number and the multi-byte transmission order.
[0052] Example 1:
[0053] This embodiment provides a method for testing floating-point data interfaces. Figure 1 This is a flowchart illustrating a floating-point data interface testing method, such as... Figure 1 As shown, the process includes the following steps:
[0054] The first step is to receive the data frame description. The received data frame description information is analyzed and processed to obtain the data frame format. The data frame description information includes field sequence number, field type, field length, field value range, field content, multi-byte transmission order, and checksum calculation method. Taking a servo control command received by software as an example, Table 1 is a schematic table of data frame description information according to an embodiment of the present invention, including frame header, source address, destination address, information code, control voltage, control angle, checksum, and frame tail. The checksum field needs to have a checksum calculation method set. Table 2 is a schematic table of setting the checksum calculation method according to an embodiment of the present invention, including start field sequence number, end field sequence number, and checksum type.
[0055] Table 1. Schematic diagram of data frame description information according to embodiments of the present invention.
[0056]
[0057] Table 2. Schematic diagram of verification and calculation methods according to embodiments of the present invention.
[0058]
[0059] The second step is the test data generation process. First, determine if the field type is a floating-point field. If the field type is floating-point, generate floating-point field test data according to the field length and the field value range. If the field type is not floating-point, generate test data for other fields according to the field length and the field content.
[0060] The test data for floating-point fields includes floating-point special data and floating-point ordinary data.
[0061] The floating-point special data includes: the floating-point special value NaN (Not a Number), the floating-point special value Inf (Infinite), special data whose value is within the field's value range and will result in NaN after high-low byte order conversion, and the floating-point number 0. The special data whose value is within the field's value range and will result in NaN after high-low byte order conversion includes: qNaN (quietNaN) and sNaN (signalingNaN). The floating-point special value NaN includes: qNaN (quietNaN) and sNaN (signalingNaN). The floating-point special value Inf includes: +Inf and -Inf. The floating-point number 0 includes: +0 and -0. Table 3 is a schematic table of floating-point special data according to an embodiment of the present invention.
[0062] Table 3. Schematic table of floating-point dedicated data according to embodiments of the present invention.
[0063]
[0064] The floating-point ordinary data includes: abnormal data whose values exceed the range of the field, boundary data whose values are above and away from the boundary of the field's value range, and normal data whose values are within the range of the field's value range.
[0065] The third step is to calculate the checksum. Following the described checksum calculation method, a checksum is generated.
[0066] The fourth step is the framing step. According to the field sequence number and the multi-byte transmission order, the fields are assembled into a data frame. Table 4 is a schematic table of data frames corresponding to floating-point special data according to an embodiment of the present invention.
[0067] Table 4. Schematic table of data frames corresponding to floating-point special data according to embodiments of the present invention.
[0068]
[0069]
[0070] Through the above steps, test design data for floating-point data interfaces is obtained, improving the sufficiency of floating-point data interface testing. This avoids software security issues caused by the untested impact of special floating-point data on the software under test in existing technologies. A floating-point data interface testing method is provided to solve the deficiency of insufficient testing of software floating-point data interfaces and improve software testing quality.
[0071] This embodiment also provides a floating-point data interface testing device, which includes a receiving and analysis module, a test data generation module, a checksum module, and a framing module. Figure 2 This is a schematic diagram of a floating-point data interface testing device.
[0072] The receiving and analysis module is used to receive data frame description information and obtain field sequence number, field type, field length, field value range, field content, multi-byte transmission order, and checksum calculation method.
[0073] The test data generation module is used to determine whether the field type is a floating-point field; if the field type is a floating-point field, it generates floating-point field test data according to the field length and the field value range; if the field type is not a floating-point field, it generates test data for other fields according to the field length and the field content.
[0074] The checksum calculation module is used to calculate and generate a checksum according to the checksum calculation method.
[0075] The framing module is used to assemble data frames according to the field sequence number and the multi-byte transmission order.
[0076] Through the above modules, a floating-point data interface testing device is obtained. Combined with the floating-point data interface testing method provided by this invention, it solves the problem of insufficient floating-point data interface testing in related technologies, and addresses the issue of low efficiency in manual design. This improves software testing quality and efficiency, thereby enhancing software security.
[0077] The floating-point data interface testing method and apparatus provided by this invention solve the problem of insufficient floating-point data interface testing in related technologies, improve software testing quality and efficiency, and thus enhance software security.
[0078] The above description is only a preferred embodiment of the present invention. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the technical principles of the present invention, and these improvements and modifications should also be considered within the scope of protection of the present invention.
Claims
1. A method for testing floating-point data interfaces, characterized in that, The method includes: S1. Description of steps for receiving data frames The system receives data frame description information, analyzes and processes it to obtain the data frame format; the data frame description information includes field sequence number, field type, field length, field value range, field content, multi-byte transmission order, and checksum calculation method; S2, Test Data Generation Steps Determine whether the field type is a floating-point field; if the field type is a floating-point field, generate floating-point field test data according to the field length and the field value range; if the field type is not a floating-point field, generate other field test data according to the field length and the field content. S3. Steps for calculating the checksum Calculate and generate a checksum according to the checksum calculation method; S4, Frame Assembly Steps According to the field sequence number and the multi-byte transmission order, the fields are combined into a data frame; in, The test data for the floating-point fields includes floating-point special data and floating-point ordinary data; The floating-point special data includes: floating-point special value NaN, floating-point special value Inf, special data whose value is within the field value range and will generate NaN after conversion of high and low byte order, and floating-point number 0. The floating-point ordinary data includes: abnormal data whose values exceed the range of the field, boundary data whose values are above and away from the boundary of the field's value range, and normal data whose values are within the range of the field's value range.
2. The floating-point data interface testing method as described in claim 1, characterized in that, The special data that will result in NaN after the value is within the field's value range and is converted from high to low byte order includes: special data that will result in qNaN after the value is within the field's value range and is converted from high to low byte order, and special data that will result in sNaN after the value is within the field's value range and is converted from high to low byte order.
3. The floating-point data interface testing method as described in claim 1, characterized in that, The floating-point special value NaN includes: floating-point special value qNaN and floating-point special value sNaN.
4. The floating-point data interface testing method as described in claim 1, characterized in that, The floating-point special value Inf includes: floating-point special value +Inf and floating-point special value -Inf.
5. The floating-point data interface testing method as described in claim 1, characterized in that, The floating-point number 0 value includes: floating-point number +0 and floating-point number -0.
6. A floating-point data interface testing device, characterized in that, The device includes a receiving and analysis module, a test data generation module, a checksum module, and a framing module; The receiving and analysis module is used to receive data frame description information and obtain field sequence number, field type, field length, field value range, field content, multi-byte transmission order, and checksum calculation method; The test data generation module is used to determine whether the field type is a floating-point field; if the field type is a floating-point field, it generates floating-point field test data according to the field length and the field value range; if the field type is not a floating-point field, it generates test data for other fields according to the field length and the field content. The checksum module is used to calculate and generate a checksum according to the checksum calculation method; The framing module is used to assemble data frames according to the field sequence number and the multi-byte transmission order; in, The test data for the floating-point field includes floating-point specific data and floating-point general data; The floating-point special data includes: floating-point special value NaN, floating-point special value Inf, special data whose value is within the field value range and will generate NaN after conversion of high and low byte order, and floating-point number 0. The floating-point ordinary data includes: abnormal data whose values exceed the range of the field, boundary data whose values are above and away from the boundary of the field's value range, and normal data whose values are within the range of the field's value range.
Citation Information
Patent Citations
Vector floating point test data class immediate instruction
CN104956319A
Resynchronization of a superscalar processor
US5649225A