Test method, computer device, and computer readable storage medium
By creating a data channel in the test system of the Internet of Things platform, the problem of large-scale development workload of serial communication protocols during traditional equipment access is solved, and the target data transmission without hardware participation is achieved, reducing the development workload and debugging test time.
Patent Information
- Application Number
- CN202011624759.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-12-30
- Publication Date
- 2024-12-03
- Estimated Expiration
- 2040-12-30
AI Technical Summary
During the construction of the IoT platform, the serial communication protocol needs to be developed when accessing traditional devices, resulting in a large amount of workload for the development of the serial communication protocol, especially when multiple IoT devices are jointly debugged and tested, the workload has increased significantly.
By determining whether there is a data channel for target data in the test system, if it does not exist, a data channel is created, and the target data is transmitted between the first communication module and the second communication module through the data channel, simulating a serial port connection, thereby reducing development Workload.
Without the hardware involved in the communication module, the target data transmission of different communication modules is applicable, which significantly reduces the workload and debugging and testing time of serial communication protocol development and improves development efficiency.
Smart Images

Figure CN114765588B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of data transmission, and in particular to a testing method, a computer device, and a computer-readable storage medium. Background Art
[0002] With the development of Internet of Things technology, more and more Internet of Things platforms have been formed. When building an Internet of Things platform, multiple traditional devices are connected to the Internet of Things platform to form Internet of Things devices. When connecting traditional devices to the Internet of Things platform, since traditional devices do not have networking functions, it is necessary to formulate a serial communication protocol to connect traditional devices to the WIFI module and access the Internet of Things platform. In the prior art, after developing the serial communication protocol, it is necessary to debug and test the serial communication protocol. During the debugging and testing, data is transmitted between the Internet of Things device and the WIFI module through the serial communication protocol. When multiple Internet of Things devices are jointly debugged and tested, multiple Internet of Things devices need to transmit data, resulting in a large workload for the development of the serial communication protocol.
[0003] Therefore, the prior art needs to be improved. Summary of the invention
[0004] The technical problem to be solved by the present invention is to provide a testing method, a computer device, and a computer-readable storage medium in view of the deficiencies in the prior art, aiming to solve the problem of large development workload of serial communication protocols in the prior art.
[0005] In one aspect, an embodiment of the present invention provides a testing method, which is applied to a testing system, wherein the testing system includes: a first communication module and a second communication module; the method includes:
[0006] Obtaining a test instruction corresponding to the first communication module, determining target data corresponding to the test instruction according to the test instruction, and judging whether there is a data channel corresponding to the target data in the test system;
[0007] When the data channel does not exist in the test system, creating the data channel in the test system;
[0008] When the data channel is created, the target data is transmitted between the first communication module and the second communication module through the data channel to test the first communication module and the second communication module.
[0009] In a second aspect, an embodiment of the present invention provides a computer device, including a memory and a processor, wherein the memory stores a computer program and is applied to a test system, wherein the test system includes: a first communication module and a second communication module; when the processor executes the computer program, the following steps are implemented:
[0010] Obtaining a test instruction corresponding to the first communication module, determining target data corresponding to the test instruction according to the test instruction, and judging whether there is a data channel corresponding to the target data in the test system;
[0011] When the data channel does not exist in the test system, creating the data channel in the test system;
[0012] When the data channel is created, the target data is transmitted between the first communication module and the second communication module through the data channel to test the first communication module and the second communication module.
[0013] In a third aspect, an embodiment of the present invention provides a computer-readable storage medium having a computer program stored thereon, which is applied to a test system, wherein the test system comprises: a first communication module and a second communication module; when the computer program is executed by a processor, the following steps are implemented:
[0014] Obtaining a test instruction corresponding to the first communication module, determining target data corresponding to the test instruction according to the test instruction, and judging whether there is a data channel corresponding to the target data in the test system;
[0015] When the data channel does not exist in the test system, creating the data channel in the test system;
[0016] When the data channel is created, the target data is transmitted between the first communication module and the second communication module through the data channel to test the first communication module and the second communication module.
[0017] Compared with the prior art, the embodiment of the present invention has the following advantages: when transmitting target data between the first communication module and the second communication module in the system, it is first determined whether there is a data channel corresponding to the target data in the system. If the data channel does not exist in the system, the data channel is created in the system, and the target data is transmitted between the first communication module and the second communication module through the data channel. The serial port connection line of the first communication module and the second communication module is simulated through the data channel, so that the first communication module and the second communication module can transmit the target data through the data channel. Therefore, when the target data is transmitted through the data channel, the data channel can be used for the transmission of target data of different programs. When developing the serial communication protocol, the hardware corresponding to the program is not required to participate, thereby greatly reducing the development workload. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0019] Figure 1 This is a diagram of the Internet of Things device access architecture in the test method of an embodiment of the present invention;
[0020] Figure 2 This is a diagram of the serial port simulation architecture on the system in the test method of an embodiment of the present invention;
[0021] Figure 3 This is a flow chart of the WIFI module in the test method of an embodiment of the present invention;
[0022] Figure 4 This is a flow chart of the MCU communication module in the test method of an embodiment of the present invention;
[0023] Figure 5 is a flow chart of a testing method in an embodiment of the present invention;
[0024] Figure 6 1 is a diagram showing the internal structure of a computer device in an embodiment of the present invention. DETAILED DESCRIPTION
[0025] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0026] The inventor has found through research that when converting traditional equipment into IoT equipment and building an IoT platform, the UART interface on the traditional equipment is connected to the WIFI module, thereby accessing the cloud through the WIFI module, and the cloud is connected to the client communication, thereby forming an IoT platform. Since traditional equipment does not have an Internet connection function, it is necessary to formulate a serial communication protocol to connect traditional equipment to the WIFI module. After developing the serial communication protocol, it is necessary to debug and test the serial communication protocol, and the serial communication protocol can be used after the debugging and testing of the serial communication protocol is completed. During the debugging and testing, data is transmitted between the IoT device and the WIFI module through the serial communication protocol. When multiple IoT devices are jointly debugged and tested, multiple IoT devices all need to transmit data, resulting in a large workload for the development of the serial communication protocol.
[0027] In order to solve the above problem, in an embodiment of the present invention, when transmitting target data between the first communication module and the second communication module in the test system, it is first determined whether there is a data channel corresponding to the target data in the test system. If the data channel does not exist in the test system, the data channel is created in the test system, and the target data is transmitted between the first communication module and the second communication module through the data channel. The serial port connection line of the first communication module and the second communication module is simulated through the data channel, so that the first communication module and the second communication module can transmit the target data through the data channel. Therefore, when the target data is transmitted through the data channel, the data channel can be used for the transmission of target data of different communication modules. When developing the protocol, the hardware corresponding to the communication module does not need to be involved, thereby greatly reducing the development workload.
[0028] like Figure 2 As shown, in an embodiment of the present invention, a test system is provided, the test system comprising: a first communication module and a second communication module. The test system refers to a system for testing data transmission between communication modules, and the communication module refers to a module for transmitting data. The test system can be a desktop computer, a tablet computer, a laptop computer, a mobile phone, a personal digital assistant or a wearable device, etc.
[0029] For example, the first communication module is a WIFI module, the second communication module is a washing machine module, the WIFI module refers to a module that runs the program of the WIFI module, and the washing machine module refers to a module that runs the program of the washing machine, that is, the program of the WIFI module is run on the WIFI module of the test system, and the program of the washing machine is run on the washing machine module, and the WIFI module and the washing machine module are tested by the test system, that is, when testing the washing machine and the WIFI module, it is only necessary to run the program of the washing machine and the program of the WIFI module on the first communication module and the second communication module of the test system respectively, so as to perform the test, without the need for the test system to connect the washing machine and the WIFI module. For another example, the first communication module is a WIFI module, and the second communication module is an air conditioning module, and the WIFI module and the washing machine module are tested by the test system.
[0030] It is understandable that if Figure 1As shown, the first communication module can be a WIFI module, an air conditioning module, a washing machine module, a dishwasher module, a clothes drying rack module, a speaker module, a television module, a refrigerator module, a lamp module, etc. The second communication module can also be a WIFI module, an air conditioning module, a washing machine module, a dishwasher module, a clothes drying rack module, a speaker module, a television module, a refrigerator module, a lamp module, etc. The first communication module and the second communication module can be any two modules that need to transmit data. For example, when data is transmitted between the air conditioning module and the washing machine module, the air conditioning module and the washing machine module can be tested in the test system.
[0031] Various non-limiting embodiments of the present invention are described in detail below in conjunction with the accompanying drawings.
[0032] See also Figure 1 and Figure 2 , shows a test method in an embodiment of the present invention. In this embodiment, the test method may include the following steps:
[0033] S1. Obtain a test instruction corresponding to the first communication module, determine target data corresponding to the test instruction according to the test instruction, and determine whether there is a data channel corresponding to the target data in the test system.
[0034] Specifically, the test system refers to a system for testing data transmission between communication modules. In one implementation of the present embodiment, the test system adopts a Linux system, and the communication module generally adopts a Linux system. Of course, in other implementations, the test system may also adopt a Unix system or a Windows system. When testing, at least one of the first communication module and the second communication module is a module to be tested, and of course the first communication module and the second communication module may both be modules to be tested. For example, when the first communication module needs to be tested, the target data is sent to the second communication module through the first communication module to test whether the second communication module can receive the target data. For another example, when the first communication module and the second communication module are tested, the first target data is first sent to the second communication module through the first communication module to test whether the second communication module can receive the first target data, and then the second target data is sent to the first communication module through the second communication module to test whether the first communication module can receive the second target data.
[0035] During the test, the first communication module and the second communication module are connected through a data channel and perform data transmission. The data channel refers to the channel for data transmission in the test system, and the data channel is a buffer of a fixed size. For example, in the Linux system, the size of the buffer is 1 page, that is, 4K bytes. The data channel is a unidirectional data transmission channel, and the data channel can be one or more. For example, the data channel includes: a first data channel and a second data channel, and the transmission direction of the second data channel is opposite to the transmission direction of the first data channel. When the first data channel and the second data channel are both connected to the first communication module and the second communication module, the first communication module and the second communication module can exchange data through the first data channel and the second data channel. The data channel has a read end and a write end, the read end is used to read data, and the write end is used to write data, that is, data is written from the write end and read from the read end.
[0036] In one implementation of this embodiment, the data channel includes: a named data channel (named pipe or FIFO, First In First Out) and an unnamed data channel (pipe). The unnamed data channel refers to an unnamed data channel. The unnamed data channel is used to exchange data between processes with affinity, so it does not need to be named. The affinity includes: a parent-child relationship. For example, the unnamed data channel is used between a parent process and a child process, and a data channel is created by using a pipe system call. When the parent process calls fork, all connections and file descriptors are passed from the parent process to the child process. For example, the parent process first writes data at the write end of the data channel, and then the child process reads data from the read end of the data channel.
[0037] The named data channel refers to a named data channel, and the named data channel is used to exchange data between any two processes, that is, the named data channel is used to exchange data between unrelated processes and also between related processes. For example, the first communication module first writes data at the write end of the data channel, and then the second communication module reads data from the read end of the data channel.
[0038] The first communication module and the second communication module serve as the transceiver of the target data. Specifically, when the first communication module serves as the transmitter of the target data, the second communication module serves as the receiver of the target data; when the second communication module serves as the transmitter of the target data, the first communication module serves as the receiver of the target data. Of course, in addition to the first communication module and the second communication module, other communication modules may also be included in the test system, for example, a third communication module and a fourth communication module. The target data may be sent from one communication module to multiple communication modules, for example, the first communication module serves as the transmitter of the target data, and the second communication module and the third communication module serve as the receiver of the target data. The target data may be sent from multiple communication modules to one communication module, for example, the second communication module and the fourth communication module serve as the transmitter of the target data, and the first communication module serves as the receiver of the target data.
[0039] When the first communication module and the second communication module in the test system transmit target data, it is first determined whether the data channel corresponding to the target data exists in the test system, that is, whether there is a data channel between the first communication module and the second communication module that can transmit the target data.
[0040] In the Internet of Things platform, multiple smart terminals are connected to the WIFI module, so during the debugging test, the WIFI module module and the smart terminal module can be debugged and tested. For example, the second communication module includes: a WIFI module module, the WIFI module module is a module for running the program of the WIFI module, and the first communication module includes: a smart terminal module, the smart terminal module is a module for running the program of the smart terminal.
[0041] The target data refers to the data transmitted between communication modules. Since the communication module can both receive and send the target data, the target data includes: first target data and second target data. The first target data and the second target data are respectively the data sent and the data received by the first communication module. For example, the first target data may be request data, and the second target data may be response data.
[0042] S2. When the data channel does not exist in the test system, create the data channel in the test system.
[0043] Specifically, if the data channel does not exist in the test system, the data channel is created in the test system. In order to facilitate the debugging test of the communication module, when creating the data channel, the data channel adopts a named data channel, that is, when creating the data channel, the data channel is named so that it can be passed by name. When creating the data channel, a data channel file, also called a FIFO file, is created, and the suffix of the data channel file is ".fifo".
[0044] S3. When the data channel is created, the target data is transmitted between the first communication module and the second communication module through the data channel to test the first communication module and the second communication module.
[0045] Specifically, after the data channel is created, the first communication module and the second communication module can use the data channel to transmit the target data, thereby testing the first communication module and the second communication module. For example, the first communication module writes the target data at the write end of the data channel, and then the second communication module reads the target data from the read end of the data channel, thereby transmitting the target data from the first communication module to the second communication module.
[0046] When debugging the test communication module on the test system, the first communication module and the second communication module are both modules to be tested, and target data needs to be transmitted between the first communication module and the second communication module. Therefore, it is first determined whether there is a data channel corresponding to the target data in the test system. If the data channel does not exist in the test system, the data channel is created in the test system and the target data is transmitted through the data channel. The data channel is used as a serial port connection line to connect the first communication module and the second communication module, so that the first communication module and the second communication module can transmit the target data through the data channel. Therefore, when the target data is transmitted through the data channel, the data channel can be used for the transmission of target data of different communication modules. When developing the serial communication protocol, the hardware corresponding to the communication module is not required, thereby greatly reducing the development workload. In other words, the test system does not need to be connected to smart terminals such as washing machines and dishwashers, thereby improving development efficiency.
[0047] It should be noted that when developing a serial communication protocol, data transmission is performed through the data channel to implement debugging and testing of the serial communication protocol, and the development of the serial communication protocol can be achieved without the hardware corresponding to the communication module. Due to the independence of development, the efficiency of the development, debugging, self-testing and joint debugging of the serial communication protocol has been greatly improved. The development time, debugging and testing time, and development costs are reduced.
[0048] In an implementation of this embodiment, the data channel includes: a first data channel. Step S2, when the data channel does not exist in the test system, creating the data channel in the test system, includes:
[0049] S21. When the first data channel does not exist in the test system, create the first data channel in the test system, so that the first communication module and the second communication module are communicatively connected through the first data channel.
[0050] Specifically, when the data channel does not exist in the test system, the first data channel F1 is created in the test system, and the first communication module and the second communication module are connected to each other through the first data channel. Specifically, the write end of the first data channel is connected to the first communication module, and the read end of the first data channel is connected to the second communication module. For example, the write end (TX) of the first data channel can be connected to the output end of the second communication module, and the read end (RX) of the first data channel can be connected to the input end of the first communication module. Then, when the second communication module outputs target data, the target data can be written from the write end of the first data channel to the first data channel.
[0051] For example, the smart terminal usually uses MCU (Microcontroller Unit), therefore, the first communication module can be an MCU communication module, the second communication module is a WIFI module, and the first data channel connects the MCU communication module and the WIFI module. The MCU communication module refers to a module that runs the program of the microcontroller unit, and the WIFI module refers to a module that runs the program of the WIFI module.
[0052] When the first data channel does not exist in the test system, the first data channel is created in the test system so that the MCU communication module and the WIFI module are communicatively connected through the first data channel. Specifically, the write end (TX) of the first data channel is communicatively connected to the output end of the WIFI module, and the read end (RX) of the first data channel is communicatively connected to the input end of the MCU communication module.
[0053] It should be noted that, since a data channel is a unidirectional transmission, a data channel has a writing end and a reading end, and therefore, the data channel has a data transmission direction. For example, the transmission direction of the first data channel is the direction of transmission from the first communication module to the second communication module, then the first communication module can write the first target data to the first data channel, and the second communication module can read the first target data from the first data channel.
[0054] The data channel also includes: a second data channel, wherein the transmission direction of the second data channel is the direction of transmission from the second communication module to the first communication module, that is, the transmission direction of the second data channel is opposite to the transmission direction of the first data channel. Two data channels are used, the target data is written in the first data channel, and the target data is read in the second data channel. The two data channels can be used at the same time, which can not only enhance the security of the target data between the communication modules, but also improve the rapid communication between the communication modules and improve the test efficiency.
[0055] Step S2, when the data channel does not exist in the test system, creating the data channel in the test system, further comprising:
[0056] S22: When the second data channel does not exist in the test system, create the second data channel in the test system, so that the first communication module and the second communication module are communicatively connected through the second data channel.
[0057] Specifically, on the basis of creating the first data channel, the second data channel F2 is created so that the first communication module and the second communication module are communicatively connected through the second data channel. Then, the first communication module and the second communication module can exchange data with each other, that is, the first communication module can send data to the second communication module, and the second communication module can also send data to the first communication module.
[0058] Specifically, the write end (TX) of the second data channel can be communicatively connected to the output end of the first communication module, and the read end (RX) of the second data channel can be communicatively connected to the input end of the second communication module. Then, when the first communication module outputs target data, the target data can be written from the write end of the second data channel to the second data channel.
[0059] For example, the first communication module is an MCU communication module, the second communication module is a WIFI module, and the second data channel connects the MCU communication module and the WIFI module. When the second data channel does not exist in the test system, the second data channel is created in the test system so that the second data channel connects the MCU communication module and the WIFI module. Specifically, the write end (TX) of the second data channel is connected to the output end of the MCU communication module, and the read end (RX) of the second data channel is connected to the input end of the WIFI module.
[0060] In an implementation of this embodiment, step S3, when the data channel is created, transmitting the target data between the first communication module and the second communication module through the data channel to test the first communication module and the second communication module, includes:
[0061] S31. When the first data channel is created, the first data channel is opened, so that the first communication module writes the first target data to the first data channel, and the second communication module reads the first target data in the first data channel.
[0062] Specifically, when the first data channel is created, the first target data can be transmitted between the first communication module and the second communication module through the first data channel. Since the write end of the first data channel is connected to the first communication module, and the read end of the first data channel is connected to the second communication module, the first communication module can write the first target data into the first data channel from the write end of the first data channel, and the second communication module can read the first target data from the read end of the first data channel.
[0063] For example, the first communication module is an MCU communication module, the second communication module is a WIFI module, and the MCU communication module and the WIFI module are connected to each other through the first data channel. After the first data channel is created, the first data channel is opened, and the WIFI module writes the first target data into the first data channel, then the MCU communication module can read the first target data from the first data channel.
[0064] In an implementation of this embodiment, the first data channel is a named data channel, and the named data channel carries a channel name. When the first data channel is created, a channel name of the first data channel is formed, and the channel name may be a path name, and the first data channel may be determined by the channel name, so as to access the path. When the first data channel is created, the channel name of the first data channel is obtained from the test system, and the first data channel is determined according to the channel name, and the first data channel is opened.
[0065] Specifically, Figure 3 and Figure 4 As shown, the first communication module is an MCU communication module, the second communication module is a WIFI module, and the MCU communication module and the WIFI module are connected through the first data channel. When the WIFI module runs the program, the WIFI module creates a write thread, and opens the write end of the first data channel through the channel name of the first data channel, and the first target data is written from the output end of the WIFI module to the write end of the first data channel. Then when the MCU communication module runs the program, the MCU communication module creates a read thread, and opens the read end of the first data channel through the channel name of the first data channel, and the first target data is read from the read end of the first data channel to the input end of the MCU communication module.
[0066] When reading and writing the first target data, a blocking read and blocking write method is adopted. Since the size of the first data channel is limited, when writing the first target data to the first data channel, if the first data channel is full, the second communication module will be blocked when continuing to write. When reading the first target data in the first data channel, if the first data channel has been read and becomes an empty data channel, the first communication module will be blocked.
[0067] Of course, when the first communication module reads the first target data in the first data channel, it is determined whether the first target data has been read. If the first target data has not been read, the first communication module continues to read the first target data in the first data channel; if the first target data has been read, the first target data is parsed; if the first communication module has not been executed to completion, the first communication module continues to read the first target data in the first data channel; if the first communication module is executed to completion, the data transmission is completed.
[0068] S32: After the first target data is transmitted, close the first data channel.
[0069] Specifically, when the first target data is transmitted, the first data channel is closed, that is, after the first target data is read by the first communication module, the first data channel is closed. It should be noted that after the first target data is read by the first communication module, the first target data in the first channel will be removed.
[0070] In an implementation of this embodiment, step S3, when the data channel is created, transmitting the target data between the first communication module and the second communication module through the data channel to test the first communication module and the second communication module, further includes:
[0071] S33. When the second data channel is created, the second data channel is opened, so that the second communication module writes the second target data to the second data channel, and the first communication module reads the second target data in the second data channel.
[0072] Specifically, when the second data channel is created, the second target data can be transmitted between the first communication module and the second communication module through the second data channel. Since the writing end of the second data channel is connected to the first communication module for communication, and the reading end of the second data channel is connected to the second communication module for communication, the first communication module can write the second target data into the second data channel from the writing end of the second data channel, and the second communication module can read the second target data from the reading end of the second data channel.
[0073] For example, the first communication module is an MCU communication module, the second communication module is a WIFI module, and the second data channel connects the MCU communication module and the WIFI module. After the second data channel is created, the second data channel is opened, and the MCU communication module writes the second target data into the second data channel, then the WIFI module can read the second target data from the second data channel.
[0074] In an implementation of this embodiment, the second data channel is a named data channel. When the second data channel is created, a channel name of the second data channel is formed. The channel name may be a path name. The second data channel may be determined by the channel name, thereby accessing the path. When the second data channel is created, the channel name of the second data channel is obtained from the test system, and the second data channel is determined according to the channel name, and the second data channel is opened.
[0075] Specifically, Figure 3 and Figure 4 As shown, the first communication module is an MCU communication module, the second communication module is a WIFI module, and the MCU communication module and the WIFI module are connected through the second data channel. When the MCU communication module runs the program, the MCU communication module creates a write thread, and opens the write end of the second data channel through the channel name of the second data channel, and the second target data is written from the output end of the MCU communication module to the write end of the second data channel. Then when the WIFI module runs the program, the WIFI module creates a read thread, and opens the read end of the second data channel through the channel name of the second data channel, and the second target data is read from the read end of the second data channel to the input end of the WIFI module.
[0076] When reading and writing the second target data, a blocking reading and blocking writing method is adopted. Since the size of the second data channel is limited, when writing the second target data into the second data channel, if the second data channel is full, the second communication module will be blocked when continuing to write. When reading the second target data in the second data channel, if the second data channel has been read out and becomes an empty data channel, the second communication module will be blocked.
[0077] Of course, when the second communication module reads the second target data in the second data channel, it is determined whether the second target data has been read. If the second target data has not been read, the second communication module continues to read the second target data in the second data channel; if the second target data has been read, the second target data is parsed; if the second communication module has not been executed, the second communication module continues to read the second target data in the second data channel; if the second communication module is executed, the data transmission is completed.
[0078] S34. When the second target data is transmitted, close the second data channel.
[0079] Specifically, when the second target data is transmitted, the second data channel is closed, that is, after the second target data is read by the second communication module, the second data channel is closed. It should be noted that after the second target data is read by the second communication module, the second target data in the second channel will be removed.
[0080] It should be noted that the first data channel and the second data channel are independent of each other, that is, the transmission of the first target data and the transmission of the second target data do not affect each other. In order to improve the efficiency of data transmission, the transmission of the first target data and the transmission of the second target data can be carried out at the same time. Of course, in order to improve the security and stability of data transmission, only the first data channel or the second data channel can be opened, that is, only the transmission of the first target data or the transmission of the second target data can be carried out.
[0081] After obtaining the test instruction corresponding to the first communication module, determining the target data corresponding to the test instruction according to the test instruction, and judging whether there is a data channel corresponding to the target data in the test system, the test method may further include the following steps:
[0082] S4. When the data channel exists in the test system, the target data is transmitted between the first communication module and the second communication module through the data channel to test the first communication module and the second communication module.
[0083] Specifically, when the data channel exists in the test system, the first communication module and the second communication module can directly use the data channel to transmit the target data to test the first communication module and the second communication module. The data channel may include: a first data channel.
[0084] Specifically, when the first data channel exists in the test system, the first data channel is opened, so that the first communication module writes the first target data to the first data channel, and the second communication module reads the first target data in the first data channel.
[0085] The data channel may include: a second data channel. When the second data channel exists in the test system, the second data channel is opened so that the second communication module writes the second target data to the second data channel, and the first communication module reads the second target data in the second data channel.
[0086] In summary, the present application discloses a test method, a computer device, and a computer-readable storage medium. The test method includes: obtaining a test instruction corresponding to the first communication module, determining the target data corresponding to the test instruction according to the test instruction, and judging whether there is a data channel corresponding to the target data in the test system; when the data channel does not exist in the test system, creating the data channel in the test system; when the data channel is created, transmitting the target data between the first communication module and the second communication module through the data channel to test the first communication module and the second communication module. The serial port connection line of the first communication module and the second communication module is simulated through the data channel, so that the first communication module and the second communication module can transmit the target data through the data channel. Therefore, since each IoT device is based on the same serial communication protocol and WIFI module, the created data channel can be applied to the program of each IoT device, and only the serial communication protocol needs to be paid attention to, and it is not necessary to pay attention to which IoT device program the first communication module and the second communication module are. That is to say, when the target data is transmitted through the data channel, the data channel can be applied to the transmission of target data of different programs, thereby greatly reducing the development workload and reducing the joint debugging test time.
[0087] In one embodiment, the present invention provides a computer device, which may be a terminal, and the internal structure is as follows: Figure 6 As shown. The computer device includes a processor, a memory, a network interface, a display screen and an input device connected through a system bus. Among them, 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 and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external terminal through a network connection. The computer program is executed by the processor to implement the test method. The display screen of the computer device can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device can be a touch layer covering the display screen, or a key, trackball or touchpad set on the computer device housing, or an external keyboard, touchpad or mouse, etc.
[0088] Those skilled in the art will understand that Figure 6 What is shown is only a block diagram of a portion of the structure related to the solution of the present invention, and does not constitute a limitation on the computer device to which the solution of the present invention 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.
[0089] In one embodiment, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program and is applied to a test system, wherein the test system includes: a first communication module and a second communication module; when the processor executes the computer program, the following steps are implemented:
[0090] Obtaining a test instruction corresponding to the first communication module, determining target data corresponding to the test instruction according to the test instruction, and judging whether there is a data channel corresponding to the target data in the test system;
[0091] When the data channel does not exist in the test system, creating the data channel in the test system;
[0092] When the data channel is created, the target data is transmitted between the first communication module and the second communication module through the data channel to test the first communication module and the second communication module.
[0093] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored, and applied to a test system, the test system comprising: a first communication module and a second communication module; when the computer program is executed by a processor, the following steps are implemented:
[0094] Obtaining a test instruction corresponding to the first communication module, determining target data corresponding to the test instruction according to the test instruction, and judging whether there is a data channel corresponding to the target data in the test system;
[0095] When the data channel does not exist in the test system, creating the data channel in the test system;
[0096] When the data channel is created, the target data is transmitted between the first communication module and the second communication module through the data channel to test the first communication module and the second communication module.
[0097] 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 specification.
Claims
1. A testing method, It is characterized in that Applied to a test system, the test system comprises: a first communication module and a second communication module; the method comprises: Obtaining a test instruction corresponding to the first communication module, determining target data corresponding to the test instruction according to the test instruction, and judging whether there is a data channel corresponding to the target data in the test system; the data channel simulates a serial port connection line between the first communication module and the second communication module; When the data channel does not exist in the test system, creating the data channel in the test system; When the data channel is created, the target data is transmitted between the first communication module and the second communication module through the data channel to test the first communication module and the second communication module; the test is a debugging test of the serial communication protocol.
2. The test method according to claim 1, It is characterized in that The data channel includes: a first data channel; When the data channel does not exist in the test system, creating the data channel in the test system includes: When the first data channel does not exist in the test system, the first data channel is created in the test system, so that the first communication module and the second communication module are communicatively connected through the first data channel.
3. The test method according to claim 2, It is characterized in that The transmission direction of the first data channel is the direction of transmission from the first communication module to the second communication module; the target data includes: first target data, the first target data is data sent from the first communication module to the second communication module; when the data channel is created, the target data is transmitted between the first communication module and the second communication module through the data channel to test the first communication module and the second communication module, including: When the first data channel is created, the first data channel is opened so that the first communication module writes the first target data to the first data channel, and the second communication module reads the first target data in the first data channel.
4. The test method according to claim 3, It is characterized in that The first data channel is a named data channel, and the named data channel carries a channel name; when the first data channel is created, the first data channel is opened so that the first communication module writes the first target data to the first data channel, and the second communication module reads the first target data in the first data channel, including: When the first data channel is created, the channel name is obtained from the test system, the first data channel is determined according to the channel name, and the first data channel is started.
5. The testing method according to claim 2, It is characterized in that The data channel further includes: a second data channel, wherein the transmission direction of the second data channel is the direction of transmission from the second communication module to the first communication module; When the data channel does not exist in the test system, creating the data channel in the test system further includes: When the second data channel does not exist in the test system, the second data channel is created in the test system, so that the first communication module and the second communication module are communicatively connected through the second data channel.
6. The test method according to claim 5, It is characterized in that The target data further includes: second target data, the second target data being data sent by the second communication module to the first communication module; when the data channel is created, the target data is transmitted between the first communication module and the second communication module through the data channel to test the first communication module and the second communication module, and further includes: When the second data channel is created, the second data channel is opened so that the second communication module writes the second target data to the second data channel, and the first communication module reads the second target data in the second data channel.
7. The testing method according to claim 1, It is characterized in that After obtaining the test instruction corresponding to the first communication module, determining the target data corresponding to the test instruction according to the test instruction, and judging whether there is a data channel corresponding to the target data in the test system, the method further includes: When the data channel exists in the test system, the target data is transmitted between the first communication module and the second communication module through the data channel to test the first communication module and the second communication module.
8. The test method according to any one of claims 1 to 7, It is characterized in that The test system includes: a Linux system, and / or the second communication module includes: a wireless communication module or an intelligent terminal communication module, and the first communication module includes: an intelligent terminal communication module.
9. A computer device comprising a memory and a processor, wherein the memory stores a computer program. It is characterized in that When the processor executes the computer program, the steps of the testing method according to any one of claims 1 to 8 are implemented.
10. A computer-readable storage medium having a computer program stored thereon, It is characterized in that When the computer program is executed by a processor, the steps of the testing method according to any one of claims 1 to 8 are implemented.
