Program testing method and device, computer equipment and nonvolatile storage medium

By determining the detection points in the program and inserting the detection code, a highly targeted test sample is generated, which solves the problem of blindness and low effectiveness of traditional testing methods, and efficient positioning and analysis of the program is achieved.

CN119003353APending Publication Date: 2024-11-22STATE GRID BEIJING ELECTRIC POWER CO +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411086695.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-08
Publication Date
2024-11-22

AI Technical Summary

Technical Problem

Traditional program testing methods cannot generate highly targeted test samples, resulting in strong blindness and low effectiveness of test results, making it difficult to accurately locate and analyze unknown security vulnerabilities in the program.

Method used

By obtaining the program to be tested and the first test sample, determining the detection point and inserting the detection code into the program to be tested, generating the second test sample, and testing based on the data during execution, achieving highly targeted testing.

Benefits of technology

A relatively unique test sample was generated, which improved the targetedness and effectiveness of the test, and enabled the more accurate location of errors and vulnerabilities in the program.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119003353A_ABST
    Figure CN119003353A_ABST
Patent Text Reader

Abstract

The invention discloses a program testing method and device and computer equipment. The method comprises the following steps: acquiring a to-be-tested program and a first test sample; determining a detection point in the to-be-detected program according to a function called in the to-be-detected program; based on the detection point, inserting a detection code into the to-be-detected program to obtain a modified to-be-detected program; inputting the first test sample into the modified to-be-tested program, and outputting data generated when the to-be-tested program is executed by the detection code; generating a second test sample based on data generated when the to-be-tested program is executed; and testing the to-be-tested program according to the second test sample to obtain a test result. According to the method, the technical problems of high blindness and low effectiveness of a program test result due to the fact that a test sample with high pertinence cannot be generated in a traditional method are solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of program testing, and in particular to a program testing method, device, computer equipment and non-volatile storage medium. Background Art

[0002] Program testing is an important part of the software development process. Its main purpose is to discover and verify errors (bugs), defects (Defects) or places that do not meet the requirements in the software. Through testing, it can be ensured that the software can run correctly under the expected environment and conditions and meet the user's needs and specifications.

[0003] However, due to the differences in the design and implementation methods of each manufacturer's program, some non-standard design and implementation methods may cause unknown security vulnerabilities in the program. Since it is impossible to see through the internal operating mechanism of the program implementation, traditional program testing methods usually need to send many unexpected and meaningless test samples to the system to accidentally trigger system crashes and other problems. Even if problems are found, it is difficult to accurately locate and analyze the root cause of the vulnerability. Therefore, traditional program testing methods generally have problems such as blindness and difficulty in positioning.

[0004] To address the above-mentioned problems, no effective solution has been proposed yet. Summary of the invention

[0005] The embodiments of the present invention provide a program testing method, apparatus, computer equipment and non-volatile storage medium to at least solve the technical problem that the traditional method cannot generate highly targeted test samples, resulting in the program testing results being highly blind and having low effectiveness.

[0006] According to one aspect of an embodiment of the present invention, a program testing method is provided, comprising: obtaining a program to be tested and a first test sample; determining a detection point in the program to be tested based on a function called in the program to be tested; inserting a detection code into the program to be tested based on the detection point to obtain a modified program to be tested; inputting the first test sample into the modified program to be tested, and having the detection code output data generated when the program to be tested is executed; generating a second test sample based on the data generated when the program to be tested is executed; and testing the program to be tested based on the second test sample to obtain a test result.

[0007] Optionally, determining a detection point in the program under test according to a function called in the program under test includes: determining a function matching a predetermined function as a target function among the functions called by the program under test; and determining a location in the program under test where the target function is called as a detection point.

[0008] Optionally, before determining the detection point in the program under test according to the function called in the program under test, the method further includes: determining a binary file corresponding to the program under test; and determining the function called in the program under test according to the binary file corresponding to the program under test.

[0009] Optionally, based on the detection point, inserting the detection code into the program to be tested to obtain a modified program to be tested includes: inserting the detection code at the location of the detection point to obtain the modified program to be tested.

[0010] Optionally, generating a second test sample based on data generated when the program to be tested is executed includes: determining abnormal features based on the data generated when the program to be tested is executed; and modifying the first test sample according to the abnormal features to obtain the second test sample.

[0011] Optionally, generating a second test sample based on data generated when the program to be tested is executed also includes: determining abnormal features based on the data generated when the program to be tested is executed; and generating a second test sample for testing the abnormal features.

[0012] According to another aspect of an embodiment of the present invention, a non-volatile storage medium is provided, the non-volatile storage medium including a stored program, wherein when the program is running, the device where the non-volatile storage medium is located is controlled to execute any one of the above-mentioned program testing methods.

[0013] According to yet another aspect of an embodiment of the present invention, a computer device is provided. The computer device includes a processor, and the processor is used to run a program. When the program is run, any one of the above program testing methods is executed.

[0014] According to yet another aspect of an embodiment of the present invention, a computer program product is provided, including a computer program, and when the computer program is executed by a processor, any one of the above-mentioned program testing methods is implemented.

[0015] In an embodiment of the present invention, a program to be tested and a first test sample are obtained; detection points are determined in the program to be tested according to functions called in the program to be tested; detection codes are inserted into the program to be tested based on the detection points to obtain a modified program to be tested; the first test sample is input into the modified program to be tested, and the detection code outputs data generated when the program to be tested is executed; a second test sample is generated based on the data generated when the program to be tested is executed; and the program to be tested is tested according to the second test sample to obtain test results, thereby achieving the purpose of generating highly targeted test samples based on relatively unique data generated by the program to be tested during the program testing process that is different from other programs, thereby achieving the technical effect of performing highly targeted tests on the program to be tested, and further solving the technical problem that the traditional method cannot generate highly targeted test samples, resulting in highly blind program test results and low effectiveness. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of this application. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:

[0017] Figure 1 A hardware structure block diagram of a computer terminal for implementing a program testing method is shown;

[0018] Figure 2 is a flowchart of a program testing method provided according to an embodiment of the present invention;

[0019] Figure 3 is a schematic diagram of a program testing device provided according to an optional embodiment of the present invention. DETAILED DESCRIPTION

[0020] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.

[0021] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0022] According to an embodiment of the present invention, a method embodiment of program testing is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.

[0023] The method embodiment provided in the first embodiment of the present application can be executed in a mobile terminal, a computer terminal or a similar computing device. Figure 1 FIG. 1 shows a hardware structure block diagram of a computer terminal for implementing a program testing method. Figure 1 As shown, the computer terminal 10 may include one or more (102a, 102b, ..., 102n are used to illustrate) processors (the processor may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA), a memory 104 for storing data. In addition, it may also include: a display, an input / output interface (I / O interface), a universal serial bus (USB) port (which may be included as one of the ports of the BUS bus), a network interface, a power supply and / or a camera. It can be understood by those skilled in the art that Figure 1 The structure shown is only for illustration and does not limit the structure of the above electronic device. Figure 1 More or fewer components as shown, or with Figure 1 Different configurations are shown.

[0024] It should be noted that the one or more processors and / or other data processing circuits described above may generally be referred to herein as "data processing circuits". The data processing circuits may be embodied in whole or in part as software, hardware, firmware, or any other combination thereof. In addition, the data processing circuit may be a single independent processing module, or may be incorporated in whole or in part into any of the other components in the computer terminal 10. As described in the embodiments of the present application, the data processing circuit acts as a processor control (e.g., selection of a variable resistor terminal path connected to an interface).

[0025] The memory 104 can be used to store software programs and modules of application software, such as the program instruction / data storage device corresponding to the program testing method in the embodiment of the present invention. The processor executes various functional applications and data processing by running the software programs and modules stored in the memory 104, that is, the program testing method of the above-mentioned application is realized. The memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 104 may further include a memory remotely arranged relative to the processor, and these remote memories may be connected to the computer terminal 10 via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0026] The display may be, for example, a touch screen liquid crystal display (LCD) that enables a user to interact with a user interface of the computer terminal 10 .

[0027] Program testing is also widely used in the field of power technology. For example, it can be applied to the compliance inspection process of new equipment entering the substation. It can conduct a comprehensive test on the network protocol processing of the equipment to verify whether it complies with safety regulations. It can also perform binary stub fuzz testing on the target process in the laboratory experimental equipment. Under the premise of ensuring that the system service is not interrupted, a large amount of automatically generated random test data is used to continuously fuzz the target protocol. When the protocol processing vulnerability is exploited, the system crash, bypass and other effects are demonstrated in a real-time environment, which is conducive to network security teaching and practical training.

[0028] However, the communication protocols used in the field of power technology usually have some adaptive modifications based on the characteristics of the power field, which makes them different from general communication protocols, and thus makes the program for implementing the communication protocol different from ordinary communication protocols. When using test samples consistent with general communication protocols to test the communication protocols in the field of power technology, the problem of low program testing efficiency will arise.

[0029] In order to solve the above problems, Figure 2 is a flow chart of a program testing method provided according to an embodiment of the present invention, such as Figure 2 As shown, the method comprises the following steps:

[0030] Step S202, obtaining a program to be tested and a first test sample;

[0031] In this step, the program to be tested refers to a software or system used for equipment communication in the field of power technology that has been developed or partially completed but has not been fully tested and verified. It needs to pass a series of tests to ensure that its functions and safety meet the established standards. The first test sample refers to the test data automatically generated by the test script, which can be randomly generated binary data, abnormal or boundary value data, formatted incorrect or incomplete data, and intentionally constructed incorrect data. The first test sample can also be a more general test sample set for ordinary communication protocols.

[0032] Step S204, determining a detection point in the program to be tested according to the function called in the program to be tested;

[0033] In this step, the functions called in the program to be tested are the basis for realizing the functions of the program, and several functions together constitute the program; at this time, by analyzing the functions called in the program to be tested, it is possible to identify which functions or code segments are the focus of the test, which may include interfaces for interacting with external systems, complex algorithm implementations, error handling logic, performance-sensitive code segments, etc. Then it can be determined which functions in the program need to be tested, and the locations related to these functions are the detection points.

[0034] Step S206, inserting detection code into the program to be tested based on the detection point to obtain a modified program to be tested;

[0035] In this step, since the functions near the detection point need to be detected intensively, in order to collect information or perform specific test operations during the program testing process, it is necessary to insert additional detection code at the detection point in the binary code of the program to obtain the modified program to be tested. Through the detection code, the program at the key position can be monitored more comprehensively. The detection code is the code added to achieve specific testing, monitoring or debugging tasks, and is responsible for collecting information when the program is executed to these points, such as variable values, number of function calls, execution time, etc. The detection code is usually designed to minimize the impact on the original program logic and is easy to switch (for example, whether to enable the detection is controlled by a configuration file or command line parameter).

[0036] Step S208, inputting the first test sample into the modified program to be tested, and having the detection code output data generated when the program to be tested is executed;

[0037] In this step, when the modified program to be tested is executed, the detection code will work as expected and output or record the data generated when the program is executed. This data may include but is not limited to: function call sequence, parameter values, return values, register parameters, memory read and write status, possible abnormal signals, etc. The detection code can output this running status information in the form of logging.

[0038] Step S210, generating a second test sample based on data generated when the program to be tested is executed;

[0039] In this step, by analyzing various types of running status information when the program is running, restoring the process and behavior when the program is running, finding the more unique data generated when the program is running, and based on the more unique data generated, generating a series of test data for targeted testing of the program to be tested. In other words, based on the data collected from the execution of the program to be tested after the modification in the previous step, these data can be further analyzed to discover potential test scenarios or boundary conditions. These newly discovered scenarios or conditions can be used as the second test sample to test the program in a more in-depth and targeted manner.

[0040] Step S212: testing the program to be tested according to the second test sample to obtain a test result.

[0041] In this step, the second test sample is input into the modified program to be tested, and various running status information of the program is monitored by detecting the code. The more unique data generated during the program testing process is analyzed and located to find out the errors or loopholes of the program to be tested and form a test result.

[0042] Through the above steps, the purpose of generating highly targeted test samples based on the relatively unique data generated by the program to be tested during the program testing process that is different from other programs is achieved, thereby achieving the technical effect of conducting highly targeted tests on the program to be tested, and further solving the technical problem that the traditional method cannot generate highly targeted test samples, resulting in highly blind and low effectiveness of program testing results.

[0043] As an optional embodiment, determining a detection point in the program under test according to the function called in the program under test includes: determining a function matching a predetermined function as a target function among the functions called by the program under test; and determining a location in the program under test where the target function is called as a detection point.

[0044] Optionally, before analyzing and preparing for software testing, the tester or developer has identified one or more specific functions in the program to be tested as predetermined functions, which are functions that play a very important role in the program and have special importance or potential problem risks for testing. Therefore, when parsing the program, the location where the predetermined function is called can be determined as the detection point.

[0045] The predetermined functions can be determined by the core functions of the program. The predetermined functions can be the core function implementation part of the program and have an important impact on the overall behavior or performance of the program. Secondly, in order to ensure the comprehensiveness of the test, the tester needs to ensure that the critical paths and logical branches of the program are covered. Therefore, the predetermined functions are often located on these critical paths, so setting detection points at their call locations helps to achieve higher test coverage.

[0046] In other words, the predetermined function is related to the purpose of this software test, and can be a code segment in the program that implements the core functions, a code segment that handles exceptions or errors, a code segment that interacts with the database, and a code segment that processes sensitive data, etc.; the target function refers to a code segment in the program to be tested that has the same or similar function to the predetermined function; inserting the detection code at the location where the target function is called in the program to be tested can obtain various types of data representing the program's running status when the program is running.

[0047] As an optional embodiment, before determining the detection point in the program under test according to the function called in the program under test, it also includes: determining the binary file corresponding to the program under test; and determining the function called in the program under test according to the binary file corresponding to the program under test.

[0048] Optionally, after obtaining the binary file, the tester or developer can use specialized tools or techniques to analyze the file to determine the functions contained therein and the calling relationships between them. These tools may include disassemblers, debuggers, binary analysis tools, etc. Through these tools, the symbol information (if available), function call instructions, etc. in the binary file can be parsed to construct the function call graph or control flow graph of the program.

[0049] The binary file is the compiled result of the program and can be run directly on the operating system. By analyzing the binary file of the program to be tested, the basic structure and execution flow of the program to be tested can be determined, and the functions called in the program to be tested can be located.

[0050] As an optional embodiment, based on the detection point, the detection code is inserted into the program to be tested to obtain the modified program to be tested, including: inserting the detection code at the location of the detection point to obtain the modified program to be tested.

[0051] Optionally, the detection point refers to the location of the target function in the binary file of the program to be tested, which may be the entry point of the target function; the entry point of the target function refers to the location in the binary file where the target function starts to execute; the detection code is a code segment in binary form, which may be code related to logging, performance monitoring, data collection, resource management, and exception capture; inserting the detection code refers to adding the detection code to the location of the target function in the binary file of the program to be tested.

[0052] As an optional embodiment, generating a second test sample based on data generated when the program to be tested is executed includes: determining abnormal characteristics based on the data generated when the program to be tested is executed; and modifying the first test sample according to the abnormal characteristics to obtain a second test sample.

[0053] Optionally, abnormal features refer to some manifestations of abnormal program operation, which may be program freezes, program runs for too long, program is unresponsive, program has no output, etc.; random, abnormal or boundary condition test data are input into the program to be tested, and various running status information of the program is captured by detecting the code, and the running status information is analyzed to determine the abnormal features of the program running process; the second test sample is obtained by modifying the first test sample, which may be changing the byte value of the first test sample, deleting or replacing the data segment of the first test sample, changing the data range or encoding format of the first test sample, etc.

[0054] As an optional embodiment, generating a second test sample based on data generated when the program to be tested is executed also includes: determining abnormal features based on the data generated when the program to be tested is executed; and generating a second test sample for testing the abnormal features.

[0055] Optionally, the tester or developer will first analyze the data generated when the program to be tested is executed, including but not limited to variable values, function call sequences, execution time, memory usage, etc. By analyzing this data, it is possible to try to identify abnormal features that are inconsistent with normal behavior. These abnormal features may indicate potential errors, performance issues, or security vulnerabilities in the program. Once the abnormal features are determined, new test samples, namely second test samples, can be constructed based on these features. These test samples are designed to specifically trigger or expose these abnormal behaviors in the program. For example, if a function returns an unexpected result under a specific input, a new test sample can be created that contains the specific input value that caused the unexpected result. By creating test samples for abnormal features, the behavior of the program under these specific conditions can be more effectively verified, thereby increasing the chance of discovering potential problems. In other words, if the abnormal features of the program during runtime are not covered by the first test sample, the first test sample cannot be directly modified to directly obtain the second test sample. It is necessary to use the sample generation script to regenerate a highly targeted second test sample so as to further test the abnormal features, which helps to discover potential errors in the program.

[0056] In order to realize automatic, flexible and efficient program testing, the present invention improves the relevant testing methods from the following aspects: various information of the tested program in the testing process is fed back in real time through the technology of inserting detection code, and by analyzing this information, a highly targeted test sample is generated, thereby improving the flexibility of program testing and solving the problem of blindness; the information obtained through the detection code guides the direction of change of the test sample, thereby achieving a higher test coverage rate and locating the problem point more accurately when the program fails; without changing the program source code, the detection code is embedded in the target binary program, and various types of running status information such as function call parameters, return values, system calls and register parameters, memory read and write status, possible abnormal signals, etc. are actively captured during its running, and this information is output through a custom log function, and the various status data associated with the same program running are parsed to restore the complete running behavior. This ability to accurately capture runtime information is helpful to reveal hidden error mechanisms in the program, analyze the causes of exceptions such as crashes and memory corruption, trace back the execution process to locate the problem code, and discover potential security vulnerabilities in the program.

[0057] It should be noted that, for the above-mentioned method embodiments, for the sake of simplicity, they are all described as a series of action combinations, but those skilled in the art should know that the present invention is not limited by the described action sequence, because according to the present invention, certain steps can be performed in other sequences or simultaneously. Secondly, those skilled in the art should also know that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present invention.

[0058] Through the description of the above implementation methods, those skilled in the art can clearly understand that the program testing method according to the above embodiment can be implemented by means of software plus a necessary general hardware platform, and of course can also be implemented by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), including a number of instructions for a terminal device (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods described in each embodiment of the present invention.

[0059] According to an embodiment of the present invention, a program testing device for implementing the above program testing method is also provided. Figure 3 is a structural block diagram of a program testing device provided according to an embodiment of the present invention. Figure 3 As shown, the program testing device includes: an acquisition module 41, a first processing module 42, a second processing module 43, a first testing module 44, a third processing module 45, and a second testing module 46. The program testing device is described below.

[0060] An acquisition module 41 is used to acquire a program to be tested and a first test sample;

[0061] A first processing module 42, connected to the acquisition module 41, is used to determine a detection point in the program to be tested according to a function called in the program to be tested;

[0062] A second processing module 43, connected to the first processing module 42, is used to insert a detection code into the program to be tested based on the detection point to obtain a modified program to be tested;

[0063] A first testing module 44, connected to the second processing module 43, is used to input the first testing sample into the modified program to be tested, and output the data generated when the program to be tested is executed by the detection code;

[0064] A third processing module 45, connected to the first testing module 44, is used to generate a second test sample based on the data generated when the program to be tested is executed;

[0065] The second testing module 46 is connected to the third processing module 45, and is used to test the program to be tested according to the second testing sample to obtain a testing result.

[0066] It should be noted that the acquisition module 41, the first processing module 42, the second processing module 43, the first test module 44, the third processing module 45, and the second test module 46 correspond to steps S202 to S212 in the embodiment, and the examples and application scenarios implemented by the multiple modules and the corresponding steps are the same, but are not limited to the contents disclosed in the above embodiment. It should be noted that the above modules, as part of the device, can be run in the computer terminal 10 provided in the embodiment.

[0067] An embodiment of the present invention may provide a computer device. Optionally, in this embodiment, the computer device may be located in at least one network device among multiple network devices of a computer network. The computer device includes a memory and a processor.

[0068] Among them, the memory can be used to store software programs and modules, such as the program instructions / modules corresponding to the program testing method and device in the embodiment of the present invention. The processor executes various functional applications and data processing by running the software programs and modules stored in the memory, that is, realizing the above-mentioned program testing method. The memory may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory may further include a memory remotely arranged relative to the processor, and these remote memories can be connected to the computer terminal via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0069] The processor can call the information and application stored in the memory through the transmission device to perform the following steps: obtain the program to be tested and the first test sample; determine the detection point in the program to be tested according to the function called in the program to be tested; based on the detection point, insert the detection code into the program to be tested to obtain the modified program to be tested; input the first test sample into the modified program to be tested, and the detection code outputs the data generated when the program to be tested is executed; based on the data generated when the program to be tested is executed, generate a second test sample; according to the second test sample, test the program to be tested to obtain the test result.

[0070] Optionally, the processor can also be used to perform the following steps: determine the detection point in the program under test according to the function called in the program under test, including: among the functions called by the program under test, determine the function that matches the predetermined function as the target function; determine the location where the target function is called in the program under test as the detection point.

[0071] Optionally, the processor can also be used to perform the following steps: before determining the detection point in the program under test according to the function called in the program under test, it also includes: determining the binary file corresponding to the program under test; determining the function called in the program under test according to the binary file corresponding to the program under test.

[0072] Optionally, the processor may also be used to perform the following steps: based on the detection point, inserting detection code into the program to be tested to obtain a modified program to be tested, including: inserting detection code at the location of the detection point to obtain the modified program to be tested.

[0073] Optionally, the processor can also be used to perform the following steps: generate a second test sample based on data generated when the program to be tested is executed, including: determining abnormal characteristics based on the data generated when the program to be tested is executed; modifying the first test sample according to the abnormal characteristics to obtain a second test sample.

[0074] Optionally, the processor can also be used to perform the following steps: generate a second test sample based on data generated when the program to be tested is executed, and also include: determine abnormal characteristics based on data generated when the program to be tested is executed; generate a second test sample for testing the abnormal characteristics.

[0075] By adopting the embodiment of the present invention, a program testing scheme is provided, which comprises obtaining a program to be tested and a first test sample; determining a detection point in the program to be tested according to a function called in the program to be tested; inserting a detection code into the program to be tested based on the detection point to obtain a modified program to be tested; inputting the first test sample into the modified program to be tested, and outputting data generated when the program to be tested is executed by the detection code; generating a second test sample based on the data generated when the program to be tested is executed; and testing the program to be tested according to the second test sample to obtain a test result, thereby achieving the purpose of generating a highly targeted test sample based on relatively unique data generated by the program to be tested during the program testing process that is different from other programs, thereby realizing the technical effect of performing a highly targeted test on the program to be tested, and further solving the technical problem that the traditional method cannot generate a highly targeted test sample, resulting in a highly blind and low effectiveness program test result.

[0076] A person of ordinary skill in the art can understand that all or part of the steps in the various methods of the above embodiments can be completed by instructing the hardware related to the terminal device through a program, and the program can be stored in a non-volatile storage medium, and the storage medium may include: a flash drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.

[0077] The embodiment of the present invention further provides a non-volatile storage medium. Optionally, in this embodiment, the non-volatile storage medium can be used to store the program code executed by the program testing method provided in the above embodiment.

[0078] Optionally, in this embodiment, the non-volatile storage medium may be located in any computer terminal in a computer terminal group in a computer network, or in any mobile terminal in a mobile terminal group.

[0079] Optionally, in this embodiment, the non-volatile storage medium is configured to store program code for executing the following steps: obtaining a program to be tested and a first test sample; determining a detection point in the program to be tested based on a function called in the program to be tested; inserting a detection code into the program to be tested based on the detection point to obtain a modified program to be tested; inputting the first test sample into the modified program to be tested, and having the detection code output data generated when the program to be tested is executed; generating a second test sample based on the data generated when the program to be tested is executed; and testing the program to be tested based on the second test sample to obtain a test result.

[0080] Optionally, the non-volatile storage medium is configured to store program code that is also used to perform the following steps: determining a detection point in the program to be tested based on a function called in the program to be tested, including: determining, among the functions called by the program to be tested, a function that matches a predetermined function as a target function; and determining a location in the program to be tested where the target function is called as a detection point.

[0081] Optionally, the non-volatile storage medium is configured to store program code that is also used to execute the following steps: before determining a detection point in the program to be tested based on a function called in the program to be tested, it also includes: determining a binary file corresponding to the program to be tested; determining the function called in the program to be tested based on the binary file corresponding to the program to be tested.

[0082] Optionally, the non-volatile storage medium is configured to store program code for executing the following steps: based on the detection point, inserting the detection code into the program to be tested to obtain a modified program to be tested, including: inserting the detection code at the location of the detection point to obtain the modified program to be tested.

[0083] Optionally, the non-volatile storage medium is configured to store program code that is also used to perform the following steps: generating a second test sample based on data generated when the program to be tested is executed, including: determining abnormal characteristics based on the data generated when the program to be tested is executed; and modifying the first test sample according to the abnormal characteristics to obtain a second test sample.

[0084] Optionally, the non-volatile storage medium is configured to store program code for executing the following steps: generating a second test sample based on data generated when the program to be tested is executed, and also including: determining abnormal characteristics based on data generated when the program to be tested is executed; generating a second test sample for testing the abnormal characteristics.

[0085] An embodiment of the present invention further provides a computer program product, including a computer program, which implements the steps of the program testing method in each embodiment of the present application when the computer program is executed by a processor.

[0086] The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.

[0087] In the above embodiments of the present invention, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0088] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of the units can be a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.

[0089] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple units. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.

[0090] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0091] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a non-volatile storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, server or network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, magnetic disk or optical disk and other media that can store program codes.

[0092] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principle of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.

Claims

1. A program testing method, characterized in that: include: Obtaining a program to be tested and a first test sample; Determining a detection point in the program to be tested according to a function called in the program to be tested; Based on the detection point, inserting detection code into the program to be tested to obtain a modified program to be tested; Inputting the first test sample into the modified program to be tested, and having the detection code output data generated when the program to be tested is executed; Generate a second test sample based on the data generated when the program to be tested is executed; The program to be tested is tested according to the second test sample to obtain a test result.

2. The method according to claim 1, characterized in that The step of determining a detection point in the program to be tested according to a function called in the program to be tested comprises: Among the functions called by the program to be tested, determining a function matching a predetermined function as a target function; The location where the target function is called in the program to be tested is determined as the detection point.

3. The method according to claim 2, characterized in that Before determining the detection point in the program to be tested according to the function called in the program to be tested, the method further includes: Determine the binary file corresponding to the program to be tested; According to the binary file corresponding to the program to be tested, a function called in the program to be tested is determined.

4. The method according to claim 1, characterized in that: The inserting detection code into the program to be tested based on the detection point to obtain a modified program to be tested includes: The detection code is inserted at the location of the detection point to obtain the modified program to be tested.

5. The method according to claim 1, characterized in that The generating a second test sample based on the data generated when the program to be tested is executed includes: Determining abnormal characteristics based on data generated when the program to be tested is executed; The first test sample is modified according to the abnormal feature to obtain the second test sample.

6. The method according to claim 1, characterized in that The generating a second test sample based on the data generated when the program to be tested is executed also includes: Determining abnormal characteristics based on data generated when the program to be tested is executed; The second test sample is generated for testing the abnormal feature.

7. A program testing device, characterized in that: include: An acquisition module, used for acquiring the program to be tested and the first test sample; A first processing module, configured to determine a detection point in the program to be tested according to a function called in the program to be tested; A second processing module is used to insert a detection code into the program to be tested based on the detection point to obtain a modified program to be tested; A first test module, used for inputting the first test sample into the modified program to be tested, and outputting data generated when the program to be tested is executed by the detection code; A third processing module, used to generate a second test sample based on the data generated when the program to be tested is executed; The second testing module is used to test the program to be tested according to the second testing sample to obtain a testing result.

8. A non-volatile storage medium, characterized in that: The non-volatile storage medium includes a stored program, wherein when the program is running, the device where the non-volatile storage medium is located is controlled to execute the program testing method according to any one of claims 1 to 6.

9. A computer device, characterized in that: include: Memory and processor, The memory stores a computer program; The processor is used to execute the computer program stored in the memory, and when the computer program is run, the processor executes the program testing method according to any one of claims 1 to 6.

10. A computer program product comprising computer instructions, characterized in that: The computer instructions are executed by a processor to implement the program testing method described in any one of claims 1 to 6.