CN117909152A - Interface downward compatibility detection method, system, computer and storage medium - Google Patents

Interface downward compatibility detection method, system, computer and storage medium Download PDF

Info

Publication number
CN117909152A
CN117909152A CN202311861747.1A CN202311861747A CN117909152A CN 117909152 A CN117909152 A CN 117909152A CN 202311861747 A CN202311861747 A CN 202311861747A CN 117909152 A CN117909152 A CN 117909152A
Authority
CN
China
Prior art keywords
interface
information
class information
standard
function
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
CN202311861747.1A
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.)
Jiangxi Booway New Technology Co ltd
Original Assignee
Jiangxi Booway New Technology 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 Jiangxi Booway New Technology Co ltd filed Critical Jiangxi Booway New Technology Co ltd
Priority to CN202311861747.1A priority Critical patent/CN117909152A/en
Publication of CN117909152A publication Critical patent/CN117909152A/en
Pending legal-status Critical Current

Links

Landscapes

  • Stored Programmes (AREA)

Abstract

The invention provides a method, a system, a computer and a storage medium for detecting downward compatibility of an interface, wherein the method comprises the following steps: analyzing the text file from the interface, and extracting interface class information corresponding to the text file; storing the interface type information into a lightweight database; and comparing and detecting interface type information in the lightweight database with standard information based on the compatibility detection rule to generate a compatibility detection report. The text file from the interface is analyzed to obtain interface class information corresponding to the text file, meanwhile, a comparison library comprising standard information is generated based on the standard interface file, and a compatibility detection rule is defined, so that the change of the interface information in the development process is directly monitored based on the compatibility detection rule, the problem of interface compatibility can be pointed out in detail, developers can be helped to solve the problem of compatibility quickly and conveniently, and the software fault tolerance is greatly improved.

Description

Interface downward compatibility detection method, system, computer and storage medium
Technical Field
The present invention relates to the field of compatibility detection technologies, and in particular, to a method, a system, a computer, and a storage medium for detecting downward compatibility of an interface.
Background
Backward compatibility is also known as backward compatibility, and refers to the fact that a piece of software may run programs written in a lower version in a higher version environment. If in the process of developing the c++ software, an interface class a exists, the class a provides function interfaces FunA and FunB outwards, if the new version of interface class loses the function interface FunA for some reasons, and thus the software cannot normally run, the interface is not compatible, otherwise, a new function interface FunC is added at the end of the class a, and although the interface file structure is different, the software still runs normally, and the interface is said to be downward compatible.
In the prior art, a common detection method for the downward compatibility of the c++ interface is to check the external link function information of each DLL by means of depends tools. And finding out incompatible points by comparing DLL information structures of different versions, thereby ensuring the compatibility of the interface. The method can ensure that the C++ interface is downward compatible, but the information is single and only an incompatible interface can be definitely determined, but the specific reasons are not detailed, the positions of the interfaces are not detailed, the method is excessively dependent on the working experience of developers, the time and the labor are consumed for defining specific incompatibility problems, and meanwhile, the compatibility of class member variables, the compatibility of non-derived classes and callback class compatibility cannot be detected.
Disclosure of Invention
Aiming at the defects of the prior art, the invention aims to provide an interface downward compatibility detection method, an interface downward compatibility detection system, a computer and a storage medium, and aims to solve the technical problems of single detection effect information and poor detection effect of the compatibility detection method in the prior art.
In order to achieve the above object, the present invention is achieved by the following technical scheme: an interface downward compatibility detection method comprises the following steps:
analyzing a text file from an interface, and converting text information corresponding to the text file into a grammar analysis tree;
Performing semantic analysis on the syntax analysis tree, and traversing the syntax analysis tree in a cursor traversing mode to extract interface class information corresponding to the text file;
Storing the interface type information into a Sqlite lightweight database;
generating a comparison library comprising standard information based on the standard interface file, and defining a compatibility detection rule;
And based on the compatibility detection rule, comparing and detecting interface type information in the Sqlite lightweight database with standard information in the comparison library to generate a compatibility detection report.
According to an aspect of the above technical solution, the step of converting text information corresponding to the text file into the parse tree specifically includes:
converting the C++ code text corresponding to the text file into a code element sequence based on a lexical analyzer;
the sequence of code elements is converted to a parse tree based on a parser.
According to an aspect of the above technical solution, the steps of performing semantic analysis on the parse tree and traversing the parse tree by using a cursor traversal manner to extract interface class information corresponding to the text file specifically include:
and performing access detection on each node information in the syntax analysis tree by adopting a cursor, and acquiring corresponding interface class information based on the node type of the node information, wherein the interface class information comprises non-derived interface class information, derived interface class information and callback class information.
According to an aspect of the foregoing technical solution, the step of defining the compatibility detection rule specifically includes:
for the non-derived interface class information, the following rules are satisfied with respect to the standard information: no member variables exist, the original function is not allowed to be deleted or modified, and the function can only be added backwards;
for the derived interface class information, the following rules are satisfied with respect to the standard information: the member variables have d/q pointer variables only, have derived interface functions only, do not allow the original functions to be deleted or modified, and the functions can only be added backwards;
For the callback class information, the following rules are satisfied with respect to the standard information: there are no member variables and the callback class function contains only function pointers as parameters.
According to an aspect of the foregoing technical solution, the step of comparing and detecting interface class information in the Sqlite lightweight database with standard information in the comparison library specifically includes:
Obtaining standard non-derived class information corresponding to the non-derived class information in the standard information;
Traversing the non-derived class information, and judging whether member variables exist between the non-derived class information and the standard non-derived class information based on the standard non-derived class information;
And traversing the member functions in the non-derived class information and the standard non-derived class information, judging whether a new function or a deleted function exists between the member functions, and judging whether function modification exists.
According to an aspect of the foregoing technical solution, the step of comparing and detecting interface class information in the Sqlite lightweight database with standard information in the comparison library specifically includes:
Obtaining standard export class information corresponding to the export class information in the standard information;
Traversing the derived class information, screening member variables based on the standard non-derived class information, and judging whether the type of the member variables is d/q pointer type;
And traversing the derived class information and the member function in the standard derived class information, and judging whether the function is a public or protection type function, whether a new function or a deleted function exists or not, and whether the function is modified or not.
According to an aspect of the foregoing technical solution, the step of comparing and detecting interface class information in the Sqlite lightweight database with standard information in the comparison library specifically includes:
Obtaining standard callback class information corresponding to the callback class information in the standard information;
Traversing the callback class information, and judging whether member variables exist between the callback class information and the standard callback class information based on the standard callback class information;
And traversing the member functions in the callback class information, and judging whether only function pointers are contained as parameters.
In a second aspect, an embodiment of the present application provides an interface downward compatibility detection system, including:
The analysis module is used for analyzing the text file from the interface and converting text information corresponding to the text file into a grammar analysis tree;
The extraction module is used for carrying out semantic analysis on the syntax analysis tree and traversing the syntax analysis tree in a cursor traversing mode so as to extract interface class information corresponding to the text file;
The storage module is used for storing the interface type information into a Sqlite light-weight database;
The standard module is used for generating a comparison library comprising standard information based on a standard interface file and defining a compatibility detection rule;
And the comparison module is used for comparing and detecting the interface type information in the Sqlite lightweight database with the standard information in the comparison library based on the compatibility detection rule so as to generate a compatibility detection report.
According to an aspect of the foregoing technical solution, the parsing module is specifically configured to:
converting the C++ code text corresponding to the text file into a code element sequence based on a lexical analyzer;
the sequence of code elements is converted to a parse tree based on a parser.
According to an aspect of the foregoing technical solution, the extraction module is specifically configured to:
and performing access detection on each node information in the syntax analysis tree by adopting a cursor, and acquiring corresponding interface class information based on the node type of the node information, wherein the interface class information comprises non-derived interface class information, derived interface class information and callback class information.
According to an aspect of the foregoing technical solution, the standard module is specifically configured to:
for the non-derived interface class information, the following rules are satisfied with respect to the standard information: no member variables exist, the original function is not allowed to be deleted or modified, and the function can only be added backwards;
for the derived interface class information, the following rules are satisfied with respect to the standard information: the member variables have d/q pointer variables only, have derived interface functions only, do not allow the original functions to be deleted or modified, and the functions can only be added backwards;
For the callback class information, the following rules are satisfied with respect to the standard information: there are no member variables and the callback class function contains only function pointers as parameters.
According to an aspect of the above technical solution, the comparison module is specifically configured to:
Obtaining standard non-derived class information corresponding to the non-derived class information in the standard information;
Traversing the non-derived class information, and judging whether member variables exist between the non-derived class information and the standard non-derived class information based on the standard non-derived class information;
And traversing the member functions in the non-derived class information and the standard non-derived class information, judging whether a new function or a deleted function exists between the member functions, and judging whether function modification exists.
According to an aspect of the foregoing technical solution, the comparison module is further configured to:
Obtaining standard export class information corresponding to the export class information in the standard information;
Traversing the derived class information, screening member variables based on the standard non-derived class information, and judging whether the type of the member variables is d/q pointer type;
And traversing the derived class information and the member function in the standard derived class information, and judging whether the function is a public or protection type function, whether a new function or a deleted function exists or not, and whether the function is modified or not.
According to an aspect of the foregoing technical solution, the comparison module is further configured to:
Obtaining standard callback class information corresponding to the callback class information in the standard information;
Traversing the callback class information, and judging whether member variables exist between the callback class information and the standard callback class information based on the standard callback class information;
And traversing the member functions in the callback class information, and judging whether only function pointers are contained as parameters.
In a third aspect, an embodiment of the present application provides a computer, including a memory, a processor, and a computer program stored on the memory and executable on the processor, where the processor implements an interface downward compatibility detection method according to the first aspect when the processor executes the computer program.
In a fourth aspect, an embodiment of the present application provides a storage medium having stored thereon a computer program which, when executed by a processor, implements an interface downward compatibility detection method as described in the first aspect.
Compared with the prior art, the invention has the beneficial effects that: the text file from the interface is analyzed to obtain interface class information corresponding to the text file, meanwhile, a comparison library comprising standard information is generated based on the standard interface file, and a compatibility detection rule is defined, so that the change of the interface information in the development process is directly monitored based on the compatibility detection rule, the problem of interface compatibility can be pointed out in detail, developers can be helped to solve the problem of compatibility quickly and conveniently, and the software fault tolerance is greatly improved.
Drawings
FIG. 1 is a flow chart of a method for detecting interface downward compatibility in a first embodiment of the present invention;
FIG. 2 is a diagram showing the structure of interface class information according to the first embodiment of the present invention;
FIG. 3 is a schematic diagram of a compatibility detection rule according to a first embodiment of the present invention;
FIG. 4 is a diagram illustrating a compatibility testing report according to a first embodiment of the present invention;
FIG. 5 is a block diagram of an interface downward compatibility detection system according to a second embodiment of the present invention;
FIG. 6 is a schematic diagram of a hardware configuration of a computer according to a third embodiment of the present invention;
The invention will be further described in the following detailed description in conjunction with the above-described figures.
Detailed Description
In order that the invention may be readily understood, a more complete description of the invention will be rendered by reference to the appended drawings. Several embodiments of the invention are presented in the figures. This invention may, however, be embodied in many different forms and should not be construed as limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete.
It will be understood that when an element is referred to as being "mounted" on another element, it can be directly on the other element or intervening elements may also be present. When an element is referred to as being "connected" to another element, it can be directly connected to the other element or intervening elements may also be present. The terms "vertical," "horizontal," "left," "right," and the like are used herein for illustrative purposes only.
Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention belongs. The terminology used herein in the description of the invention is for the purpose of describing particular embodiments only and is not intended to be limiting of the invention. The term "and/or" as used herein includes any and all combinations of one or more of the associated listed items.
Referring to fig. 1 to 2, an interface downward compatibility detection method in a first embodiment of the present invention includes the following steps:
And step S100, analyzing the text file from the interface, and converting text information corresponding to the text file into a grammar analysis tree.
Preferably, in this embodiment, the step S100 specifically includes:
And step S110, converting the C++ code text corresponding to the text file into a code element sequence based on a lexical analyzer. Conveniently, a lexical analyzer is used to convert the c++ code text into objects in order to convert the files into a data structure that is convenient to access. The lexical analysis inputs an interface file (. H or. Hpp), and outputs a group of Token, i.e. a sequence of code elements, which is a code element corresponding to a keyword, identifier, constant, operator, etc. in the interface file.
Step S120, converting the code element sequence into a parse tree based on a parser. Conveniently, token group data is converted into a parse tree (AST) using a parse analyzer. The Token sequence is organized into a tree-like data structure according to the grammar rules of the context-free grammar description language by individual words without grammatical significance. Each node represents a grammatical structure, such as an expression, statement, function, etc.
And step 200, performing semantic analysis on the syntax analysis tree, and traversing the syntax analysis tree in a cursor traversing mode to extract interface class information corresponding to the text file. Specifically, in this step, the semantic analysis is a process of performing static semantic checking on the source code. Traversing AST grammar tree, detecting semantic errors of declaration, function declaration and type matching of member variables. If the coding grammar does not accord with the C++ coding specification, corresponding error information is generated. Furthermore, the AST grammar tree is traversed by adopting a cursor traversing mode, and interface type information is extracted. The cursor (Cursors) is an indicator to indicate AST nodes, traversing the syntax tree by moving the cursor. Cursors can have a parent Cursors and a child Cursors, each cursor being labeled with a node type, such as a structure type (CXCursor _ StructDecl), a class type (CXCursor _ CLASSDECL), an enumeration type (CXCursor _ EnumDecl). And extracting interface class information, tracing the class type cursors to the corresponding data nodes, and converting the node information into class information. Conveniently, the extracted class type structure, i.e. the class information structure schematic diagram, is shown in fig. 2.
And step S300, storing the interface type information into a Sqlite lightweight database.
Step S400, generating an alignment library comprising standard information based on the standard interface file, and defining a compatibility detection rule.
Specifically, in the present embodiment, compatibility detection rules are defined, which are strictly executed according to the rules to ensure that the interfaces are downward compatible. The content is explicitly detected according to the reason of compatibility generation, and the compatibility detection rule is shown in fig. 3.
As shown in fig. 3, the step S400 specifically includes:
Step S410, for the non-derived interface class information, the following rules are satisfied with respect to the standard information: there are no member variables, the original function is not allowed to be deleted or modified, and the function can only be appended. The contract cannot have member variables, and compatibility can be ensured.
Step S420, for the derived interface class information, the following rules are satisfied with respect to the standard information: the member variables have and only can have d/q pointer variables, have and only export interface functions, do not allow deleting or modifying original functions, and the functions can only be added back.
Step S430, for the callback information, the following rules are satisfied with respect to the standard information: there are no member variables and the callback class function contains only function pointers as parameters. The contract cannot have member variables, and compatibility can be ensured. The function pointer supports std:: function and custom function pointer.
And step S500, based on the compatibility detection rule, comparing and detecting interface type information in the Sqlite lightweight database with standard information in the comparison library to generate a compatibility detection report. Specifically, in the present embodiment, the compatibility detection report is generated by comparing the interface information in the version database. According to the steps, the version library file is generated for each version of the interface file. The compatibility detection is to compare two version library files, so before the compatibility detection is performed, a standard interface file and a file (local and three-party library files) on which the standard file depends are defined, and then a standard version library is generated as a comparison library.
Preferably, in this embodiment, the step S500 specifically includes:
step S511, obtaining standard non-export class information corresponding to the non-export class information in the standard information;
Step S512, traversing the non-derived class information, and judging whether member variables exist between the non-derived class information and the standard non-derived class information;
Step S513, traversing the member functions in the non-derived class information and the standard non-derived class information, and judging whether there is a new function or a deleted function between them, and whether there is a function modification.
Specifically, in some application scenarios of the present embodiment, for detection of non-derived class information, specific detection content includes the following steps:
1. And analyzing the current version and the standard version library file to obtain all non-export class data.
2. Traversing the non-derived class of the current version, judging whether member variables exist in the class, and recording errors if the member variables exist.
3. And traversing the non-derived class of the current and standard version, and retrieving a class member function information list. Step-by-step comparison function information after retrieval is completed:
3.1. comparing functions, judging whether a new function is added or deleted, and if so, recording the new function adding or deleting error.
3.2. Comparing the functions, judging whether modified functions (including modified function parameters, return value types, function names, function types and the like) exist, and if so, recording that the functions have modified errors.
Preferably, in this embodiment, the step S500 specifically further includes:
step S521, obtaining standard export class information corresponding to the export class information in the standard information;
Step S522, traversing the derived class information, screening member variables based on the standard non-derived class information, and judging whether the type of the member variables is d/q pointer type;
Step S523, traversing the derived class information and the member function in the standard derived class information, and judging whether the derived class information and the member function are public or protection type functions, whether new functions or deleted functions exist, and whether function modification exists.
Specifically, in some application scenarios of the present embodiment, for the detection of the derived class information, the specific detection content includes the following steps:
1. And analyzing the current version and the standard version library file to obtain all the exported class data.
2. Traversing the derived class of the current version, searching class member variables, judging whether the member variables are of d/q pointer types or not, and judging the basis as follows:
a. it is determined whether the type of the class member variable is a class pointer type.
B. and judging whether the name of the member variable is equal to the name of the class + 'Private' mark.
3. And traversing the current and standard version derived classes, and retrieving the function information list. And after the search is completed, comparing the function information in three steps:
3.1. And judging whether the function list of the current version is a public or protection type function. If the private type function is the private type function, the export interface is prompted to not allow the private interface warning to be provided.
3.2. Judging whether a new function or a deletion function exists, and if so, recording the new function or the deletion function error.
3.3. Whether a modified function (including modified function parameters, return value types, function names, function types, etc.) exists or not is judged, and if the modified function is changed, the record function is modified by errors.
Preferably, in this embodiment, the step S500 specifically further includes:
Step S531, standard callback class information corresponding to the callback class information in the standard information is obtained;
step S532, traversing the callback class information, and judging whether member variables exist between the callback class information and the standard callback class information based on the standard callback class information;
step S533, traversing the member functions in the callback class information, and judging whether only function pointers are contained as parameters.
Specifically, in some application scenarios of the present embodiment, for detecting callback class information, specific detection content includes the following steps:
1. The callback class is retrieved from the current version library class list, and the callback class is identified according to a naming convention mode, such as (the naming contains 'CallBack' words). And then retrieving data from the member variable table and the function information table according to the callback class ID, and detecting compatibility problems in two steps after retrieval is completed:
1.1. it is detected whether a member variable exists.
1.2. It is detected whether the function parameters are parameters of the function pointer type and only parameters of the function pointer type.
Further, error information recorded in the detection process is summarized and collated to generate a compatibility detection report, and in some application scenarios of this embodiment, the compatibility detection report is shown in fig. 4.
In summary, according to the interface downward compatibility detection method in the above embodiment of the present invention, the text file from the interface is parsed to obtain the interface class information corresponding to the text file, and meanwhile, a comparison library including standard information is generated based on the standard interface file, and a compatibility detection rule is defined, and the comparison is performed based on the compatibility detection rule, so that the change of the interface information in the development process is directly monitored, the interface compatibility problem can be pointed out in detail, the developer is helped to solve the compatibility problem quickly and conveniently, and the software fault tolerance is greatly improved.
Example two
As shown in fig. 5, a second embodiment of the present application provides an interface downward compatibility detection system, including:
The analysis module is used for analyzing the text file from the interface and converting text information corresponding to the text file into a grammar analysis tree;
The extraction module is used for carrying out semantic analysis on the syntax analysis tree and traversing the syntax analysis tree in a cursor traversing mode so as to extract interface class information corresponding to the text file;
The storage module is used for storing the interface type information into a Sqlite light-weight database;
The standard module is used for generating a comparison library comprising standard information based on a standard interface file and defining a compatibility detection rule;
And the comparison module is used for comparing and detecting the interface type information in the Sqlite lightweight database with the standard information in the comparison library based on the compatibility detection rule so as to generate a compatibility detection report.
Preferably, in this embodiment, the parsing module is specifically configured to:
converting the C++ code text corresponding to the text file into a code element sequence based on a lexical analyzer;
the sequence of code elements is converted to a parse tree based on a parser.
According to an aspect of the foregoing technical solution, the extraction module is specifically configured to:
and performing access detection on each node information in the syntax analysis tree by adopting a cursor, and acquiring corresponding interface class information based on the node type of the node information, wherein the interface class information comprises non-derived interface class information, derived interface class information and callback class information.
Preferably, in this embodiment, the standard module is specifically configured to:
for the non-derived interface class information, the following rules are satisfied with respect to the standard information: no member variables exist, the original function is not allowed to be deleted or modified, and the function can only be added backwards;
for the derived interface class information, the following rules are satisfied with respect to the standard information: the member variables have d/q pointer variables only, have derived interface functions only, do not allow the original functions to be deleted or modified, and the functions can only be added backwards;
For the callback class information, the following rules are satisfied with respect to the standard information: there are no member variables and the callback class function contains only function pointers as parameters.
Preferably, in this embodiment, the comparison module is specifically configured to:
Obtaining standard non-derived class information corresponding to the non-derived class information in the standard information;
Traversing the non-derived class information, and judging whether member variables exist between the non-derived class information and the standard non-derived class information based on the standard non-derived class information;
And traversing the member functions in the non-derived class information and the standard non-derived class information, judging whether a new function or a deleted function exists between the member functions, and judging whether function modification exists.
Preferably, in this embodiment, the comparison module is further configured to:
Obtaining standard export class information corresponding to the export class information in the standard information;
Traversing the derived class information, screening member variables based on the standard non-derived class information, and judging whether the type of the member variables is d/q pointer type;
And traversing the derived class information and the member function in the standard derived class information, and judging whether the function is a public or protection type function, whether a new function or a deleted function exists or not, and whether the function is modified or not.
Preferably, in this embodiment, the comparison module is further configured to:
Obtaining standard callback class information corresponding to the callback class information in the standard information;
Traversing the callback class information, and judging whether member variables exist between the callback class information and the standard callback class information based on the standard callback class information;
And traversing the member functions in the callback class information, and judging whether only function pointers are contained as parameters.
The respective modules may be functional modules or program modules, and may be implemented by software or hardware. For modules implemented in hardware, the various modules may be located in the same processor; or the modules may be located in different processors, respectively, in any combination.
A third embodiment of the present application provides a computer, and it can be understood that the principles mentioned in the interface downward compatibility detection system in this embodiment correspond to the interface downward compatibility detection method in the first embodiment of the present application, and related principles not described in detail may be correspondingly referred to the first embodiment, which is not repeated herein.
The computer may include a processor 81 and a memory 82 in which computer program commands are stored.
In particular, the processor 81 may include a Central Processing Unit (CPU), or an Application SPECIFIC INTEGRATED Circuit (ASIC), or may be configured as one or more integrated circuits that implement embodiments of the present application.
The memory 82 may include, among other things, mass storage for data or commands. By way of example, and not limitation, memory 82 may comprise a hard disk drive (HARD DISK DRIVE, abbreviated HDD), floppy disk drive, solid state drive (solid STATE DRIVE, abbreviated SSD), flash memory, optical disk, magneto-optical disk, magnetic tape, or universal serial bus (Universal Serial Bus, abbreviated USB) drive, or a combination of two or more of these. The memory 82 may include removable or non-removable (or fixed) media, where appropriate. The memory 82 may be internal or external to the data processing apparatus, where appropriate. In a particular embodiment, the memory 82 is a Non-Volatile (Non-Volatile) memory. In particular embodiments, memory 82 includes read-only memory (ROM) and random access memory (Random Access Memory, RAM). Where appropriate, the ROM may be a mask-programmed ROM, a programmable ROM (Programmable Read-only memory, abbreviated PROM), an erasable PROM (Erasable Programmable Read-only memory, abbreviated EPROM), an electrically erasable PROM (ELECTRICALLY ERASABLE PROGRAMMABLE READ-only memory, abbreviated EEPROM), an electrically rewritable ROM (ELECTRICALLY ALTERABLE READ-only memory, abbreviated EAROM), or a FLASH memory (FLASH), or a combination of two or more of these. The RAM may be a static random-access memory (SRAM) or a dynamic random-access memory (Dynamic Random Access Memory DRAM), where the DRAM may be a fast page mode dynamic random-access memory (Fast Page Mode Dynamic Random Access Memory, FPMDRAM), an extended data output dynamic random-access memory (Extended Date Out Dynamic Random Access Memory, EDODRAM), a synchronous dynamic random-access memory (Synchronous Dynamic Random-access memory, SDRAM), or the like, as appropriate.
The memory 82 may be used to store or cache various data files that need to be processed and/or communicated, as well as possible computer program commands executed by the processor 82.
The processor 81 implements any of the interface downward compatibility detection methods of the above embodiments by reading and executing the computer program commands stored in the memory 82.
In some of these embodiments, the computer may also include a communication interface 83 and a bus 80. As shown in fig. 6, the processor 81, the memory 82, and the communication interface 83 are connected to each other through the bus 80 and perform communication with each other.
The communication interface 83 is used to enable communication between modules, devices, units and/or units in embodiments of the application. The communication interface 83 may also enable communication with other components such as: and the external equipment, the image/data acquisition equipment, the database, the external storage, the image/data processing workstation and the like are used for data communication.
Bus 80 includes hardware, software, or both, coupling the components of the computer to one another. Bus 80 includes, but is not limited to, at least one of: data Bus (Data Bus), address Bus (Address Bus), control Bus (Control Bus), expansion Bus (Expansion Bus), local Bus (Local Bus). By way of example, and not limitation, bus 80 may include a graphics acceleration interface (ACCELERATED GRAPHICS Port, abbreviated as AGP) or other graphics bus, an enhanced industry standard architecture (Extended Industry Standard Architecture, abbreviated as EISA) bus, a front side bus (front side bus, abbreviated as FSB), a HyperTransport (abbreviated as HT) interconnect, an industry standard architecture (Industry Standard Architecture, abbreviated as ISA) bus, a wireless bandwidth (InfiniBand) interconnect, a Low Pin Count (LPC) bus, a memory bus, a micro channel architecture (Micro Channel Architecture, abbreviated as MCA) bus, a peripheral component interconnect (PERIPHERAL COMPONENT INTERCONNECT, abbreviated as PCI) bus, a PCI-express (PCI-X) bus, a serial advanced technology attachment (SERIAL ADVANCED Technology Attachment, abbreviated as SATA) bus, a video electronics standards Association local (Video Electronics Standards Association Local Bus, abbreviated as VLB) bus, or other suitable bus, or a combination of two or more of these. Bus 80 may include one or more buses, where appropriate. Although embodiments of the application have been described and illustrated with respect to a particular bus, the application contemplates any suitable bus or interconnect.
In addition, in combination with the interface downward compatibility detection method in the above embodiment, a fourth embodiment of the present application provides a readable storage medium. The readable storage medium having stored thereon computer program commands; the computer program instructions, when executed by a processor, implement any of the interface downward compatibility detection methods of the above embodiments.
The technical features of the above-described embodiments may be arbitrarily combined, and for brevity, all of the possible combinations of the technical features of the embodiments are not described, however, as long as there is no contradiction between the combinations of the technical features, they should be considered as the scope of the description.
The above examples illustrate only a few embodiments of the application, which are described in detail and are not to be construed as limiting the scope of the application. It should be noted that it will be apparent to those skilled in the art that several variations and modifications can be made without departing from the spirit of the application, which are all within the scope of the application. Accordingly, the scope of protection of the present application is to be determined by the appended claims.

Claims (10)

1. An interface downward compatibility detection method is characterized by comprising the following steps:
analyzing a text file from an interface, and converting text information corresponding to the text file into a grammar analysis tree;
Performing semantic analysis on the syntax analysis tree, and traversing the syntax analysis tree in a cursor traversing mode to extract interface class information corresponding to the text file;
Storing the interface type information into a Sqlite lightweight database;
generating a comparison library comprising standard information based on the standard interface file, and defining a compatibility detection rule;
And based on the compatibility detection rule, comparing and detecting interface type information in the Sqlite lightweight database with standard information in the comparison library to generate a compatibility detection report.
2. The method for detecting interface downward compatibility according to claim 1, wherein the step of converting the text information corresponding to the text file into a parse tree specifically comprises:
converting the C++ code text corresponding to the text file into a code element sequence based on a lexical analyzer;
the sequence of code elements is converted to a parse tree based on a parser.
3. The method for detecting interface downward compatibility according to claim 1, wherein the steps of performing semantic analysis on the parse tree and traversing the parse tree by means of cursor traversal to extract interface class information corresponding to the text file specifically comprise:
and performing access detection on each node information in the syntax analysis tree by adopting a cursor, and acquiring corresponding interface class information based on the node type of the node information, wherein the interface class information comprises non-derived interface class information, derived interface class information and callback class information.
4. The method for detecting downward compatibility of an interface according to claim 3, wherein the step of defining a compatibility detection rule specifically comprises:
for the non-derived interface class information, the following rules are satisfied with respect to the standard information: no member variables exist, the original function is not allowed to be deleted or modified, and the function can only be added backwards;
for the derived interface class information, the following rules are satisfied with respect to the standard information: the member variables have d/q pointer variables only, have derived interface functions only, do not allow the original functions to be deleted or modified, and the functions can only be added backwards;
For the callback class information, the following rules are satisfied with respect to the standard information: there are no member variables and the callback class function contains only function pointers as parameters.
5. The method for detecting interface downward compatibility according to claim 3, wherein the step of comparing the interface class information in the Sqlite lightweight database with the standard information in the comparison library specifically comprises:
Obtaining standard non-derived class information corresponding to the non-derived class information in the standard information;
Traversing the non-derived class information, and judging whether member variables exist between the non-derived class information and the standard non-derived class information based on the standard non-derived class information;
And traversing the member functions in the non-derived class information and the standard non-derived class information, judging whether a new function or a deleted function exists between the member functions, and judging whether function modification exists.
6. The method for detecting interface downward compatibility according to claim 3, wherein the step of comparing the interface class information in the Sqlite lightweight database with the standard information in the comparison library specifically comprises:
Obtaining standard export class information corresponding to the export class information in the standard information;
Traversing the derived class information, screening member variables based on the standard non-derived class information, and judging whether the type of the member variables is d/q pointer type;
And traversing the derived class information and the member function in the standard derived class information, and judging whether the function is a public or protection type function, whether a new function or a deleted function exists or not, and whether the function is modified or not.
7. The method for detecting interface downward compatibility according to claim 3, wherein the step of comparing the interface class information in the Sqlite lightweight database with the standard information in the comparison library specifically comprises:
Obtaining standard callback class information corresponding to the callback class information in the standard information;
Traversing the callback class information, and judging whether member variables exist between the callback class information and the standard callback class information based on the standard callback class information;
And traversing the member functions in the callback class information, and judging whether only function pointers are contained as parameters.
8. An interface downward compatibility detection system, comprising:
The analysis module is used for analyzing the text file from the interface and converting text information corresponding to the text file into a grammar analysis tree;
The extraction module is used for carrying out semantic analysis on the syntax analysis tree and traversing the syntax analysis tree in a cursor traversing mode so as to extract interface class information corresponding to the text file;
The storage module is used for storing the interface type information into a Sqlite light-weight database;
The standard module is used for generating a comparison library comprising standard information based on a standard interface file and defining a compatibility detection rule;
And the comparison module is used for comparing and detecting the interface type information in the Sqlite lightweight database with the standard information in the comparison library based on the compatibility detection rule so as to generate a compatibility detection report.
9. A computer comprising a memory, a processor and a computer program stored on the memory and executable on the processor, characterized in that the processor implements the interface downward compatibility detection method of any one of claims 1-7 when executing the computer program.
10. A storage medium having stored thereon a computer program, which when executed by a processor implements the interface downward compatibility detection method of any of the preceding claims 1-7.
CN202311861747.1A 2023-12-29 2023-12-29 Interface downward compatibility detection method, system, computer and storage medium Pending CN117909152A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311861747.1A CN117909152A (en) 2023-12-29 2023-12-29 Interface downward compatibility detection method, system, computer and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311861747.1A CN117909152A (en) 2023-12-29 2023-12-29 Interface downward compatibility detection method, system, computer and storage medium

Publications (1)

Publication Number Publication Date
CN117909152A true CN117909152A (en) 2024-04-19

Family

ID=90687318

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311861747.1A Pending CN117909152A (en) 2023-12-29 2023-12-29 Interface downward compatibility detection method, system, computer and storage medium

Country Status (1)

Country Link
CN (1) CN117909152A (en)

Similar Documents

Publication Publication Date Title
CN109800175B (en) Ether house intelligent contract reentry vulnerability detection method based on code instrumentation
US10372594B2 (en) Method and device for retrieving test case based on code coverage
CN111488174B (en) Method and device for generating application program interface document, computer equipment and medium
US8732673B2 (en) Automated debugging system and method
US10394694B2 (en) Unexplored branch search in hybrid fuzz testing of software binaries
US20010037492A1 (en) Method and apparatus for automatically extracting verification models
CN110502227B (en) Code complement method and device, storage medium and electronic equipment
US20160306736A1 (en) Translation verification testing
US20130152061A1 (en) Full fidelity parse tree for programming language processing
CN108563561B (en) Program implicit constraint extraction method and system
CN112988163B (en) Intelligent adaptation method, intelligent adaptation device, intelligent adaptation electronic equipment and intelligent adaptation medium for programming language
CN110286912B (en) Code detection method and device and electronic equipment
CN117909152A (en) Interface downward compatibility detection method, system, computer and storage medium
US8819645B2 (en) Application analysis device
CN115221047A (en) Automatic test case generation method and electronic equipment
CN112433943A (en) Method, device, equipment and medium for detecting environment variable based on abstract syntax tree
US20210208857A1 (en) Parsability of code snippets
CN112286784B (en) Test case generation method, device, server and storage medium
CN112162738B (en) Data conversion method and device, terminal equipment and storage medium
CN112162777B (en) Source code feature extraction method and device
CN116305131B (en) Static confusion removing method and system for script
US20230350788A1 (en) Method and system for providing delta code coverage information for work items
CN115658030A (en) Code processing method and device and electronic equipment
Savitskii et al. Fast analysis of source code in C and C++
CN114003234A (en) Local compiling method, device and equipment for small program and computer readable 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