Test method and device, computer equipment, readable storage medium and program product

By identifying the communication endpoint of the USB device and automatically generating test data packets, the problem of high cost of traditional USB functional testing is solved, and a more flexible and automated testing process is achieved, reducing the detection cost.

CN119512839APending Publication Date: 2025-02-25SUZHOU WATECH ELECTRONICS CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411596254.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-11
Publication Date
2025-02-25

AI Technical Summary

Technical Problem

Traditional USB functional testing relies on expensive dedicated test boards or ATE devices, resulting in high testing costs and increased maintenance costs.

Method used

A test method and device are provided, by identifying the communication endpoint of the device to be detected, generating a matching information input interface, responding to the test instructions input by the user, automatically generate a test data packet and transmitting it to the device to be detected, and receiving and analyzing the response data packet to generate test results.

Benefits of technology

It reduces inspection costs, improves testing automation and flexibility, reduces equipment dependence, and effectively reduces initial investment and maintenance costs during the testing process.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119512839A_ABST
    Figure CN119512839A_ABST
Patent Text Reader

Abstract

The invention relates to a test method and device, computer equipment, a computer readable storage medium and a computer program product. The method comprises the following steps: determining to-be-detected equipment; identifying a communication endpoint corresponding to the to-be-detected device, and generating an information input interface corresponding to the communication endpoint; responding to an input instruction received through the information input interface, and obtaining test information; generating a test data packet according to the test information, and sending the test data packet to the to-be-detected device; and receiving a response data packet sent by the to-be-detected device, and obtaining a test result according to the response data packet. By adopting the method, the detection cost can be reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of testing technology, and in particular to a testing method, apparatus, computer equipment, computer-readable storage medium, and computer program product. Background Art

[0002] With the widespread application of USB (Universal Serial Bus) technology, USB devices have become an indispensable communication interface in various electronic devices, used for multiple functions such as data transmission, device control and power management. Since USB devices need to interact with different types of hosts and operating systems, it is particularly important to ensure their compatibility, stability and transmission performance.

[0003] Functional testing is a key step to verify whether USB devices can work properly in various actual usage scenarios. It aims to detect the performance of the device, the reliability of data transmission, and whether it complies with USB protocol standards. Through functional testing, developers can ensure the stable operation of the device in different systems and environments, improve user experience, and reduce potential compatibility and performance issues.

[0004] However, traditional USB functional testing usually relies on dedicated USB test boards or ATE (automated test equipment), which can send and receive USB signals and verify the communication capabilities of the device. However, dedicated test boards and ATE equipment are expensive, usually requiring a large initial investment, and as the equipment ages, it will also bring certain maintenance and replacement costs. Summary of the invention

[0005] Based on this, it is necessary to provide a testing method, apparatus, computer equipment, computer-readable storage medium and computer program product that can reduce the detection cost in response to the above technical problems.

[0006] In a first aspect, the present application proposes a testing method, which is applied to detect a host, and the method comprises:

[0007] Identify the equipment to be tested;

[0008] Identify the communication endpoint corresponding to the device to be detected, and generate an information input interface corresponding to the communication endpoint;

[0009] Responding to an input instruction received through the information input interface, acquiring test information;

[0010] Generate a test data packet according to the test information, and send the test data packet to the device to be tested;

[0011] Receive a response data packet sent by the device to be detected, and obtain a test result according to the response data packet.

[0012] In one embodiment, the test information includes one or more of test data, data length, communication type, transmission frequency and test duration; the communication endpoint includes one or more of synchronous endpoint, batch endpoint and interrupt endpoint; the test data packet includes synchronous test data packet and batch test data packet.

[0013] In one embodiment, generating a test data packet according to the test information and sending the test data packet to the device to be detected includes:

[0014] If the communication type is synchronous transmission, generating the synchronous test data packet according to the test data and the data length;

[0015] The synchronous test data packet is sent to the device to be detected through the synchronous endpoint according to the sending frequency.

[0016] In one embodiment, generating a test data packet according to the test information and sending the test data packet to the device to be detected includes:

[0017] If the communication type is batch transmission, generating the batch test data packet according to the test data and the data length;

[0018] Splitting the batch test data packet into a plurality of sub-data packets according to the endpoint capacity of the device to be detected;

[0019] Monitor the sending time;

[0020] If the sending duration does not reach the test duration, the sub-data packet is continuously sent to the device to be detected through the batch endpoint.

[0021] In one embodiment, obtaining a test result according to the response data packet includes:

[0022] If the response data packet is identical to the test data packet and the confirmation mark is yes, the test result is determined to be passed; the confirmation mark is used to indicate that the device to be tested has received the test data packet; the confirmation mark is sent in advance by the device to be tested and stored in the detection host.

[0023] In one embodiment, determining the device to be detected includes:

[0024] Scan USB ports to obtain reference test devices;

[0025] A user instruction is received, and the device to be detected is determined from the reference detection devices according to the user instruction.

[0026] In one embodiment, the identifying the communication endpoint corresponding to the device to be detected includes:

[0027] Sending a descriptor request to the device to be detected through the first control endpoint to obtain a descriptor corresponding to the device to be detected; the descriptor is obtained by searching according to the descriptor request after the device to be detected receives the descriptor request and sent to the detection host through the second control endpoint;

[0028] The descriptor is parsed to obtain the communication endpoint.

[0029] In a second aspect, the present application proposes a testing device, the device comprising:

[0030] A device determination module, used to determine the device to be detected;

[0031] An endpoint identification module, used to identify the communication endpoint corresponding to the device to be detected, and generate an information input interface corresponding to the communication endpoint;

[0032] A response module, used for responding to an input instruction received through the information input interface to obtain test information;

[0033] A sending module, used for generating a test data packet according to the test information, and sending the test data packet to the device to be tested;

[0034] The receiving module is used to receive a response data packet sent by the device to be detected, and obtain a test result according to the response data packet.

[0035] In a third aspect, the present application proposes a computer device, comprising a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the above method when executing the computer program.

[0036] In a fourth aspect, the present application proposes a computer-readable storage medium having a computer program stored thereon, wherein the computer program implements the steps of the above method when executed by a processor.

[0037] In a fifth aspect, the present application proposes a computer program product, comprising a computer program, which implements the steps of the above method when executed by a processor.

[0038] In the above-mentioned test method, apparatus, computer equipment, computer-readable storage medium and computer program product, the detection host generates an information input interface matching the endpoint by identifying the communication endpoint, and responds to the test instructions input by the user. After obtaining the test information, the test host automatically generates a test data packet and transmits it to the device to be tested. Subsequently, the detection host receives the response data packet returned by the device and performs a comparison analysis to finally generate the test results. By integrating the software solution on the detection host, not only the automation and flexibility of the test are improved, but also the equipment dependence and testing costs are effectively reduced. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0040] Figure 1 An application environment diagram of a test method in an embodiment;

[0041] Figure 2 A schematic diagram of a test method in one embodiment;

[0042] Figure 3 A schematic flow chart of a test step in another embodiment;

[0043] Figure 4 is a structural block diagram of a testing device in one embodiment;

[0044] Figure 5 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION

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

[0046] The test method provided in the embodiment of the present application can be applied to Figure 1In the application environment shown. Among them, the USB port of the detection host is connected to the USB interface of the device to be detected through a USB cable to establish a data transmission path. The detection host scans the available USB ports, identifies and selects the device to be detected; then identifies the communication endpoints supported by the device to be detected, and generates an information input interface corresponding to the communication endpoints to facilitate the acquisition of test information; the detection host generates a test data packet based on the test information, and sends the test data packet to the device to be detected through the USB interface. After the device to be detected receives the test data packet, it generates a response data packet and sends the response data packet to the detection host, and the detection host obtains the test result based on the response data packet.

[0047] In an exemplary embodiment, Figure 2 As shown, a test method is provided, which is applied to Figure 1 The detection host in the example is used to illustrate, including the following steps S202 to S210. Among them:

[0048] Step S202, determining the device to be detected.

[0049] The device to be tested is a device connected to the testing host through a USB interface and is the test target.

[0050] Optionally, in a scenario where the read and write performance of a USB flash drive is tested, the device to be tested may be a USB flash drive.

[0051] Optionally, in testing a USB module of an embedded system, the device to be detected is a USB chip on the embedded system.

[0052] Optionally, there may be multiple USB ports on the test host, so at the beginning of the test, the host will scan all connected USB device ports to obtain device information for each port. During the test, the user can select devices on one or more USB ports as devices to be tested. For each selected device, the test host will occupy the corresponding USB port and establish a communication path with the device for parallel or independent testing.

[0053] Step S204, identifying the communication endpoint corresponding to the device to be detected, and generating an information input interface corresponding to the communication endpoint.

[0054] Among them, the communication endpoint is the channel for USB devices to transfer data with the host, which can be understood as the starting point or end point of the data flow. Each USB device has at least one control endpoint, which is used to initialize and configure the device. In addition, depending on the type and function of the device, it may contain multiple communication endpoints, such as endpoints for bulk data transfer, synchronous transfer, or interrupt events.

[0055] Optional communication endpoints include control endpoints, bulk transfer endpoints, isochronous transfer endpoints, and interrupt transfer endpoints. Among them, the control endpoint is used to transmit device configuration instructions, which must be included in every USB device; the bulk transfer endpoint is used to transmit large-capacity data, such as files or storage data; the isochronous transfer endpoint is used for real-time transmission, such as audio or video streams; the interrupt transfer endpoint is used for low-latency event transmission, such as mouse movement, keyboard key operation, etc.

[0056] Since different devices to be detected may have different communication endpoints, for example, a USB flash drive includes a batch transmission endpoint, and an audio device includes a synchronous transmission endpoint, it is necessary to identify the communication endpoint corresponding to the device to be detected in this step.

[0057] Optionally, the detection host sends a descriptor request to the device to be detected through the control endpoint to obtain the communication endpoint of the device to be detected.

[0058] Optionally, the detection host may obtain the communication endpoint of the device to be detected through the device driver of the operating system. For example, the detection host calls the operating system API to query the communication endpoint of the device.

[0059] After identifying the communication endpoint corresponding to the device to be tested, the detection host automatically generates the corresponding input interface based on the acquired endpoint information. Each endpoint will have an independent input area so that users can configure parameters for different types of endpoints. For example, for a batch transfer endpoint, the interface will provide the upload test data and the data length corresponding to the test data.

[0060] Optionally, the interface of the synchronous transmission endpoint will also include the transmission frequency. This is because synchronous transmission is usually used for real-time streaming media transmission such as audio and video, and data needs to be transmitted at strict time intervals to avoid audio and video freezes or distortions. The corresponding interface of the interrupt transmission endpoint supports time simulation, allowing users to input sequences or modeled events. This is because interrupt transmission is used to capture low-latency events such as keyboard keys and mouse movements. These events usually need to be delivered within a specific time window to ensure a timely response.

[0061] Step S206, in response to the input instruction received through the information input interface, obtaining test information.

[0062] After generating the input interface corresponding to the communication endpoint, the detection host will enter the standby state and continuously monitor the user's input operations on the interface. When the user configures the test information in the different endpoint interfaces and clicks the Submit or Confirm button, the system will immediately respond to these instructions and read all the test information configured by the user.

[0063] Optionally, the configuration information includes uploaded files, transmission frequency, data packet size, transmission duration or event sequence, etc.

[0064] Optionally, the detection host will check the integrity and validity of this information. In case of batch transmission, it will confirm whether the data packet size exceeds the maximum packet size of the endpoint; in case of synchronous transmission, it will check whether the transmission frequency is within the range supported by the device; in case of interrupt transmission, it will verify whether the input event sequence logic is reasonable and ensure that the time interval is set within an acceptable range. If it is detected that the input information is incomplete or does not meet the requirements, the user will be prompted to modify or supplement it through the interface to ensure that all required parameters are correctly filled in.

[0065] Step S208: Generate a test data packet according to the test information, and send the test data packet to the device to be tested.

[0066] Optionally, the detection host will generate corresponding test data packets for scenarios such as batch transmission, synchronous transmission, and interrupt transmission according to the types of different communication endpoints.

[0067] Optionally, after the data packet is generated, the system will select the appropriate transmission path according to the endpoint information in the device descriptor. If it is a bulk transfer, the corresponding bulk transfer endpoint will be selected (such as the OUT endpoint for sending); if it is a synchronous transfer, the synchronous endpoint is used to ensure that the data packet is transmitted within the specified time; interrupt transmission uses the interrupt endpoint to send events. The host sends the generated data packet to the device to be detected through the USB interface and monitors the status of the transmission in real time to ensure that each packet can be sent correctly.

[0068] Optionally, during the transmission process, the detection host will record the sending time, transmission rate and response of each data packet. If an abnormality occurs during the transmission process (such as timeout or data loss), the detection host will immediately record the error log and retry or prompt the user as appropriate. For batch transmission, if the data packet is split into multiple parts, the detection host will ensure that each sub-packet is sent in sequence and monitor the transmission integrity. In the synchronous transmission scenario, the detection host will strictly send data packets at the set frequency to ensure the continuity and real-time nature of the streaming data. Interrupted transmission will gradually trigger operations according to the simulated event sequence and monitor the response of the device.

[0069] Step S210, receiving a response data packet sent by the device to be tested, and obtaining a test result according to the response data packet.

[0070] Optionally, after the test data packet is sent, the detection host enters a receiving state, waiting for the device to be detected to return a response data packet through a corresponding communication endpoint.

[0071] Optionally, the response data packet can be used to confirm whether the device correctly receives and processes the test data and provide the status of the device or the test results.

[0072] Furthermore, the response data packet is generated according to the type of the transmission communication endpoint. For example, in a bulk transmission scenario, the response data packet may contain data verification information written by the device; while in an interrupt transmission, the response packet will contain the device's processing results for the simulated event. One thing that needs to be explained is that in synchronous transmission, there is no response packet. This is because synchronous transmission focuses on real-time data transmission, such as the transmission of audio and video streams. The core goal of synchronous transmission is to ensure that data is transmitted on time, and even if data is lost, there will be no retransmission or waiting for a response. This is different from the mechanism of bulk transmission and control transmission, which uses ACK to ensure data integrity.

[0073] Optionally, the test host will log all received response data, comparison results, and transmission performance (such as transmission rate, latency, etc.) and generate a detailed test report. The report will summarize the success rate of each transmission, the errors that occurred, and the response of the device. If the test is long-term, the test host will also analyze the stability of the device under high load to check whether there is performance degradation or frequent errors.

[0074] In the above test method, the detection host identifies the communication endpoint, generates an information input interface that matches the endpoint, responds to the test instructions input by the user, obtains the test information, and automatically generates a test data packet and transmits it to the device to be tested. Subsequently, the detection host receives the response data packet returned by the device and compares and analyzes it, and finally generates the test results. The software solution integrated on the detection host not only improves the automation and flexibility of the test, but also effectively reduces device dependence and testing costs.

[0075] Further, in one embodiment, the above-mentioned test data packet is generated according to the test information, and the test data packet is sent to the device to be tested, including: if the communication type is synchronous transmission, a synchronous test data packet is generated according to the test data and the data length; according to the sending frequency, the synchronous test data packet is sent to the device to be tested through the synchronous endpoint.

[0076] Optionally, if the communication type is synchronous transmission, the detection host will generate synchronous test data packets based on the test data and data length entered by the user. Synchronous test data packets are used to simulate real-time transmission scenarios, such as audio or video streaming. In the process of generating data packets, the detection host will package the test data according to the specified data format and ensure that the length of each packet meets the transmission requirements of the device.

[0077] Optionally, after completing the generation of the data packets, the detection host will send these data packets one by one through the synchronous transmission endpoint of the device according to the transmission frequency configured by the user. The key to synchronous transmission is the time sensitivity of the data, so the detection host will use a timer or clock mechanism to ensure that each data packet is accurately sent within the set frequency interval. For example, if the user sets a frequency of 48kHz, the detection host will ensure that 48,000 data packets are sent per second to simulate real audio transmission.

[0078] Optionally, during the transmission process, the detection host will monitor the transmission of data packets in real time to ensure that each transmission is successfully executed and record the timestamp of the transmission. If there is a delay, packet loss or timeout during the transmission process, the detection host will immediately record the error and issue a warning or prompt as needed. The process of transmitting through synchronous endpoints can test the performance and stability of the device to be tested in real-time transmission scenarios, ensuring that it can correctly handle high-frequency data streams in actual use.

[0079] Furthermore, in one embodiment, a test data packet is generated based on the test information, and the test data packet is sent to the device to be tested, including: if the communication type is batch transmission, generating a batch test data packet based on the test data and the data length; splitting the batch test data packet into multiple sub-data packets based on the endpoint capacity of the device to be tested; monitoring the sending duration; if the sending duration does not reach the test duration, continuously sending the sub-data packets to the device to be tested through the batch endpoint.

[0080] Optionally, after generating a batch test data packet, the detection host will split the test data packet into multiple sub-data packets according to the endpoint capacity of the device to be detected. This is because the amount of data transmitted each time cannot exceed the maximum endpoint capacity of the device (usually determined by the maximum packet size in the device descriptor). For example, if the batch endpoint capacity of the device to be detected is 512 bytes, and the total length of the test data is 1MB, the detection host will split it into several 512-byte sub-data packets and send them in sequence.

[0081] Optionally, during the sub-packet sending process, the detection host will continuously monitor the sending duration. If the sending duration does not reach the test duration set by the user (such as a 24-hour stress test), the detection host will continue to send sub-packets to the device to be tested through the batch endpoint. During the entire test duration, data transmission will be performed in a cyclic manner to ensure that the device can still stably receive and process data under high load.

[0082] Optionally, during the transmission, the detection host will also record the timestamp, transmission rate and error information of each transmission. If a timeout, packet loss or transmission failure is detected, the detection host will immediately record the error log and issue a warning or prompt as needed. By continuously monitoring the transmission duration and batch transmission performance, the detection host can comprehensively evaluate the stability and reliability of the device to be tested under large data volume transmission.

[0083] Furthermore, the test result is obtained according to the response data packet, including: if the response data packet is the same as the test data packet and the confirmation mark is yes, the test result is determined to be passed; the confirmation mark is used to indicate that the device to be tested has received the test data packet; the confirmation mark is sent in advance by the device to be tested and stored in the detection host.

[0084] In the loopback test, the detection host will first send a test data packet to the device to be detected through the OUT endpoint. Assuming that the content of the test data packet is "12345678", the data will be transmitted to the device to be detected through USB. After receiving the data packet, the device to be detected will immediately process it and return a confirmation mark to the detection host according to the protocol, such as sending an ACK mark, indicating that the data packet has been successfully received.

[0085] Among them, ACK is not transmitted back through data packets, but is sent independently to the detection host after the device successfully receives the OUT transmission data. After the detection host receives the ACK confirmation, it will automatically trigger an IN transmission, that is, the detection host actively requests the device to send back the previously received data as is. If the loopback test function is normal, the device to be tested will accurately transmit the data "12345678" back to the detection host through the IN endpoint.

[0086] After the detection host completes the entire process of OUT transmission and IN transmission, the data received in the IN transmission will be compared with the original OUT transmission data. If the data content of the two transmissions is exactly the same, and the host successfully receives the ACK confirmation mark returned by the device during OUT transmission, then the loopback test is considered to have passed. This indicates that the device's sending and receiving paths are normal, and there are no errors in the data transmission back and forth between the device and the host.

[0087] If the host fails to receive the ACK confirmation mark during the test, or the data received during IN transmission is inconsistent with the original data, the test will be considered failed and an error message will be recorded. Possible causes of the error include the device failing to correctly process the OUT transmission data, the data being damaged during internal storage or transmission back to the device, or the host's IN transmission request failing to execute correctly.

[0088] In the above embodiment, through this loopback test, the stability and data integrity of the device in bidirectional transmission can be fully verified.

[0089] Furthermore, the above-mentioned determination of the device to be detected includes: scanning the USB port to obtain a reference detection device; receiving a user instruction, and determining the device to be detected from the reference detection device according to the user instruction.

[0090] First, the detection host scans all USB ports, detects all currently connected devices, and obtains basic information of these devices, such as manufacturer ID, product ID, device class (such as storage device or audio device), etc. These devices will be listed as reference detection devices in the test plug-in interface.

[0091] Next, the detection host receives the user's selection instruction. The user can select the target device to be tested from the reference detection device list based on the detected device information. If multiple devices are connected, the user can accurately locate the device by filtering through the interface or directly entering the specified manufacturer ID and product ID. The detection host will mark the device as a device to be detected based on the user's selection.

[0092] Once the device to be tested is determined, the test host will lock its USB port, establish a communication path, and prepare to perform further test operations. This process ensures that the system can flexibly identify and select the target device. Even if multiple USB devices are connected at the same time, it can quickly locate and configure the required device to be tested, laying the foundation for subsequent tests.

[0093] Furthermore, in one embodiment, the above-mentioned identification of the communication endpoint corresponding to the device to be detected includes: sending a descriptor request to the device to be detected through a first control endpoint to obtain a descriptor corresponding to the device to be detected; after the device to be detected receives the descriptor request, the descriptor is searched and obtained according to the descriptor request and sent to the detection host through a second control endpoint; and the descriptor is parsed to obtain the communication endpoint.

[0094] First, the detection host sends a descriptor request to the device to be detected through the first control endpoint. The descriptor request is used to obtain configuration information of the device to understand the communication endpoints and their properties supported by the device.

[0095] When the device to be detected receives a descriptor request, it will search for the corresponding descriptor information from its internal storage or firmware according to the content of the request. These descriptors may include device descriptors, configuration descriptors, interface descriptors, etc. The most important of these are endpoint descriptors that contain endpoint type, quantity, direction, and maximum packet size. After the device to be detected finds the corresponding descriptor, it will send the descriptor data back to the detection host through the second control endpoint (i.e., the IN direction of the control endpoint).

[0096] After receiving the descriptor, the detection host will parse it to identify the communication endpoint information supported by the device. The parsing results will include the type of each endpoint (such as control, bulk, synchronous, interrupt), the transmission direction (IN or OUT), and the maximum packet size of the endpoint. This information will be used to generate an input interface corresponding to the device's communication endpoint and configure transmission parameters for subsequent tests to ensure that the device's endpoint can communicate normally with the detection host.

[0097] In one embodiment, by parsing the descriptor, it is possible to flexibly adapt to the communication requirements of different devices, whether it is batch transmission of large-capacity data or interrupt transmission of low-latency events, and provide users with a reliable testing environment.

[0098] In an exemplary embodiment, in combination Figure 3 As shown, Figure 3 The figure is a schematic diagram of the steps of a testing method in an embodiment.

[0099] 1. Open the test plug-in. The test plug-in is a module that is pre-developed and integrated with the USB interface communication function. It contains the relevant API and function code of the libusb library, which is used to manage the connection, data transmission and test configuration of USB devices. After the plug-in is loaded, it enters the standby state and is ready to perform USB device detection and test operations.

[0100] 2. Determine the device to be tested. The test plug-in will scan all USB ports, obtain the currently connected reference test device, and display the basic information of each device (such as manufacturer ID (VID), product ID (PID), etc.) for the user to select. The user enters instructions or selects a device through the interface, and the system determines the specific device to be tested based on the instruction. Once the device to be tested is determined, the plug-in will lock the USB port and establish a connection for subsequent descriptor acquisition and communication testing.

[0101] 3. Initialize the PC port and send a descriptor request. The plug-in sends a descriptor request command to the control endpoint of the device to be detected by calling the libusb API integrated in it to obtain the descriptor information of the device.

[0102] 4. Detect the descriptor response and determine whether to continue the test. If the plug-in fails to receive the descriptor response from the device to be tested, the test is terminated and the system enters the standby state, waiting for the next test task to start. If the descriptor is successfully received, the plug-in will parse the descriptor according to the USB protocol and extract the endpoint information and communication capabilities of the device.

[0103] 5. Parse the descriptor information and generate an operation interface. The plug-in analyzes the parsed descriptor to obtain the communication endpoint types supported by the device, such as bulk transfer, synchronous transfer, interrupt transfer, etc. Based on the parsing results, the system will generate a corresponding operation interface for each endpoint type. In these interfaces, users can enter or select test parameters, such as data content, data length, transmission packet size and frequency, etc., and can configure the data length of the receiving end and display the received data content. In this embodiment, the control transmission endpoint, synchronous transmission endpoint, bulk transmission endpoint, and interrupt transmission endpoint are judged in turn and the operation interface is generated. In other embodiments, any endpoint can be tested, or judged in other orders, which is not specifically limited in this embodiment.

[0104] 6. Generate test data packets and perform tests. Based on the test information entered by the user on the operation interface, the plug-in will generate test data packets suitable for each transmission type. For bulk transfer endpoints, the system will split the data packet into multiple sub-packets; for synchronous transfer endpoints, the data packet will be sent regularly according to the set frequency; for interrupt transfer endpoints, the data packet will simulate the event sequence for transmission. The plug-in calls the libusb API to send these test data packets to the device to be tested through the corresponding USB endpoint and monitor the sending and receiving of the data.

[0105] 7. Receive response data packets and generate test results.

[0106] It should be noted that, in this embodiment, the above test process is completed through a pre-developed plug-in.

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

[0108] Based on the same inventive concept, the embodiment of the present application also provides a test device for implementing the test method involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in one or more test device embodiments provided below can refer to the limitations on the test method above, and will not be repeated here.

[0109] In an exemplary embodiment, Figure 4 As shown, a test device is provided, including: a device determination module 410, an endpoint identification module 420, a response module 430, a sending module 440 and a receiving module 450, wherein:

[0110] The device determination module 410 is used to determine the device to be detected.

[0111] The endpoint identification module 420 is used to identify the communication endpoint corresponding to the device to be detected and generate an information input interface corresponding to the communication endpoint.

[0112] The response module 430 is used to respond to the input instruction received through the information input interface and obtain test information.

[0113] The sending module 440 is used to generate a test data packet according to the test information, and send the test data packet to the device to be detected.

[0114] The receiving module 450 is used to receive a response data packet sent by the device to be detected, and obtain a test result according to the response data packet.

[0115] In one embodiment, the test information in the above-mentioned response module 430 includes one or more of test data, data length, communication type, sending frequency and test duration; the communication endpoint includes one or more of synchronous endpoints, batch endpoints and interrupt endpoints; the test data packet includes synchronous test data packets and batch test data packets.

[0116] In one embodiment, the sending module 440 includes:

[0117] A synchronous test packet generating unit is used to generate the synchronous test data packet according to the test data and the data length if the communication type is synchronous transmission.

[0118] The first test sending unit is used to send the synchronous test data packet to the device to be detected through the synchronous endpoint according to the sending frequency.

[0119] In one embodiment, the sending module 440 includes:

[0120] A batch test packet generating unit is used to generate the batch test data packet according to the test data and the data length if the communication type is batch transmission.

[0121] The splitting unit is used to split the batch test data packet into multiple sub-data packets according to the endpoint capacity of the device to be detected.

[0122] The duration detection unit is used to monitor the sending duration.

[0123] The second test sending unit is configured to continuously send the sub-data packet to the device to be detected through the batch endpoint if the sending duration does not reach the test duration.

[0124] In one embodiment, the receiving module 450 includes:

[0125] A detection unit, used to determine that the test result is passed if the response data packet is the same as the test data packet and the confirmation mark is yes; the confirmation mark is used to indicate that the device to be detected has received the test data packet; the confirmation mark is sent in advance by the device to be detected and stored in the detection host.

[0126] In one embodiment, the device determination module 410 includes:

[0127] The scanning unit is used to scan the USB port to obtain a reference detection device.

[0128] The selection unit is used to receive a user instruction and determine the device to be detected from the reference detection devices according to the user instruction.

[0129] In one embodiment, the endpoint identification module 420 includes:

[0130] The request sending unit is used to send a descriptor request to the device to be detected through the first control endpoint to obtain the descriptor corresponding to the device to be detected; the descriptor is obtained by the device to be detected after receiving the descriptor request, according to the descriptor request, and sent to the detection host through the second control endpoint.

[0131] The descriptor parsing unit is used to parse the descriptor to obtain the communication endpoint.

[0132] Each module in the above-mentioned test device can be implemented in whole or in part by software, hardware and a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute the operations corresponding to each module above.

[0133] In an exemplary embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as shown in FIG. Figure 5 As shown. The computer device includes a processor, a memory, an input / output interface (Input / Output, referred to as I / O) and a communication interface. The processor, the memory and the input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store test information. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a test method is implemented.

[0134] Those skilled in the art will understand that Figure 5 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0135] In an exemplary embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the steps of the method in any one of the above embodiments when executing the computer program.

[0136] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps of the method in any one of the above embodiments are implemented.

[0137] In one embodiment, a computer program product is provided, comprising a computer program, which implements the steps of the method in any one of the above embodiments when executed by a processor.

[0138] Those of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, an artificial intelligence (AI) processor, etc., but are not limited to this.

[0139] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.

[0140] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.

Claims

1. A testing method, characterized in that: Applied to detecting a host, the method comprises: Identify the equipment to be tested; Identify the communication endpoint corresponding to the device to be detected, and generate an information input interface corresponding to the communication endpoint; Responding to an input instruction received through the information input interface, acquiring test information; Generate a test data packet according to the test information, and send the test data packet to the device to be tested; Receive a response data packet sent by the device to be detected, and obtain a test result according to the response data packet.

2. The method according to claim 1, characterized in that The test information includes one or more of test data, data length, communication type, transmission frequency and test duration; the communication endpoint includes one or more of synchronous endpoint, batch endpoint and interrupt endpoint; The test data packets include synchronous test data packets and batch test data packets.

3. The method according to claim 2, characterized in that The step of generating a test data packet according to the test information and sending the test data packet to the device to be detected includes: If the communication type is synchronous transmission, generating the synchronous test data packet according to the test data and the data length; The synchronous test data packet is sent to the device to be detected through the synchronous endpoint according to the sending frequency.

4. The method according to claim 2, characterized in that: The step of generating a test data packet according to the test information and sending the test data packet to the device to be detected includes: If the communication type is batch transmission, generating the batch test data packet according to the test data and the data length; Splitting the batch test data packet into a plurality of sub-data packets according to the endpoint capacity of the device to be detected; Monitor the sending time; If the sending duration does not reach the test duration, the sub-data packet is continuously sent to the device to be detected through the batch endpoint.

5. The method according to claim 1, characterized in that The obtaining of the test result according to the response data packet comprises: If the response data packet is identical to the test data packet and the confirmation mark is yes, the test result is determined to be passed; the confirmation mark is used to indicate that the device to be tested has received the test data packet; the confirmation mark is sent in advance by the device to be tested and stored in the detection host.

6. The method according to claim 1, characterized in that The step of determining the device to be detected includes: Scan USB ports to obtain reference test devices; A user instruction is received, and the device to be detected is determined from the reference detection devices according to the user instruction.

7. The method according to claim 1, characterized in that The identifying the communication endpoint corresponding to the device to be detected includes: Sending a descriptor request to the device to be detected through the first control endpoint to obtain a descriptor corresponding to the device to be detected; the descriptor is obtained by searching according to the descriptor request after the device to be detected receives the descriptor request and sent to the detection host through the second control endpoint; The descriptor is parsed to obtain the communication endpoint.

8. A testing device, characterized in that: The device comprises: A device determination module, used to determine the device to be detected; An endpoint identification module, used to identify the communication endpoint corresponding to the device to be detected, and generate an information input interface corresponding to the communication endpoint; A response module, used for responding to an input instruction received through the information input interface to obtain test information; A sending module, used for generating a test data packet according to the test information, and sending the test data packet to the device to be tested; The receiving module is used to receive a response data packet sent by the device to be detected, and obtain a test result according to the response data packet.

9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.