Test method, device, equipment, medium and program product
By using the user-layer test interface in the test script and calling the interfaces of different host computer software, the problems of reduced testing efficiency and high maintenance costs caused by inconsistent interfaces of different manufacturers are solved, and efficient ECU automation testing is achieved.
Patent Information
- Application Number
- CN202411532858.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-30
- Publication Date
- 2025-02-14
AI Technical Summary
When performing automated testing of electronic control units (ECUs), due to the different interfaces of the upper computer software of different manufacturers, corresponding automated test scripts need to be developed, resulting in reduced testing efficiency and high maintenance costs.
By using the user-layer test interface in the test script, the target interface of the target host computer software is called to test the target function. The user-layer test interface is obtained by encapsulating the interface function of different host computer software based on the test business scenario, and is compatible with the scheduling of different host computer software.
It realizes that different benches are scheduled through different host computer software, and the target function test of the ECU is completed, which greatly improves the testing efficiency, reduces the post-maintenance cost of the test script, and reduces the learning cost of the testers.
Smart Images

Figure CN119441043A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of testing technology, and in particular to a testing method, device, equipment, medium and program product. Background Art
[0002] With the development of vehicle intelligence, the standard requirements for the vehicle's Electronic Control Unit (ECU) are getting higher and higher. Correspondingly, there are more and more automated testing software for ECU.
[0003] At present, when performing automated testing on ECUs, the interfaces of the host computer software corresponding to the test benches of different manufacturers are different. For different host computer software interfaces, corresponding automated testing scripts need to be developed to perform automated testing, which reduces the testing efficiency of the ECU. Summary of the invention
[0004] The purpose of the present invention is to provide a test method, device, equipment, medium and program product to solve the problem of reducing the test efficiency of ECU due to the need to develop corresponding automated test scripts for different host computer software interfaces to perform automated testing.
[0005] In order to achieve the above object, the technical solution adopted by the present invention is as follows:
[0006] A testing method comprises: receiving a test instruction, the test instruction is used to instruct to test a target function of an electronic control unit ECU; determining a target host computer software, the target host computer software is software running on a target test bench for testing the ECU; calling a target interface of the target host computer software through a user layer test interface in a test script to test the target function, the user layer test interface is obtained by encapsulating the interface functions of interfaces corresponding to different host computer software according to a test business scenario.
[0007] According to the above technical means, since the user-layer test interface is obtained by encapsulating the interface functions corresponding to different host computer software according to the test business scenario, it is compatible with the scheduling of different host computer software. It can enable testers to change from paying attention to the use of different host computer software and the description of the corresponding interfaces to only needing to understand a set of standard user-layer test interfaces, and then different test benches can be scheduled through different host computer software to complete the test of the target function of the ECU. This can greatly improve the test efficiency of the ECU, reduce the later maintenance cost of the test script, and reduce the learning cost required for testers to perform ECU automation testing.
[0008] Furthermore, the user layer test interface is obtained in the following manner: obtaining interfaces corresponding to multiple host computer software respectively; for each host computer software, creating a first application object corresponding to the software identifier of the host computer software according to the software identifier of the host computer software; based on the test business scenario, mapping the attribute behavior corresponding to the first application object to a first behavior function corresponding to the interface function of the host computer software, and encapsulating the first behavior function as a basic step function to obtain a user layer test interface.
[0009] Furthermore, the testing method also includes: for the host computer software to be connected, obtaining the mapping relationship between the software identifier of the host computer software to be connected and the interface of the host computer software to be connected; according to the mapping relationship, extracting the software identifier and interface of the host computer software to be connected; injecting the software identifier and interface of the host computer software into the basic step function, and creating a second application object corresponding to the software identifier of the host computer software to be connected; based on the test business scenario corresponding to the host computer software to be connected, mapping the attribute behavior corresponding to the second application object to the second behavior function corresponding to the interface function of the host computer software to be connected, and encapsulating the second behavior function into the basic step function to complete the encapsulation of the interface function of the host computer software to be connected.
[0010] Furthermore, the test method also includes: obtaining a signal identifier and a signal physical value corresponding to the bus signal to be sent, the bus signal to be sent includes a controller area network CAN signal and / or a CAN signal with a variable data rate; parsing a bus database file, obtaining a message identifier and message information corresponding to the bus signal to be sent according to the signal identifier, and converting the signal physical value into binary data; assembling the message identifier, message information and binary data to obtain target bus data; and sending the target bus data to the ECU.
[0011] Further, determining the target host computer software includes: querying a configuration file to determine the target host computer software, wherein the configuration file includes a software identifier of the target host computer software.
[0012] Furthermore, the user-layer test interface includes an initialization function interface, a preparation test function interface, a start test function interface and an end test function interface, wherein the initialization function interface is used to initialize the initial state and initial environment before the test; the preparation test function interface is used to encapsulate the test conditions, test properties and variables before the test; the start test function interface is used to implement the specific logic of the test steps and the diagnosis of the test results; the end test function interface is used to restore the test environment to the initial state.
[0013] Further, the target interface of the target host computer software is called through the user layer test interface in the test script to test the target function, including: calling the target interface through the target user layer test interface in the start test function interface to test the target function, the target user layer test interface is the user layer test interface corresponding to the target function.
[0014] Furthermore, the testing method also includes: during the process of testing the target function, outputting a test log.
[0015] Furthermore, the target user layer test interface includes multiple ones, and the test method further includes: storing the test result corresponding to each target user layer test interface; and determining the target test result of the target function according to the multiple test results.
[0016] A test device comprises: a receiving module for receiving a test instruction, wherein the test instruction is used to instruct to test a target function of an electronic control unit ECU; a determining module for determining a target host computer software, wherein the target host computer software is software running on a target bench for testing the ECU; and a testing module for calling a target interface of the target host computer software through a user layer test interface in a test script to test the target function, wherein the user layer test interface is obtained by encapsulating the interface functions of interfaces corresponding to different host computer software according to a test business scenario.
[0017] Furthermore, the testing device also includes an acquisition module for obtaining a user layer test interface in the following manner: obtaining interfaces corresponding to multiple host computer software respectively; for each host computer software, creating a first application object corresponding to the software identifier of the host computer software according to the software identifier of the host computer software; based on the test business scenario, mapping the attribute behavior corresponding to the first application object to a first behavior function corresponding to the interface function of the host computer software, and encapsulating the first behavior function as a basic step function to obtain a user layer test interface.
[0018] Furthermore, the acquisition module is also used to: for the host computer software to be connected, obtain the mapping relationship between the software identifier of the host computer software to be connected and the interface of the host computer software to be connected; according to the mapping relationship, extract the software identifier and interface of the host computer software to be connected; inject the software identifier and interface of the host computer software into the basic step function, and create a second application object corresponding to the software identifier of the host computer software to be connected; based on the test business scenario corresponding to the host computer software to be connected, map the attribute behavior corresponding to the second application object to the second behavior function corresponding to the interface function of the host computer software to be connected, and encapsulate the second behavior function into the basic step function to complete the encapsulation of the interface function of the host computer software to be connected.
[0019] Furthermore, the test device also includes a first processing module, which is used to: obtain a signal identifier and a signal physical value corresponding to the bus signal to be sent, the bus signal to be sent includes a controller area network CAN signal and / or a CAN signal with a variable data rate; parse the bus database file, and obtain a message identifier and message information corresponding to the bus signal to be sent according to the signal identifier, and convert the signal physical value into binary data; assemble the message identifier, message information and binary data to obtain the target bus data; and send the target bus data to the ECU.
[0020] Furthermore, the determination module is specifically used to: query a configuration file to determine the target host computer software, and the configuration file includes a software identifier of the target host computer software.
[0021] Furthermore, the user-layer test interface includes an initialization function interface, a preparation test function interface, a start test function interface and an end test function interface, wherein the initialization function interface is used to initialize the initial state and initial environment before the test; the preparation test function interface is used to encapsulate the test conditions, test properties and variables before the test; the start test function interface is used to implement the specific logic of the test steps and the diagnosis of the test results; the end test function interface is used to restore the test environment to the initial state.
[0022] Further, the test module is specifically used to test the target function by calling the target interface through the target user layer test interface in the start test function interface, and the target user layer test interface is a user layer test interface corresponding to the target function.
[0023] Furthermore, the testing device also includes an output module, which is used to output a test log during the process of testing the target function.
[0024] Furthermore, the target user layer test interface includes multiple ones, and the test device also includes a second processing module, which is used to: store the test result corresponding to each target user layer test interface; and determine the target test result of the target function according to the multiple test results.
[0025] An electronic device comprises: a processor and a memory connected to the processor in communication; the memory stores computer-executable instructions; the processor executes the computer-executable instructions stored in the memory to implement the test method of the present invention.
[0026] A computer-readable storage medium stores computer program instructions, and when the computer program instructions are executed, the test method of the present invention is implemented.
[0027] A computer program product includes a computer program. When the computer program is executed, the test method of the present invention is implemented.
[0028] Beneficial effects of the present invention: The test method, device, equipment, medium and program product provided by the present invention, when receiving a test instruction for instructing to test the target function of the ECU, determines the target host computer software, which is the software running on the target test bench for testing the ECU; calls the target interface of the target host computer software through the user layer test interface in the test script to test the target function. Among them, the user layer test interface is obtained by encapsulating the interface function of the interface corresponding to different host computer software according to the test business scenario, and can be compatible with the scheduling of different host computer software, which can make the test personnel change from the previous need to pay attention to the use of different host computer software and the description of the corresponding interface to only needing to understand a set of standard user layer test interfaces, so as to realize the scheduling of different test benches through different host computer software, thereby completing the test of the target function of the ECU, which can greatly improve the test efficiency of the ECU, reduce the later maintenance cost of the test script, and can reduce the learning cost required for the test personnel to perform ECU automated testing. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] Figure 1 A schematic diagram of an application scenario provided by an embodiment of the present invention;
[0030] Figure 2 A flow chart of a testing method provided by an embodiment of the present invention;
[0031] Figure 3 A flow chart for encapsulating the interface function to be connected to the upper computer software provided by an embodiment of the present invention;
[0032] Figure 4 A flow chart for developing the business logic of a test script provided by an embodiment of the present invention;
[0033] Figure 5 A flowchart of assembling bus signals provided by an embodiment of the present invention;
[0034] Figure 6 A schematic diagram of the structure of a testing device provided in one embodiment of the present invention;
[0035] Figure 7 A schematic diagram of the structure of a testing device provided in another embodiment of the present invention;
[0036] Figure 8 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0037] The following will describe the embodiments of the present invention with reference to the accompanying drawings and preferred embodiments. Those skilled in the art can easily understand other advantages and effects of the present invention from the contents disclosed in this specification. The present invention can also be implemented or applied through other different specific embodiments, and the details in this specification can also be modified or changed in various ways based on different viewpoints and applications without departing from the spirit of the present invention. It should be understood that the preferred embodiments are only for illustrating the present invention, not for limiting the scope of protection of the present invention.
[0038] It should be noted that the illustrations provided in the following embodiments are only schematic illustrations of the basic concept of the present invention, and thus the drawings only show components related to the present invention rather than being drawn according to the number, shape and size of components in actual implementation. In actual implementation, the type, quantity and proportion of each component may be changed arbitrarily, and the component layout may also be more complicated.
[0039] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in the present invention are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant laws, regulations and standards, and corresponding operation entrances shall be provided for users to choose to authorize or refuse.
[0040] With the development of vehicle intelligence, the standard requirements for the vehicle's Electronic Control Unit (ECU) are getting higher and higher. Correspondingly, there are more and more automated testing software for ECU.
[0041] At present, when performing automated testing on ECUs, the interfaces of the host computer software corresponding to the test benches of different manufacturers are different. When changing to a different manufacturer's test bench, the previous version of the automated test script is not compatible with the manufacturer's test bench that is replaced later. Therefore, for different host computer software interfaces, corresponding automated test scripts need to be developed to perform automated testing, resulting in high maintenance costs for automated scripts and reduced ECU testing efficiency. In addition, when testers change to different manufacturers' test benches, the cost of ECU automated testing is high, because different manufacturers' test benches have different corresponding host computer interfaces, and a set of customized test frameworks need to be developed to support automated testing of the new test bench, resulting in high automated learning costs.
[0042] Based on the above problems, the present invention provides a testing method, which encapsulates interface functions of interfaces corresponding to different host computer software according to the test business scenario, and obtains a user-layer test interface, which is compatible with the scheduling of different host computer software. When writing a test script, the tester can directly call the user-layer test interface without paying attention to the use of different host computer software and the description of the corresponding interface. Different test benches can be scheduled by different host computer software, thereby completing the test of the target function of the ECU, which can greatly improve the test efficiency of the ECU, reduce the later maintenance cost of the test script, and reduce the learning cost required for the tester to perform ECU automated testing.
[0043] In the following, the application scenario of the solution provided by the present invention is firstly described by way of example.
[0044] Figure 1 Schematic diagram of an application scenario provided by an embodiment of the present invention. Figure 1 As shown, in this application scenario, the tester triggers the automated test of ECU 103 through the host computer 102 corresponding to the test bench 101, wherein the host computer 102 calls the target interface of the host computer software running on the host computer 102 through the user layer test interface in the test script according to the test method provided by the present invention, and performs automated testing on the target function to be tested of the ECU. The user layer test interface is obtained by encapsulating the interface function corresponding to different host computer software according to the test business scenario; the host computer 102 and the test bench 101 are connected to each other by, for example, Ethernet.
[0045] It should be noted that Figure 1 This is only a schematic diagram of an application scenario provided by an embodiment of the present invention. Figure 1 does not limit the equipment included in Figure 1 The positional relationship between the devices is limited.
[0046] The technical solution of the present invention is described in detail below through specific embodiments. It should be noted that the following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described in detail in some embodiments.
[0047] Figure 2 This is a flow chart of a test method provided by an embodiment of the present invention. The test method can be executed by software and / or hardware devices. For example, the hardware device can be a test device, and the test device can be an electronic device or a processing chip in the electronic device. Figure 2 As shown, the method of the embodiment of the present invention includes:
[0048] S201. Receive a test instruction, where the test instruction is used to instruct to test a target function of an ECU.
[0049] In an embodiment of the present invention, the test instruction may be input by a tester to an electronic device executing an embodiment of the present method, or may be sent by other devices to an electronic device executing an embodiment of the present method. The test instruction is used to instruct to test a target function of the ECU, such as opening a window of a vehicle. It is understood that before receiving the test instruction, a test environment needs to be set up so that the test environment supports the execution of the test method provided in an embodiment of the present invention. For details on how to set up the test environment, please refer to the subsequent embodiments.
[0050] S202 , determining the target host computer software, where the target host computer software is software running on a target test bench for testing the ECU.
[0051] In this step, the host computer software includes, for example, Controldesk (an integrated development environment for real-time simulation and testing), Canoe (a development and testing tool for ECUs), and TSMaster (a test management tool), which are used to perform automated testing on ECUs through corresponding test benches. Taking the target host computer software as Controldesk as an example, the ECU can be automatically tested through the test bench corresponding to Controldesk.
[0052] Further, optionally, determining the target host computer software may include: querying a configuration file to determine the target host computer software, wherein the configuration file includes a software identifier of the target host computer software.
[0053] For example, the target host computer software can be managed through a configuration file. For example, if the ECU is automatically tested through the bench corresponding to Controldesk, the software identifier of Controldesk can be configured as a configuration parameter in the configuration file, so that when the ECU is automatically tested, the configuration file can be queried, and the target host computer software can be determined according to the software identifier of the host computer software in the configuration file.
[0054] S203, calling the target interface of the target host computer software through the user layer test interface in the test script to test the target function. The user layer test interface is obtained by encapsulating the interface functions of the interfaces corresponding to different host computer software according to the test business scenario.
[0055] It can be understood that for different upper software, in order to support the interfaces corresponding to different upper computer software, the interface can also be called a component object model (COM) interface. According to the test business scenario, the interfaces corresponding to different upper computer software can be encapsulated with interface functions to obtain a standard user-level test interface. The user-level test interface is compatible with the scheduling of different upper computer software, which can make the tester change from the previous need to pay attention to the use of different upper computer software and the description of the corresponding interface to only needing to understand a set of standard user-level test interfaces, so that different upper computer software can be used to schedule different test benches, thereby completing the corresponding ECU test. For example, for the upper computer software corresponding to the test benches of different manufacturers, such as the Controldesk upper computer software corresponding to the dSPACE test bench (a hardware and software platform for developing, testing and verifying embedded control systems) and the Canoe upper computer software corresponding to the vector test bench (a hardware and software platform for developing, testing and verifying embedded control systems), when the tester performs manual ECU testing, he will rely on the upper computer software corresponding to these test benches to perform the corresponding ECU test. Therefore, it is necessary to encapsulate the corresponding functions that testers use these host computers to test and obtain a standard user-level test interface, so that testers can call the corresponding functions of the required host computer interface through the user-level test interface, and achieve the purpose of using the host computer software to complete the ECU test task through scripts.
[0056] In this step, the user layer test interface is provided to the tester for direct use. The tester does not need to pay attention to the implementation of the source code. The test script business logic is developed by calling the user layer test interface to obtain the developed test script. When testing the target function of the ECU, the target interface of the target host computer software can be called through the user layer test interface in the test script to test the target function.
[0057] Further, optionally, the user layer test interface is obtained in the following manner: obtaining interfaces corresponding to multiple host computer software respectively; for each host computer software, creating a first application object corresponding to the software identifier of the host computer software according to the software identifier of the host computer software; based on the test business scenario, mapping the attribute behavior corresponding to the first application object to a first behavior function corresponding to the interface function of the host computer software, and encapsulating the first behavior function as a basic step function to obtain the user layer test interface.
[0058] Exemplarily, for multiple host computer software, interfaces corresponding to multiple host computer software can be summarized, and for each host computer software, according to the software identification of the host computer software, a first application object corresponding to the software identification of the host computer software is mapped and created, and the first application object is, for example, an application object in a win32 library, wherein the win32 library is a set of application programming interfaces (Application Programming Interface, API) for interacting with the Windows operating system. Based on the test business scenario, the behavior corresponding to the first application object is mapped to the first behavior function corresponding to the interface function of the host computer software, and the first behavior function is encapsulated as a basic step function to obtain a user layer test interface, wherein the user layer test interface includes a basic step function interface, and the basic step function interface includes, for example, a read variable function interface for reading the variable value (i.e., signal) of a variable and a write variable function interface for modifying the variable value (i.e., signal) of a variable, and the read variable function interface is, for example, represented by api_read_variables(), and the write variable function interface is, for example, represented by api_write_variables(). For example, if the target function of the ECU is to open the car window, the user-level test interface api_write_variables() can be called to input the variables and variable values corresponding to opening the car window into the interface, and the COM interface corresponding to the target function of the host computer software can be called through the interface, so that the target function can be tested through the test bench. The user-level test interface can also include other operation method interfaces for operating the host computer software, such as user-level test interfaces corresponding to a series of operations such as opening the host computer, closing the host computer, creating experiments for the host computer, and loading experiments, for testers to use in automated testing. Optionally, since the host computer software is provided by different manufacturers, the operation methods of multiple host computers can be modularly packaged. For example, the COM interface of the host computer software Controldesk can be packaged as the Controldesk module code, and the COM interface of the host computer software Canoe can be packaged as the Canoe module code.
[0059] The test method provided by the embodiment of the present invention determines the target host computer software when receiving the test instruction for instructing to test the target function of the ECU. The target host computer software is the software running on the target test bench for testing the ECU; the target interface of the target host computer software is called through the user layer test interface in the test script to test the target function. Among them, the user layer test interface is obtained by encapsulating the interface functions of the interfaces corresponding to different host computer software according to the test business scenario, and can be compatible with the scheduling of different host computer software. It can make the test personnel change from having to pay attention to the use of different host computer software and the description of the corresponding interface to only needing to understand a set of standard user layer test interfaces, so as to realize the scheduling of different test benches through different host computer software, thereby completing the test of the target function of the ECU, which can greatly improve the test efficiency of the ECU, reduce the later maintenance cost of the test script, and reduce the learning cost required for the test personnel to perform ECU automated testing.
[0060] Based on the above embodiment, in a possible implementation manner, a test environment corresponding to the test method provided in the embodiment of the present invention can be built by the following five steps:
[0061] Step 1: The method of the embodiment of the present invention is developed based on a python (a programming language) environment to meet the test requirements, and a python script can be used to replace the tester to implement the manual use case scenario to better meet the execution of the script. The method of the embodiment of the present invention needs to be run in a python environment, so a python environment can be built.
[0062] Step 2: Install different host computer software in the test environment to ensure that the interface of the host computer software can be successfully called when testing the target function of the ECU, thereby ensuring normal data interaction between the electronic device executing the embodiment of the method and the host computer. Specific host computer software includes, for example, Controldesk, Canoe, and TSMaster.
[0063] Step 3. Install the third-party libraries that the host computer software depends on, such as downloading the third-party libraries of the host computer software that needs to be called, and configuring the downloaded third-party libraries to the site-packages (a python directory for storing third-party libraries and modules installed through package management tools) folder of the Python environment to ensure that when calling the interface of the host computer software, the function methods encapsulated by the third-party libraries can be used normally.
[0064] Step 4: Build an operating environment for controller area network (CAN) signals, CAN with Flexible Data-Rate (CAN FD) signals, and local interconnect network (LIN) signals to provide CAN signals, CAN FD signals, and LIN signals. Among them, for CAN signals, it is necessary to download and install the CANLIB (a programming library for controlling and operating CAN bus) driver, and put the dynamic link library (DLL) file under the CANLIB folder into the corresponding directory of the operating system; for example, if the operating system is a windows (a graphical user interface operating system) operating system, the dll file under the CANLIB folder can be placed in the system32 (an important system folder in the Windows operating system) and syswow64 (an important folder in the Windows operating system) directories; for CANFD signals and LIN signals, you can download a third-party library that supports sending CANFD signals and LIN signals and the corresponding usbcan.dll file (a dynamic link library file); you can download the TSMASTER.PY module used to provide the interface and example of the TSMaster host computer sending signals; build the hardware environment required for the ECU, and complete the wiring harness connection of the corresponding test bench and the test bench controller (ie, ECU) and the host computer (such as a computer used for testing).
[0065] Step 5. Install the software corresponding to the test method provided by the embodiment of the present invention. In the python environment mentioned in step 1, put the software corresponding to the test method provided by the embodiment of the present invention into the site-packages folder; import the controldesk_modular module of the encapsulated host computer software Controldesk into the site-packages folder; import the canoe_modular module of the encapsulated host computer software Canoe into the site-packages folder; import the tsmaster_modular module of the encapsulated host computer software TSMaster into the site-packages folder; testers can select different host computer modules to develop test scripts by modifying the configuration file parameters according to different test benches.
[0066] On the basis of the above embodiments, considering the expansion of the use of new host computer software for automated testing of ECU, in a possible implementation mode, for the host computer software to be connected, the mapping relationship between the software identifier of the host computer software to be connected and the interface of the host computer software to be connected is obtained; according to the mapping relationship, the software identifier and interface of the host computer software to be connected are extracted; the software identifier and interface of the host computer software to be connected are injected into the basic step function, and a second application object corresponding to the software identifier of the host computer software to be connected is created; based on the test business scenario corresponding to the host computer software to be connected, the attribute behavior corresponding to the second application object is mapped to the second behavior function corresponding to the interface function of the host computer software to be connected, and the second behavior function is encapsulated as the basic step function to complete the encapsulation of the interface function of the host computer software to be connected.
[0067] Exemplarily, the host computer software to be connected is a new host computer software to be used. The mapping relationship between the software identifier of the host computer software to be connected and the interface of the host computer software to be connected can be maintained through a configuration file. Therefore, the embodiment of the present invention can obtain the mapping relationship from the configuration file, extract the software identifier and interface of the host computer software to be connected, inject the software identifier and interface of the host computer software into the basic step function, and complete the interface function encapsulation of the host computer software to be connected. Figure 3 A flowchart for encapsulating the interface function to be connected to the host computer software provided by an embodiment of the present invention, such as Figure 3 As shown, the process of encapsulating the interface function to be connected to the upper computer software may include the following steps:
[0068] S301, obtaining a property interface file of the upper computer software to be connected.
[0069] S302, check whether the attribute interface file is standardized, if not, execute step S303; if yes, execute step S304.
[0070] S303: Output the cause of the error.
[0071] S304: Acquire a COM interface file including a mapping relationship between a software identifier of the host computer software to be connected and an interface of the host computer software to be connected.
[0072] It can be understood that the tester has established the COM interface file in advance according to the mapping relationship rules, so the COM interface file can be obtained.
[0073] S305, importing the COM interface file.
[0074] In this step, for example, the COM interface file may be imported through the software registration function register_software_tools.
[0075] S306: extract the specific software identifier of the host computer software to be connected (such as the name of the host computer software to be connected) and the COM interface in the COM interface file.
[0076] S307: Inject the software identification and COM interface behavior of the upper computer software to be connected into the basic extension class.
[0077] S308: Map the basic extension class object to the second application object of the win32 library.
[0078] In this step, the second application object may be verified, and if the verification fails, the error reason is output.
[0079] S309: Map the attribute behavior corresponding to the second application object to a second behavior function corresponding to the interface function to be connected to the upper computer software.
[0080] S310, encapsulating the second behavior function into a basic step function, and completing the interface function encapsulation to be connected to the upper computer software.
[0081] In this step, it can be checked whether each second behavior function has completed the mapping. If so, the second behavior function is encapsulated as a basic step function to complete the interface function encapsulation to be connected to the upper computer software; if not, the error reason is output.
[0082] For this embodiment, it can be understood that the access to the host computer software corresponding to the new test bench can be completed by rapid horizontal expansion according to the test bench to be used according to business needs, and this operation will not be significantly changed in the outer layer, that is, the interface layer provided to the user (that is, the user layer test interface). Therefore, for testers, when performing ECU automation testing through a new test bench, it is no longer necessary to pay attention to the interface function of the new host computer software. It is only necessary to provide the COM interface of the new host computer software and perform dynamic injection of the COM interface. The embodiment of the present invention maps the COM interface of the new host computer software to the specific implementation behavior function, and encapsulates the behavior function as a basic step function, and provides a user layer test interface to the outside.
[0083] Next, the specific user layer test interface is described in detail.
[0084] Based on the above embodiment, optionally, the user-layer test interface includes an initialization function interface, a preparation test function interface, a start test function interface and an end test function interface, wherein the initialization function interface is used to initialize the initial state and initial environment before the test; the preparation test function interface is used to encapsulate the test conditions, test properties and variables before the test; the start test function interface is used to implement the specific logic of the test steps and the diagnosis of the test results; the end test function interface is used to restore the test environment to the initial state.
[0085] Exemplarily, the user-level test interface is provided to the tester for direct calling to carry out the structured development of the test script, and the tester does not need to pay attention to the implementation of the source code. Specifically, the tester first calls the initialization function interface, such as represented by the init() function interface, through which some initial states and initial environments before the test can be initialized. Then the preparation test function interface is introduced, such as represented by the prepare_test() function interface, through which some necessary test conditions, necessary test attributes and variables before the test can be encapsulated. Then the start test function interface is introduced, such as represented by the start_test() function interface, through which the specific logic of the test steps and the diagnosis of the final test results can be implemented. Finally, the end test function interface is represented by the end_test() function interface, through which the test environment can be restored to the initial state.
[0086] Optionally, S203, calling the target interface of the target host computer software through the user layer test interface in the test script to test the target function, may further include: calling the target interface through the target user layer test interface in the start test function interface to test the target function, the target user layer test interface being the user layer test interface corresponding to the target function.
[0087] For example, if the target function is to open the car window, the target user layer test interface api_write_variables() in the user layer test interface can be called to input the variables and variable values corresponding to opening the car window into the interface, and the COM interface corresponding to the target function of the host computer software can be called through the interface, so that the target function can be tested through the test bench.
[0088] Based on the above embodiments, Figure 4 The following is a flow chart of the development of the business logic of the test script provided by an embodiment of the present invention, wherein the host computer software is Controldesk as an example. Figure 4 As shown, the development process of the business logic of the test script can include the following steps:
[0089] S401, calling the init() function interface to initialize the initial state and initial environment before the test, such as setting the initial state of the test bench power-on or test bench power-off.
[0090] S402. Call the prepare_test() function interface to encapsulate the test conditions, test properties and variables before the test, such as setting the test conditions required for the test, setting the initial values of some variable signal conditions required for the test, and some other variables that need to be set in advance, such as defining variables as unlock signals or lock signals, etc.
[0091] S403, calling the start_test() function interface to implement the specific logic of the test steps and diagnose the test results. Specifically, for example, the api_open_controldesk() function interface used to open the host computer software Controldesk can be called first to open Controldesk. After the interface is successfully called, if no abnormal situation occurs, Controldesk can be started and the display interface can be displayed to the tester.
[0092] S404, calling the api_load_project() function interface for loading the project path to activate the project path.
[0093] The tester can judge the function result of the function interface at the script level. If the activation is successful, the function interface returns a result with a Boolean value of true (True), and the result is recorded in the script's overall result list; if the activation fails, the function interface returns a result with a Boolean value of not True, and the result is recorded in the script's overall result list.
[0094] S405. After activating the project path, call the api_load_experiment() function interface for loading the experimental model to activate the experimental model under the project.
[0095] If the activation is successful, the function interface returns a result whose Boolean value is true (True), and the result is recorded in the script's overall result list; if the activation fails, the function interface returns a result whose Boolean value is not True, and the result is recorded in the script's overall result list.
[0096] S406: After the engineering path and the experimental model are activated, the variable signal can be operated to implement the specific logic of the test step.
[0097] Exemplarily, the api_read_variables() function interface can be called to read the signal of the variable at this time (i.e., the variable value), and the api_write_variables() function interface can be called to modify the signal of the variable, for example, the signal of the variable can be modified to the unlock signal set in step S402. When the unlock signal is successfully issued, the host computer software Controldesk will transmit the unlock signal to the corresponding ECU controller, and the hardware devices on the test bench, such as the rearview mirror, will be in the unfolded state, the taillights will flash, etc. Similarly, if the return result of the function interface of this step is not True, the test script will record the execution result of this step in the overall result list of the script, and the hardware devices on the test bench will not have any state changes.
[0098] S407. After the specific logic of the test step is implemented, the end_start() function interface is called to restore the test environment to the initial state, such as setting the signal of the variable to the original initial value.
[0099] Through the business logic development process of the above test script, testers no longer need to pay attention to the use of different host computer software and the description of the corresponding interfaces, but only need to understand a set of standard user-level test interfaces to schedule different test benches through different host computer software, thereby completing the test of the target functions of the ECU. This can greatly improve the test efficiency of the ECU, reduce the later maintenance cost of the test script, and reduce the learning cost required for testers when performing ECU automated testing.
[0100] Optionally, during the testing of the target function, a test log is output.
[0101] For example, during the process of testing the target function, the corresponding test log can be output for the specific test steps of the target function and saved locally, which is convenient for testers to trace the source of the problem and helps testers to develop the required scenario test scripts more efficiently and quickly.
[0102] Optionally, the target user layer test interface includes multiple ones, and the test method provided by the embodiment of the present invention may further include: storing the test result corresponding to each target user layer test interface; and determining the target test result of the target function according to the multiple test results.
[0103] It can be understood that in order to verify the authenticity of the test script results, a method for comparing the results can be designed. Therefore, a function of automatic assertion of script results can be provided to diagnose the final test results of the test script. Specifically, when the test script calls the API interface function, if a certain failed step occurs, the entire test script will be displayed as failed at the end. Only when all steps are executed successfully will the entire test script be displayed as successful at the end. In this embodiment, exemplarily, based on the function of automatic assertion of script results, the test results corresponding to each target user layer test interface are stored, so that the final target test result of the target function can be determined based on multiple test results.
[0104] On the basis of the above embodiments, considering that a method for providing a CAN signal or a CANFD signal is still needed, in one possible implementation manner, a signal identifier and a signal physical value corresponding to the bus signal to be sent are obtained, and the bus signal to be sent includes a CAN signal and / or a CANFD signal; the bus database file is parsed, and according to the signal identifier, a message identifier and message information corresponding to the bus signal to be sent are obtained, and the signal physical value is converted into binary data; the message identifier, message information and binary data are assembled to obtain the target bus data; and the target bus data is sent to the ECU.
[0105] It can be understood that this embodiment is used to facilitate testers to use CAN devices to send CAN signals or CANFD signals, wherein the devices include, for example, kvaser devices (a device for CAN bus), usbcan devices (a device for connecting CAN bus to a universal serial bus interface), or tscan devices (a CAN bus analysis tool). This embodiment, for example, encapsulates the standard function library related to the CAN bus, so that testers do not need to pay too much attention to the splicing of signals, but only need to simply input the physical value of the signal. Exemplarily, Figure 5 A flowchart of assembling bus signals provided by an embodiment of the present invention is as follows: Figure 5 As shown, the process of assembling the bus signal includes the following steps:
[0106] S501: Obtain a signal identifier and a signal physical value corresponding to a bus signal to be sent.
[0107] The bus signal to be sent is, for example, a CAN signal or a CANFD signal, and the signal identifier and signal physical value corresponding to the bus signal to be sent are, for example, input by a tester.
[0108] S502, parse the bus database file (ie, DBC file) to determine whether the parsing is successful. If the parsing fails, execute step S503; if the parsing is successful, execute S504 and steps after S504.
[0109] Exemplarily, the DBC file is parsed by calling a method provided by the CANtools library (a Python library for processing CAN data).
[0110] S503: Exit the analysis and return the reason for failure.
[0111] S504: Obtain a message identifier and message information corresponding to the bus signal to be sent according to the signal identifier, and convert the signal physical value into binary data.
[0112] In this step, if the acquisition of the message information fails, the reason for the failure in acquiring the message information may be returned.
[0113] S505: Assemble the message identifier, message information and binary data to obtain target bus data.
[0114] In this step, if the assembly data fails, the reason for the failure of the assembly data can be returned. After the target bus data is obtained through this step, the target bus data can be sent to the ECU.
[0115] This embodiment can automatically convert the signal physical value into binary data received by the CAN device, thereby greatly improving the efficiency of testers when using CAN signals or CANFD signals for testing.
[0116] The following are embodiments of the device of the present invention, which can be used to implement the method embodiments of the present invention. For details not disclosed in the device embodiments of the present invention, please refer to the method embodiments of the present invention.
[0117] Figure 6 This is a schematic diagram of the structure of a testing device provided by an embodiment of the present invention. Figure 6 As shown, the testing device 600 of the embodiment of the present invention includes: a receiving module 601, a determining module 602 and a testing module 603. Among them:
[0118] The receiving module 601 is used to receive a test instruction, where the test instruction is used to instruct to test a target function of the electronic control unit ECU.
[0119] The determination module 602 is used to determine the target host computer software, where the target host computer software is the software running on the target test bench for testing the ECU.
[0120] The test module 603 is used to call the target interface of the target host software through the user layer test interface in the test script to test the target function. The user layer test interface is obtained by encapsulating the interface functions of the interfaces corresponding to different host software according to the test business scenario.
[0121] Furthermore, the testing device 600 also includes an acquisition module (not shown in the figure), which is used to obtain a user-layer test interface in the following manner: obtaining interfaces corresponding to multiple host computer software respectively; for each host computer software, creating a first application object corresponding to the software identifier of the host computer software according to the software identifier of the host computer software; based on the test business scenario, mapping the attribute behavior corresponding to the first application object to a first behavior function corresponding to the interface function of the host computer software, and encapsulating the first behavior function as a basic step function to obtain a user-layer test interface.
[0122] Furthermore, the acquisition module is also used to: for the host computer software to be connected, obtain the mapping relationship between the software identifier of the host computer software to be connected and the interface of the host computer software to be connected; according to the mapping relationship, extract the software identifier and interface of the host computer software to be connected; inject the software identifier and interface of the host computer software into the basic step function, and create a second application object corresponding to the software identifier of the host computer software to be connected; based on the test business scenario corresponding to the host computer software to be connected, map the attribute behavior corresponding to the second application object to the second behavior function corresponding to the interface function of the host computer software to be connected, and encapsulate the second behavior function into the basic step function to complete the encapsulation of the interface function of the host computer software to be connected.
[0123] Furthermore, the test device 600 also includes a first processing module (not shown in the figure), which is used to: obtain a signal identifier and a signal physical value corresponding to the bus signal to be sent, the bus signal to be sent includes a controller area network CAN signal and / or a CAN signal with a variable data rate; parse the bus database file, and obtain a message identifier and message information corresponding to the bus signal to be sent according to the signal identifier, and convert the signal physical value into binary data; assemble the message identifier, message information and binary data to obtain the target bus data; and send the target bus data to the ECU.
[0124] Further, the determination module 602 is specifically used to: query the configuration file to determine the target host computer software, and the configuration file includes the software identifier of the target host computer software.
[0125] Furthermore, the user-layer test interface includes an initialization function interface, a preparation test function interface, a start test function interface and an end test function interface, wherein the initialization function interface is used to initialize the initial state and initial environment before the test; the preparation test function interface is used to encapsulate the test conditions, test properties and variables before the test; the start test function interface is used to implement the specific logic of the test steps and the diagnosis of the test results; the end test function interface is used to restore the test environment to the initial state.
[0126] Further, the test module 603 is specifically used to test the target function by calling the target interface through the target user layer test interface in the start test function interface, where the target user layer test interface is a user layer test interface corresponding to the target function.
[0127] Furthermore, the testing device 600 also includes an output module (not shown in the figure) for outputting a test log during the process of testing the target function.
[0128] Furthermore, the target user layer test interface includes multiple ones, and the test device 600 also includes a second processing module (not shown in the figure), which is used to: store the test results corresponding to each target user layer test interface; and determine the target test results of the target function based on the multiple test results.
[0129] The device of the embodiment of the present invention can be used to execute the technical solution of any of the above-mentioned method embodiments. Its implementation principle and technical effects are similar and will not be repeated here.
[0130] Based on the above embodiments, in a possible implementation manner, Figure 7 This is a schematic diagram of the structure of a testing device provided by another embodiment of the present invention. Figure 7 As shown, the test device 700 of the embodiment of the present invention may include: a host computer module 701, a system basic module 702, a basic expansion module 703, a system log module 704 and a system signal analysis module 705. Among them:
[0131] The host computer module 701 is used to encapsulate the ECU test functions commonly used by testers into the modules of the corresponding host computer software, so that the testers can call the required corresponding functions of the host computer through the user layer test interface; the host computer module 701 may include: a host computer configuration submodule 7011, used to configure the target host computer software required for ECU testing; a host computer operation submodule 7012, used to call the interfaces of different host computer software; a host computer step encapsulation submodule 7013, used to encapsulate the interfaces of different host computer software into a unified behavior function interface.
[0132] The system basic module 702 is used to determine the operating structure of the user layer test interface and encapsulate each user layer test interface; the system basic module 702 may include: an operating structure dependency submodule 7021, which is used to execute in sequence the initialization function interface, the preparation test function interface, the start test function interface and the end test function interface when calling the user layer test interface; a basic step encapsulation submodule 7022, which is used to encapsulate each user layer test interface.
[0133] The basic extension module 703 is used to expand and complete the access of the host computer software corresponding to the new test bench; the basic extension module 703 may include: an interface file parsing submodule 7031, used to parse the COM interface file containing the mapping relationship between the software identifier of the host computer software to be connected and the interface of the host computer software to be connected; a class behavior mapping injection submodule 7032, used to inject the software identifier and COM interface behavior of the host computer software to be connected into the basic extension class, map the basic extension class object to the second application object, and map the attribute behavior corresponding to the second application object to the second behavior function corresponding to the interface function of the host computer software to be connected; a conventional behavior step encapsulation submodule 7033, used to encapsulate the second behavior function into a basic step function to complete the interface function encapsulation of the host computer software to be connected.
[0134] The system log module 704 is used to output logs and provide automatic assertion functions for test script execution results; the system log module 704 may include: a log recording submodule 7041, which is used to provide log output functions; and a log assertion submodule 7042, which is used to provide automatic assertion functions for test script execution results.
[0135] The system signal analysis module 705 is used to analyze and obtain the target bus data according to the signal identifier and signal physical value corresponding to the bus signal to be sent; the system signal analysis module 705 may include: a signal analysis submodule 7051, used to parse the bus database file, obtain the message identifier and message information corresponding to the bus signal to be sent according to the signal identifier, and convert the signal physical value into binary data, assemble the message identifier, message information and binary data to obtain the target bus data; a signal operation submodule 7052, used to send the target bus data to the ECU through the CAN device.
[0136] The device of the embodiment of the present invention can be used to execute the technical solution in any of the above-mentioned method embodiments. Its implementation principle and technical effects are similar and will not be repeated here.
[0137] Figure 8 This is a schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. Figure 8 As shown, the electronic device 800 may include: at least one processor 801 and a memory 802 .
[0138] The memory 802 is used to store programs. Specifically, the programs may include program codes, and the program codes include computer-executable instructions.
[0139] The memory 802 may include a high-speed random access memory (RAM), and may also include a non-volatile memory (non-volatile memory), such as at least one disk memory.
[0140] The processor 801 is used to execute the computer-executable instructions stored in the memory 802 to implement the test method described in the aforementioned method embodiment. Among them, the processor 801 may be a central processing unit (CPU), or an application-specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiment of the present invention. Specifically, when implementing the test method described in the aforementioned method embodiment, the electronic device may be, for example, an electronic device with processing functions such as a server.
[0141] Optionally, the electronic device 800 may further include a communication interface 803. In a specific implementation, if the communication interface 803, the memory 802 and the processor 801 are implemented independently, the communication interface 803, the memory 802 and the processor 801 may be interconnected through a bus and communicate with each other. The bus may be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc., but it does not mean that there is only one bus or one type of bus.
[0142] Optionally, in a specific implementation, if the communication interface 803, the memory 802 and the processor 801 are integrated on a chip, the communication interface 803, the memory 802 and the processor 801 can communicate through an internal interface.
[0143] The present invention also provides a computer-readable storage medium, in which computer program instructions are stored. When a processor executes the computer program instructions, the above test method is implemented.
[0144] The present invention also provides a computer program product, comprising a computer program, which implements the above testing method when executed by a processor.
[0145] The computer-readable storage medium mentioned above can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read only memory (EEPROM), erasable programmable read only memory (EPROM), programmable read only memory (PROM), read only memory (ROM), magnetic storage, flash memory, magnetic disk or optical disk. The readable storage medium can be any available medium that can be accessed by a general or special-purpose computer.
[0146] An exemplary readable storage medium is coupled to the processor so that the processor can read information from the readable storage medium and write information to the readable storage medium. Of course, the readable storage medium can also be an integral part of the processor. The processor and the readable storage medium can be located in a dedicated integrated circuit. Of course, the processor and the readable storage medium can also exist in the test device as discrete components.
[0147] Those skilled in the art can understand that all or part of the steps of implementing the above-mentioned method embodiments can be completed by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When the program is executed, the steps of the above-mentioned method embodiments are executed; and the aforementioned storage medium includes: ROM, RAM, disk or optical disk and other media that can store program codes.
[0148] Finally, it should be noted that the above embodiments are only preferred embodiments for fully illustrating the present invention, and the protection scope of the present invention is not limited thereto. Any equivalent substitution or change made by a person skilled in the art based on the present invention is within the protection scope of the present invention.
Claims
1. A testing method, characterized in that: include: Receiving a test instruction, wherein the test instruction is used to instruct to test a target function of an electronic control unit ECU; Determine target host computer software, where the target host computer software is software running on a target test bench for testing the ECU; The target interface of the target host computer software is called through the user layer test interface in the test script to test the target function. The user layer test interface is obtained by encapsulating the interface functions of the interfaces corresponding to different host computer software according to the test business scenario.
2. The testing method according to claim 1, characterized in that: The user layer test interface is obtained by: Get the interfaces corresponding to multiple host computer software respectively; For each host computer software, a first application object corresponding to the software identifier of the host computer software is created according to the software identifier of the host computer software; based on the test business scenario, the attribute behavior corresponding to the first application object is mapped to a first behavior function corresponding to the interface function of the host computer software, and the first behavior function is encapsulated as a basic step function to obtain the user layer test interface.
3. The testing method according to claim 2, characterized in that: Also includes: For the host computer software to be connected, obtaining a mapping relationship between the software identifier of the host computer software to be connected and the interface of the host computer software to be connected; According to the mapping relationship, extract the software identifier and interface of the upper computer software to be connected; The software identification and interface of the host computer software are injected into the basic step function, and a second application object corresponding to the software identification of the host computer software to be connected is created; based on the test business scenario corresponding to the host computer software to be connected, the attribute behavior corresponding to the second application object is mapped to the second behavior function corresponding to the interface function of the host computer software to be connected, and the second behavior function is encapsulated as the basic step function to complete the encapsulation of the interface function of the host computer software to be connected.
4. The testing method according to any one of claims 1 to 3, characterized in that: Also includes: Acquire a signal identifier and a signal physical value corresponding to a bus signal to be sent, wherein the bus signal to be sent includes a controller area network (CAN) signal and / or a CAN signal with a variable data rate; Parse the bus database file, obtain the message identifier and message information corresponding to the bus signal to be sent according to the signal identifier, and convert the signal physical value into binary data; Assembling the message identifier, the message information and the binary data to obtain target bus data; The target bus data is sent to the ECU.
5. The testing method according to any one of claims 1 to 3, characterized in that: The step of determining the target host computer software includes: A configuration file is queried to determine the target host computer software, wherein the configuration file includes a software identifier of the target host computer software.
6. The testing method according to any one of claims 1 to 3, characterized in that: The user-layer test interface includes an initialization function interface, a preparation test function interface, a start test function interface and an end test function interface, wherein the initialization function interface is used to initialize the initial state and initial environment before the test; the preparation test function interface is used to encapsulate the test conditions, test properties and variables before the test; the start test function interface is used to implement the specific logic of the test steps and the diagnosis of the test results; the end test function interface is used to restore the test environment to the initial state environment.
7. The testing method according to claim 6, characterized in that: The method of calling the target interface of the target host computer software through the user layer test interface in the test script to test the target function includes: The target interface is called through the target user layer test interface in the start test function interface to test the target function, and the target user layer test interface is a user layer test interface corresponding to the target function.
8. The testing method according to claim 7, characterized in that: Also includes: During the process of testing the target function, a test log is output.
9. The testing method according to claim 7, characterized in that: The target user layer test interface includes multiple ones, and the method further includes: Storing the test result corresponding to each of the target user layer test interfaces; A target test result of the target function is determined based on the multiple test results.
10. A testing device, characterized in that: include: A receiving module, used for receiving a test instruction, wherein the test instruction is used for instructing to test a target function of an electronic control unit ECU; A determination module, used for determining target host computer software, wherein the target host computer software is software running on a target test bench for testing the ECU; The test module is used to call the target interface of the target host computer software through the user layer test interface in the test script to test the target function. The user layer test interface is obtained by encapsulating the interface functions of the interfaces corresponding to different host computer software according to the test business scenario.
11. An electronic device, characterized in that: include: A processor, and a memory communicatively connected to the processor; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory to implement the testing method according to any one of claims 1 to 9.
12. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer program instructions, and when the computer program instructions are executed, the testing method according to any one of claims 1 to 9 is implemented.
13. A computer program product, comprising a computer program, characterized in that When the computer program is executed, the testing method according to any one of claims 1 to 9 is implemented.