[go: up one dir, main page]

CN116521510A - Test method, test device, test equipment, test storage medium and test product - Google Patents

Test method, test device, test equipment, test storage medium and test product Download PDF

Info

Publication number
CN116521510A
CN116521510A CN202210078880.9A CN202210078880A CN116521510A CN 116521510 A CN116521510 A CN 116521510A CN 202210078880 A CN202210078880 A CN 202210078880A CN 116521510 A CN116521510 A CN 116521510A
Authority
CN
China
Prior art keywords
target
information
thread
statement
operation method
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202210078880.9A
Other languages
Chinese (zh)
Inventor
ι™ˆδΌŸζ–Œ
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Tencent Technology Shenzhen Co Ltd
Original Assignee
Tencent Technology Shenzhen Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to CN202210078880.9A priority Critical patent/CN116521510A/en
Publication of CN116521510A publication Critical patent/CN116521510A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Prevention of errors by analysis, debugging or testing of software
    • G06F11/3604Analysis of software for verifying properties of programs
    • G06F11/3608Analysis of software for verifying properties of programs using formal methods, e.g. model checking, abstract interpretation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Prevention of errors by analysis, debugging or testing of software
    • G06F11/3604Analysis of software for verifying properties of programs
    • G06F11/3616Analysis of software for verifying properties of programs using software metrics
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The application discloses a testing method, a testing device, testing equipment, a storage medium and a testing product, and belongs to the technical field of computers. The method comprises the following steps: acquiring first information; acquiring at least one text file corresponding to a target application; determining an operation method and first thread information corresponding to at least one instruction statement; determining second thread information corresponding to the operation method according to the first information; and comparing the first thread information with the second thread information to obtain a thread test result corresponding to the target application. According to the technical scheme provided by the embodiment of the application, the comprehensive thread test result can be automatically determined only by carrying out static analysis on the instruction statement of the target application, so that the diversified use scene is covered, the complexity of abnormal access test of the thread is reduced, the comprehensiveness and accuracy of the test are improved, and the test efficiency is integrally improved.

Description

Test method, test device, test equipment, test storage medium and test product
Technical Field
The present disclosure relates to the field of computer technologies, and in particular, to a testing method, apparatus, device, storage medium, and product.
Background
At present, more or less multithreaded access problems are encountered in the development process of the application program, and if related problems are encountered, the application program is easy to be blocked and paralyzed, so that the user experience is very affected.
In the related art, an application program to be tested is operated, so that the condition of an interactive operation instruction access thread received by a user interface is detected in the operation process of the application program to be tested, and a warning prompt is made when the condition of an abnormal access thread is detected.
However, in the related art, the thread access test can only be performed in the running process of the program, and the diversified use scenes are difficult to reproduce, the test complexity is high, the problem of missing test is easy to occur, and the comprehensiveness and the accuracy of the test are low.
Disclosure of Invention
The embodiment of the application provides a testing method, device, equipment, storage medium and product, which can statically analyze the abnormal access problem of threads, reduce the complexity of abnormal access testing of threads, improve the comprehensiveness and accuracy of testing and integrally improve the testing efficiency.
According to one aspect of embodiments of the present application, there is provided a test method, the method comprising:
acquiring first information, wherein the first information is used for representing the corresponding relation between at least one operation method associated with a target test scene and at least two threads, and the at least two threads are threads corresponding to a target application;
Acquiring at least one text file corresponding to the target application, wherein the at least one text file comprises at least one instruction statement;
determining an operation method and first thread information corresponding to the at least one instruction statement, wherein the first thread information is used for representing an actual execution thread corresponding to the operation method;
determining second thread information corresponding to the operation method according to the first information, wherein the second thread information is used for representing a target execution thread corresponding to the operation method in the target test scene;
and comparing the first thread information with the second thread information to obtain a thread test result corresponding to the target application.
According to an aspect of embodiments of the present application, there is provided a test apparatus, the apparatus comprising:
the first information acquisition module is used for acquiring first information, wherein the first information is used for representing the corresponding relation between at least one operation method associated with a target test scene and at least two threads, and the at least two threads are threads corresponding to a target application;
the text file acquisition module is used for acquiring at least one text file corresponding to the target application, wherein the at least one text file comprises at least one instruction statement;
The execution thread determining module is used for determining an operation method corresponding to the at least one instruction statement and first thread information, wherein the first thread information is used for representing an actual execution thread corresponding to the operation method;
the target thread determining module is used for determining second thread information corresponding to the operation method according to the first information, wherein the second thread information is used for representing a target execution thread corresponding to the operation method in the target test scene;
and the test result generation module is used for comparing the first thread information with the second thread information to obtain a thread test result corresponding to the target application.
According to an aspect of the embodiments of the present application, there is provided a computer apparatus including a processor and a memory, where at least one instruction, at least one program, a code set, or an instruction set is stored, and the at least one instruction, the at least one program, the code set, or the instruction set is loaded and executed by the processor to implement the above-mentioned test method.
According to one aspect of embodiments of the present application, there is provided a computer-readable storage medium having stored therein at least one instruction, at least one program, a set of codes, or a set of instructions, the at least one instruction, the at least one program, the set of codes, or the set of instructions being loaded and executed by a processor to implement the above-described test method.
According to one aspect of embodiments of the present application, there is provided a computer program product comprising computer instructions stored in a computer readable storage medium. A processor of a computer device reads the computer instructions from a computer-readable storage medium, the processor executing the computer instructions, causing the computer device to execute to implement the test method described above.
The technical scheme provided by the embodiment of the application can bring the following beneficial effects:
the method comprises the steps of obtaining corresponding information between each operation method and each thread in a target test scene, determining the operation method corresponding to the instruction statement in the text file corresponding to the target application, determining the target execution thread corresponding to the instruction statement according to the corresponding information, comparing the target execution thread with the actual execution thread corresponding to the determined instruction statement, and obtaining a thread test result corresponding to the whole target application.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings that are needed in the description of the embodiments will be briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and that other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a schematic diagram of an application execution environment provided by one embodiment of the present application;
FIG. 2 is a flow chart diagram of a test method provided in one embodiment of the present application;
FIG. 3 is a second flowchart of a test method provided in one embodiment of the present application;
FIG. 4 is a flow chart III of a test method provided by one embodiment of the present application;
FIG. 5 illustrates a schematic diagram of a method call chain information acquisition flow;
FIG. 6 illustrates a flow diagram for thread exception access testing based on a method call chain acquisition plug-in;
FIG. 7 illustrates a schematic diagram of a multi-threaded exception access detection flow;
FIG. 8 illustrates a schematic diagram of a test results page;
FIG. 9 is a flow chart four of a test method provided in one embodiment of the present application;
FIG. 10 is a flow chart five of a test method provided by one embodiment of the present application;
FIG. 11 is a flow chart six of a test method provided in one embodiment of the present application;
FIG. 12 illustrates a schematic diagram of a detection flow of abnormal thread access;
FIG. 13 is a block diagram of a test apparatus provided in one embodiment of the present application;
fig. 14 is a block diagram of a computer device according to an embodiment of the present application.
Detailed Description
The test method provided in the embodiment of the present application relates to computer technology, and application scenarios, related terms or nouns possibly related to the embodiment of the method of the present application are briefly described below, so as to facilitate understanding by those skilled in the art of the present application.
The C language is a general program design language facing to the process and abstract, and is widely applied to the bottom development. C++ is inheritance of C language, and can be used for carrying out procedural programming of C language, carrying out object-based programming with abstract data types as characteristics, and carrying out object-oriented programming with inheritance and polymorphism as characteristics.
Objective-C is a generic, high-level, object-oriented programming language.
Clang: a C, C ++, objective-C and Objective-C++ programming language.
GCD (Grand Central Dispatch, multithreaded optimization) is a multi-core programming method.
A User Interface (UI) is a medium for interaction and exchange of information between a system and a User, which enables conversion between an internal form of information and a human-acceptable form.
The hypertext transfer protocol (Hyper Text Transfer Protocol, HTTP) is a simple request-response protocol.
The API (Application Programming Interface, application program interface) is a predefined interface (e.g. function, HTTP interface) or a convention that refers to the engagement of different components of a software system.
JSON (JavaScript Object Notation, JS object profile) is a lightweight data exchange format. The compact and clear hierarchical structure makes JSON an ideal data exchange language. Is easy to read and write by people, is easy to analyze and generate by machines, and effectively improves the network transmission efficiency.
For the purpose of making the objects, technical solutions and advantages of the present application more apparent, the embodiments of the present application will be described in further detail below with reference to the accompanying drawings.
Referring to fig. 1, a schematic diagram of an application running environment provided in one embodiment of the present application is shown. The application execution environment may include: a terminal 10 and a server 20.
The terminal 10 includes, but is not limited to, a cell phone, a computer, an intelligent voice interaction device, an intelligent home appliance, a vehicle-mounted terminal, an aircraft, a game console, an electronic book reader, a multimedia playing device, a wearable device, and the like. A client in which an application program can be installed in the terminal 10.
In the embodiment of the present application, the application may be any type of application, including, but not limited to, a communication application, a system management application, a news application, a social application, an interactive entertainment application, a browser application, a shopping application, a content sharing application, a finance application, a game application, an education application, a life service application, a map application, a reading application, a Virtual Reality (VR) application, an augmented Reality (Augmented Reality, AR) application, and the like, which is not limited in this embodiment of the present application. The application program may be developed by an application development program, and a client of the application development program may be installed in the terminal 10. In an exemplary embodiment, the application development program is an integrated development environment (IDE, integrated Development Environment), which is an application program for providing a program development environment, generally including tools such as a code editor, a compiler, a debugger, and a graphical user interface, and integrated with development software services such as a code writing function, an analysis function, a compiling function, and a debugging function. Alternatively, the application development program is an integrated development environment Xcode running on the target operating system.
The server 20 is used to provide background services for the application programs or clients of the application development programs in the terminal 10. For example, the server 20 may be a background server of the application program or application development program described above. The server 20 may be an independent physical server, a server cluster or a distributed system formed by a plurality of physical servers, or may be a cloud server providing cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDNs (Content Delivery Network, content delivery networks), basic cloud computing services such as big data and artificial intelligence platforms, and the like. Alternatively, the server 20 provides background services for applications in a plurality of terminals 10 at the same time.
Alternatively, the terminal 10 and the server 20 may communicate with each other via the network 30. The terminal 10 and the server 20 may be directly or indirectly connected through wired or wireless communication, and the present application is not limited thereto.
Referring to fig. 2, a flowchart of a testing method according to an embodiment of the present application is shown. The method can be applied to a computer device, wherein the computer device is an electronic device with data computing and processing capabilities, and the execution subject of each step can be the terminal 10 in the application running environment shown in fig. 1. The method may include the following steps (210-250).
Step 210, obtain first information.
The first information is used for representing the corresponding relation between at least one operation method associated with the target test scene and at least two threads, wherein the at least two threads are threads corresponding to the target application. The target test scene includes at least one scene to be tested, such as a scene related to UI operations, a time-consuming operation scene, and some other special scenes.
Optionally, each target application corresponds to a process. Each process may contain multiple threads that may run simultaneously and each process some tasks.
In an exemplary embodiment, the at least two threads include, but are not limited to, a main thread and a worker thread. The worker thread is a child thread. After the target application is running, a main thread (MainThread) is generated by default. Optionally, the main thread is dedicated to handling UI-related operations, such as display and updating of interfaces, handling user interaction events, etc. For one application, the introduction of multiple threads is largely due to the fact that there are some operations that are very time consuming, such as: this time consuming operation is not able to operate in the main thread by sending a network request and waiting for a response from the server, because the main thread is used during the waiting time, and the user is not able to do any interaction, thus greatly affecting the user experience. For time-consuming operation, a thread, such as a working thread, needs to be additionally created, the thread is put into a background process, and after the process is completed to obtain a result, the thread returns to the main thread to set the UI interface.
The above operation method has a corresponding class (also referred to as an object class in the embodiment of the present application). A class refers to a prototype of an object of a type that declares the Property that each object has, and also defines a series of methods (methods) that all objects of the same class use, the methods described above.
In an exemplary embodiment, a method of an object (referred to as a recipient of a message) may be invoked by sending the message to the object, i.e., the method of operation described above. The name of the called operation method and the corresponding parameters, such as the information of the sent message content, are written in the instruction statement.
By acquiring the first information, the corresponding relation between at least one operation method and at least two threads associated with the target test scene can be determined, and the target execution thread corresponding to each operation method in the target test scene can be determined through the corresponding relation.
In an exemplary embodiment, the above-described test method is applied to a target application development program. Accordingly, as shown in fig. 3, before the step 210, the testing method further includes the following step 290, and fig. 3 shows a second flowchart of the testing method provided in an embodiment of the present application.
Step 290, displaying the application development page corresponding to the target application development program.
Based on the application development page, compiling operation for the target application can be received; in response to the application development page receiving a compiling operation for the target application, execution begins at step 210 described above. Accordingly, as shown in fig. 3, the above step 210 may be alternatively implemented by the following step 210 a.
In step 210a, in response to the application development page receiving a compiling operation for the target application, first information is obtained.
The compiling operation includes a selecting operation for a compiling option in the application development page.
The target application development program can integrate the test script corresponding to the test method and related plug-ins, such as a method call chain acquisition plug-in, and the test method can be executed by running the test script and the method call chain acquisition plug-in.
Step 220, at least one text file corresponding to the target application is obtained.
The at least one text file includes at least one instruction statement. The at least one text file is at least one source code file corresponding to the target application.
In Objective-C, the definition of each class includes two parts: interfaces (interfaces) and implementations (actuations). The interface part is defined in the h file and contains declarations, attributes and methods of classes, the main purpose of which is to provide an access interface to the outside. The implementation part is defined in the m file and is mainly used for the functional implementation of the method. The at least one text includes at least one m-file corresponding to the target application. m is a file format, chinese name is executable source code file, and file extension is.m. H, the file is a header file, the header file is used as a carrier file containing functional functions and data interface declarations, and is mainly used for saving the declarations of the program, and the definition file is used for saving the implementation of the program.
In an exemplary embodiment, as shown in FIG. 3, after the step 220, the test method further includes the following steps (260-270).
Step 260, obtaining a target text segment in at least one text file.
The target text segment is used for representing implementation information of the target object category. Optionally, the target text segment is a code segment corresponding to an implementation part of the target object class. The Object-C code has declaration interface and implementation of materialization, and the embodiment of the application needs to acquire the implementation of the class in the analysis process to acquire all methods of the class, so as to analyze a method call chain.
In an exemplary embodiment, the above-described target object class may also be referred to as a class. The implementation part of the class starts with a class start identifier (such as @ materialization) and ends with a corresponding class end identifier (@ end). The target text segment can thus be determined by both of the above-mentioned identifications. In the implementation part of the class, i.e. the target text segment, code content is included that implements the method defined by the interface part.
Optionally, the target object class includes an object class provided by the target system, and also includes a custom object class, which is not limited in this embodiment of the present application.
In step 270, in the case that the target text segment includes a target text segment corresponding to the preset operation method, a target instruction sentence in the target text segment is determined.
The method comprises the steps that a preset operation method is an operation method corresponding to a target object type, a target text segment is used for representing implementation information of the preset operation method, a target instruction statement is an instruction statement representing method calling information corresponding to the preset operation method, and at least one instruction statement comprises a target instruction statement.
The target object class corresponds to at least one operation method, each operation method corresponds to a section of implementation code, and the section of code for implementing the operation method can be called a text section corresponding to the operation method, and represents implementation information of the operation method.
The instruction sentences in the text segment can call the operation methods or functions to transfer messages, and the target object category corresponding to the called operation methods or functions can be the same category or other categories.
In one possible implementation, the preset operation method includes a first operation method, where the first operation method is an operation method corresponding to the first programming language. Optionally, the first programming language is the Objective-C language. Accordingly, as shown in fig. 4, the implementation process of the above step 270 includes the following steps (271-272), and fig. 4 shows a flowchart three of the test method provided in one embodiment of the present application.
In step 271, in the case that the target text segment includes a first text segment corresponding to the first operation method, an instruction sentence associated with the first target information in the first text segment is determined.
The first text segment is used for representing implementation information of a first operation method, the first target information is used for representing a method call relation corresponding to the first operation method, and the first target information comprises at least one of object category inheritance information, first identification information and first parameter information corresponding to the first operation method. Optionally, the first operation method is an operation method implemented based on a function corresponding to the first programming language, and the first operation method may be determined by analyzing a function associated with the first programming language in the instruction statement.
The object class inheritance information is used for representing an object class corresponding to the first operation method and a parent object class corresponding to the object class, including but not limited to an object class alias and a parent object class alias. The object class inheritance information may be determined based on information of a message receiver in an instruction statement corresponding to the first operation method.
The first identification information is used for representing method identification information corresponding to the first operation method, and includes, but is not limited to, identification information such as a method name, a keyword and the like.
The first parameter information is parameter information associated with a first operation method and capable of changing a method call order, such as Selector (SEL) parameter information and statement block (block) parameter information, which change the method call order.
A Selector (SEL) is used to select one of the method execution in the list of methods responsible for the object in the message.
The statement blocks or instruction statement blocks described above are also referred to as code blocks. Block is the object that encapsulates a set of code instruction statements, which can be executed at any time. It is essentially a portable anonymous function that can be entered as a parameter of the method and function and can be returned from the method and function.
In step 272, the instruction statement associated with the object class inheritance information, the first identification information, and the first parameter information is determined as the target instruction statement.
And reserving the object class inheritance information, the first identification information and the instruction statement associated with the first parameter information, and determining a method calling relation corresponding to the first operation method by taking the object class inheritance information, the first identification information and the instruction statement as a target instruction statement.
In another possible implementation manner, the preset operation method includes a second operation method, and the second operation method is an operation method corresponding to the second programming language. Optionally, the second programming language is the C language. Accordingly, as shown in fig. 4, the implementation of the above step 270 further includes the following steps (273-274).
Step 273, in the case that the target text segment includes a second text segment corresponding to the second operation method, determining an instruction sentence associated with the second target information in the second text segment.
The second text segment is used for representing implementation information of a second operation method, the second target information is used for representing a method calling relation corresponding to the second operation method, and the second target information comprises second identification information and second parameter information corresponding to the second operation method. Optionally, the second operation method is an operation method implemented based on a function corresponding to the second programming language, and the second operation method may be determined by analyzing a function associated with the second programming language in the instruction statement.
The second identification information is used for representing method identification information corresponding to the second operation method, including but not limited to identification information such as a method name, a keyword, and the like.
The second parameter information is complete parameter information corresponding to the second operation method. Optionally, the function associated with the second programming language is a function related to GCD, and since the function related to GCD may change the currently accessed thread according to different parameters, parameter information associated with the second operation method needs to be completely saved as the second parameter information.
In step 274, the instruction statement in which the second identification information is associated with the second parameter information is determined as the target instruction statement.
And reserving the instruction statement associated with the second identification information and the second parameter information, and taking the instruction statement as a target instruction statement to determine a method calling relation corresponding to the second operation method.
In an exemplary embodiment, as shown in FIG. 4, after performing step 274 described above, the test method described above further includes step 280 described below.
Step 280, generating a target file corresponding to at least one text file based on the target instruction statement.
The target file is used for representing the method call chain information corresponding to at least one instruction statement.
In an exemplary embodiment, the target file is a JSON file. After the target instruction statement is determined from the text file, a JSON file can be generated based on the content of the target instruction statement, then method call information corresponding to each target instruction statement, such as an operation method corresponding to each instruction statement, parameter information, identification information, object class integration information and the like corresponding to the operation method, can be determined by analyzing the JSON file, and complete method call chain information in the target application can be determined by the method call information corresponding to each target instruction statement.
The embodiment of the application needs to analyze the multithreading abnormal access problem, and needs to know the whole process of the method call related to the target application to judge whether the call accords with the thread safety. Therefore, the grammar analysis can be carried out by Clang, and the method call chain information can be acquired.
In an exemplary embodiment, the first target information and the second target information are both analyzed by Clang, the result of Clang default analysis is that text files are used as units, and the obtained data is also a class structure of a single text file, and the analysis of thread safety problems based on a complete method call chain is not satisfied, so that improvement is required for the situation, and the purpose is to be able to access the complete method call chain of the whole engineering project, and the content of each text file can be saved in the form of JSON files. Alternatively, based on the content of the target instruction statement in each text file, a JSON file corresponding to each text file may be generated. The JSON file corresponding to the at least one text file can represent the complete method call chain information corresponding to the whole target.
In one example, as shown in FIG. 5, a schematic diagram of a method call chain information acquisition flow is illustratively shown. In an exemplary embodiment, a target compiler Clang and a method call chain acquisition plug-in are integrated in a target application development program, where the method call chain acquisition plug-in is based on a plug-in generated by the target compiler Clang, and by compiling a plurality of text files corresponding to a target application in the target application development program, instruction sentences in the plurality of text files can be parsed based on the target compiler and the method call chain acquisition plug-in, so as to acquire method call chain information corresponding to each text file. Alternatively, the above may be replaced by a Clang-type tool, such as an oclin (static code analysis tool), with the purpose of a method call chain for taking the entire item. The plurality of text files, that is, the declaration (interface) code of the class and the implementation (materialization) code of the class exist in the code text in the plurality of code files. In the embodiment of the present application, in the process of performing syntax analysis by using the target compiler and the method call chain acquisition plug-in, the target text segment to be acquired includes the implementation code of the class, and all the operation methods corresponding to the classes and the text segments corresponding to the operation methods can be acquired by acquiring the implementation code of the class.
In the case where the operation method corresponds to an OC (object-C) function (for example, in the case where the target operation method is the first operation method), object class inheritance information, first identification information, and first parameter information corresponding to the operation method are parsed from a text segment corresponding to the operation method. The object class inheritance information includes, but is not limited to, class names (object classes) corresponding to the operation methods and parent classes (parent object classes) thereof, wherein the class names and the parent classes thereof can be determined by message receivers corresponding to the operation methods; the first identification information comprises, but is not limited to, function names corresponding to the operation method; the first parameter information includes, but is not limited to, a parameter type. The parent class is stored to determine the inheritance relationship corresponding to the operation method, and the type of the class corresponding to the operation method can be determined based on the inheritance relationship, for example, the class corresponding to the operation method is judged to be a UI related class or other classes except the UI related class, and the type of the class is associated with the thread; the save function name is used to determine a thread switch or the like, and the first parameter information refers to parameter information associated with the operation method and capable of changing a method call order, such as Selector (SEL) parameter information and statement block (block) parameter information, which change the method call order. The method calling relation corresponding to the operation method can be determined by acquiring the object category inheritance information, the first identification information and the first parameter information, and the three kinds of information corresponding to the target operation method in the text file are summarized to reflect the method calling information corresponding to the text file.
In the case that the operation method corresponds to the C function (for example, in the case that the target operation method is the second operation method), the second identification information and the second parameter information corresponding to the operation method are parsed from the text segment corresponding to the operation method. The second identification information comprises the function name of the C function corresponding to the operation method. Optionally, the function C is a function related to GCD, and since the function related to GCD may change the thread currently accessed according to different parameters, parameter information related to the operation method needs to be completely saved as the second parameter information.
Optionally, the method call chain information can be obtained by outputting class names corresponding to the first operation method and parent classes, function names and selector parameter information or statement block parameter information thereof, and outputting function names corresponding to the second operation method and complete parameter information.
Step 230, determining an operation method and first thread information corresponding to at least one instruction statement.
The first thread information is used for representing an actual execution thread corresponding to the operation method. Alternatively, the actual execution thread may be determined based on the method call chain information. The actual execution thread corresponding to each instruction statement is associated with the last execution instruction statement corresponding to the instruction statement, and if the last execution instruction statement does not involve thread change operation, the actual execution thread of the instruction statement is the same as the execution thread of the last execution instruction statement; if the last execution instruction statement involves a thread change operation, the actual execution thread of the instruction statement is the target switch thread after the last execution instruction statement is executed. Thus, the first thread information may be determined by the method call chain information and the thread marking information. The thread marking information is used for representing the history execution thread corresponding to the history detection statement.
In an exemplary embodiment, as shown in FIG. 3, after performing step 270, step 230 may be alternatively performed by step 230a described below.
In step 230a, the operation method and the first thread information corresponding to the target instruction statement are determined.
In an exemplary embodiment, as shown in fig. 4, after the step 280 is performed, the implementation of the step 230a includes the following steps (230 a 1-230 a 2).
In step 230a1, the target file is analyzed to obtain an analysis result.
Analyzing the statement in the JSON file to obtain relevant information corresponding to the target instruction statement, wherein the relevant information comprises the first target information and the second target information.
Step 230a2, determining the operation method and the first thread information corresponding to the target instruction statement according to the analysis result.
And determining an operation method corresponding to the target instruction statement and method call information corresponding to the operation method according to the analysis result, and determining an actual execution thread corresponding to the target instruction statement according to the method call information, or determining the actual execution thread corresponding to the target instruction statement according to the method call information and the thread mark information.
In one example, as shown in FIG. 6, a flow diagram for thread exception access testing based on a method call chain acquisition plug-in is illustratively shown. In the flow shown in fig. 6, the target compiler Clang and the method call chain acquisition plug-in plug in are integrated into the application development program Xcode; the method comprises the steps of compiling a plurality of code files corresponding to a target application through an application development program, carrying out grammar analysis on instruction sentences in the code files based on the target compiler and a method call chain acquisition plug-in the compiling process, generating a target file, such as a JSON file, capable of representing method call chain information corresponding to each code file, further analyzing the target file, and then realizing thread abnormal access test to obtain a test result.
Step 240, determining second thread information corresponding to the operation method according to the first information.
The second thread information is used for representing a target execution thread corresponding to the operation method in the target test scene.
In the process of judging the target execution thread, it is necessary to know which operation methods need to be called in the main thread and which operation methods need to be called in the working thread, so that the corresponding relations between the methods and the threads can be sorted in advance, and after the operation methods corresponding to the instruction sentences are identified, the target execution thread corresponding to the operation methods can be determined according to the first information.
In one example, as shown in table 1 below, a portion of the first information is shown.
TABLE 1
Wherein, NSData represents a class of static byte buffers bridging data. NSData and its variable subclasses provide data objects or object-oriented wrappers for byte buffers. NSData classes provide a way to save their content to files in an atomic manner.
The UlPasteBoard representation described above is a class of user interface sticker. In typical usage, when a user requests a copy, cut, or repeat operation of an option in the user interface, an object in the application will write data to the clipboard. Then another object in the same or a different application reads the data from the paste board and presents it to the user at the new location; this typically occurs when a user requests a paste operation.
The above-mentioned avaset represents a class of multimedia playback for modeling multiple types of media tracks. Audio and video tracks are the most common track types.
And step 250, comparing the first thread information with the second thread information to obtain a thread test result corresponding to the target application.
The thread test result is used for representing the abnormal thread access condition in the target application.
By comparing the first thread information with the second thread information, whether the target execution thread and the actual execution thread corresponding to the instruction statement are consistent or not can be determined, if the target execution thread and the actual execution thread are not the same thread or are not the same class of threads, the thread call exception of the corresponding instruction statement is described, and therefore the thread test result can be generated.
In one example, as shown in FIG. 7, a schematic diagram of a multi-threaded exception access detection flow is illustratively shown. In the flow shown in fig. 7, a method call chain acquisition plug-in is integrated into an application development program Xcode; compiling a plurality of code files corresponding to the terminal application through an application development program, and performing grammar analysis on instruction sentences in the code files based on the method call chain acquisition plug-in the compiling process to obtain method call chain information; and combining and comparing the method call chain information with corresponding information between an operation method and threads in the multithreading scene to be detected to perform detection analysis of multithreading abnormal access, thereby obtaining a test result.
In an exemplary embodiment, as shown in FIG. 3, the implementation of step 250 described above includes the following steps (251-254).
Step 251, comparing the first thread information with the second thread information to obtain a comparison result.
In a possible implementation manner, the first thread information includes a thread identifier corresponding to an actual execution thread, the second thread information includes a thread identifier corresponding to a target execution thread, and the thread identifier corresponding to the actual execution thread is compared with the thread identifier corresponding to the target execution thread, so that a thread identifier comparison result can be obtained. The comparison result comprises a thread identification comparison result. By comparing the thread identifications, whether the target execution thread and the actual execution thread are the same thread or not can be determined, and correspondingly, the thread identification comparison result is that the target execution thread is the same as or different from the actual execution thread.
In another possible implementation manner, the first thread information includes a thread class corresponding to an actual execution thread, the second thread information includes a thread class corresponding to a target execution thread, and the thread class comparison result may be obtained by comparing the thread class corresponding to the actual execution thread with the thread class corresponding to the target execution thread. The comparison result comprises a thread class comparison result. By comparing thread types, whether the target execution thread and the actual execution thread are the same type threads or not can be determined, and correspondingly, the thread identification comparison result is that the target execution thread is the same or different from the actual execution thread in type.
In step 252, if the comparison result indicates that the first thread information and the second thread information do not match, an abnormal instruction statement is determined according to the comparison result.
The actual execution thread corresponding to the abnormal instruction statement is inconsistent with the target execution thread corresponding to the abnormal instruction statement.
The case that the first thread information and the second thread information are not matched includes that the target execution thread and the actual execution thread are not the same thread, and that the thread types of the target execution thread and the actual execution thread are different.
And determining the instruction statement which does not match the first thread information and the second thread information as the abnormal instruction statement.
Step 253, obtaining statement information corresponding to the abnormal instruction statement.
The statement information includes, but is not limited to, path information of a text file corresponding to the abnormal instruction statement, line number information of the abnormal instruction statement in the text file, an operation method corresponding to the abnormal instruction statement, an instance object, and thread call information.
Step 254, a thread test result is generated based on the statement information.
And generating the thread test result based on statement information corresponding to each abnormal instruction statement.
In an exemplary embodiment, the thread test results described above are displayed in a test results page. The abnormal instruction statement includes a first abnormal instruction statement and a second abnormal instruction statement. The first abnormal instruction statement is an instruction statement in which the target execution thread is a main thread and the actual execution thread is a worker thread, and the second abnormal instruction statement is an instruction statement in which the target execution thread is a worker thread and the actual execution thread is a main thread.
Alternatively, statement information of the first abnormal instruction statement and statement information of the second abnormal instruction statement are displayed in the test result page.
In one example, as shown in FIG. 8, a schematic diagram of a test results page is illustratively shown. In the test result page 80 shown in fig. 8, statement information of an abnormal instruction statement 1 that needs to operate at the main thread and statement information of a second abnormal instruction statement 2 that needs to operate at the worker thread are shown. The statement information of the abnormal instruction statement 1 may include an abnormal code file path 1, an example 1, an operation method 1, a code line number 1 and an abnormal call 1 corresponding to the abnormal instruction statement 1; statement information for the exception instruction statement 2 may include an exception code file path 2[ example 2 operation method 2] - > code line number 2: [ exception call 2].
One specific example of thread detection results is listed below to facilitate understanding by those skilled in the art, and is described below. The meaning of each statement information can be determined according to the following statement information format, namely, an abnormal code file path [ example operation method ] - > code line number: [ exception call ].
Operation at the main thread is required:
/Source/App/PersonalLiveBiz/Developer/DataReportTool/PLDevDataReportViewController.m[PL DevDataReportViewControllerexportLogFile:]->line:195[UIViewframe]οΌ›
/Source/App/PersonalLiveBiz/Room/Plugin/Gift/UI/PLGiftDisplay/PLFreeGiftDisplayViewController.m[PLFreeGiftDisplayViewControlleraddEmitterImage:width:]->line:307[UIView subviews]οΌ›
/Source/App/PersonalLiveBiz/AnnualCeLebration/RedPacket/PLAnnuaLRedPacketViewController.m[PLAnnuaLRedPacketViewControllerdataUpdatedοΌ›returnCodeοΌ›]->lineοΌ›375[PLPlayerViewmaskImageView]οΌ›
/Source/App/PersonalLiveBiz/EditPersonalInfo/UI/PLEditSchoolViewController.m[PLEditSchoolViewControllersearchBarTextDidEndEditing:]->line:225[UIButton enabled]οΌ›
/Source/App/PersonalLiveBiz/Room/Plugin/MemberList/PLMemberListCell.m[PLMemberListCellupdateAvatarFrame:type:]->line:230[YYAnimatedImageViewsetImage:]οΌ›
/Source/App/PersonalLiveBiz/TinyVideo/TinyVideo/PhotoEdit/Mosaic/FSMosaicViewController.m[FSMosaicViewControllerupdateImageοΌ›]->line:415[UIButtonenabled]。
Operation is required in the working thread:
/Source/App/PersonalLiveBiz/ShortRecord/Logic/PLDeliverShortVideoMgr.m[PLDeliverShortVideaMgrdeliverShortRecord:ShowProcess:]->line:131[NSDatadataWithContentsOfURL:]οΌ›
/Source/App/PersonalLiveBiz/Room/Plugin/OnlineDating/Logic/Lottie0pti/0DLottieUnzipper.m[ODLottieUnzipperunZipFile:toPath:]->line:77[MiniZipArchivenew]οΌ›
/Source/App/PersonalLiveBiz/ShortRecord/Logic/PLDeliverShortVideoMgr.m[PLDeliverShortVideoMgrinternalDeliverDoodle:]->lineοΌ›797[NSDatadataWithContents0fURLοΌ›]οΌ›
/Source/Kernel/QMX/QMX/Effects/GPUImageAudioSampLeDataProvider.m[GPUImageAudioSampleDataProviderreadAudioSamplesFromAsset:startTime:duration:]->line:49[AVAsset duration]οΌ›
/Source/App/Controls/QUI/UI/Cell/QUITableViewCell.m[QUITableViewCellgetImaqeFromURLοΌ›]->line:196[NSData dataWithContentsOfURL:]οΌ›
/Source/App/PersonalLiveBiz/TinyVideo/VideoPublish/PLVideoPublish.m[PLVideoPublish getFeedId:]->line:95[NSData dataWithContents0furl:]。
by displaying the statement information of the abnormal instruction statement, a developer can be helped to quickly solve the problem of abnormal thread access.
In summary, according to the technical solution provided in the embodiments of the present application, by acquiring the corresponding information between each operation method and each thread in the target test scenario and determining the operation method corresponding to the instruction statement in the text file corresponding to the target application, the target execution thread corresponding to the instruction statement may be determined according to the corresponding information, and then the target execution thread may be compared with the actual execution thread corresponding to the determined instruction statement, so as to obtain the thread test result corresponding to the whole target application, thereby comprehensively reflecting the situation of the abnormal access thread in the instruction statement corresponding to the target application, without dynamically running the target application, only performing static analysis on the instruction statement of the target application may automatically determine the comprehensive thread test result, covering the diversified use scenario, reducing complexity of the abnormal access test of the thread, improving the comprehensiveness and accuracy of the test, and integrally improving the test efficiency.
Referring to fig. 9, a flowchart of a testing method according to an embodiment of the present application is shown. The method can be applied to a computer device, wherein the computer device is an electronic device with data computing and processing capabilities, and the execution subject of each step can be the terminal 10 in the application running environment shown in fig. 1. The method may include the following steps (901-919).
Step 901, displaying an application development page corresponding to the target application development program.
In step 902, first information is obtained in response to the application development page receiving a compiling operation for a target application.
Step 903, at least one text file corresponding to the target application is obtained.
Step 904, obtaining a target text segment in at least one text file.
In step 905, in the case that the target text segment includes a first text segment corresponding to the first operation method, an instruction sentence associated with the first target information in the first text segment is determined.
Step 906, determining an instruction sentence associated with the second target information in the second text segment in the case that the target text segment includes the second text segment corresponding to the second operation method.
For the explanation of the above steps, reference should be made to the content of the previous embodiment, and the description is omitted here.
Step 907, obtaining at least one instruction statement based on the object class inheritance information, the first identification information, the instruction statement associated with the first parameter information, and the instruction statement associated with the second identification information and the second parameter information.
And screening the object category inheritance information, the first identification information and the instruction statement related to the first parameter information and the instruction statement related to the second identification information and the second parameter information from at least one text file to obtain at least one instruction statement to be analyzed in the embodiment of the application.
Optionally, generating a target file corresponding to the at least one text file based on the at least one instruction statement; analyzing the target file to obtain an analysis result; and determining an operation method and first thread information corresponding to at least one instruction statement according to the analysis result. The process of determining the operation method corresponding to at least one instruction statement and the first thread information is performed in the following steps.
Step 908, a target pointer is obtained.
The target pointer is used for representing the position information corresponding to the instruction statement to be detected.
Step 909, based on the target pointer, determining a current detection statement in the at least one instruction statement.
Step 910, thread marking information is obtained.
The thread marking information is used for representing the history execution thread corresponding to the history detection statement.
Because the embodiment of the application determines the abnormal access problem of the thread through static code analysis, the instruction statement is not actually executed, and therefore the execution thread corresponding to the instruction statement needs to be marked.
Thread marking information includes, but is not limited to, thread identification and thread category.
Step 911, based on the thread marking information, determining the first thread information corresponding to the current detection statement.
The actual execution thread corresponding to each instruction statement is associated with the last execution instruction statement corresponding to the instruction statement, and if the last execution instruction statement does not involve thread change operation, the actual execution thread of the instruction statement is the same as the execution thread of the last execution instruction statement; if the last execution instruction statement involves a thread change operation, the actual execution thread of the instruction statement is the target switch thread after the last execution instruction statement is executed. Therefore, it is necessary to acquire the mark information capable of characterizing the historical execution thread and determine the actual execution thread corresponding to the current detection statement based on the thread mark information.
Step 912, performing operation method identification processing on the current detection statement to obtain a target operation method corresponding to the current detection statement.
In an exemplary embodiment, word recognition processing is performed on the current detection sentence, and a word recognition result is obtained. If the word recognition result corresponds to the target field corresponding to the target operation method, the operation method corresponding to the current detection statement can be determined to be the target operation method.
Step 913, determining second thread information corresponding to the target operation method according to the first information.
And determining the thread information corresponding to the target operation method in the first information as the second thread information.
Step 914, comparing the first thread information with the second thread information to obtain a comparison result.
In step 915, if the comparison result indicates that the first thread information and the second thread information do not match, the current detection statement is determined as an abnormal instruction statement.
Step 916, outputting statement information corresponding to the abnormal instruction statement.
Step 917, determining whether the current test statement is the last instruction statement. If yes. Step 918 is performed; if not, go to step 919.
Step 918, generating a thread test result based on the statement information.
In step 919, the target pointer and thread marking information are updated based on the target operating method. And starts execution from step 909 described above.
In an exemplary embodiment, as shown in fig. 10, the implementation of the step 919 includes the following steps (9191-9197), and fig. 10 shows a flowchart five of a test method according to an embodiment of the present application.
In step 9191, it is determined whether the target operation method is a thread change operation method. If yes, start execution from step 9192; if not, go to step 9197.
Whether the operation method is a thread change operation method is judged, and a need exists to know which operation method calls change threads. In an exemplary embodiment, second information is acquired, where the second information includes attribute information corresponding to at least one thread change operation method, and the attribute information includes a class, a method name, and a thread class corresponding to the thread change operation method; and judging whether the target operation method is a thread change operation method according to the second information. Specifically, if the second information includes the target operation method, the target operation method is a thread change operation method; if the second information does not include the target operation method, the target operation method does not change the operation method for the thread.
In one example, as shown in table 2 below, a portion of the second information is shown.
TABLE 2
Where NSThread represents an abstract class of execution threads that can be used if the method is intended to run in its own execution thread. NSOperation represents an abstract class of code and data related to a single task. Nsnotatization center is a notification distribution mechanism that can broadcast information to registered watchers. DetachNewThreadWithBlock (using code blocks to separate new threads) is a method of separating new threads using blocks. The deltachnewhreadselector uses a selector to separate new threads, the toTarget, the target receiver, the witobjecte, is a method of separating a new thread and using the specified selector as the thread entry point. The Selector under the method is a Selector for sending target information to a target receiver; toparget is an object that receives target information at a new thread; the witobjectis parameter information, possibly null, delivered to the intended recipient. performselectlnbackground, withole, refers to a method of invoking a recipient on a new background thread. The selector under the method is a selector for identifying the method call; the target information under the method may be an argument parameter that is passed to the method at the time of invocation. If the method does not have parameters, the target information is null if there is no parameter. performselectonmainthread (executing selector on main thread): witobject (target information): waitunit done (waiting for completion): modes): refers to a method of invoking a recipient on main thread using a specified mode. performselectonmainthread (executing selector on main thread): witobject:. Waitunit done:. Waiting for completion) refers to a method of invoking a recipient on main thread using default mode. The block operation withblock refers to a method of creating and returning an object and adding a specified block thereto. initWithTarget (initialization target): selector): object: refer to returning NSThread to be initialized with a given parameter. dispatch_async refers to a method of submitting a block of code to execute asynchronously on a dispatch queue and return immediately. dispatch_sync refers to a method of submitting a code block to a specified dispatch queue for synchronous execution. Avplayltemdplaytoendtimenotification refers to a method of a system issuing a notification when a player item plays to its end time.
In step 9192, changed thread information corresponding to the target operating method is determined.
And under the condition that the target operation method is a thread change operation method, determining changed thread information corresponding to the target operation method.
After the thread called by the instruction statement changes the operation method, the execution thread of the next instruction statement is changed, and the thread changed by the thread change operation method usually corresponds to the thread change operation method, so that the changed thread can be determined according to the target operation method, and the changed thread information is changed thread information.
In step 9193, the thread marking information is updated based on the changed thread information.
Optionally, the thread marking information is updated to the changed thread information, so as to determine the actual execution thread corresponding to the next detection statement.
In step 9194, parameter information corresponding to the target operation method is obtained.
The parameter information is used for determining a message receiver for message transmission by using the target operation method, and an instruction statement corresponding to the message receiver is executed after the execution of the current detection statement.
Step 9195, determining the next detection statement corresponding to the current detection statement based on the parameter information.
In one possible implementation, as shown in fig. 11, the implementation of the step 9195 includes the following steps (9195 a to 9195 b), and fig. 11 shows a flowchart six of a test method provided in an embodiment of the present application.
In step 9195a, when the parameter information includes statement block parameter information, an instruction statement block corresponding to the statement block parameter information is determined.
An instruction statement block refers to a set of instruction statements that perform a target operation. Instruction statement blocks are the code blocks mentioned in the above embodiments.
If the parameter information comprises statement block parameter information, the next detection statement corresponding to the current detection statement is indicated to be in the instruction statement set corresponding to the instruction statement block, so that the instruction statement block corresponding to the current detection statement is determined according to the statement block parameter information,
step 9195b determines the next detection statement in the instruction statement block.
In an exemplary embodiment, if the instruction statement block is called for the first time, the first instruction statement in the instruction statement block may be determined to be the next detection statement.
In another possible implementation, as shown in fig. 11, the implementation of the step 9195 includes the following steps (9195 c-9195 e).
In step 9195c, in case the parameter information includes selector parameter information, a first object class corresponding to the target operation method and a second object class corresponding to the selector parameter information are determined.
The target operation method is an operation method called by the current detection statement, and the first object class corresponding to the target operation method is also an object class corresponding to the current detection statement; the next detection statement indicated by the selector parameter information also invokes the operation method, so that the second object class corresponding to the selector parameter information is also the second object class corresponding to the next detection statement.
In the exemplary embodiment, the instruction sentences corresponding to the respective object categories are respectively in different text files, so that in the case of a thread change, it is necessary to determine the object category corresponding to the current detection sentence and the next detection sentence, thereby determining the next detection sentence.
In step 9195d, if the first object class matches the second object class, determining the instruction sentence corresponding to the selector parameter information in the text file corresponding to the current detection sentence as the next detection sentence.
The case where the first object class matches the second object class includes the first object class being the same as the second object class. If the first object class is the same as the second object class, it can be explained that the current detection sentence and the next detection sentence both correspond to the same object class, and the next detection sentence does not need to be searched from other files.
In an exemplary embodiment, a first JSON file corresponding to a text file corresponding to a current detection statement is parsed, an instruction statement corresponding to selector parameter information in the text file corresponding to the current detection statement is determined, and the instruction statement is determined as a next detection statement.
In step 9195e, if the first object class does not match the second object class, determining the instruction sentence corresponding to the selector parameter information in the text file corresponding to the second object class as the next detection sentence.
The first object class and the second object class not matching includes the first object class being different from the second object class. If the first object class is different from the second object class, it may be indicated that the current detection sentence and the next detection sentence correspond to different object classes, and the next detection sentence needs to be searched from other files.
In an exemplary embodiment, a second JSON file corresponding to a text file corresponding to a second object class is obtained; and analyzing the second JSON file, determining a corresponding instruction statement of the selector parameter information in the text file corresponding to the second object category, and determining the instruction statement as a next detection statement.
In step 9196, the location information corresponding to the target pointer is updated to the location information corresponding to the next detection statement.
Step 9197, keeping thread marking information unchanged, and updating the position information corresponding to the target pointer to the position information of the next instruction statement corresponding to the current detection statement in the at least one instruction statement.
And under the condition that the target operation method does not change the operation method for the thread, maintaining thread marking information unchanged, and updating the position information corresponding to the target pointer into the position information of the next instruction statement corresponding to the current detection statement in at least one instruction statement.
In one example, as shown in FIG. 12, a schematic diagram of a detection flow of an abnormal thread access is shown. And traversing the operation methods in each class, and judging whether the operation method is detected after traversing any operation method. If yes, not processing; if not, traversing each statement node in the text segment corresponding to the operation method, and judging whether the operation method corresponding to the statement accords with the thread call after traversing any statement node. If not, sending out a warning that the statement is an abnormal thread calling statement; if yes, judging whether the operation method corresponding to the statement has the thread changing capability. If not, updating the sentence nodes and continuously detecting according to the flow; if so, the thread type is marked, and whether a selector parameter or a code block parameter (block) exists in the parameter associated with the operation method corresponding to the statement is judged. If the block exists, traversing the corresponding code block node, and starting to execute from the step of judging whether the operation method accords with the thread call; if the selector exists, judging whether the operation method pointed by the selector is the method of the category or not so as to check whether a cross-category traversal method is needed or not. The above-described class method refers to an operation method belonging to the class currently traversed. If yes, changing the traversing sequence to the operation method pointed by the selector in the class and executing from the step of judging whether the operation method is detected or not; if not, acquiring JSON files corresponding to other classes, analyzing the JSON files corresponding to other classes, changing the traversing sequence to other class operation methods pointed by the selector, and executing from the step of judging whether the operation methods are detected. And (3) circulating until all classes are traversed, outputting a complete test result after the whole circulating detection process is finished, and finding out all instruction sentences related to abnormal thread access.
The following is a code written in the Objective-C language, in which instruction statements in which an abnormal thread access condition exists are marked in the form of comments, and the code content is as follows:
in the code, the instruction statement of the 37 th line and the instruction statement of the 52 th line do not conform to the thread call, so that the instruction statement of the 37 th line and the instruction statement of the 52 th line are displayed as abnormal instruction statements in the final test result, and the instruction statement of the 37 th line and the instruction statement of the 52 th line are indicated to be executed on the main thread.
In summary, according to the technical scheme provided by the embodiment of the application, static code analysis is performed when the target application is compiled, so that a target instruction statement related to method call in a text file is obtained, and an operation method related to the target instruction statement call is traversed, so that a method call relation between the target instruction statements and related thread switching operation are determined, historical execution thread information is marked, an actual execution thread corresponding to the target instruction statement is determined according to the historical execution thread information under the condition that no code is run, the actual execution thread is compared with the target execution thread, so that an abnormal instruction statement is determined, a test result is generated according to statement information of the abnormal instruction statement, the condition of the abnormal access thread in the instruction statement corresponding to the target application is comprehensively reflected, the target application does not need to be dynamically operated, the comprehensive thread test result can be automatically determined only by performing static analysis on the instruction statement of the target application, the diversified use scene is covered, the complexity of the thread abnormal access test is reduced, the test comprehensiveness and the test accuracy are improved, and the test efficiency is integrally improved.
The following are device embodiments of the present application, which may be used to perform method embodiments of the present application. For details not disclosed in the device embodiments of the present application, please refer to the method embodiments of the present application.
Referring to fig. 13, a block diagram of a test apparatus according to an embodiment of the present application is shown. The device has the function of realizing the test method, and the function can be realized by hardware or by executing corresponding software by the hardware. The device may be a computer device or may be provided in a computer device. The apparatus 1300 may include: the first information acquisition module 1310, the text file acquisition module 1320, the execution thread determination module 1330, the target thread determination module 1340, and the test result generation module 1350.
A first information obtaining module 1310, configured to obtain first information, where the first information is used to characterize a correspondence between at least one operation method associated with a target test scenario and at least two threads, where the at least two threads are threads corresponding to a target application;
a text file obtaining module 1320, configured to obtain at least one text file corresponding to the target application, where the at least one text file includes at least one instruction sentence;
An execution thread determining module 1330, configured to determine an operation method and first thread information corresponding to the at least one instruction statement, where the first thread information is used to characterize an actual execution thread corresponding to the operation method;
a target thread determining module 1340, configured to determine, according to the first information, second thread information corresponding to the operation method, where the second thread information is used to characterize a target execution thread corresponding to the operation method in the target test scenario;
and the test result generating module 1350 is configured to compare the first thread information with the second thread information to obtain a thread test result corresponding to the target application.
In an exemplary embodiment, the test result generating module 1350 includes: the device comprises a thread comparison unit, an abnormal statement determination unit, a statement information acquisition unit and a test result generation unit.
And the thread comparison unit is used for comparing the first thread information with the second thread information to obtain a comparison result.
And the abnormal statement determining unit is used for determining an abnormal instruction statement according to the comparison result if the comparison result indicates that the first thread information is not matched with the second thread information, and the actual execution thread corresponding to the abnormal instruction statement is inconsistent with the target execution thread corresponding to the abnormal instruction statement.
And the statement information acquisition unit is used for acquiring statement information corresponding to the abnormal instruction statement.
And the test result generating unit is used for generating the thread test result based on the statement information.
In an exemplary embodiment, the thread of execution determination module 1330 includes: the device comprises a pointer acquisition unit, a detection statement determination unit, a thread mark acquisition unit, an execution thread determination unit, an operation method identification unit and an information update unit.
The pointer acquisition unit is used for acquiring a target pointer, wherein the target pointer is used for representing the position information corresponding to the instruction statement to be detected.
And the detection statement determining unit is used for determining the current detection statement in the at least one instruction statement based on the target pointer.
The thread mark acquisition unit is used for acquiring thread mark information, and the thread mark information is used for representing a history execution thread corresponding to the history detection statement.
And the execution thread determining unit is used for determining the first thread information corresponding to the current detection statement based on the thread marking information.
And the operation method identification unit is used for carrying out operation method identification processing on the current detection statement to obtain a target operation method corresponding to the current detection statement.
And an information updating unit configured to update the target pointer and the thread flag information based on the target operation method, and start execution from the step of determining a current detection statement in the at least one instruction statement based on the target pointer.
In an exemplary embodiment, the information updating unit includes: the thread change determining subunit, the thread mark updating subunit, the method parameter obtaining subunit, the detection statement determining subunit and the pointer updating subunit.
And the thread change determining subunit is used for determining changed thread information corresponding to the target operation method when the target operation method is the thread change operation method.
And the thread mark updating subunit is used for updating the thread mark information based on the changed thread information.
And the method parameter acquisition subunit is used for acquiring parameter information corresponding to the target operation method.
And the detection statement determining subunit is used for determining the next detection statement corresponding to the current detection statement based on the parameter information.
And the pointer updating subunit is used for updating the position information corresponding to the target pointer into the position information corresponding to the next detection statement.
In an exemplary embodiment, the detection statement determination subunit is specifically configured to:
determining an instruction statement block corresponding to statement block parameter information under the condition that the parameter information comprises statement block parameter information, wherein the instruction statement block refers to an instruction statement set for executing target operation;
the next detection statement is determined in the instruction statement block.
In an exemplary embodiment, the detection statement determination subunit is further specifically configured to:
determining a first object category corresponding to the target operation method and a second object category corresponding to the selector parameter information under the condition that the parameter information comprises the selector parameter information;
if the first object class is matched with the second object class, determining the instruction statement corresponding to the selector parameter information in the text file corresponding to the current detection statement as the next detection statement;
and if the first object class is not matched with the second object class, determining the instruction statement corresponding to the selector parameter information in the text file corresponding to the second object class as the next detection statement.
In an exemplary embodiment, the apparatus 1300 further comprises: the system comprises a text fragment acquisition module and a target sentence determination module.
And the text segment acquisition module is used for acquiring a target text segment in the at least one text file, wherein the target text segment is used for representing the realization information of the target object category.
The target sentence determining module is used for determining a target instruction sentence in the target text segment under the condition that the target text segment comprises the target text segment corresponding to a preset operation method; the target text segment is used for representing implementation information of the preset operation method, the target instruction statement is an instruction statement representing method calling information corresponding to the preset operation method, and the at least one instruction statement comprises the target instruction statement.
The execution thread determining module 1330 is further configured to determine an operation method and first thread information corresponding to the target instruction statement.
In an exemplary embodiment, the preset operation method includes a first operation method, where the first operation method is an operation method corresponding to a first programming language, and the target sentence determining module includes: a first sentence determining unit, a target sentence determining unit.
A first sentence determining unit, configured to determine, in a case where the target text segment includes a first text segment corresponding to the first operation method, an instruction sentence associated with first target information in the first text segment; the first text segment is used for representing implementation information of the first operation method, the first target information is used for representing a method calling relation corresponding to the first operation method, and the first target information comprises at least one of object category inheritance information, first identification information and first parameter information corresponding to the first operation method.
And the target instruction statement determining unit is used for determining the instruction statement associated with the object category inheritance information, the first identification information and the first parameter information as the target instruction statement.
In an exemplary embodiment, the preset operation method includes a second operation method, where the second operation method is an operation method corresponding to a second programming language, and the target sentence determining module further includes: and a second sentence determination unit.
A second sentence determining unit, configured to determine, in a case where the target text segment includes a second text segment corresponding to the second operation method, an instruction sentence associated with second target information in the second text segment; the second text segment is used for representing implementation information of the second operation method, the second target information is used for representing a method calling relation corresponding to the second operation method, and the second target information comprises second identification information and second parameter information corresponding to the second operation method.
The target instruction statement determining unit is further configured to determine an instruction statement associated with the second identification information and the second parameter information as the target instruction statement.
In an exemplary embodiment, the apparatus 1300 further comprises: and a target file generation module.
The target file generation module is used for generating a target file corresponding to the at least one text file based on the target instruction statement, and the target file is used for representing the method call chain information corresponding to the at least one instruction statement.
The execution thread determining module 1330 includes: target file analysis unit, method and thread determination unit.
And the target file analysis unit is used for analyzing the target file to obtain an analysis result.
And the method and thread determining unit is used for determining an operation method and first thread information corresponding to the target instruction statement according to the analysis result.
In an exemplary embodiment, the apparatus corresponds to a target application development program, and the apparatus 1300 further includes: the system comprises a page display module and a compiling execution module.
And the page display module is used for displaying an application development page corresponding to the target application development program.
And the compiling execution module is used for responding to the application development page to receive the compiling operation aiming at the target application, and executing from the step of acquiring the first information.
In summary, according to the technical solution provided in the embodiments of the present application, by acquiring the corresponding information between each operation method and each thread in the target test scenario and determining the operation method corresponding to the instruction statement in the text file corresponding to the target application, the target execution thread corresponding to the instruction statement may be determined according to the corresponding information, and then the target execution thread may be compared with the actual execution thread corresponding to the determined instruction statement, so as to obtain the thread test result corresponding to the whole target application, thereby comprehensively reflecting the situation of the abnormal access thread in the instruction statement corresponding to the target application, without dynamically running the target application, only performing static analysis on the instruction statement of the target application may automatically determine the comprehensive thread test result, covering the diversified use scenario, reducing complexity of the abnormal access test of the thread, improving the comprehensiveness and accuracy of the test, and integrally improving the test efficiency.
It should be noted that, in the apparatus provided in the foregoing embodiment, when implementing the functions thereof, only the division of the foregoing functional modules is used as an example, in practical application, the foregoing functional allocation may be implemented by different functional modules, that is, the internal structure of the device is divided into different functional modules, so as to implement all or part of the functions described above. In addition, the apparatus and the method embodiments provided in the foregoing embodiments belong to the same concept, and specific implementation processes of the apparatus and the method embodiments are detailed in the method embodiments and are not repeated herein.
Referring to fig. 14, a block diagram of a computer device according to an embodiment of the present application is shown. The computer device may be a terminal. The computer device is used to implement the test method provided in the above embodiments. Specifically, the present invention relates to a method for manufacturing a semiconductor device.
In general, the computer device 1400 includes: a processor 1401 and a memory 1402.
Processor 1401 may include one or more processing cores, such as a 4-core processor, an 8-core processor, and the like. The processor 1401 may be implemented in at least one hardware form of DSP (Digital Signal Processing ), FPGA (Field Programmable Gate Array, field programmable gate array), PLA (Programmable Logic Array ). The processor 1401 may also include a main processor, which is a processor for processing data in an awake state, also called a CPU (Central Processing Unit ), and a coprocessor; a coprocessor is a low-power processor for processing data in a standby state. In some embodiments, the processor 1401 may be integrated with a GPU (Graphics Processing Unit, image processor) for rendering and rendering of content required to be displayed by the display screen. In some embodiments, the processor 1401 may also include an AI (Artificial Intelligence ) processor for processing computing operations related to machine learning.
Memory 1402 may include one or more computer-readable storage media, which may be non-transitory. Memory 1402 may also include high-speed random access memory, as well as non-volatile memory, such as one or more magnetic disk storage devices, flash memory storage devices. In some embodiments, a non-transitory computer readable storage medium in memory 1402 is used to store at least one instruction, at least one program, set of codes, or set of instructions configured to be executed by one or more processors to implement the above-described test methods.
In some embodiments, the computer device 1400 may also optionally include: a peripheral interface 1403 and at least one peripheral. The processor 1401, memory 1402, and peripheral interface 1403 may be connected by a bus or signal lines. The individual peripheral devices may be connected to the peripheral device interface 1403 via buses, signal lines or a circuit board. Specifically, the peripheral device includes: at least one of radio frequency circuitry 1404, a touch display screen 1405, a camera assembly 1406, audio circuitry 1407, a positioning assembly 1408, and a power source 1409.
Those skilled in the art will appreciate that the architecture shown in fig. 14 is not limiting as to the computer device 1400, and may include more or fewer components than shown, or may combine certain components, or employ a different arrangement of components.
In an exemplary embodiment, a computer readable storage medium is also provided, in which at least one instruction, at least one program, a set of codes, or a set of instructions is stored, which when executed by a processor, implement the above-described test method.
Alternatively, the computer-readable storage medium may include: ROM (Read Only Memory), RAM (Random Access Memory ), SSD (Solid State Drives, solid state disk), or optical disk, etc. The random access memory may include ReRAM (Resistance Random Access Memory, resistive random access memory) and DRAM (Dynamic Random Access Memory ), among others.
In an exemplary embodiment, a computer program product or a computer program is also provided, the computer program product or computer program comprising 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 the processor executes the computer instructions so that the computer device performs the above-described test method.
It should be understood that references herein to "a plurality" are to two or more. "and/or", describes an association relationship of an association object, and indicates that there may be three relationships, for example, a and/or B, and may indicate: a exists alone, A and B exist together, and B exists alone. The character "/" generally indicates that the context-dependent object is an "or" relationship. In addition, the step numbers described herein are merely exemplary of one possible execution sequence among steps, and in some other embodiments, the steps may be executed out of the order of numbers, such as two differently numbered steps being executed simultaneously, or two differently numbered steps being executed in an order opposite to that shown, which is not limited by the embodiments of the present application.
In addition, in the specific embodiments of the present application, related data such as user information is related, when the above embodiments of the present application are applied to specific products or technologies, user permission or consent needs to be obtained, and the collection, use and processing of related data need to comply with related laws and regulations and standards of related countries and regions.
The foregoing description of the exemplary embodiments of the present application is not intended to limit the invention to the particular embodiments disclosed, but on the contrary, the intention is to cover all modifications, equivalents, alternatives, and alternatives falling within the spirit and scope of the invention.

Claims (15)

1. A method of testing, the method comprising:
acquiring first information, wherein the first information is used for representing the corresponding relation between at least one operation method associated with a target test scene and at least two threads, and the at least two threads are threads corresponding to a target application;
acquiring at least one text file corresponding to the target application, wherein the at least one text file comprises at least one instruction statement;
determining an operation method and first thread information corresponding to the at least one instruction statement, wherein the first thread information is used for representing an actual execution thread corresponding to the operation method;
determining second thread information corresponding to the operation method according to the first information, wherein the second thread information is used for representing a target execution thread corresponding to the operation method in the target test scene;
and comparing the first thread information with the second thread information to obtain a thread test result corresponding to the target application.
2. The method of claim 1, wherein comparing the first thread information with the second thread information to obtain a thread test result corresponding to the target application, comprises:
Comparing the first thread information with the second thread information to obtain a comparison result;
if the comparison result indicates that the first thread information is not matched with the second thread information, determining an abnormal instruction statement according to the comparison result, wherein an actual execution thread corresponding to the abnormal instruction statement is inconsistent with a target execution thread corresponding to the abnormal instruction statement;
acquiring statement information corresponding to the abnormal instruction statement;
and generating the thread test result based on the statement information.
3. The method according to claim 1 or 2, wherein determining the operation method and the first thread information corresponding to the at least one instruction statement comprises:
acquiring a target pointer, wherein the target pointer is used for representing position information corresponding to an instruction statement to be detected;
determining a current detection statement in the at least one instruction statement based on the target pointer;
acquiring thread marking information, wherein the thread marking information is used for representing a history execution thread corresponding to a history detection statement;
determining first thread information corresponding to the current detection statement based on the thread marking information;
Performing operation method identification processing on the current detection statement to obtain a target operation method corresponding to the current detection statement;
updating the target pointer and the thread marking information based on the target operation method, and starting execution from the step of determining a current detection statement in the at least one instruction statement based on the target pointer.
4. The method of claim 3, wherein the updating the target pointer and the thread tag information based on the target operation method comprises:
determining changed thread information corresponding to the target operation method under the condition that the target operation method is a thread change operation method;
updating the thread marking information based on the changed thread information;
acquiring parameter information corresponding to the target operation method;
determining a next detection statement corresponding to the current detection statement based on the parameter information;
and updating the position information corresponding to the target pointer to the position information corresponding to the next detection statement.
5. The method of claim 4, wherein the determining, based on the parameter information, a next detection statement corresponding to the current detection statement comprises:
Determining an instruction statement block corresponding to statement block parameter information under the condition that the parameter information comprises statement block parameter information, wherein the instruction statement block refers to an instruction statement set for executing target operation;
the next detection statement is determined in the instruction statement block.
6. The method of claim 4, wherein determining a next detection statement corresponding to the current detection statement based on the parameter information, further comprises:
determining a first object category corresponding to the target operation method and a second object category corresponding to the selector parameter information under the condition that the parameter information comprises the selector parameter information;
if the first object class is matched with the second object class, determining the instruction statement corresponding to the selector parameter information in the text file corresponding to the current detection statement as the next detection statement;
and if the first object class is not matched with the second object class, determining the instruction statement corresponding to the selector parameter information in the text file corresponding to the second object class as the next detection statement.
7. The method according to claim 1, wherein the method further comprises:
acquiring a target text segment in the at least one text file, wherein the target text segment is used for representing realization information of a target object class;
determining a target instruction sentence in a target text segment under the condition that the target text segment comprises the target text segment corresponding to a preset operation method; the method comprises the steps that a target text segment is used for representing implementation information of a target object type, a target instruction statement is used for representing method calling information corresponding to the target object type, and at least one instruction statement comprises the target instruction statement;
the determining the operation method and the first thread information corresponding to the at least one instruction statement includes:
and determining an operation method and first thread information corresponding to the target instruction statement.
8. The method according to claim 7, wherein the preset operation method includes a first operation method, the first operation method being an operation method corresponding to a first programming language, and the determining, in a case where the target text segment includes a target text segment corresponding to the preset operation method, a target instruction sentence in the target text segment includes:
Determining an instruction statement associated with first target information in a first text segment under the condition that the target text segment comprises the first text segment corresponding to the first operation method; the first text segment is used for representing implementation information of the first operation method, the first target information is used for representing a method calling relation corresponding to the first operation method, and the first target information comprises at least one of object category inheritance information, first identification information and first parameter information corresponding to the first operation method;
and determining the object category inheritance information, the first identification information and the instruction statement related to the first parameter information as the target instruction statement.
9. The method according to claim 7, wherein the preset operation method includes a second operation method, the second operation method being an operation method corresponding to a second programming language, and the determining, in the case that the target text segment includes a target text segment corresponding to the preset operation method, a target instruction sentence in the target text segment includes:
determining an instruction statement associated with second target information in a second text segment under the condition that the target text segment comprises the second text segment corresponding to the second operation method; the second text segment is used for representing implementation information of the second operation method, the second target information is used for representing a method calling relation corresponding to the second operation method, and the second target information comprises second identification information and second parameter information corresponding to the second operation method;
And determining the instruction statement associated with the second identification information and the second parameter information as the target instruction statement.
10. The method according to any one of claims 7 to 9, further comprising:
generating a target file corresponding to the at least one text file based on the target instruction statement, wherein the target file is used for representing method call chain information corresponding to the at least one instruction statement;
the determining the operation method and the first thread information corresponding to the target instruction statement comprises the following steps:
analyzing the target file to obtain an analysis result;
and determining an operation method and first thread information corresponding to the target instruction statement according to the analysis result.
11. The method of claim 1, wherein the method is applied in a target application development program, the method further comprising:
displaying an application development page corresponding to the target application development program;
and in response to the application development page receiving a compiling operation for the target application, executing from the step of acquiring the first information.
12. A test apparatus, the apparatus comprising:
The first information acquisition module is used for acquiring first information, wherein the first information is used for representing the corresponding relation between at least one operation method associated with a target test scene and at least two threads, and the at least two threads are threads corresponding to a target application;
the text file acquisition module is used for acquiring at least one text file corresponding to the target application, wherein the at least one text file comprises at least one instruction statement;
the execution thread determining module is used for determining an operation method corresponding to the at least one instruction statement and first thread information, wherein the first thread information is used for representing an actual execution thread corresponding to the operation method;
the target thread determining module is used for determining second thread information corresponding to the operation method according to the first information, wherein the second thread information is used for representing a target execution thread corresponding to the operation method in the target test scene;
and the test result generation module is used for comparing the first thread information with the second thread information to obtain a thread test result corresponding to the target application.
13. A computer device comprising a processor and a memory having stored therein at least one instruction, at least one program, code set or instruction set that is loaded and executed by the processor to implement the test method of any of claims 1 to 11.
14. A computer readable storage medium having stored therein at least one instruction, at least one program, code set, or instruction set, the at least one instruction, the at least one program, the code set, or instruction set being loaded and executed by a processor to implement the test method of any of claims 1 to 11.
15. A computer program product, characterized in that it comprises computer instructions stored in a computer-readable storage medium, from which computer instructions a processor of a computer device reads, which processor executes the computer instructions, so that the computer device executes to implement the test method according to any one of claims 1 to 11.
CN202210078880.9A 2022-01-24 2022-01-24 Test method, test device, test equipment, test storage medium and test product Pending CN116521510A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210078880.9A CN116521510A (en) 2022-01-24 2022-01-24 Test method, test device, test equipment, test storage medium and test product

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210078880.9A CN116521510A (en) 2022-01-24 2022-01-24 Test method, test device, test equipment, test storage medium and test product

Publications (1)

Publication Number Publication Date
CN116521510A true CN116521510A (en) 2023-08-01

Family

ID=87406822

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210078880.9A Pending CN116521510A (en) 2022-01-24 2022-01-24 Test method, test device, test equipment, test storage medium and test product

Country Status (1)

Country Link
CN (1) CN116521510A (en)

Similar Documents

Publication Publication Date Title
CN106980504B (en) Application program development method and tool and equipment thereof
CN111736840A (en) Compiling method and running method of applet, storage medium and electronic equipment
CN110764748B (en) Code calling method, device, terminal and storage medium
CN114691188B (en) Compatibility assessment method, device, equipment and storage medium
CN115639980A (en) Draggable front-end logic arrangement method and device for low-code platform
CN110941655A (en) A data format conversion method and device
CN110955409B (en) Method and device for creating resources on cloud platform
CN108170430B (en) Interface display method and system
CN113901083A (en) Heterogeneous data source operation resource analysis positioning method and equipment based on multiple analyzers
CN113778897A (en) Automatic test method, device, equipment and storage medium of interface
CN113051514A (en) Element positioning method and device, electronic equipment and storage medium
CN111240772A (en) Data processing method and device based on block chain and storage medium
CN112988175A (en) Cross-platform application installation package generation method, device, medium and electronic equipment
CN110888972A (en) Sensitive content identification method and device based on Spark Streaming
CN115599359A (en) Code generation method, device, equipment and medium
CN113987337A (en) Search method, system, equipment and storage medium based on componentized dynamic arrangement
CN116521510A (en) Test method, test device, test equipment, test storage medium and test product
CN111488286A (en) Method and device for independently developing Android module
CN116414689A (en) Interface parameter verification method and system based on reflection mechanism
CN115858556A (en) Data processing method and device, storage medium and electronic equipment
CN110765003B (en) Code detection method, device and equipment and storage medium
CN114546410A (en) Code optimization method based on design mode and related equipment
CN113961279A (en) Page rendering method, device, server and storage medium
CN110688430A (en) Method and device for obtaining data bypass and electronic equipment
CN117075912B (en) Method for program language conversion, compiling method and related equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination