Test case generation method and device, equipment and medium

By automatically generating test case parameters, the problem of poor reusability of test cases in chip research and development is solved, the testing efficiency and accuracy are improved, and human errors and maintenance costs are reduced.

CN120234246APending Publication Date: 2025-07-01SHANDONG YUNHAI GUOCHUANG CLOUD COMPUTING EQUIP IND INNOVATION CENT CO LTD
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202510360990.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-25
Publication Date
2025-07-01

AI Technical Summary

Technical Problem

During the development of chip products, the performance differences between multiple test environments lead to a large gap in test cases executability and execution time, and it is difficult for existing technology to efficiently reuse test cases. Multiple sets of parameters need to be written manually, which increases maintenance costs and is prone to errors.

Method used

By obtaining the test case configuration file, parsing and generating the target test case parameter template, and automatically generating test case parameters based on the value range defined by the architecture to avoid human error.

Benefits of technology

Improves the efficiency and accuracy of test case generation, reduces human errors, and reduces maintenance costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120234246A_ABST
    Figure CN120234246A_ABST
Patent Text Reader

Abstract

The invention provides a test case generation method and device, equipment and a medium, and is applied to the technical field of testing, the method comprises the steps that a test case configuration file of a target test environment is acquired, the test case configuration file comprises test case parameter templates corresponding to test points, and the test case parameter templates correspond to the test points; the test case parameter template is a parameter template generated based on case parameters of a standard test case of a test point and a test result; the test case configuration file is analyzed, a test case parameter template corresponding to a target test point is obtained and serves as a target test case parameter template, and the target test point is a test point of a to-be-generated test case parameter in the test points; generating target test case parameters based on the target test case parameter template and a parameter value range, wherein the parameter value range is a value range determined based on architecture definition; and generating a target test case based on the target test case parameter. In this way, the test case generation efficiency and accuracy can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of testing technologies, and particularly to a test case generation method, device, equipment and medium. Background Art

[0002] There are various test environments in the R & D process of chip products. The performance differences of different test environments are relatively large, resulting in large differences in the executability of test cases, the execution time of test cases, etc. When testing in different environments, test cases can hardly be reused. When conducting tests, for the same test case, multiple sets of different parameters need to be written, which is time-consuming and laborious and increases the later maintenance cost. Moreover, it is necessary to construct suitable parameters for different test environments, involving a large number of parameter modifications, which is very easy to make mistakes and affects the efficiency and accuracy of test case generation.

[0003] Therefore, how to improve the efficiency and accuracy of test case generation is a problem that needs to be solved by those skilled in the art. Summary of the Invention

[0004] In view of this, the purpose of the present invention is to provide a test case generation method, device, equipment and medium, which can improve the efficiency and accuracy of test case generation. The specific scheme is as follows:

[0005] In a first aspect, the present invention provides a test case generation method, including:

[0006] Obtain a test case configuration file for a target test environment, where the test case configuration file includes test case parameter templates corresponding to each test point, and the test case parameter template is a parameter template generated based on the case parameters and test results of a standard test case for the test point;

[0007] Parse the test case configuration file to obtain a test case parameter template corresponding to a target test point as a target test case parameter template, where the target test point is the test point for which test case parameters are to be generated among the test points;

[0008] Generate target test case parameters based on the target test case parameter template and a parameter value range, where the parameter value range is a value range determined based on architecture definitions;

[0009] Generate a target test case based on the target test case parameters.

[0010] Optionally, the generating target test case parameters based on the target test case parameter template and the parameter value range includes:

[0011] Obtain preset parameter indication information, where the preset parameter indication information is used to indicate preset parameters in the target test case parameter template;

[0012] Generate test case parameters other than the preset parameters based on the target test case parameter template and the parameter value range;

[0013] Generate target test case parameters based on the generated test case parameters and the preset parameters.

[0014] Optionally, in the test case configuration file, when any test point contains multiple test factors, each test factor has a corresponding test case parameter sub-template for that test factor.

[0015] Optionally, parsing the test case configuration file to obtain the test case parameter template corresponding to the target test point includes:

[0016] Parse the test case configuration file, and use the test point that matches the test point and all the test factors under that test point as the target test point, and use the test case parameter sub-templates corresponding to each test factor of the target test point as the test case parameter template corresponding to the target test point.

[0017] Optionally, it further includes:

[0018] Obtain the test factors in the target test case parameter template;

[0019] Determine the test factor as the preset parameter and generate the preset parameter indication information.

[0020] Optionally, the test result is the test result obtained by testing the standard test case of the test point multiple times.

[0021] Optionally, it further includes:

[0022] When it is detected that the test environment is switched, obtain the test case configuration file corresponding to the switched test environment to generate the test case corresponding to the switched test environment;

[0023] Among them, different test environments correspond to different test case configuration files.

[0024] In a second aspect, the present invention provides a test case generation device, including:

[0025] A configuration file acquisition module, configured to acquire a test case configuration file of a target test environment, where the test case configuration file includes test case parameter templates corresponding to each test point, and the test case parameter template is a parameter template generated based on the use case parameters and test results of the standard test case of the test point;

[0026] A configuration file parsing module, configured to parse the test case configuration file to obtain a test case parameter template corresponding to a target test point, as the target test case parameter template, where the target test point is a test point for which test case parameters are to be generated among the various test points;

[0027] A test case parameter determination module, configured to generate target test case parameters based on the target test case parameter template and a parameter value range, where the parameter value range is a value range determined based on the architecture definition;

[0028] A test case generation module, configured to generate target test cases based on the target test case parameters.

[0029] In a third aspect, the present invention provides an electronic device, including:

[0030] A memory, configured to store a computer program;

[0031] A processor, configured to execute the computer program to implement the steps of the foregoing test case generation method.

[0032] In a fourth aspect, the present invention provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the foregoing test case generation method are implemented.

[0033] In a fifth aspect, the present invention provides a computer program product, including a computer program / instructions, and when the computer program / instructions are executed by a processor, the steps of the foregoing test case generation method are implemented.

[0034] As can be seen from the above solutions, the present invention provides a test case generation method, including: obtaining a test case configuration file of a target test environment, where the test case configuration file includes test case parameter templates corresponding to various test points, and the test case parameter templates are parameter templates generated based on the case parameters and test results of standard test cases for the test points; parsing the test case configuration file to obtain a test case parameter template corresponding to a target test point, as the target test case parameter template, where the target test point is a test point for which test case parameters are to be generated among the various test points; generating target test case parameters based on the target test case parameter template and a parameter value range, where the parameter value range is a value range determined based on the architecture definition; generating target test cases based on the target test case parameters.

[0035] It can be seen that the beneficial effects of the present invention are as follows: Test case parameters are generated through the test case configuration file corresponding to the test environment, and then test cases are obtained. Among them, the test case configuration file includes a parameter template generated based on the use case parameters and test results of each test point based on the standard test case. By parsing the test case configuration file, the target test case parameter template is obtained, and the target test case parameters are generated in combination with the parameter value range determined based on the architecture definition. In this way, the generated test case parameters conform to the architecture definition and the actual performance of the current test environment, the value range is more reasonable, human errors are avoided, and test cases are automatically generated using the configuration file without manually writing multiple sets of different test case parameters, and the efficiency of generating test cases is higher, which can improve the efficiency and accuracy of generating test cases. BRIEF DESCRIPTION OF THE DRAWINGS

[0036] In order to more clearly illustrate the embodiments of the present invention, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings in the following description are only some embodiments of the present invention, and those of ordinary skill in the art can obtain other drawings based on these drawings without creative efforts.

[0037] Figure 1 It is a flowchart of a test case generation method provided by an embodiment of the present invention;

[0038] Figure 2 It is a flowchart of a test case parameter generation provided by an embodiment of the present invention;

[0039] Figure 3 It is a flowchart of a test case configuration file generation provided by an embodiment of the present invention;

[0040] Figure 4 It is a flowchart of a test case configuration file parsing provided by an embodiment of the present invention;

[0041] Figure 5 It is a flowchart of a test case parameter generation provided by an embodiment of the present invention;

[0042] Figure 6 It is a schematic structural diagram of a test case generation device provided by an embodiment of the present invention;

[0043] Figure 7 It is a structural diagram of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0044] Next, the technical solutions in the embodiments of the present invention will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all embodiments. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts shall fall within the protection scope of the present invention.

[0045] As used in the specification of the present invention and the above accompanying drawings, the terms "comprising" and "having", as well as any variations related to "comprising" and "having", are intended to cover non-exclusive inclusion. For example, a process, method, system, product or device that includes a series of steps or units is not limited to the listed steps or units, but may include steps or units not listed.

[0046] There are various test environments during the R & D process of chip products, usually including the virtual prototype simulation test environment before tape-out, the hardware prototype simulation test environment, and the product board test after tape-out. The performance differences among these test environments are significant, resulting in huge gaps in test case executability, test case execution time, etc. When testing in different environments, test cases can hardly be reused. For example, for a test case, when tested in the virtual prototype simulation test environment, the test case execution time is 10 hours. In the case of limited test environment resources, such an execution efficiency is obviously too low. For the same test case with exactly the same test case parameters, when tested in the hardware prototype simulation test environment, the test case execution time is 10 minutes, and the test case duration is normal. Additionally, for some test cases with dependencies between test steps, due to the performance differences of the test environments, if the test case parameters are not adapted to the environment, the test cases may still fail. For example, for a test case with three test steps, namely step1, step2, and step3, where step2 is an asynchronous task and it is required that at step3, it can be checked that step2 is still executing. When designing the test case, it is expected that step2 takes more than 10 minutes. When tested in the virtual prototype simulation test environment, the test case executes successfully, step1 takes 10 minutes, step2 takes 20 minutes, and step3 takes 3 minutes. For the same test case with exactly the same test case parameters, when tested in the hardware prototype simulation test environment, step1 takes 1 minute, step2 takes 2 minutes, and step3 fails to execute. Analyzing the error reason, step2 completes much earlier than expected, step3 starts to execute after 10 minutes, the status of step2 cannot be queried, and step3 directly returns a failure, resulting in the test case execution failure. Therefore, for the same test case, it is necessary to prepare several sets of different test case parameters, which is extremely laborious. For example, if n test cases need to be manually written for test environment 1, then n test cases also need to be manually written for test environment 2. The differences among several sets of different test cases mostly focus on the values of the test case parameters. Due to the large differences between test environments, the values of test case parameters in different test environments do not have a simple proportional relationship, so several sets of different test case parameters cannot be obtained through a simple formula. Therefore, the following problems exist: for the same test case, multiple sets of different parameters need to be written, which is time-consuming and laborious and increases the later maintenance cost; it is necessary to construct suitable parameters for different test environments, involving a large number of parameter modifications, and it is very easy to make mistakes.

[0047] Therefore, the present invention provides a test case generation scheme, which can improve the test case generation efficiency and accuracy.

[0048] To enable those skilled in the art to better understand the solution of the present invention, the present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments.

[0049] Next, a test case generation method provided by an embodiment of the present invention will be introduced in detail. Figure 1 FIG. is a flowchart of a test case generation method provided by an embodiment of the present invention. The test case generation method includes:

[0050] Step S11: Obtain a test case configuration file for a target test environment. The test case configuration file includes a test case parameter template corresponding to each test point. The test case parameter template is a parameter template generated based on the case parameters and test results of a standard test case for the test point.

[0051] In an embodiment of the present invention, the object to be tested may be hardware and software products supporting the hardware. The object to be tested may include multiple test environments, such as a virtual prototype simulation test environment, a hardware prototype simulation test environment, a product board test environment after tape-out, etc.

[0052] It should be noted that there are multiple test environments in the process of chip product R & D, including a virtual prototype simulation test environment before tape-out, a hardware prototype simulation test environment, a product board test after tape-out, etc. The performances of these test environments vary greatly. Embodiments of the present invention can generate corresponding test case configuration files for different test environments. When testing is required in a corresponding test environment, the test case configuration file of the corresponding test environment can be obtained, that is, the test case configuration file of the target test environment.

[0053] In an optional embodiment, in the test case configuration file, when any test point includes multiple test factors, each test factor has a corresponding test case parameter sub-template.

[0054] Among them, the test point of the test case refers to the test function point, and the test factor refers to the factor that may affect the test result during the test.

[0055] Moreover, the test result is the test result obtained by performing multiple tests on the standard test case of the test point. The test result is the execution duration of the standard test case. The average value is taken from multiple tests to obtain the average execution duration as the test result, and the test result is more stable and reproducible.

[0056] Embodiments of the present invention can write standard test cases based on test points in a selected test environment. Testers can design standard test cases according to the test requirement document. The standard test cases do not contain random parameters so that the test results can be quantified. Execute the standard test cases multiple times to obtain test results. Use the test case parameters and test results of the standard test cases to form a test case parameter template, and then write it into a test case configuration file. The test case configuration file can include test case parameter templates corresponding to each test point. In an alternative embodiment, Python can be used as the coding language, and a JSON (a data interchange format) file can be used as the test case configuration file. The test point name is used as the key, and the value type is a list. If there are multiple test factors for a test point, multiple test case parameter sub-templates can be included in the list. The variable type of the test case parameter sub-template is a dictionary. Each parameter name or test factor of the test case parameter sub-template is used as the sub_key, and the value of each parameter is used as the sub_value. Different test environments have significant performance differences, the designed standard test cases are different, the test results are also different, and the written test case configuration files are also different.

[0057] Step S12: Parse the test case configuration file to obtain the test case parameter template corresponding to the target test point as the target test case parameter template, where the target test point is the test point for which test case parameters are to be generated among the various test points.

[0058] That is to say, the test case configuration file can contain test case parameter templates for multiple test points. Embodiments of the present invention can parse the test case configuration file to obtain the test case parameter template of the test point for which test case parameters are to be generated. The target test case parameter template can be obtained by matching using the test point name.

[0059] In an alternative embodiment, parse the test case configuration file, and use the test point that matches the test point and all the test factors under this test point as the target test point, and use the test case parameter sub-templates corresponding to each test factor of the target test point as the test case parameter template corresponding to the target test point.

[0060] That is to say, first match the test point. If the test point contains multiple test factors and all the test factors match, then the target test point is obtained, and thus the test case parameter sub-templates corresponding to each test factor are obtained as the target test case parameter template.

[0061] Step S13: Generate target test case parameters based on the target test case parameter template and the parameter value range, where the parameter value range is the value range determined based on the architecture definition.

[0062] Among them, the architecture is defined as the architecture definition of the object to be tested, that is, the architectures of both the hardware and the software products supporting the hardware need to be considered. The parameter values of the target test case parameters conform to the architecture definition, and the relationships between the target test case parameters conform to the architecture definition.

[0063] Embodiments of the present invention can obtain preset parameter indication information, where the preset parameter indication information is used to indicate preset parameters in the target test case parameter template; generate test case parameters other than the preset parameters based on the target test case parameter template and the parameter value range; and generate target test case parameters based on the generated test case parameters and the preset parameters. That is, embodiments of the present invention can generate parameters other than the preset parameters in the target test case parameter template. The preset parameters are parameters that remain fixed.

[0064] In an alternative embodiment, the test factors in the target test case parameter template can be obtained; the test factors are determined as preset parameters, and the preset parameter indication information is generated. Embodiments of the present invention can keep the test factors unchanged and change other parameters.

[0065] In an alternative embodiment, test case parameters other than the preset parameters can be generated based on the test results in the target test case parameter template, the duration required for the target test case to execute, and the parameter value range. That is, the use case parameters that meet the duration required for the target test case to execute and are within the parameter value range can be generated according to the proportional relationship between the test results in the target test case parameter template and the duration required for the target test case to execute, and the values of the parameters other than the preset parameters in the target test case parameter template. In this way, test cases that more accurately meet the test requirements can be obtained quickly and accurately.

[0066] Moreover, in an alternative embodiment, if the target test case parameter template is a template corresponding to multiple test factors, and the multiple test factors respectively correspond to weights, the test factors with non-zero weights can be selected from the multiple test factors as the target test factors, the execution duration of the test case part corresponding to the target test factor is determined based on the weight of the target test factor and the duration required for the target test case to execute, the test case parameters corresponding to the target test factor are determined based on the execution duration and the test results in the target test case parameter template, and then the test case parameters corresponding to other test factors are determined based on the parameter association relationship between the test factors. In this way, the values of each parameter can be reasonably determined.

[0067] Step S14: Generate a target test case based on the target test case parameters.

[0068] It can be understood that test case parameters are variables or values used in test cases. In the embodiments of the present invention, target test case parameters can be generated according to requirements, which can be a group or multiple groups. These variables or values can be replaced or changed during test execution.

[0069] Furthermore, when it is detected that the test environment is switched, the test case configuration file corresponding to the switched test environment is obtained to generate test cases corresponding to the switched test environment; wherein, different test environments correspond to different test case configuration files. Among them, the generation of test cases corresponding to the switched test environment can refer to the foregoing public content and will not be elaborated herein.

[0070] It can be seen that in the embodiments of the present invention, test case parameters are generated through the test case configuration file corresponding to the test environment, and then test cases are obtained. Among them, the test case configuration file includes a parameter template generated based on the use case parameters and test results of each test point based on the standard test case. By parsing the test case configuration file, the target test case parameter template is obtained, and combined with the parameter value range determined based on the architecture definition, the target test case parameters are generated. In this way, the generated test case parameters conform to the architecture definition and the actual performance of the current test environment, the value range is more reasonable, human errors are avoided, and test cases are automatically generated using the configuration file without manually writing multiple sets of different test case parameters, and the efficiency of generating test cases is higher, which can improve the efficiency and accuracy of generating test cases.

[0071] The present invention provides a solution for generating test case parameters according to a test case configuration file, and then obtaining test cases. See Figure 2 as shown Figure 2 is a flowchart for generating test case parameters provided by an embodiment of the present invention. According to different environments, corresponding test case configuration files are generated; the test case configuration files are parsed; different test case parameters are automatically generated. As Figure 2 shown, taking test environments 1 to 3 as examples, for different test environments, test cases can be automatically generated using the test case configuration file, which can include three modules: a test case configuration file generation module, a test case configuration file parsing module, and a test case parameter generation module. Among them, according to different environments, the test case configuration file generation module can be used to generate corresponding test case configuration files; then, through the test case configuration file parsing module, the test case configuration files are parsed; finally, through the test case parameter generation module, different test case parameters are automatically generated. When the test environment is switched, there is no need to manually write different test case parameters for the same test case, but test case parameters are automatically generated through the test case configuration files corresponding to different environments, greatly reducing the workload of testers.

[0072] Furthermore, see Figure 3 as shownFigure 3 This is a flowchart for generating a test case configuration file provided by an embodiment of the present invention. Testers design standard test cases based on the test requirement document. There should be no random parameters in the designed standard test cases, which is to make the test results quantifiable. In theory, one standard test case can be designed for one test point; if there are multiple test factors in a test point and all have an obvious impact on the test results, then standard test cases can be designed separately for these test factors to obtain test results respectively, or a standard test case corresponding to the test point with multiple test factors can be designed without separate design, and the weights corresponding to different test factors are determined. This weight can represent the impact on the execution time of the test case. The greater the impact, the longer the weight, that is, the greater the impact on extending the execution time. Execute the standard test case to obtain the test results. The standard test case needs to be executed multiple times to ensure that the test results are stable and reproducible. Use the standard test case parameters and test results to form a test case parameter template, and use these test case parameter templates to write a test case configuration file. Use Python as the coding language and a JSON file as the configuration file. The test point name is used as the key, and the value type is a list; if there are multiple test factors in a test point, then generally there are multiple test case parameter sub-templates, and the test case parameter sub-templates are added to the list as elements; for the test case parameter sub-template, the variable type is a dictionary, and each parameter name or test factor in the test case parameter sub-template is used as a sub-key, and the value of each parameter is used as a sub-value. Different test environments have significant performance differences, so the designed standard test cases are different, the test results are different, and the written test case configuration files are also different.

[0073] Further, refer to Figure 4 as shown in Figure 4 This is a flowchart for parsing a test case configuration file provided by an embodiment of the present invention. Use the JSON library function of Python to read the test case configuration file and convert it into a Python dictionary format; different test environments require reading different test case configuration files. Traverse the test case configuration file to find the test case parameter template that is the same as the test point; traverse the found test case parameter template to find the test case parameter sub-template that is the same as the test factor in the test point. If there are multiple test factors in the test point, then the test case parameter sub-template must also exactly match the multiple test factors in the test point. Output the found test case parameter sub-template. The parameters of the test case parameter sub-template are usually all the parameters of a test case.

[0074] Further, refer to Figure 5 as shown in Figure 5A flowchart for generating test case parameters provided by an embodiment of the present invention. Read the test case parameter sub-template and use the test case parameter generator to generate the parameters of the target test case. Figure 5 The function of the test case parameter generator is to generate reasonable test case parameters that meet the test points. The test case parameter generator consists of a series of functions written in Python, and its main functions are as follows: Accept the test case parameter sub-template as input and accept the preset parameters of the target test case as input. Traverse the test case parameter sub-template and the preset parameters of the target test case, use built-in functions to calculate and generate all the parameters included in the test case parameter sub-template except the preset parameters, combine the preset parameters and the generated parameters as the target test case parameters. Output the target test case parameters. Among them, the functions of the built-in functions of the test case parameter generator: According to the definition of the architecture document, constrain the value range of the generated test case parameters, randomly generate the target parameters within the value range, or calculate the target parameters in combination with the preset parameters; the value size and range between each target parameter also need to conform to the architecture definition.

[0075] Next, take the RAID (i.e., disk array) function test as an example. When only testing the RAID read and write functions, using the software prototype simulation environment for testing, the execution time of a test case may be between several hours and several days; for the same case, using the hardware prototype simulation environment for testing, the case execution time is between a few minutes and dozens of minutes; at the real product board test stage, for the same case, the execution time may be only a few seconds. Since the software prototype simulation platform simulates the hardware behavior based on computer software, although it can be easily modified and debugged, the speed is slow; the hardware prototype simulation platform uses special hardware devices (such as FPGA) to accelerate the simulation process, and the speed is significantly improved; while the real hardware circuit directly executes operations at the physical level, and the speed is improved by several orders of magnitude compared with the simulation platform.

[0076] For configuration file generation, when testing on the hardware prototype simulation platform, according to the test requirements document, for the raid5 sequential write test, the following standard test cases are designed. Create an 8-disk raid5 with a raid size of sliding_window (i.e., sliding window), create a ns (i.e., namespace) on the raid with a ns size of sliding_window, perform a fio (i.e., Flexible I / O Tester, an open-source tool for generating various I / O loads to test the read and write performance of storage devices) write test on the ns with a write size of sliding_window. To reduce the impact of environmental fluctuations on the test results, execute this test case 10 times on the hardware prototype simulation platform, with execution times of 523, 598, 576, 501, 590, 556, 579, 515, 593, 588 respectively, and the time unit is s. Calculate the average value and round it up to 562s.

[0077] Combine the above test case input parameters and test results to obtain a test case parameter template, and then write the test case parameter template into the test case configuration file. The test case configuration file uses the JSON format as follows.

[0078] { # Test point

[0079] "raid_normal_write":

[0080] # Test case parameter template [

[0082] # Test case parameter sub-template

[0083] { # Use case parameters

[0084] # Test factor 1

[0085] "raid_level": "5",

[0086] "raid_id": "0",

[0087] "disk_num": "8",

[0088] "chunk_size": "64k",

[0089] "raid_size": "sliding_window",

[0090] "ns_id": "1",

[0091] "ns_size": "sliding_window",

[0092] # Test Factor 2

[0093] "rw": "write",

[0094] "bs": "4k",

[0095] "size": "sliding_window",

[0096] # Test Result

[0097] "runtime": "562s"

[0098] }

[0100] }

[0101] Furthermore, for the configuration file parsing, when writing a test case for RAID5 write, if the execution time of the test case is required not to exceed 1h, then the test point is "raid_normal_write", the test factor 1 "raid_level": "5", and the test factor 2 "rw": "write". Through the test case configuration file parsing module, read the test case configuration file. Given the test point "raid_normal_write", read the corresponding test case parameter template; through the test factors "raid_level": "5" and "rw": "write", match the corresponding test case parameter sub-template.

[0102] In the above test case parameter sub-template, the meanings of each parameter are as follows: raid_level refers to the level of creating a RAID; raid_id refers to the number of the created RAID; disk_num refers to the number of disks used to create a RAID; chunk_size refers to the stripe unit size, and the stripe unit means the data block written to a single physical disk each time; raid_size refers to the size of the created RAID; sliding_window is equal to chunk_size * (disk_num – parse_disk_num) * disk_num, where parse_disk_num refers to the number of parity disks, which depends on raid_level. When raid_level is 5 here, parse_disk_num is 1; ns_id refers to the number of the namespace; ns_size refers to the size of the namespace; rw refers to the read / write mode; bs refers to the block size for each read / write; size refers to the total size of the read / write; runtime refers to the test result of the case.

[0103] ​Enter the test case parameter generation module, input the test case parameter sub-template, and generate the target test case parameters through the test case parameter generator. If certain parameters are required to be fixed for the test point, use the fixed parameters. For example, in this use case, the raid_level can only be 5. Use Python coding to write the corresponding built-in functions to make the value range of the generated parameters conform to the architecture definition: the raid_id must be an integer between 0 and 63; when the raid_level value is 5, the disk_num must be greater than 3 and less than 32; the chunk_size value is '64k', '128k' or '256k'; the raid_size must be an integer multiple of chunk_size * (disk_num – parse_disk_num); the ns_id must be an integer between 1 and 63; the ns_size must be an integer multiple of chunk_size * (disk_num – parse_disk_num) and must be less than or equal to the raid_size; the rw is the same as in the test case configuration file because w is the test factor for the test point of this use case; the bs must be an integer multiple of 4k and divisible by size; the size must be less than or equal to the ns_size and divisible by bs.

[0104] In this test case, creating a raid and creating an ns are only configuration-related operations. The time consumption of configuration-related operations is almost negligible compared to the time consumption of the write operation. Therefore, the use case execution time is approximately equivalent to the time consumption of the write operation. When the size is silding_window, the use case execution time is 562s. When the use case execution time is required not to exceed 1h, a simple calculation gives 3600 / 562≈6.4. Then the size is less than 6.4 * silding_window, and is an integer multiple of bs, that is, 4k, and less than or equal to the ns_size.

[0105] The test case parameters obtained through the test case parameter generator naturally conform to the architecture definition. Compared with the parameters manually written, the probability of error is lower. Moreover, by using the test case parameter template that matches the test environment to generate test case parameters, it conforms to the actual performance of the current test environment. Therefore, the value range of the test case parameters is more reasonable, greatly reducing the situation where the test case fails due to unreasonable values of the test case parameters. The above example shows that when testing on the hardware prototype simulation platform, the configuration file generation module is used to generate a test case parameter template including the normal write test of RAID. The configuration file parsing module is used to match the sub-template of the normal write test of RAID5. The sub-template of the normal write test of RAID5 and the preset parameters of the target test case are input into the test case parameter generation module, and all the parameters of the target test case are generated through the test case parameter generator. Compared with the traditional method of manually writing the parameters of the test case, the method of generating the test case configuration file by combining the pre-test results and automatically generating the test case according to the configuration file has higher efficiency in generating the test case, higher correctness in generating the test case parameters, and more reasonable values.

[0106] When a test case parameter template related to a new test point needs to be generated, new standard test cases need to be designed and tested multiple times to obtain the corresponding test case parameter template, which is then appended to the test case configuration file. When switching to different test environments for testing, different test case configuration files need to be generated according to the above method, read and parsed, and finally the required test case parameters are generated.

[0107] In the embodiment of the present invention, during the chip testing process, according to the characteristics of different test environments, the method of generating the test case configuration file by combining the pre-test results and automatically generating the test case according to the configuration file is used to ensure that the parameters are reasonable and accurate, and reduce human errors. During the chip testing process, according to the characteristics of different test environments, the method of generating the test case configuration file by combining the pre-test results and automatically generating the test case according to the configuration file only requires designing a small number of test case parameter templates. Through the test case configuration file generation module, the test case configuration file parsing module, and the test case parameter generation module, a chip testing system is constructed to avoid repeated writing of test cases. In this way, the test case parameter template is obtained through the real test environment, and the test case configuration file is written. Using these configuration files to automatically generate test cases makes the parameters more reasonable and accurate, and reduces the errors introduced by manual writing by testers. For different test environments, only a small number of test case parameter templates need to be designed, the test case configuration file is written, and then the test cases are automatically generated through the test case configuration file. Testers do not need to write multiple sets of different test case parameters for the same test case, greatly reducing the repetitive work of testers.

[0108] The present invention uses a JSON file as the writing method of the test case configuration file, taking the raid5 write test on the hardware prototype simulation platform as an example. Writing the test case configuration file in other forms, identifying different test environments, and automatically generating test cases in other fields besides the raid test are also within the protection scope of the present invention.

[0109] See Figure 6 As shown, an embodiment of the present invention provides a test case generation device, including:

[0110] A configuration file acquisition module 61, configured to acquire a test case configuration file for a target test environment, where the test case configuration file includes a test case parameter template corresponding to each test point, and the test case parameter template is a parameter template generated based on the case parameters and test results of the standard test case for the test point;

[0111] A configuration file parsing module 62, configured to parse the test case configuration file to obtain a test case parameter template corresponding to the target test point as the target test case parameter template, where the target test point is the test point for which the test case parameters are to be generated among the test points;

[0112] A case parameter determination module 63, configured to generate target test case parameters based on the target test case parameter template and the parameter value range, where the parameter value range is a value range determined based on the architecture definition;

[0113] A test case generation module 64, configured to generate a target test case based on the target test case parameters.

[0114] In an optional embodiment, the case parameter determination module 63 may include:

[0115] A preset parameter indication information acquisition module, configured to acquire preset parameter indication information, where the preset parameter indication information is used to indicate the preset parameters in the target test case parameter template;

[0116] A first parameter generation sub-module, configured to generate test case parameters other than the preset parameters based on the target test case parameter template and the parameter value range;

[0117] A second parameter generation sub-module, configured to generate target test case parameters based on the generated test case parameters and the preset parameters.

[0118] In an optional embodiment, in the test case configuration file, when any test point includes multiple test factors, each test factor has a corresponding test case parameter sub-template.

[0119] In an alternative embodiment, the profile parsing module 62 may be configured to:

[0120] Parse the test case configuration file, and use the test points that match the test points and all the test factors under the test points as the target test points, and use the test case parameter sub-templates corresponding to each test factor of the target test points as the test case parameter templates corresponding to the target test points.

[0121] Furthermore, the apparatus further includes a preset parameter indication information generation module:

[0122] Obtain the test factors in the target test case parameter template;

[0123] Determine the test factors as preset parameters, and generate the preset parameter indication information.

[0124] In an alternative embodiment, the test result is the test result obtained by testing the standard test case of the test point multiple times.

[0125] In an alternative embodiment, the apparatus is further configured to:

[0126] When it is detected that the test environment is switched, obtain the test case configuration file corresponding to the switched test environment to generate the test cases corresponding to the switched test environment;

[0127] Wherein, different test environments correspond to different test case configuration files.

[0128] It can be seen that in the embodiment of the present invention, the test case parameters are generated through the test case configuration file corresponding to the test environment, and then the test cases are obtained. Among them, the test case configuration file includes the parameter templates generated by the use case parameters and test results of each test point based on the standard test case. By parsing the test case configuration file, the target test case parameter template is obtained, and the target test case parameters are generated in combination with the parameter value range determined based on the architecture definition. In this way, the generated test case parameters conform to the architecture definition and the actual performance of the current test environment, the value range is more reasonable, artificial errors are avoided, and the test cases are automatically generated using the configuration file without manually writing multiple sets of different test case parameters, and the efficiency of generating test cases is higher, which can improve the efficiency and accuracy of generating test cases.

[0129] Figure 6 For the description of the features in the corresponding embodiments, reference may be made to Figure 1 the relevant descriptions of the corresponding embodiments, which will not be elaborated here one by one.

[0130] Figure 7 The following is a structural diagram of an electronic device provided by an embodiment of the present invention. As Figure 7 shown, the electronic device includes: a memory 70 for storing a computer program;

[0131] A processor 71, which is configured to implement the steps of the test case generation method in the above-mentioned embodiments when executing a computer program.

[0132] Wherein, the processor 71 may include one or more processing cores, such as a quad-core processor, an octa-core processor, etc. The processor 71 may be implemented in at least one hardware form of digital signal processing (DSP), field-programmable gate array (FPGA), or programmable logic array (PLA). The processor 71 may also include a main processor and a coprocessor. The main processor is a processor for processing data in the wake state, also known as the central processing unit (CPU); the coprocessor is a low-power processor for processing data in the standby state. In some embodiments, the processor 71 may be integrated with a graphics processing unit (GPU), and the GPU is responsible for rendering and drawing the content to be displayed on the display screen. In some embodiments, the processor 71 may further include an artificial intelligence (AI) processor, and the AI processor is used to process computational operations related to machine learning.

[0133] The memory 70 may include one or more computer-readable storage media, and the computer-readable storage media may be non-transitory. The memory 70 may further include high-speed random access memory and non-volatile memory, such as one or more disk storage devices and flash storage devices. In this embodiment, the memory 70 is at least used to store the following computer program 701. After the computer program is loaded and executed by the processor 71, it can implement the relevant steps of the test case generation method disclosed in any of the foregoing embodiments. In addition, the resources stored in the memory 70 may further include an operating system 702 and data 703, etc., and the storage method may be transient storage or permanent storage. Among them, the operating system 702 may include Windows, Unix, Linux, etc. The data 703 may include, but is not limited to, parameter data, etc.

[0134] In some embodiments, the electronic device may further include a display screen 72, an input / output interface 73, a communication interface 74, a power supply 75, and a communication bus 76.

[0135] Those skilled in the art can understand that Figure 7 the structure shown in does not constitute a limitation on the electronic device, and it may include more or fewer components than those shown in the figure.

[0136] It can be understood that when the test case generation method in the above embodiments is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the current technology, or all or part of this technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and executes all or part of the steps of the methods in the various embodiments of the present invention. The foregoing storage medium includes: various media such as USB flash drives, mobile hard disks, read-only memories (ROMs), random access memories (RAMs), electrically erasable programmable ROMs, registers, hard disks, removable disks, CD-ROMs, magnetic disks, or optical discs that can store program codes.

[0137] Based on this, the embodiments of the present invention further provide a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the test case generation method as described above are implemented.

[0138] Next, a computer program product provided by the embodiments of the present application will be introduced. The computer program product described below can be cross-referred to other embodiments described in this article.

[0139] A computer program product includes computer programs / instructions. When the computer programs / instructions are executed by a processor, the steps of the foregoing disclosed test case generation method are implemented.

[0140] The above has introduced in detail a test case generation method, device, equipment, and medium provided by the embodiments of the present invention. The various embodiments in the specification are described in a progressive manner. Each embodiment focuses on the differences from other embodiments. The same or similar parts among the various embodiments can be referred to each other. For the device disclosed in the embodiments, since it corresponds to the method disclosed in the embodiments, the description is relatively simple. For the relevant parts, reference can be made to the description of the method part.

[0141] Those skilled in the art may further realize that the units and algorithm steps of each example described in connection with the embodiments disclosed herein can be implemented by electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of each example have been generally described according to their functions in the above description. Whether these functions are executed in a hardware or software manner depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods for each specific application to implement the described functions, but such implementation should not be considered to exceed the scope of the present invention.

[0142] The above has introduced in detail a test case generation method, apparatus, device, and medium provided by the present invention. Specific examples have been used herein to elaborate on the principles and implementation manners of the present invention. The description of the above embodiments is only used to help understand the method and its core idea of the present invention. It should be noted that for those of ordinary skill in the art in the technical field, without departing from the principles of the present invention, several improvements and modifications can be made to the present invention, and these improvements and modifications also fall within the protection scope of the claims of the present invention.

Claims

1. A test case generation method, characterized in that: include: Obtain a test case configuration file of the target test environment, wherein the test case configuration file includes a test case parameter template corresponding to each test point, and the test case parameter template is a parameter template generated based on the case parameters and test results of the standard test case of the test point; Parsing the test case configuration file to obtain a test case parameter template corresponding to a target test point as a target test case parameter template, wherein the target test point is a test point for which test case parameters are to be generated among the test points; Generate target test case parameters based on the target test case parameter template and parameter value range, wherein the parameter value range is a value range determined based on the architecture definition; A target test case is generated based on the target test case parameters.

2. The test case generation method according to claim 1, characterized in that: The generating the target test case parameters based on the target test case parameter template and the parameter value range includes: Acquire preset parameter indication information, where the preset parameter indication information is used to indicate preset parameters in the target test case parameter template; Generate test case parameters other than the preset parameters based on the target test case parameter template and parameter value range; Generate target test case parameters based on the generated test case parameters and the preset parameters.

3. The test case generation method according to claim 2, characterized in that: In the test case configuration file, when any test point includes multiple test factors, each test factor has a test case parameter sub-template corresponding to the test factor.

4. The test case generation method according to claim 3, characterized in that: The parsing of the test case configuration file to obtain a test case parameter template corresponding to the target test point includes: The test case configuration file is parsed, a test point that matches the test point and the test factors under the test point are matched is taken as a target test point, and a test case parameter sub-template corresponding to each test factor of the target test point is taken as a test case parameter template corresponding to the target test point.

5. The test case generation method according to claim 4, characterized in that: Also includes: Obtaining the test factors in the target test case parameter template; The test factor is determined as a preset parameter, and the preset parameter indication information is generated.

6. The test case generation method according to claim 1, characterized in that: The test results are obtained by performing multiple tests on standard test cases of the test points.

7. The test case generation method according to any one of claims 1 to 6, characterized in that: Also includes: When the test environment switch is detected, the test case configuration file corresponding to the switched test environment is obtained to generate the test case corresponding to the switched test environment; Among them, different test environments correspond to different test case configuration files.

8. A test case generating device, characterized in that: include: A configuration file acquisition module, used to acquire a test case configuration file of a target test environment, wherein the test case configuration file includes a test case parameter template corresponding to each test point, and the test case parameter template is a parameter template generated based on the case parameters and test results of a standard test case of the test point; A configuration file parsing module, used to parse the test case configuration file to obtain a test case parameter template corresponding to a target test point as a target test case parameter template, wherein the target test point is a test point for which test case parameters are to be generated among the test points; A test case parameter determination module, used to generate target test case parameters based on the target test case parameter template and parameter value range, wherein the parameter value range is a value range determined based on the architecture definition; A test case generation module is used to generate a target test case based on the target test case parameters.

9. An electronic device, characterized in that: include: Memory for storing computer programs; A processor, configured to execute the computer program to implement the steps of the test case generation method according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the test case generation method according to any one of claims 1 to 7 are implemented.

Citation Information

Cited By

  • Test processing method and device, electronic equipment and storage medium

    CN121681394A

  • A test processing method, apparatus, electronic device, and storage medium

    CN121681394B