ROSS software containerization automatic difference testing method based on large language model
Through the containerized automatic differential testing method based on large language models, the problems of ROSS software test case generation and differential testing in multi-version environments are solved, and an efficient and automated test process is realized, which improves the testing efficiency and quality.
Patent Information
- Application Number
- CN202411689736.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-25
- Publication Date
- 2025-03-11
AI Technical Summary
It is difficult for the prior art to automatically generate high-quality ROSS software test cases, and differential testing is difficult to implement in multi-version environments, resulting in low testing efficiency and waste of resources.
The containerized automatic differential testing method based on large language models is adopted, and the quality and diversity of test cases are optimized by building an independent ROSS software environment by using large language models to generate high-quality test cases, and through syntax detection, branch coverage verification and prompt word template design.
It significantly improves the testing efficiency of ROSS software, reduces waste of human and material resources, and the generated test cases are of high quality, can effectively detect defects, providing an efficient and reliable ROSS software testing solution.
Smart Images

Figure CN119597660A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of automated testing of modern software engineering, and in particular relates to a ROSS software containerized automatic differential testing method based on a large language model, which can be used to implement automated differential testing and optimization of ROSS software and improve test efficiency and coverage. Background Art
[0002] In industrial software, the design and execution of test cases are more complex than in general software. Industrial software is usually highly complex and highly coupled, which makes test automation particularly difficult. Take the finite element analysis program ROSS as an example. This is an open source Python library that focuses on analyzing the dynamic behavior of rotor systems. The rotor is a key component in mechanical equipment such as engines, turbines, and motors. ROSS provides the ability to create rotor models and numerical simulations to predict the motion and response of the rotor under different conditions, thereby optimizing the design and improving the performance of the equipment. With ROSS, engineers can analyze rotor dynamics more efficiently, ensure its stable operation and reduce the risk of failure. However, due to its program complexity, manually designing test cases is not only cumbersome, but also prone to subjectivity and high error rates. Therefore, test automation is particularly important. Differential testing is an effective software testing method that aims to find potential errors or inconsistencies by comparing the output results of different versions or different implementations of the program. The core idea is to perform tests on the same input and compare the output results to verify the correctness of the program. However, differential testing is often limited in practice by version conflicts in the programming environment, and it is difficult to run multiple program versions at the same time. This often requires manual configuration of multiple environments, further increasing the difficulty of automation.
[0003] Traditional search algorithms also face many challenges when dealing with complex programs. They are prone to falling into local optimal solutions and find it difficult to generate high-quality test cases. They also require complex fitness function design and parameter tuning, which increases the complexity of testing. In contrast, the emergence of large language models simplifies the test case generation process. These models can better understand the program structure and generate test cases with higher coverage, thereby effectively improving test efficiency and quality. However, there are still some challenges in using large language models for industrial software testing. For example, how to effectively use the information generated by the model to improve the quality of test cases and improve the ability of differential testing to find defects. In addition, designing prompt word templates suitable for differential testing of industrial software is also a problem to be solved. The design of these templates is directly related to the quality of the model generation results, which in turn affects the effectiveness of the test. Summary of the invention
[0004] The technical problem solved by the present invention is to automatically generate high-quality ROSS software test cases based on a large language model, and use containerization technology to build different versions of ROSS software to achieve automatic differential testing, thereby improving test efficiency and reducing waste of human and material resources. In order to ensure the automated implementation of differential testing, two independent ROSS software environments are built using containerization technology, and multiple program versions are run simultaneously to achieve differential testing; in order to ensure the quality of test cases generated by a large language model, syntax detection and correction are performed on the test cases generated by the large language model, and further optimized through verification and improvement of branch coverage; in order to solve the drawbacks of traditional methods that industrial software test cases rely on manual intervention, multiple effective and accurate prompt word templates are designed for use in test case generation, improvement, and mutation, to improve the quality and diversity of test cases, and the maximum number of iterations, improvements, and mutations, U, are set to ensure that results are obtained within a limited time; information such as the test cases and their results is saved in a json file, and the result json file R is finally output. json .
[0005] The technical solution of the present invention:
[0006] The ROSS software containerized automatic differential testing method based on a large language model has the following specific steps:
[0007] Step (1) Build container C separately 1 , C 2 and C 3 Three containers, build the same version of Python environment for the three containers, and build a Python environment for container C. 2 With container C 3 Build different versions of ROSS software environment in the test environment, build network communication for these three containers, and test the program set F all Save to container C 1 And mount the same shared folder F for the three containers share ;
[0008] Step (2) In container C 1 In the test program set F all Scan and check each method file F old , scan the branch path, perform static code instrumentation on the code, and generate the method file F after static instrumentation insert , and construct the corresponding test case format T style ;
[0009] Step (3) In container C 1 In the example above, we construct a prompt word template P to be supplemented. 1: "For a given program that has been code-instrumented, the instrumented function is CountLine (line number), and try to generate a test case that satisfies a high branch path coverage rate: <method under test>; please generate the corresponding test case according to the following test case format: <corresponding test case format>; only generate code without any other description." Use the statically instrumented method file F obtained in step (2) insert Content and corresponding test case format T style Fill in <test method> and <corresponding test case format> respectively, and finally obtain a series of natural language precise prompts for inputting the large language model, input the selected large language model, and obtain the generated test case T;
[0010] Step (4) sets the maximum number of iteration improvements U. 1 In the process, the generated test case T is syntax checked and corrected, and then the generated test case T is branch covered. If it passes the verification, the corresponding test case format T style Merge with test case T as successful test case T success Go to step (6), otherwise the corresponding test case format T style Merge with test case T as failed test case T fail Go to step (5) to perform iterative improvement operation. If the number of iterative improvements of the current test case has reached its maximum number of iterative improvements U, then take the test case of the last iterative improvement and its corresponding test case format T style Merge as successful test case T success .
[0011] Step (5) In container C 1 In the example above, a prompt word template P is constructed to be supplemented. 2 : "For a given program that has been code-instrumented: <method under test>, the test case: <test case>'s branch coverage is improved, where the instrumented function is CountLine (line number), and the previous coverage information is: <coverage information>, please improve the test case, only generate code without any other description." Use the statically instrumented method file F obtained in step (2) insert Fill <method under test> with the content of the failed test case T that failed the verification fail Fill <test case>, use the information of the scanned branch path, executed branch path and unexecuted branch path generated by the test case scanning in the branch coverage verification process to merge and fill <error information>, and input it into the selected large language model to obtain the improved test case T new Go to step (4);
[0012] Step (6) In container C1 In the example, the successful test case T will be read success Write the contents of the shared folder F share Temporary file F in temp In, transported to container C 2 With container C 3 In. Container C 2 With container C 3 For the received temporary file F temp Perform a read operation and execute the temporary file F temp The results are fed back to container C 1 The comparison operation is performed in and the comparison results are written into the result json file R json In the output, the successful test case T success Go to step (7).
[0013] Step (7) sets the maximum number of mutations M. In container C 1 In the example, a prompt word template P is constructed to be supplemented. 3 : "For the following test case: <test case>, perform random mutation according to the given mutation rule. Tested function information: <tested function>. It is required to perform mutation while retaining the branch path coverage of the existing test case: <mutation rule table>". Use the successful test case T success And the test method file F old The contents of <test case> and <tested function> are filled in respectively, and the <mutation rule table> is filled in with mutation rules. success Perform mutation operation according to mutation rules to obtain the test case T after mutation mutation Go to step (6); if the number of mutations of the current test case exceeds the maximum number of mutations M, terminate the iteration and traverse the next method file F to be tested old , until the tested program set F all Until the traversal is completed.
[0014] Step (8) Output the result json file R json .
[0015] Furthermore, step (1) specifically includes the following steps:
[0016] 1-1) are containers C 1 Container C 2 and container C 3 Build the Dockerfile file to build the same version of Python environment for the three containers, including container C 2 With container C 3 Build different versions of ROSS software environments;
[0017] 1-2) The program set F to be tested all Save to container C 1 middle;
[0018] 1-3) Use Docker Compose to build container C 1 Depends on container C 2 With C 3 Communication network, and mount the same shared folder F for three containers share .
[0019] Furthermore, step (4) specifically includes the following steps:
[0020] 4-1) Set the number of iteration improvements U for the currently generated test case T;
[0021] 4-2) In container C 1 In , regular expressions are used to perform syntax checking and calibration on the generated test case T, and to complete missing brackets and characters;
[0022] 4-3) Perform branch coverage verification on the test case T. If its branch path coverage is 100%, it passes the verification, and the corresponding test case format T style Merge with test case T as successful test case T success Go to step (6); otherwise, the corresponding test case format T style Merge with test case T as failed test case T fail Go to step 4-4);
[0023] 4-4) Check the number of iterations corresponding to the currently generated test case T. If the maximum number of iterations U is reached, take the test case with the last iteration as the successful test case T. success , otherwise go to step (5) for iterative improvement, and the corresponding number of iterative improvements increases by one.
[0024] Furthermore, step (6) specifically includes the following steps:
[0025] 6-1) In container C1, read the successful test case T success Write the contents of the shared folder F share Temporary file F in temp In, transported to container C 2 With container C 3 middle;
[0026] 6-2) Container C 2 With container C 3 For the received temporary file F temp Perform a read operation, use the read content as a test case and execute it, and execute the temporary file F tempThe result obtained is transmitted to container C through the Python third-party library Flask in network communication mode 1 middle;
[0027] 6-3) Container C 1 For container C 2 With container C 3 Compare the feedback numerical results a and b, and calculate the relative difference percentage between the two numerical results: If the err value range is within the (1e-10)% range, it can be considered that the numerical results generated by the two comparison containers have no significant difference, and the numerical results returned by the two containers, the corresponding version numbers, and the successful test cases T success The content, fields and tested method file F are the same old Write the contents of the result json file R json and set the field same to True; otherwise, write the above content to the result json file R json And then set the same field in it to False. Finally, output the successful test case T success Go to step (7).
[0028] Furthermore, in step (7), the mutation rule is as follows:
[0029] Type: small disturbance; description: increase or decrease the original value by 1.
[0030] Type: Sign mutation; Description: Change the sign of the original value, +1 becomes -1.
[0031] Type: Random large and small number mutation; Description: The original value is multiplied by 10 to the 6th power or -10 to the 6th power.
[0032] Type: floating point mutation; Description: increase or decrease the number of digits after the decimal point of the original value.
[0033] Type: Fractional mutation; Description: Take the reciprocal of the original value.
[0034] Type: Exponential mutation; Description: Applies an exponential or square root operation to the original value.
[0035] Compared with the prior art, the present invention has the following advantages and effects:
[0036] The method of the present invention can efficiently generate test cases for the program automation of ROSS software, and realize automated differential testing. By integrating the syntax and semantic information of ROSS software, and combining containerization technology to build an independent test environment, running different versions of programs for differential testing at the same time, the test efficiency is significantly improved and resource waste is reduced. At the same time, the present invention designs a variety of efficient prompt word templates for generating, improving and mutating test cases, which improves the quality and diversity of test cases. Through the grammar detection and correction mechanism and branch coverage verification and optimization, the generated test cases are significantly improved in quality and quantity, and are more in line with actual production needs. The method gets rid of the limitations of traditional methods, does not require complex parameter adjustment, and shows strong flexibility and universality. In a variety of test scenarios, it can effectively reduce the burden on developers in test case design, and improve the automation level and efficiency of the test process, providing an efficient and reliable ROSS software testing solution. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] Figure 1 It is a flow chart of the ROSS software containerized automatic differential testing method based on a large language model of the present invention.
[0038] Figure 2 It is a flow subgraph of the network communication phase based on containerization in the ROSS software containerization automatic differential testing method based on a large language model of the present invention.
[0039] Figure 3 It is a flow subgraph of the test case verification phase in the ROSS software containerized automatic differential testing method based on a large language model of the present invention.
[0040] Figure 4 It is a process subgraph of the result comparison phase based on differential testing in the ROSS software containerized automatic differential testing method based on a large language model of the present invention. DETAILED DESCRIPTION
[0041] The method of the present invention is described in detail below in conjunction with the accompanying drawings, technical solutions and embodiments.
[0042] like Figure 1 As shown, the ROSS software containerized automatic differential testing method for a large language model of the present invention is performed according to the following process: First, use the Dockerfile file to create a container C 1 Container C 2 and container C 3 Build a unified Python environment and test the program set F all Store in container C 1 In the container C 2 and container C 3Configure different versions of ROSS to build a basic control software environment for subsequent differential testing. Then, build network communication for the three containers and mount the shared folder F share In container C1, scan the assembly F under test all , traverse each of the tested method files F old , scan the branch path, perform static code instrumentation on it to generate the method file F after static instrumentation insert , and construct the corresponding test case format T for this file style Finally, the statically instrumented method file F insert And its corresponding test case format T style Construct the initial prompt word template P 1 , the prompt word template is transmitted to the selected large language model to generate test case T.
[0043] Perform syntax check and correction on the generated test case T to ensure the syntax correctness of the test case program. At the same time, perform branch coverage verification on the test case T. If it fails to pass the verification, determine whether the number of iterations of the current test case T has reached the maximum number of iterations U. If it has reached the maximum number of iterations U of the test case T, take the test case of the last iteration and its corresponding test case format T. style Merge as successful test case T success Otherwise, the test case is matched with its corresponding test case format T style Merge as failed test case T fail And the corresponding scanned branch path, executed branch path and unexecuted branch path information to construct a new prompt word template P 2 , which is fed into the selected large language model to generate new test cases T new For the test case T that passes the verification, the corresponding test case format T style Combined with test case T to form successful test case T success And save it to the shared folder F share Temporary folder F in temp In this case, container C 2 and container C 3 It will synchronously receive and read the contents of the file, read the contents into a code program to execute operations and obtain corresponding numerical results, and feed the results obtained by the two containers back to container C. 1 The comparison operation is performed in the result json file R json middle.
[0044] For the current successful test case T success Perform mutation operation. First, determine the successful test case Tsuccess Whether the number of mutations exceeds the maximum number of mutations M, if it has exceeded, the iteration is terminated. Otherwise, the test case T is successfully tested. success , Test method file F old And the mutation rules are combined to construct a new prompt word template P 3 Transmitted to the selected large language model to generate mutated test cases T mutation .
[0045] The following takes the calculate_eccentricity_ratio program in the important Fluid Flow module in ROSS as an example to explain the implementation details of each process in detail. The specific implementation method is as follows:
[0046] (1) Figure 2 As shown in the figure, we build a container-based network communication. First, we use Dockerfile to build a Python environment with the same version and the tested assembly F all Store in container C 1 In, and for container C 2 With C 3 Build different versions of ROSS software. Then, use Docker Compose to build the container C 1 Depends on container C 2 With C 3 The communication network of container C 1 Can be used with container C 2 and container C 3 Interact and mount the same shared folder F for three containers share .
[0047] Through container-based network communication, it is possible to build a container-based 1 The dominant test environment is responsible for generating subsequent test cases and performing mutation operations. 2 and container C 3 It serves as the control group for differential testing and is used to feed back the numerical results obtained by executing the test case to container C. 1 Conduct comparative analysis in.
[0048] 1.1、Dockerfile file construction:
[0049] Container C 1 The Dockerfile-C1 file is as follows:
[0050]
[0051] Container C 2 The Dockerfile-C2 file is as follows:
[0052]
[0053] Container C 3 The Dockerfile-C3 file is as follows:
[0054]
[0055]
[0056] 1.2. Docker Compose build
[0057] After completing the construction of the Dockerfile files for each container, use Docker Compose to build network communication and mount the same shared folder F share , the docker-compose.yml file is as follows:
[0058]
[0059]
[0060]
[0061] By executing the docker-compose.yml file, you can complete the construction of three containers, as well as network communication and mounting shared folders F share 's construction.
[0062] (2) Figure 1 As shown, first, in container C 1 In the process of traversing the tested program set F all Get the method file F old , scan its branch path, and perform static instrumentation on it to obtain the method file F after static instrumentation insert , and construct the corresponding test case format T style , construct a prompt word template P to be supplemented 1 : "For a given program that has been instrumented, the instrumentation function is CountLine (line number), try to generate test cases that meet high branch path coverage: <method under test>; please generate corresponding test cases according to the following test case format: <corresponding test case format>; only generate code without any other description." Use the method under test file F after static instrumentation insert Content and corresponding test case format T styleFill in <tested method> and <corresponding test case format> respectively, and finally obtain a series of natural language precise prompts for inputting the large language model, input the selected large language model, and obtain the generated test case T.
[0063] 2.1 Information Scanning
[0064] a) Scan the program set Fluid Flow under test;
[0065] b) Traverse the calculated_eccentricity_ratio.py file of the method under test, which is defined as follows:
[0066]
[0067]
[0068] c) Perform static instrumentation on the method file calculate_eccentricity_ratio.py to obtain the method file F after static instrumentation insert as follows:
[0069]
[0070]
[0071]
[0072] Among them, the role of the branch path stub function is to insert the CountLine (line number) function after the code line, which is used to count the number of times each line of code is executed. During the execution of the test case, when passing through a certain path, the branch path stub function of the corresponding line number will be called, and it is stipulated that the stub function will not be inserted after the return and raise statements. By counting and recording all the branch path stub functions called during the execution process, all the executed branch paths can be obtained, thereby analyzing the branch path coverage of the program. The branch path stub function is as follows:
[0073]
[0074] d) Through the static instrumentation of the method under test file F insert Perform static code analysis on the function and automatically build the corresponding test case format T style as follows:
[0075]
[0076] e) Combine the above contents into the prompt word template P 1In this implementation, Qwen2.5-Code is selected as the large language model for testing. The generated test case T is as follows:
[0077]
[0078] In this way, we can effectively generate diverse test cases for specific functions and generate effective and reliable test cases for differential testing.
[0079] (3) Figure 3 As shown, test case verification. The test case T generated in (2) is verified. First, the syntax of the test case T is checked and corrected to complete the missing brackets and characters. Then the branch path coverage of the test case T is verified to determine whether the branch path coverage of the current test case T is 100%. If so, the test case T is compared with its corresponding test case format T. style Merge as successful test case T success Otherwise, determine whether the number of iterations of the current test case T has reached the maximum number of iterations U. If so, take the last iteration of the improved test case and its corresponding test case format T. style Merge as successful test case T success Otherwise, the test case T is matched with its corresponding test case format T style Merge as failed test case T fail Enter the subsequent iterative improvement process, and the corresponding iterative improvement number increases by one.
[0080] 3.1. Syntax detection and correction. For the generated test case T, the regular expression is used to identify the missing right bracket in the fourth statement, so the missing bracket is automatically completed, and the corrected test case T is as follows:
[0081]
[0082]
[0083] 3.2. Branch path coverage verification. By performing branch path coverage verification on the test case T, the execution path obtained by the instrumented function is as follows:
[0084] “
[0085] {1:1,2:1,3:1,4:1,8:1,9:1,5:6,6:6,10:1}
[0086] {1:2,2:2,3:2,4:2,8:4,9:2,5:11,6:11,10:2}
[0087] {1:3,2:3,3:3,4:3,8:7,9:3,5:16,6:16,10:3}
[0088] {1:4,2:4,3:4,4:4,8:10,9:4,5:21,6:21,10:4}
[0089] ”
[0090] The path is represented by a key-value pair, which represents "code line: execution times". From this statistical analysis, the test case T is executed on all path nodes, and the branch path coverage rate reaches 100%, so the test case T is regarded as a successful test case T. success .
[0091] (4) Figure 1 As shown, for the test case that failed in (3), the test case T and its corresponding test case format T style Merge as failed test case T fail , and the method under test file F after static instrumentation insert The content, scanned branch paths, executed branch paths, and unexecuted branch paths are merged and integrated to fill in the prompt word template P 2 In the example above, it is fed into the selected large language model to generate new test cases T new , and proceed to (3) for test case verification.
[0092] (5) Figure 4 As shown in the figure, the results of differential testing are compared. success Read to shared folder F share Temporary file F temp In this case, container C 2 With container C 3 Synchronously receive the file and read its contents, execute the test case contents to obtain the corresponding numerical results, and feed the numerical results generated by the two containers back to container C 1 In container C 1 The relative difference percentage of the numerical results fed back by the two containers is calculated to obtain the err value. If the err value range is within the range of (1e-10)%, it can be considered that the numerical results fed back by the two containers have no significant difference, and the field same is set to True, otherwise it is set to False. The field same, the numerical results returned by the two containers, the corresponding version number, and the successful test case T success The contents of the tested method file Fold are merged and written into the result json file R json middle.
[0093] Specifically, get container C 2 The returned numerical results are as follows:
[0094] “ 0.9998904349385358 0.008840344745393159 0.0031830243464929958 0.04999999999999999
[0099] ”
[0100] Container C 3 The returned numerical results are as follows:
[0101] “ 0.9998904349385361 0.008840344745393154 0.0031830243464929971 0.04999999999999999
[0106] ”
[0107] By feeding the results of these two containers into container C 1 The relative difference percentage is calculated in the following err value results:
[0108]
[0109] From the results, all numerical results are within the acceptable range, so the value of the field same is set to False, and the field same, the numerical results returned by the two containers, the corresponding version numbers, and the successful test case T are added. success Contents and test method file F old The contents of the merged result are written into the json file R json The result json file R json as follows:
[0110]
[0111]
[0112]
[0113] Thus, an effective automated differential testing process is completed.
[0114] (6) Figure 1As shown, for a successful test case T that has completed a differential test case process success First, determine whether the number of mutations exceeds the maximum number of mutations M. If so, terminate the iteration; otherwise, compare it with the mutation rule and the method file F to be tested. old Merge fill prompt word template P 3 , and the prompt word template P 3 Transmitted to the selected large language model for mutation test case T mutation Generation of.
[0115] Specifically, for a successful test case T success , the mutation test case T obtained after the mutation of the mutation rule mutation as follows:"
[0116]
[0117]
[0118] The four test statements were subjected to small amplitude perturbation, sign mutation, random large number and small number mutation, and fraction mutation operations respectively.
[0119] Therefore, through mutation operations, the number and diversity of test cases are increased.
Claims
1. An automatic differential testing method for ROSS software containerization based on a large language model, characterized in that: The specific steps are as follows: Step (1) construct three containers, C1, C2 and C3, respectively, build the same version of Python environment for the three containers, build different versions of ROSS software environment for container C2 and container C3, build network communication for the three containers, and build the tested program set F all Save to container C1 and mount the same shared folder F for the three containers share ; Step (2) In container C1, the program set F all Scan and check each method file F old , scan the branch path, perform static code instrumentation on the code, and generate the method file F after static instrumentation insert , and construct the corresponding test case format T style ; Step (3) In container C1, construct a prompt word template P1 to be supplemented: "For a given program that has been code-instrumented, the instrumentation function is CountLine (line number), try to generate a test case that satisfies a high branch path coverage rate: <test method>; please generate the corresponding test case according to the following test case format: <corresponding test case format>; only generate code without any other description;" Use the statically instrumented test method file F obtained in step (2) insert Content and corresponding test case format T style Fill in <test method> and <corresponding test case format> respectively, and finally obtain a series of natural language precise prompts for inputting the large language model, input the selected large language model, and obtain the generated test case T; Step (4) sets the maximum number of iterations U; in container C1, performs syntax check and correction on the generated test case T, and then performs branch coverage verification on the generated test case T. If the verification passes, the corresponding test case format T is style Merge with test case T as successful test case T success Go to step (6), otherwise the corresponding test case format T style Merge with test case T as failed test case T fail Go to step (5) to perform iterative improvement operation; if the number of iterative improvements of the current test case has reached its maximum number of iterative improvements U, then take the test case of the last iterative improvement and its corresponding test case format T style Merge as successful test case T success ; Step (5) In container C1, construct a prompt word template P2 to be supplemented: "For a given program that has been code-instrumented: <test method>'s test case: <test case>'s branch coverage is improved, where the instrumented function is CountLine (line number), previous coverage information: <coverage information>, please improve the test case, only generate code without any other description;" Use the statically instrumented test method file F obtained in step (2) insert Fill <method under test> with the content of the test case T that failed the verification fail Fill <test case>, use the information of the scanned branch path, executed branch path and unexecuted branch path generated by the test case scanning in the branch coverage verification process to merge and fill <error information>, and input it into the selected large language model to obtain the improved test case T new Go to step (4); Step (6) In container C1, read the successful test case T success Write the contents of the shared folder F share Temporary file F in temp , and transported to container C2 and container C3; container C2 and container C3 receive temporary file F temp Perform a read operation and execute the temporary file F temp The results are fed back to the container C1 for comparison; and the comparison results are written into the result json file R json In the output, the successful test case T success Go to step (7); Step (7) Set the maximum number of mutations M; in container C1, construct a prompt word template P3 to be supplemented: "For the following test case: <test case>, perform random mutation according to the given mutation rule, tested function information: <test function>, require mutation while retaining the branch path coverage of the existing test case: <mutation rule table>"; use the successful test case T success And the test method file F old The contents of <test case> and <tested function> are filled in respectively, and the <mutation rule table> is filled in with mutation rules; for successful test case T success Perform mutation operation according to mutation rules to obtain the test case T after mutation mutation Go to step (6); if the number of mutations of the current test case exceeds the maximum number of mutations M, terminate the iteration and traverse the next method file F to be tested old , until the tested program set F all Until the traversal is completed; Step (8) Output the result json file R json .
2. The ROSS software containerized automatic differential testing method based on a large language model according to claim 1 is characterized in that: Step (1) specifically includes the following steps: 1-1) Build Dockerfile files for container C1, container C2, and container C3 respectively, build the same version of Python environment for the three containers, and build different versions of ROSS software environment for container C2 and container C3; 1-2) The program set F to be tested all Save to container C1; 1-3) Use Docker Compose to build a communication network in which container C1 depends on containers C2 and C3, and mount the same shared folder F for the three containers. share .
3. The ROSS software containerized automatic differential testing method based on a large language model according to claim 1 is characterized in that: Step (4) specifically includes the following steps: 4-1) Set the number of iteration improvements U for the currently generated test case T; 4-2) In container C1, use regular expressions to perform syntax checking and calibration on the generated test case T, and complete the missing brackets and characters; 4-3) Perform branch coverage verification on the test case T; if its branch path coverage is 100%, it passes the verification, then the corresponding test case format T style Merge with test case T as successful test case T success Go to step (6); otherwise, the corresponding test case format T style Merge with test case T as failed test case T fail Go to step 4-4); 4-4) Check the number of iterations corresponding to the currently generated test case T. If the maximum number of iterations U is reached, take the test case with the last iteration as the successful test case T. success , otherwise go to step (5) for iterative improvement, and the corresponding number of iterative improvements increases by one.
4. The ROSS software containerized automatic differential testing method based on a large language model according to claim 1 is characterized in that: Step (6) specifically includes the following steps: 6-1) In container C1, read the successful test case T success Write the contents of the shared folder F share Temporary file F in temp , transported to container C2 and container C3; 6-2) Container C2 and container C3 receive temporary file F temp Perform a read operation, use the read content as a test case and execute it, and execute the temporary file F temp The result obtained by the Python third-party library Flask is transmitted to the container C1 via network communication; 6-3) Container C1 compares the numerical results a and b fed back by containers C2 and C3, and calculates the relative difference percentage between the two numerical results: If the err value range is within the range of (1e-10)%, it is considered that there is no significant difference in the numerical results generated by the two comparison containers, and the numerical results returned by the two containers, the corresponding version numbers, and the successful test cases T success The content, fields and tested method file F are the same old Write the contents of the result json file R json and set the field same to True; otherwise, write the above content to the result json file R json And set the same field in it to False; finally, output the successful test case T success Go to step (7).
5. The ROSS software containerized automatic differential testing method based on a large language model according to claim 1 is characterized in that: In step (7), the mutation rules are as follows: Type: small disturbance; description: increase or decrease the original value by 1; Type: Sign mutation; Description: Change the sign of the original value, +1 becomes -1; Type: random large and small number mutation; description: the original value is 10 to the 6th power or -10 to the 6th power; Type: floating point mutation; Description: increase or decrease the number of digits after the decimal point of the original value; Type: fractional mutation; description: take the reciprocal of the original value; Type: Exponential mutation; Description: Applies an exponential or square root operation to the original value.