Testing method and system for single chip microcomputer program

By providing a microcontroller program testing method suitable for multiple microcontroller types, the difficulty of unit testing of microcontroller software is solved by using pre-generated test cases and test programs, and a simple and easy-to-use testing process is realized, reducing editing workload and improving testing efficiency.

CN112256559BActive Publication Date: 2025-02-28QINGDAO HAIER AIR CONDITIONER GENERAL CORP LTD +1
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202010990058.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-09-18
Publication Date
2025-02-28
Estimated Expiration
2040-09-18

AI Technical Summary

Technical Problem

Unit testing of microcontroller software is very difficult due to differences in manufacturers and kernel types. The existing tools and methods are mainly used to test portable programs on the PC side, and there is a lack of testing methods suitable for multiple microcontroller types.

Method used

It provides a test method for microcontroller programs, including obtaining pre-generated test cases and testing programs generated based on test cases, obtaining a microcontroller with a test program written in it, and sending a test case to the microcontroller through the upper computer, and determining whether the logic of the test program is correct based on the data returned by the microcontroller.

Benefits of technology

It makes microcontroller program testing simple and easy, reduces the editing workload of test cases, and improves testing efficiency and accuracy by automatically generating overview test cases.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure 00000000_0000_ABST
    Figure 00000000_0000_ABST
Patent Text Reader

Abstract

The present invention provides a testing method and system for a single-chip microcomputer program. The testing method for the single-chip microcomputer program includes: obtaining a pre-generated test case and a test program generated according to the test case; obtaining a single-chip microcomputer with the test program burned in; and sending the test case to the single-chip microcomputer through a host computer, and judging whether the logic of the test program is correct according to the data returned by the single-chip microcomputer. The scheme of the present invention makes the single-chip microcomputer program testing simple and easy by providing a program testing method and an independent testing system platform applicable to a variety of single-chip microcomputer types; only the input parameter name, parameter value range, and parameter step size need to be edited to automatically generate a coverage test case, thereby reducing the workload of editing the test case and making it easy to understand the role of the test case.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of single chip microcomputer technology, and in particular to a single chip microcomputer program testing method and system. Background Art

[0002] Due to the differences and number of MCU manufacturers and core types, there are many compiler models, which makes unit testing of MCU software very difficult. Currently, there are few tools and methods specifically for testing MCU software, and most of them are for testing portable programs on the PC side. Summary of the invention

[0003] An object of the present invention is to provide a program testing method applicable to various types of single-chip microcomputers, so that the single-chip microcomputer program testing is simple and easy.

[0004] A further object of the present invention is to reduce the workload of editing test cases.

[0005] In particular, the present invention provides a testing method for a single-chip microcomputer program, comprising: obtaining a pre-generated test case and a test program generated according to the test case; obtaining a single-chip microcomputer with the test program burned into it; and sending the test case to the single-chip microcomputer via a host computer, and determining whether the logic of the test program is correct based on the data returned by the single-chip microcomputer.

[0006] Optionally, the step of obtaining a pre-generated test case includes: obtaining a first test case after editing and management, and generating a second test case based on the first test case, wherein the first test case includes one or more first input parameters and one or more first control parameters, and the second test case includes a set of fixed second input parameters and a set of fixed second control parameters.

[0007] Optionally, the first input parameter and the second input parameter include descriptions of parameter type, parameter range, and parameter change step, and the first comparison parameter and the second comparison parameter include descriptions of type and return value range.

[0008] Optionally, the step of generating a test program according to the test case includes: generating a header file of the test program according to the test case.

[0009] Optionally, the step of obtaining the single-chip microcomputer with the test program burned in includes: generating the test program according to a compilation system dedicated to the single-chip microcomputer; and burning the test program into the single-chip microcomputer by manual burning or online software upgrade method.

[0010] Optionally, the method for testing the single-chip microcomputer program further includes: collecting test results through port signals of the single-chip microcomputer to determine whether the logic of the test program is correct.

[0011] Optionally, after the step of determining whether the logic of the test program is correct, the method further includes: outputting the test result of the test program.

[0012] According to another aspect of the present invention, there is also provided a single chip computer program testing system, comprising:

[0013] The first acquisition module is configured to acquire pre-generated test cases and test programs generated according to the test cases; the second acquisition module is configured to acquire the microcontroller with the test program burned in it; and the determination module is configured to send the test cases to the microcontroller through the host computer, and determine whether the logic of the test program is correct based on the data returned by the microcontroller.

[0014] Optionally, the first acquisition module includes: a use case acquisition module, configured to acquire the first use case after editing and management, and generate a second use case based on the first use case, wherein the first use case includes one or more first input parameters and one or more first control parameters, and the second use case includes a set of fixed second input parameters and a set of fixed second control parameters; and a program acquisition module, configured to generate a header file of a test program based on the test case.

[0015] Optionally, the second acquisition module is further configured to: generate a test program according to a compiler system dedicated to the single-chip microcomputer; and burn the test program into the single-chip microcomputer by manual burning or online software upgrade method.

[0016] The present invention provides a method and system for testing a single-chip microcomputer program, which obtains pre-generated test cases and test programs generated according to the test cases; obtains a single-chip microcomputer with the test program burned in; and sends the test cases to the single-chip microcomputer through a host computer, and determines whether the logic of the test program is correct according to the data returned by the single-chip microcomputer. By providing a program testing method applicable to multiple single-chip microcomputer types and an independent testing system platform, single-chip microcomputer program testing is simple and easy.

[0017] Furthermore, the testing method and system of the single-chip microcomputer program of the present invention, the step of obtaining a pre-generated test case includes: obtaining a first test case after editing and management, and generating a second test case based on the first test case, wherein the first test case includes one or more first input parameters and one or more first comparison parameters, and the second test case includes a set of fixed second input parameters and a set of fixed second comparison parameters. The first input parameter and the second input parameter include a description of the parameter type, parameter range, and parameter change step size, and the first comparison parameter and the second comparison parameter include a description of the type and return value range. Only the input parameter name, parameter value range, and parameter step size need to be edited to automatically generate coverage test cases, which reduces the editing workload of the test cases and makes it easy to understand the role of the test cases.

[0018] Based on the following detailed description of specific embodiments of the present invention in conjunction with the accompanying drawings, those skilled in the art will become more aware of the above and other objects, advantages and features of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] Hereinafter, some specific embodiments of the present invention will be described in detail in an exemplary and non-limiting manner with reference to the accompanying drawings. The same reference numerals in the accompanying drawings indicate the same or similar components or parts. It should be understood by those skilled in the art that these drawings are not necessarily drawn to scale. In the accompanying drawings:

[0020] Figure 1 is a schematic diagram of a method for testing a single chip computer program according to an embodiment of the present invention;

[0021] Figure 2 is a detailed flow chart of a method for testing a single chip computer program according to an embodiment of the present invention;

[0022] Figure 3 is a schematic block diagram of a single-chip computer program testing system according to an embodiment of the present invention; and

[0023] Figure 4 is a schematic block diagram of a single-chip computer program testing system according to another embodiment of the present invention. DETAILED DESCRIPTION

[0024] This embodiment first provides a method for testing a single-chip microcomputer program, which is applicable to a variety of single-chip microcomputer types and makes single-chip microcomputer program testing simple and easy. Figure 1 FIG. 1 is a schematic diagram of a method for testing a single-chip microcomputer program according to an embodiment of the present invention. Figure 1 As shown, the test method of the microcontroller program can perform the following steps:

[0025] Step S102, obtaining a pre-generated test case and a test program generated according to the test case;

[0026] Step S104, obtaining a single chip microcomputer with a test program burned into it;

[0027] Step S106, sending the test case to the single-chip microcomputer through the host computer, and judging whether the logic of the test program is correct according to the data returned by the single-chip microcomputer.

[0028] In the above steps, the step of obtaining the pre-generated test case in step S102 may include: obtaining the first test case after editing and management, and generating the second test case according to the first test case, wherein the first test case includes one or more first input parameters and one or more first comparison parameters, and the second test case includes a set of fixed second input parameters and a set of fixed second comparison parameters. Among them, the first input parameter and the second input parameter include descriptions of parameter type, parameter range, and parameter change step, and the first comparison parameter and the second comparison parameter include descriptions of type and return value range. In fact, it can be understood that the first input parameter is a conceptual parameter and the second input parameter is a specific parameter.

[0029] The step of generating a test program according to the test case in step S102 may include: generating a header file of the test program according to the test case. The step of obtaining a microcontroller with the test program burned in step S104 may include: generating the test program according to a compiler system dedicated to the microcontroller; and burning the test program into the microcontroller by manual burning or online software upgrade.

[0030] In addition, after the test case is sent to the single-chip microcomputer by the host computer in step S106, it can be determined whether the logic of the test program is correct according to the data returned by the single-chip microcomputer. In some other embodiments, the test result can also be collected by the port signal of the single-chip microcomputer to determine whether the logic of the test program is correct. And, after the step of determining whether the logic of the test program is correct, it can also include: outputting the test result of the test program.

[0031] The test method of the single-chip microcomputer program of this embodiment obtains a pre-generated test case and a test program generated according to the test case; obtains a single-chip microcomputer with the test program burned in; and sends the test case to the single-chip microcomputer through a host computer, and determines whether the logic of the test program is correct according to the data returned by the single-chip microcomputer. By providing a program testing method applicable to multiple single-chip microcomputer types and an independent test system platform, single-chip microcomputer program testing is simple and easy.

[0032] In some optional embodiments, higher technical effects can be achieved by further optimizing and configuring the above steps. The following describes in detail the testing method of the microcontroller program of this embodiment in combination with the introduction of an optional execution process of this embodiment. This embodiment is only an example of the execution process. During the specific implementation, the execution order and operating conditions of some steps can be modified according to the specific implementation requirements. Figure 2 Detailed flow chart of a method for testing a single-chip microcomputer program according to an embodiment of the present invention. The method for testing a single-chip microcomputer program comprises the following steps:

[0033] Step S202, obtaining the first use case after editing and management, and generating a second use case according to the first use case;

[0034] Step S204, generating a header file of the test program according to the test case;

[0035] Step S206, generating a test program according to a compiler system dedicated to the single-chip microcomputer;

[0036] Step S208, burning the test program into the single chip microcomputer by manual burning or online software upgrade method;

[0037] Step S210, sending the test case to the single-chip microcomputer through the host computer, and judging whether the logic of the test program is correct according to the data returned by the single-chip microcomputer;

[0038] Step S212, output the test result of the test program.

[0039] In the above steps, the first use case in step S202 includes one or more first input parameters and one or more first comparison parameters, and the second use case includes a set of fixed second input parameters and a set of fixed second comparison parameters. The first input parameter and the second input parameter include descriptions of parameter type, parameter range, and parameter change step, and the first comparison parameter and the second comparison parameter include descriptions of type and return value range. The second use case is a coverage test case.

[0040] In step S210, the host computer sends the test case to the MCU, and determines whether the logic of the test program is correct based on the data returned by the MCU. In a specific embodiment, for example, the function of the test program is to obtain the maximum value of a and b, and a and b are unsigned integers. Then, by testing a=(0...255), b=(0...255), a full coverage result can be obtained. If each group is correct, it is determined that the program logic is correct).

[0041] The test method of the single-chip microcomputer program of this embodiment obtains the first use case after editing and management, and generates the second use case based on the first use case, wherein the first use case includes one or more first input parameters and one or more first comparison parameters, and the second use case includes a set of fixed second input parameters and a set of fixed second comparison parameters. The first input parameter and the second input parameter include a description of the parameter type, parameter range, and parameter change step, and the first comparison parameter and the second comparison parameter include a description of the type and return value range. Only the input parameter name, parameter value range, and parameter step need to be edited to automatically generate coverage test cases, which reduces the editing workload of the test cases and makes it easy to understand the role of the test cases.

[0042] This embodiment also provides a test system for a single-chip microcomputer program. Figure 31 is a schematic block diagram of a single-chip microcomputer program testing system 100 according to an embodiment of the present invention. The single-chip microcomputer program testing system 100 may generally include: a first acquisition module 110 , a second acquisition module 120 and a determination module 130 .

[0043] Among them, the first acquisition module 110 can be configured to obtain pre-generated test cases and test programs generated according to the test cases. The test cases may include a first test case and a second test case, the first test case includes one or more first input parameters and one or more first control parameters, and the second test case includes a set of fixed second input parameters and a set of fixed second control parameters. Among them, the first input parameter and the second input parameter include descriptions of parameter type, parameter range, and parameter change step, and the first control parameter and the second control parameter include descriptions of type and return value range. The second test case is a coverage test case.

[0044] The second acquisition module 120 can be configured to acquire a single-chip microcomputer with a test program burned in it. The determination module 130 can be configured to send a test case to the single-chip microcomputer through the host computer, and determine whether the logic of the test program is correct according to the data returned by the single-chip microcomputer.

[0045] Figure 4 FIG. 1 is a schematic block diagram of a single chip computer program testing system 100 according to another embodiment of the present invention. Based on the previous embodiment, the first acquisition module 110 may include: a use case acquisition module 111 and a program acquisition module 112 .

[0046] The use case acquisition module 111 can be configured to acquire the first use case after editing and management, and generate a second use case based on the first use case, wherein the first use case includes one or more first input parameters and one or more first comparison parameters, and the second use case includes a set of fixed second input parameters and a set of fixed second comparison parameters. The program acquisition module 112 can be configured to generate a header file of a test program based on the test case.

[0047] The second acquisition module 120 in this embodiment can also be configured to: generate a test program according to a compiler system dedicated to the single-chip microcomputer; and burn the test program into the single-chip microcomputer by manual burning or online software upgrade method.

[0048] The single-chip microcomputer program test system 100 of this embodiment can be applied to various single-chip microcomputer types by providing an independent test system platform, making single-chip microcomputer program testing simple and easy. In addition, only the input parameter name, parameter value range, and parameter step size need to be edited to automatically generate coverage test cases, which reduces the workload of editing test cases and makes it easy to understand the role of test cases.

[0049] By burning the test program into the single-chip microcomputer, for example, by manually burning or upgrading the software online, and then giving the input parameters through the host computer, and then running the test program, obtaining the control parameters, and returning them to the host computer, the host computer makes a judgment based on the preset results, and obtains the coverage test results by changing different input parameters, thereby determining whether the logic of the test program is correct. It should be noted that the host computer is the PC terminal mentioned above. Through the design management of test cases, for example, detailed cases are automatically generated through phased cases; the test system 100 is used to access the code under test, without changing the code under test, and without the need for stubbing or editing input and output conversion operations.

[0050] In some other embodiments, the single-chip program test system 100 may have a test case editing module, a test case generation module, a test program editing module, a test program generation module, a test program burning module, a test program communication module, a test management module, a single-chip test program running system, a single-chip test platform driver module, a test result verification module, a test report output module, etc. Among them, the single-chip test program running system and the single-chip test platform driver module run on the single-chip end, and other modules run on the PC end.

[0051] Specifically, the test case editing module is used to edit and manage test cases. There are multiple formats, including test case type 1: including one or more first input parameters and one or more first comparison parameters. The first input parameter contains the description of parameter type, parameter range, and parameter change step. The first comparison parameter has the description of type and return value range. Test case type 2: each test case contains a set of fixed second input parameters and a set of fixed second comparison parameters. The test case generation module generates a coverage test case type 2 based on the test case type 1 to ensure the reliability of the test.

[0052] The test program editing module edits the test program, which is the call and header file editing of the program under test. The test program generation module generates the test program header file according to the test case. The test program burning module burns the generated burning program into the target board chip. The burning program is compiled and generated using the compiler system dedicated to the microcontroller. The test program communication module controls and manages the communication with the target board, controls the sending of test cases and the receiving of test results. The test management module manages the test process and displays the test results and test progress of the case. The microcontroller test program running system is a system for managing test programs on the microcontroller. The microcontroller test platform driver module is used to support the microcontroller test program running system for the drivers of different microcontrollers. The test result verification module verifies whether each test result received is in compliance. The test report output module is used to output the summary of the test content at the end of the test.

[0053] At this point, those skilled in the art should recognize that, although multiple exemplary embodiments of the present invention have been shown and described in detail herein, many other variations or modifications that conform to the principles of the present invention can still be directly determined or derived based on the content disclosed in the present invention without departing from the spirit and scope of the present invention. Therefore, the scope of the present invention should be understood and recognized as covering all these other variations or modifications.

Claims

1. A method for testing a single-chip microcomputer program, comprising: Obtaining pre-generated test cases and test programs generated according to the test cases; Obtaining a single-chip microcomputer with the test program burned into it; as well as The test case is sent to the single-chip microcomputer through the host computer, and the logic of the test program is determined to be correct according to the data returned by the single-chip microcomputer. The step of obtaining the pre-generated test case includes: obtaining a first test case after editing and management, and generating a second test case according to the first test case, wherein the first test case includes one or more first input parameters and one or more first comparison parameters, and the second test case includes a set of fixed second input parameters and a set of fixed second comparison parameters; The first input parameter and the second input parameter include descriptions of parameter type, parameter range, and parameter change step size, and the first comparison parameter and the second comparison parameter include descriptions of type and return value range. The step of generating a test program according to the test case includes: generating a header file of the test program according to the test case; The step of obtaining the single-chip microcomputer with the test program burned in comprises: generating the test program according to a compiler system dedicated to the single-chip microcomputer; and burning the test program into the single-chip microcomputer by manual burning or online software upgrade method. The first input parameter is a conceptual parameter, the second input parameter is a specific parameter, and the second use case is a coverage test case.

2. The method for testing a single chip microcomputer program according to claim 1, further comprising: The test results are collected through the port signal of the single chip microcomputer to determine whether the logic of the test program is correct.

3. The method for testing a single chip computer program according to claim 1 or 2, wherein after the step of determining whether the logic of the test program is correct, the method further comprises: Output the test results of the test program.

4. A single-chip microcomputer program testing system, comprising: A first acquisition module is configured to acquire a pre-generated test case and a test program generated according to the test case; A second acquisition module is configured to acquire a single chip microcomputer with the test program burned into it; as well as A determination module is configured to send the test case to the single-chip microcomputer through the host computer, and determine whether the logic of the test program is correct according to the data returned by the single-chip microcomputer, The first acquisition module includes: a use case acquisition module configured to acquire a first use case after editing and management, and generate a second use case according to the first use case, wherein the first use case includes one or more first input parameters and one or more first comparison parameters, and the second use case includes a set of fixed second input parameters and a set of fixed second comparison parameters; The first input parameter and the second input parameter include descriptions of parameter type, parameter range, and parameter change step size, and the first comparison parameter and the second comparison parameter include descriptions of type and return value range. The first acquisition module includes: a program acquisition module configured to generate a header file of the test program according to the test case; The second acquisition module is further configured to: generate the test program according to the compiler system dedicated to the single-chip microcomputer; and burn the test program into the single-chip microcomputer by manual burning or online software upgrade method, The first input parameter is a conceptual parameter, the second input parameter is a specific parameter, and the second use case is a coverage test case.

Citation Information

Patent Citations

  • Test case generation method and device

    CN106294138A

  • Test case management method and device and electronic equipment

    CN109710532A

  • Automatic upgrading test device and system applied to locomotive

    CN110687888A