Use Case Generation Method, Device, Computer-Readable Storage Medium, and Electronic Device

By analyzing the object code, SCD API test cases are generated, which solves the problem of inefficiency in testers' SCD API testing and improves testing efficiency.

CN114510412BActive Publication Date: 2025-07-22RUIJIE NETWORKS CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111641273.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-29
Publication Date
2025-07-22
Estimated Expiration
2041-12-29

AI Technical Summary

Technical Problem

In SCD API testing, testers need to spend a lot of effort to analyze APIs, attributes, and data types, incomprehensible and efficient, resulting in inefficient product testing.

Method used

By analyzing the object code, obtaining API call examples and business dependencies, generating CLI configuration and traffic data, generating SCD API function and parameter call logs based on this information, and then generating test cases.

Benefits of technology

It greatly reduces the professional requirements of testers, saves manual analysis and script writing work, and significantly improves testing efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114510412B_ABST
    Figure CN114510412B_ABST
Patent Text Reader

Abstract

The present application discloses a use case generation method, apparatus, system and electronic device. The method includes: analyzing a target code to obtain application programming interface (API) call examples and business dependencies, generating command line interface (CLI) configurations and traffic data for the API call examples; generating corresponding SCD API function and parameter call logs according to the CLI configurations issued to the device under test; generating the relationship between the CLI and the SCD API functions and the relationship between the business and the traffic according to the CLI configurations, traffic data, use case information, and SCD API function and parameter call logs; generating a current test case according to the CLI execution order, API call examples, the relationship between the CLI and SCD API parameters, and the relationship between the business and traffic data. Therefore, the professional requirements for testers in SCD API testing are greatly reduced, and the work of manual analysis and script writing by testers is eliminated, greatly improving the testing efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of communications, and in particular, to a use case generation method, apparatus, computer-readable storage medium, and electronic device. Background Art

[0002] With the development of network technology, as an important type of network device, switch technology is also undergoing rapid changes. Currently, Switch Chip Driver (SCD) has emerged as a chip for switches to provide a unified API upward and interface with different ASICs downward, enabling SONiC (Software for Open Networking in the Cloud) and upper-layer APPs to run on different hardware platforms.

[0003] However, in the product development based on SCD, since the SCD header file only provides the SCD Header definition, chip manufacturers need to re-implement it and provide binary files for chip users. However, during the testing process of products using this chip, testers need to spend a great deal of effort analyzing SCD APIs, attributes, and data types, analyzing the relationship between SCD APIs and services, analyzing service scenarios, and constructing verification traffic packets. Moreover, there is a gap in understanding and efficiency between the testing of SCD APIs and the development and implementation of SCD APIs. There are confusions regarding the usage and call order of SCD APIs, and it is impossible to effectively ensure the quick verification of the integrity of SCD APIs, which greatly affects the testing efficiency of products based on SCD. Summary of the Invention

[0004] Embodiments of this application provide a use case generation method, apparatus, computer-readable storage medium, and electronic device to solve the defect of low testing efficiency for SCD APIs in the prior art.

[0005] To achieve the above objective, embodiments of this application provide a use case generation method, including:

[0006] Analyzing the target code to obtain application programming interface (API) call examples and service dependencies;

[0007] Generating command-line interface (CLI) configurations and traffic data for the API call examples;

[0008] Generating corresponding SCD API function and parameter call logs according to the CLI configurations sent to the device under test;

[0009] Generate the relationship between the CLI and SCD API functions and the relationship between the service and traffic based on the CLI configuration, traffic data, use case information, SCD API function, and parameter call logs;

[0010] Generate the current test case according to the CLI execution order, API call examples, the relationship between CLI and SCD API parameters, and the relationship between the service and traffic data.

[0011] An embodiment of the present application also provides a use case generation device, including:

[0012] An analysis module for analyzing the target code to obtain application programming interface (API) call examples and service dependencies;

[0013] A first generation module for generating a command line interface (CLI) configuration and traffic data for the API call examples;

[0014] A second generation module for generating corresponding SCD API function and parameter call logs according to the CLI configuration sent to the device under test.

[0015] A third generation module for generating the relationship between the CLI and SCD API functions and the relationship between the service and traffic based on the CLI configuration, traffic data, use case information, SCD API function, and parameter call logs;

[0016] A use case generation module for generating the current test case according to the CLI execution order, API call examples, the relationship between CLI and SCD API parameters, and the relationship between the service and traffic data.

[0017] An embodiment of the present application also provides a computer-readable storage medium, on which a computer program executable by a processor is stored, wherein when the program is executed by the processor, it implements the use case generation method provided by the embodiment of the present application.

[0018] An embodiment of the present application also provides an electronic device, including:

[0019] A memory for storing programs;

[0020] A processor for running the program stored in the memory to execute the use case generation method provided by the embodiment of the present application.

[0021] The test case generation method, device, computer-readable storage medium, and electronic device provided by the embodiments of the present application analyze the target code to obtain call examples and business dependencies, generate CLI configurations and traffic data, and then generate the SCD API function and parameter call logs based on the target device with the CLI configuration issued. Furthermore, the relationships between this information are generated based on the above information, and finally, the current test case is generated. Therefore, the professional requirements for testers in SCD API testing are greatly reduced, and the work of manual analysis and script writing by testers is eliminated, greatly improving the test efficiency.

[0022] The above description is only an overview of the technical solution of the present application. In order to be able to understand the technical means of the present application more clearly, it can be implemented in accordance with the content of the specification. And in order to make the above and other purposes, features, and advantages of the present application more obvious and understandable, the specific embodiments of the present application are specifically exemplified below. BRIEF DESCRIPTION OF THE DRAWINGS

[0023] By reading the detailed description of the preferred embodiments below, various other advantages and benefits will become clear to those of ordinary skill in the art. The drawings are only for the purpose of showing the preferred embodiments and are not considered to be a limitation of the present application. And throughout the drawings, the same reference numerals are used to represent the same components. In the drawings:

[0024] Figure 1 It is a schematic diagram of the application scenario of the test case generation solution provided by the embodiments of the present application;

[0025] Figure 2 It is a flowchart of an embodiment of the test case generation method provided by the present application;

[0026] Figure 3 It is a schematic structural diagram of an embodiment of the test case generation device provided by the present application;

[0027] Figure 4 It is a schematic structural diagram of an embodiment of the electronic device provided by the present application. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0028] The exemplary embodiments of the present disclosure will be described in more detail below with reference to the drawings. Although the exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided so that the present disclosure can be more thoroughly understood and the scope of the present disclosure can be fully conveyed to those skilled in the art.

[0029] The solution provided by the embodiments of the present application can be applied to any device or system with the ability to generate test cases, etc. Figure 1Schematic diagram of the application scenario of the use case generation solution provided by the embodiments of the present application Figure 1 The scenario shown is only one of the examples of the scenarios where the technical solution of the present application can be applied.

[0030] With the development of network technology, as an important type of network device, switch technology is also changing with each passing day. Currently, Switch Chip Driver (SCD) has emerged as the chip of the switch to provide a unified API upward and interface with different ASICs downward, enabling SONiC (Software for Open Networking in the Cloud) and upper-layer APPs to run on different hardware platforms.

[0031] For example, as shown in Figure 1 In the operating system part, there is an SCD layer, which interfaces with the control stack upward. Various APIs can be set in the control stack, especially the core API for implementing basic forwarding operations. Downward, it can interface with various adapters, and these adapters can be various compatible SCD adapters, through which it can interface with the hardware.

[0032] In the existing SCD specification, the SCD APIs in the control stack can include three types: mandatory functions, which can be the core APIs for the basic forwarding operations required by the control stack docked by SCD. All adapter implementations must support these functions; optional functions, which can be a set of additional functions defined in compatible SCD adapter implementations but not required. They can enable non-core forwarding functions in a standard manner, and only the control stack implementations using them require them; user-defined functions, which can be a set of additional functions neither defined nor required by compatible SCD adapter implementations.

[0033] Therefore, in the prior art, an SCD-RTF (Remote Testing Framework) test framework customized for SCD APIs has been proposed, which realizes function-level interface testing through IDL (Interface Description Language) and RPC (remote procedure call) technologies, and solves the problem of difficult online service testing of chip drivers. However, chip driver testing generally has more offline or unit tests, insufficient scenario test verification, and cannot call remote services like local calls to effectively and accurately supplement online service scenario testing and verify the integration of services and drivers online, thereby enhancing the software quality of chip drivers.

[0034] In the product development based on SCD, since the SCD header file only provides the SCD Header definition, it is usually necessary to re-implement it and provide a binary file for chip users. However, during the testing process of the products using this chip, testers need to spend a great deal of effort analyzing the SCD API, attributes, and data types, analyzing the relationship between the SCD API and the business, analyzing the business scenarios, and constructing verification traffic messages. Moreover, there is a gap in understanding and efficiency between the testing of the SCD API and its development and implementation. There are confusions about the usage and call order of the SCD API, and it is impossible to effectively ensure the quick verification of the integrity of the SCD API, which greatly affects the testing efficiency of the products based on SCD.

[0035] Therefore, in the embodiments of this application, a test case generation method is proposed. In this generation method, the code version corresponding to the network device can be obtained from the code server, and corresponding recognition rules can be formulated according to the code characteristics. The code static analysis is carried out using the established rules to obtain API call examples, the relationship between the CLI and the business, and the business dependency relationship, and the analysis results are stored in the database analysis record module.

[0036] For example, the code can be statically analyzed first to obtain the composition of API call examples, the relationship between the CLI and the business, and the business dependency relationship. Specifically, for example, through traversing the abstract syntax tree of the business code, corresponding recognition rules can be formulated according to the characteristics of the SCD API, SCD API attributes, and SCD API data types to obtain API call examples. Through traversing the CLI code, the characteristics of the CLI framework are refined, and recognition rules are customized to obtain the relationship between the CLI and the business; through traversing the abstract syntax trees of SCD and business code, the characteristics of the SCD business are refined, and recognition rules are formulated to obtain the business dependency relationship.

[0037] In the embodiments of this application, a test environment can be composed of an execution server and the network device under test. After determining the API call examples and business dependency relationship as above. The execution server can send CLI configurations and traffic data to the test target device through automated scripts or manual triggering, etc., so as to collect the log information on the server and transfer this information and the test case information to, for example, the test case dynamic analysis module. Then, the network device under test can configure the corresponding log level initially to trigger the call logs of the corresponding SCD API functions and parameters according to the sent CLI configurations, so that the log collection on the network device under test uploads these logs to the test case dynamic analysis module.

[0038] After that, the CLI configuration, traffic data, and use case information can be configured, and the logs of SCD API functions and parameter calls can be invoked. For example, through a rule engine, the relationship between the CLI and SCD API functions / parameters can be extracted and stored in the database analysis record module.

[0039] After that, based on the database analysis record information, the execution order of SCD API use cases can be generated using the CLI execution order. Using API call examples, the attributes and data types of SCD API can be generated. Using the relationship between the CLI and SCD API parameters, the SCD API data type parameter configuration can be generated. Using the relationship between the service and traffic, the SCD API use case traffic configuration can be generated. Then, according to the SCD-RTF framework template, the above information can be combined into a new use case, that is, the current test case.

[0040] Therefore, according to the embodiments of the present application, after obtaining the current test case, the newly generated current test case can also be sent to, for example, the server where SCD-RTF is located, and the newly generated current test case can be executed through SCD-RTF. As a result, the target device under test receives the SCD API call of the newly generated current test case and can generate the corresponding SCD API call log.

[0041] According to the identification information of SCD-RTF and the test case, such as tags, the previous test case before the generation of the current test case can be identified, and the function call log can be parsed and compared to calculate the similarity. If the similarity reaches a predetermined threshold, it can be determined that the current test case is qualified; otherwise, it is judged as failed.

[0042] Therefore, according to the use case generation scheme of the embodiments of the present application, by analyzing the target code to obtain call examples and business dependencies, generating CLI configurations and traffic data, and then generating the relationship between these information based on the SCD API function and parameter call logs generated by the target device with the CLI configuration, and finally generating the current test case. Therefore, the professional requirements for testers in SCD API testing are greatly reduced, and the work of testers manually analyzing and writing scripts is eliminated, greatly improving the testing efficiency.

[0043] Figure 2 It is a flowchart of an embodiment of the use case generation method provided by the present application. As Figure 2 shown, the use case generation method may include the following steps:

[0044] S201, analyze the target code to obtain the application programming interface (API) call examples and business dependencies.

[0045] In the embodiment of the present application, static analysis can be performed on the code in step S201 to obtain the composition of API call examples, CLI and business relationships, and business dependencies. Specifically, the target code can be obtained from various code servers storing the code, or the tester can manually upload the code as the target code. Thus, in step S201, for example, by traversing the business code abstract syntax tree, corresponding recognition rules can be formulated according to the characteristics of the SCD API, SCD API attributes, and SCD API data types to obtain API call examples. By traversing the CLI code, the characteristics of the CLI framework are refined, and recognition rules are customized to obtain the CLI and business relationships; by traversing the SCD and business code abstract syntax trees, the SCD business characteristics are refined, and recognition rules are formulated to obtain business dependencies.

[0046] S202, generate a command-line interface CLI configuration and traffic data for the API call example.

[0047] After obtaining the API call example in step S201, in step S202, the CLI configuration and traffic data can be generated according to the API call example obtained in step S201 from, for example, a database storing various information recorded during the execution of use cases by an execution server storing the SCD-PTF framework.

[0048] S203, generate corresponding SCD API function and parameter call logs according to the CLI configuration sent to the device under test.

[0049] S204, generate the relationship between the CLI and the SCD API function and the relationship between the business and the traffic according to the CLI configuration, traffic data, use case information, and SCD API function and parameter call logs.

[0050] In step S203, the CLI configuration generated by, for example, an automated script or manual trigger can be sent to the device under test, such as the network device under test, to generate corresponding SCD API functions and corresponding parameter call logs. For example, the API sends the CLI configuration and traffic data to the test target device by means of an automated script or manual trigger, etc., so that the log information on the server can be collected to transfer this information and the use case information to, for example, the use case dynamic analysis module. Then, the device under test can configure the corresponding log level initially to trigger the corresponding SCD API function and parameter call logs according to the sent CLI configuration, so that the logs can be uploaded to the use case dynamic analysis module through log collection on the device under test.

[0051] Thus, in step S204, based on the SCD generated in step S203, as well as the SCD API function and parameter call logs, the relationship between the CLI and the SCD API function / parameters can be extracted through, for example, a rule engine, and it can be stored in, for example, a database analysis record module.

[0052] S205. Generate the current test case according to the CLI execution order, API call examples, the relationship between the CLI and SCD API parameters, and the relationship between the service and traffic data.

[0053] Based on the database analysis record information, the SCD API use case execution order can be generated using the CLI execution order. The attributes and data types of the SCD API can be generated using the API call examples. The SCD API data type parameter configuration can be generated using the relationship between the CLI and SCD API parameters. The SCD API use case traffic configuration can be generated using the relationship between the service and traffic. Then, according to the SCD-RTF framework template, the above information can be combined into a new use case, that is, the current test case.

[0054] Therefore, according to the embodiments of the present application, after obtaining the current test case, the newly generated current test case can also be sent to, for example, the server where the SCD-RTF is located, and the newly generated current test case is executed through the SCD-RTF, so that the target device under test receives the SCD API call of the newly generated current test case and can generate the corresponding SCD API call log.

[0055] In addition, the method according to the embodiments of the present application may further include: determining the previous test case executed on the server for executing the test case before the current test case according to the identifier of the current test case; calculating the similarity of the function call logs of the current test case and the previous test case; and determining the pass degree of the current test case according to the similarity.

[0056] Therefore, in the embodiments of the present application, after generating the current test case, the previous test case before the generation of the current test case can also be identified according to the SCD-RTF and the identifier information of the current test case, such as a label, and the function call logs are parsed and compared to calculate the similarity. If the similarity reaches a predetermined threshold, it can be determined that the current test case is qualified, otherwise it is determined to fail.

[0057] According to the use case generation solution of the embodiments of the present application, call examples and business dependencies are obtained by analyzing the target code. CLI configurations and traffic data are generated based on the business dependencies. Furthermore, based on the SCD API functions and parameter call logs generated by the target device with the CLI configuration issued, the relationships between this information are generated, and finally the current test case is generated. Therefore, the professional requirements for testers in SCD API testing are greatly reduced, and the work of manual analysis and script writing by testers is eliminated, greatly improving the testing efficiency.

[0058] Figure 3 FIG. 4 is a schematic structural diagram of an embodiment of a use case generation device provided by the present application, which can be used to execute the method steps as Figure 2 shown. As Figure 3 shown, the use case generation device may include: an analysis module 31, a first generation module 32, a second generation module 33, a third generation module 34, and a use case generation module 35.

[0059] The analysis module 31 may be used to analyze the target code to obtain application programming interface (API) call examples and business dependencies.

[0060] In the embodiments of the present application, the analysis module 31 may perform static analysis on the code to obtain the composition of API call examples, CLI and business relationships, and business dependencies. Specifically, the target code may be obtained from various code servers storing the code, or the tester may also manually upload the code as the target code. Thus, for example, through traversing the business code abstract syntax tree, corresponding recognition rules are formulated according to the characteristics of the SCD API, SCD API attributes, and SCD API data types to obtain API call examples. Through traversing the CLI code, the characteristics of the CLI framework are refined, and recognition rules are customized to obtain the CLI and business relationships; through traversing the SCD and business code abstract syntax trees, the SCD business characteristics are refined, and recognition rules are formulated to obtain business dependencies.

[0061] The first generation module 32 may be used to generate command line interface (CLI) configurations and traffic data for the API call examples.

[0062] After the analysis module 31 obtains the API call examples, the first generation module 32 may generate CLI configurations and traffic data from, for example, a database storing various information recorded during the execution of use cases by an execution server of the SCD-PTF framework according to the API call examples obtained in step S201.

[0063] The second generation module 33 can be used to generate corresponding SCDAPI functions and parameter call logs according to the CLI configuration sent to the target device under test.

[0064] The third generation module 34 can be used to generate the relationship between the CLI and the SCD API functions and the relationship between the service and the traffic according to the CLI configuration, traffic data, use case information, SCD API functions and parameter call logs.

[0065] The second generation module 33 can send the CLI configuration generated by, for example, an automated script or manual trigger to the target device under test, such as a network device under test, to generate corresponding SCD API functions and corresponding parameter call logs. For example, the API sends the CLI configuration and traffic data to the test target device by means of an automated script or manual trigger, etc., so as to collect the log information on the server and transfer this information and the use case information to, for example, the use case dynamic analysis module. After that, the target device under test can configure the corresponding log level initially to trigger the corresponding SCD API functions and parameter call logs according to the sent CLI configuration, so that these logs can be uploaded to the use case dynamic analysis module through log collection on the target device under test.

[0066] Thus, the third generation module 34 can extract the relationship between the CLI and the SCD API functions / parameters according to the SCD and the SCD API functions and parameter call logs generated in step S203, and can store it in, for example, the database analysis record module.

[0067] The use case generation module 35 can be used to generate the current test case according to the CLI execution order, API call examples, the relationship between the CLI and the SCDAPI parameters, and the relationship between the service and the traffic data.

[0068] According to the database analysis record information, the SCD API use case execution order can be generated by using the CLI execution order. The attributes and data types of the SCD API can be generated by using the API call examples. The SCDAPI data type parameter configuration can be generated by using the relationship between the CLI and the SCD API parameters. The SCD API use case traffic configuration can be generated by using the relationship between the service and the traffic. Then, according to the SCD-RTF framework template, the above information can be combined into a new use case, that is, the current test case.

[0069] Therefore, according to the embodiments of the present application, after obtaining the current test case, the newly generated current test case can also be sent to, for example, the server where the SCD-RTF is located, and the newly generated current test case is executed through the SCD-RTF, so that the target device under test receives the SCD API call of the newly generated current test case and can generate the corresponding SCD API call log.

[0070] In addition, in the embodiments of the present application, after generating the current test case, the previous test case before the generation of the current test case can also be identified according to the SCD-RTF and the identification information of the current test case, such as tags, and the function call logs are parsed and compared to calculate the similarity. If the similarity reaches a predetermined threshold, it can be determined that the current test case is qualified, otherwise it is determined to fail.

[0071] The test case generation device according to the embodiments of the present application analyzes the target code to obtain call examples and business dependencies, generates CLI configurations and traffic data according to the business dependencies, and then generates SCD API function and parameter call logs based on the target device to which the CLI configuration is issued. Furthermore, the relationship between these information is generated based on the above information, and finally the current test case is generated. Therefore, the professional requirements for testers in SCD API testing are greatly reduced, and the work of testers manually analyzing and writing scripts is eliminated, greatly improving the test efficiency.

[0072] The internal functions and structures of the test case generation device are described above, and the device can be implemented as an electronic device. Figure 4 It is a schematic structural diagram of an embodiment of the electronic device provided by the present application. As Figure 4 shown, the electronic device includes a memory 41 and a processor 42.

[0073] The memory 41 is used to store programs. In addition to the above programs, the memory 41 can also be configured to store various other data to support operations on the electronic device. Examples of these data include instructions for any application program or method for operating on the electronic device, contact data, phone book data, messages, pictures, videos, etc.

[0074] The memory 41 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 memory, flash memory, magnetic disk or optical disk.

[0075] The processor 42 is not limited to a central processing unit (CPU), and may also be a graphics processing unit (GPU), a field programmable gate array (FPGA), an embedded neural network processor (NPU), or an artificial intelligence (AI) chip, etc. The processor 42 is coupled to the memory 41 and executes the program stored in the memory 41, and when the program runs, it executes the test case generation method of the above embodiments.

[0076] Furthermore, asFigure 4 As shown, the electronic device may further include other components such as a communication component 43, a power supply component 44, an audio component 45, a display 46, etc. Figure 4 Only some components are schematically shown in the figure, which does not mean that the electronic device only includes Figure 4 the components shown.

[0077] The communication component 43 is configured to facilitate communication between the electronic device and other devices in a wired or wireless manner. The electronic device can access a wireless network based on communication standards, such as WiFi, 3G, 4G, or 5G, or a combination thereof. In an exemplary embodiment, the communication component 43 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 43 further includes a Near Field Communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on Radio Frequency Identification (RFID) technology, Infrared Data Association (IrDA) technology, Ultra-Wideband (UWB) technology, Bluetooth (BT) technology, and other technologies.

[0078] The power supply component 44 provides power for various components of the electronic device. The power supply component 44 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power for the electronic device.

[0079] The audio component 45 is configured to output and / or input audio signals. For example, the audio component 45 includes a microphone (MIC). When the electronic device is in an operating mode, such as a call mode, a recording mode, and a voice recognition mode, the microphone is configured to receive external audio signals. The received audio signals can be further stored in the memory 41 or sent via the communication component 43. In some embodiments, the audio component 44 further includes a speaker for outputting audio signals.

[0080] The display 46 includes a screen, and the screen may include a Liquid Crystal Display (LCD) and a Touch Panel (TP). If the screen includes a touch panel, the screen can be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touches, swipes, and gestures on the touch panel. The touch sensors can not only sense the boundaries of touch or swipe actions, but also detect the duration and pressure associated with the touch or swipe operations.

[0081] Those of ordinary skill in the art can understand that all or part of the steps of implementing the above method embodiments can be completed by hardware related to program instructions. The foregoing program can be stored in a computer-readable storage medium. When the program is executed, it executes the steps including the above method embodiments; and the foregoing storage medium includes various media such as ROM, RAM, magnetic disks, or optical discs that can store program codes.

[0082] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that they can still modify the technical solutions described in the foregoing embodiments, or perform equivalent replacements on some or all of the technical features; and these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the various embodiments of the present invention.

Claims

1. A use case generation method, comprising: Performing code static analysis on the code of a network device developed based on the switch chip driver SCD to obtain application programming interface API call examples and business dependencies; Generating command line interface CLI configurations and traffic data according to the API call examples and business dependencies; By sending the CLI configurations and traffic data to the device under test, triggering and collecting the SCD API function and parameter call logs corresponding to the CLI configurations by the device under test, so as to obtain the SCD API function and parameter call logs; Generating the relationship between the CLI and the SCD API function / parameters and the relationship between the business and the traffic according to the CLI configuration logs, the traffic data, the use case information, and the SCD API function and parameter call logs; Generating the current test case according to the CLI execution order, the API call examples, the relationship between the CLI and the SCD API parameters, and the relationship between the business and the traffic data.

2. The use case generation method according to claim 1, wherein the use case generation method further comprises: Executing the current test case to obtain SCD API call logs; Determining the quality of the current test case according to the SCD API call logs.

3. The use case generation method according to claim 2, wherein determining the quality of the current test case according to the SCD API call logs further comprises: Determining the previous test case executed on the server where the test case is executed before the current test case according to the identifier of the current test case; Calculating the similarity of the function call logs between the current test case and the previous test case; Determining the qualification degree of the current test case according to the similarity.

4. The use case generation method according to claim 1, wherein, The generating the current test case according to the CLI execution order, the API call examples, the relationship between the CLI and the SCD API parameters, and the relationship between the business and the traffic data comprises: Generating the SCD API use case execution order according to the database analysis record information and using the CLI execution order; Generating the attributes and data types of the SCD API using the API call examples; Generating the SCD API data type parameter configuration using the relationship between the CLI and the SCD API parameters; Generating the SCD API use case traffic configuration using the relationship between the business and the traffic; Generating the current test case according to the SCD-RTF framework template.

5. The use case generation method according to claim 2, wherein, The executing the current test case to obtain SCD API call logs comprises: Sending the current test case to the server where the SCD-RTF framework is located to execute the test case; Generating SCD API call logs according to the calls of the SCD API of the current test case; Collecting the SCD API call logs by the test target device of the current test case.

6. A use case generation device, comprising: An analysis module for performing code static analysis on the code of a network device developed based on the switch chip driver SCD to obtain application programming interface API call examples and business dependencies; A first generation module for generating a command line interface (CLI) configuration and traffic data according to the API call example and business dependencies. A second generation module for obtaining the SCD API function and parameter call logs by sending the CLI configuration and traffic data to a device under test, triggering the device under test to collect the SCD API function and parameter call logs corresponding to the CLI configuration. A third generation module for generating the relationship between the CLI and SCD API functions / parameters and the relationship between the business and traffic according to the CLI configuration logs, the traffic data, the use case information, and the SCD API function and parameter call logs. A use case generation module for generating the current test case according to the CLI execution order, the API call example, the relationship between the CLI and SCD API parameters, and the relationship between the business and traffic data.

7. The use case generation device according to claim 6, wherein the use case generation device further comprises: An execution module for executing the current test case to obtain the SCD API call logs. A determination module for determining the quality of the current test case according to the SCD API call logs.

8. The use case generation device according to claim 7, wherein, The determination module is further configured to: Determine the previous test case executed on the server for executing the test case before the current test case according to the identifier of the current test case. Calculate the similarity between the function call logs of the current test case and the previous test case. Determine the qualification of the current test case according to the similarity.

9. A computer-readable storage medium having a computer program stored thereon that is executable by a processor, wherein, The program, when executed by the processor, implements the use case generation method according to any one of claims 1 to 5.

10. An electronic device comprising: A memory for storing a program. A processor for running the program stored in the memory to execute the use case generation method according to any one of claims 1 to 5.

Citation Information

Patent Citations

  • Method and device for testing case

    CN113326196A

  • Switching chip drive test method and device, electronic equipment and storage medium

    CN113360386A