Method and device for realizing automatic test based on virtual serial port and storage medium

By creating a virtual serial port device and binding it to the simulated serial port of the chip software simulation platform, test instructions are automatically generated and executed, solving the problem of high human resource input in existing technologies and achieving efficient automated testing.

CN116107896BActive Publication Date: 2026-07-24NEW H3C SEMICON TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
NEW H3C SEMICON TECH CO LTD
Filing Date
2023-02-17
Publication Date
2026-07-24

Smart Images

  • Figure CN116107896B_ABST
    Figure CN116107896B_ABST
Patent Text Reader

Abstract

Embodiments of the present application provide a method and device for implementing automatic testing based on a virtual serial port and a storage medium, wherein a virtual serial port device pair is created, the virtual serial port device pair comprising a master serial port device and a slave serial port device; the slave serial port device is bound to a simulated serial port of a chip software simulation platform; a first script file is executed to generate a test instruction for the master serial port device, so that the master serial port device forwards the test instruction as a standard input stream to the slave serial port device; and the slave serial port device is used to write the test instruction into a simulated CPU of a simulated chip in the chip software simulation platform through the simulated serial port, so that the simulated CPU executes the test instruction. Compared with the prior art, the universality and portability of the chip software automatic testing process are increased, the input of human resources in chip software testing is greatly reduced, and the automation of chip software testing is realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer technology, and in particular to a method, apparatus and storage medium for automated testing based on a virtual serial port. Background Technology

[0002] Chip development requires extensive simulation verification. Commonly used simulation verification platforms include hardware simulation platforms and software simulation platforms. Although hardware simulation platforms are close to actual chips, hardware simulation equipment is expensive, has high environmental requirements, and limited resources. In contrast, software simulation platforms have almost unlimited resources and can be used immediately after installation. Therefore, early verification and testing work in the chip software development cycle is mainly carried out on software simulation platforms. Summary of the Invention

[0003] The purpose of this invention is to provide a method, apparatus, and storage medium for automated testing based on a virtual serial port, to solve the problem that existing automated chip testing still requires testers to temporarily input test commands, making it impossible to fully manage the automated testing process. The specific technical solution is as follows:

[0004] To achieve the above objectives, embodiments of the present invention provide a method for automated testing based on a virtual serial port, the method comprising:

[0005] Create a virtual serial port device pair, which includes a master serial port device and a slave serial port device;

[0006] Bind the serial port device to the simulated serial port of the chip software simulation platform;

[0007] The first script file is executed to generate test instructions for the master serial port device, so that the master serial port device forwards the test instructions as a standard input stream to the slave serial port device; the slave serial port device is used to write the test instructions into the simulated CPU of the simulated chip in the chip software simulation platform through the simulated serial port, so that the simulated CPU executes the test instructions.

[0008] Optionally, the slave serial port device is further configured to receive test feedback information output by the simulated CPU through the simulated serial port, and send the test feedback information as a standard output stream to the master serial port device;

[0009] The method further includes:

[0010] The second script file is executed to generate a text output command for the main serial port device, and the test feedback information is obtained.

[0011] Optionally, after obtaining the test feedback information, the method further includes:

[0012] The third script file is executed to automatically parse the test feedback information and obtain the parsing results.

[0013] Optionally, the chip software simulation platform is pre-started and initialized by executing a script.

[0014] To achieve the above objectives, embodiments of the present invention also provide an apparatus for automated testing based on a virtual serial port, the apparatus comprising:

[0015] A creation module is used to create virtual serial port device pairs, which include a master serial port device and a slave serial port device.

[0016] A binding module is used to bind the serial port device to the simulated serial port of the chip software simulation platform;

[0017] The first execution module is used to execute the first script file to generate test instructions for the master serial port device, so that the master serial port device forwards the test instructions as a standard input stream to the slave serial port device; the slave serial port device is used to write the test instructions into the simulated CPU of the simulated chip in the chip software simulation platform through the simulated serial port, so that the simulated CPU executes the test instructions.

[0018] Optionally, the slave serial port device is further configured to receive test feedback information output by the simulated CPU through the simulated serial port, and send the test feedback information as a standard output stream to the master serial port device;

[0019] The device further includes:

[0020] The second execution module is used to execute the second script file, generate text output commands for the main serial port device, and obtain the test feedback information.

[0021] Optionally, after obtaining the test feedback information, the device further includes:

[0022] The third execution module is used to execute the third script file and automatically parse the test feedback information to obtain the parsing results.

[0023] Optionally, the chip software simulation platform is pre-started and initialized by executing a script.

[0024] To achieve the above objectives, embodiments of the present invention also provide an electronic device, including a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus;

[0025] Memory, used to store computer programs;

[0026] When a processor executes a program stored in memory, it implements the steps of any of the above methods.

[0027] To achieve the above objectives, embodiments of the present invention also provide a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps of any of the above methods.

[0028] Beneficial effects of the embodiments of the present invention:

[0029] The present invention provides a method, apparatus, and storage medium for automated testing based on a virtual serial port. A virtual serial port device pair is created, comprising a master serial port device and a slave serial port device. The slave serial port device is bound to a simulated serial port of a chip software simulation platform. A first script file is executed to generate test instructions for the master serial port device, causing the master serial port device to forward the test instructions as a standard input stream to the slave serial port device. The slave serial port device is used to write the test instructions into the simulated CPU of the simulated chip in the chip software simulation platform through the simulated serial port, so that the simulated CPU executes the test instructions.

[0030] As can be seen, in this embodiment of the invention, a virtual serial port device pair is created, comprising a master serial port device and a slave serial port device, and the slave serial port device is bound to the simulated serial port of the chip software simulation platform. A byte stream channel exists between the master and slave serial port devices. External devices, for the standard input / standard output of the master serial port device, will forward this data as a standard input stream to the slave serial port device through the byte stream channel.

[0031] Therefore, when the master serial port device receives a test command, it will automatically forward the test command as a standard input stream to the slave serial port device. The slave serial port device is bound to the chip software simulation platform, so the test command can be written into the simulated CPU of the simulated chip in the chip software simulation platform, and the simulated CPU can then execute the test command.

[0032] Test commands for the main serial port device can be pre-written into a script file. By executing the script file, test commands can be automatically generated and sent to the main serial port device. Therefore, there is no need to input test commands on the fly during the test, which greatly reduces the human resource investment in chip software testing. Testers only need to code the script according to the rules to fully manage and run the automated test process.

[0033] Of course, implementing any product or method of the present invention does not necessarily require achieving all of the advantages described above at the same time. Attached Figure Description

[0034] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other embodiments can be obtained based on these drawings.

[0035] Figure 1 A flowchart illustrating the startup and operation of a chip software simulation platform;

[0036] Figure 2 A schematic diagram of a serial communication model simulated by a software simulation platform;

[0037] Figure 3 This is a flowchart illustrating an existing technology for automated chip testing based on a software simulation platform.

[0038] Figure 4 A flowchart illustrating a human-computer interaction scenario;

[0039] Figure 5 This is a flowchart illustrating an automated testing process based on a virtual serial port, provided by an embodiment of the present invention.

[0040] Figure 6 A schematic diagram of a virtual serial port device pair;

[0041] Figure 7 This is a schematic diagram illustrating the connection between a Sim platform and a virtual serial port device.

[0042] Figure 8 This is a schematic diagram of a structure of an automated testing device based on a virtual serial port, provided in an embodiment of the present invention.

[0043] Figure 9 This is a schematic diagram of an electronic device provided in an embodiment of the present invention. Detailed Implementation

[0044] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art based on this application are within the scope of protection of the present invention.

[0045] To facilitate understanding, we will first provide a brief introduction to the background technologies related to testing during chip development.

[0046] Because chip development requires extensive simulation and verification, simulation verification platforms provide the environment for this work. These platforms primarily consist of hardware and software simulation platforms. Hardware simulation platforms are closer to the actual chip, but they are expensive, have demanding environmental requirements, and limited resources. Software simulation platforms, on the other hand, have virtually unlimited resources and are ready to use upon installation. Therefore, early verification and testing in the chip software development cycle are mainly conducted on software simulation platforms.

[0047] Chip software simulation platforms primarily simulate the behavior of chips logically. This includes not only normal business logic simulation but also CPU simulation when simulating chip products containing a CPU (Central Processing Unit). Therefore, when performing verification work on a platform that includes CPU simulation, it is necessary to run an actual operating system on the chip software simulation platform and run microcode programs on it. Suitable operating systems include Linux or other chip manufacturer-developed operating systems.

[0048] The chip software development and testing phases require numerous repetitive startups of the simulation platform, and each restart and environment initialization of the hardware simulation platform is quite time-consuming. For example... Figure 1 As shown, Figure 1 A flowchart illustrating the startup and operation of a chip software simulation platform.

[0049] Starting and initializing the chip simulation platform are prerequisites for its operation. While starting and initializing the chip software platform environment is faster, the numerous repetitive operations are still quite manpower-intensive. Each test case requires repeated command interactions, which can be automated. In automated testing, the entire test execution process is typically coded into a script. Using managed scripts to run multiple software processes allows for the construction of a complete test environment and implementation of the entire test process. Finally, only the test results need to be viewed, eliminating the need for continuous human monitoring.

[0050] However, in automated testing, achieving automated human-computer interaction is both a key focus and a challenge in reducing labor costs. Fully automated human-computer interaction can significantly expand testing coverage. The chip software simulation platform itself is software running on a Linux operating system, and it simulates the CPU operations of the corresponding chip architecture. Therefore, it needs to bind a simulated serial port to a virtual terminal of an external operating system to input test commands and output kernel print information, thus achieving human-computer interaction.

[0051] As an example, see Figure 2 , Figure 2 This is a schematic diagram of a serial communication model simulated by a software simulation platform, such as... Figure 2 As shown, the CPU of the software simulation platform simulates serial communication according to the common serial communication interface standard and protocol, and binds to an external Linux system virtual terminal for information interaction. Here, tty can be understood as a terminal device, such as a character device, rs232 can be understood as a standard serial interface, uart16650 can be understood as a chip that supports serial port communication, kernel can be understood as the core part of most operating systems, TX represents sending data, and RX represents receiving data.

[0052] Figure 3 This is a flowchart illustrating an existing technology for automated chip testing based on a software simulation platform, such as... Figure 3 As shown, the existing automated testing process can complete the steps of starting the chip software simulation platform, initializing the chip simulation platform, connecting the simulated serial port of the software simulation platform to the virtual terminal, and loading the operating system image through a managed script. However, the CPU simulated serial port of the software simulation platform can only be bound to an existing open terminal. After loading the operating system image, it is necessary to enter commands in the virtual terminal in a human-computer interaction manner, receive feedback from the operating system, and then view the terminal printouts to complete the subsequent operation process.

[0053] If you wish to continue using scripts to implement command interaction, you can only use the Linux built-in `echo` command to redirect the output command to the corresponding virtual terminal. However, this method is equivalent to using the virtual terminal as a display terminal. Therefore, the command string is only transmitted to the corresponding virtual terminal as the standard output stream. The command will not be used as the standard input stream of the virtual terminal, and thus the command will not be transmitted to the simulated CPU of the simulated chip in the software simulation platform, and the simulated CPU will not execute the relevant command.

[0054] In summary, existing automated testing processes have reached the point where... Figure 4 In the human-computer interaction scenario shown, it is necessary to manually enter commands on the terminal, and after the operating system processes and provides feedback, the terminal printouts must be manually viewed. This turns the desired automated testing process into a semi-automated testing process.

[0055] To address the problems existing in current automated chip testing technologies based on software simulation platforms, this invention provides a method, apparatus, and storage medium for automated testing based on a virtual serial port. It can be applied to electronic devices running the Linux operating system.

[0056] like Figure 5 As shown, the method for automated testing based on a virtual serial port provided in this embodiment of the invention may include the following steps:

[0057] S501: Create a virtual serial port device pair, which includes a master serial port device and a slave serial port device.

[0058] In this embodiment of the invention, the master serial port device and the slave serial port device can be character devices.

[0059] As an example, such as Figure 6 As shown, Figure 6 This diagram illustrates a possible structure for a virtual serial port device pair, where a master serial port device and a slave serial port device constitute a virtual serial port device pair, which can also be considered a Pty (pseudoterminal). In the diagram, stdin represents standard input; as an example, a keyboard is a device used for standard input, and the data stream input from the keyboard can be understood as a standard input stream. stdout represents standard output; as an example, a screen is a device used for standard output, and the data stream output to the screen can be understood as a standard output stream.

[0060] In embodiments of the present invention, such as Figure 6 As shown, there are two byte stream channels between the master and slave serial port devices. Input / output from one device is forwarded to the other device via these byte stream channels. Specifically, the external device's standard input / output for the master serial port device is forwarded as a standard input stream to the slave serial port device via the byte stream channel between stdin and stdin, as shown in the diagram. Conversely, the slave serial port device's standard input / output is forwarded as a standard output stream to the master serial port device via the byte stream channel between stdout and stdout, as shown in the diagram.

[0061] In this embodiment of the invention, virtual serial port device pairs can be created using the Socat command line. As an example, this can be achieved using the command `socat -d -d pty,xx1pty,xx2`, where `xx1` and `xx2` represent the port numbers of the virtual serial port device pair.

[0062] In this embodiment of the invention, after creating a virtual serial port device pair, the chip software simulation platform can be started and initialized.

[0063] In one embodiment of the present invention, the chip software simulation platform is pre-started and initialized by executing a script. That is, the startup and initialization process steps of the chip software simulation platform are pre-coded into a script according to rules, and the chip software simulation platform can be started and initialized by executing the script.

[0064] In addition, the Socat command line used to create virtual serial port device pairs can also be pre-coded into a script according to rules, and the virtual serial port device pairs can be created by executing the script file.

[0065] S502: Binds the serial port device to the simulated serial port of the chip software simulation platform.

[0066] In this embodiment of the invention, the chip software simulation platform simulates the chip's CPU, which is referred to as the simulated CPU for ease of description. In order to realize the interaction with the simulated CPU, the chip software simulation platform simulates a serial port, which is referred to as the simulated serial port.

[0067] In this embodiment of the invention, binding the serial port device to the aforementioned simulated serial port can be understood as follows: the simulated CPU is connected to the serial port device through the simulated serial port, and the serial port device serves as both an input and output device for the simulated CPU. That is, for the standard input stream directed to the serial port device, the serial port device will write to the simulated CPU; and the standard output stream generated by the simulated CPU will also be sent to the serial port device.

[0068] As an example, see Figure 7 , Figure 7 This diagram illustrates a connection between a Simulator (chip software simulation platform) platform and a virtual serial port device pair. TTY0 and TTY1 serve as the slave and master serial port devices, respectively. TTY2 can be understood as an external terminal device. In this embodiment, script files encoded for automated testing can be stored in and executed on TTY2.

[0069] In this embodiment of the invention, the process steps of binding the serial port device to the simulated serial port can also be pre-coded into a script according to rules and implemented by executing the script file.

[0070] S503: Executes the first script file to generate test instructions for the master serial port device, so that the master serial port device forwards the test instructions as a standard input stream to the slave serial port device; the slave serial port device is used to write the test instructions into the simulated CPU of the simulated chip in the chip software simulation platform through the simulated serial port, so that the simulated CPU executes the test instructions.

[0071] In this embodiment of the invention, the first script file may be a part of the test script file, and the test script file can be understood as a script that includes all operation commands involved in the test process. The above steps S501-S502 can all be implemented by executing the test script file.

[0072] Specifically, before conducting chip-related tests, testers can record these commands in a computer-recognizable programming language in a test script file. This allows the computer to directly read test instructions from the test script file during subsequent automated testing, eliminating the need for testers to manually input commands.

[0073] In this embodiment of the invention, the main serial port device can be set as the specified target device in the first script file, so that after the computer executes the first script file, it generates test instructions for the main serial port device. That is, after generating the test instructions, the test instructions are directly redirected and output to the main serial port device.

[0074] like Figure 6 As shown, the external device forwards the standard input / standard output of the master serial port device as a standard input stream to the slave serial port device through the byte stream channel between stdin and stdin shown in the diagram. Therefore, the master serial port device can directly forward the above test commands as a standard input stream to the slave serial port device.

[0075] As an example, see Figure 7 After executing the test script file in the Linux operating system, a test command is generated for the master serial port device TTY1. After receiving the test command, the master serial port device TTY1 uses the test command as a standard input stream and forwards it to the slave serial port device TTY0 based on the data stream channel between TTY1 and TTY0.

[0076] In this embodiment of the invention, since the serial port device is pre-bound to the simulated serial port of the chip software simulation platform, that is, the serial port device simultaneously serves as the input and output device of the simulated CPU, when the serial port device receives a test instruction as a standard input stream, it will write the test instruction into the simulated CPU of the simulated chip in the chip software simulation platform. After receiving the test instruction, the simulated CPU will perform related operations according to the test instruction.

[0077] Continuing from the previous example, after TTY0 receives the test command sent by TTY1 through the data stream channel and as a standard input stream, it will forward the test command to the sim's simulated CPU. After receiving the test command, the simulated CPU will execute the corresponding operation according to the specific content of the test command.

[0078] The present invention provides a method for automated testing based on a virtual serial port, comprising: creating a virtual serial port device pair, including a master serial port device and a slave serial port device; binding the slave serial port device to a simulated serial port of a chip software simulation platform; executing a first script file to generate test instructions for the master serial port device, so that the master serial port device forwards the test instructions as a standard input stream to the slave serial port device; and using the slave serial port device to write the test instructions into the simulated CPU of the simulated chip in the chip software simulation platform through the simulated serial port, so that the simulated CPU executes the test instructions.

[0079] As can be seen, in this embodiment of the invention, a virtual serial port device pair is created, comprising a master serial port device and a slave serial port device, and the slave serial port device is bound to the simulated serial port of the chip software simulation platform. A byte stream channel exists between the master and slave serial port devices. External devices, for the standard input / standard output of the master serial port device, will forward this data as a standard input stream to the slave serial port device through the byte stream channel.

[0080] Therefore, when the master serial port device receives a test command, it will automatically forward the test command as a standard input stream to the slave serial port device. The slave serial port device is bound to the chip software simulation platform, so the test command can be written into the simulated CPU of the simulated chip in the chip software simulation platform, and the simulated CPU can then execute the test command.

[0081] Test commands for the main serial port device can be pre-written into a script file. By executing the script file, test commands can be automatically generated and sent to the main serial port device. Therefore, there is no need to input test commands on the fly during the test, which greatly reduces the human resource investment in chip software testing. Testers only need to code the script according to the rules to fully manage and run the automated test process.

[0082] In one embodiment of the present invention, the serial port device is further configured to receive test feedback information output by the simulated CPU through the simulated serial port, and send the test feedback information as a standard output stream to the main serial port device. The test feedback information characterizes the execution result of the simulated CPU for the test instruction. Accordingly, the method may further include: executing a second script file to generate a text output command for the main serial port device to obtain the test feedback information.

[0083] In this embodiment of the invention, the slave serial port device also functions as the output device of the simulated CPU in the chip software simulation platform. After executing the test instructions, the simulated CPU of the simulated chip in the chip software simulation platform generates corresponding test feedback information and automatically sends the test feedback information to the slave serial port device through the simulated serial port. The slave serial port device then sends the test feedback information as a standard output stream to the master serial port device.

[0084] In this embodiment of the invention, the second script file may be a part of the test script file, used to generate text output commands for the main serial port device.

[0085] As an example, the text output command can be the cat command in Linux systems, which is usually used to concatenate files and print them to standard output. In other words, it is usually used to view file contents, for example: cat [option] [File], where [option] is optional and [File] represents the file to be processed, which can be one file or multiple files.

[0086] For ease of understanding, Figure 7 For example, after the simulated CPU of the simulation chip in the Sim software simulation platform receives the test command sent from the serial port device TTY0, it will execute multiple corresponding operations according to the test command. After the multiple corresponding operations are completed, the Sim software simulation platform will generate test feedback information corresponding to each operation, that is, it will generate execution results corresponding to each operation. At this time, the simulated CPU of the simulation chip in Sim will forward this test feedback information to the serial port device TTY0. After receiving the test feedback information sent by the simulated CPU of the simulation chip in Sim, the serial port device TTY0 will send the test feedback information as a standard output stream to the master serial port device TTY1.

[0087] Continuing the previous example, after receiving the test feedback information sent from the serial port device TTY0, the main serial port device TTY1 can briefly save the test feedback information. The computer executes a preset test script file to generate a cat command (text output command) for the main serial port device TTY1. When viewing the file content corresponding to the main serial port device TTY1 with this command, the test feedback information of the simulated chip CPU in the SIM for each test command can be obtained, and thus the test feedback information can be fed back to the tester.

[0088] During chip software testing, if the amount of data being processed is too large or other network issues cause the computer to take a long time to execute test commands, testers will also need to wait a considerable amount of time after inputting test commands via the command line to view the computer's test feedback information. This invention can not only generate test commands by reading preset test scripts, but also generate commands to obtain feedback information for the test commands by reading preset test scripts. As can be seen, no human intervention is required during the entire testing process, and testers do not need to wait for the execution time of the test commands. They only need to confirm the test results after the preset test script has finished executing to complete the logic test of the entire chip.

[0089] In one embodiment of the present invention, after the step of obtaining test feedback information, the method may further include:

[0090] The third script file is executed to automatically parse the test feedback information and obtain the parsing results.

[0091] Specifically, the test feedback information directly output by the software test simulation platform is usually quite redundant and not convenient for testers to analyze directly. Therefore, the relevant process steps for automated parsing can be pre-coded into a third script file, which can also be understood as a part of the test script file.

[0092] By executing a third-party script file, the test feedback information can be automatically parsed to obtain the parsing results. The parsing results can clearly and intuitively display the final test results, and testers can intuitively confirm whether the chip's preset functions have been implemented based on the parsing results.

[0093] Corresponding to the method for automated testing based on a virtual serial port provided in the embodiments of the present invention, the embodiments of the present invention also provide an apparatus for automated testing based on a virtual serial port, see below. Figure 8 The device may include the following modules:

[0094] Create module 801, which is used to create virtual serial port device pairs, including a master serial port device and a slave serial port device;

[0095] Binding module 802 is used to bind the serial port device to the simulated serial port of the chip software simulation platform;

[0096] The first execution module 803 is used to execute the first script file and generate test instructions for the master serial port device, so that the master serial port device forwards the test instructions as a standard input stream to the slave serial port device; the slave serial port device is used to write the test instructions into the simulated CPU of the simulated chip in the chip software simulation platform through the simulated serial port, so that the simulated CPU executes the test instructions.

[0097] An apparatus for automated testing based on a virtual serial port, provided by an embodiment of the present invention, is used to create a virtual serial port device pair, comprising a master serial port device and a slave serial port device; bind the slave serial port device to a simulated serial port of a chip software simulation platform; execute a first script file to generate test instructions for the master serial port device, so that the master serial port device forwards the test instructions as a standard input stream to the slave serial port device; the slave serial port device is used to write the test instructions into the simulated CPU of the simulated chip in the chip software simulation platform through the simulated serial port, so that the simulated CPU executes the test instructions.

[0098] As can be seen, in this embodiment of the invention, a virtual serial port device pair is created, comprising a master serial port device and a slave serial port device, and the slave serial port device is bound to the simulated serial port of the chip software simulation platform. A byte stream channel exists between the master and slave serial port devices. External devices, for the standard input / standard output of the master serial port device, will forward this data as a standard input stream to the slave serial port device through the byte stream channel.

[0099] Therefore, when the master serial port device receives a test command, it will automatically forward the test command as a standard input stream to the slave serial port device. The slave serial port device is bound to the chip software simulation platform, so the test command can be written into the simulated CPU of the simulated chip in the chip software simulation platform, and the simulated CPU can then execute the test command.

[0100] Test commands for the main serial port device can be pre-written into a script file. By executing the script file, test commands can be automatically generated and sent to the main serial port device. Therefore, there is no need to input test commands on the fly during the test, which greatly reduces the human resource investment in chip software testing. Testers only need to code the script according to the rules to fully manage and run the automated test process.

[0101] In one embodiment of the present invention, the serial port device is further configured to receive test feedback information output by the simulated CPU through the simulated serial port, and send the test feedback information as a standard output stream to the main serial port device.

[0102] exist Figure 8 Based on the device shown, a second execution module may also be included.

[0103] The second execution module is used to execute the second script file, generate text output commands for the main serial port device, and obtain test feedback information.

[0104] In one embodiment of the present invention, Figure 8 Based on the device shown, a third execution module may also be included.

[0105] The third execution module is used to execute the third script file, automatically parse the test feedback information, and obtain the parsing results.

[0106] In one embodiment of the present invention, the chip software simulation platform is pre-started and initialized by executing a script.

[0107] Based on the same inventive concept, and according to the above-described method for automated testing based on a virtual serial port, this invention also provides an electronic device, such as... Figure 9As shown, it includes a processor 901, a communication interface 902, a memory 903, and a communication bus 904, wherein the processor 901, the communication interface 902, and the memory 903 communicate with each other through the communication bus 904.

[0108] Memory 903 is used to store computer programs;

[0109] When processor 901 executes a program stored in memory 903, it performs the following steps:

[0110] Create a virtual serial port device pair, which includes a master serial port device and a slave serial port device;

[0111] Bind the serial port device to the simulated serial port of the chip software simulation platform;

[0112] The first script file is executed to generate test instructions for the master serial port device, so that the master serial port device forwards the test instructions as a standard input stream to the slave serial port device; the slave serial port device is used to write the test instructions into the simulated CPU of the simulated chip in the chip software simulation platform through the simulated serial port, so that the simulated CPU executes the test instructions.

[0113] The communication bus mentioned in the above electronic devices can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. This communication bus can be divided into address bus, data bus, control bus, etc. For ease of illustration, only one thick line is used to represent it in the diagram, but this does not indicate that there is only one bus or one type of bus.

[0114] The communication interface is used for communication between the aforementioned electronic devices and other devices.

[0115] The memory may include random access memory (RAM) or non-volatile memory (NVM), such as at least one disk storage device. Optionally, the memory may also be at least one storage device located remotely from the aforementioned processor.

[0116] The processors mentioned above can be general-purpose processors, including central processing units (CPUs), network processors (NPs), etc.; they can also be digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.

[0117] Using the electronic device provided in this embodiment of the invention, a virtual serial port device pair is created, comprising a master serial port device and a slave serial port device; the slave serial port device is bound to a simulated serial port of a chip software simulation platform; a first script file is executed to generate test instructions for the master serial port device, so that the master serial port device forwards the test instructions as a standard input stream to the slave serial port device; the slave serial port device is used to write the test instructions into the simulated CPU of the simulated chip in the chip software simulation platform through the simulated serial port, so that the simulated CPU executes the test instructions.

[0118] As can be seen, in this embodiment of the invention, a virtual serial port device pair is created, comprising a master serial port device and a slave serial port device, and the slave serial port device is bound to the simulated serial port of the chip software simulation platform. A byte stream channel exists between the master and slave serial port devices. External devices, for the standard input / standard output of the master serial port device, will forward this data as a standard input stream to the slave serial port device through the byte stream channel.

[0119] Therefore, when the master serial port device receives a test command, it will automatically forward the test command as a standard input stream to the slave serial port device. The slave serial port device is bound to the chip software simulation platform, so the test command can be written into the simulated CPU of the simulated chip in the chip software simulation platform, and the simulated CPU can then execute the test command.

[0120] Test commands for the main serial port device can be pre-written into a script file. By executing the script file, test commands can be automatically generated and sent to the main serial port device. Therefore, there is no need to input test commands on the fly during the test, which greatly reduces the human resource investment in chip software testing. Testers only need to code the script according to the rules to fully manage and run the automated test process.

[0121] In another embodiment of the present invention, a computer-readable storage medium is also provided, which stores a computer program that, when executed by a processor, implements any of the steps of the above-described automated testing method based on a virtual serial port.

[0122] In another embodiment of the present invention, a computer program product containing instructions is also provided, which, when run on a computer, causes the computer to execute any of the methods for automated testing based on a virtual serial port in the above embodiments.

[0123] In the above embodiments, implementation can be achieved entirely or partially through software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented entirely or partially in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of the present invention are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid state disk (SSD)).

[0124] It should be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0125] The various embodiments in this specification are described in a related manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, the embodiments of the apparatus, electronic device, computer-readable storage medium, and computer program product for automated testing based on a virtual serial port are basically similar to the method embodiments for automated testing based on a virtual serial port, and therefore the description is relatively simple. Relevant parts can be referred to in the description of the method embodiments for automated testing based on a virtual serial port.

[0126] The above description is merely a preferred embodiment of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention are included within the scope of protection of the present invention.

Claims

1. A method for automated testing based on a virtual serial port, characterized in that, The method is applied to an external terminal device, and the method includes: A virtual serial port device pair is created, comprising a master serial port device and a slave serial port device; the external terminal device, the master serial port device, and the slave serial port device are independent of each other; a byte stream channel exists between the master serial port device and the slave serial port device, and the external terminal device forwards the standard input / standard output of the master serial port device to the slave serial port device as a standard input stream through the byte stream channel; The slave serial device is bound to the simulated serial port of the chip software simulation platform; wherein, the steps of creating a virtual serial port device pair and binding the slave serial device to the simulated serial port of the chip software simulation platform are both implemented by executing a test script file; The first script file is executed to generate test instructions for the master serial port device, so that the master serial port device forwards the test instructions as a standard input stream to the slave serial port device; the slave serial port device is used to write the test instructions into the simulated CPU of the simulated chip in the chip software simulation platform through the simulated serial port, so that the simulated CPU executes the test instructions.

2. The method according to claim 1, characterized in that, The slave serial port device is also used to receive test feedback information output by the simulated CPU through the simulated serial port, and send the test feedback information as a standard output stream to the master serial port device; The method further includes: The second script file is executed to generate a text output command for the main serial port device, and the test feedback information is obtained.

3. The method according to claim 2, characterized in that, After obtaining the test feedback information, the method further includes: The third script file is executed to automatically parse the test feedback information and obtain the parsing results.

4. The method according to claim 1, characterized in that, The chip software simulation platform is pre-started and initialized by executing a script.

5. A device for automated testing based on a virtual serial port, characterized in that, The device is used in an external terminal device, and the device includes: A creation module is used to create a virtual serial port device pair, which includes a master serial port device and a slave serial port device. The external terminal device, the master serial port device, and the slave serial port device are independent of each other. There is a byte stream channel between the master serial port device and the slave serial port device. The external terminal device forwards the standard input / standard output of the master serial port device to the slave serial port device as a standard input stream through the byte stream channel. A binding module is used to bind the slave serial port device to the simulated serial port of the chip software simulation platform; wherein, the steps of creating a virtual serial port device pair and binding the slave serial port device to the simulated serial port of the chip software simulation platform are both implemented by executing a test script file; The first execution module is used to execute the first script file to generate test instructions for the master serial port device, so that the master serial port device forwards the test instructions as a standard input stream to the slave serial port device; the slave serial port device is used to write the test instructions into the simulated CPU of the simulated chip in the chip software simulation platform through the simulated serial port, so that the simulated CPU executes the test instructions.

6. The apparatus according to claim 5, characterized in that, The slave serial port device is also used to receive test feedback information output by the simulated CPU through the simulated serial port, and send the test feedback information as a standard output stream to the master serial port device; The device further includes: The second execution module is used to execute the second script file, generate text output commands for the main serial port device, and obtain the test feedback information.

7. The apparatus according to claim 6, characterized in that, After obtaining the test feedback information, the device further includes: The third execution module is used to execute the third script file and automatically parse the test feedback information to obtain the parsing results.

8. The apparatus according to claim 5, characterized in that, The chip software simulation platform is pre-started and initialized by executing a script.

9. An electronic device, characterized in that, It includes a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus; Memory, used to store computer programs; A processor, when executing a program stored in memory, implements the steps of the method described in any one of claims 1-4.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the steps of the method described in any one of claims 1-4.