CN115237807B - Program testing method, device and readable storage medium - Google Patents
Program testing method, device and readable storage medium Download PDFInfo
- Publication number
- CN115237807B CN115237807B CN202210964356.1A CN202210964356A CN115237807B CN 115237807 B CN115237807 B CN 115237807B CN 202210964356 A CN202210964356 A CN 202210964356A CN 115237807 B CN115237807 B CN 115237807B
- Authority
- CN
- China
- Prior art keywords
- program
- information
- target
- hardware
- test
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
- 238000012360 testing method Methods 0.000 claims abstract description 211
- 230000002093 peripheral effect Effects 0.000 claims abstract description 60
- 238000000034 method Methods 0.000 claims abstract description 33
- 230000004044 response Effects 0.000 claims description 8
- 230000000007 visual effect Effects 0.000 claims description 8
- 238000004590 computer program Methods 0.000 claims description 6
- 238000011161 development Methods 0.000 abstract description 5
- 238000004891 communication Methods 0.000 description 12
- 238000012545 processing Methods 0.000 description 10
- 238000005516 engineering process Methods 0.000 description 5
- 238000010586 diagram Methods 0.000 description 4
- 230000003287 optical effect Effects 0.000 description 4
- 230000005236 sound signal Effects 0.000 description 4
- 230000015556 catabolic process Effects 0.000 description 3
- 230000001133 acceleration Effects 0.000 description 2
- 230000009471 action Effects 0.000 description 2
- 230000006978 adaptation Effects 0.000 description 2
- 230000009286 beneficial effect Effects 0.000 description 2
- 230000008859 change Effects 0.000 description 2
- 238000001514 detection method Methods 0.000 description 2
- 230000003993 interaction Effects 0.000 description 2
- 238000007726 management method Methods 0.000 description 2
- 230000004048 modification Effects 0.000 description 2
- 238000012986 modification Methods 0.000 description 2
- 230000008569 process Effects 0.000 description 2
- 238000003491 array Methods 0.000 description 1
- 238000013500 data storage Methods 0.000 description 1
- 230000006870 function Effects 0.000 description 1
- 238000003384 imaging method Methods 0.000 description 1
- 239000004973 liquid crystal related substance Substances 0.000 description 1
- 238000004088 simulation Methods 0.000 description 1
- 230000003068 static effect Effects 0.000 description 1
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Prevention of errors by analysis, debugging or testing of software
- G06F11/3668—Testing of software
- G06F11/3672—Test management
- G06F11/3684—Test management for test design, e.g. generating new test cases
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/22—Detection or location of defective computer hardware by testing during standby operation or during idle time, e.g. start-up testing
- G06F11/26—Functional testing
- G06F11/261—Functional testing by simulating additional hardware, e.g. fault simulation
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Prevention of errors by analysis, debugging or testing of software
- G06F11/3668—Testing of software
- G06F11/3672—Test management
- G06F11/3688—Test management for test execution, e.g. scheduling of test suites
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02D—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
- Y02D10/00—Energy efficient computing, e.g. low power processors, power management or thermal management
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Computer Hardware Design (AREA)
- General Engineering & Computer Science (AREA)
- Quality & Reliability (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Debugging And Monitoring (AREA)
Abstract
The present disclosure relates to a program testing method, apparatus, and readable storage medium, the program testing method including: and acquiring a program file and a script file, wherein the script file comprises hardware information, peripheral information and associated information corresponding to target hardware, generating a target simulator according to the script file, loading the program file through the target simulator to run the program, and inputting the test information into the target simulator running the program to obtain an actual test result. According to the hardware information, the peripheral information and the associated information corresponding to the target hardware, the target simulator corresponding to the target hardware can be quickly generated, and then the program file is tested through the target simulator, so that the real use environment of the program when the program is applied to the target hardware can be simulated as much as possible. The method does not need a real hardware environment, saves development cost, avoids inaccurate test results caused by hardware damage, simultaneously avoids the influence of burning time on test efficiency, and improves test efficiency.
Description
Technical Field
The disclosure relates to the technical field of testing, and in particular relates to a program testing method, a program testing device and a readable storage medium.
Background
In the related art, when developing a corresponding program for an MCU (Microcontroller Unit, micro control unit), it is necessary to use a development board and a real object such as a burner to deploy the program into the development board for testing, and the hardware is damaged due to electrostatic breakdown or other reasons, which may cause inaccurate testing results. Moreover, the burning requires a certain time, which affects the test efficiency. Meanwhile, the test environment with the participation of entity hardware is not beneficial to automatic test, and the aim of realizing the automatic test also needs to additionally increase customized developed automatic test equipment, thereby generating higher cost. The program is directly compiled into a version of a PC (Personal Computer ) to be tested in the PC, so that the test result is inconsistent with the running of the MCU, and the accuracy of the test result is affected.
Disclosure of Invention
In order to overcome the problems in the related art, the present disclosure provides a program testing method, apparatus and readable storage medium, which can quickly generate a target simulator according to hardware information, peripheral information and associated information corresponding to target hardware, further test a program file through the target simulator to obtain an actual testing result, and simulate a real use environment of a program as much as possible, thereby obtaining a more accurate testing result, avoiding the influence of burning time on testing efficiency, being more convenient for deploying automatic testing, improving testing efficiency and reducing testing cost.
According to a first aspect of the embodiments of the present disclosure, there is provided a program testing method, the program being applied to target hardware, the program testing method including:
acquiring a program file and a script file, wherein the script file comprises hardware information, peripheral information and associated information corresponding to the target hardware;
generating a target simulator according to the script file;
loading the program file through the target simulator so as to run the program;
acquiring test information;
and inputting the test information into a target simulator running the program to obtain an actual test result.
Optionally, the generating a target simulator according to the script file includes:
generating a first sub-simulator according to the hardware information;
generating a second sub-simulator according to the peripheral information;
and connecting the first sub-simulator with the second sub-simulator according to the association information to obtain the target simulator.
Optionally, the target simulator comprises a graphical user interface, wherein the graphical user interface is used for displaying the running result of the program;
the obtaining test information includes:
generating the test information according to a trigger operation instruction of a user for the graphical user interface;
after inputting the test information into a target simulator running the program to obtain an actual test result, the method further comprises:
and displaying the actual test result through the graphical user interface.
Optionally, the acquiring test information includes:
acquiring a test case, wherein the test case comprises the test information and a target test result;
acquiring the test information from the test case;
after the test information is input into the target simulator running the program to obtain the actual test result, the method further comprises:
and obtaining a test report according to the target test result and the actual test result.
Optionally, before the program file and the script file are acquired, the method further comprises:
acquiring a program code corresponding to the program;
and compiling the program code to obtain the program file.
Optionally, before compiling the program code to obtain the program file, the method further includes:
determining whether the program code meets a preset writing rule;
the compiling the program code to obtain the program file includes:
and compiling the program code to obtain the program file when the program code meets the preset writing rule.
Optionally, the script file further includes debug port information;
after loading the program file by the target simulator, the method further comprises:
creating a debugging port according to the debugging port information;
and connecting the target simulator with a debugger through the debugging port.
According to a second aspect of embodiments of the present disclosure, there is provided a program testing apparatus, comprising:
the first acquisition module is configured to acquire a program file and a script file, wherein the script file comprises hardware information, peripheral information and associated information corresponding to the target hardware;
the generation module is configured to generate a target simulator according to the script file;
a loading module configured to load the program file through the target simulator to run the program;
the second acquisition module is configured to acquire test information;
and the obtaining module is configured to input the test information into a target simulator running the program to obtain an actual test result.
Optionally, the generating module includes:
a first generation sub-module configured to generate a first sub-simulator from the hardware information;
a second generation sub-module configured to generate a second sub-simulator according to the peripheral information;
and the third generation sub-module is configured to connect the first sub-simulator with the second sub-simulator according to the association information so as to obtain the target simulator.
Optionally, the target simulator comprises a graphical user interface, wherein the graphical user interface is used for displaying the running result of the program;
the second acquisition module includes:
the first acquisition sub-module is configured to generate the test information according to a trigger operation instruction of a user for the graphical user interface;
the apparatus further comprises:
and the display module is configured to display the actual test result through the graphical user interface.
Optionally, the second acquisition module includes:
the second acquisition submodule is configured to acquire a test case, wherein the test case comprises the test information and a target test result;
the third acquisition submodule is configured to acquire the test information from the test case;
the apparatus further comprises:
and the second obtaining submodule is configured to obtain a test report according to the target test result and the actual test result.
Optionally, the apparatus further comprises:
a third acquisition module configured to acquire program codes corresponding to the program;
and the compiling module is configured to compile the program codes to obtain the program files.
Optionally, the apparatus further comprises:
a determining module configured to determine whether the program code satisfies a preset writing rule;
the compiling module comprises:
and the compiling sub-module is configured to compile the program code to obtain the program file when the program code meets a preset compiling rule.
Optionally, the script file further includes debug port information;
the apparatus further comprises:
the creation module is configured to create a debugging port according to the debugging port information;
and the connection module is configured to connect the target simulator with a debugger through the debugging port.
According to a third aspect of the embodiments of the present disclosure, there is provided a program testing apparatus including:
a processor;
a memory for storing processor-executable instructions;
wherein the processor is configured to implement the steps of the program testing method provided by an aspect of the present disclosure.
According to a fourth aspect of embodiments of the present disclosure, there is provided a computer readable storage medium having stored thereon computer program instructions which, when executed by a processor, implement the steps of the program test method provided by an aspect of the present disclosure.
The technical scheme provided by the embodiment of the disclosure can comprise the following beneficial effects:
the method comprises the steps of obtaining a program file and a script file, wherein the script file comprises hardware information, peripheral information and associated information corresponding to target hardware, generating a target simulator according to the script file, loading the program file through the target simulator to run the program, obtaining test information, and inputting the test information into the target simulator running the program to obtain an actual test result.
According to the hardware information, the peripheral information and the associated information corresponding to the target hardware, the target simulator corresponding to the target hardware can be quickly generated, and then the program file is tested through the target simulator, so that the real use environment of the program when the program is applied to the target hardware can be simulated as much as possible, and a more accurate test result is obtained. And avoid the use of physical hardware such as development board and writer to avoid the hardware to lead to the test result inaccurate because of electrostatic breakdown or other reasons damages, improved the accuracy of test result, and avoided the influence of burn time to test efficiency, more convenient deployment automation test has improved test efficiency, has reduced test cost.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the disclosure and together with the description, serve to explain the principles of the disclosure.
FIG. 1 is a flowchart illustrating a program test method according to an exemplary embodiment.
FIG. 2 is a flow chart illustrating a method of target simulator generation, according to an example embodiment.
FIG. 3 is a flowchart illustrating another program test method according to an exemplary embodiment.
FIG. 4 is a flowchart illustrating yet another program test method according to an exemplary embodiment.
FIG. 5 is a block diagram of a program testing apparatus, according to an example embodiment.
Fig. 6 is a block diagram illustrating an apparatus for program testing according to an exemplary embodiment.
Detailed Description
Reference will now be made in detail to exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, the same numbers in different drawings refer to the same or similar elements, unless otherwise indicated. The implementations described in the following exemplary examples are not representative of all implementations consistent with the present disclosure. Rather, they are merely examples of apparatus and methods consistent with some aspects of the present disclosure as detailed in the accompanying claims.
Fig. 1 is a flowchart illustrating a program testing method according to an exemplary embodiment, in which the program is applied to a target file, and the program testing method may be used in a terminal as shown in fig. 1, including the following steps.
In step S101, a program file and a script file are acquired, the script file including hardware information, peripheral information, and associated information corresponding to target hardware.
The target hardware may be an MCU, a CPU (Central Processing Unit ), an MPU (Microprocessor Unit, microprocessor), and an SoC (System on Chip), and the program is applied to the target hardware, that is, the program is developed for the target hardware.
The program may be a visual APP application developed by a developer for the target hardware, or may be a non-visual logic handler applied inside the target hardware. The obtained program file is the file which corresponds to the program and can be used for the execution of the target hardware.
The script file may be a file input by a user or a file imported by the user, and may be used to generate a target simulator corresponding to the target hardware, for simulating the entire running environment of the program when running in the target hardware. The script file may include hardware information, peripheral information, and associated information corresponding to the target hardware. Taking the target hardware as an MCU as an example, the hardware information can be an MCU instruction set, the peripheral can be a driving chip, a communication controller, a display screen and the like, the peripheral information can be a peripheral instruction set corresponding to each peripheral, and the related information can be connection information between the hardware and each peripheral and the like.
In step S102, a target simulator is generated from the script file.
In this embodiment, a target simulator corresponding to the target hardware may be generated according to the script file, and since the target simulator is generated not only through the hardware information corresponding to the target hardware, but also according to the peripheral information corresponding to the target hardware and the associated information, the target simulator may simulate the real use environment of the program when applied to the target hardware as much as possible, thereby obtaining a more accurate test result.
In step S103, a program file is loaded by the target simulator to run the program.
In this embodiment, the program file is loaded by the target simulator so that the program can run on the target simulator.
In step S104, test information is acquired.
In this embodiment, the test information is trigger information for a function of the program, and is used for testing the program.
In step S105, the test information is input to the target simulator running the program, and an actual test result is obtained.
In this embodiment, the test information is input into the target simulator running the program, and the test information triggers the program, so that the program responds to the test information to obtain a corresponding response result, and the response result can be determined as an actual test result.
In this embodiment, according to the hardware information, the peripheral information and the associated information corresponding to the target hardware, the target simulator corresponding to the target hardware can be quickly generated, and then the program file is tested by the target simulator, so that the real use environment of the program when the program is applied to the target hardware can be simulated as much as possible, and a more accurate test result can be obtained. And avoid the use of physical hardware such as development board and writer to avoid the hardware to lead to the test result inaccurate because of electrostatic breakdown or other reasons damages, improved the accuracy of test result, and avoided the influence of burn time to test efficiency, more convenient deployment automation test has improved test efficiency, has reduced test cost.
FIG. 2 is a flow chart illustrating a method of generating a target simulator according to an exemplary embodiment, as shown in FIG. 2, in one possible implementation, generating a target simulator from a script file may include the following steps.
In step S201, a first sub-simulator is generated from the hardware information.
In this embodiment, the target simulator may be composed of a plurality of sub-simulators, where according to the hardware information, a first sub-simulator corresponding to the hardware may be generated, and taking the target hardware as the MCU as an example, the first sub-simulator may simulate a plurality of systems that compose the MCU.
In step S202, a second sub-simulator is generated from the peripheral information.
In this embodiment, a plurality of second sub-simulators corresponding to a plurality of peripheral devices may be generated according to peripheral device information, and the peripheral devices may be a driving chip, a communication controller, a display screen, and the like. The peripheral information may be a peripheral instruction set corresponding to each peripheral, and one second sub-simulator may be generated according to the peripheral instruction set corresponding to each peripheral so as to simulate a plurality of peripherals corresponding to the target hardware through the plurality of second sub-simulators.
In step S203, the first sub-simulator and the second sub-simulator are connected according to the association information to obtain the target simulator.
In this embodiment, the association information may be connection information between the hardware and each peripheral device, and the connection information may represent a connection manner, for example, the connection manner may be an IO port connection, a UART connection, an SPI connection, or an IIC connection. The first sub-simulator and the second sub-simulator can be connected through corresponding connection modes to obtain the target simulator, so that the obtained target simulator can simulate the real use environment of the program when the program is applied to target hardware as much as possible, and a more accurate test result is obtained.
In one possible implementation, the target simulators may be multiple, and the method for generating the target simulators according to the script file may be:
and generating a plurality of interconnected target simulators according to the hardware information, the peripheral information and the associated information.
In this embodiment, the hardware information in the script file may include information corresponding to a plurality of hardware, the peripheral information may include peripheral information corresponding to a plurality of hardware, and the association information may include connection information between a plurality of hardware, or may include association information between hardware and a peripheral. And generating a plurality of target simulators through the hardware information, the peripheral information and the association information, and connecting the plurality of target simulators according to the association information among the plurality of hardware to obtain a plurality of target simulators which are connected with each other. So as to carry out system test on the program through a plurality of interconnected target simulators, so as to carry out more detailed test on the program and obtain more accurate test results. The connection information between the plurality of hardware may include an IO port connection, an ethernet connection, and a CAN connection, that is, the plurality of target simulators may be connected through the IO port connection, the ethernet connection, and the CAN connection.
In one possible implementation, the target simulator includes a graphical user interface for presenting the results of the program's execution. At this time, the method for acquiring the test information may be: and generating test information according to a trigger operation instruction of a user for the graphical user interface.
Since the target simulator simulates a peripheral, the target simulator may provide a graphical user interface that may present the results of the running of the program. That is, the user can directly visually operate the program on the target simulator. At this time, the user can visually run the program directly on the target simulator to test the program. The test information can be generated according to a trigger operation instruction of a user aiming at the graphical user interface, and the program can respond to the trigger operation instruction to obtain an actual test result. And then displaying the actual test result through a graphical user interface of the target simulator so that a user can judge whether the actual test result is consistent with the target test result. If the codes are consistent, the program can be confirmed to have no problem, and if the codes are inconsistent, the program is confirmed to have the problem, and the codes corresponding to the program need to be modified. The target test result is the correct response result of the program to the test information. For example, the user may click a control on the graphical user interface to see if the program can correctly respond to the instruction corresponding to the control, and feedback the corresponding target test result.
In the embodiment, the visual display of the program during running can be performed through the graphical user interface, so that a user can test the program through specific operation, the test process and the test result are more visual, the user can test the program more conveniently, and the test is more comprehensive.
In a possible implementation manner, the program may also be tested by a test case method, for example, a method for obtaining test information is: and acquiring a test case, wherein the test case comprises test information and a target test result, and the test information is acquired from the test case.
In this embodiment, the test case may include test information and a target test result, where the test information is used to test the program, and the target test result is a correct response result corresponding to the test information. The test information in the test case can be directly obtained to test the program.
After the actual test result is obtained, a corresponding test report may be obtained based on the actual test result and the target test result, and the test report may include the test location and the test result. For example, the test report may be that there is a problem at the test location or that there is no problem at the test location.
In a possible embodiment, before the program file and the script file are acquired, the method further includes: program codes corresponding to the program are obtained, and the program codes are compiled to obtain a program file.
In this embodiment, the first program code is input by the user, and then the program code may be compiled so that a program file executable in the operating environment of the target hardware can be compiled.
In a possible embodiment, before compiling the program code to obtain the program file, the method further comprises: and determining whether the program code meets preset writing rules.
And compiling the program code to obtain a program file when the program code meets the preset writing rule.
In this embodiment, the basic detection, such as style detection, may be performed on the program code first, so as to eliminate the basic problem of the program code first. The method comprises the steps of presetting preset writing rules corresponding to target hardware, detecting the program codes according to the preset writing rules, and compiling the program codes to obtain executable program files when the program codes meet the preset writing rules. When the program code does not meet the preset writing rule, outputting the program code segments which do not meet the rule to a user so that the user can modify the program code segments which do not meet the rule.
In one possible embodiment, the script file may further include debug port information, and after loading the program file by the target simulator, the method further comprises: creating a debugging port according to the debugging port information; the target simulator is connected with the debugger through the debugging port.
In this embodiment, a debug port may be generated based on the debug port information, and the target simulator and the debugger may be connected through the debug port. The debugger may be a virtual debugger, and may be generated through debugger information. The debugger can complete the debugging actions such as setting breakpoints, checking events happening in the program, dynamically changing the execution environment of the program and the like. Through the debugger, debugging modification can be performed on the program file so that the program can run smoothly in the target simulator.
FIG. 3 is a flow chart illustrating another program testing method according to an exemplary embodiment, as shown in FIG. 3, which in one possible implementation includes the steps of:
in step S301, a program code and a script file are acquired.
In step S302, it is determined whether or not to perform the code style check, if yes, step S303 is performed, and if no, step S304 is performed. Whether to execute the code style check can be judged according to information input by a user, whether to execute the code style check can also be judged according to preset information, and the preset judgment information can be to execute the code style check or not.
In step S303, a code style check is performed.
In step S304, it is determined whether or not to compile, if so, step S305 is executed, and if not, step S312 is executed. Wherein, it can judge whether to execute compiling according to the information input by the user.
In step S305, the compiler compiles the program code into an executable program file.
In step S306, it is determined whether or not the operation is simulated, if so, step S307 is executed, and if not, step S312 is executed. Wherein, whether to simulate operation can be judged according to the information input by the user.
In step S307, a target simulator is generated from the script file. A target simulator may be generated for the executor from the script file.
In step S308, the target simulator loads the executable file.
In step S309, it is determined whether or not to debug, if yes, step S310 is executed, and if no, step S311 is executed. Wherein, whether to debug can be judged according to the information input by the user.
In step S310, a debug interface is created, and a simulator and a debugger are connected through the debug interface.
In step S311, the test information input by the user is acquired through the graphical user interface or the command line, and the test result is acquired according to the test information.
In step S312, a test result is output. The test result may be an actual test result obtained by the program in response to the trigger operation instruction, wherein if not compiled, the output test result may be untested, and if not simulated, the output test result may be untested.
In the embodiment, the visual display of the program during running can be performed through the graphical user interface, so that a user can test the program through specific operation, the test process and the test result are more visual, the user can test the program more conveniently, and the test is more comprehensive.
FIG. 4 is a flow chart illustrating yet another program testing method according to an exemplary embodiment, as shown in FIG. 4, which in one possible implementation includes the steps of:
in step S401, a program code and a script file are acquired.
In step S402, a test case is acquired.
In step S403, it is determined whether or not to perform the code style check, if so, step S404 is performed, and if not, step S405 is performed.
In step S404, a code style check is performed.
In step S405, it is determined whether or not to compile, if so, step S406 is executed, and if not, step S413 is executed.
In step S406, the compiler compiles the program code into an executable program file.
In step S407, it is determined whether or not the simulation operation is performed, if yes, step S408 is performed, and if no, step S413 is performed.
In step S408, a target simulator is generated from the script file.
In step S409, the target simulator loads the executable file.
In step S410, the input of the simulator is automatically controlled according to the test case.
In step S411, the output of the simulator is checked and compared with the test case.
In step S412, it is determined whether the test case has been executed, if so, step S413 is executed, and if not, step S410 is returned.
In step S413, a test report is output.
In this embodiment, the test case, the test program, and the output test report may be automatically tested to obtain the test result.
FIG. 5 is a block diagram of a program testing apparatus, according to an example embodiment. Referring to fig. 5, the apparatus 500 includes a first acquisition module 501, a generation module 502, a loading module 503, a second acquisition module 504, and an acquisition module 505.
The first obtaining module 501 is configured to obtain a program file and a script file, where the script file includes hardware information, peripheral information and associated information corresponding to the target hardware;
the generating module 502 is configured to generate a target simulator according to the script file;
the loading module 503 is configured to load the program file through the target simulator to run the program;
the second obtaining module 504 is configured to obtain test information;
the obtaining module 505 is configured to input the test information into a target simulator running the program, so as to obtain an actual test result.
Optionally, the generating module 502 includes:
a first generation sub-module configured to generate a first sub-simulator from the hardware information;
a second generation sub-module configured to generate a second sub-simulator according to the peripheral information;
and the third generation sub-module is configured to connect the first sub-simulator with the second sub-simulator according to the association information so as to obtain the target simulator.
Optionally, the target simulator comprises a graphical user interface, wherein the graphical user interface is used for displaying the running result of the program;
the second obtaining module 504 includes:
the first acquisition sub-module is configured to generate the test information according to a trigger operation instruction of a user for the graphical user interface;
the apparatus further comprises:
and the display module is configured to display the actual test result through the graphical user interface.
Optionally, the second obtaining module 504 includes:
the second acquisition submodule is configured to acquire a test case, wherein the test case comprises the test information and a target test result;
the third acquisition submodule is configured to acquire the test information from the test case;
the apparatus further comprises:
and the second obtaining submodule is configured to obtain a test report according to the target test result and the actual test result.
Optionally, the apparatus further comprises:
a third acquisition module configured to acquire program codes corresponding to the program;
and the compiling module is configured to compile the program codes to obtain the program files.
Optionally, the apparatus further comprises:
a determining module configured to determine whether the program code satisfies a preset writing rule;
the compiling module comprises:
and the compiling sub-module is configured to compile the program code to obtain the program file when the program code meets a preset compiling rule.
Optionally, the script file further includes debug port information;
the apparatus further comprises:
the creation module is configured to create a debugging port according to the debugging port information;
and the connection module is configured to connect the target simulator with a debugger through the debugging port.
The specific manner in which the various modules perform the operations in the apparatus of the above embodiments have been described in detail in connection with the embodiments of the method, and will not be described in detail herein.
The present disclosure also provides a computer readable storage medium having stored thereon computer program instructions which, when executed by a processor, implement the steps of the program test method provided by the present disclosure.
Fig. 6 is a block diagram illustrating an apparatus for program testing according to an exemplary embodiment. For example, apparatus 600 may be a mobile phone, computer, digital broadcast terminal, messaging device, game console, tablet device, medical device, exercise device, personal digital assistant, or the like.
Referring to fig. 6, apparatus 600 may include one or more of the following components: a processing component 602, a memory 604, a power component 606, a multimedia component 608, an audio component 610, an input/output interface 612, a sensor component 614, and a communication component 616.
The processing component 602 generally controls overall operation of the apparatus 600, such as operations associated with display, telephone calls, data communications, camera operations, and recording operations. The processing component 602 may include one or more processors 620 to execute instructions to perform all or part of the steps of the methods described above. Further, the processing component 602 can include one or more modules that facilitate interaction between the processing component 602 and other components. For example, the processing component 602 may include a multimedia module to facilitate interaction between the multimedia component 608 and the processing component 602.
The memory 604 is configured to store various types of data to support operations at the apparatus 600. Examples of such data include instructions for any application or method operating on the apparatus 600, contact data, phonebook data, messages, pictures, videos, and the like. The memory 604 may be implemented by any type or combination of volatile or nonvolatile memory devices such as Static Random Access Memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic or optical disk.
The power supply component 606 provides power to the various components of the device 600. The power supply components 606 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power for the apparatus 600.
The multimedia component 608 includes a screen between the device 600 and the user that provides an output interface. In some embodiments, the screen may include a Liquid Crystal Display (LCD) and a Touch Panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from a user. The touch panel includes one or more touch sensors to sense touches, swipes, and gestures on the touch panel. The touch sensor may sense not only the boundary of a touch or slide action, but also the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 608 includes a front camera and/or a rear camera. The front camera and/or the rear camera may receive external multimedia data when the apparatus 600 is in an operational mode, such as a photographing mode or a video mode. Each front camera and rear camera may be a fixed optical lens system or have focal length and optical zoom capabilities.
The audio component 610 is configured to output and/or input audio signals. For example, the audio component 610 includes a Microphone (MIC) configured to receive external audio signals when the apparatus 600 is in an operational mode, such as a call mode, a recording mode, and a voice recognition mode. The received audio signals may be further stored in the memory 604 or transmitted via the communication component 616. In some embodiments, audio component 610 further includes a speaker for outputting audio signals.
The input/output interface 612 provides an interface between the processing component 602 and peripheral interface modules, which may be a keyboard, click wheel, buttons, etc. These buttons may include, but are not limited to: homepage button, volume button, start button, and lock button.
The sensor assembly 614 includes one or more sensors for providing status assessment of various aspects of the apparatus 600. For example, the sensor assembly 614 may detect the open/closed state of the device 600, the relative positioning of the components, such as the display and keypad of the device 600, the sensor assembly 614 may also detect a change in position of the device 600 or a component of the device 600, the presence or absence of user contact with the device 600, the orientation or acceleration/deceleration of the device 600, and a change in temperature of the device 600. The sensor assembly 614 may include a proximity sensor configured to detect the presence of nearby objects in the absence of any physical contact. The sensor assembly 614 may also include a light sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 614 may also include an acceleration sensor, a gyroscopic sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
The communication component 616 is configured to facilitate communication between the apparatus 600 and other devices in a wired or wireless manner. The device 600 may access a wireless network based on a communication standard, such as WiFi,2G or 3G, or a combination thereof. In one exemplary embodiment, the communication component 616 receives broadcast signals or broadcast-related information from an external broadcast management system via a broadcast channel. In one exemplary embodiment, the communication component 616 further includes a Near Field Communication (NFC) module to facilitate short range communications. For example, the NFC module may be implemented based on Radio Frequency Identification (RFID) technology, infrared data association (IrDA) technology, ultra Wideband (UWB) technology, bluetooth (BT) technology, and other technologies.
In an exemplary embodiment, the apparatus 600 may be implemented by one or more Application Specific Integrated Circuits (ASICs), digital Signal Processors (DSPs), digital Signal Processing Devices (DSPDs), programmable Logic Devices (PLDs), field Programmable Gate Arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic elements for executing the methods described above.
In an exemplary embodiment, a non-transitory computer-readable storage medium is also provided, such as memory 604, including instructions executable by processor 620 of apparatus 600 to perform the above-described method. For example, the non-transitory computer readable storage medium may be ROM, random Access Memory (RAM), CD-ROM, magnetic tape, floppy disk, optical data storage device, etc.
In another exemplary embodiment, a computer program product is also provided, which comprises a computer program executable by a programmable apparatus, the computer program having code portions for performing the program test method described above when being executed by the programmable apparatus.
Other embodiments of the disclosure will be apparent to those skilled in the art from consideration of the specification and practice of the disclosure. This application is intended to cover any adaptations, uses, or adaptations of the disclosure following, in general, the principles of the disclosure and including such departures from the present disclosure as come within known or customary practice within the art to which the disclosure pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the disclosure being indicated by the following claims.
It is to be understood that the present disclosure is not limited to the precise arrangements and instrumentalities shown in the drawings, and that various modifications and changes may be effected without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.
Claims (9)
1. A program test method, wherein the program is applied to target hardware, the program test method comprising:
acquiring a program file and a script file, wherein the script file comprises hardware information, peripheral information and associated information corresponding to the target hardware;
generating a target simulator according to the script file, wherein the target simulator comprises a graphical user interface, the graphical user interface is provided by a peripheral simulated by the target simulator, and the graphical user interface is used for operating the program on the target simulator in a visual way by a user and displaying the running result of the program;
loading the program file through the target simulator so as to run the program;
obtaining test information, the obtaining test information comprising: generating test information according to a trigger operation instruction of a user for the graphical user interface;
inputting the test information into a target simulator running the program so that the program responds to the trigger operation instruction to obtain an actual test result;
displaying the actual test result through the graphical user interface, wherein the actual test result is used for a user to judge whether the actual test result is consistent with a target test result, and the target test result is a correct response result of the program to the test information;
the method comprises the steps of generating a script file, wherein the hardware information comprises information corresponding to a plurality of pieces of hardware, the peripheral information comprises peripheral information corresponding to the plurality of pieces of hardware, the associated information comprises connection information between the plurality of pieces of hardware and associated information between the hardware and the peripheral, and the generating a target simulator according to the script file comprises the following steps:
generating a plurality of target simulators through the hardware information, the peripheral information and the association information between the hardware and the peripheral;
and connecting a plurality of target simulators according to the connection information among the plurality of hardware to obtain a plurality of target simulators which are connected with each other.
2. The program testing method of claim 1, wherein,
the generating a target simulator according to the script file further comprises:
generating a first sub-simulator according to the hardware information;
generating a second sub-simulator according to the peripheral information;
and connecting the first sub-simulator with the second sub-simulator according to the association information to obtain the target simulator.
3. The program testing method of claim 1, wherein,
the obtaining test information further includes:
acquiring a test case, wherein the test case comprises the test information and a target test result;
acquiring the test information from the test case;
after the test information is input into the target simulator running the program to obtain an actual test result, the method further comprises:
and obtaining a test report according to the target test result and the actual test result.
4. A program testing method according to any one of claim 1 to 3, wherein,
before the program file and the script file are acquired, the method further comprises:
acquiring a program code corresponding to the program;
and compiling the program code to obtain the program file.
5. The program testing method of claim 4, wherein,
before compiling the program code to obtain the program file, the method further includes:
determining whether the program code meets a preset writing rule;
the compiling the program code to obtain the program file includes:
and compiling the program code to obtain the program file when the program code meets the preset writing rule.
6. A program testing method according to any one of claim 1 to 3, wherein,
the script file also comprises debugging port information;
after loading the program file by the target simulator, the method further comprises:
creating a debugging port according to the debugging port information;
and connecting the target simulator with a debugger through the debugging port.
7. A program testing apparatus, comprising:
the first acquisition module is configured to acquire a program file and a script file, wherein the script file comprises hardware information, peripheral information and associated information corresponding to target hardware;
a generation module configured to generate a target simulator from the script file, the target simulator including a graphical user interface provided by a peripheral emulated by the target simulator, the graphical user interface for a user to visually operate the program on the target simulator, and for presenting a result of the running of the program;
a loading module configured to load the program file through the target simulator to run the program;
the second acquisition module is configured to acquire test information, and the acquisition of the test information comprises: generating test information according to a trigger operation instruction of a user for the graphical user interface;
the obtaining module is configured to input the test information into a target simulator running the program so that the program responds to the trigger operation instruction to obtain an actual test result;
the display module is configured to display the actual test result through the graphical user interface, wherein the actual test result is used for a user to judge whether the actual test result is consistent with a target test result, and the target test result is a correct response result of the program to the test information;
the method comprises the steps of generating a script file, wherein the hardware information comprises information corresponding to a plurality of pieces of hardware, the peripheral information comprises peripheral information corresponding to the plurality of pieces of hardware, the associated information comprises connection information between the plurality of pieces of hardware and associated information between the hardware and the peripheral, and the generating a target simulator according to the script file comprises the following steps:
generating a plurality of target simulators through the hardware information, the peripheral information and the association information between the hardware and the peripheral;
and connecting a plurality of target simulators according to the connection information among the plurality of hardware to obtain a plurality of target simulators which are connected with each other.
8. A program testing apparatus, comprising:
a processor;
a memory for storing processor-executable instructions;
wherein the processor is configured to:
acquiring a program file and a script file, wherein the script file comprises hardware information, peripheral information and associated information corresponding to target hardware;
generating a target simulator according to the script file, wherein the target simulator comprises a graphical user interface, the graphical user interface is provided by a peripheral simulated by the target simulator, and the graphical user interface is used for operating the program on the target simulator in a visual way by a user and displaying the running result of the program;
loading the program file through the target simulator so as to run the program;
obtaining test information, the obtaining test information comprising: generating test information according to a trigger operation instruction of a user for the graphical user interface;
inputting the test information into a target simulator running the program to obtain an actual test result;
displaying the actual test result through the graphical user interface, wherein the actual test result is used for a user to judge whether the actual test result is consistent with a target test result, and the target test result is a correct response result of the program to the test information;
the method comprises the steps of generating a script file, wherein the hardware information comprises information corresponding to a plurality of pieces of hardware, the peripheral information comprises peripheral information corresponding to the plurality of pieces of hardware, the associated information comprises connection information between the plurality of pieces of hardware and associated information between the hardware and the peripheral, and the generating a target simulator according to the script file comprises the following steps:
generating a plurality of target simulators through the hardware information, the peripheral information and the association information between the hardware and the peripheral;
and connecting a plurality of target simulators according to the connection information among the plurality of hardware to obtain a plurality of target simulators which are connected with each other.
9. A computer readable storage medium having stored thereon computer program instructions, which when executed by a processor, implement the steps of the method of any of claims 1 to 6.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202210964356.1A CN115237807B (en) | 2022-08-11 | 2022-08-11 | Program testing method, device and readable storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202210964356.1A CN115237807B (en) | 2022-08-11 | 2022-08-11 | Program testing method, device and readable storage medium |
Publications (2)
Publication Number | Publication Date |
---|---|
CN115237807A CN115237807A (en) | 2022-10-25 |
CN115237807B true CN115237807B (en) | 2024-02-06 |
Family
ID=83678674
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202210964356.1A Active CN115237807B (en) | 2022-08-11 | 2022-08-11 | Program testing method, device and readable storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN115237807B (en) |
Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1581098A (en) * | 2004-05-20 | 2005-02-16 | 北京大学 | Simulator structure method |
CN110365641A (en) * | 2019-05-31 | 2019-10-22 | 阿里巴巴集团控股有限公司 | Cross-site scripting attack leak detection method, equipment and computer-readable medium |
CN111200535A (en) * | 2018-11-16 | 2020-05-26 | 阿里巴巴集团控股有限公司 | Simulation system and method for equipment |
Family Cites Families (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20120185820A1 (en) * | 2011-01-19 | 2012-07-19 | Suresh Kadiyala | Tool generator |
-
2022
- 2022-08-11 CN CN202210964356.1A patent/CN115237807B/en active Active
Patent Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1581098A (en) * | 2004-05-20 | 2005-02-16 | 北京大学 | Simulator structure method |
CN111200535A (en) * | 2018-11-16 | 2020-05-26 | 阿里巴巴集团控股有限公司 | Simulation system and method for equipment |
CN110365641A (en) * | 2019-05-31 | 2019-10-22 | 阿里巴巴集团控股有限公司 | Cross-site scripting attack leak detection method, equipment and computer-readable medium |
Non-Patent Citations (2)
Title |
---|
ArmSim全系统模拟器的设计与实现;邓立波;龙翔;高小鹏;;微计算机信息(02);第9-11、52页 * |
邓立波 ; 龙翔 ; 高小鹏 ; .ArmSim全系统模拟器的设计与实现.微计算机信息.2008,(02),第9-11、52页. * |
Also Published As
Publication number | Publication date |
---|---|
CN115237807A (en) | 2022-10-25 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN106354628A (en) | Payment app test method and device thereof | |
CN107656872B (en) | Software testing method, device, equipment and computer storage medium | |
CN113377370B (en) | File processing method and device, electronic equipment and storage medium | |
CN109344051B (en) | Data processing method and device, electronic equipment and storage medium | |
CN112363950B (en) | Application program debugging method and device | |
CN110287106B (en) | Method and device for debugging shader code, electronic equipment and storage medium | |
CN111209195B (en) | Method and device for generating test case | |
CN112214405A (en) | Software testing method and device, electronic equipment and readable storage medium | |
CN110781080A (en) | Program debugging method and device and storage medium | |
CN109426504B (en) | Program processing method, program processing device, electronic device and storage medium | |
CN106533841A (en) | Method, apparatus and system for testing protocol consistency of user identification module cards | |
CN115237807B (en) | Program testing method, device and readable storage medium | |
CN110851370B (en) | Program testing method and device and storage medium | |
CN112416751B (en) | Processing method, device and storage medium for interface automation testing | |
CN106021004B (en) | Customer behavior modeling unit, test macro and test method | |
CN106293683A (en) | The Compilation Method of a kind of project and device | |
CN115543831A (en) | Test script generation method, device, equipment and storage medium | |
CN111290944B (en) | Script generation method, script generation device and storage medium | |
CN112817868B (en) | Information processing method, device and medium | |
CN119377030B (en) | System-on-chip verification method, device, electronic device and readable storage medium | |
CN112835757A (en) | Screen testing method and device | |
CN113590470B (en) | Software debugging method and device, electronic equipment and storage medium | |
CN114594949B (en) | Interface simulation method, device and integrated development environment system | |
CN118069538B (en) | User interface testing method and device, electronic equipment and medium | |
CN116450534B (en) | Method, device, equipment and medium for generating mobile terminal application program |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |