CN111831573B - Method, device, computer system and medium for determining code branch coverage condition - Google Patents

Method, device, computer system and medium for determining code branch coverage condition Download PDF

Info

Publication number
CN111831573B
CN111831573B CN202010734322.4A CN202010734322A CN111831573B CN 111831573 B CN111831573 B CN 111831573B CN 202010734322 A CN202010734322 A CN 202010734322A CN 111831573 B CN111831573 B CN 111831573B
Authority
CN
China
Prior art keywords
code
branch
executed
function
target application
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.)
Active
Application number
CN202010734322.4A
Other languages
Chinese (zh)
Other versions
CN111831573A (en
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.)
Industrial and Commercial Bank of China Ltd ICBC
Original Assignee
Industrial and Commercial Bank of China Ltd ICBC
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 Industrial and Commercial Bank of China Ltd ICBC filed Critical Industrial and Commercial Bank of China Ltd ICBC
Priority to CN202010734322.4A priority Critical patent/CN111831573B/en
Publication of CN111831573A publication Critical patent/CN111831573A/en
Application granted granted Critical
Publication of CN111831573B publication Critical patent/CN111831573B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3676Test management for coverage analysis

Landscapes

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

Abstract

The present disclosure provides a method for determining a code branch coverage condition, including: determining a logic grammar tree of the target application program according to the code logic of the target application program, wherein the logic grammar tree comprises a plurality of branches, and each branch is used for representing a function call relation in the code of the target application program; acquiring function call chain information of executed codes in the process of testing a target application program; generating a branch relation diagram of the executed code according to the function call chain information of the executed code; and determining the code branch coverage condition of the target application program in the test process according to the branch relation diagram and the logic grammar tree of the executed code. The present disclosure provides a determination apparatus, a computer system, and a medium for code branch coverage. The method and the device for determining the code branch coverage condition can be used for determining the code branch coverage condition in the software testing process in the financial field or other fields.

Description

Method, device, computer system and medium for determining code branch coverage condition
Technical Field
The present disclosure relates to the field of computer technology, and more particularly, to a method, an apparatus, a computer system, and a medium for determining a code branch coverage situation.
Background
Software testing is the process of executing a program to find errors in the program, and is a software process that helps identify the accuracy (overall) and completeness (quality) of developed (intermediate or final versions) computer software. The test scene should cover all program branches as much as possible, avoiding software errors not being found due to test scene misses. The black box test is an important means of software test, and in the black box test process, because a tester has difficulty in grasping code program branches and execution conditions of the program branches, judgment of test coverage conditions of the code branches is always a difficult problem faced by the black box test.
Disclosure of Invention
In view of this, the present disclosure provides a method, apparatus, computer system, and medium for determining code branch coverage.
One aspect of the present disclosure provides a method for determining a code branch coverage condition, including: determining a logic grammar tree of a target application program according to code logic of the target application program, wherein the logic grammar tree comprises a plurality of branches, and each branch is used for representing a function call relation in the code of the target application program; acquiring function call chain information of executed codes in the process of testing the target application program, wherein the function call chain information comprises a plurality of functions in the executed codes and call relations among the functions; generating a branch relation diagram of the executed code according to the function call chain information of the executed code, wherein the branch relation diagram comprises a plurality of branches, and each branch is used for representing the function call relation in the executed code; and determining code branch coverage conditions of the target application program in the test process according to the branch relation diagram of the executed code and the logic grammar tree.
According to an embodiment of the present disclosure, obtaining function call chain information of executed code includes: determining an entry function in code of the target application; mounting a instrumentation program on the entry function, so as to execute the instrumentation program simultaneously when determining to execute the entry function; and in the process of executing the code of the target application program, acquiring the function call chain information of the code in the process of executing through the instrumentation program.
According to an embodiment of the present disclosure, generating a branching relationship graph of the executed code according to function call chain information in the executed code includes: performing at least one of data deduplication, data cleaning and standardization treatment on the function call chain information to obtain the treated function call chain information; and integrating the plurality of functions in the processed function call chain information and the call relations among the functions to obtain a branch relation diagram of the executed code.
According to an embodiment of the present disclosure, determining a code branch coverage condition of the target application program in a test process according to the branch relation graph of the executed code and the logical syntax tree includes: and determining code branch coverage conditions of the target application program in the test process according to the mapping relation between branches in the branch relation diagram of the executed code and branches in the logic grammar tree.
According to an embodiment of the present disclosure, determining a code branch coverage condition of the target application in a test process according to a mapping relationship between branches in a branch relationship graph of the executed code and branches in the logical syntax tree includes: generating an overlaid branch list of the executed code according to the mapping relation between branches in the branch relation diagram of the executed code and branches in the logic grammar tree; and/or generating an uncovered branch list of the executed code according to the mapping relation between the branches in the branch relation diagram of the executed code and the branches in the logic grammar tree.
Another aspect of the present disclosure provides an apparatus for determining coverage of a code branch, including: a first determining module, configured to determine a logic syntax tree of a target application according to code logic of the target application, where the logic syntax tree includes a plurality of branches, and each branch is used to characterize a function call relationship in code of the target application; the acquisition module is used for acquiring function call chain information of the executed codes in the process of testing the target application program, wherein the function call chain information comprises a plurality of functions in the executed codes and call relations among the functions; the generation module is used for generating a branch relation diagram of the executed code according to the function call chain information of the executed code, wherein the branch relation diagram comprises a plurality of branches, and each branch is used for representing the function call relation in the executed code; and the second determining module is used for determining code branch coverage conditions of the target application program in the test process according to the branch relation diagram of the executed code and the logic grammar tree.
According to an embodiment of the present disclosure, the acquisition module includes: a determining unit configured to determine an entry function in a code of the target application program; the mounting unit is used for mounting the instrumentation program on the entry function so as to execute the instrumentation program simultaneously when the entry function is determined to be executed; and the acquisition unit is used for acquiring the function call chain information of the code in the execution process through the instrumentation program in the process of executing the code of the target application program.
According to an embodiment of the present disclosure, the generating module includes: the processing unit is used for carrying out at least one of data deduplication, data cleaning and standardization processing on the function call chain information to obtain the processed function call chain information; and the integration unit is used for integrating the plurality of functions in the processed function call chain information and the call relations among the functions to obtain the branch relation diagram of the executed code.
Another aspect of the present disclosure provides a computer-readable storage medium storing computer-executable instructions that, when executed, are configured to implement a method as described above.
Another aspect of the present disclosure provides a computer program comprising computer executable instructions which when executed are for implementing a method as described above.
Another aspect of the present disclosure provides a computer system comprising: one or more processors; and a storage means for storing one or more programs, which when executed by the one or more processors cause the one or more processors to implement the methods as described above.
According to the embodiment of the disclosure, a logic grammar tree of a target application program is determined according to code logic of the target application program, function call chain information in executed codes is obtained in the process of testing the target application program, a branch relation diagram of the executed codes is generated according to the function call chain information of the executed codes, and a technical means of code branch coverage condition of the target application program in the test process is determined according to the branch relation diagram of the executed codes and the logic grammar tree. The code branch coverage condition of the application program in the test process is determined according to the relation between the branch relation diagram of the executed code generated by the test process and the logic grammar tree generated by the original code, so that the control of the program branch calling condition in the test process can be realized, and the technical problem of program defects caused by the fact that the code branches cannot be covered by the test scene in the related technology is solved.
Drawings
The above and other objects, features and advantages of the present disclosure will become more apparent from the following description of embodiments thereof with reference to the accompanying drawings in which:
FIG. 1 schematically illustrates an exemplary system architecture of a method and apparatus for determining code finger coverage in which embodiments of the present disclosure may be applied;
FIG. 2 schematically illustrates a flow chart of a method of determining code finger coverage in accordance with an embodiment of the present disclosure;
FIG. 3 schematically illustrates a flow diagram of a method of obtaining function call chain information in executed code, according to an embodiment of the disclosure;
FIG. 4 schematically illustrates a flow chart of a method of generating a branch relationship graph of executed code according to an embodiment of the disclosure;
FIG. 5 schematically illustrates a block diagram of a determination apparatus of code finger coverage situation according to an embodiment of the present disclosure; and
fig. 6 schematically illustrates a block diagram of a computer system according to an embodiment of the disclosure.
Detailed Description
Hereinafter, embodiments of the present disclosure will be described with reference to the accompanying drawings. It should be understood that the description is only exemplary and is not intended to limit the scope of the present disclosure. In the following detailed description, for purposes of explanation, numerous specific details are set forth in order to provide a thorough understanding of the embodiments of the present disclosure. It may be evident, however, that one or more embodiments may be practiced without these specific details. In addition, in the following description, descriptions of well-known structures and techniques are omitted so as not to unnecessarily obscure the concepts of the present disclosure.
The terminology used herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the disclosure. The terms "comprises," "comprising," and/or the like, as used herein, specify the presence of stated features, steps, operations, and/or components, but do not preclude the presence or addition of one or more other features, steps, operations, or components.
All terms (including technical and scientific terms) used herein have the same meaning as commonly understood by one of ordinary skill in the art unless otherwise defined. It should be noted that the terms used herein should be construed to have meanings consistent with the context of the present specification and should not be construed in an idealized or overly formal manner.
Where expressions like at least one of "A, B and C, etc. are used, the expressions should generally be interpreted in accordance with the meaning as commonly understood by those skilled in the art (e.g.," a system having at least one of A, B and C "shall include, but not be limited to, a system having a alone, B alone, C alone, a and B together, a and C together, B and C together, and/or A, B, C together, etc.). Where a formulation similar to at least one of "A, B or C, etc." is used, in general such a formulation should be interpreted in accordance with the ordinary understanding of one skilled in the art (e.g. "a system with at least one of A, B or C" would include but not be limited to systems with a alone, B alone, C alone, a and B together, a and C together, B and C together, and/or A, B, C together, etc.).
The embodiment of the disclosure provides a method for determining code branch coverage condition, which comprises the following steps: determining a logic grammar tree of the target application program according to the code logic of the target application program, wherein the logic grammar tree comprises a plurality of branches, and each branch is used for representing a function call relation in the code of the target application program; acquiring function call chain information of executed codes in the process of testing a target application program, wherein the function call chain information comprises a plurality of functions in the executed codes and call relations among the functions; generating a branch relation diagram of the executed code according to the function call chain information in the executed code, wherein the branch relation diagram comprises a plurality of branches, and each branch is used for representing the call relation among functions in the executed code; and determining the code branch coverage condition of the target application program in the test process according to the branch relation diagram and the logic grammar tree of the executed code.
Fig. 1 schematically illustrates an exemplary system architecture 100 to which the methods and apparatus for determining code finger coverage of embodiments of the present disclosure may be applied. It should be noted that fig. 1 is only an example of a system architecture to which embodiments of the present disclosure may be applied to assist those skilled in the art in understanding the technical content of the present disclosure, but does not mean that embodiments of the present disclosure may not be used in other devices, systems, environments, or scenarios.
As shown in fig. 1, a system architecture 100 according to this embodiment may include an electronic device 101, a test server 102, and a code repository server 103.
The code repository server 103 may have stored therein the original code of the application under test, which may be compiled and then deployed into the test environment provided by the test server 102. The test environment may be, for example, an environment provided by a virtual machine running in the test server 102, into which the code of the application program is deployed, and the test may be performed.
The test environment provided by the test server 102 may be configured with a custom analysis program, for example, may be a instrumentation program, and execution of the instrumentation program may obtain stub point data of an application program in an execution process, where the stub point data may include, for example, a calling relationship between functions, an execution result of each function, and the like, and may obtain different stub point data according to needs. The acquired pile point data may then be transmitted to the electronic device 101.
After acquiring the pile point data sent by the test server 102, the electronic device 101 may analyze the pile point data to obtain test-related performance data. For example, stub data may include call relationships between various functions in the executed code, and a branch relationship graph of the executed code may be generated from the call relationships between the various functions.
The electronic device 101 may also obtain the original code of the application program from the code repository server 103, and then analyze the statements in the code to obtain a logic syntax tree, where each branch in the logic syntax tree may represent a function call relationship of the code.
The electronic device 101 analyzes the mapping relation between the branch relation diagram of the executed code generated by using the stub data and the logic grammar tree generated by using the original code of the application program, so as to obtain the code branch coverage condition of the application program in the test process, for example, the code branch coverage condition can comprise a covered branch list, an uncovered branch list and the like.
It should be understood that the number of electronic devices and servers in fig. 1 is merely illustrative. There may be any number of electronic devices and servers, as desired for implementation.
Fig. 2 schematically illustrates a flow chart of a method of determining code finger coverage in accordance with an embodiment of the present disclosure.
As shown in fig. 2, the method includes operations S201 to S204.
In operation S201, a logical syntax tree of a target application program is determined according to code logic of the target application program.
Wherein the logical syntax tree comprises a plurality of branches, each branch for characterizing a function call relationship in code of the target application.
According to an embodiment of the present disclosure, the target application may be an application to be tested. The electronic device 101 may also obtain the original code of the application to be tested from the code repository server 103, and then obtain a logical syntax tree by analyzing the statements in the code. Statement logic in code may be call relationships between functions, and thus, syntax trees may be used to characterize call relationships of functions in code. A branch may be formed between every two nodes in the syntax tree, each node may represent a function, and thus, a branch may be used to characterize the call relationship between the two functions.
For example, the code of the application program may include a function a, a function B, a function C, a function D, a function E, and the like, where the call relationship between the functions may include: function A may call function B, function A may call function C, function A may call function D, function B may call function E, etc. Branches in the syntax tree may include, according to call relationships between the respective functions: function a→function B, function a→function C, function a→function D, function b→function E, and so on.
In the process of testing the target application, function call chain information of the executed code is acquired in operation S202, wherein the function call chain information includes a plurality of functions in the executed code and call relationships between the functions.
According to an embodiment of the present disclosure, a parser may be configured in a test environment provided by the test server 102, to parse a code of an application into a bytecode, and a instrumentation program may be configured, and the instrumentation program may be installed on a key function of the application program, so that the instrumentation program is executed in parallel when the key function is executed, where the key function may be an entry function and/or an exit function.
According to the embodiment of the disclosure, the instrumentation program can acquire stub point data of the application program in the execution process, the stub point data can comprise, for example, calling relations among functions, execution results of each function and the like, and different stub point data can be acquired according to requirements. The acquired pile point data may then be transmitted to the electronic device 101.
According to an embodiment of the disclosure, along with the above example, the function a may be an entry function, and the instrumentation program may be installed on the function a, and when the function a is executed, the instrumentation program is executed with an addition, and during the execution, the instrumentation program may be configured to obtain a case where the function a invokes other functions during the execution. For example, it may be obtained that function a calls function B, function C, function D, etc. during execution, and function B calls function E during the process of calling function B. These call relations may be sent to the electronic device 101.
In operation S203, a branch relation graph of the executed code is generated according to the function call chain information of the executed code. Wherein the branch relationship graph includes a plurality of branches, each branch for characterizing a function call relationship in the executed code.
According to the embodiment of the disclosure, the electronic device 101 may acquire the stub data sent by the test server 102 and may include the call relations between the functions in the executed code, and integrating the call relations between the functions may generate the branch relation graph of the executed code according to the call relations between the functions.
In operation S204, a code branch coverage condition of the target application program in the test process is determined according to the branch relation diagram and the logic syntax tree of the executed code.
According to the embodiment of the disclosure, the electronic device 101 analyzes the mapping relationship between the branch relationship graph of the executed code generated by using the stub data and the logic syntax tree generated by using the original code of the application program, so as to obtain the code branch coverage condition of the application program in the test process.
For example, branches of a logical syntax tree may include function A→function B, function A→function C, function A→function D, function B→function E, and branches in a branch relationship diagram of executed code may include A→function B, function A→function C, function B→function E. It may be determined that covered branches include a→function B, function a→function C, function b→function E, and uncovered branches include function a→function D.
According to the embodiment of the disclosure, the code branch coverage situation can also be displayed in a tree diagram manner, for example, different colors can be used to respectively represent covered branches and uncovered branches in the tree diagram. The coverage condition of the code branches can be obtained more intuitively by the testers. The functional tester can review the test scene and codes by using the uncovered program branch list; project management personnel can quantitatively analyze project test progress by utilizing code branch coverage conditions; project quality control personnel can predict and evaluate project quality risks by using code branch coverage conditions.
According to the embodiment of the disclosure, a logic grammar tree of a target application program is determined according to code logic of the target application program, function call chain information in executed codes is obtained in the process of testing the target application program, a branch relation diagram of the executed codes is generated according to the function call chain information in the executed codes, and code branch coverage conditions of the target application program in the test process are determined according to the branch relation diagram of the executed codes and the logic grammar tree. According to the relation between the branch relation diagram of the executed code generated by the test process and the logic grammar tree generated by the original code, the code branch coverage condition of the application program in the test process is determined, so that the grasp of the program branch calling condition in the test process can be realized, and the program defect caused by the fact that the code branch cannot be covered by the test scene is avoided.
FIG. 3 schematically illustrates a flow chart of a method of obtaining function call chain information in executed code, according to an embodiment of the disclosure.
As shown in fig. 3, operation S202 includes operations S301 to S303.
In operation S301, an entry function in the code of the target application program is determined.
According to embodiments of the present disclosure, the target application may be loaded by a parser in test server 102, and the critical functions may be entry and/or exit functions of the program. For example, the function A can be piled up and down, and the instrumentation tool can be loaded into the application process by means of an additional process, so as to mount the key function A.
In operation S302, the instrumentation program is installed on the entry function to simultaneously execute the instrumentation program when it is determined to execute the entry function.
In operation S303, in the process of executing the code of the target application program, function call chain information of the code in the process of execution is acquired through the instrumentation program.
According to the embodiment of the disclosure, after the test process is started, a parser interface is used to add a custom analysis code when the mounted key function is executed during the loading of the byte code, so as to track and acquire the function execution condition and function call chain information of the tested application program.
FIG. 4 schematically illustrates a flow chart of a method of generating a branch relationship graph of executed code, according to an embodiment of the disclosure.
As shown in fig. 4, operation S203 includes operations S401 to S402.
In operation S401, at least one of data deduplication, data cleansing, and normalization processing is performed on function call chain information, resulting in processed function call chain information.
In operation S402, a plurality of functions in the processed function call chain information and call relations among the functions are integrated, and a branching relation diagram of the executed code is obtained.
According to the embodiment of the disclosure, the collected information is subjected to de-duplication, cleaning, standardization processing and the like in real time, and the data can be packaged into a standardized protocol and sent to the electronic device 101. The electronic device 101 may perform an integrated analysis on function call chain data of the same application under test in a specified test period to generate an executed code branch relation graph.
Fig. 5 schematically shows a block diagram of a determination apparatus of code finger coverage situation according to an embodiment of the present disclosure.
As shown in fig. 5, the determining apparatus 500 for code branch coverage situations includes a first determining module 501, an acquiring module 502, a generating module 503, and a second determining module 504.
The first determining module 501 is configured to determine a logic syntax tree of the target application program according to code logic of the target application program, where the logic syntax tree includes a plurality of branches, and each branch is used to characterize a function call relationship in code of the target application program.
The obtaining module 502 is configured to obtain function call chain information of the executed code during a process of testing the target application program, where the function call chain information includes a plurality of functions in the executed code and call relationships between the functions.
The generating module 503 is configured to generate a branch relation graph of the executed code according to the function call chain information of the executed code, where the branch relation graph includes a plurality of branches, and each branch is used to characterize a function call relation in the executed code.
The second determining module 504 is configured to determine a code branch coverage condition of the target application program in the testing process according to the branch relation diagram and the logic syntax tree of the executed code.
According to an embodiment of the present disclosure, the acquisition module 502 includes a determination unit, a mounting unit, and an acquisition unit.
The determining unit is used for determining an entry function in the code of the target application program.
The mounting unit is used for mounting the instrumentation program on the entry function so as to execute the instrumentation program simultaneously when the entry function is determined to be executed.
The acquisition unit is used for acquiring the function call chain information of the code in the execution process through the instrumentation program in the process of executing the code of the target application program.
According to an embodiment of the present disclosure, the acquisition module 502 includes a processing unit and an integration unit.
The processing unit is used for carrying out at least one of data deduplication, data cleaning and standardization processing on the function call chain information to obtain the processed function call chain information.
The integrating unit is used for integrating a plurality of functions in the processed function call chain information and call relations among the functions to obtain a branch relation diagram of the executed code.
According to the embodiment of the disclosure, the second determining module 504 is configured to determine a code branch coverage situation of the target application program in the test process according to a mapping relationship between branches in the branch relation graph of the executed code and branches in the logic syntax tree.
The second determination module 504 includes a first generation unit and a second generation unit.
The first generating unit is used for generating an overlaid branch list of the executed code according to the mapping relation between the branches in the branch relation diagram of the executed code and the branches in the logic grammar tree.
The second generating unit is used for generating an uncovered branch list of the executed code according to the mapping relation between the branches in the branch relation diagram of the executed code and the branches in the logic grammar tree.
It should be noted that, the method and the device for determining the coverage situation of the code branch provided by the embodiment of the present disclosure may be used for determining the coverage situation of the code branch in the software testing process in the financial field, and may also be used for determining the coverage situation of the code branch in the software testing process in any field other than the financial field.
Any number of modules, sub-modules, units, sub-units, or at least some of the functionality of any number of the sub-units according to embodiments of the present disclosure may be implemented in one module. Any one or more of the modules, sub-modules, units, sub-units according to embodiments of the present disclosure may be implemented as split into multiple modules. Any one or more of the modules, sub-modules, units, sub-units according to embodiments of the present disclosure may be implemented at least in part as a hardware circuit, such as a Field Programmable Gate Array (FPGA), a Programmable Logic Array (PLA), a system-on-chip, a system-on-substrate, a system-on-package, an Application Specific Integrated Circuit (ASIC), or in any other reasonable manner of hardware or firmware that integrates or encapsulates the circuit, or in any one of or a suitable combination of three of software, hardware, and firmware. Alternatively, one or more of the modules, sub-modules, units, sub-units according to embodiments of the present disclosure may be at least partially implemented as computer program modules, which when executed, may perform the corresponding functions.
For example, any of the first determination module 501, the acquisition module 502, the generation module 503, and the second determination module 504 may be combined in one module/unit/sub-unit, or any of them may be split into a plurality of modules/units/sub-units. Alternatively, at least some of the functionality of one or more of these modules/units/sub-units may be combined with at least some of the functionality of other modules/units/sub-units and implemented in one module/unit/sub-unit. According to embodiments of the present disclosure, at least one of the first determination module 501, the acquisition module 502, the generation module 503, and the second determination module 504 may be implemented at least in part as hardware circuitry, such as a Field Programmable Gate Array (FPGA), a Programmable Logic Array (PLA), a system on a chip, a system on a substrate, a system on a package, an Application Specific Integrated Circuit (ASIC), or may be implemented in hardware or firmware in any other reasonable way of integrating or packaging circuitry, or in any one of or a suitable combination of three of software, hardware, and firmware. Alternatively, at least one of the first determination module 501, the acquisition module 502, the generation module 503 and the second determination module 504 may be at least partially implemented as computer program modules, which when run may perform the respective functions.
It should be noted that, the determining device portion of the code branch coverage situation in the embodiment of the present disclosure corresponds to the determining method portion of the code branch coverage situation in the embodiment of the present disclosure, and the description of the determining device portion of the code branch coverage situation specifically refers to the determining method portion of the code branch coverage situation, which is not described herein.
Fig. 6 schematically illustrates a block diagram of a computer system suitable for implementing the above-described method according to an embodiment of the present disclosure. The computer system illustrated in fig. 6 is merely an example and should not be construed as limiting the functionality and scope of use of the embodiments of the present disclosure.
As shown in fig. 6, a computer system 600 according to an embodiment of the present disclosure includes a processor 601 that can perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM) 602 or a program loaded from a storage section 608 into a Random Access Memory (RAM) 603. The processor 601 may include, for example, a general purpose microprocessor (e.g., a CPU), an instruction set processor and/or an associated chipset and/or a special purpose microprocessor (e.g., an Application Specific Integrated Circuit (ASIC)), or the like. Processor 601 may also include on-board memory for caching purposes. The processor 601 may comprise a single processing unit or a plurality of processing units for performing different actions of the method flows according to embodiments of the disclosure.
In the RAM 603, various programs and data required for the operation of the system 600 are stored. The processor 601, the ROM 602, and the RAM 603 are connected to each other through a bus 604. The processor 601 performs various operations of the method flow according to the embodiments of the present disclosure by executing programs in the ROM 602 and/or the RAM 603. Note that the program may be stored in one or more memories other than the ROM 602 and the RAM 603. The processor 601 may also perform various operations of the method flow according to embodiments of the present disclosure by executing programs stored in the one or more memories.
According to an embodiment of the present disclosure, the system 600 may further include an input/output (I/O) interface 605, the input/output (I/O) interface 605 also being connected to the bus 604. The system 600 may also include one or more of the following components connected to the I/O interface 605: an input portion 606 including a keyboard, mouse, etc.; an output portion 607 including a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, a speaker, and the like; a storage section 608 including a hard disk and the like; and a communication section 609 including a network interface card such as a LAN card, a modem, or the like. The communication section 609 performs communication processing via a network such as the internet. The drive 610 is also connected to the I/O interface 605 as needed. Removable media 611 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is installed as needed on drive 610 so that a computer program read therefrom is installed as needed into storage section 608.
According to embodiments of the present disclosure, the method flow according to embodiments of the present disclosure may be implemented as a computer software program. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable storage medium, the computer program comprising program code for performing the method shown in the flowcharts. In such an embodiment, the computer program may be downloaded and installed from a network through the communication portion 609, and/or installed from the removable medium 611. The above-described functions defined in the system of the embodiments of the present disclosure are performed when the computer program is executed by the processor 601. The systems, devices, apparatus, modules, units, etc. described above may be implemented by computer program modules according to embodiments of the disclosure.
The present disclosure also provides a computer-readable storage medium that may be embodied in the apparatus/device/system described in the above embodiments; or may exist alone without being assembled into the apparatus/device/system. The computer-readable storage medium carries one or more programs which, when executed, implement methods in accordance with embodiments of the present disclosure.
According to embodiments of the present disclosure, the computer-readable storage medium may be a non-volatile computer-readable storage medium. Examples may include, but are not limited to: a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the context of this disclosure, a computer-readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device.
For example, according to embodiments of the present disclosure, the computer-readable storage medium may include ROM 602 and/or RAM 603 and/or one or more memories other than ROM 602 and RAM 603 described above.
The flowcharts and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams or flowchart illustration, and combinations of blocks in the block diagrams or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions. Those skilled in the art will appreciate that the features recited in the various embodiments of the disclosure and/or in the claims may be combined in various combinations and/or combinations, even if such combinations or combinations are not explicitly recited in the disclosure. In particular, the features recited in the various embodiments of the present disclosure and/or the claims may be variously combined and/or combined without departing from the spirit and teachings of the present disclosure. All such combinations and/or combinations fall within the scope of the present disclosure.
The embodiments of the present disclosure are described above. However, these examples are for illustrative purposes only and are not intended to limit the scope of the present disclosure. Although the embodiments are described above separately, this does not mean that the measures in the embodiments cannot be used advantageously in combination. The scope of the disclosure is defined by the appended claims and equivalents thereof. Various alternatives and modifications can be made by those skilled in the art without departing from the scope of the disclosure, and such alternatives and modifications are intended to fall within the scope of the disclosure.

Claims (7)

1. A method for determining code branch coverage condition includes:
determining a logic grammar tree of a target application program according to code logic of the target application program, wherein the logic grammar tree comprises a plurality of branches, and each branch is used for representing a function call relation in the code of the target application program;
in the process of testing the target application program, acquiring function call chain information of the executed code, wherein the function call chain information comprises a plurality of functions in the executed code and call relations among the functions, and,
acquiring function call chain information of executed codes comprises:
determining an entry function in code of the target application;
mounting a instrumentation program on the entry function, so as to execute the instrumentation program simultaneously when determining to execute the entry function; and
in the process of executing the code of the target application program, adding a self-defined analysis code through a parser interface when the byte code is loaded or when the mounted key function is executed, and acquiring the function execution condition and function call chain information of the code in the executing process;
generating a branch relation graph of the executed code according to the function call chain information of the executed code, wherein generating the branch relation graph of the executed code according to the function call chain information of the executed code comprises:
performing at least one of data deduplication, data cleaning and standardization treatment on the function call chain information to obtain the treated function call chain information; and
integrating the plurality of functions in the processed function call chain information and the call relations among the functions to obtain a branch relation diagram of the executed code; the branch relation graph comprises a plurality of branches, each branch is used for representing a function call relation in the executed code; and
and determining code branch coverage conditions of the target application program in the test process according to the branch relation diagram of the executed codes and the logic grammar tree.
2. The method of claim 1, wherein determining code branch coverage of the target application during testing from the branch relation graph of the executed code and the logical syntax tree comprises:
and determining code branch coverage conditions of the target application program in the test process according to the mapping relation between branches in the branch relation diagram of the executed code and branches in the logic grammar tree.
3. The method of claim 2, wherein determining code branch coverage of the target application during testing based on a mapping relationship between branches in the branch relationship graph of the executed code and branches in the logical syntax tree comprises:
generating an overlaid branch list of the executed code according to the mapping relation between branches in the branch relation diagram of the executed code and branches in the logic grammar tree; and/or
And generating an uncovered branch list of the executed code according to the mapping relation between the branches in the branch relation diagram of the executed code and the branches in the logic grammar tree.
4. A code finger coverage condition determining apparatus, comprising:
a first determining module, configured to determine a logic syntax tree of a target application according to code logic of the target application, where the logic syntax tree includes a plurality of branches, and each branch is used to characterize a function call relationship in code of the target application;
an acquisition module for acquiring function call chain information of the executed code in the process of testing the target application program, wherein the function call chain information comprises a plurality of functions in the executed code and call relations among the functions,
acquiring function call chain information of executed codes comprises:
determining an entry function in code of the target application;
mounting a instrumentation program on the entry function, so as to execute the instrumentation program simultaneously when determining to execute the entry function; and
in the process of executing the code of the target application program, adding a self-defined analysis code through a parser interface when the byte code is loaded or when the mounted key function is executed, and acquiring the function execution condition and function call chain information of the code in the executing process;
the generation module is used for generating a branch relation diagram of the executed code according to the function call chain information of the executed code, wherein the generation module comprises:
the processing unit is used for carrying out at least one of data deduplication, data cleaning and standardization processing on the function call chain information to obtain the processed function call chain information; and
the integrating unit is used for integrating the plurality of functions in the processed function call chain information and the call relations among the functions to obtain a branch relation diagram of the executed code; the branch relation graph comprises a plurality of branches, each branch is used for representing a function call relation in the executed code; and
and the second determining module is used for determining code branch coverage conditions of the target application program in the test process according to the branch relation diagram of the executed code and the logic grammar tree.
5. The apparatus of claim 4, wherein the acquisition module comprises:
a determining unit configured to determine an entry function in a code of the target application program;
the mounting unit is used for mounting the instrumentation program on the entry function so as to execute the instrumentation program simultaneously when the entry function is determined to be executed; and
and the acquisition unit is used for acquiring the function call chain information of the code in the execution process through the instrumentation program in the process of executing the code of the target application program.
6. A computer system, comprising:
one or more processors;
a memory for storing one or more programs,
wherein the one or more programs, when executed by the one or more processors, cause the one or more processors to implement the method of any of claims 1-3.
7. A computer readable storage medium having stored thereon executable instructions which when executed by a processor cause the processor to implement the method of any of claims 1 to 3.
CN202010734322.4A 2020-07-27 2020-07-27 Method, device, computer system and medium for determining code branch coverage condition Active CN111831573B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010734322.4A CN111831573B (en) 2020-07-27 2020-07-27 Method, device, computer system and medium for determining code branch coverage condition

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010734322.4A CN111831573B (en) 2020-07-27 2020-07-27 Method, device, computer system and medium for determining code branch coverage condition

Publications (2)

Publication Number Publication Date
CN111831573A CN111831573A (en) 2020-10-27
CN111831573B true CN111831573B (en) 2024-03-08

Family

ID=72926543

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010734322.4A Active CN111831573B (en) 2020-07-27 2020-07-27 Method, device, computer system and medium for determining code branch coverage condition

Country Status (1)

Country Link
CN (1) CN111831573B (en)

Families Citing this family (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112559343B (en) * 2020-12-11 2022-11-15 腾讯科技(深圳)有限公司 Test path generation method and related equipment
CN112783786B (en) * 2021-02-01 2024-02-09 中国工商银行股份有限公司 Method, apparatus, device, medium and program product for generating test cases
CN113032254B (en) * 2021-03-19 2024-05-31 中国工商银行股份有限公司 Test coverage condition evaluation method and device
CN113051173B (en) * 2021-04-13 2024-04-19 广州虎牙科技有限公司 Method, device, computer equipment and storage medium for arranging and executing test flow
CN113127362A (en) * 2021-04-23 2021-07-16 中国工商银行股份有限公司 Object testing method, object testing device, electronic device, and readable storage medium
CN113448850A (en) * 2021-06-29 2021-09-28 平安健康保险股份有限公司 Method, system, device and medium for visualizing a chain of method calls

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107797923A (en) * 2017-10-10 2018-03-13 平安科技(深圳)有限公司 Code coverage rate analysis method and application server
CN109271322A (en) * 2018-09-25 2019-01-25 杭州群核信息技术有限公司 A kind of software test range determining method, method for testing software and device
CN110389764A (en) * 2019-06-19 2019-10-29 平安普惠企业管理有限公司 Dead code method for cleaning, equipment, storage medium and device

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7849509B2 (en) * 2005-10-07 2010-12-07 Microsoft Corporation Detection of security vulnerabilities in computer programs

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107797923A (en) * 2017-10-10 2018-03-13 平安科技(深圳)有限公司 Code coverage rate analysis method and application server
CN109271322A (en) * 2018-09-25 2019-01-25 杭州群核信息技术有限公司 A kind of software test range determining method, method for testing software and device
CN110389764A (en) * 2019-06-19 2019-10-29 平安普惠企业管理有限公司 Dead code method for cleaning, equipment, storage medium and device

Also Published As

Publication number Publication date
CN111831573A (en) 2020-10-27

Similar Documents

Publication Publication Date Title
CN111831573B (en) Method, device, computer system and medium for determining code branch coverage condition
US8510842B2 (en) Pinpointing security vulnerabilities in computer software applications
US8386851B2 (en) Functional coverage using combinatorial test design
US8776029B2 (en) System and method of software execution path identification
US20190317882A1 (en) Method and apparatus for testing a code file
US20080244536A1 (en) Evaluating static analysis results using code instrumentation
US20120054553A1 (en) Fault localization using condition modeling and return value modeling
US9952965B2 (en) Test self-verification with integrated transparent self-diagnose
CN110532185B (en) Test method, test device, electronic equipment and computer readable storage medium
US20130054923A1 (en) Automatic memory leak detection
CN111290941A (en) Method and device for testing multiple interfaces, computing equipment and medium
CN110704303B (en) Method and device for acquiring test coverage information
Brunet et al. Structural conformance checking with design tests: An evaluation of usability and scalability
US9015012B2 (en) Completion of partial coverage tasks
WO2011089478A1 (en) Debugger system, method and computer program product for debugging instructions
CN109902001B (en) Method for detecting uninitialized variable and terminal equipment
US9841960B2 (en) Dynamic provision of debuggable program code
CN115858393A (en) Software test range evaluation method and system based on call chain
CN113392033B (en) Method and device for determining passive IAST test API coverage rate
US11880470B2 (en) System and method for vulnerability detection in computer code
CN115373929A (en) Test method, device, equipment, readable storage medium and program product
US8458523B2 (en) Meta attributes in functional coverage models
US20220164277A1 (en) Analysis and Testing of Embedded Code
Lu et al. Spectrum-base fault localization by exploiting the failure path
CN113127364A (en) Performance test method and device, electronic equipment and storage medium

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
GR01 Patent grant
GR01 Patent grant