A data processing method, related device and storage medium

CN114816971BActive Publication Date: 2026-09-18TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202110073906.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-01-19
Publication Date
2026-09-18
Estimated Expiration
2041-01-19

AI Technical Summary

Technical Problem

目前,一方面,采用程序的文档产生工具Doxgen获取完整调用链的效率不高,而在代码里加入打点信息的方法,获取到的调用链不完整,另一方面,一般完整的调用链所包含的信息量非常庞大,直接使用并不现实,且对于后续改动的代码调用链可能有所不同

Benefits of technology

[0024] As can be seen, the data processing method provided in this embodiment of the invention can compile the target program by submitting information to obtain the complete call chain of the target program, i.e., the complete call chain data. Then, it matches the target call chain associated with the changed function in the source code of the target program in the complete call chain data, takes the call chain where the changed function is the called function as the target call chain, and then aggregates the target call chain. This reduces the amount of information contained in the target call chain and lowers the complexity of the target call chain, so as to generate concise and effective test guidance data. Furthermore, the test guidance data obtained after aggregation can better improve the test coverage of the target program and avoid missed tests after the source code is modified.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114816971B_ABST
    Figure CN114816971B_ABST
Patent Text Reader

Abstract

Embodiments of the present application disclose a data processing method, related equipment and a storage medium, the method comprising: obtaining calling chain data of a target program and submission information, the submission information comprising source code of the target program, and the calling chain data being obtained by compiling the target program according to the submission information; determining a target calling chain associated with a changed function in the source code according to the calling chain data and the submission information, the target calling chain comprising calling chains in which each function calling the changed function is located; performing aggregation processing on the functions included in the target calling chain to obtain test guidance data, the test guidance data comprising one or more of a calling path between classes aggregated according to class names, the changed function, class name note information and a screenshot of a user interface corresponding to the aggregated classes. According to the embodiments of the present application, the calling chain affected by the changed function can be efficiently and accurately obtained, and concise and effective test guidance information can be generated.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer technology, and in particular to a data processing method, related equipment, and storage medium. Background Technology

[0002] In the development of application software, various programming languages ​​are used, such as Objective-C, C, and C++, thus involving the calls between functions of these languages. These call relationships can be represented by call chains, which are instructive in both testing and development. Currently, on the one hand, using documentation tools like Doxgen to obtain complete call chains is inefficient, and adding dotted information to the code results in incomplete chains. On the other hand, a complete call chain typically contains a vast amount of information, making direct use impractical, and the call chain may differ for subsequent code modifications. Therefore, how to accurately and efficiently analyze call chains and use them to guide the testing process is a problem worthy of further research. Summary of the Invention

[0003] In view of the above problems, embodiments of the present invention provide a data processing method, related equipment and storage medium, which can accurately and efficiently obtain the call chain affected by the changed function and generate concise and effective test guidance information.

[0004] One embodiment of the present invention provides a data processing method applied to a server, the method comprising:

[0005] Obtain the call chain data and commit information of the target program. The commit information includes the source code of the target program. The call chain data is obtained by compiling the target program based on the commit information. The call chain data includes at least one call chain, and each call chain is used to indicate the call path between functions in the target program during the compilation process.

[0006] The target call chain associated with the modified function in the source code is determined based on the call chain data and the submission information. The target call chain includes the call chains of each function that calls the modified function.

[0007] The functions included in the target call chain are aggregated to obtain test guidance data. The test guidance data includes one or more of the following: the call paths between classes aggregated by class name, the modified functions, class name annotation information, and screenshots of the user interface corresponding to the aggregated classes.

[0008] One embodiment of the present invention provides a data processing method applied to a terminal device, the method comprising:

[0009] Obtain the submission information for the target program, the submission information including the source code of the target program;

[0010] The target program is compiled according to the submitted information to obtain the call chain data of the target program. The call chain data includes at least one call chain, and each call chain is used to indicate the call path between functions in the target program during the compilation process.

[0011] The submission information and the call chain data are sent to the server so that the server can determine the target call chain associated with the changed functions in the source code based on the call chain data and the submission information, and perform aggregation processing on the functions included in the target call chain to obtain test guidance data.

[0012] One embodiment of the present invention provides a data processing apparatus, comprising:

[0013] The acquisition module is used to acquire the call chain data and submission information of the target program. The submission information includes the source code of the target program. The call chain data is obtained by compiling the target program based on the submission information. The call chain data includes at least one call chain, and each call chain is used to indicate the call path between functions in the target program during the compilation process.

[0014] The determination module is used to determine the target call chain associated with the modified function in the source code based on the call chain data and the submission information, wherein the target call chain includes the call chain of each function that calls the modified function;

[0015] An aggregation module is used to aggregate the functions included in the target call chain to obtain test guidance data. The test guidance data includes one or more of the following: the call paths between classes obtained by aggregation according to class name, the modified functions, class name annotation information, and screenshots of the user interface corresponding to the aggregated classes.

[0016] One embodiment of the present invention provides a data processing apparatus, comprising:

[0017] The acquisition module is used to acquire submission information for the target program, the submission information including the source code of the target program;

[0018] The compilation module is used to compile the target program according to the submission information to obtain the call chain data of the target program. The call chain data includes at least one call chain, and each call chain is used to indicate the call path between functions in the target program during the compilation process.

[0019] The sending module is used to send the submission information and the call chain data to the server, so that the server can determine the target call chain associated with the changed functions in the source code based on the call chain data and the submission information, and perform aggregation processing on the functions included in the target call chain to obtain test guidance data.

[0020] One aspect of the present invention provides a server, including a processor and a memory, and a computer program stored in the memory and capable of running on the processor, wherein the processor invokes the computer program to perform some or all of the steps performed by the server in the above aspect.

[0021] One embodiment of the present invention provides a terminal device, including: a network interface, a processor, and a memory. The network interface, the processor, and the memory are connected. The network interface is used to provide data communication functions, the memory is used to store computer programs, and the processor is used to call the computer programs to execute some or all of the steps performed by the terminal device in the above-mentioned aspect.

[0022] Accordingly, embodiments of the present invention provide a storage medium storing a computer program, the computer program including program instructions, which are loaded and executed by one or more processors to perform the data processing method described above.

[0023] Accordingly, the present invention provides a computer program product or computer program including computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the data processing method described above.

[0024] As can be seen, the data processing method provided in this embodiment of the invention can compile the target program by submitting information to obtain the complete call chain of the target program, i.e., the complete call chain data. Then, it matches the target call chain associated with the changed function in the source code of the target program in the complete call chain data, takes the call chain where the changed function is the called function as the target call chain, and then aggregates the target call chain. This reduces the amount of information contained in the target call chain and lowers the complexity of the target call chain, so as to generate concise and effective test guidance data. Furthermore, the test guidance data obtained after aggregation can better improve the test coverage of the target program and avoid missed tests after the source code is modified. Attached Figure Description

[0025] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0026] Figure 1a This is a schematic diagram of the architecture of a data processing system provided in an embodiment of the present invention;

[0027] Figure 1b This is a schematic diagram of the architecture of another data processing system provided in an embodiment of the present invention;

[0028] Figure 2 This is a flowchart illustrating a data processing method provided in an embodiment of the present invention;

[0029] Figure 3 This is a schematic diagram illustrating the display of test guidance data on a terminal device according to an embodiment of the present invention;

[0030] Figure 4 This is a flowchart illustrating another data processing method provided in an embodiment of the present invention;

[0031] Figure 5 This is a schematic diagram of a syntax generation tree provided in an embodiment of the present invention;

[0032] Figure 6 This is a schematic diagram of a matching expression creation strategy provided in an embodiment of the present invention;

[0033] Figure 7 This is a schematic diagram of the structure of a data processing device provided in an embodiment of the present invention;

[0034] Figure 8 This is a schematic diagram of another data processing device provided in an embodiment of the present invention;

[0035] Figure 9 This is a schematic diagram of the structure of a server provided in an embodiment of the present invention;

[0036] Figure 10 This is a schematic diagram of the structure of a terminal device provided in an embodiment of the present invention. Detailed Implementation

[0037] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of the present invention, and not all of them. Therefore, the following detailed description of the embodiments of the present invention provided in the accompanying drawings is not intended to limit the scope of the claimed invention, but merely to illustrate selected embodiments of the invention. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without inventive effort are within the scope of protection of the present invention.

[0038] Please see Figure 1a This is a schematic diagram of the architecture of a data processing system provided in an embodiment of the present invention, such as... Figure 1a As shown, the architecture of the data processing system may include a server 100 and terminal devices 101. Each terminal device 101 can be connected to the server 100 via a network. The network connection may include a wired connection or a wireless connection, so that each terminal device 101 can interact with the server 100 through the network connection.

[0039] Each terminal device 101 can generate compilation data, such as the source code of the target program, call chain logs, and program compilation logs, and send it to the server 100. Each terminal device 101 can also be used to display business data obtained by the server 100 after parsing the compilation data sent by the terminal device 101. This business data may specifically include modified functions, aggregated target call chains, screenshots of the user interface, and controller functions to be annotated. Each terminal device 101 can also store the aforementioned compilation data and business data. Each terminal device 101 is equipped with a program compilation device, such as the Xcode compiler, for compiling the source code of the target program. Additionally, functional plugins can be added to the compiler to process the source code of the target program accordingly and implement the required functions.

[0040] Server 100 can receive compiled data from each terminal device 101, store it, and parse and process it using relevant functional modules to obtain business data. Server 100 can store business data in a corresponding database and can also send business data to terminal device 101 for display. Server 100 can be a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms.

[0041] It should be noted that the terminal device 101 in the embodiments of the present invention may include: tablet computers, laptop computers, desktop computers, smart TVs, desktop computers, smartphones, smartwatches and other smart terminal devices that can install and compile programs, but is not limited to these.

[0042] For ease of understanding Figure 1a The working principle of the corresponding data processing system architecture will be further explained by referring to the relevant modules contained in server 100 and terminal device 101. Figure 1b It is based on Figure 1a Another data processing system architecture.

[0043] The logical architecture of the data processing system includes modules such as compiler 101a, user / automation 101b, logic layer 100a, storage layer 100b, and web front-end 101c. Among them, compiler 101a, user / automation 101b, and web front-end 101c are all parts that run on terminal device 101, while logic layer 100a and storage layer 100b belong to server 100.

[0044] In its specific implementation, compiler 101a is primarily used to synchronize the generated call chain log to logic layer 100a, and can also submit the source code of the target program to the server. Compiler 101a monitors user operations in real time. Upon detecting a commit command for the target program, it starts the lightweight compiler Clang to compile the target program, obtains the call chain information, and writes it to the call chain log, thus generating the call chain log. The monitoring of commits and the generation of call chain logs are continuously executed components within compiler 101a. Figure 1b The fact that the call chain log is generated and then monitored indicates that this process is ongoing. Once the call chain log is generated, it can be synchronized to logic layer 100a. Specifically, the compiler 101a can generate the call chain log and synchronize it to logic layer 100a simultaneously. For example, it can obtain a call chain and write it to the call chain log, then synchronize it to logic layer 100a at the same time. Alternatively, it can synchronize it to logic layer 100a only after the call chain log contains a certain number of call chains. It can also synchronize it to logic layer 100a only after the target program's generated call chain log includes all of the target program's call chains.

[0045] The User / Automation 101b module is mainly used to report controller function images to the logic layer 100a. Through UI operation, that is, by running the target program using pre-designed test cases, the module takes screenshots of the user interface that jumps to each different function during the target program's runtime, obtains the controller image, and reports the controller image to the logic layer 100a.

[0046] The logic layer 100a is mainly used to receive call chain logs synchronized from the compiler 101a, Controller images reported by the user / automation 101b, and to interact with the storage layer 100b. The call chain log is parsed by the call chain log parsing module in the logic layer 100a. Then, the submission module retrieves the submission information from the database in the storage layer 100b. The submission information includes the source code of the target program. Compared with the previous submission, the target program has changed. Therefore, the submission information can be analyzed by the change function acquisition module to obtain the change function. Then, the impact call chain calculation module is used to perform corresponding calculations on the change function obtained by the change function acquisition module and the call chain data parsed by the call chain log parsing module to obtain the affected call chain. Since the obtained affected call chain may contain call paths consisting of thousands or tens of thousands of function calls, an aggregation module is needed to make it more concise and reduce the length of the function call chain. Then, the Controller image processing module matches the affected call chain with the reported Controller image to obtain the corresponding Controller image. After obtaining the Controller image, the logic layer 100a sends the above business data to the Web frontend 101c.

[0047] The main function of storage layer 100b is to interact with logic layer 100a, store relevant data parsed by logic layer 100a, such as storing the complete call chain data obtained after parsing the call chain logs in storage layer 100b's Redis (a high-performance key-value database), commit logs (including modified functions, i.e., change functions), affected call chains, etc. in other databases, and storing the Controller images corresponding to the aggregated affected call chains in the image library. Furthermore, it can also store the source code of the target program submitted by compiler 101a in the database, and store the Controller images reported by UI operations in the image library, so that the Controller image processing module can obtain the final Controller image by pulling the images in the image library and the affected functions in the database.

[0048] The Web frontend 101c is used to receive the aforementioned business data, namely, commit logs, affected functions, comments (i.e., Controller functions that need comments), test information, and Controller images. The Web frontend 101c visualizes all this business data, providing better guidance for testers and facilitating developers to verify the functions corresponding to the code changes.

[0049] Furthermore, for ease of understanding, please refer to Figure 2 , Figure 2 The embodiments of the present invention are based on Figure 1b The illustrated data processing system provides a flowchart of a data processing method. This method can be executed by a server (e.g., server 100 as described above), and the data processing method may include at least the following steps S201-S203:

[0050] S201, Obtain the call chain data and commit information of the target program. The commit information includes the source code of the target program, and the call chain data is obtained by compiling the target program based on the commit information.

[0051] In one possible embodiment, the submission information includes the source code of the target program stored on the server. After the terminal device receives the submission command, it can store the source code of the target program in a server such as... Figure 1b In the storage layer 100a of the server shown, the source code of the target program can also be stored in the server during synchronous call chain logs or after Clang compilation. This allows the server to directly retrieve the source code included in the current commit information from storage layer 100a. The specific storage method and timing are not limited here. The target program can be the complete code content after modifications to the source code of the target application. Each commit from a terminal device generally involves corresponding development modifications. The target application can be an application running on systems such as iOS, Linux, Windows, and Android, and its functionality is mainly implemented by the corresponding source code. The call chain data of the target program includes at least one call chain, where each call chain indicates the call path between functions during the compilation process of the target program. For example, there exists a call chain with the specific call path represented as: function a → function b → function c. The corresponding call relationship is that function a calls function b, and function b calls function c, where function b and function c are both called functions relative to function a. Typically, for feature-rich target applications, the target program's call chain will not be a simple single call chain, but rather a large number of complex call chains to implement different functions. The aforementioned call chain data is obtained by compiling the target program. Specifically, the terminal device performs the compilation operation, obtains the call chain, writes it to the call chain log, and then synchronizes the call chain log to the server. Figure 1b The call chain log parsing module parses the call chain logs to obtain the call chain data stored in the call chain logs. There are no restrictions on the content and data format of the call chain logs.

[0052] S202, determine the target call chain associated with the modified function in the source code based on the call chain data and the submission information, wherein the target call chain includes the call chains of each function that calls the modified function.

[0053] In one possible embodiment, the compiler 101a monitors the submission commands for the target program in real time, obtains submission information, and stores it on the server. Each submission can be considered a change to the target program relative to the previous submission, such as changing the execution order of functions or modifying function names. In short, any additions, deletions, or modifications to the target program source code of the previous submission can be considered part of the target program. Therefore, the source code of the target program included in the submission information also includes the changed functions. The submission information can be understood as the source code submitted after each development modification. Thus, the changed functions can be obtained first from the source code of the target program included in the submission information. Specifically, this can be executed by the server, utilizing the above... Figure 1b The submission module in the middle logic layer 100a first retrieves the submission information from the storage layer 100b, and then uses the change function module to analyze the submission information. Optionally, the analysis principle of the change function module can be based on the association between code and line number, that is, the code content and line number correspond one-to-one. When the code content changes, the corresponding line number will also change. Generally speaking, the modified code is the code included in a certain sub-function, so the line number corresponding to the sub-function will not change, but the line number of the modified code will definitely change. The sub-function can be mapped according to the changed line number and used as the change function. The modified code is obtained by comparing the source code of the target program in this submission with the source code of the target program in the previous submission. As an extensible method, each change can also be recorded as a log. By parsing the log, the modified code can be directly obtained, and then the change function can be obtained.

[0054] Then, based on the call paths between functions indicated by each call chain, the target call chain for calling the modified function is determined from at least one call chain. Specifically, since call chain data includes multiple call chains indicating call paths, if the modified function calls other functions but is not called by those functions, the call chain containing the modified function will not be affected and cannot be considered a target call chain. However, if other functions call the modified function, meaning the modified function is the called function and its functionality is affected, then it can be considered a target call chain. For example, if the modified function is c, and there are two call chains: function a → function b → function c → function e, and function c → function g → function m, the former, where the modified function c is the called function, can be considered a target call chain, i.e., the affected call chain. However, the latter, where the modified function c is no longer the called function, will not affect the call chain and therefore cannot be considered a target call chain; that is, this call chain is not the call chain containing the functions that call the modified function.

[0055] Using the above method, the changed function is obtained based on the submitted information and call chain data, and then the call chain data is obtained, ultimately resulting in the target call chain. The acquisition of the target call chain is automated and intelligent through automatic parsing and summarization by the server.

[0056] S203, aggregate the functions included in the target call chain to obtain test guidance data. The test guidance data includes one or more of the following: the call paths between classes aggregated by class name, the modified functions, class name annotation information, and screenshots of the user interface corresponding to the aggregated classes.

[0057] In one possible implementation, some feature-rich target applications involve millions of lines of code, resulting in tens of thousands of complete call chain results. Such a massive amount of data cannot provide effective guidance for testing, and testing may even be impossible based on it. Therefore, it is necessary to refine the call chain data. By analyzing the existing call chain data of the target application, certain patterns can be discovered. Based on these patterns, the amount of data in the target call chain can be significantly reduced.

[0058] In the specific implementation, at least one class name can be determined based on the functions included in the target call chain. Each function in the target call chain includes its class name in its function name. Then, the functions in the target call chain are aggregated according to at least one class name to obtain at least one aggregated class. Finally, test guidance data is determined based on this aggregated at least one class. The target call chain is a call path consisting of many function calls, and many of these functions have similar names. For example, `CustomerToolBartListController p_addItem` and `CustomerToolBartListController p_deleteItem` have the same prefix, indicating that both functions belong to the `CustomerToolBartListController` class. Therefore, the class names included in these functions are the same. Aggregating according to the class names determined from the functions in the target call chain significantly reduces the amount of data compared to the original target call chain, resulting in call paths between multiple classes, thus yielding test guidance data. It should be noted that since modified functions will ultimately be used as test guidance data, modified functions are not included in the aggregation process, allowing them to be displayed.

[0059] For example, please refer to Table 1 for the target call chain, which is the function called corresponding to a modified function (the changing function) (two target call chains):

[0060] Table 1 Target Call Chain

[0061]

[0062] It can be observed that the two call chains contained in the above target call chain both involve calls within a Controller. Each Controller is a class, therefore the target call chain can be aggregated according to Controller. That is, CustomerToolBartListController-a or CustomerToolBartListController-b both belong to the CustomerToolBartListController class, and thus can all be represented as CustomerToolBartListController. Experimental verification shows that the functions included in the aggregated call chain data are reduced by 56 times, and the impact testing can be fully completed.

[0063] Specifically, determining test guidance data based on at least one aggregated class can be achieved by first acquiring at least one screenshot of the user interface generated by the target program during runtime. Each screenshot indicates the functionality corresponding to a class in the target program. Correspondingly, the user interface screenshots are obtained from the above... Figure 1b Implemented in the User / Automation 101b module, this involves using hook functions to capture the call message before the target program actually calls the function, thus gaining control. The hook function then takes a screenshot of the user interface corresponding to the called function and reports it to the server for processing by the server's appropriate module. For example, each screenshot represents a Controller image. Then, based on the class name corresponding to at least one aggregated class, the user interface screenshot corresponding to that class is determined from the at least one screenshot. Here, the target call chain is aggregated by class name to obtain at least one aggregated class. Since each reported screenshot has a unique class name, the user interface screenshot corresponding to the aggregated target call chain can be matched based on the class name. Next, the call paths between the at least one aggregated class are determined based on the call paths between the functions included in the target call chain. The call paths between the at least one aggregated class, the corresponding user interface screenshots, and the modified function are used as test guidance data. The target call chain mainly includes function calls within a certain class, resulting in relatively long call paths. Although the length of the call path changes after aggregation, the call relationships between the corresponding classes and the call relationships between the classes to which the functions in the target call chain belong remain unchanged. For example, the target call chain has function a → function b1 → function b2 → function b3 → function c3, where the changed function is function c3. Functions b1, b2, and b3 are functions within class b. Therefore, by aggregating according to class name b, we can obtain the aggregated call path: function a → function b → function c3. This is a call path between multiple classes and can be used as part of the test guidance data. In addition, screenshots of the user interface and changed functions can also be used as test guidance data.

[0064] In one embodiment, after aggregating the target call chain, the call relationships between multiple classes are obtained. Developers can also manually annotate the class names to guide testing. Table 2 below shows examples of annotations for each class.

[0065] Table 2 Examples of Development Notes

[0066] CloudPrintGuidViewController Print application guide page ConversationLBSViewController Location selection interface ConversationMemberController Group member list ConvMemberSearchController Group member list search ChatManagerController Management - Chat Management Interface

[0067] It can be observed that different class names correspond to different functional descriptions. The screenshots of the navigation interfaces mentioned above can be understood as screenshots of the user interface corresponding to the functional switching between each different class. The corresponding manual descriptions can be understood as displaying the aggregated classes to the terminal device, but the class descriptions are to be supplemented.

[0068] As one possible implementation, the server can also send the aforementioned test guidance data to the terminal device, enabling the terminal device to display the test guidance data in its user interface, thus facilitating testers in developing supplementary test cases for the target program. See details below. Figure 3 This is a schematic diagram showing the aforementioned test guidance data displayed on the terminal device. It includes the changed function (the modified function), the affected function (the call path after aggregating the target call chain), and screenshots of the user interface. The screenshots of the user interface correspond to the affected functions. Figure 3 Screenshot (a) of the user interface corresponds to the class `WorkLogDetailViewController`, while screenshot (b) corresponds to `WorkLogViewControllerinitWithLogEntities`. If a modified function corresponds to multiple different target call chain data, or multiple modified functions each correspond to multiple target call chain data, this will be displayed on the terminal device. By intuitively displaying the aggregated call chain data, automatic annotation of the call chain is achieved, reducing the cost of manual annotation and improving testing efficiency. Based on this test guidance data, testers can design supplementary test cases. Using these supplementary test cases to test the target program allows for a preliminary evaluation of the functionality implemented by the modified code.

[0069] In summary, the embodiments of the present invention have at least the following advantages:

[0070] By utilizing server-related functional modules to process the acquired call chain data and submission information of the target program, the functions corresponding to the modified code in the target program, i.e., the modified functions, are obtained. Based on the modified functions, the target call chain is matched from multiple call chains, and the functions included therein are aggregated according to certain rules, such as class names. This simplifies the target call chain, greatly reduces the complexity of analyzing the target call chain, and improves the reliability of the call chain for guiding testing. In addition, the test guidance data includes screenshots of the user interface corresponding to the aggregated target call chain, the call paths between aggregated classes, and the modified functions, which are visualized on the terminal device. This enables automatic system annotation (i.e., directly indicating the function of the class through the user interface screenshot), saving development annotation time, speeding up the testing process, and supplementing test scenarios through this test guidance data, reducing the probability of missed tests.

[0071] Please see Figure 4 , Figure 4 The embodiments of the present invention are based on Figure 1b The diagram shows another data processing method provided by the data processing system. This method can be executed by the aforementioned terminal device 101, and the data processing method may include at least the following steps S401-S403:

[0072] S401, Obtain submission information for the target program, the submission information including the source code of the target program.

[0073] In one possible embodiment, the target program can correspond to a target application, which can be an application running on systems such as iOS, Android, Windows, and Linux. The target program enables the implementation of the target application's functions. When it's necessary to improve or add functionality to the target application, or to fix unknown defects, these objectives can be achieved by adjusting or modifying the target application's source code. Specifically, the modified source code can be compiled by a suitable compiler on a terminal device (such as a desktop computer), such as Code::Blocks or Xcode, to obtain compilation results. This provides data for developers to reference, determining the correctness and reliability of code adjustments. Here, the modified source code is considered the target program. After each modification, a commit command must be executed to obtain commit information, i.e., the target program's source code. The modified source code, through the commit command, triggers the compiler to compile the target program. In this source code, the changed code generally refers to the code in the sub-functions that implement a specific function.

[0074] S402, the target program is compiled according to the submitted information to obtain the call chain data of the target program. The call chain data includes at least one call chain, and each call chain is used to indicate the call path between functions in the target program during the compilation process.

[0075] In one possible embodiment, the compilation of the target program can be initiated based on its source code. During the compilation process, a compiler plugin is used to obtain the corresponding syntactic representation structure of the target program, and a syntax tree matcher is used to analyze and process the syntactic representation structure to obtain the call chain data of the target program. Specifically, after the compiler detects the commit command input by the developer, it automatically starts the compiler to compile the target program. Furthermore, a compiler plugin, such as the Clang plugin, is used to compile the submitted source code of the target program. The lightweight compiler Clang can handle C, C++, Objective-C, and Objective-C++ languages. This compiler, as the compilation front-end of the target application running in iOS, provides a series of tools to analyze the source code. Users can also build their own tools based on Clang to process the target program. That is, the aforementioned Clang plugin performs lexical analysis and syntax analysis on the target program, generating an Abstract Syntax Tree (AST), which is a tree-like representation of the syntactic structure of the source code, where each node represents a structure in the source code. The ASTMatcher tool provided by Clang is then used to analyze the AST of the syntactic representation structure to obtain the call chain data of the target program. In the example operation, Clang plugins written by developers can be included as part of the compilation process and loaded at runtime. Using ASTMatcher to write Clang plugins can significantly reduce code redundancy and improve efficiency, thereby accurately and efficiently matching the desired nodes and obtaining complete call chain data for the target program. This call chain data consists of multiple call chains, each revealing the call relationships between functions in the target program at runtime and indicating the function call path. For specific examples of call chains, please refer to [link to example]. Figure 2 The corresponding S201 will not be explained further here.

[0076] As an example, see Figure 5 This is the syntax tree result extracted from the process of Objective-C (OC) calling C++ (i.e., C++). We can see that class implementations define `ObjCImplemetation`, method definitions define `OjbcMethodDecl`, and C++ calls have `CXXMemberCallExpr`. Therefore, searching the AST can retrieve call chain data. Thus, by implementing a Clang plugin and including it during compilation, the plugin will match and obtain the call chain results. Specifically, the call chain data is obtained by executing a matching expression; the matching expression differs for different call types. For example, the corresponding... Figure 5 When calling C++ from Objective-C, the corresponding matching expressions are:

[0077]

[0078] Each function in this matching expression (such as `hasAncestor`) is a Matcher. There are three types of Matchers: Node Matchers, which match all nodes of a specific type (e.g., `objcMethodDeclr` matches Objective-C method declaration nodes); Traversal Matchers, which limit the search scope of the matching expression starting from the currently matched node (e.g., `hasAncestor` indicates that the next match should be performed on the ancestor nodes of the current node); and Narrowing Matchers, which narrow the matching scope (e.g., `hasname` limits the name of the match, thus being a Narrowing Matcher). Furthermore, `bind` can only be called on Node Matchers. For example, calling `bind` on `objcMethodDeclr` in the matching expression binds the corresponding node to the string. For instance, `cxxMemberCallExper().bind("classCaller")` binds `cxxMemberCallExper` to the string "classCaller".

[0079] There are certain strategies for creating matching expressions, which can be found in [reference needed]. Figure 6 The process mainly consists of four steps. Step 60: Determine the outermost class of the node to be matched, which is the function call. For example, to match method call relationships, the outermost class must be determined, which is the outermost layer of the matching expression, objCMethodDecl. Step 61: Select a suitable matcher from the AST Matcher Reference. After obtaining the function call, select the matcher related to the calling function based on the call relationship. Based on the above principles, the matching expression is created. Step 62: Verify the matching effect and determine whether it needs to be refined to narrow down the matching node set. The Clang-query tool provided by Clang can be used to verify the matching effect. If it does not meet expectations, further adjustments are made to the matching expression. Step 63: Repeat steps 60-62 until the matcher is complete. This can be understood as the final verification result meeting expectations, allowing the matching expression to obtain the complete call chain corresponding to different types.

[0080] S403, the submission information and the call chain data are sent to the server, so that the server determines the target call chain associated with the changed function in the source code based on the call chain data and the submission information, and performs aggregation processing on the functions included in the target call chain to obtain test guidance data.

[0081] In one possible embodiment, the terminal device sends the submission information and call chain data to the server in a manner that can be found in [reference needed]. Figure 1b The corresponding process involves writing call chain data to the call chain log of the local terminal device and synchronizing the call chain log to the server's logical layer 100a. For submissions that include the source code of the target program, the log is also synchronized to the server's storage layer 100b. This is primarily to identify the modified functions in the source code. Then, the target call chain is determined using the modified functions and the call chain data. The correlation between the target function and the modified function is reflected in the fact that the modified function exists as a called function in the call chain. Of course, the server further analyzes and aggregates the target call function to obtain test guidance data. The terminal device receives the test guidance data sent by the server and displays it to better guide the testing.

[0082] In summary, the embodiments of the present invention have at least the following advantages:

[0083] The terminal device obtains the call chain by compiling the target program. Specifically, it uses Clang tools to process the target program, which can quickly and accurately obtain call chain data. By writing the call chain data into the call chain log and synchronizing it to the server, and storing the commit information on the server, the server can parse the relevant data sent by the terminal device to obtain test guidance data. This allows for the recording and reporting of each development change, improving the server's efficiency in analyzing the affected call chain based on each development change. The intuitive display of the test guidance data on the terminal device also makes the testing more targeted and avoids missed tests.

[0084] Please see Figure 7 , Figure 7 This is a schematic diagram of a data processing device provided in an embodiment of the present invention. The data processing device can be a computer program (including program code) running on a server, for example, an application software. The device can be used to execute corresponding steps in the method provided in the embodiment of the present invention. The device 70 may include: an acquisition module 701, a determination module 702, and an aggregation module 703, wherein:

[0085] The acquisition module 701 is used to acquire the call chain data and submission information of the target program. The submission information includes the source code of the target program. The call chain data is obtained by compiling the target program according to the submission information. The call chain data includes at least one call chain, and each call chain is used to indicate the call path between functions in the target program during the compilation process.

[0086] The determination module 702 is used to determine the target call chain associated with the modified function in the source code based on the call chain data and the submission information. The target call chain includes the call chains of each function that calls the modified function.

[0087] The aggregation module 703 is used to aggregate the functions included in the target call chain to obtain test guidance data. The test guidance data includes one or more of the following: the call paths between classes obtained by aggregation according to class name, the modified functions, class name annotation information, and screenshots of the user interface corresponding to the aggregated classes.

[0088] In one embodiment, the aggregation module 703 is further configured to: determine at least one class name based on the functions included in the target call chain, wherein the function name of each function included in the target call chain includes a class name; aggregate the functions included in the target call chain according to the at least one class name to obtain at least one aggregated class; and determine test guidance data based on the at least one aggregated class.

[0089] In one embodiment, the aggregation module 703 is further configured to: acquire at least one screenshot of the user interface generated by the target program during runtime, each screenshot indicating a function corresponding to a class of the target program; determine a screenshot of the user interface corresponding to the at least one class after aggregation from the at least one screenshot based on the class name corresponding to the at least one class after aggregation; determine the call path between the at least one class after aggregation based on the call path between functions included in the target call chain; and use the call path between the at least one class after aggregation, the corresponding screenshot of the user interface, and the changed function as test guidance data.

[0090] In one embodiment, the device 70 further includes a sending module 704 for sending the test guidance data to a terminal device, so that the terminal device displays the test guidance data in a user interface, the test guidance data being used to formulate supplementary test cases for the target program.

[0091] The apparatus 70 provided in this embodiment of the invention acquires submission information and the call chain data of the target program through the acquisition module 701, determines the target call chain associated with the modified function using the determination module 702, and then aggregates the target call chain using the aggregation module 703 to obtain test guidance data, which is then sent to the terminal device through the sending module 704. The data processing by the relevant modules of this apparatus not only reduces the complexity of the target call chain, but also, the test guidance data obtained after aggregation can better improve the test coverage of the target program and reduce the risk of missed tests.

[0092] Please see Figure 8 , Figure 8 This is a schematic diagram of another data processing device provided in an embodiment of the present invention. The data processing device can be a computer program (including program code) running on a terminal device, for example, an application software. The device can be used to execute corresponding steps in the method provided in the embodiments of the present invention. The device 80 may include: an acquisition module 801, a compilation module 802, and a sending module 803, wherein:

[0093] The acquisition module 801 is used to acquire submission information for the target program, the submission information including the source code of the target program.

[0094] The compilation module 802 is used to compile the target program according to the submission information to obtain the call chain data of the target program. The call chain data includes at least one call chain, and each call chain is used to indicate the call path between functions in the target program during the compilation process.

[0095] The sending module 803 is used to send the submission information and the call chain data to the server, so that the server can determine the target call chain associated with the changed function in the source code based on the call chain data and the submission information, and perform aggregation processing on the functions included in the target call chain to obtain test guidance data.

[0096] In one embodiment, the compilation module 802 is specifically used to: initiate the compilation of the target program based on the source code of the target program; during the compilation process, use a compilation plugin to obtain the syntax representation structure corresponding to the target program, and use a syntax tree matcher to analyze and process the syntax representation structure to obtain the call chain data of the target program.

[0097] The device 80 provided in this embodiment of the invention is used in a terminal device. It obtains the source code of the target program through the acquisition module 801, compiles it using the compilation module 802 to obtain call chain data, and sends the submission information and call chain data to the server using the sending module 803 to assist the server in analyzing and obtaining the target call chain, thereby improving the terminal device's testing capability for code that has been developed and modified.

[0098] Please see Figure 9 , Figure 9 This is a schematic diagram of a server structure provided in an embodiment of the present invention. The server 90 may include a processor 901, a memory 902, a network interface 903, and at least one communication bus 904. The processor 901 is used to schedule computer programs and may include a central processing unit, a controller, or a microprocessor; the memory 902 is used to store computer programs and may include high-speed random access memory, non-volatile memory, such as disk storage devices or flash memory devices; the network interface 903 provides data communication functions, and the communication bus 904 is responsible for connecting the various communication components.

[0099] The processor 901 can be used to call computer programs in memory to perform the following operations:

[0100] Obtain the call chain data and commit information of the target program. The commit information includes the source code of the target program. The call chain data is obtained by compiling the target program based on the commit information. The call chain data includes at least one call chain, and each call chain is used to indicate the call path between functions in the target program during the compilation process.

[0101] The target call chain associated with the modified function in the source code is determined based on the call chain data and the submission information. The target call chain includes the call chains of each function that calls the modified function.

[0102] The functions included in the target call chain are aggregated to obtain test guidance data. The test guidance data includes one or more of the following: the call paths between classes aggregated by class name, the modified functions, class name annotation information, and screenshots of the user interface corresponding to the aggregated classes.

[0103] In one embodiment, the processor 901 is specifically configured to: determine at least one class name based on the functions included in the target call chain, wherein the function name of each function included in the target call chain includes a class name; aggregate the functions included in the target call chain according to the at least one class name to obtain at least one aggregated class; and determine test guidance data based on the at least one aggregated class.

[0104] In one embodiment, the processor 901 is specifically configured to: acquire at least one screenshot of the user interface generated by the target program during runtime, each screenshot indicating a function corresponding to a class of the target program; determine a screenshot of the user interface corresponding to the aggregated at least one class from the at least one screenshot based on the class name corresponding to the aggregated at least one class; determine the call path between the aggregated at least one class based on the call path between functions included in the target call chain; and use the call path between the aggregated at least one class, the corresponding screenshot of the user interface, and the modified function as test guidance data.

[0105] In one embodiment, the processor 901 is specifically configured to: send the test guidance data to a terminal device, so that the terminal device displays the test guidance data in a user interface, wherein the test guidance data is used to formulate supplementary test cases for the target program.

[0106] It should be understood that the server described in the embodiments of the present invention can implement the data processing method described in the embodiments, or it can execute the data processing device described in the corresponding embodiments, which will not be repeated here. In addition, the beneficial effects of using the same method will also not be repeated here.

[0107] Please see Figure 10 , Figure 10 This is a schematic diagram of the structure of a terminal device according to an embodiment of the present invention. The terminal device 1000 can be as described above. Figure 1aThe terminal device 101 may include a processor 1001, at least one communication bus 1002, an input / output control device 1003, a network interface 1004, and a memory 1005. The processor 1001 is used to schedule computer programs and can be a central processing unit (CPU), controller, microprocessor, microcontroller, or other electronic components to interpret computer instructions and process data. The communication bus 1002 is responsible for connecting various communication components. The input / output control device 1003 includes, but is not limited to, a display screen and a keyboard. The display screen can be an LCD screen or an e-ink screen, and the input device can be a physical keyboard, touch keyboard, touchpad, mouse, etc. The network interface 1004 can be a wired or wireless network interface for providing data communication functions. The memory 1005 includes application management, a user interface module, a network communication module, and an operating system, and can be non-volatile memory or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), RAMbus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and RAMbus dynamic RAM (RDRAM), etc.

[0108] The processor 1001 performs the following operations by calling the computer program stored in the memory 1005:

[0109] Obtain the submission information for the target program, the submission information including the source code of the target program;

[0110] The target program is compiled according to the submitted information to obtain the call chain data of the target program. The call chain data includes at least one call chain, and each call chain is used to indicate the call path between functions in the target program during the compilation process.

[0111] The submission information and the call chain data are sent to the server so that the server can determine the target call chain associated with the changed functions in the source code based on the call chain data and the submission information, and perform aggregation processing on the functions included in the target call chain to obtain test guidance data.

[0112] In one embodiment, the processor 1001 is further configured to: initiate the compilation of the target program based on the source code of the target program; during the compilation process, use a compilation plugin to obtain the syntax representation structure corresponding to the target program, and use a syntax tree matcher to analyze and process the syntax representation structure to obtain the call chain data of the target program.

[0113] It should be understood that the terminal device described in the embodiments of the present invention can implement the data processing method described in the embodiments, or it can execute the data processing device described in the corresponding embodiments, which will not be repeated here. In addition, the beneficial effects of using the same method will also not be repeated here.

[0114] It should be noted that the servers or terminal devices mentioned above are all types of computer devices. If computer devices are mentioned in the text, they can refer to either servers or terminal devices.

[0115] Furthermore, it should be noted that embodiments of the present invention also provide a storage medium storing a computer program for the aforementioned data processing method. This computer program includes program instructions. When one or more processors load and execute these program instructions, the data processing method described in the embodiments can be implemented, as will not be repeated here. The beneficial effects of using the same method will also not be repeated here. It is understood that the program instructions can be deployed on one or more computer devices capable of communicating with each other for execution.

[0116] This invention also provides a computer program product or computer program that includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the steps described in the embodiments of the methods above.

[0117] Those skilled in the art will further recognize that the modules and algorithm steps of the various examples described in conjunction with the embodiments disclosed in this specification can be implemented in 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 in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementations should not be considered beyond the scope of this invention.

[0118] Finally, it should be noted that the terminology in the specification, claims, and accompanying drawings of this invention, such as relational terms like "first" and "second," is used merely to distinguish one entity or operation from another, and does not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or terminal device that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or terminal device. Without further limitation, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or terminal device that includes said element.

[0119] The above description is merely a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any person skilled in the art can easily conceive of various equivalent modifications or substitutions within the technical scope disclosed in the present invention, and these modifications or substitutions should all be covered within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of the claims.

Claims

1. A data processing method, characterized by, Applied to a server, the method includes: The method involves obtaining call chain data and commit information of the target program. The commit information includes the source code of the target program and is obtained by executing a commit command for the target program after each development modification. The commit command is also used to trigger the compilation of the target program. The call chain data is obtained by compiling the target program based on the commit information. The call chain data includes at least one call chain, and each call chain indicates the call path between functions in the target program during the compilation process. The method also involves obtaining modified functions from the source code of the target program included in the commit information. The modified functions are the functions corresponding to the modified code in the source code of the target program. Based on the call path between functions indicated by each call chain, a target call chain for calling the modified function is determined from the at least one call chain, the target call chain including the call chains of each function that calls the modified function; The functions included in the target call chain are aggregated to obtain test guidance data. The test guidance data includes one or more of the following: the call paths between classes aggregated by class name, the modified functions, class name comments, and screenshots of the user interface corresponding to the aggregated classes; wherein, the modified functions are not included in the scope of the aggregation process.

2. The method as described in claim 1, characterized in that, The aggregation of functions included in the target call chain to obtain test guidance data includes: At least one class name is determined based on the functions included in the target call chain, wherein the function name of each function included in the target call chain includes the class name; The functions included in the target call chain are aggregated according to the at least one class name to obtain at least one aggregated class; Test guidance data is determined based on at least one class after aggregation.

3. The method as described in claim 2, characterized in that, The step of determining test guidance data based on at least one class after aggregation includes: Obtain at least one screenshot of the user interface generated by the target program during runtime, each screenshot indicating the function corresponding to a class of the target program; Based on the class name corresponding to the at least one class after aggregation, determine the screenshot of the user interface corresponding to the at least one class after aggregation from the at least one screenshot; The call paths between at least one class after aggregation are determined based on the call paths between functions included in the target call chain; The call paths between at least one class after aggregation, the corresponding screenshots of the user interface, and the modified functions are used as test guidance data.

4. The method according to any one of claims 1 to 3, characterized in that, After aggregating the functions included in the target call chain to obtain test guidance data, the process further includes: The test guidance data is sent to the terminal device so that the terminal device displays the test guidance data in the user interface. The test guidance data is used to formulate supplementary test cases for the target program.

5. A data processing method, characterized in that, Applied to a terminal device, the method includes: Obtain commit information for the target program, the commit information including the source code of the target program; the commit information is obtained by executing a commit command for the target program after each development change, the commit command is also used to trigger the compilation of the target program; The target program is compiled according to the submitted information to obtain the call chain data of the target program. The call chain data includes at least one call chain, and each call chain is used to indicate the call path between functions in the target program during the compilation process. The submission information and the call chain data are sent to the server, enabling the server to obtain the modified function from the source code of the target program included in the submission information; the modified function is the function corresponding to the modified code in the source code of the target program; based on the call path between functions indicated by each call chain, the target call chain that calls the modified function is determined from the at least one call chain, and the functions included in the target call chain are aggregated to obtain test guidance data; the test guidance data includes one or more of the following: the call path between classes obtained by aggregating by class name, the modified function, class name annotation information, and screenshots of the user interface corresponding to the aggregated class; the modified function is not included in the scope of the aggregation process.

6. The method as described in claim 5, characterized in that, The step of compiling the target program based on the submitted information to obtain the call chain data of the target program includes: The compilation of the target program is initiated based on the source code of the target program; During the compilation process, a compiler plugin is used to obtain the syntax representation structure corresponding to the target program, and a syntax tree matcher is used to analyze and process the syntax representation structure to obtain the call chain data of the target program.

7. A server, characterized in that, include: Memory, used to store computer programs; The processor invokes the computer program in the memory to execute the data processing method as described in any one of claims 1 to 4.

8. A terminal device, characterized in that, include: The system includes a network interface, a processor, and a memory, wherein the network interface, the processor, and the memory are connected, the network interface is used to provide data communication functions, the memory is used to store computer programs, and the processor is used to invoke the computer programs to execute the data processing method as described in claim 5 or 6.

9. A storage medium, characterized in that, The storage medium stores a computer program, the computer program including program instructions, which are loaded and executed by one or more processors to perform the data processing method as described in any one of claims 1 to 6.

10. A computer program product, characterized in that, The computer program product includes computer instructions stored in a computer-readable storage medium; the processor of the computer device reads the computer instructions from the computer-readable storage medium and executes them to perform the data processing method as described in any one of claims 1 to 6.

Citation Information

Patent Citations

  • Test point acquisition method and device in program test, storage medium and equipment

    CN111290950A