A method, device, medium and product for identifying software key functions

By extracting test cases from the software user manual and building a method call diagram, and identifying software key functions in combination with structural entropy indicators, the problem of low accuracy of software key functions recognition in the existing technology is solved, and the comprehensibility and maintenance efficiency of the software are improved.

CN119377092BActive Publication Date: 2025-05-30ZHEJIANG GONGSHANG UNIVERSITY
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411909261.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-12-24
Publication Date
2025-05-30
Estimated Expiration
2044-12-24

AI Technical Summary

Technical Problem

The prior art has low accuracy when identifying software key functions, resulting in poor comprehensibility and low maintenance efficiency.

Method used

By extracting test cases from the software user manual, running the software to determine the running trajectory, abstract the call relationship between functions as a method call graph, and calculate the importance value of the function based on the structural entropy index to identify the software key functions.

Benefits of technology

It improves the accuracy of software key functions recognition, enhances the comprehensibility and maintenance efficiency of the software, and makes up for the shortcomings of existing static and dynamic analysis.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119377092B_ABST
    Figure CN119377092B_ABST
Patent Text Reader

Abstract

The present application discloses a method, device, medium and product for identifying software key functions, relating to the field of computer technology. The method extracts a plurality of test cases of the software to be tested according to the user manual of the software to be tested; runs the software to be tested according to the plurality of test cases to determine the running track of the software to be tested; based on the running track, abstracts the call relationship between functions during the running process of the software to be tested into a method call graph; uses the running track to correct the method call graph to determine the corrected method call graph; according to the corrected method call graph, calculates the structural entropy index value of the function corresponding to each node in the corrected method call graph as the importance value of the function corresponding to the node; based on the importance value of the function corresponding to each node and a preset threshold, identifies the software key functions in the software to be tested. It realizes the accurate identification of software key functions and improves the understanding and effective maintenance of the software to be tested.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and particularly to a method, device, medium and product for identifying key functions of software. Background Art

[0002] To understand a large software system, an effective method is to start from the core elements of the software (such as packages, classes, functions, attributes, etc.), gradually expand to other related elements, and finally master the overall structure. Existing research has tried various methods to identify these core elements. However, there are still the following deficiencies.

[0003] (1) Static analysis mainly extracts the call relationships between functions during software operation from the source code of the software, but the call relationships between functions extracted by static analysis are inaccurate.

[0004] (2) Existing dynamic analysis mainly focuses on the identification of key classes and key packages, lacking the identification of key functions of software, resulting in poor understandability and low maintenance efficiency of the software.

[0005] (3) Existing dynamic analysis techniques rely on the log information collected during the daily operation of the software to parse the software functions and the relationships between functions. For some software lacking log information, the existing dynamic analysis techniques cannot be used, resulting in a low accuracy rate for identifying key functions of the software.

[0006] (4) In existing static analysis and dynamic analysis, the importance of functions used during software operation is not considered, and the existing indicators for evaluating the importance of functions used during software operation are not accurate enough, resulting in a low accuracy rate for identifying key functions of the software.

[0007] Based on the above deficiencies, how to effectively identify key functions of software based on dynamic analysis and the importance indicators of functions during software operation to improve the understandability and maintainability of the software has important theoretical and practical significance. Summary of the Invention

[0008] The purpose of the present application is to provide a method, device, medium and product for identifying key functions of software, which can solve the problems of poor understandability and low maintenance efficiency of the software caused by the low accuracy rate of identifying key functions of the software.

[0009] To achieve the above purpose, the present application provides the following solutions.

[0010] First aspect, the present application provides a method for identifying software key functions, and the method for identifying software key functions includes: extracting a plurality of test cases of the software to be tested according to the user manual of the software to be tested; running the software to be tested according to the plurality of test cases to determine the running track of the software to be tested; abstracting the call relationship between functions during the running of the software to be tested into a method call graph based on the running track; the call relationship between functions represents the call relationship between nodes in the method call graph, and the call relationship between functions is determined based on dynamic analysis; determining a corrected method call graph based on the running track and the method call graph; constructing a structural entropy index according to the corrected method call graph, and calculating the structural entropy index value of the function corresponding to each node in the corrected method call graph as the importance value of the function corresponding to the node; determining the software key functions of the software to be tested based on the importance value of the function corresponding to each node and a preset threshold.

[0011] Second aspect, the present application provides a computer device, including: a memory, a processor, and a computer program stored on the memory and executable on the processor, and the processor executes the computer program to implement the method for identifying software key functions described above.

[0012] Third aspect, the present application provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the method for identifying software key functions described above is implemented.

[0013] Fourth aspect, the present application provides a computer program product, including a computer program, and when the computer program is executed by a processor, the method for identifying software key functions described above is implemented.

[0014] According to the specific embodiments provided by the present application, the following technical effects are disclosed in the present application.

[0015] The present application provides a method, device, medium, and product for identifying software key functions. First, for the running of the software to be tested in the present application, the test cases extracted from the user manual are used, which provides a new idea for extracting the running track of the software to be tested. Compared with the dynamic analysis method based on the running log of the software to be tested, the method for obtaining the running track based on the user manual in the present application is more general and can be used to obtain more running tracks of the software to be tested. Then, based on the running track, the call relationship between functions during the running of the software to be tested is abstracted into a method call graph, and the call relationship between functions is determined based on dynamic analysis. Therefore, compared with static analysis, the call relationship between functions determined by dynamic analysis in the present application is more accurate and can more truly reflect the interaction relationship between functions during software running, thus improving the accuracy of identifying software key functions.

[0016] Further, according to the corrected method call graph, a structural entropy index is constructed, and the structural entropy index can accurately evaluate the importance of functions. It can be seen that by calculating the structural entropy index values of the functions corresponding to each node in the corrected method call graph, the importance of the functions corresponding to the nodes can be accurately identified, making up for the problem in existing static analysis and dynamic analysis that the recognition accuracy of key functions of the software to be tested is low due to the failure to consider the influence of the importance of the functions used during the operation of the software to be tested. Furthermore, based on the accurately identified key functions of the software, the understanding and effective maintenance of the software to be tested can be improved, providing technical support for the development of highly reliable software to be tested. Description of the Drawings

[0017] To more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the drawings required for use in the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For those of ordinary skill in the art, without creative efforts, other drawings can also be obtained based on these drawings.

[0018] Figure 1 It is a schematic flowchart of a method for identifying key functions of software provided in an embodiment of the present application.

[0019] Figure 2 It is a method call graph of a method for identifying key functions of software provided in an embodiment of the present application.

[0020] Figure 3 It is an execution mode graph of a method for identifying key functions of software provided in an embodiment of the present application.

[0021] Figure 4 It is a corrected method call graph of a method for identifying key functions of software provided in an embodiment of the present application. Detailed Embodiments

[0022] The following will clearly and completely describe the technical solutions in the embodiments of the present application with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only some embodiments of the present application, rather than all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative efforts belong to the scope of protection of the present application.

[0023] To make the above objects, features, and advantages of the present application more obvious and understandable, the present application will be further described in detail below with reference to the drawings and specific embodiments.

[0024] As Figure 1 shown, the present application provides a method for identifying key functions of software, including step 101 - step 106.

[0025] Step 101: Extract multiple test cases of the software under test according to the user manual of the software under test.

[0026] In some embodiments, step 101 specifically includes: splitting the sentences in the user manual based on the Stanford Parser tool to determine the core elements of each sentence; the core elements include the key dependency relationships among the subject, verb, adjective, and object; based on the core elements of each sentence, constructing a dependency tree of the sentence and extracting the operation information in the dependency tree; the operation information includes the verb, the subject, and the object; generating the multiple test cases according to the respective operation information.

[0027] Among them, the extracted operation information such as the verb, subject, and object is used as a test case structure, and the parsing result is output as a structured text file. Each line in the file includes: operation behavior (operation verb), operation object (noun), and related description information and other operation information. That is, the text information in the user manual of the software under test is parsed, and the relevant verb-object structure is extracted to generate test cases.

[0028] Exemplarily, use the following partial information of the user manual, as shown below:

[0029] After launching the application, the user will see three buttons: Addition Button, Subtraction Button, and Five Addition Button.

[0030] First, the user can click the Addition Button to perform an operation that increments the current value by 1.

[0031] Next, the user can click the Subtraction Button to perform an operation that decrements the current value by 1.

[0032] Finally, the user can click the FiveAddition Button to perform an operation that increments the current value by 5.

[0033] Part of the user manual describes that there are three buttons in the software interface, namely the Addition Button, the Subtraction Button, and the FiveAddition Button. After the user clicks the Addition Button, the number will increase by 1; after the user clicks the Subtraction Button, the number will decrease by 1; after the user clicks the FiveAddition Button, the number will increase by 5. Parse the information in this user manual using the Stanford Parser tool. First, label the part of speech of each word in each clause. For example, "NN" represents a common noun, "VB" represents a verb, and "VBG" represents the present participle form of a verb, etc. Second, identify the core elements in the sentence structure, such as the subject, object, verb, etc., and their relationships. Here, mainly focus on key dependency relationships such as "nsubj" (subject), "dobj" (direct object), "amod" (adjective modifier), etc. "User" is the subject of this sentence, indicating the person who performs the action; "click" is the main verb of the sentence, indicating the action performed; "Addition Button" is the direct object of "click", indicating the object that the user clicks. Finally, take the extracted subject ("user"), operation verb - operation object pairs ("click" - "Addition Button"), etc. as a test case structure and output it to a text file. Parse the partial information of the above user manual, and the partial information of the extracted test case is as follows:

[0034] 1;1:user2:launch%VBG|application%NN;3:

[0035] 2;1:user2:click%VB|Addition Button%NN;perform%VB|operation%NN;3:that|increment;by|1;

[0036] 3;1:user2:click%VB|Subtraction Button%NN;perform%VB|operation%NN;3:by|1;

[0037] 4;1:user2:click%VB|FiveAddition Button%NN;perform%VB|operation%NN;3:that|increment;by|5;

[0038] It can be seen from the above-extracted results that each line consists of three parts. The first part represents the main role performing the action, the second part represents the operation verb-operation object pair, and the third part records the detailed description of the object or target. This application mainly focuses on the second part and uses it as test cases. There are 4 test cases obtained from the above-extracted results. The first one allows the user to run the application, the second one allows the user to click the "Addition" button, the third one allows the user to click the "Subtraction" button, and the fourth one allows the user to click the "FiveAddition" button.

[0039] Step 102: Run the software under test according to the multiple test cases to determine the running trajectory of the software under test.

[0040] In some embodiments, step 102 specifically includes: developing a script for collecting the running trajectory of the software according to the AspectJ framework; embedding the script into the source code of the software under test, running the multiple test cases, and determining the running trajectory of the software under test.

[0041] Among them, develop a script for collecting the running trajectory of the software based on the AspectJ framework and embed it into the source code of the software, so as to realize real-time monitoring of the runtime behavior of the software (such as monitoring method calls, message passing, and resource usage, etc.). According to the test cases generated in step 101, operate on the software, and use the tool developed in step 102 to track, capture, and record the running trajectory, and save the running trajectory in a.dat format log file.

[0042] Exemplarily, the Java software source code is as follows:

[0043] public class App {

[0044] public static void main(String[] args) {

[0045] System.out.println( "Hello World!" );

[0046] App app = new App();

[0047] / / Simulate the user clicking the addition button

[0048] app.onAddClick(5);

[0049] / / Simulate user clicking the subtract button

[0050] app.onSubClick(5);

[0051] / / Simulate user clicking the add 5 button

[0052] app.onAddFiveClick(10);

[0053] }

[0054] private void onAddClick(int a) {

[0055] int result = add(a);

[0056] System.out.println("Result: " + result);

[0057] }

[0058] private void onSubClick(int a) {

[0059] a = add(a);

[0060] a = sub(a);

[0061] int result = sub(a);

[0062] System.out.println("Result: " + result);

[0063] }

[0064] public void onAddFiveClick(int a) {

[0065] int result = a;

[0066] for (int i = 0; i<5; i++) {

[0067] result = add(result);

[0068] }

[0069] System.out.println("Final Result after adding 5: " + result);

[0070] onAddClick(a);

[0071] }

[0072] private int add(int a) {

[0073] return a + 1;

[0074] }

[0075] private int sub(int a) {

[0076] return a - 1;

[0077] }

[0078] }

[0079] Furthermore, perform corresponding operations on the software interface according to the test cases obtained in step 101. In the Java software source code, manually call methods to replace actual interface operations such as clicking buttons. According to the Java software source code, after running the software, first execute the main function, and then after the user clicks the "Addition" button, the onAddClick function is called 1 time, and the add function is called 1 time through the onAddClick function; next, the user clicks the "Subtraction" button, the onSubClick function is executed 1 time, and the add function is called 1 time and the sub function is called 2 times through the onSubClick function; next, the user clicks the "FiveAddition" button, the onAddFiveClick function is executed 1 time, the add function is called 5 times and the onAddClick function is called 1 time through the onAddFiveClick function, and then the add function is called 1 time through the onAddClick function. After all the test cases are executed, the following execution trace is finally obtained:

[0080] $1;1728751817229372200;public org.example.App. <init> (); <no-session-id>;6233544834234187777;1728751817229145900;1728751817229156700;DESKTOP-0JCC7QM;1;1

[0081] $1;1728751817230262900;private int org.example.App.add(int); <no-session-id>;6233544834234187777;1728751817230250200;1728751817230257700;DESKTOP-0JCC7QM;3;2

[0082] $1;1728751817230366500;private void org.example.App.onAddClick(int); <no-session-id>;6233544834234187777;1728751817230223700;1728751817230363800;DESKTOP-0JCC7QM;2;1

[0083] $1;1728751817230406100;private int org.example.App.add(int); <no-session-id>;6233544834234187777;1728751817230400000;1728751817230404000;DESKTOP-0JCC7QM;5;2

[0084] $1;1728751817230439600;private int org.example.App.sub(int); <no-session-id>;6233544834234187777;1728751817230430800;1728751817230437600;DESKTOP-0JCC7QM;6;2

[0085] $1;1728751817230470600;private int org.example.App.sub(int); <no-session-id>;6233544834234187777;1728751817230457400;1728751817230461500;DESKTOP-0JCC7QM;7;2

[0086] $1;1728751817230531600;private void org.example.App.onSubClick(int); <no-session-id>;6233544834234187777;1728751817230392400;1728751817230527900;DESKTOP-0JCC7QM;4;1

[0087] $1;1728751817230573700;private int org.example.App.add(int); <no-session-id>;6233544834234187777;1728751817230568800;1728751817230571900;DESKTOP-0JCC7QM;9;2

[0088] $1;1728751817230591800;private int org.example.App.add(int); <no-session-id>;6233544834234187777;1728751817230581000;1728751817230589600;DESKTOP-0JCC7QM;10;2

[0089] $1;1728751817230605400;private int org.example.App.add(int); <no-session-id>;6233544834234187777;1728751817230601500;1728751817230604200;DESKTOP-0JCC7QM;11;2

[0090] $1;1728751817230617500;private int org.example.App.add(int); <no-session-id>;6233544834234187777;1728751817230613000;1728751817230616500;DESKTOP-0JCC7QM;12;2

[0091] $1;1728751817230627600;private int org.example.App.add(int); <no-session-id>;6233544834234187777;1728751817230622300;1728751817230625800;DESKTOP-0JCC7QM;13;2

[0092] $1;1728751817230707900;private int org.example.App.add(int); <no-session-id>;6233544834234187777;1728751817230702500;1728751817230705600;DESKTOP-0JCC7QM;15;3

[0093] $1;1728751817230749300;private void org.example.App.onAddClick(int); <no-session-id>;6233544834234187777;1728751817230697300;1728751817230747500;DESKTOP-0JCC7QM;14;2

[0094] $1;1728751817230756400;public void org.example.App.onAddFiveClick(int); <no-session-id>;6233544834234187777;1728751817230563100;1728751817230755200;DESKTOP-0JCC7QM;8;1

[0095] $1;1728751817230760800;public static void org.example.App.main(java.lang.String[]); <no-session-id>;6233544834234187777;1728751817228521400;1728751817230759800;DESKTOP-0JCC7QM;0;0

[0096] Among them, each line corresponds to a record, and each record represents a function call. Each record consists of ten fields, and each field is separated by a semicolon ";". Here, we mainly focus on the third value indicating the called class and function, the ninth value being the execution order index (eoi), and the tenth value representing the stack depth (ess).

[0097] Exemplarily, $1 represents the type of the monitoring record, and 172875181722937220 represents the difference between the current moment and a preset historical moment, with the difference converted to a time unit of nanoseconds. Among such information in the running tracks such as 623354483423418777 and 172875181722914590, they are all time information and will not be elaborated here one by one.

[0098] Step 103: Based on the running track, abstract the call relationship between functions during the running of the software to be tested into a method call graph; the call relationship between functions represents the call relationship between the functions corresponding to the nodes at both ends of the directed edge in the method call graph, and the call relationship between functions is determined based on dynamic analysis.

[0099] In some embodiments, the method call graph in step 103 includes a set of nodes and a set of directed edges; the set of nodes is the set of functions actually executed during the running of the software to be tested; the directed edge indicates that the function corresponding to the node at one end of the directed edge calls the function corresponding to the node at the other end of the directed edge; each directed edge is assigned an edge weight value; the edge weight value represents the total number of times the call relationship between the functions corresponding to the nodes at both ends of the directed edge appears during the running of the multiple test cases.

[0100] Among them, the functions, the call relationship between functions, and the number of function calls in step 103 are the functions actually executed, the actual call relationships between functions, and the actual number of function calls generated during the execution of the test cases, which is a kind of dynamic analysis (information that can only be collected during the running of the software), rather than static analysis based on source code (information obtained by analyzing the source code without running the software). At the same time, there are also significant differences between the present application and the analysis method based on software running logs. The method based on running logs collects information during the daily running of the software, reflecting the user's usage preferences, while the present application is based on the operation manual and collects the functions required to implement all functions of the software, the calls between functions, and the number of calls between functions.

[0101] In practical applications, the call relationship information between functions obtained from the analysis of the running trajectory is as follows:

[0102] public static void org.example.App.main(java.lang.String[])publicorg.example.App. <init>()

[0103] public static void org.example.App.main(java.lang.String[])private void org.example.App.onAddClick(int)

[0104] private void org.example.App.onAddClick(int)private int org.example.App.add(int)

[0105] public static void org.example.App.main(java.lang.String[])private void org.example.App.onSubClick(int)

[0106] private void org.example.App.onSubClick(int)private int org.example.App.add(int)

[0107] private void org.example.App.onSubClick(int)private int org.example.App.sub(int)

[0108] private void org.example.App.onSubClick(int)private int org.example.App.sub(int)

[0109] public static void org.example.App.main(java.lang.String[])public void org.example.App.onAddFiveClick(int)

[0110] public void org.example.App.onAddFiveClick(int)private int org.example.App.add(int)

[0111] public void org.example.App.onAddFiveClick(int)private int org.example.App.add(int)

[0112] public void org.example.App.onAddFiveClick(int)private int org.example.App.add(int)

[0113] public void org.example.App.onAddFiveClick(int)private int org.example.App.add(int)

[0114] public void org.example.App.onAddFiveClick(int)private int org.example.App.add(int)

[0115] public void org.example.App.onAddFiveClick(int)private void org.example.App.onAddClick(int)

[0116] private void org.example.App.onAddClick(int)private int org.example.App.add(int)

[0117] From the call relationships between the above functions, it can be seen that each line represents the former function calling the latter function once. Then, abstract the call relationship into Figure 2 the method call graph MCG = ( N , L ). Among them, , N represents the set of functions actually executed during software runtime; L ={(main, onAddClick), (onAddClick, add), (main,onSubClick), (onSubClick, add), (onSubClick, sub), (main, onAddFiveClick),(onAddFiveClick, add), (onAddFiveClick, onAddClick)}, L represents the set of call relationships between functions (i.e., the set of directed edges), and the direction is that the former calls the latter.

[0118] Step 104: Use the running trace to correct the method call graph and determine the corrected method call graph.

[0119] Among them, the corrected method call graph is represented by UMCG, and the N and L is the same as that of MCG. The main difference is that UMCG corrects the edge weights in MCG.

[0120] In some embodiments, step 104 specifically includes steps 201 - 203.

[0121] Step 201: Determine the subgraph corresponding to the test case according to the running trace corresponding to any test case; use the subgraph as the execution mode of the test case.

[0122] Step 202: For any directed edge in the execution mode, determine the old edge weight of the directed edge, and count the co-occurrence times of the call relationships between the functions corresponding to the nodes at both ends of the directed edge in the execution modes of each test case.

[0123] Step 203: Determine the new edge weight of the directed edge according to the co-occurrence times and the old edge weight; determine the corrected method call graph according to the new edge weight corresponding to each directed edge.

[0124] Among them, MCG is constructed by executing the test cases in step 101. Therefore, the functions and the call relationships between functions obtained when executing a specific test case will all constitute a subgraph of MCG. In this application, the subgraph of MCG corresponding to executing a test case is regarded as the execution mode corresponding to this test case.

[0125] Further, count the co-occurrence times of the functions corresponding to the two ends of each directed edge in the MCG in all execution modes, and add this co-occurrence times to the edge weight of this edge as the new edge weight, that is, new edge weight = old edge weight + co-occurrence times. It should be noted that the old edge weight refers to the total number of calls of this directed edge in all execution modes, and the co-occurrence times refer to the number of execution modes in which this directed edge appears.

[0126] Specifically, the call relationship obtained by executing each test case corresponds to a subgraph of the MCG, that is, an execution mode. According to the call relationship between functions corresponding to each test case, three execution modes are obtained. As Figure 3 shown, the number of times the call relationship between functions appears in the execution mode is used as the edge weight. Next, correct the edge weight according to the execution mode, count the co-occurrence times of the functions at both ends of each directed edge in all execution modes, and add this co-occurrence times to the edge weight of this edge as the new edge weight. Figure 3 In the onAddClick function calls the add function in two execution modes, execution mode 1 and execution mode 3, so the co-occurrence times of (onAddClick, add) is 2, and thus correct the edge weight of (onAddClick, add) to 2 + 2 = 4. (main, onAddClick) only appears in one execution mode, execution mode 1, so the co-occurrence times of (main, onAddClick) is 1, and thus correct the edge weight of (main, onAddClick) to 1 + 1 = 2. The correction process of other edge weights is similar. The corrected UMCG graph is as Figure 4 shown. For the convenience of subsequent description, all nodes will be identified using letters A to F.

[0127] In some embodiments, step 203 specifically includes: adding the co-occurrence times to the old edge weight to obtain the new edge weight of the directed edge.

[0128] Step 105: According to the corrected method call graph, construct a structural entropy index, and calculate the structural entropy index value of the function corresponding to each node in the corrected method call graph as the importance value of the function corresponding to the node.

[0129] In some embodiments, step 105 specifically includes steps 301 - 303.

[0130] Step 301: For any directed edge in the corrected method call graph, calculate the relative importance value of the directed edge; ; where is the relative importance of the directed edge ; and All are nodes in the corrected method call graph; is a node The set of functions corresponding to the nodes on the incoming edge; is a directed edge in the corrected method call graph The edge weight of; is the edge in the corrected method call graph The edge weight of; is Any node corresponding function on the incoming edge of the node in ; Is the set of nodes in the corrected method call graph.

[0131] Step 302: Calculate the entropy of the node . ; where, is the entropy of the node ; is the relative importance value of the directed edge The natural logarithm of.

[0132] Step 303: Calculate the structural entropy index value of the node based on the entropy of the node ; ; where, is the structural entropy index value of the node ; is the node The set of functions corresponding to the nodes on the outgoing edge of; is Any node corresponding function in; is a directed edge in the corrected method call graph The edge weight of; is a directed edge in the corrected method call graph The edge weight of; is Any node corresponding function in; is the entropy of the node .

[0133] Among them, all parameters are dimensionless and have no unit.

[0134] In practical applications, calculate the structural entropy index value of any node based on the UMCG constructed in step 104, and use it as the importance value of the corresponding function of the node . The calculation of the structural entropy of the node specifically includes the following steps.

[0135] ​Step 1: Calculate the relative importance of all directed edges < j , i > in the UMCG, that is: ;

[0136] ;

[0137] As Figure 4 shown, all nodes in the corrected UMCG diagram are identified using letters A to F.

[0138] Specifically, Figure 4 the weights of all edges in , , , , , , , .

[0139] Step 2: Based on the obtained in Step 1, calculate the entropy of node e i , that is ; Therefore, Figure 4 the entropies of all nodes in , , , , , .

[0140] Step 3: Based on the entropy of node obtained in Step 2, calculate the structural entropy of node , that is: ; Therefore, Figure 4 the structural entropies of all nodes in

[0141] , , , , , .

[0142] Step 106: Identify the software critical functions in the software to be tested based on the importance values of the functions corresponding to each node and a preset threshold.

[0143] Specifically, based on the structural entropy index values of all nodes obtained in step 105 (i.e., the importance values of the functions corresponding to each node), the importance values of the functions corresponding to each node are sorted in descending order to obtain a sorting result. The functions less than a preset threshold in the sorting result are obtained as the identified software key functions. Among them, the preset threshold can be: the functions ranked in the top 15%.

[0144] Exemplarily, the sorting result is (E: 4.85) > (C: 2.27) > (F: 1.6) > (B = D: 1.33). Figure 4 There are 6 functions in total. Taking the top 15%, that is, 6 × 15% = 0.9, and rounding up to 1. Therefore, the function add corresponding to node E in the top 1 of the sorting result is taken as the software key function.

[0145] The present application discloses a method for identifying software key methods based on dynamic analysis and structural entropy, including the following steps: extracting test cases for running the software from the user manual of the software; running the software developed in Java language according to the test cases to obtain the execution trace of the software; abstracting the call relationship between functions during software operation into a method call graph according to the execution trace; analyzing the call relationship between functions according to the execution trace, and then correcting the method call graph; constructing a structural entropy metric index, and calculating the structural entropy of the function corresponding to the node based on the corrected method call graph; measuring the importance of the function with structural entropy, and regarding the functions ranked in the top 15% (a generally recognized threshold in the field) in the sorting result of the importance values of the functions as key functions. In the present application, the software runs using the test cases extracted from the user manual, which provides a new idea for extracting the execution trace of the software. Compared with the dynamic analysis method based on software operation logs, the strategy used in the present application is more general and can be used to obtain more execution traces of the software. In addition, the present application corrects the method call graph through execution pattern mining, and then calculates the importance of the function. Compared with the dynamic analysis method directly based on software operation logs and method call graphs, the present application can further consider the influence of the execution pattern corresponding to the software operation test cases on the importance of the function. The present application makes up for the deficiencies of the existing static and dynamic analysis in the software key function identification technology, which leads to the problem of the accuracy of software key function identification, and has important significance for improving the efficiency of code understanding and maintenance, and provides technical support for developing highly reliable software.

[0146] In an exemplary embodiment, a computer device is further provided, including a memory and a processor. A computer program is stored in the memory, and when the processor executes the computer program, the above method is implemented.

[0147] In an exemplary embodiment, a computer-readable storage medium is provided, storing a computer program, and when the computer program is executed by a processor, the above method is implemented.

[0148] In an exemplary embodiment, a computer program product is provided, including a computer program which, when executed by a processor, implements the above method.

[0149] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use, and processing of relevant data need to comply with relevant regulations.

[0150] Those of ordinary skill in the art can understand that all or part of the processes of implementing the methods in the above embodiments can be completed by instructing relevant hardware through a computer program. The computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above methods. Among them, any reference to a memory, database, or other medium used in the embodiments provided in this application can include at least one of non-volatile and volatile memories. Non-volatile memories can include read-only memory (ROM), magnetic tapes, floppy disks, flash memories, optical memories, high-density embedded non-volatile memories, resistive random access memories (ReRdM), magnetoresistive random access memories (MRdM), ferroelectric random access memories (FRdM), phase change memories (PCM), graphene memories, etc. Volatile memories can include random access memories (RdM) or external cache memories, etc. By way of illustration and not limitation, RdM can be in various forms, such as static random access memory (SRdM) or dynamic random access memory (DRdM), etc.

[0151] The databases involved in the embodiments provided in this application can include at least one of relational databases and non-relational databases. Non-relational databases can include distributed databases based on blockchain, etc., without limitation. The processors involved in the embodiments provided in this application can be general-purpose processors, central processors, graphics processors, digital signal processors, programmable logics, data processing logics based on quantum computing, etc., without limitation.

[0152] The technical features of the above embodiments can be combined arbitrarily. For the sake of brevity of description, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, it should be considered as the scope recorded in this specification.

[0153] In this text, specific examples are used to elaborate on the principles and implementation manners of the present application. The description of the above embodiments is only used to help understand the method and its core idea of the present application; at the same time, for those of ordinary skill in the art, according to the idea of the present application, there will be changes in the specific implementation manners and application scopes. In summary, the content of this specification should not be construed as a limitation to the present application.< / init> < / init>

Claims

1. A method for identifying key software functions, characterized in that: The method for identifying the key software functions includes: Extract multiple test cases of the software to be tested according to the user manual of the software to be tested; Running the software to be tested according to the multiple test cases to determine the running track of the software to be tested; Based on the running track, the calling relationship between functions in the running process of the software to be tested is abstracted into a method call graph; the calling relationship between functions represents the calling relationship between functions corresponding to the nodes at both ends of the directed edge in the method call graph, and the calling relationship between functions is determined based on dynamic analysis; The method call graph is modified by using the running trajectory to determine the modified method call graph; specifically comprising: determining the subgraph corresponding to any test case according to the running trajectory corresponding to the test case; using the subgraph as the execution mode of the test case; for any directed edge in the execution mode, determining the old edge weight of the directed edge, and counting the number of co-occurrences of the calling relationship between the functions corresponding to the nodes at both ends of the directed edge in the execution mode of each test case; determining the new edge weight of the directed edge according to the co-occurrence number and the old edge weight; determining the modified method call graph according to the new edge weight corresponding to each directed edge; According to the modified method call graph, a structural entropy index is constructed, and the structural entropy index value of the function corresponding to each node in the modified method call graph is calculated as the importance value of the function corresponding to the node; Based on the importance value of the function corresponding to each node and a preset threshold, the key software functions in the software to be tested are identified.

2. The method for identifying software key functions according to claim 1, characterized in that: According to the user manual of the software to be tested, extract multiple test cases of the software to be tested, including: Sentences in the user manual are split based on the Stanford Parser tool to determine the core elements of each sentence; the core elements include key dependencies between subjects, verbs, adjectives, and objects; Based on the core elements of each sentence, a dependency tree of the sentence is constructed, and operation information in the dependency tree is extracted; the operation information includes the verb, the subject, and the object; The multiple test cases are generated according to each of the operation information.

3. The method for identifying software key functions according to claim 1, characterized in that: Running the software to be tested according to the multiple test cases to determine the running track of the software to be tested specifically includes: Develop scripts to collect software running traces based on the AspectJ framework; The script is embedded into the source code of the software to be tested, and the multiple test cases are run to determine the running track of the software to be tested.

4. The method for identifying software key functions according to claim 1, characterized in that: The method call graph includes a set of nodes and a set of directed edges; The set of nodes is a set of functions actually executed when the software to be tested is running; The directed edge indicates that the function corresponding to the node at one end of the directed edge calls the function corresponding to the node at the other end of the directed edge; Each directed edge is assigned an edge weight; The edge weight represents the total number of times the calling relationship between the functions corresponding to the nodes at both ends of the directed edge occurs when the multiple test cases are run.

5. The method for identifying software key functions according to claim 1, characterized in that: Determining a new edge weight of the directed edge according to the number of co-occurrences and the old edge weight specifically includes: The co-occurrence count is added to the old edge weight to obtain a new edge weight of the directed edge.

6. The method for identifying software key functions according to claim 1, characterized in that: Calculating the structural entropy index value of the function corresponding to each node in the modified method call graph as the importance value of the function corresponding to the node specifically includes: Call any directed edge in the modified method graph , calculate the relative importance value of the directed edge; ;in, For directed edges the relative importance of and are all nodes in the modified method call graph; For Node The set of functions corresponding to the nodes on the incoming edge; is the directed edge in the modified method call graph The edge weight of The edge in the modified method call graph The edge weight of for Midpoint Any node on the incoming edge corresponds to a function; is the set of nodes in the modified method call graph; Calculate the node according to the relative importance value Entropy of ;in, For Node Entropy of For directed edges The relative importance value of The natural logarithm of According to the node Entropy calculation node The structural entropy index value of ;in, For Node The structural entropy index value of Is a node The set of functions corresponding to the nodes on the outgoing edges; for Any node in the corresponding function; is the directed edge in the modified method call graph The edge weight of is the directed edge in the modified method call graph The edge weight of for Any node in the corresponding function; For Node The entropy of .

7. A computer device comprising: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the method for identifying key software functions according to any one of claims 1 to 6.

8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method for identifying a key software function described in any one of claims 1 to 6 is implemented.

9. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the method for identifying a key software function described in any one of claims 1 to 6 is implemented.

Citation Information

Patent Citations

  • Effective test case reuse method and device for software fuzz testing

    CN116383092A

  • Software testing method and device, equipment and storage medium

    CN117632694A