CN111382076A - Application program testing method and device, electronic equipment and computer storage medium - Google Patents

Application program testing method and device, electronic equipment and computer storage medium Download PDF

Info

Publication number
CN111382076A
CN111382076A CN202010163489.XA CN202010163489A CN111382076A CN 111382076 A CN111382076 A CN 111382076A CN 202010163489 A CN202010163489 A CN 202010163489A CN 111382076 A CN111382076 A CN 111382076A
Authority
CN
China
Prior art keywords
application program
file
preset
target dynamic
dynamic link
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.)
Granted
Application number
CN202010163489.XA
Other languages
Chinese (zh)
Other versions
CN111382076B (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.)
Beijing ByteDance Network Technology Co Ltd
Original Assignee
Beijing ByteDance Network 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 Beijing ByteDance Network Technology Co Ltd filed Critical Beijing ByteDance Network Technology Co Ltd
Priority to CN202010163489.XA priority Critical patent/CN111382076B/en
Publication of CN111382076A publication Critical patent/CN111382076A/en
Application granted granted Critical
Publication of CN111382076B publication Critical patent/CN111382076B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

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/3688Test management for test execution, e.g. scheduling of test suites
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

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

Abstract

The application provides a test method and device of an application program, electronic equipment and a computer readable storage medium, and relates to the field of data processing. The method comprises the following steps: when the application program is started, determining a target dynamic link library through a script file preset in the application program; for any file accessed by the application program, recording related information of the file through the target dynamic library; and when the access is finished and any file meets the preset conditions, taking the corresponding related information as a test result and outputting the test result. According to the method and the device, a program developer can quickly locate and repair the vulnerability of the application program, the file meets the preset condition after the application program finishes accessing any file, the problem that the application program is crashed due to the fact that the number of the files which do not meet the preset condition reaches a certain number is solved, and user experience is improved.

Description

Application program testing method and device, electronic equipment and computer storage medium
Technical Field
The present application relates to the field of data processing technologies, and in particular, to a method and an apparatus for testing an application program, an electronic device, and a computer-readable storage medium.
Background
With the development of science and technology, the hardware performance of the intelligent terminal is more and more powerful, and the operation of various types of application programs in the intelligent terminal can be supported. However, sometimes, the application program may crash during running due to some bugs existing in the application program itself.
For example, an application may need to open and use various files, including system files, program files of the application itself, or user files, to perform I/O operations at runtime. Under normal conditions, an application program closes a file after the file is used up, and under the condition that the application program has a bug, the application program does not close the file in time, namely the file leaks. Files that are simultaneously opened on some operating system platforms are limited, a program crash can be caused if the number of file leaks exceeds the limit, and the information of the crash generally cannot be located to a specific leaked file, that is, it cannot be determined which file is opened by which code of an application program and the opened file is not closed, so that not only is the user experience of a user when the application program is used reduced, but also great repair difficulty is caused to a program developer.
Disclosure of Invention
This summary is provided to introduce a selection of concepts in a simplified form that are further described below in the detailed description. This summary is not intended to identify key features or essential features of the claimed subject matter, nor is it intended to be used to limit the scope of the claimed subject matter.
The application provides a test method and device for an application program, an electronic device and a computer readable storage medium, which can solve the problems that the user experience of a user when the application program is used is reduced and great repair difficulty is caused to a program developer when the application program acts. The technical scheme is as follows:
in a first aspect, a method for testing an application program is provided, where the method includes:
when the application program is started, determining a target dynamic link library through a script file preset in the application program;
for any file accessed by the application program, recording related information of the file through the target dynamic library;
and when the access is finished and any file meets the preset conditions, taking the corresponding related information as a test result and outputting the test result.
In a second aspect, there is provided an apparatus for testing an application, the apparatus comprising:
the first processing module is used for determining a target dynamic link library through a script file preset in the application program when the application program is started;
the second processing module is used for recording the relevant information of any file accessed by the application program through the target dynamic library;
and the third processing module is used for taking the corresponding related information as a test result and outputting the test result when the access is finished and any file meets the preset condition.
In a third aspect, an electronic device is provided, which includes:
a processor, a memory, and a bus;
the bus is used for connecting the processor and the memory;
the memory is used for storing operation instructions;
the processor is configured to call the operation instruction, and the executable instruction enables the processor to execute an operation corresponding to the test method of the application program shown in the first aspect of the present application.
In a fourth aspect, a computer-readable storage medium is provided, on which a computer program is stored, which when executed by a processor implements the method for testing an application program as shown in the first aspect of the present application.
The beneficial effect that technical scheme that this application provided brought is:
in the embodiment of the invention, when the application program is started, a target dynamic link library is determined through a preset script file in the application program, relevant information of any file accessed by the application program is recorded through the target dynamic library, and when the access is finished and the any file meets a preset condition, the corresponding relevant information is used as a test result and the test result is output. Therefore, in the running process of the application program, the relevant information of the file accessed by the application program is recorded through the preset target dynamic link library, and after the access is finished, the relevant information corresponding to the file which does not meet the preset condition is output as a test result, so that a program developer positions out a specific code segment with a bug in the application program based on the test result, the code segment is corrected, the program developer can quickly position and repair the bug of the application program, the file meets the preset condition after the application program finishes accessing any file, the problem that the application program is crashed due to the fact that the number of the files which do not meet the preset condition reaches a certain number is solved, and user experience is improved.
Drawings
The above and other features, advantages and aspects of various embodiments of the present disclosure will become more apparent by referring to the following detailed description when taken in conjunction with the accompanying drawings. Throughout the drawings, the same or similar reference numbers refer to the same or similar elements. It should be understood that the drawings are schematic and that elements and features are not necessarily drawn to scale.
Fig. 1 is a schematic flowchart illustrating a method for testing an application according to an embodiment of the present application;
fig. 2 is a schematic flowchart illustrating a method for testing an application according to another embodiment of the present application;
fig. 3 is a schematic structural diagram of an apparatus for testing an application according to another embodiment of the present application;
fig. 4 is a schematic structural diagram of an electronic device for testing an application according to yet another embodiment of the present application.
Detailed Description
Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While certain embodiments of the present disclosure are shown in the drawings, it is to be understood that the present disclosure may be embodied in various forms and should not be construed as limited to the embodiments set forth herein, but rather are provided for a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the disclosure are for illustration purposes only and are not intended to limit the scope of the disclosure.
It should be understood that the various steps recited in the method embodiments of the present disclosure may be performed in a different order, and/or performed in parallel. Moreover, method embodiments may include additional steps and/or omit performing the illustrated steps. The scope of the present disclosure is not limited in this respect.
The term "include" and variations thereof as used herein are open-ended, i.e., "including but not limited to". The term "based on" is "based, at least in part, on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". Relevant definitions for other terms will be given in the following description.
It should be noted that the terms "first", "second", and the like in the present disclosure are only used for distinguishing different devices, modules or units, and are not used for limiting the devices, modules or units to be determined as different devices, modules or units, and are not used for limiting the sequence or interdependence relationship of the functions executed by the devices, modules or units.
It is noted that references to "a", "an", and "the" modifications in this disclosure are intended to be illustrative rather than limiting, and that those skilled in the art will recognize that "one or more" may be used unless the context clearly dictates otherwise.
The names of messages or information exchanged between devices in the embodiments of the present disclosure are for illustrative purposes only, and are not intended to limit the scope of the messages or information.
The application program testing method, device, electronic equipment and computer readable storage medium provided by the application program aim to solve the above technical problems in the prior art.
The following describes the technical solutions of the present application and how to solve the above technical problems with specific embodiments. The following several specific embodiments may be combined with each other, and details of the same or similar concepts or processes may not be repeated in some embodiments. Embodiments of the present application will be described below with reference to the accompanying drawings.
In one embodiment, a method for testing an application is provided, as shown in fig. 1, the method includes:
step S101, when an application program is started, a target dynamic link library is determined through a script file preset in the application program;
in practical application, the application program can be installed in the intelligent terminal. After the application program is installed in the intelligent terminal, a program file, such as a script file, required by the application program during running can be obtained.
Script (Script) is simply a strip of text commands that are visible (e.g., opening a notepad for viewing, editing), and when executed, is interpreted by an interpreter of the system into machine-recognizable instructions that are executed in program order.
It should be noted that, in practical applications, the script file can be obtained after the application program is installed, but since the script file is a collection of text commands, even after the application program is installed, the user can change the text commands in the script file according to actual needs, thereby meeting the needs of the user.
Further, Dynamic Link Library (DLL) is a way to implement the concept of shared function libraries. The extensions of these library functions are ". dll", ". ocx" (library containing ActiveX controls) or ". drv" (legacy system drivers).
Dynamic linking provides a way for a process to call functions that do not belong to its executable code. The executable code for the functions is located in a DLL file that contains one or more functions that have been compiled, linked and stored separately from the process in which they are used. DLLs also facilitate sharing of data and resources. Multiple applications can simultaneously access the contents of a single DLL copy in memory.
In practical applications, different operating systems typically have corresponding default dynamic link libraries. For example, in Windows, the dynamically linked library is most often a file with a ". dll" extension, but could also be ". ocx" or other extension; in Linux it is often a ". so" file. Which provide code, data or functions to applications running under the Windows or Linux operating systems, respectively. The application may open, enable, query, disable, and close the drivers according to instructions in the DLL file.
Step S102, recording relevant information of a file through a target dynamic library aiming at any file accessed by an application program;
wherein, the access to the file can include but is not limited to opening, closing, reading or writing operations to the file; the file may be any file that the application may access, including but not limited to a system file, a program file of the application itself, or a user file; the related information of the file includes but is not limited to the file name, access frequency, access time consumption, access function name or call stack information of the file.
And step S103, when the application program finishes the access to any file, taking the relevant information meeting the preset conditions as a test result, and outputting the test result.
When the application program finishes accessing any file, detecting whether the file meets a preset condition, if so, taking relevant information corresponding to the file as a test result, outputting the test result, and further storing the test result; if not, no other operations may be performed.
In the embodiment of the invention, when the application program is started, the target dynamic link library is determined through the preset script file in the application program, the relevant information of the file is recorded through the target dynamic library aiming at any file accessed by the application program, and when the access is finished and any file meets the preset condition, the corresponding relevant information is taken as the test result and the test result is output. Therefore, in the running process of the application program, the relevant information of the file accessed by the application program is recorded through the preset target dynamic link library, and after the access is finished, the relevant information corresponding to the file which does not meet the preset condition is output as a test result, so that a program developer positions out a specific code segment with a bug in the application program based on the test result, the code segment is corrected, the program developer can quickly position and repair the bug of the application program, the file meets the preset condition after the application program finishes accessing any file, the problem that the application program is crashed due to the fact that the number of the files which do not meet the preset condition reaches a certain number is solved, and user experience is improved.
In another embodiment, a method for testing an application program is provided, as shown in fig. 2, the method includes:
step S201, when the application program is started, a target dynamic link library is determined through a script file preset in the application program;
in practical application, the application program can be installed in an intelligent terminal, and the intelligent terminal can have the following characteristics:
(1) on a hardware architecture, a device has a central processing unit, a memory, an input unit and an output unit, that is, the device is often a microcomputer device having a communication function. In addition, various input modes such as a keyboard, a mouse, a touch screen, a microphone, a camera and the like can be provided, and input can be adjusted as required. Meanwhile, the equipment often has a plurality of output modes, such as a telephone receiver, a display screen and the like, and can be adjusted according to needs;
(2) on a software system, the device must have an operating system, such as Windows Mobile, Symbian, Palm, Android, iOS, and the like. Meanwhile, the operating systems are more and more open, and personalized application programs developed based on the open operating system platforms are infinite, such as a communication book, a schedule, a notebook, a calculator, various games and the like, so that the requirements of personalized users are met to a great extent;
(3) in terms of communication capacity, the device has flexible access mode and high-bandwidth communication performance, and can automatically adjust the selected communication mode according to the selected service and the environment, thereby being convenient for users to use. The device can support GSM (Global System for Mobile Communication), WCDMA (Wideband Code Division Multiple Access), CDMA2000(Code Division Multiple Access), TDSCDMA (Time Division-Synchronous Code Division Multiple Access), Wi-Fi (Wireless-Fidelity), WiMAX (world interoperability for Microwave Access), etc., thereby adapting to various systems of networks, not only supporting voice service, but also supporting various Wireless data services;
(4) in the aspect of function use, the equipment focuses more on humanization, individuation and multi-functionalization. With the development of computer technology, devices enter a human-centered mode from a device-centered mode, and the embedded computing, control technology, artificial intelligence technology, biometric authentication technology and the like are integrated, so that the human-oriented purpose is fully embodied. Due to the development of software technology, the equipment can be adjusted and set according to individual requirements, and is more personalized. Meanwhile, the device integrates a plurality of software and hardware, and the function is more and more powerful.
Further, after the application program is installed in the intelligent terminal, a program file, such as a script file, required by the application program during running can be obtained.
Script (Script) is simply a strip of text commands that are visible (e.g., opening a notepad for viewing, editing), and when executed, is interpreted by an interpreter of the system into machine-recognizable instructions that are executed in program order.
The script mainly has the following characteristics:
grammars and structures are usually simpler;
learning and use is generally simpler;
"interpretation" of easily modified programs is usually used as a way of running, without the need for "compilation";
the development capacity of the program is superior to the operation efficiency;
the working efficiency of a system administrator is greatly improved.
Scripts can typically be temporarily called and executed by an application. Various scripts are widely used in web page design because the scripts can not only reduce the scale of the web page and increase the browsing speed of the web page, but also enrich the representation of the web page, such as animation, sound, etc. For the most common example, mailbox software such as outlook express or Foxmail can be automatically called when an Email address on a webpage is clicked, and the mailbox software is realized through a script function, wherein the webpage corresponds to a browser, and the automatic calling of the mailbox software is a text command in a script.
It should be noted that, in practical applications, the script file can be obtained after the application program is installed, but since the script file is a collection of text commands, even after the application program is installed, the user can change the text commands in the script file according to actual needs, thereby meeting the needs of the user.
Further, Dynamic Link Library (DLL) is one way to implement the concept of shared function libraries. The extensions of these library functions are ". dll", ". ocx" (library containing ActiveX controls) or ". drv" (legacy system drivers).
Dynamic linking provides a way for a process to call functions that do not belong to its executable code. The executable code for the functions is located in a DLL file that contains one or more functions that have been compiled, linked and stored separately from the process in which they are used. DLLs also facilitate sharing of data and resources. Multiple applications can simultaneously access the contents of a single DLL copy in memory.
Updates can be more easily applied to individual modules using dynamically linked libraries without affecting other parts of the program. For example, if a large network game has hundreds of MB or even several GB of game code in one application, the modification work will be time consuming later, and if the code for different functions is placed in several dynamically linked libraries, the update can be applied without regenerating or installing the whole program.
A dynamic link library file is a non-executable binary program file that allows applications to share code and other resources necessary to perform a particular task. The DLL file contains many functions and resources that allow a program based on a specified operating system to operate in the context of the specified operating system.
The dynamically linked library has the following advantages:
1) the characteristics of the application program are expanded;
2) may be written in a variety of programming languages;
3) the management of software projects is simplified;
4) the memory is saved;
5) facilitate resource sharing;
6) to facilitate localization of applications;
7) help to resolve platform differences;
8) may be used for some special purposes. For example, Windows makes certain features available only to DLLs.
In practical applications, different operating systems typically have corresponding default dynamic link libraries. For example, in Windows, the dynamically linked library is most often a file with a ". dll" extension, but could also be ". ocx" or other extension; in Linux it is often a ". so" file. Which provide code, data or functions to applications running under the Windows or Linux operating systems, respectively. The application may open, enable, query, disable, and close the drivers according to instructions in the DLL file.
In a preferred embodiment of the present invention, the step of determining the target dynamic link library through a script file preset in the application program includes:
determining an environment variable of a target parameter corresponding to an application program through a script file;
and determining a target dynamic link library from the environment variables.
Specifically, the embodiment of the present invention may be applied to a test phase of an application program, before the application program is run, a dynamic link library including various standard I/O (Input/Output) functions meeting operating system requirements, such as open/close, write/read, and the like, may be implemented in advance by writing code, and then a script file, such as a wrap. Therefore, a pre-programmed dynamic link library can be obtained when the application program is installed; or before the application program is installed and operated, storing the pre-programmed dynamic link library to the target path, and then re-declaring the environment variable of the target parameter, namely ensuring that the pre-programmed dynamic link library is appointed when the application program is operated; of course, the present invention is also applicable in other ways, and may be adjusted according to actual requirements in practical applications, which is not limited in the embodiments of the present invention.
Further, when the application program is running, the application program executes a text command of declaring the LD _ PRELOAD environment variable in the wrap.
Step 202, replacing a system standard dynamic link library in a preset system with a target dynamic link library; an application program is installed in the preset system;
in practical application, when an application program runs in a terminal installed with a specified operating system, a system standard dynamic link library of the operating system is used by default, under normal conditions, the application program can access various files during running, specifically, the files can be opened, the content of the files can be acquired, and when the access is finished, the opened files can be closed.
However, when an application develops a vulnerability, a situation occurs in which a file is opened by the application but not closed, which is referred to as "file leakage". When the number of file leaks exceeds a threshold value, the application program may crash, such as being unable to start, flashing back, and the like.
In the embodiment of the invention, the preset dynamic link library can monitor all I/O operations on the application program starting path and the conventional code execution path, collect information such as the opened file name and the call stack, and through the information, a program developer can easily find the vulnerability of the application program, namely which section of code of the application program opens which file, so that the corresponding code section is leaked according to the unclosed file positioning file, and then the code section is modified, thereby avoiding the situation that the application program is crashed.
Therefore, in the embodiment of the invention, after the target dynamic link library is determined, the target dynamic link library is used for replacing a system standard dynamic link library in the operating system; wherein, the application program is installed in the operating system.
Step S203, recording the relevant information of the file through a target dynamic library aiming at any file accessed by the application program;
wherein, the access to the file can include but is not limited to opening, closing, reading or writing operations to the file; the file may be any file that the application may access, including but not limited to a system file, a program file of the application itself, or a user file; the related information of the file includes but is not limited to the file name, access frequency, access time consumption, access function name or call stack information of the file.
In a preferred embodiment of the present invention, the step of recording the relevant information of the file through the target dynamic library for any file accessed by the application program includes:
when the application program executes any I/O operation aiming at any file, the file name and the call stack information of any file are recorded.
Specifically, in the running process of the application program, when the application program executes any I/O operation on any file, the relevant information of the file, mainly the file name and the call stack information, is recorded through the target dynamic library.
Where a call stack is a stack in computer science that stores messages about running subroutines. Sometimes referred to as a "stack" only, but not necessarily storing only subroutine messages in the stack. The call stack is most often used to deposit the return address of the subroutine. When any subprogram is called, the main program must temporarily store the address to which the subprogram should be returned after the subprogram is completely run. Therefore, if the called subroutine calls another subroutine, its own return address must be stored in the call stack and retrieved after it has been run. In a recursive program, each level of recursion must add an address to the call stack, so if the program appears to recurse indefinitely (or only a plethora of recursive levels), the call stack will produce stack overflow.
The main functions of the call stack, in addition to storing return addresses, can also be used to store:
local variables: the variables of the subprogram can be stored in the call stack, so that the function of separating the variables among different subprograms can be achieved;
parameter transmission: if the register is not enough to accommodate the parameter of the subprogram, the parameter can be stored on the call stack;
environment transfer: some languages (e.g., Pascal and Ada) support "multi-level subroutines," i.e., subroutines that utilize local variables of the main program. These variables may be passed into the subroutine through the call stack.
Based on the above-mentioned features of the call stack, in the embodiment of the present invention, a code segment with a leak in the application program may be determined based on the file name of the file and the call stack information.
And step S204, when the access is finished and any file meets the preset conditions, taking the corresponding related information as a test result and outputting the test result.
When the application program finishes accessing any file, detecting whether the file meets a preset condition, if so, taking relevant information corresponding to the file as a test result, outputting the test result, and further storing the test result; if not, no other operations may be performed.
In a preferred embodiment of the present invention, the completion of the access to any file by the application program includes the application program performing a close operation on any file;
when the access is finished and any file meets the preset conditions, the step of taking the corresponding related information as a test result comprises the following steps:
when an application program executes closing operation on any file, detecting whether any file is closed;
if any file is not closed, the condition that the file meets the preset condition is judged, and the related information of any file is used as a test result.
In particular, the termination of access by an application to any file may include the application performing a close operation on the file, which, under normal circumstances, the file is closed, and in the case of a vulnerability in the application, the file is not closed, therefore, in the case that the application program performs the closing operation and the file is not closed, the file name of the file which is not closed and the call stack information corresponding to the file name are obtained, and then outputs it as a test result, so that the program developer can locate which section of code of the application program accesses which file and does not close the file by calling stack information, thereby correcting the code section, and the problem that the application program is crashed because the file is not closed after the application program finishes accessing any file is further solved.
Of course, the method for locating a code segment with a bug in an application program in other ways besides the way of detecting whether the access is closed is also applicable to the present application, and the method and the device can be set according to actual requirements in actual applications, which is not limited in this embodiment of the present invention.
In the embodiment of the invention, when the application program is started, the target dynamic link library is determined through the preset script file in the application program, the relevant information of the file is recorded through the target dynamic library aiming at any file accessed by the application program, and when the access is finished and any file meets the preset condition, the corresponding relevant information is taken as the test result and the test result is output. Therefore, in the running process of the application program, the relevant information of the file accessed by the application program is recorded through the preset target dynamic link library, and after the access is finished, the relevant information corresponding to the file which does not meet the preset condition is output as a test result, so that a program developer positions out a specific code segment with a bug in the application program based on the test result, the code segment is corrected, the program developer can quickly position and repair the bug of the application program, the file meets the preset condition after the application program finishes accessing any file, the problem that the application program is crashed due to the fact that the number of the files which do not meet the preset condition reaches a certain number is solved, and user experience is improved.
Fig. 3 is a schematic structural diagram of an apparatus for testing an application according to another embodiment of the present application, and as shown in fig. 3, the apparatus of this embodiment may include:
the first processing module 301 is configured to determine a target dynamic link library through a script file preset in an application program when the application program is started;
the second processing module 302 is configured to record, for any file accessed by the application program, related information of the file through the target dynamic library;
the third processing module 303 is configured to, when the access is finished and any file meets a preset condition, take the corresponding related information as a test result, and output the test result.
In a preferred embodiment of the present invention, the first processing module includes:
the environment variable determining submodule is used for determining the environment variable of the target parameter corresponding to the application program through the script file;
and the target dynamic link library determining submodule is used for determining the target dynamic link library from the environment variables.
In a preferred embodiment of the present invention, the method further comprises:
the replacing module is used for replacing a system standard dynamic link library in a preset system by the target dynamic link library after the step of determining the target dynamic link library through a script file preset in the application program; the preset system is provided with an application program.
In a preferred embodiment of the present invention, the second processing module is specifically configured to:
when the application program executes any I/O operation aiming at any file, the file name and the call stack information of any file are recorded through the target dynamic library.
In a preferred embodiment of the present invention, the end of access includes the application performing a close operation on any file;
the third processing module comprises:
the detection submodule is used for detecting whether any file is closed or not when the application program initiates a closing instruction to any file;
and the judging submodule is used for judging that the preset condition is met if any file is not closed, and taking the relevant information of any file as a test result.
The testing apparatus for application programs of this embodiment can execute the testing methods for application programs shown in the first embodiment and the second embodiment of this application, and the implementation principles thereof are similar, and are not described herein again.
In the embodiment of the invention, when the application program is started, the target dynamic link library is determined through the preset script file in the application program, the relevant information of the file is recorded through the target dynamic library aiming at any file accessed by the application program, and when the access is finished and any file meets the preset condition, the corresponding relevant information is taken as the test result and the test result is output. Therefore, in the running process of the application program, the relevant information of the file accessed by the application program is recorded through the preset target dynamic link library, and after the access is finished, the relevant information corresponding to the file which does not meet the preset condition is output as a test result, so that a program developer positions out a specific code segment with a bug in the application program based on the test result, the code segment is corrected, the program developer can quickly position and repair the bug of the application program, the file meets the preset condition after the application program finishes accessing any file, the problem that the application program is crashed due to the fact that the number of the files which do not meet the preset condition reaches a certain number is solved, and user experience is improved.
Referring now to FIG. 4, a block diagram of an electronic device 400 suitable for use in implementing embodiments of the present disclosure is shown. The electronic devices in the embodiments of the present disclosure may include, but are not limited to, mobile terminals such as mobile phones, notebook computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), in-vehicle terminals (e.g., car navigation terminals), and the like, and fixed terminals such as digital TVs, desktop computers, and the like. The electronic device shown in fig. 4 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present disclosure.
The electronic device includes: a memory and a processor, wherein the processor may be referred to as the processing device 401 hereinafter, and the memory may include at least one of a Read Only Memory (ROM)402, a Random Access Memory (RAM)403 and a storage device 408 hereinafter, which are specifically shown as follows: as shown in fig. 4, electronic device 400 may include a processing device (e.g., central processing unit, graphics processor, etc.) 401 that may perform various appropriate actions and processes in accordance with a program stored in a Read Only Memory (ROM)402 or a program loaded from a storage device 408 into a Random Access Memory (RAM) 403. In the RAM403, various programs and data necessary for the operation of the electronic apparatus 400 are also stored. The processing device 401, the ROM 402, and the RAM403 are connected to each other via a bus 404. An input/output (I/O) interface 405 is also connected to bus 404.
Generally, the following devices may be connected to the I/O interface 405: input devices 406 including, for example, a touch screen, touch pad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, etc.; an output device 407 including, for example, a Liquid Crystal Display (LCD), a speaker, a vibrator, and the like; storage 408 including, for example, tape, hard disk, etc.; and a communication device 409. The communication means 409 may allow the electronic device 400 to communicate wirelessly or by wire with other devices to exchange data. While fig. 4 illustrates an electronic device 400 having various means, it is to be understood that not all illustrated means are required to be implemented or provided. More or fewer devices may alternatively be implemented or provided.
In particular, according to an embodiment of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program carried on a non-transitory computer readable medium, the computer program containing program code for performing the method illustrated by the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network via the communication device 409, or from the storage device 408, or from the ROM 402. The computer program performs the above-described functions defined in the methods of the embodiments of the present disclosure when executed by the processing device 401.
It should be noted that the computer readable medium in the present disclosure can be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, 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), an optical fiber, 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 present 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. In contrast, in the present disclosure, a computer readable signal medium may comprise a propagated data signal with computer readable program code embodied therein, either in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: electrical wires, optical cables, RF (radio frequency), etc., or any suitable combination of the foregoing.
In some embodiments, the clients, servers may communicate using any currently known or future developed network protocol, such as HTTP (HyperText transfer protocol), and may be interconnected with any form or medium of digital data communication (e.g., a communications network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), the Internet (e.g., the Internet), and peer-to-peer networks (e.g., ad hoc peer-to-peer networks), as well as any currently known or future developed network.
The computer readable medium may be embodied in the electronic device; or may exist separately without being assembled into the electronic device.
The computer readable medium carries one or more programs which, when executed by the electronic device, cause the electronic device to: when the application program is started, determining a target dynamic link library through a script file preset in the application program; recording related information of the file through a target dynamic library aiming at any file accessed by an application program; and when the access is finished and any file meets the preset conditions, taking the corresponding related information as a test result and outputting the test result.
Computer program code for carrying out operations for the present disclosure may be written in any combination of one or more programming languages, including but not limited to an object oriented programming language such as Java, Smalltalk, C + +, and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider).
The flowchart 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 and/or flowchart illustration, and combinations of blocks in the block diagrams and/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.
The modules or units described in the embodiments of the present disclosure may be implemented by software or hardware. Wherein the designation of a module or unit does not in some cases constitute a limitation of the unit itself.
The functions described herein above may be performed, at least in part, by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field Programmable Gate Arrays (FPGAs), Application Specific Integrated Circuits (ASICs), Application Specific Standard Products (ASSPs), systems on a chip (SOCs), Complex Programmable Logic Devices (CPLDs), and the like.
In the context of this disclosure, a machine-readable medium may be a tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, 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), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
According to one or more embodiments of the present disclosure, [ example one ] there is provided a test method of an application program, including:
when the application program is started, determining a target dynamic link library through a script file preset in the application program;
for any file accessed by the application program, recording related information of the file through the target dynamic library;
and when the access is finished and any file meets the preset conditions, taking the corresponding related information as a test result and outputting the test result.
Preferably, the step of determining the target dynamic link library through a script file preset in the application program includes:
determining an environment variable of a target parameter corresponding to the application program through the script file;
and determining the target dynamic link library from the environment variables.
Preferably, after the step of determining the target dynamic link library by using a script file preset in the application program, the method further includes:
replacing a system standard dynamic link library in a preset system by the target dynamic link library; the preset system is provided with the application program.
Preferably, the step of recording, by the target dynamic library, the relevant information of any file accessed by the application program includes:
and when the application program executes any I/O operation aiming at any file, recording the file name and the call stack information of any file through the target dynamic library.
Preferably, the access end comprises the application program executing a closing operation on any file;
when the access is finished and any file meets the preset conditions, the step of taking the corresponding related information as a test result comprises the following steps:
when the application program initiates a closing instruction to any file, detecting whether the any file is closed;
and if the any file is not closed, judging that the preset condition is met, and taking the related information of the any file as a test result.
According to one or more embodiments of the present disclosure, [ example two ] there is provided an apparatus of example one, comprising:
the first processing module is used for determining a target dynamic link library through a script file preset in the application program when the application program is started;
the second processing module is used for recording the relevant information of any file accessed by the application program through the target dynamic library;
and the third processing module is used for taking the corresponding related information as a test result and outputting the test result when the access is finished and any file meets the preset condition.
Preferably, the first processing module comprises:
the environment variable determining submodule is used for determining the environment variable of the target parameter corresponding to the application program through the script file;
and the target dynamic link library determining submodule is used for determining the target dynamic link library from the environment variables.
Preferably, the method further comprises the following steps:
the replacing module is used for replacing a system standard dynamic link library in a preset system by using the target dynamic link library after the step of determining the target dynamic link library through the script file preset in the application program; the preset system is provided with the application program.
Preferably, the second processing module is specifically configured to:
and when the application program executes any I/O operation aiming at any file, recording the file name and the call stack information of any file through the target dynamic library.
Preferably, the access end comprises the application program executing a closing operation on any file;
the third processing module comprises:
the detection submodule is used for detecting whether any file is closed or not when the application program initiates a closing instruction to any file;
and the judging submodule is used for judging that the preset condition is met if any file is not closed, and taking the relevant information of any file as a test result.
The foregoing description is only exemplary of the preferred embodiments of the disclosure and is illustrative of the principles of the technology employed. It will be appreciated by those skilled in the art that the scope of the disclosure herein is not limited to the particular combination of features described above, but also encompasses other embodiments in which any combination of the features described above or their equivalents does not depart from the spirit of the disclosure. For example, the above features and (but not limited to) the features disclosed in this disclosure having similar functions are replaced with each other to form the technical solution.
Further, while operations are depicted in a particular order, this should not be understood as requiring that such operations be performed in the particular order shown or in sequential order. Under certain circumstances, multitasking and parallel processing may be advantageous. Likewise, while several specific implementation details are included in the above discussion, these should not be construed as limitations on the scope of the disclosure. Certain features that are described in the context of separate embodiments can also be implemented in combination in a single embodiment. Conversely, various features that are described in the context of a single embodiment can also be implemented in multiple embodiments separately or in any suitable subcombination.
Although the subject matter has been described in language specific to structural features and/or methodological acts, it is to be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or acts described above. Rather, the specific features and acts described above are disclosed as example forms of implementing the claims.

Claims (10)

1. A method for testing an application program, comprising:
when the application program is started, determining a target dynamic link library through a script file preset in the application program;
for any file accessed by the application program, recording related information of the file through the target dynamic library;
and when the access is finished and any file meets the preset conditions, taking the corresponding related information as a test result and outputting the test result.
2. The method for testing an application program according to claim 1, wherein the step of determining the target dynamic link library through a script file preset in the application program comprises:
determining an environment variable of a target parameter corresponding to the application program through the script file;
and determining the target dynamic link library from the environment variables.
3. The method for testing an application program according to claim 1 or 2, wherein after the step of determining the target dynamic link library by using a script file preset in the application program, the method further comprises:
replacing a system standard dynamic link library in a preset system by the target dynamic link library; the preset system is provided with the application program.
4. The method for testing an application program according to claim 1, wherein the step of recording, by the target dynamic library, the relevant information of any file accessed by the application program includes:
and when the application program executes any I/O operation aiming at any file, recording the file name and the call stack information of any file through the target dynamic library.
5. The method for testing an application program according to claim 1 or 4, wherein the end of access includes the application program performing a close operation on the any file;
when the access is finished and any file meets the preset conditions, the step of taking the corresponding related information as a test result comprises the following steps:
when the application program initiates a closing instruction to any file, detecting whether the any file is closed;
and if the any file is not closed, judging that the preset condition is met, and taking the related information of the any file as a test result.
6. An apparatus for testing an application, comprising:
the first processing module is used for determining a target dynamic link library through a script file preset in the application program when the application program is started;
the second processing module is used for recording the relevant information of any file accessed by the application program through the target dynamic library;
and the third processing module is used for taking the corresponding related information as a test result and outputting the test result when the access is finished and any file meets the preset condition.
7. The apparatus for testing an application according to claim 6, wherein the first processing module comprises:
the environment variable determining submodule is used for determining the environment variable of the target parameter corresponding to the application program through the script file;
and the target dynamic link library determining submodule is used for determining the target dynamic link library from the environment variables.
8. The apparatus for testing an application according to claim 6 or 7, further comprising:
the replacing module is used for replacing a system standard dynamic link library in a preset system by using the target dynamic link library after the step of determining the target dynamic link library through the script file preset in the application program; the preset system is provided with the application program.
9. An electronic device, comprising:
a processor, a memory, and a bus;
the bus is used for connecting the processor and the memory;
the memory is used for storing operation instructions;
the processor is used for executing the test method of the application program in any one of the claims 1-5 by calling the operation instruction.
10. A computer-readable storage medium for storing computer instructions which, when run on a computer, cause the computer to perform the method of testing an application program of any of claims 1-5.
CN202010163489.XA 2020-03-10 2020-03-10 Application program testing method and device, electronic equipment and computer storage medium Active CN111382076B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010163489.XA CN111382076B (en) 2020-03-10 2020-03-10 Application program testing method and device, electronic equipment and computer storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010163489.XA CN111382076B (en) 2020-03-10 2020-03-10 Application program testing method and device, electronic equipment and computer storage medium

Publications (2)

Publication Number Publication Date
CN111382076A true CN111382076A (en) 2020-07-07
CN111382076B CN111382076B (en) 2023-04-25

Family

ID=71218679

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010163489.XA Active CN111382076B (en) 2020-03-10 2020-03-10 Application program testing method and device, electronic equipment and computer storage medium

Country Status (1)

Country Link
CN (1) CN111382076B (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113127374A (en) * 2021-05-19 2021-07-16 支付宝(杭州)信息技术有限公司 Application program testing method and device applied to iOS equipment

Citations (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2008110111A1 (en) * 2007-03-13 2008-09-18 Huawei Technologies Co., Ltd. Method and device to call dynamic library and dynamic library server and master program implementing device
JP2010267128A (en) * 2009-05-15 2010-11-25 Ntt Docomo Inc Analysis system, analysis device, detection method, analysis method and program
US20130054925A1 (en) * 2011-08-24 2013-02-28 Microsoft Corporation Memory allocation tracking
US20160283357A1 (en) * 2014-03-07 2016-09-29 Tencent Technology (Shenzhen) Company Limited Call stack relationship acquiring method and apparatus
CN106201633A (en) * 2016-07-29 2016-12-07 腾讯科技(深圳)有限公司 A kind of method and device injecting dll file
CN106294071A (en) * 2016-08-11 2017-01-04 宁波舜宇光电信息有限公司 A kind of software crash formation gathering method and system thereof
CN106371940A (en) * 2015-07-21 2017-02-01 腾讯科技(深圳)有限公司 Solution method and device for program crash
CN107085548A (en) * 2016-02-16 2017-08-22 阿里巴巴集团控股有限公司 A kind of method, device and electronic equipment for monitoring application program internal memory
US20180089007A1 (en) * 2016-09-23 2018-03-29 Justin E. Gottschlich Detecting root causes of use-after-free memory errors
CN109726560A (en) * 2018-06-26 2019-05-07 360企业安全技术(珠海)有限公司 Terminal device system protection method and device
CN110362487A (en) * 2019-07-11 2019-10-22 腾讯科技(深圳)有限公司 A kind of test method and device of application program
CN110795355A (en) * 2019-10-30 2020-02-14 深圳开立生物医疗科技股份有限公司 Method and device for detecting memory leakage

Patent Citations (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2008110111A1 (en) * 2007-03-13 2008-09-18 Huawei Technologies Co., Ltd. Method and device to call dynamic library and dynamic library server and master program implementing device
JP2010267128A (en) * 2009-05-15 2010-11-25 Ntt Docomo Inc Analysis system, analysis device, detection method, analysis method and program
US20130054925A1 (en) * 2011-08-24 2013-02-28 Microsoft Corporation Memory allocation tracking
US20160283357A1 (en) * 2014-03-07 2016-09-29 Tencent Technology (Shenzhen) Company Limited Call stack relationship acquiring method and apparatus
CN106371940A (en) * 2015-07-21 2017-02-01 腾讯科技(深圳)有限公司 Solution method and device for program crash
CN107085548A (en) * 2016-02-16 2017-08-22 阿里巴巴集团控股有限公司 A kind of method, device and electronic equipment for monitoring application program internal memory
CN106201633A (en) * 2016-07-29 2016-12-07 腾讯科技(深圳)有限公司 A kind of method and device injecting dll file
CN106294071A (en) * 2016-08-11 2017-01-04 宁波舜宇光电信息有限公司 A kind of software crash formation gathering method and system thereof
US20180089007A1 (en) * 2016-09-23 2018-03-29 Justin E. Gottschlich Detecting root causes of use-after-free memory errors
CN109726560A (en) * 2018-06-26 2019-05-07 360企业安全技术(珠海)有限公司 Terminal device system protection method and device
CN110362487A (en) * 2019-07-11 2019-10-22 腾讯科技(深圳)有限公司 A kind of test method and device of application program
CN110795355A (en) * 2019-10-30 2020-02-14 深圳开立生物医疗科技股份有限公司 Method and device for detecting memory leakage

Non-Patent Citations (3)

* Cited by examiner, † Cited by third party
Title
JANAKAUD: "file-leak-detector" *
JENKINSCI: "lib-file-leak-detector" *
廖维川;: "Windows动态链接库调试技术" *

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113127374A (en) * 2021-05-19 2021-07-16 支付宝(杭州)信息技术有限公司 Application program testing method and device applied to iOS equipment
CN113127374B (en) * 2021-05-19 2022-05-17 支付宝(杭州)信息技术有限公司 Application program testing method and device applied to iOS equipment

Also Published As

Publication number Publication date
CN111382076B (en) 2023-04-25

Similar Documents

Publication Publication Date Title
US9307342B2 (en) Dynamic rendering for software applications
CN110502357A (en) A kind of stack retrogressive method, device, medium and equipment
CN110851204B (en) Application starting method and device and application packaging method and device
CN102830959B (en) A kind of built-in browser interface dynamic expansion method and system
US20160125194A1 (en) Dynamic service discovery
CN112817657B (en) Application program starting item loading method, device, system and storage medium
CN111400068B (en) Interface control method and device, readable medium and electronic equipment
CN104050001A (en) Resource processing method, device and equipment based on Android system
CN112181467B (en) Method and device for upgrading memory firmware of terminal, terminal and storage medium
CN111382076B (en) Application program testing method and device, electronic equipment and computer storage medium
CN111949297B (en) Block chain intelligent contract upgrading method and device and electronic equipment
CN107133169B (en) Application test packet generation method and generation device
CN112905220A (en) Thermal restoration method, device, equipment and storage medium
CN110502251B (en) Application installation method and device
CN116991434A (en) Packet reorganization method, system and storage medium for android APP
US10606612B2 (en) Context check bypass to enable opening shared-object libraries
CN113760631B (en) Page loading time length determining method, device, equipment and storage medium
CN111552531B (en) Page display method, device, terminal and storage medium
CN116263824A (en) Resource access method and device, storage medium and electronic equipment
CN110704767B (en) Page opening method and device, electronic equipment and storage medium
US9697018B2 (en) Synthesizing inputs to preserve functionality
CN115237458A (en) Method for calling inference hardware to execute AI application and related product
CN111797009A (en) Method and device for detecting code compatibility and electronic equipment
CN112631609A (en) Compiling method, device, terminal and storage medium
CN112068814A (en) Method, device, system and medium for generating executable file

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
CB02 Change of applicant information

Address after: 100041 B-0035, 2 floor, 3 building, 30 Shixing street, Shijingshan District, Beijing.

Applicant after: Tiktok vision (Beijing) Co.,Ltd.

Address before: 100041 B-0035, 2 floor, 3 building, 30 Shixing street, Shijingshan District, Beijing.

Applicant before: BEIJING BYTEDANCE NETWORK TECHNOLOGY Co.,Ltd.

Address after: 100041 B-0035, 2 floor, 3 building, 30 Shixing street, Shijingshan District, Beijing.

Applicant after: Douyin Vision Co.,Ltd.

Address before: 100041 B-0035, 2 floor, 3 building, 30 Shixing street, Shijingshan District, Beijing.

Applicant before: Tiktok vision (Beijing) Co.,Ltd.

CB02 Change of applicant information
GR01 Patent grant
GR01 Patent grant