Test method and operation system, continuous integration platform, equipment, medium, program product and vehicle
By deploying relevant code and scripts on the continuous integration platform, automated testing of business code of the vehicle-mounted embedded real-time operating system is solved, and the problem of low testing efficiency in the existing technology is improved.
Patent Information
- Application Number
- CN202510059708.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-15
- Publication Date
- 2025-05-09
AI Technical Summary
The lack of effective unit testing methods suitable for vehicle-mounted embedded real-time operating systems in the prior art leads to low development and testing efficiency.
Provides a testing method to implement automated testing through a continuous integration platform deploying business code, unit test code, test cases, unit test framework, on-board operating system, compiled scripts and test scripts. The method includes running a compiled script to generate an executable file, and testing the business code through the test script, generating test results and unit test reports.
Through automated testing, all-weather testing of business code on the on-board operating system is achieved, which improves development and testing efficiency, reduces the compilation process and times, and improves the work efficiency of testers.
Smart Images

Figure CN119961165A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the automotive field, and specifically to a testing method and operating system, a continuous integration platform, equipment, media, program products, and vehicles. Background Art
[0002] Currently, there are few unit testing methods applicable to the field of vehicle-mounted embedded real-time operating systems, or they are not perfect, and embedded software is updated quickly. Therefore, a testing method is needed to improve the development and testing efficiency of vehicle-mounted embedded real-time operating systems. Summary of the invention
[0003] The present application provides a testing method and operating system, continuous integration platform, equipment, medium, program product, and vehicle, which are beneficial to improving the development and testing efficiency of business codes applied to vehicle-mounted operating systems.
[0004] In the first aspect, an embodiment of the present application provides a testing method, which is applied to a continuous integration platform, on which business code, unit test code, test cases, unit test framework, vehicle operating system, compiled scripts and test scripts are deployed; the method comprises: running the compiled script to obtain an executable file; wherein the executable file comprises: the compiled business code, the compiled unit test code, the compiled unit test framework, the compiled test cases and the compiled vehicle operating system; the business code is the code to be tested; the business code is applied to the vehicle operating system; the unit test code is used to verify the correctness of the business code; the unit test code is written according to the unit test framework; running the test script so that the test script tests the business code by running the executable file to obtain a test result; wherein the test script is written according to the test case, and the test case is used to indicate the purpose and steps of the test.
[0005] It can be understood that in the test method provided in the embodiment of the present application, for the business code applied to the vehicle operating system, during the test process, the business code, the unit test code corresponding to the business code, the test case, the unit test framework, the vehicle operating system applied by the business code, the compilation script and the test script are deployed on the continuous integration platform, and the compilation script is run by the continuous integration platform to obtain an executable file; the continuous integration platform also runs the test script so that the test script tests the business code by running the executable file to obtain the test result. In this way, since the vehicle operating system is widely used and the software iteration and update on the vehicle operating system is fast, the business code on the vehicle operating system is tested through the continuous integration platform, and the business code on the vehicle operating system is tested around the clock, thereby improving the development and testing efficiency of the business code applied to the vehicle operating system.
[0006] In some embodiments, the compilation script includes a first parameter and a second parameter; accordingly, the running of the compilation script also includes: running the compilation script to generate a coverage file; wherein the coverage file is generated by at least running the first parameter in the compilation script; the executable file is compiled based on at least the first parameter and the second parameter; the running of the test script so that the test script runs the executable file also includes: running the test script so that the test script runs the executable file to generate a test coverage file; the method also includes: generating a unit test report based on the coverage file and the test coverage file.
[0007] It can be understood that in the test method provided in the embodiment of the present application, the first parameter and the second parameter are added to the compilation script, the compilation script with the first parameter and the second parameter added is run to obtain an executable file and generate a coverage file; the test script is run so that the test script runs the executable file to generate a test coverage file; and a unit test report is generated based on the coverage file and the test coverage file. In this way, by providing a unit test report, it is beneficial for developers and testers to understand the test status of the business code, and then it is beneficial for developers to quickly locate, analyze and solve problems, and realize rapid iteration of business code, that is, to improve the development and testing efficiency of business code applied to the vehicle operating system.
[0008] In some embodiments, the unit testing framework, the business code, the unit testing code and the test cases deployed on the continuous integration platform are integrated on the vehicle operating system; running the compilation script to obtain an executable file includes: running the compilation script to compile the vehicle operating system to obtain an executable file.
[0009] It can be understood that in the test method provided in the embodiment of the present application, since the unit test framework, business code, unit test code and test cases are all integrated on the vehicle operating system, there is no need to compile the business code, unit test code, unit test framework, test cases and vehicle operating system separately, and then link the compiled executable files into one executable file. Instead, the vehicle operating system can be compiled once to obtain the executable file, thereby improving the work efficiency of testers by reducing the compilation process and number of times.
[0010] In some embodiments, generating a unit test report based on the coverage file and the test coverage file includes: comparing and analyzing the coverage file and the test coverage file through a code coverage reporting tool to obtain unit test data; converting the format of the unit test data to obtain a unit test report; wherein the unit test report includes: the function coverage of the business code, the line coverage of the business code, the branch coverage of the business code, and the pass status of the test case.
[0011] It can be understood that in the test method provided in the embodiment of the present application, the coverage file and the test coverage file are compared and analyzed by the code coverage report tool to obtain unit test data; the format of the unit test data is converted to obtain a unit test report; wherein the unit test report includes: function coverage of the business code, line coverage of the business code, branch coverage of the business code, and the pass status of the test cases. In this way, it is beneficial for developers and testers to understand the test status of the business code through the unit test report, which in turn helps developers to quickly locate, analyze and solve problems, and realize rapid iteration of business code, that is, to improve the development and testing efficiency of business code applied to the vehicle operating system.
[0012] In some embodiments, when the unit test report meets the conditions, the vehicle-mounted operating system, the business code and the compiled script are deployed on a continuous deployment platform for user use.
[0013] It can be understood that in the testing method provided in the embodiment of the present application, since the continuous deployment platform is a tool that automatically deploys the software to the production environment after the software is built and tested, when the unit test report meets the conditions, the vehicle-mounted operating system, business code and compiled script are used to be deployed on the continuous deployment platform for user use, which is beneficial to improve the deployment speed of the vehicle-mounted operating system, business code and compiled script, and reduce deployment risks.
[0014] In the second aspect, an embodiment of the present application provides a vehicle-mounted operating system, characterized in that the kernel of the vehicle-mounted operating system includes: a unit testing framework, a unit testing code, a test case and a business code; wherein the business code is the code to be tested; the unit testing code is used to verify the correctness of the business code; the unit testing code is written according to the unit testing framework; the test case is used to indicate the purpose and steps of the test; the vehicle-mounted operating system is used to be deployed on a continuous integration platform so that the continuous integration platform executes the method described in the first aspect.
[0015] It can be understood that the kernel of the vehicle operating system provided in the embodiment of the present application includes a unit test framework, unit test code, test cases and business code, and the vehicle operating system including the unit test framework, unit test code, test cases and business code is deployed on the continuous integration platform. In this way, the continuous integration platform does not need to compile the unit test framework, unit test code, test cases and business code vehicle operating system separately, and then link the compiled executable files into one executable file, but compiles the vehicle operating system once to obtain the executable file, thereby reducing the compilation process and number of times, and improving the work efficiency of testers.
[0016] In the third aspect, an embodiment of the present application provides a continuous integration platform, characterized in that business code, unit test code, test cases, unit test framework, vehicle-mounted operating system, compiled scripts and test scripts are deployed on the continuous integration platform; the continuous integration platform comprises: a first running module, configured to run the compiled script to obtain an executable file; wherein the executable file comprises: the compiled business code, the compiled unit test code, the compiled unit test framework, the compiled test cases and the compiled vehicle-mounted operating system; the business code is the code to be tested; the business code is applied to the vehicle-mounted operating system; the unit test code is used to verify the correctness of the business code; the unit test code is written according to the unit test framework; a second running module, configured to run the test script, so that the test script tests the business code by running the executable file to obtain a test result; wherein the test script is written according to the test case, and the test case is used to indicate the purpose and steps of the test.
[0017] In a fourth aspect, an embodiment of the present application provides an electronic device, comprising a memory and a processor, wherein the memory stores a computer program executable on the processor, and when the processor executes the program, the method described in the first aspect is implemented.
[0018] In a fifth aspect, an embodiment of the present application provides a computer-readable storage medium having a computer program stored thereon, which implements the method described in the first aspect when executed by a processor.
[0019] In a sixth aspect, an embodiment of the present application provides a computer program product, including a computer program or instructions, which, when executed by a processor, implements the method described in the first aspect.
[0020] In a seventh aspect, an embodiment of the present application provides a vehicle, comprising a continuous integration platform, wherein the continuous integration platform is used to implement the method described in the first aspect. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] Figure 1 A schematic diagram of the implementation process of a test method provided in the embodiment of the present application Figure 1 ;
[0022] Figure 2 A schematic diagram of the structure of a vehicle-mounted operating system provided in an embodiment of the present application;
[0023] Figure 3 A schematic diagram of the implementation process of a test method provided in the embodiment of the present application Figure 2 ;
[0024] Figure 4 A schematic diagram of a continuous integration platform provided in an embodiment of the present application;
[0025] Figure 5 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application;
[0026] Figure 6 A schematic diagram of the structure of a vehicle provided in an embodiment of the present application. DETAILED DESCRIPTION
[0027] The technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application.
[0028] In order to make the purpose, technical solutions and advantages of the present application clearer, the present application will be further described below in conjunction with the accompanying drawings. The described embodiments should not be regarded as limiting the present application. All other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of this application.
[0029] In the following description, reference is made to “some embodiments\other embodiments”, which describe a subset of all possible embodiments, but it can be understood that “some embodiments\other embodiments” may be the same subset or different subsets of all possible embodiments and may be combined with each other without conflict.
[0030] In the following description, the terms "first\second" involved are merely used to distinguish similar objects and do not represent a specific ordering of the objects. It can be understood that "first\second" can be interchanged with a specific order or sequence where permitted, so that the embodiments of the present application described herein can be implemented in an order other than that illustrated or described herein.
[0031] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein are only for the purpose of describing the embodiments of this application and are not intended to limit this application.
[0032] In a related art, a unit test framework suitable for embedded systems is provided to solve the problem of standardized testing of current embedded field application programs. The unit test framework includes a standard test interface module, a test case export module, a test command parsing module, a test unit execution module, a log module and a test result processing module. The test case export module abstracts the test case program into a test initialization module, a test cleanup module and a test case program entry module, and uses the linker characteristics to export the test case program to a specified code segment in the program image. The unit test framework is written in standard C language, implements a universal test interface, reduces the difficulty of writing test case programs, improves code reuse, shortens the development cycle, is applicable to all embedded operating systems, and can be transplanted to a bare metal system that does not use an embedded system.
[0033] However, this method involves too many modules and is relatively complex, which is not suitable for the field of vehicle embedded real-time operating systems. It also does not consider continuous integration platforms to achieve automated testing.
[0034] In another related technology, an embedded software unit testing method, system, readable medium and electronic device are provided. In a compilation server, a unit test framework static library, a unit test code file, a source code project and a unit test framework main function file are automatically cross-compiled to generate an executable file according to a first compilation rule file, and the executable file is automatically copied to the embedded software running platform to automatically generate a unit test result file. When a developer provides a new testable version, it is no longer necessary to manually compile the source code into a source code dynamic library and provide it to the unit tester. It is only necessary to upload the added or modified source code file to the configuration management server, which improves the speed at which the developer updates the testable version; the unit tester only needs to upload the added or modified unit test code file to the configuration management server and run the system to obtain the unit test result file, which improves the testing efficiency of the unit tester.
[0035] In another related technology, although a continuous integration platform is considered and automated testing is basically achieved, it is limited to specific tools and testing environments, that is, application priority.
[0036] In summary, there is no better way to implement automated unit testing in the field of vehicle embedded real-time operating systems.
[0037] In view of this, an embodiment of the present application provides a testing method, which is applied to a continuous integration platform, on which business code, unit test code, test cases, a unit test framework, an in-vehicle operating system, a compilation script, and a test script are deployed; Figure 1 A schematic diagram of the implementation process of a test method provided in the embodiment of the present application Figure 1 ,like Figure 1 As shown, the method includes the following steps 101 to 102:
[0038] Step 101, run the compilation script to obtain an executable file; the executable file includes: compiled business code, compiled unit test code, compiled unit test framework, compiled test cases and compiled vehicle operating system; the business code is the code to be tested; the business code is applied to the vehicle operating system; the unit test code is used to verify the correctness of the business code; the unit test code is written according to the unit test framework;
[0039] Step 102, running the test script so that the test script tests the business code by running the executable file to obtain the test result; wherein the test script is written according to the test case, and the test case is used to indicate the purpose and steps of the test.
[0040] It can be understood that in the test method provided in the embodiment of the present application, for the business code applied to the vehicle operating system, during the test process, the business code, the unit test code corresponding to the business code, the test case, the unit test framework, the vehicle operating system applied by the business code, the compilation script and the test script are deployed on the continuous integration platform, and the compilation script is run by the continuous integration platform to obtain an executable file; the continuous integration platform also runs the test script so that the test script tests the business code by running the executable file to obtain the test result. In this way, since the vehicle operating system is widely used and the software iteration and update on the vehicle operating system is fast, the business code on the vehicle operating system is tested through the continuous integration platform, and the business code on the vehicle operating system is tested around the clock, thereby improving the development and testing efficiency of the business code applied to the vehicle operating system.
[0041] In some embodiments, the vehicle-mounted operating system includes: a vehicle-mounted embedded operating system.
[0042] It should be understood that in the embodiments of the present application, the vehicle embedded operating system is a dedicated computer system designed to control and manage various functions and devices in the car. It is usually based on embedded technology, which closely integrates computer hardware and software to enable the device to perform specific tasks without direct user operation. The main functions of the vehicle embedded operating system include: multimedia entertainment, driving assistance, powertrain control, body electronic control, and safety system.
[0043] In some embodiments, the compilation script includes a first parameter and a second parameter; accordingly, the running of the compilation script also includes: running the compilation script to generate a coverage file; wherein the coverage file is generated by at least running the first parameter in the compilation script; the executable file is compiled based on at least the first parameter and the second parameter; the running of the test script so that the test script runs the executable file also includes: running the test script so that the test script runs the executable file to generate a test coverage file; the method also includes: generating a unit test report based on the coverage file and the test coverage file.
[0044] It can be understood that in the test method provided in the embodiment of the present application, the first parameter and the second parameter are added to the compilation script, the compilation script with the first parameter and the second parameter added is run to obtain an executable file and generate a coverage file; the test script is run so that the test script runs the executable file to generate a test coverage file; and a unit test report is generated based on the coverage file and the test coverage file. In this way, by providing a unit test report, it is beneficial for developers and testers to understand the test status of the business code, and then it is beneficial for developers to quickly locate, analyze and solve problems, and realize rapid iteration of business code, that is, to improve the development and testing efficiency of business code applied to the vehicle operating system.
[0045] In some embodiments, the first parameter is a -fprofile-arcs parameter, the second parameter is a -ftest-coverage parameter, the coverage file is a .gcno file, and the test coverage file is a .gcda file.
[0046] It should be understood that in the embodiment of the present application, the -fprofile-arcs parameter is used to insert additional code during the compilation process to collect jump information between basic blocks when the program is running. After running the program compiled with the -fprofile-arcs parameter, a .gcda file will be generated. This file contains the number of jumps between basic blocks when the program is running. The -ftest-coverage parameter is used to generate a .gcno file during compilation. This file contains the basic blocks of the program and the corresponding source code line number information. The -ftest-coverage parameter is usually used together with the -fprofile-arcs parameter. The .gcda file and the .gcno file are used to generate a code coverage report.
[0047] In some embodiments, running the compilation script to obtain an executable file includes: running the compilation script to compile the business code, the unit test code, the unit test framework, the test case and the vehicle operating system to respectively obtain the executable file corresponding to the business code, the executable file corresponding to the unit test code, the executable file corresponding to the unit test framework, the executable file corresponding to the test case and the executable file corresponding to the vehicle operating system; linking the executable file corresponding to the business code, the executable file corresponding to the unit test code, the executable file corresponding to the unit test framework and the executable file corresponding to the vehicle operating system to obtain an executable file.
[0048] In some embodiments, the unit testing framework, the business code, the unit testing code and the test cases deployed on the continuous integration platform are integrated on the vehicle operating system; running the compilation script to obtain an executable file includes: running the compilation script to compile the vehicle operating system to obtain an executable file.
[0049] It can be understood that in the test method provided in the embodiment of the present application, since the unit test framework, business code, unit test code and test cases are all integrated on the vehicle operating system, there is no need to compile the business code, unit test code, unit test framework, test cases and vehicle operating system separately, and then link the compiled executable files into one executable file. Instead, the vehicle operating system can be compiled once to obtain the executable file, thereby improving the work efficiency of testers by reducing the compilation process and number of times.
[0050] In some embodiments, the unit testing framework is transplanted onto the kernel of the vehicle-mounted operating system, and the business code and unit testing code are directly written on the vehicle-mounted operating system.
[0051] In some embodiments, generating a unit test report based on the coverage file and the test coverage file includes: comparing and analyzing the coverage file and the test coverage file through a code coverage reporting tool to obtain unit test data; converting the format of the unit test data to obtain a unit test report; wherein the unit test report includes: the function coverage of the business code, the line coverage of the business code, the branch coverage of the business code, and the pass status of the test case.
[0052] It can be understood that in the test method provided in the embodiment of the present application, the coverage file and the test coverage file are compared and analyzed by the code coverage report tool to obtain unit test data; the format of the unit test data is converted to obtain a unit test report; wherein the unit test report includes: function coverage of the business code, line coverage of the business code, branch coverage of the business code, and the pass status of the test cases. In this way, it is beneficial for developers and testers to understand the test status of the business code through the unit test report, which in turn helps developers to quickly locate, analyze and solve problems, and realize rapid iteration of business code, that is, to improve the development and testing efficiency of business code applied to the vehicle operating system.
[0053] In some embodiments, the code coverage reporting tool is a Linux Test Project Coverage (LCOV) tool.
[0054] In some embodiments, converting the format of the unit test data to obtain the unit test report includes: using a genhtml command to convert the unit test data generated by the LCOV tool into a unit test report in a HyperText Markup Language (HTML) format.
[0055] In some embodiments, based on the unit test report, developers can quickly locate, analyze and solve problems. The modified code is uploaded to the continuous integration platform again, and the continuous integration platform will rerun the compilation script and test script, execute the unit test code and use cases again, and then test the modified code uninterruptedly. Generate new unit test reports and results based on the test results, and then solve the newly exposed problems, and repeat this process. All problems in the upper-level business code are eventually solved. This process does not need to be executed manually, and developers only need to pay attention to the final test results, which greatly improves the efficiency of development and saves time and labor costs.
[0056] In some embodiments, when the unit test report meets the conditions, the vehicle-mounted operating system, the business code and the compiled script are deployed on a continuous deployment platform for user use.
[0057] It can be understood that in the testing method provided in the embodiment of the present application, since the continuous deployment platform is a tool that automatically deploys the software to the production environment after the software is built and tested, when the unit test report meets the conditions, the vehicle-mounted operating system, business code and compiled script are used to be deployed on the continuous deployment platform for user use, which is beneficial to improve the deployment speed of the vehicle-mounted operating system, business code and compiled script, and reduce deployment risks.
[0058] In some embodiments, the unit test report satisfies the following conditions: the function coverage of the business code is greater than or equal to the function coverage threshold, the line coverage of the business code is greater than or equal to the line coverage threshold, the branch coverage of the business code is greater than or equal to the branch coverage threshold, and at least the test cases in the high-risk area pass.
[0059] It should be understood that in the embodiments of the present application, the function coverage threshold, line coverage threshold and branch coverage threshold are not limited. In some embodiments, the function coverage threshold can be set to a relatively low value, because function coverage mainly focuses on whether the function is called, rather than the detailed execution path inside the function. For some key or core functions, a higher coverage threshold can be set to ensure that these functions are fully tested. In some embodiments, line coverage is an important indicator to measure whether the test case covers every line of the source code. Therefore, the line coverage threshold can be set at a higher level, such as 80% or above 90%, to ensure that most of the code is tested. However, for some specific code segments (such as exception handling, boundary conditions, etc.), a higher line coverage threshold may be required to ensure that these critical paths are fully tested. In some embodiments, branch coverage is an important indicator to measure whether the test case covers each branch in the code. For code containing complex logic and multiple branches, the branch coverage threshold should generally be set higher to ensure that each branch is tested. Similarly, for critical or high-risk branches, a higher coverage threshold may need to be set to ensure the robustness and reliability of these branches.
[0060] The embodiment of the present application provides a vehicle-mounted operating system, Figure 2 A schematic diagram of the structure of a vehicle-mounted operating system provided in an embodiment of the present application is shown in FIG. Figure 2As shown, the kernel 201 of the vehicle operating system includes: a unit test framework 202, a unit test code 203, a test case 204 and a business code 205; wherein the business code 205 is the code to be tested; the unit test code 203 is used to verify the correctness of the business code 205; the unit test code 203 is written according to the unit test framework 202; the test case 204 is used to indicate the purpose and steps of the test; the vehicle operating system 20 is used to be deployed on a continuous integration platform so that the continuous integration platform executes the test method provided in the above-mentioned embodiment of the present application.
[0061] It can be understood that the kernel 201 of the vehicle operating system provided in the embodiment of the present application includes a unit test framework 202, a unit test code 203, a test case 204 and a business code 205, and the vehicle operating system 20 including the unit test framework 202, the unit test code 203, the test case 204 and the business code 205 is deployed on the continuous integration platform. In this way, the continuous integration platform does not need to compile the unit test framework 202, the unit test code 203, the test case 204 and the business code 205 vehicle operating system 20 separately, and then link the compiled executable files into one executable file, but compiles the vehicle operating system 20 once to obtain the executable file, thereby reducing the compilation process and the number of times, and improving the work efficiency of the tester.
[0062] The following describes an exemplary application of the embodiments of the present application in a practical application scenario.
[0063] Currently, there are few unit testing methods applicable to the field of in-vehicle embedded real-time operating systems, or some of them are not perfect. In addition, embedded software is updated rapidly, and a method is needed that can support full verification and testing to expose problems in embedded real-time operating systems.
[0064] The embodiment of the present application proposes a method (i.e., an example of a testing method) with a simple module and capable of implementing automated testing in a continuous integration and continuous deployment platform to solve this problem, in order to cope with the phenomenon that the software (i.e., an example of a business code) in a vehicle-mounted embedded real-time operating system (i.e., an example of a vehicle-mounted operating system) is iteratively updated very quickly, the software quality cannot be guaranteed, and the problems existing in the software cannot be fully exposed.
[0065] The test method provided in the embodiment of the present application includes the following contents:
[0066] 11. The unit test framework involved in this test method has few dependencies and is transplanted into a real-time operating system (i.e., an example of an in-vehicle operating system). At the same time, the unit test case can be used as an upper-layer application of the real-time operating system, so that it can be directly tested after compiling once. There is no need to compile the unit test framework, unit test case, real-time operating system and other codes separately, and then link them into an executable file. The compilation process and number of times are reduced, and the work efficiency of testers is improved.
[0067] 12. Using the continuous integration and continuous deployment platform, you can achieve all-weather automated unit testing. Testers only need to write unit test cases and no longer need to manually compile and execute test cases, which greatly improves the test efficiency of testers and reduces their workload.
[0068] 13. Able to provide visual unit test reports, including but not limited to code coverage, code branch coverage, test case pass status, etc.
[0069] 14. According to the unit test report, problems can be quickly located, analyzed and solved, which improves the efficiency of development and testing. And after each code update, the continuous integration platform and continuous deployment platform will automatically execute test cases to ensure code quality.
[0070] It can be understood that in the embodiments of the present application, direct testing can be achieved after one compilation, without the need for multiple compilations, reducing the number of compilations and improving efficiency; it can achieve all-weather automated testing, fully expose problems in the code, ensure code quality, and improve development and testing efficiency; it can provide intuitive unit test reports, which help developers and testers understand the execution of the code; based on the unit test reports, it helps developers to quickly locate, analyze and solve problems and achieve rapid iteration of software.
[0071] Figure 3 A schematic diagram of the implementation process of a test method provided in the embodiment of the present application Figure 2 ,like Figure 3 As shown, the method includes the following steps 301 to 310:
[0072] Step 301, porting the unit test framework to the real-time operating system;
[0073] Step 302, write upper layer business code;
[0074] Step 303, write unit test code;
[0075] Step 304, write a compilation script and a test script;
[0076] Step 305, deploy to the continuous integration platform;
[0077] The real-time operating system including the unit test framework, business code, unit test code, compilation scripts and test scripts will be deployed to the continuous integration platform;
[0078] Step 306, the continuous integration platform automatically compiles into executable files and .gcno files;
[0079] Step 307, the continuous integration platform executes the test case and generates a .gcda file;
[0080] Step 308, the continuous integration platform compares the .gcno and .gcda files using the ICOV tool;
[0081] Step 309, the continuous integration platform generates a unit test report;
[0082] Step 310: Analyze and resolve the positioning problem.
[0083] The present application relates to a unit testing method for a real-time operating system (i.e., an example of a testing method). The specific implementation steps refer to the following:
[0084] twenty one, Figure 2 The structural block diagram of the vehicle operating system 20 is shown, in which the unit test framework 202 is on top of the vehicle operating system kernel 201. The unit test framework 202 only needs to rely on the standard C library interface in the vehicle operating system 20 and does not require additional interfaces. Above the unit test framework 202 are unit test code 203 and test cases 204. The unit test code 203 mainly uses the test functions such as assertions provided by the unit test framework 201 to complete the test for the upper-layer business code 205. Finally, the entire system is deployed on the continuous integration platform to complete the automated test.
[0085] 22. According to Figure 3 The overall process of the test shown above first requires porting the unit test framework to the real-time operating system as part of the real-time operating system. Then write the upper-level business code normally, that is, the code that needs to be tested. After writing, you need to use the functions provided by the unit test framework to write the corresponding unit test code and cases. At this time, the business code, unit test code, and test framework are all in the real-time operating system. Then write the corresponding compilation script and test script to the continuous integration platform. The continuous integration platform only needs to execute the compilation script, and then the compilation script follows the compilation rules and adds the -fprofile-arch parameter and -ftest-coverage parameter in the compilation parameters. After the compilation is completed, the corresponding .gcno file and executable file will be generated. Several parts of the code only need to be compiled once, without multiple compilations, which improves efficiency and reduces workload.
[0086] 23. The test script runs the executable file. After the execution is completed, the unit test framework will output the test results and generate a .gcda file. Then the continuous integration platform will use the LCOV tool to compare the .gcno file and .gcda file mentioned above to generate a unit test report, which includes the function coverage, line coverage, branch coverage and test case passing status of the business code. At the same time, the continuous integration platform will continue to execute these test cases to fully expose the problems in the business code, thereby ensuring the quality of the code.
[0087] 24. Based on the problems found by the unit test framework, developers can quickly locate, analyze and solve the problems. The modified code is uploaded to the continuous integration platform again. The platform will re-execute the compilation and test scripts, re-execute the unit test code and use cases, and then continuously test the modified code. Generate new unit test reports and results based on the test results, and then solve the newly exposed problems, and repeat this process. All problems in the upper-level business code are finally solved. This process does not need to be executed manually. Developers only need to pay attention to the final test results, which greatly improves the efficiency of development and saves time and labor costs. After the test passes, the business code, real-time operating system, and compiled code are deployed to the continuous deployment platform.
[0088] Finally, it should be noted that the above embodiments are only used to illustrate the technical solution of the present application and are not intended to limit it. Although the present application has been described in detail with reference to the preferred embodiments, a person of ordinary skill in the art should understand that the technical solution of the present application can be modified or replaced by equivalents without departing from the purpose and scope of the technical solution of the present application, which should be included in the scope of protection of the present application.
[0089] It should be noted that although the steps of the method in the present application are described in a specific order in the accompanying drawings, this does not require or imply that the steps must be performed in this specific order, or that all the steps shown must be performed to achieve the desired results. Additionally or alternatively, some steps may be omitted, multiple steps may be combined into one step for execution, and / or one step may be decomposed into multiple steps for execution, etc.; or, the steps in different embodiments may be combined into a new technical solution. Based on the foregoing embodiments, the embodiments of the present application provide a continuous integration platform, which includes the modules included and the units included in the modules, which can be implemented by a processor; of course, it can also be implemented by a specific logic circuit; in the implementation process, the processor may be an AI acceleration engine (such as NPU, etc.), a graphics processor (GPU), a central processing unit (CPU), a microprocessor (MPU), a digital signal processor (DSP) or a field programmable gate array (FPGA), etc.
[0090] Figure 4A schematic diagram of a continuous integration platform provided in an embodiment of the present application is shown as follows: Figure 4 As shown, the continuous integration platform 40 is deployed with business code 401, unit test code 402, test case 403, unit test framework 404, vehicle operating system 405, compilation script 406 and test script 407; the continuous integration platform 40 includes: a first operation module 408 and a second operation module 409; wherein,
[0091] The first running module 408 is configured to run the compiled script to obtain an executable file; wherein the executable file includes: the compiled business code, the compiled unit test code, the compiled unit test framework, the compiled test case and the compiled vehicle operating system; the business code is the code to be tested; the business code is applied to the vehicle operating system; the unit test code is used to verify the correctness of the business code; the unit test code is written according to the unit test framework;
[0092] The second running module 409 is configured to run the test script so that the test script tests the business code by running the executable file to obtain a test result; wherein the test script is written according to a test case, and the test case is used to represent the purpose and steps of the test.
[0093] In some embodiments, the compilation script includes a first parameter and a second parameter; a first running module 408 is configured to run the compilation script to generate a coverage file; wherein the coverage file is generated by at least running the first parameter in the compilation script; the executable file is compiled according to at least the first parameter and the second parameter; a second running module 409 is configured to run the test script so that the test script runs the executable file to generate a test coverage file; the continuous integration platform also includes a generation module, and the generation module is configured to generate a unit test report according to the coverage file and the test coverage file.
[0094] In some embodiments, the unit testing framework, the business code, the unit testing code and the test cases deployed on the continuous integration platform are integrated on the vehicle operating system; the first running module 408 is configured to run the compilation script to compile the vehicle operating system to obtain an executable file.
[0095] In some embodiments, the generation module is configured to compare and analyze the coverage file and the test coverage file through a code coverage reporting tool to obtain unit test data; convert the format of the unit test data to obtain a unit test report; wherein the unit test report includes: the function coverage of the business code, the line coverage of the business code, the branch coverage of the business code, and the pass status of the test case.
[0096] In some embodiments, when the unit test report meets the conditions, the vehicle-mounted operating system, the business code and the compiled script are deployed on a continuous deployment platform for user use.
[0097] The description of the above continuous integration platform embodiment is similar to the description of the above method embodiment, and has similar beneficial effects as the method embodiment. For technical details not disclosed in the embodiment of the continuous integration platform of this application, please refer to the description of the method embodiment of this application for understanding.
[0098] It should be noted that the division of modules in the embodiments of the present application is schematic and is only a logical function division. There may be other division methods in actual implementation. In addition, each functional unit in each embodiment of the present application may be integrated into a processing unit, or may exist physically alone, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of a software functional unit. It may also be implemented in the form of a combination of software and hardware.
[0099] It should be noted that in the embodiment of the present application, if the above method is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the embodiment of the present application can be essentially or partly embodied in the form of a software product that contributes to the relevant technology. The computer software product is stored in a storage medium, including several instructions to enable an electronic device to execute all or part of the methods described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a U disk, a mobile hard disk, a read-only memory (ROM), a magnetic disk or an optical disk. In this way, the embodiment of the present application is not limited to any specific combination of hardware and software.
[0100] An embodiment of the present application provides an electronic device, Figure 5 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application is shown in FIG. Figure 5As shown, the electronic device 50 includes a memory 501 and a processor 502. The memory 501 stores a computer program that can be run on the processor 502. When the processor 502 executes the program, the steps in the method provided in the above embodiment are implemented.
[0101] It should be noted that the memory 501 is configured to store instructions and applications executable by the processor 502, and can also cache data to be processed or processed by the processor 502 and various modules in the electronic device 50, which can be implemented through flash memory (FLASH) or random access memory (Random Access Memory, RAM).
[0102] An embodiment of the present application provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps in the method provided in the above embodiment are implemented.
[0103] An embodiment of the present application provides a computer program product including instructions, which, when executed on a computer, enables the computer to execute the steps of the method provided in the above method embodiment.
[0104] The embodiment of the present application provides a vehicle, Figure 6 A schematic diagram of the structure of a vehicle provided in an embodiment of the present application is shown in FIG. Figure 6 As shown, the vehicle 60 includes a continuous integration platform 40, and the continuous integration platform 40 is used to implement the steps in the method provided in the above method embodiment.
[0105] It should be noted here that the description of the above storage medium and device embodiments is similar to the description of the above method embodiments, and has similar beneficial effects as the method embodiments. For technical details not disclosed in the storage medium and device embodiments of this application, please refer to the description of the method embodiments of this application for understanding.
[0106] It should be understood that "one embodiment" or "an embodiment" or "some embodiments" mentioned throughout the specification means that specific features, structures or characteristics related to the embodiment are included in at least one embodiment of the present application. Therefore, "in one embodiment" or "in one embodiment" or "in some embodiments" appearing throughout the specification may not necessarily refer to the same embodiment. In addition, these specific features, structures or characteristics can be combined in one or more embodiments in any suitable manner. It should be understood that in various embodiments of the present application, the size of the sequence number of the above-mentioned processes does not mean the order of execution, and the execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiment of the present application. The above-mentioned sequence numbers of the embodiments of the present application are only for description and do not represent the advantages and disadvantages of the embodiments. The above description of each embodiment tends to emphasize the differences between the various embodiments, and the same or similar aspects can be referenced to each other. For the sake of brevity, this article will not repeat them.
[0107] The term "and / or" in this article is only a description of the association relationship of associated objects, indicating that there may be three relationships. For example, object A and / or object B can represent three situations: object A exists alone, object A and object B exist at the same time, and object B exists alone.
[0108] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or continuous integration platform including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or device including the element.
[0109] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. The embodiments described above are merely illustrative. For example, the division of the modules is only a logical function division. There may be other division methods in actual implementation, such as: multiple modules or components can be combined, or can be integrated into another system, or some features can be ignored, or not executed. In addition, the coupling, direct coupling, or communication connection between the components shown or discussed can be through some interfaces, and the indirect coupling or communication connection of devices or modules can be electrical, mechanical or other forms.
[0110] The modules described above as separate components may or may not be physically separated, and the components displayed as modules may or may not be physical modules; they may be located in one place or distributed on multiple network units; some or all of the modules may be selected according to actual needs to achieve the purpose of the present embodiment.
[0111] In addition, all functional modules in the embodiments of the present application may be integrated into one processing unit, or each module may be a separate unit, or two or more modules may be integrated into one unit; the above-mentioned integrated modules may be implemented in the form of hardware or in the form of hardware plus software functional units.
[0112] A person skilled in the art can understand that all or part of the steps of implementing the above method embodiment can be completed by hardware related to program instructions, and the aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it executes the steps of the above method embodiment; and the aforementioned storage medium includes: mobile storage devices, read-only memories (ROM), magnetic disks or optical disks, etc., various media that can store program codes.
[0113] Alternatively, if the above-mentioned integrated unit of the present application is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the embodiment of the present application can essentially or in other words, the part that contributes to the relevant technology can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for enabling an electronic device to execute all or part of the methods described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as mobile storage devices, ROMs, magnetic disks, or optical disks.
[0114] The methods disclosed in several method embodiments provided in this application can be combined arbitrarily without conflict to obtain new method embodiments. The features disclosed in several product embodiments provided in this application can be combined arbitrarily without conflict to obtain new product embodiments.
[0115] The features disclosed in several method or device embodiments provided in this application can be arbitrarily combined without conflict to obtain new method embodiments or device embodiments.
[0116] The above is only an implementation method of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application.
Claims
1. A testing method, characterized in that: The method is applied to a continuous integration platform, on which business code, unit test code, test cases, a unit test framework, an in-vehicle operating system, a compilation script, and a test script are deployed; The method comprises: Run the compilation script to obtain an executable file; wherein the executable file includes: the compiled business code, the compiled unit test code, the compiled unit test framework, the compiled test case and the compiled vehicle operating system; the business code is the code to be tested; the business code is applied to the vehicle operating system; the unit test code is used to verify the correctness of the business code; the unit test code is written according to the unit test framework; Run the test script so that the test script tests the business code by running the executable file to obtain a test result; wherein the test script is written according to a test case, and the test case is used to represent the purpose and steps of the test.
2. The testing method according to claim 1, characterized in that: The compilation script includes a first parameter and a second parameter; Accordingly, the running of the compiled script further includes: Running the compilation script to generate a coverage file; wherein the coverage file is generated by at least running a first parameter in the compilation script; and the executable file is compiled according to at least the first parameter and the second parameter; The running of the test script so that the test script runs an executable file further includes: Running the test script so that the test script runs the executable file and generates a test coverage file; The method further comprises: Generate a unit test report based on the coverage file and the test coverage file.
3. The testing method according to claim 2, characterized in that: The unit test framework, the business code, the unit test code and the test case deployed on the continuous integration platform are integrated on the vehicle operating system; and the running of the compilation script to obtain an executable file includes: Run the compilation script to compile the vehicle-mounted operating system to obtain an executable file.
4. The testing method according to claim 2, characterized in that: The generating a unit test report according to the coverage file and the test coverage file includes: Comparative analysis is performed on the coverage file and the test coverage file by using a code coverage reporting tool to obtain unit test data; Convert the format of the unit test data to obtain a unit test report; wherein the unit test report includes: the function coverage of the business code, the line coverage of the business code, the branch coverage of the business code and the pass status of the test case.
5. The testing method according to any one of claims 2 to 4, characterized in that: When the unit test report meets the conditions, the vehicle-mounted operating system, the business code and the compiled script are deployed on a continuous deployment platform for user use.
6. A vehicle-mounted operating system, characterized in that: The kernel of the vehicle-mounted operating system includes: a unit test framework, unit test code, test cases and business code; wherein the business code is the code to be tested; the unit test code is used to verify the correctness of the business code; the unit test code is written according to the unit test framework; the test case is used to indicate the purpose and steps of the test; the vehicle-mounted operating system is used to be deployed on a continuous integration platform so that the continuous integration platform executes the method described in any one of claims 1 to 5.
7. A continuous integration platform, characterized in that: The continuous integration platform is deployed with business code, unit test code, test cases, unit test framework, vehicle operating system, compilation script and test script; The continuous integration platform includes: The first running module is configured to run the compiled script to obtain an executable file; wherein the executable file includes: the compiled business code, the compiled unit test code, the compiled unit test framework, the compiled test case and the compiled vehicle operating system; the business code is the code to be tested; the business code is applied to the vehicle operating system; the unit test code is used to verify the correctness of the business code; the unit test code is written according to the unit test framework; The second running module is configured to run the test script so that the test script tests the business code by running the executable file to obtain a test result; wherein the test script is written according to a test case, and the test case is used to represent the purpose and steps of the test.
8. An electronic device comprising a memory and a processor, wherein the memory stores a computer program that can be run on the processor, characterized in that: When the processor executes the program, the method according to any one of claims 1 to 5 is implemented.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 5 is implemented.
10. A computer program product comprising a computer program or instructions, characterized in that When the computer program or instruction is executed by a processor, the method according to any one of claims 1 to 5 is implemented.
11. A vehicle, characterized in that: The vehicle comprises a continuous integration platform, and the continuous integration platform is used to implement the method according to any one of claims 1 to 5.
Citation Information
Cited By
Software layering test method and system, computer equipment and storage medium
CN120803961A