CN111984524A - Fault injection method, fault simulation method, fault injection device, and storage medium - Google Patents

Fault injection method, fault simulation method, fault injection device, and storage medium Download PDF

Info

Publication number
CN111984524A
CN111984524A CN201910437874.6A CN201910437874A CN111984524A CN 111984524 A CN111984524 A CN 111984524A CN 201910437874 A CN201910437874 A CN 201910437874A CN 111984524 A CN111984524 A CN 111984524A
Authority
CN
China
Prior art keywords
fault
application system
injected
fault injection
information
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201910437874.6A
Other languages
Chinese (zh)
Inventor
周鹏飞
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Alibaba Group Holding Ltd
Original Assignee
Alibaba Group Holding 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 Alibaba Group Holding Ltd filed Critical Alibaba Group Holding Ltd
Priority to CN201910437874.6A priority Critical patent/CN111984524A/en
Publication of CN111984524A publication Critical patent/CN111984524A/en
Pending legal-status Critical Current

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/3604Software analysis for verifying properties of programs
    • G06F11/3612Software analysis for verifying properties of programs by runtime analysis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/362Software debugging
    • G06F11/3636Software debugging by tracing the execution of the program
    • 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

Abstract

The embodiment of the invention discloses a fault injection method, a fault simulation method, a fault injection device and a storage medium, wherein the fault injection method comprises the following steps: acquiring fault injection information, wherein the fault injection information comprises: information of an application system to be injected with a fault, fault behavior information to be injected and fault injection breakpoint position information; executing a fault injection configuration instruction based on the fault injection information, and configuring fault injection parameters of the application system, wherein the fault injection parameters comprise: parameters of an application system to be injected with a fault, parameters of a fault behavior to be injected and breakpoint position parameters of the fault behavior in a source code of the application system; and when the process of the application system runs to a breakpoint position, running the fault source code based on the configured fault source code corresponding to the breakpoint position. By adopting the scheme of the embodiment of the invention, the software reliability verification efficiency of the application system can be improved.

Description

Fault injection method, fault simulation method, fault injection device, and storage medium
Technical Field
The invention relates to the technical field of computer software, in particular to a fault injection method, a fault simulation method, a fault injection device and a storage medium.
Background
In order to find a fault and actively correct the fault before the fault does not occur, whether the program to be verified generates an abnormal condition or not can be checked in a mode of actively injecting the fault into the program (code) of the software system. By actively introducing the fault, the fault of the software system can be detected in advance, so that the system error can be simulated in a short time, and the system failure data can be obtained to evaluate the fault tolerance and stability of the program to be verified.
The existing fault injection schemes mainly have two types: one is to simulate the fault of a computer such as a server itself or an operating system, such as simulating CPU utilization rate being too high, disk full, disk IO interface being busy, network card abnormality, etc. The other is fault injection aiming at the process of the application system, the fault is injected into the application system to change the execution logic or effect of the program, but the source code and the compiling package of the application are not changed, and the operating system is not influenced.
Currently, there is a fault simulation in the process of an application system for Java programs, which is implemented by a virtual machine tool interface (JVMTI).
The inventor finds that a software application system written in Java language needs to be interpreted and executed by a virtual machine, is complex to implement, is only suitable for application programs with a virtual machine structure, and has limited applicable languages, and for application systems written in non-Java language, a fault injection mode for Java programs cannot be adopted for fault injection and fault simulation. Therefore, how to realize the in-process fault simulation of the application system to improve the software reliability verification efficiency is an urgent technical problem to be solved.
Disclosure of Invention
In view of this, embodiments of the present invention provide a method, a device and a storage medium for implementing fault injection in a process of an application system, which can improve software reliability verification efficiency of the application system.
In one aspect of the embodiments of the present invention, a fault injection method is provided, including:
acquiring fault injection information, wherein the fault injection information comprises: information of an application system to be injected with a fault, fault behavior information to be injected and fault injection breakpoint position information;
Executing a fault injection configuration instruction based on the fault injection information, and configuring fault injection parameters of the application system, wherein the fault injection parameters comprise: parameters of an application system to be injected with a fault, parameters of a fault behavior to be injected and breakpoint position parameters of the fault behavior in a source code of the application system;
and when the process of the application system runs to a breakpoint position, running the fault source code based on the configured fault source code corresponding to the breakpoint position.
Optionally, the application system to be fault-injected is in a running state, and the information of the application system to be fault-injected includes: process identification information of the application system to be fault injected; the parameters of the application system to be injected with the fault comprise: and identifying the process of the application system to be injected with the fault.
Optionally, the information of the application system to be fault injected further includes extended class library information; the parameters of the application system to be injected with the fault further include: the starting file position and name of the application system, and the starting loading configuration parameters of the extended class library of the application system.
Optionally, the application system to be fault-injected is in a non-running state, and the information of the application system to be fault-injected includes: the starting file position and name of the application system to be injected with the fault; the parameters of the application system to be injected with the fault comprise: and the starting file position and the name of the application system to be injected with the fault.
Optionally, the information of the application to be fault injected further includes extended class library information; the parameters of the application system to be injected with the fault further include: and starting and loading configuration parameters by the extended class library of the application system.
Optionally, the information of the application system to be injected with the fault further includes: fault injection is carried out on the information of the main process or the sub process of the application system to be injected with the fault; the parameters of the application system to be injected with the fault further include: fault injection into the main process of the application system or configuration parameters of all sub-processes of the application system.
Optionally, after configuring the fault injection parameters of the application system, the method further includes: and executing preset fault configuration validation operation.
Optionally, the executing, based on the fault injection information, a fault injection configuration instruction to configure the fault injection parameters of the application system includes at least one of:
based on the fault injection information, when a step jump execution instruction triggered by user operation is received, gradually configuring fault injection parameters of the application system according to a preset configuration sequence;
and automatically and gradually configuring the fault injection parameters of the application system according to a preset configuration sequence under the triggering of a preset instruction or program based on the fault injection information.
Optionally, the source code of the application system and the failure source code include: code written in a high-level language and/or code that is decompiled based on an executable file of an application system implemented in the high-level language.
Optionally, the fault injection method is executed based on a preset GDB debug command or a Ptrace system call function.
Optionally, when the fault injection method is executed based on a preset GDB debug instruction, before configuring a breakpoint location parameter of the fault behavior in source code of an application system, the method further includes: closing the GDB paginated printing program to execute the result function.
In another aspect of the embodiments of the present invention, a fault simulation method is provided, including:
acquiring an identifier of a process of an application system with an injected fault based on parameters of the application system with the injected fault;
loading the process of the application system with the fault injected as a sub-process based on the identification of the process of the application system with the fault injected;
when a signal of executing to a breakpoint position transmitted by the process of the application system with the fault injected is received, configuring corresponding fault behavior parameters based on the configured breakpoint, and transmitting corresponding execution instructions to the process of the application system, so that the process of the application system runs the fault source code corresponding to the fault behavior parameters at the breakpoint position according to the execution instructions.
Optionally, the loading, based on the identifier of the process of the fault-injected application system, the process of the fault-injected application system as a child process includes: and loading the main process of the application system with the fault injected as a sub-process based on the identification of the process of the application system with the fault injected, wherein the main process of the application system comprises all sub-processes.
Optionally, before acquiring, based on the parameter of the fault-injected application system, the identifier of the process of the fault-injected application system, the method further includes: and executing corresponding fault configuration validation operation on the application system with the fault injection configuration completed based on the running state of the application system during fault injection.
Optionally, the fault simulation method further includes: in the running process of the application system, when a preset separation command is received, based on the identification of the injected fault contained in the preset separation command, the fault source code corresponding to the identification of the injected fault is separated from the process of the application system.
Optionally, the fault simulation method further includes: when a preset fault injection device unloading instruction is received, all faults injected by the fault injection device are unloaded, and the process of the fault injection device is removed from a process list of an operating system.
In another aspect of the embodiments of the present invention, there is also provided a fault injection apparatus, including:
a fault injection information obtaining unit adapted to obtain fault injection information, the fault injection information including: information of an application system to be injected with a fault, fault behavior information to be injected and fault injection breakpoint position information;
a fault injection configuration unit adapted to execute a fault injection configuration instruction based on the fault injection information acquired by the fault injection information acquisition unit, and configure fault injection parameters of the application system, where the fault injection parameters include: parameters of an application system to be injected with a fault, parameters of a fault behavior to be injected and breakpoint position parameters of the fault behavior in a source code of the application system;
and the fault running unit is suitable for running the fault source code based on the fault source code corresponding to the breakpoint position configured by the fault injection configuration unit when the process of the application system runs to the breakpoint position.
In another aspect of the embodiments of the present invention, there is provided another fault injection apparatus, including:
the application system information acquisition unit is suitable for acquiring the process identifier of the application system with the fault injected based on the parameters of the application system with the fault injected;
The process loading unit is suitable for loading the process of the application system with the fault injected as a sub-process based on the identification of the process of the application system with the fault injected;
and the fault simulation unit is suitable for transmitting a corresponding execution instruction to the process of the application system based on the configured fault behavior parameter corresponding to the breakpoint position when receiving a signal transmitted by the process of the application system injected with the fault and executed to the breakpoint position, so that the process of the application system runs the fault source code corresponding to the fault behavior parameter at the breakpoint position according to the execution instruction.
In another aspect of the embodiments of the present invention, a computer-readable storage medium is further provided, on which computer instructions are stored, and when the computer instructions are executed, the steps of the fault injection method according to any one of the foregoing embodiments are performed.
In yet another aspect of the embodiments of the present invention, a computer-readable storage medium is further provided, on which computer instructions are stored, and when the computer instructions are executed, the steps of the fault simulation method according to any one of the foregoing embodiments are executed.
By adopting the fault injection scheme in the embodiment of the invention, after the fault injection information is obtained, a fault configuration instruction can be executed based on the fault injection information, and the configuration of the fault injection parameters of the application system comprises the following steps: the method comprises the steps that parameters of an application system to be subjected to fault injection, parameters of fault behaviors to be injected, breakpoint position parameters of the fault behaviors in source codes of the application system and the like are obtained, and then when a process of the application system runs to the breakpoint position, the fault source codes can be run based on the configured fault source codes corresponding to the breakpoint position, so that fault injection and fault simulation in the process of the application system can be achieved, and the software reliability verification efficiency of the application system can be greatly improved. Moreover, by adopting the fault injection scheme of the embodiment of the invention, the injected fault source code cannot be compiled with the source code of the application system, so that the source code of the application system cannot be polluted.
Further, when it is determined that the application system is in the running state, in the process of configuring the injection fault, when the information of the application system to be injected with the fault includes the information of the extended class library, the start file position and the name of the application system to be injected with the fault may be configured, and the extended class library loading configuration parameters of the application system to be injected with the fault may be configured, so that the application system loads the extended class library corresponding to the information of the extended class library when starting, and thus, according to whether the application system to be injected with the fault actually includes the extended class library or not, the application system including the corresponding extended class library or not may be set in the process of simulating the fault, which may more truly simulate the running environment of the application system, and improve the reliability and the validity of the fault simulation verification result.
Further, in the fault injection process, based on the information about whether the fault to be injected into the main process or the subprocess of the application system is injected into the information about the main process or the subprocess of the application system, the fault to be injected into the main process or the subprocess of the application system is configured, and the fault to be injected into all the subprocesses of the application system is configured as required, so that fault simulation with finer granularity of the application system can be realized, system bugs are avoided, and the reliability and effectiveness of the fault simulation verification result are improved.
Further, based on the acquired fault injection information, when a step jump execution instruction triggered by a user operation is received, the fault injection parameters of the application system may be configured step by step according to a preset configuration sequence. By adopting the scheme, a user can gradually configure the fault code to be injected of the application system under the guidance of a preset configuration sequence according to needs, so that the operation and debugging are facilitated.
Further, the fault injection parameters of the application system may be automatically configured step by step according to a preset configuration sequence under the trigger of a preset instruction or program based on the acquired fault injection information. By adopting the scheme, the in-process fault injection of the application system can be automatically realized based on the fault injection information input by the user, the fault injection efficiency can be further improved, and fault injection errors caused by manual configuration can be avoided.
Furthermore, the source code of the application system and the fault source code may be codes written in a high-level language, or codes obtained by decompiling an executable file of the application system implemented based on the high-level language, so that the fault injection and fault simulation scheme may support in-process fault injection and simulation of the application system implemented in multiple programming languages, and has wide applicability.
By adopting the fault simulation scheme of the embodiment of the invention, the identification of the process of the application system with the fault injected can be obtained based on the parameter of the application system with the fault injected, the process of the application system with the fault injected is loaded as a sub-process based on the identification of the process of the application system with the fault injected, and when a signal that the process of the application system with the fault injected is executed to a breakpoint position is received, the corresponding fault behavior parameter can be configured based on the configured breakpoint, and a corresponding execution instruction is transmitted to the process of the application system, so that the process of the application system runs the fault code corresponding to the fault behavior parameter at the breakpoint position according to the execution instruction. As can be seen from the above fault simulation process, the fault source code is not compiled with the source code of the application system, so that the injected fault does not contaminate the source code of the application system.
Furthermore, the main process of the application system with the fault injected can be loaded as a sub-process based on the identification of the process of the application system with the fault injected, and the main process of the application system comprises all sub-processes, so that the fault can be injected into the main process of the application system and the sub-processes of the application system by adopting the scheme, thereby realizing the fault simulation with finer granularity of the application system, avoiding the generation of system bugs and improving the reliability and the effectiveness of the fault simulation verification result.
Furthermore, in the running process of the application system, the fault source code is separated from the process of the application system based on the received preset separation command, and the fault source code can be removed without restarting the application system, so that the fault simulation efficiency can be further improved.
Further, when a preset unloading instruction of the fault injection device is received, all faults injected by the fault injection device are automatically unloaded, and the process of the fault injection device is removed from the process list of the operating system, so that the source codes of the application system are not polluted in the whole fault injection and simulation process, the normal operation of the codes of the application system is not influenced, and the application system can be really and reliably operated.
Drawings
FIG. 1 shows a flow chart of a fault injection method in an embodiment of the invention;
FIG. 2 is a flow chart of a fault injection method of an application system in a running state according to an embodiment of the present invention;
FIG. 3 is a flow chart illustrating a fault injection configuration method in an embodiment of the invention;
FIG. 4 is a flowchart illustrating a method for configuring an extended class library during fault injection according to an embodiment of the present invention;
FIG. 5 is a flowchart illustrating a method for configuring a sub-process during fault injection according to an embodiment of the present invention;
FIG. 6 is a flowchart illustrating a fault injection method for an application system in a non-running state according to an embodiment of the present invention;
FIG. 7 is a flow chart illustrating another fault injection configuration method in an embodiment of the invention;
FIG. 8 is a flowchart illustrating another method for configuring an extended class library during fault injection in an embodiment of the present invention;
FIG. 9 is a flowchart illustrating another method for configuring a sub-process during fault injection according to an embodiment of the present invention;
FIG. 10 is a flow chart of a fault simulation method in an embodiment of the invention;
FIG. 11 is a schematic diagram of a fault injection apparatus according to an embodiment of the present invention;
fig. 12 is a schematic structural diagram showing another fault injection apparatus according to an embodiment of the present invention.
Detailed Description
As described in the background art, how to implement in-process fault injection and fault simulation of an application system to improve software reliability verification efficiency is a technical problem to be solved urgently.
In view of the above technical problems, an aspect of the embodiments of the present invention provides a fault injection scheme, which may execute a fault injection configuration instruction based on acquired fault injection information, configure fault injection parameters of the application system, including parameters of the application system to be injected with a fault, parameters of a fault behavior to be injected, breakpoint position parameters of a fault behavior in a source code of the application system, and the like, and run the fault source code based on a configured fault source code corresponding to a breakpoint position when a process of the application system runs to the breakpoint position, so that injection and fault simulation of a fault of the application system may be implemented, and further, software reliability verification efficiency of the application system may be greatly improved.
The fault injection scheme does not need to be based on JVMTI, and can be suitable for the reliability verification of codes written in various high-level languages and the verification of codes after the decompilation of executable files of an application system realized based on the high-level languages. Moreover, by adopting the fault injection scheme of the embodiment of the invention, the injected fault source code cannot be compiled with the source code of the application system, so that the source code of the application system cannot be polluted.
Referring to a flowchart of a fault injection method in the embodiment of the present invention shown in fig. 1, in the embodiment of the present invention, a process of injecting a fault into an application system may be implemented by the following steps:
s11, acquiring fault injection information, wherein the fault injection information comprises: and the information of the application system to be injected with the fault, the information of the fault behavior to be injected and the position information of the fault injection breakpoint.
S12, executing a fault injection configuration instruction based on the fault injection information, and configuring fault injection parameters of the application system, where the fault injection parameters include: the parameters of the application system to be injected with the fault, the parameters of the fault behavior to be injected and the breakpoint position parameters of the fault behavior in the source code of the application system.
S13, when the process of the application system runs to a breakpoint position, the fault source code is run based on the configured fault source code corresponding to the breakpoint position.
By adopting the scheme, the fault configuration instruction can be executed based on the fault injection information acquired by the fault, the fault injection parameters of the application system are configured, and the fault injection parameters comprise the parameters of the application system to be injected with the fault, the parameters of the fault behavior to be injected, the parameters of the breakpoint position of the fault behavior in the source code of the application system and the like. Moreover, by adopting the fault injection scheme, the injected fault source code cannot be compiled with the source code of the application system, so that the source code of the application system cannot be polluted.
For a better understanding and realization of the embodiments of the invention, the following detailed description is given by way of specific application scenarios with reference to the accompanying drawings.
When the application system is in the running state, the embodiment of the invention can be adopted to carry out fault injection. Referring to the flowchart of the fault injection method of the application system in the running state of fault injection shown in fig. 2, in the embodiment of the present invention, the following fault injection manner may be adopted:
s21, acquiring fault injection information, wherein the fault injection information comprises: the fault injection method comprises the following steps of process identification information of an application system to be injected with a fault, fault behavior information to be injected and fault injection breakpoint position information.
In specific implementation, a corresponding fault injection information input interface may be set to input or select the fault injection information, or the fault injection information may be acquired by the fault injection interface. For example, a user may request a command to include corresponding fault injection information through a preset fault injection interface, such as obtaining the fault injection information through an http get request.
When the application system to be injected with a fault is in a running state, the information of the application system to be injected with a fault may include: the process identification information of the application system to be injected with the fault may be, for example, a name of the application system to be injected with the fault.
In a specific implementation, according to a requirement for fault simulation verification and actual characteristics of the application system, the information of the application system to be injected with the fault may further include one or more of extended class library information of the application system, information of whether the fault is injected into a main process or a sub-process of the application system to be injected with the fault, and the like, and for example, the information may include one or more of extended class library identification information, identification information of whether the fault is injected into only the main process of the application system or into all sub-processes of the application system, and the like.
In a specific implementation, the fault behavior information to be injected may be a name, a storage address, or other unique identifier of the fault behavior.
In a specific implementation, the fault injection breakpoint position information may be specific position information of which line of the source code of the application system to be injected with the fault source code to be injected is in.
When the application system to be fault-injected is in a running state, the process of the application system to be fault-injected may be obtained based on the process identification information of the application system to be fault-injected.
And S22, executing a fault injection configuration instruction based on the acquired fault injection information, and configuring the fault injection parameters of the application system, wherein the parameters of the application system to be injected with the fault include the process identification of the application system to be injected with the fault.
In a specific implementation, the fault injection configuration may be performed in a step-by-step configuration manner according to a pre-configuration sequence.
In specific implementation, a debugging tool such as GDB or a system call function such as Ptrace may be used for fault injection configuration. The GDB is a debugging tool under Unix and Unix-like. The Ptrace System Call function provides a way for one process (the "tracer") to supervise and control another process (the "tracee"), and can check and change data in the memory and registers of the "tracee" process, which can be used to implement breakpoint debugging and system call tracing.
After the fault injection configuration is completed, the fault injection configuration can be directly validated, or a preset validation operation is executed, so that the fault injection configuration is validated. For example, when the application system is in a running state, after completing injecting the fault into the process of the application system, the application system may be restarted, so that the fault injection configuration is enabled. It will be appreciated that restarting the application system is not the only way to validate the application system fault injection configuration. In particular implementations, other fault injection configuration validation approaches may also be employed.
In particular implementations, fault injection configuration may be performed by manual step-by-step configuration or by automated configuration.
Specifically, for manual configuration, the following method can be adopted: and based on the acquired fault injection information, gradually configuring the fault injection parameters of the application system according to a preset configuration sequence when a step jump execution instruction triggered by user operation is received. And after configuration is completed, when a restart instruction is received, the application system can be restarted, so that the fault injection configuration is effective.
In a manual configuration manner, in a specific implementation, after a user can input fault injection information in the fault injection device of the embodiment of the present invention, and then configure one fault injection parameter, the next fault injection parameter is configured according to a next skip trigger button of the fault injection device or a corresponding operation instruction. In the fault injection configuration process, the previous step can be returned to for modification. And after all the injection configurations are finished and stored, the user can click a restart button or trigger a restart key to restart the application system, so that the fault injection configuration is effective.
And by adopting a manual fault injection configuration mode, a user can gradually configure the fault injection parameters of the application system under the guidance of a preset configuration sequence according to needs, so that the operation and debugging are facilitated.
For the automated fault injection configuration, the following can be adopted: and automatically and gradually configuring the fault injection parameters of the application system according to a preset configuration sequence under the triggering of a preset instruction or program on the basis of the acquired fault injection information, and automatically executing a restart operation after the configuration is completed to restart the application system.
By adopting an automatic fault injection configuration mode, the fault injection device provided by the embodiment of the invention can automatically realize in-process fault injection of the application system based on fault injection information input by a user, can further improve the fault injection efficiency, and can also avoid fault injection errors caused by manual configuration.
In a specific implementation, each configuration in the fault injection configuration may be automatically performed based on a preset automatic instruction, a program, an interface, or a plug-in, and the next configuration may be automatically skipped according to a preset configuration sequence until all configuration items are configured. Thereafter, the application system may be automatically restarted to validate the fault injection configuration parameters. In an embodiment of the invention, automatic configuration can be realized based on an expect instruction. The expect command is a software suite for realizing automatic interaction function, and can be used for realizing communication between automatic and interactive task programs without manual intervention of people.
Referring to a flowchart of a fault injection configuration method in the embodiment of the present invention shown in fig. 3, in an embodiment of the present invention, based on the characteristics of the application system and the obtained fault injection parameters, fault injection configuration may be performed by adopting the following steps:
s221, configuring the process identifier of the application system to be fault-injected based on the process identifier information of the application system to be fault-injected.
In a specific implementation, the process identifier of the application system to be injected with the fault may be configured based on parameters such as a name and an identifier of the application system to be injected with the fault.
S222, based on the identifier of the application system to be injected with the fault and the fault injection breakpoint position information, configuring a breakpoint position parameter of the fault behavior in a source code of the application system.
In a specific implementation, the process of the application system to be injected with the fault may be obtained based on the identifier of the application system to be injected with the fault, and then the source code corresponding to the process may be obtained, and the breakpoint position parameter of the fault behavior in the source code of the application system may be configured based on the fault injection breakpoint position information.
In an embodiment of the present invention, the application system to be injected with the fault is an application system implemented in C + + language. And configuring by adopting a GDB tool, wherein the GDB tool can acquire the process of the application system to be injected with the fault according to the process Identification (ID) of the C + + application system attached (attach) to the process of the C + + application system.
The fault injection breakpoint position information can be configured as specific position information of which line of the source code of the application system to be injected with the fault is the fault source code to be injected.
And S223, configuring the fault behavior parameters to be injected at the corresponding breakpoint positions of the source codes of the application system based on the fault behavior information to be injected.
For example, fault behavior to be injected may include: delay of several seconds, failure behavior of the method to return a failure value, failure behavior to modify a variable value, and so on. Wherein: the delay fault of the program under any condition can be simulated by delaying for several seconds, the fault behavior of the fault value returned by the method is that the current method is directly jumped out and any value is returned, the faults such as problem data returned by the method and the like can be simulated, the fault such as the error state code returned by the value of the modified variable can be simulated, and the fault such as the modification of the variable value by a hacker and the like can be simulated.
In a specific implementation, the to-be-injected fault behavior information may be a delay of N seconds, when injecting a delay fault, a user may input or select a to-be-injected fault behavior as information corresponding to the delay fault behavior, such as a delay (delay), and may input a specific number of seconds of delay, and accordingly, the to-be-injected fault behavior parameter may be configured to be executed with a delay of several seconds (a program delay fault in any case may be simulated), and the to-be-injected fault behavior information is: when the method returns the fault behavior information of the specified preset error value, the user can input or select the corresponding fault behavior as a return (return) and the returned specified error value, and the configuration method returns the fault behavior parameter corresponding to the preset error value. When the injected fault behavior information is a value of a change variable, the user can input or select the corresponding fault behavior as a modification (modify), and give the modified variable name (if the variable is an object, the name of the variable to be modified: the attribute name) and the variable value.
By adopting the steps to carry out fault injection configuration, the fault source code corresponding to the fault behavior parameter can be injected into the process of the application system in the running process of the application system.
In a specific implementation, the GDB tool or the system call function Ptrace may be used to perform the fault injection configuration of the above steps.
In specific implementation, more extended configurations can be performed on the application system according to the program structure characteristics of the application system to be subjected to fault injection and the reliability verification requirement of the application system. The following is a description of two specific examples.
In an embodiment of the present invention, the application system to be fault injected includes an extended class library, and based on this, besides the above steps S221 to S223, the extended class library may be configured in the fault injection configuration process. Referring to a flowchart of an extended class library configuration method in the fault injection configuration process in the embodiment of the present invention shown in fig. 4, in a specific implementation, a fault injection system may perform the following fault injection configuration:
s224, determining whether to configure the starting file position of the application system to be fault-injected and the starting loading configuration of the extension class library based on whether the parameter of the application system to be fault-injected contains the extension class library information.
Through step S224, it may be determined whether the application system to be fault-injected includes an extended class library, if the extended class library is included, or the information of the application system to be fault-injected input by the user includes extended class library information, for example, a specific extended class library identifier is selected, or a specific extended class library address is input, step S225 may be continuously performed, and if the input parameter of the application system to be fault-injected does not include the extended class library information, step S225 may be skipped, and other fault injection configurations may be continuously performed according to a preset configuration sequence.
And S225, when the parameters of the application system to be fault-injected include the information of the extension class library, respectively acquiring the start file position and the start loading configuration of the extension class library of the application system to be fault-injected, configuring the start file position of the application system to be fault-injected, and configuring the start loading configuration parameters of the extension class library of the application system to be fault-injected.
In a specific implementation, if the fault injection system obtains a specific extension class library identifier or address, the application system to be fault injected may be configured to load an extension class library corresponding to the extension class library identifier when being started; if the user selects a specific extension class library option, the start loading configuration parameters of the extension class library of the application system to be injected with the fault can be configured, so that the extension class library related in the running process of the application system is loaded when the application system is started.
By adopting the configuration mode of the extension class library, whether the corresponding extension class library is contained or not is set in the fault simulation process according to whether the actual operation of the application system to be injected with the fault contains the extension class library or not, if the corresponding extension class library is loaded in the configuration, the corresponding class library is loaded in the operation process of the application system in the fault simulation process after the configuration is effective, so that the operation environment of the application system can be simulated more truly, and the reliability and the effectiveness of the fault simulation verification result are improved.
In some complex applications, besides one or more processes, some processes may also have sub-processes running under them. For such a situation, in the fault injection configuration process, in order to improve the reliability and validity of the fault simulation verification result, the fault can be injected into the sub-process of the application system, so that the fault simulation with finer granularity of the application system is realized, and the generation of system loopholes is avoided. Referring to the flowchart of a sub-process configuration method in the fault injection configuration process shown in fig. 5, the method specifically includes the following steps:
s226, acquiring the information of the main process or the sub process of the application system to be fault injected with the fault, wherein the information of the application system to be fault injected with the fault includes the information of the main process or the sub process.
Through step S226, if the information of the application system to be fault-injected, which is input by the user, includes information of whether the fault is injected into the main process or the sub-process of the application system, for example, a sub-process configuration option is selected, or a specific sub-process identifier is input, step S227 may be continuously executed, and if the input information of the application system to be fault-injected does not include information of whether the fault is injected into the main process or the sub-process of the application system, step S226 may be skipped, and other fault injection configurations may be continuously performed according to a preset configuration sequence.
S227, correspondingly configuring the configuration parameters of the main process or all the sub-processes of the application system for injecting the fault into the application system.
In specific implementation, when the information of the application system to be injected with the fault includes information of a sub-process of the application system to be injected with the fault, all the sub-processes of the application system to be injected with the fault are configured.
For example, if a user selects or enters a child process option (child), it may be configured to inject a fault into all child processes of the application system; if the user selects or enters a main process injection option (false), then the fault may be injected only into the main process of the application system, and not into the sub-processes of the application system.
It should be noted that, in a specific implementation, the fault injection configuration method described in each embodiment corresponding to fig. 3 to fig. 5 is not only a fixed fault injection configuration sequence, but also the sequence of steps between fig. 3, fig. 4, and fig. 5 may be changed under the condition that the overall sequence of fig. 3 to fig. 5 is not changed, as long as the configuration sequence is preset. In an embodiment of the present invention, the steps S221 to S224 to S227 to S222 to S223 may be sequentially performed, and in another embodiment of the present invention, the steps S224 to S225 may be performed first, the steps S226 to S227 may be performed, and the steps S221 to S223 may be performed finally.
S23, when the process of the application system runs to a breakpoint position, the fault source code is run based on the configured fault source code corresponding to the breakpoint position.
Through step S22, after the configuration of fault injection is completed, the fault injection apparatus may load the process of the application system to run as a sub-process, and stop to run the fault source code corresponding to the breakpoint position when the process of the application system runs to the breakpoint position. Through step 23, a fault simulation experiment or drill can be performed.
In an embodiment of the present invention, the commands may be set and executed based on the GDB, and the fault code corresponding to the set fault behavior parameter is automatically executed after the program of the application system is executed to the breakpoint, for example, the execution is delayed for several seconds, and the delayed fault of the program in any situation may be simulated; the value of the variable is changed, the fault that an error state code is returned and the variable value is modified by a hacker can be simulated; or directly jumping out of the current method and returning any value, and the method can be simulated to return faults such as problem data and the like.
Through the steps S21-S23, the fault injection and the fault simulation of the application system in the running state can be completed, and therefore the software reliability verification efficiency of the application system can be greatly improved.
In a specific implementation, the source code of the application system and the failure source code include: code written in a high-level language and/or code that is decompiled based on an executable file of an application system implemented in the high-level language. For example, the application system may be C, C + +, D, Objective-C, Fortran, Java, OpenCL C, Pascal, assembly, modular-2, Go, Ada, or a code obtained by decompiling an executable file of the application system implemented by these languages.
As previously described, fault injection may be performed based on a preset GDB debug tool or a Ptrace system call function. It will be appreciated that different debugging tools may have subtle differences in the specific implementation. For example, when the fault injection method is executed based on a preset GDB debug instruction, before a breakpoint is set at a corresponding position of a source code of the application system based on the fault behavior information to be injected and fault injection breakpoint position information of the fault source code to be injected in the application system to be fault injected, and a fault source code corresponding to the breakpoint position is configured, a GDB paging printing program execution result function may be closed, and when fault injection is performed based on a Ptrace system call function, this operation is not performed.
In the following, how to perform fault injection in the non-operating state of the application system according to the embodiment of the present invention is described, referring to the flowchart of the fault injection method shown in fig. 6, the method may specifically include the following steps:
s61, acquiring fault injection information, wherein the fault injection information comprises: the method comprises the steps of starting file position and name of an application system to be injected with faults, fault behavior information to be injected and fault injection breakpoint position information.
In specific implementation, a corresponding fault injection information input interface may be set to input or select the fault injection information, or the fault injection information may be acquired by the fault injection interface. For example, a user may request a command to include corresponding fault injection information through a preset fault injection interface, such as obtaining the fault injection information through an http get request.
In this embodiment of the present invention, when the application system to be fault injected is in a non-running state, the information of the application system to be fault injected may include: and the starting file position and the name of the application system to be injected with the fault. In specific implementation, according to the requirement for fault simulation verification and the actual characteristics of the application system, the information of the application system to be injected with the fault may further include one or more of information of an extended class library of the application system, information of whether to inject the sub-process of the application system, and the like, and for example, may include one or more of an extended class library identifier, an injection sub-process option, and the like.
In a specific implementation, the fault behavior information to be injected may be a name, a storage address, or other unique identifier of the fault behavior.
In a specific implementation, the fault injection breakpoint position information may be specific position information of which line of the source code of the application system to be injected with the fault source code to be injected is in.
And S62, executing a fault injection configuration instruction based on the acquired fault injection information, and configuring the fault injection parameters of the application system, wherein the parameters of the application system to be injected with the fault include the start file position and the name of the application system to be injected with the fault.
In a specific implementation, the fault injection configuration may be performed in a step-by-step configuration manner according to a pre-configuration sequence.
In specific implementation, a debugging tool such as GDB or a system call function such as Ptrace may be used for fault injection configuration.
After the fault injection configuration is completed, the fault injection configuration may be directly validated, or a preset fault configuration validation operation is performed, so that the fault injection configuration is validated. For example, when the application system is in the non-running state, after the fault injection configuration is completed, the user system may be started, so that the fault injection configuration is enabled. It will be appreciated that launching the application system is not the only way to effect the application system fault injection configuration. In particular implementations, other fault injection configuration validation approaches may also be employed.
In particular implementations, fault injection configuration may be performed by manual step-by-step configuration or by automated configuration.
Specifically, for manual configuration, the following method can be adopted: and based on the acquired fault injection information, gradually configuring the fault injection parameters of the application system according to a preset configuration sequence when a step jump execution instruction triggered by user operation is received. And after configuration is completed, when a starting instruction is received, the application system can be started, so that the fault injection configuration is effective.
In a manual configuration manner, in a specific implementation, a user may input fault injection information in the fault injection device of the embodiment of the present invention, configure one fault injection parameter, and then configure the next fault injection parameter according to a next skip trigger button of the fault injection device or a corresponding operation instruction. In the fault injection configuration process, the previous step can be returned to for modification. And after all the injection configurations are finished and stored, the user can click a start button or trigger a start key to start the application system, so that the fault injection configuration is effective.
And by adopting a manual fault injection configuration mode, a user can gradually configure the fault injection parameters of the application system under the guidance of a preset configuration sequence according to needs, so that the operation and debugging are facilitated.
For the automated fault injection configuration, the following can be adopted: and automatically and gradually configuring the fault injection parameters of the application system according to a preset configuration sequence under the triggering of a preset instruction or program on the basis of the acquired fault injection information, and automatically executing a starting operation after the configuration is finished to start the application system.
By adopting an automatic fault injection configuration mode, the fault injection device provided by the embodiment of the invention can automatically realize in-process fault injection of the application system based on fault injection information input by a user, can further improve the fault injection efficiency, and can also avoid fault injection errors caused by manual configuration.
In a specific implementation, each configuration in the fault injection configuration may be automatically performed based on a preset automatic instruction, a program, an interface, or a plug-in, and the next configuration may be automatically skipped according to a preset configuration sequence until all configuration items are configured. The application system may then be automatically launched to validate the fault injection configuration parameters. In an embodiment of the invention, automatic configuration can be realized based on an expect instruction.
Referring to fig. 7, which is a flowchart of a fault injection configuration method in an embodiment of the present invention, based on characteristics of the application system and acquired fault injection parameters, fault injection configuration may be performed by adopting the following steps:
and S621, configuring the starting file position of the application system to be fault-injected based on the starting file position and name of the application system to be fault-injected.
In an embodiment of the present invention, the application system to be injected with the fault is an application system implemented in C + + language. And configuring by adopting a GDB tool, wherein the starting file position of the C + + application system can be configured by the GDB tool.
And S622, configuring breakpoint position parameters of the fault behaviors in the source codes of the application system based on the starting file position and name of the application system to be fault-injected and fault injection breakpoint position information.
In specific implementation, the start file of the application system to be fault-injected may be obtained based on the start file position and name of the application system to be fault-injected, the source code of the application system to be fault-injected is identified based on the start file of the application system to be fault-injected, and a breakpoint position parameter of a fault behavior in the source code of the application system is configured.
And S623, configuring fault behavior parameters corresponding to the breakpoint positions at the corresponding breakpoint positions of the source codes of the application system based on the fault behavior information to be injected.
For example, fault behavior to be injected may include: delay of several seconds, failure behavior of the method to return a failure value, failure behavior to modify a variable value, and so on. Wherein: the delay fault of the program under any condition can be simulated by delaying for several seconds, the fault behavior of the fault value returned by the method is that the current method is directly jumped out and any value is returned, the faults such as problem data returned by the method and the like can be simulated, the fault such as the error state code returned by the value of the modified variable can be simulated, and the fault such as the modification of the variable value by a hacker and the like can be simulated.
For the specific type and configuration method of the failure behavior, reference may be made to the foregoing processing manner of the application system in the running state, and details are not described here.
By adopting the steps to carry out fault injection configuration, the fault source code corresponding to the fault behavior parameter can be injected into the process of the application system when the application system is in a non-running state.
In a specific implementation, the GDB tool or the system call function Ptrace may be used to perform the fault injection configuration of the above steps.
In specific implementation, more extended configurations can be performed on the application system according to the program structure characteristics of the application system to be subjected to fault injection and the reliability verification requirement of the application system. The following is a description of two specific examples.
In an embodiment of the present invention, the application system to be fault injected includes an extended class library, and based on this, besides the steps S621 to S623 described above, the configuration of the extended class library may be performed in the fault injection configuration process. Referring to a flowchart of an extended class library configuration method in the fault injection configuration process in the embodiment of the present invention shown in fig. 8, similar to the fault injection configuration in the application system running state, in a specific implementation, the fault injection system may perform the following fault injection configuration:
and S624, determining whether to configure the start-up loading configuration of the extended class library of the application system to be fault-injected based on whether the parameter of the application system to be fault-injected contains the information of the extended class library.
Through step S624, it may be determined whether the application system to be fault-injected includes an extension class library, if the application system to be fault-injected includes the extension class library, or the information of the application system to be fault-injected input by the user includes extension class library information, for example, a specific extension class library identifier is selected, or a specific extension class library address is input, step S625 may be continuously performed, and if the input parameter of the application system to be fault-injected does not include the extension class library information, step S625 may be skipped, and other fault injection configurations may be continuously performed according to a preset configuration sequence.
And S625, when the information of the application system to be fault-injected includes the information of the extension class library, configuring the extension class library of the application system to be fault-injected to start loading configuration parameters.
In a specific implementation, if the fault injection system obtains a specific extension class library identifier or address, the application system to be fault injected may be configured to load an extension class library corresponding to the extension class library identifier when being started; if the user selects a specific extension class library option, the start loading configuration parameters of the extension class library of the application system to be injected with the fault can be configured, so that the extension class library related in the running process of the application system is loaded when the application system is started.
By adopting the configuration mode of the extended class library, the running environment of the application system can be simulated more truly, and the reliability and the effectiveness of the fault simulation verification result are improved.
In some complex applications, besides one or more processes, some processes may also have sub-processes running under them. For such a situation, in the fault injection configuration process, in order to improve the reliability and validity of the fault simulation verification result, the fault can be injected into the sub-process of the application system, so that the fault simulation with finer granularity of the application system is realized, and the generation of system loopholes is avoided. Referring to a flowchart of a sub-process configuration method in a fault injection configuration process shown in fig. 9, the method may specifically include the following steps:
S626, acquiring the information of the main process or the sub process of the application system to be injected with the fault, wherein the information of the application system to be injected with the fault comprises the information of the main process or the sub process of the application system to be injected with the fault.
Through step S626, if the information of the application system to be injected with the fault, which is input by the user, includes information of a main process or a sub process of the application system to be injected with the fault, for example, a main process or a sub process option is selected or input, step S627 may be continuously performed, and if the input information of the application system to be injected with the fault does not include information of whether the fault is the main process or the sub process of the application system, step S627 may be skipped, and other fault injection configurations may be continuously performed according to a preset configuration order.
S627, configuring configuration parameters whether to inject the fault into the main process of the application system or all the sub-processes of the application system correspondingly.
And when the information of the application system to be injected with the fault comprises the information of the subprocess of the application system to be injected with the fault, configuring all the subprocesses for injecting the fault into the application system.
In a specific implementation, if the fault injection device acquires information (child) of a fault injection sub-process, all sub-processes of the application system to be injected with the fault may be configured. For example, if a user selects or enters a sub-process injection option, then it may be configured to inject a fault into all sub-processes of the application system; if the user selects or enters a main process injection option (false), then the fault may be injected only into the main process of the application system, and not into the sub-processes of the application system.
It should be noted that, in a specific implementation, the fault injection configuration method described in each embodiment corresponding to fig. 7 to 9 is not only a fixed fault injection configuration sequence, but also the sequence of the sequential steps of the steps between fig. 7, fig. 8, and fig. 9 may be changed when the overall sequence of fig. 7 to 9 is not changed, as long as the configuration sequence is preset. For example, steps S621 to S624 to S627 to S622 to S623 may be sequentially performed, and for example, steps S624 to S625, steps S626 to S627, and steps S621 to S623 may be performed first.
S63, when the process of the application system runs to a breakpoint position, the fault source code is run based on the configured fault source code corresponding to the breakpoint position.
Through step S62, after the configuration of fault injection is completed, the fault injection apparatus may load the process of the application system to run as a sub-process, and stop to run the fault source code corresponding to the breakpoint position when the process of the application system runs to the breakpoint position. In step S63, a failure simulation experiment or drill can be performed.
In an embodiment of the present invention, the commands may be set and executed based on the GDB, and the fault code corresponding to the set fault behavior parameter is automatically executed after the program of the application system is executed to the breakpoint, for example, the execution is delayed for several seconds, and the delayed fault of the program in any situation may be simulated; the value of the variable is changed, the fault that an error state code is returned and the variable value is modified by a hacker can be simulated; or directly jumping out of the current method and returning any value, and the method can be simulated to return faults such as problem data and the like.
Through the steps S61-S63, the fault injection and the fault simulation of the application system in the non-running state can be completed, and therefore the software reliability verification efficiency of the application system can be greatly improved. By adopting the fault injection scheme, the injected fault source code cannot be compiled with the source code of the application system, so that the source code of the application system cannot be polluted.
In a specific implementation, the source code of the application system and the failure source code may include: code written in a high-level language, and/or code that is decompiled based on an executable file of an application system implemented in the high-level language. For example, the application system may be C, C + +, D, Objective-C, Fortran, Java, OpenCL C, Pascal, assembly, modular-2, Go, Ada, or a code obtained by decompiling an executable file of the application system implemented by these languages.
As described above, fault injection and fault simulation may be performed based on a preset GDB debug tool or a Ptrace system call function. It will be appreciated that different debugging tools may have subtle differences in the specific implementation. For example, when the fault injection method is executed based on a preset GDB debug instruction, before a breakpoint is set at a corresponding position of a source code of the application system based on the fault behavior information to be injected and the fault injection breakpoint position information and a fault source code corresponding to the breakpoint position is configured, an execution result function of the GDB paging printer may be closed.
In the embodiment of the present invention, the running state of the application system to be fault-injected can be automatically identified according to the acquired fault injection information, fault injection configuration is performed step by step based on the preset fault injection configuration mode and configuration sequence in the corresponding state, and after configuration is completed and corresponding actions are taken to enable the fault injection configuration of the application system to take effect, when the process of the application system runs to a breakpoint position, the fault source code is run based on the configured fault source code corresponding to the breakpoint position, so that fault simulation can be performed on the application system.
In order to make the embodiments of the present invention better understood and realized by those skilled in the art, the fault simulation method of the embodiments of the present invention is described in detail below by way of specific embodiments with reference to the accompanying drawings.
Referring to a flowchart of a fault simulation method in the embodiment of the present invention shown in fig. 10, specifically, the method may include the following steps:
s101, acquiring the process identification of the application system with the fault injected based on the parameters of the application system with the fault injected.
No matter whether the application system to be fault-injected is in an operating state or a non-operating state, the fault can be injected by using the corresponding fault injection method introduced in the foregoing embodiment of the present invention, and after the fault injection configuration becomes effective, the fault simulation can be performed on the application system with the fault injected.
For the application system with the fault injection configuration completed, the corresponding fault configuration validation operation can be executed based on the running state of the application system during fault injection. For example, for an application system in a running state, after fault injection, the application system may be restarted to validate the fault injection configuration; for the application system in the non-running state, after fault injection, the application system may be started to enable the fault injection configuration to take effect.
S102, loading the process of the application system with the fault injected as a sub-process based on the identification of the process of the application system with the fault injected.
In a specific implementation, if the application system includes a child process, in the process of loading the main process of the application system with the fault injected to run as the child process, the child process of the application system is also loaded, so that the child processes of the application system are nested in the main process of the application system as grandchild processes and are loaded together. After the fault injection method provided by the embodiment of the invention is injected into the application system, the fault can be injected into the main process of the application system and the sub-process of the application system as required, so that the fault simulation with finer granularity of the application system can be realized, the system loophole is avoided, and the reliability and the effectiveness of the fault simulation verification result are improved.
S103, when a signal of executing to a breakpoint position transmitted by the process of the application system with the fault injected is received, configuring corresponding fault behavior parameters based on the configured breakpoint, and transmitting corresponding execution instructions to the process of the application system, so that the process of the application system runs the fault source codes corresponding to the fault behavior parameters at the breakpoint position according to the execution instructions.
For example, when a signal that the process of the application system injected with the fault executes to a breakpoint position is received, the corresponding delay fault parameter is configured based on the configured breakpoint, and a corresponding execution instruction is transmitted to the process of the application system, so that the process of the application system runs the fault source code corresponding to the delay fault parameter at the breakpoint position according to the execution instruction, and delays for several seconds.
By adopting the fault simulation method, the identification of the process of the application system with the fault injected can be obtained based on the parameters of the application system with the fault injected, the process of the application system with the fault injected serves as a sub-process, when a signal that the process of the application system with the fault injected executes to a breakpoint position is received, the corresponding fault behavior parameters can be configured based on the configured breakpoint position, and corresponding execution instructions are transmitted to the process of the application system, so that the process of the application system runs the fault codes corresponding to the fault behavior parameters at the breakpoint position according to the execution instructions. As can be seen from the above fault simulation process, the fault source code is not compiled with the source code of the application system, so that the injected fault does not contaminate the source code of the application system.
And S104, in the running process of the application system, when a preset separation command is received, based on the injected fault identification contained in the preset separation command, separating the fault source code corresponding to the injected fault identification from the process of the application system.
As an alternative, in the running process of the application system, the fault source code is separated from the process of the application system based on the received preset separation command, and the fault source code can be removed without restarting the application system, so that the fault simulation efficiency can be further improved.
In an embodiment of the present invention, based on the GDB, the detach command may be adopted to implement the fault separation without restarting the application system.
S105, when a preset fault injection device unloading instruction is received, unloading all faults injected by the fault injection device, and removing the process of the fault injection device from the process list of the operating system.
As an alternative, after the fault injection device of the embodiment of the present invention is adopted to successfully inject a fault into the application system and complete all fault simulations, when a preset fault injection device uninstalling instruction is received, all faults injected by the fault injection device may be automatically uninstalled, and the process of the fault injection device is removed from the process list of the operating system, so that the whole fault injection and simulation process does not cause any pollution to the source code of the application system and does not affect the normal operation of the application system code.
The embodiment of the invention also provides a fault injection device corresponding to the embodiment of the fault injection method, and the following detailed description is given through specific embodiments with reference to the attached drawings.
Fig. 11 shows a schematic structural diagram of a fault injection apparatus in an embodiment of the present invention, and in an embodiment of the present invention, referring to fig. 11, a fault injection apparatus 110 includes: a fault injection information acquisition unit 111, a fault injection configuration unit 112, and a fault operation unit 113, wherein:
the fault injection information obtaining unit 111 is adapted to obtain fault injection information, where the fault injection information includes: information of an application system to be injected with a fault, fault behavior information to be injected and fault injection breakpoint position information;
the fault injection configuration unit 112 is adapted to execute a fault injection configuration instruction based on the fault injection information acquired by the fault injection information acquisition unit 111, and configure fault injection parameters of the application system, where the fault injection parameters include: parameters of an application system to be injected with a fault, parameters of a fault behavior to be injected and breakpoint position parameters of the fault behavior in a source code of the application system;
the fault running unit 113 is adapted to run the fault source code based on the fault source code corresponding to the breakpoint position configured by the fault injection configuration unit 112 when the process of the application system runs to the breakpoint position.
By adopting the fault injection device, the fault can be injected into the process of the application system, then the fault simulation can be carried out, further, the verification efficiency of the software reliability of the application system can be greatly improved, and the injected fault source code cannot be compiled together with the source code of the application system, so that the source code of the application system cannot be polluted.
In a specific implementation, the information of the application system to be injected with the fault, which is suitable for being obtained by the fault injection information obtaining unit 111, may include: process identification information of the application system to be fault injected in the running state; the parameters of the application system to be configured by the fault injection configuration unit 112 may include a process identifier of the application system to be injected with the fault.
In a specific implementation, the information of the application system to be fault-injected, which is adapted to be obtained by the fault injection information obtaining unit 111, may further include extended class library information, and the parameters of the application system to be fault-injected, which are adapted to be configured by the fault injection configuration unit 112, may further include: the starting file position and name of the application system to be injected with the fault, and the starting loading configuration parameters of the extended class library of the application system.
In a specific implementation, the information of the application system to be injected with the fault, which is obtained by the fault injection information obtaining unit 111, includes: the starting file position and the name of the application system to be injected with the fault in the non-running state; the parameters of the application system to be fault-injected, which are suitable for being configured by the fault injection configuration unit 112, include: and the starting file position and the name of the application system to be injected with the fault.
In a specific implementation, for the application system in an un-running state, the information of the application system to which the fault is to be injected, which is adapted to be obtained by the fault injection information obtaining unit 111, may further include extended class library information; the parameters of the application system to be fault-injected, which are suitable for being configured by the fault injection configuration unit 112, may further include: and starting and loading configuration parameters by the extended class library of the application system.
In a specific implementation, whether the application system to be fault-injected is in an operating state or an non-operating state, the information of the application system to be fault-injected, which is adapted to be acquired by the fault injection information acquiring unit 111, may further include: fault injection is carried out on the information of the main process or the sub process of the application system to be injected with the fault; the parameters of the application system to be fault-injected, which are suitable for being configured by the fault injection configuration unit 112, may further include: fault injection into the main process of the application system or configuration parameters of all sub-processes of the application system.
In a specific implementation, with continued reference to fig. 11, the fault injection apparatus 110 may further include: a fault configuration validation unit 114 adapted to perform a preset fault configuration validation operation after the fault injection configuration unit 112 configures the fault injection parameters of the application system.
Referring to fig. 11, in a specific implementation, the fault injection configuration unit 112 may include at least one of:
a first fault injection configuration subunit 1121, configured, based on the fault injection information, to gradually configure the fault injection parameters of the application system according to a preset configuration sequence when receiving a step jump execution instruction triggered by a user operation;
the second fault injection configuration subunit 1122 is adapted to automatically configure the fault injection parameters of the application system step by step according to a preset configuration sequence under the trigger of a preset instruction or program based on the fault injection information.
By adopting the first fault injection configuration subunit, the fault injection parameters of the application system can be configured step by step according to a preset configuration sequence when a step jump execution instruction triggered by user operation is received based on the acquired fault injection information. By adopting the scheme, a user can gradually configure the fault code to be injected of the application system under the guidance of a preset configuration sequence according to needs, so that the operation and debugging are facilitated.
And by adopting the second fault injection configuration subunit, the fault injection parameters of the application system can be automatically configured step by step according to a preset configuration sequence under the triggering of a preset instruction or program based on the acquired fault injection information. By adopting the scheme, the in-process fault injection of the application system can be automatically realized based on the fault injection information input by the user, the fault injection efficiency can be further improved, and fault injection errors caused by manual configuration can be avoided.
Fig. 12 is a schematic structural diagram of another fault injection apparatus in an embodiment of the present invention, and in an embodiment of the present invention, referring to fig. 12, the fault injection apparatus 120 may include: an application system information obtaining unit 121, a process loading unit 122, and a fault simulation unit 123, wherein:
the application system information obtaining unit 121 is adapted to obtain, based on a parameter of the application system with the fault injected, an identifier of a process of the application system with the fault injected;
the process loading unit 122 is adapted to load the process of the fault-injected application system as a sub-process based on the identifier of the process of the fault-injected application system;
The fault simulation unit 123 is adapted to, when receiving a signal that the process of the application system injected with the fault executes to a breakpoint position and is transmitted, transmit a corresponding execution instruction to the process of the application system based on the configured fault behavior parameter corresponding to the breakpoint position, so that the process of the application system runs the fault source code corresponding to the fault behavior parameter at the breakpoint position according to the execution instruction.
The fault injection device is adopted to carry out fault simulation on the application system with the fault injected, the process of the application system with the fault injected is loaded as a sub-process, and the process of the application system runs the fault code corresponding to the fault behavior parameter at the breakpoint position according to the execution instruction. In the process of fault injection and fault simulation by adopting the fault injection device, the fault source code cannot be compiled with the source code of the application system, so that the injected fault cannot pollute the source code of the application system.
In a specific implementation, the process loading unit 122 is adapted to load the main process of the application system with the fault injected as a sub-process based on the identification of the process of the application system with the fault injected, and the main process of the application system includes all sub-processes.
In a specific implementation, with continued reference to fig. 12, the fault injection apparatus 120 may further include: a fault configuration validation unit 124, adapted to perform, before the application system information obtaining unit 121 obtains, based on the parameter of the application system into which the fault is injected, the identifier of the process of the application system into which the fault is injected, on the application system in which the fault injection configuration is completed, and based on the running state of the application at the time of fault injection, a corresponding fault configuration validation operation is performed.
With continued reference to fig. 12, in an embodiment of the present invention, the fault injection apparatus 120 may further include: and the fault separation unit 125 is adapted to, when a preset separation command is received in the running process of the application system, separate a fault source code corresponding to an injected fault identifier from the process of the application system based on the injected fault identifier included in the preset separation command.
Through the fault separation unit, the fault source code can be separated from the process of the application system based on the received preset separation command in the running process of the application system after the fault simulation is completed, and the fault source code can be removed without restarting the application system, so that the fault simulation efficiency can be further improved.
With continued reference to fig. 12, in an embodiment of the present invention, the fault injection apparatus 120 may further include: the fault uninstalling unit 126 is adapted to uninstall all faults injected by the fault injection device and remove the processes of the fault injection device from the process list of the operating system when a preset fault injection device uninstalling instruction is received.
By adopting the fault unloading unit in the fault injection device, when a preset fault injection device unloading instruction is received, all faults injected by the fault injection device are automatically unloaded, and the process of the fault injection device is removed from the process list of the operating system, so that the source code of the application system is not polluted in the whole fault injection and simulation process, the normal operation of the code of the application system is not influenced, and the application system can really and reliably operate.
It should be noted that the fault injection method, the fault simulation method, and the fault injection apparatus in the above embodiments may be cross-referenced according to corresponding application scenarios, and different embodiments may also be used in combination in order to optimize processing performance and improve reliability of fault simulation verification.
The embodiment of the present invention further provides a computer-readable storage medium corresponding to the fault injection method of the foregoing embodiment, where a computer instruction is stored on the computer-readable storage medium, and in a specific implementation, when the computer instruction runs, the steps of the fault injection method of any one of the foregoing embodiments may be executed, which may specifically refer to the drawings and the foregoing embodiments, and are not described herein again.
The embodiment of the present invention further provides a computer-readable storage medium corresponding to the fault simulation method of the foregoing embodiment, where a computer instruction is stored on the computer-readable storage medium, and in a specific implementation, when the computer instruction runs, the steps of the fault simulation method of any one of the foregoing embodiments may be executed, which may specifically refer to the drawings and the foregoing embodiments, and are not described herein again.
The computer-readable storage medium may include, for example, any suitable type of memory unit, memory device, memory article, memory medium, storage device, storage article, storage medium and/or storage unit, for example, memory, removable or non-removable media, erasable or non-erasable media, writeable or re-writeable media, digital or analog media, hard disk, floppy disk, compact disk read Only memory (CD-ROM), compact disk recordable (CD-R), compact disk Rewriteable (CD-RW), optical disk, magnetic media, magneto-optical media, removable memory cards or disks, various types of Digital Versatile Disk (DVD), a tape, a cassette, or the like.
Although the present invention is disclosed above, the present invention is not limited thereto. Various changes and modifications may be effected therein by one skilled in the art without departing from the spirit and scope of the invention as defined in the appended claims.

Claims (20)

1. A fault injection method, comprising:
acquiring fault injection information, wherein the fault injection information comprises: information of an application system to be injected with a fault, fault behavior information to be injected and fault injection breakpoint position information;
executing a fault injection configuration instruction based on the fault injection information, and configuring fault injection parameters of the application system, wherein the fault injection parameters comprise: parameters of an application system to be injected with a fault, parameters of a fault behavior to be injected and breakpoint position parameters of the fault behavior in a source code of the application system;
and when the process of the application system runs to a breakpoint position, running the fault source code based on the configured fault source code corresponding to the breakpoint position.
2. The fault injection method according to claim 1, wherein the application system to be injected with the fault is in a running state, and the information of the application system to be injected with the fault comprises: process identification information of the application system to be fault injected; the parameters of the application system to be injected with the fault comprise: and identifying the process of the application system to be injected with the fault.
3. The fault injection method according to claim 2, wherein the information of the application system to be injected with the fault further includes extended class library information; the parameters of the application system to be injected with the fault further include: the starting file position and name of the application system, and the starting loading configuration parameters of the extended class library of the application system.
4. The fault injection method according to claim 1, wherein the application system to be injected with the fault is in a non-running state, and the information of the application system to be injected with the fault comprises: the starting file position and name of the application system to be injected with the fault; the parameters of the application system to be injected with the fault comprise: and the starting file position and the name of the application system to be injected with the fault.
5. The fault injection method according to claim 4, wherein the information of the application to be injected with the fault further includes extended class library information; the parameters of the application system to be injected with the fault further include: and starting and loading configuration parameters by the extended class library of the application system.
6. The fault injection method according to claim 1, wherein the information of the application system to be injected with the fault further comprises: fault injection is carried out on the information of the main process or the sub process of the application system to be injected with the fault; the parameters of the application system to be injected with the fault further include: fault injection into the main process of the application system or configuration parameters of all sub-processes of the application system.
7. The fault injection method according to claim 1, further comprising, after configuring the fault injection parameters of the application system: and executing preset fault configuration validation operation.
8. The fault injection method according to any one of claims 1 to 7, wherein the executing a fault injection configuration instruction based on the fault injection information to configure the fault injection parameters of the application system comprises at least one of:
based on the fault injection information, when a step jump execution instruction triggered by user operation is received, gradually configuring fault injection parameters of the application system according to a preset configuration sequence;
and automatically and gradually configuring the fault injection parameters of the application system according to a preset configuration sequence under the triggering of a preset instruction or program based on the fault injection information.
9. The fault injection method according to any one of claims 1 to 7, wherein the source code of the application system and the fault source code comprise: code written in a high-level language and/or code that is decompiled based on an executable file of an application system implemented in the high-level language.
10. The fault injection method according to claim 9, wherein the fault injection method is executed based on a preset GDB debug command or a Ptrace system call function.
11. The fault injection method according to claim 10, wherein when the fault injection method is executed based on preset GDB debugging instructions, before configuring breakpoint location parameters of the fault behavior in source code of an application system, the fault injection method further comprises:
closing the GDB paginated printing program to execute the result function.
12. A method of fault simulation, comprising:
acquiring an identifier of a process of an application system with an injected fault based on parameters of the application system with the injected fault;
loading the process of the application system with the fault injected as a sub-process based on the identification of the process of the application system with the fault injected;
when a signal of executing to a breakpoint position transmitted by the process of the application system with the fault injected is received, configuring corresponding fault behavior parameters based on the configured breakpoint, and transmitting corresponding execution instructions to the process of the application system, so that the process of the application system runs the fault source code corresponding to the fault behavior parameters at the breakpoint position according to the execution instructions.
13. The method according to claim 12, wherein the loading the process of the fault-injected application system as a sub-process based on the identification of the process of the fault-injected application system comprises:
And loading the main process of the application system with the fault injected as a sub-process based on the identification of the process of the application system with the fault injected, wherein the main process of the application system comprises all sub-processes.
14. The method of claim 12, wherein before obtaining the identification of the process of the fault-injected application system based on the parameters of the fault-injected application system, the method further comprises:
and executing corresponding fault configuration validation operation on the application system with the fault injection configuration completed based on the running state of the application system during fault injection.
15. The fault simulation method according to any one of claims 12 to 14, further comprising:
in the running process of the application system, when a preset separation command is received, based on the identification of the injected fault contained in the preset separation command, the fault source code corresponding to the identification of the injected fault is separated from the process of the application system.
16. The fault simulation method according to any one of claims 12 to 14, further comprising: when a preset fault injection device unloading instruction is received, all faults injected by the fault injection device are unloaded, and the process of the fault injection device is removed from a process list of an operating system.
17. A fault injection apparatus, comprising:
a fault injection information obtaining unit adapted to obtain fault injection information, the fault injection information including: information of an application system to be injected with a fault, fault behavior information to be injected and fault injection breakpoint position information;
a fault injection configuration unit adapted to execute a fault injection configuration instruction based on the fault injection information acquired by the fault injection information acquisition unit, and configure fault injection parameters of the application system, where the fault injection parameters include: parameters of an application system to be injected with a fault, parameters of a fault behavior to be injected and breakpoint position parameters of the fault behavior in a source code of the application system;
and the fault running unit is suitable for running the fault source code based on the fault source code corresponding to the breakpoint position configured by the fault injection configuration unit when the process of the application system runs to the breakpoint position.
18. A fault injection apparatus, comprising:
the application system information acquisition unit is suitable for acquiring the process identifier of the application system with the fault injected based on the parameters of the application system with the fault injected;
The process loading unit is suitable for loading the process of the application system with the fault injected as a sub-process based on the identification of the process of the application system with the fault injected;
and the fault simulation unit is suitable for transmitting a corresponding execution instruction to the process of the application system based on the configured fault behavior parameter corresponding to the breakpoint position when receiving a signal transmitted by the process of the application system injected with the fault and executed to the breakpoint position, so that the process of the application system runs the fault source code corresponding to the fault behavior parameter at the breakpoint position according to the execution instruction.
19. A computer readable storage medium having computer instructions stored thereon, wherein the computer instructions when executed perform the steps of the method of any one of claims 1 to 11.
20. A computer readable storage medium having computer instructions stored thereon for performing the steps of the method of any one of claims 12 to 16 when the computer instructions are executed.
CN201910437874.6A 2019-05-24 2019-05-24 Fault injection method, fault simulation method, fault injection device, and storage medium Pending CN111984524A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910437874.6A CN111984524A (en) 2019-05-24 2019-05-24 Fault injection method, fault simulation method, fault injection device, and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910437874.6A CN111984524A (en) 2019-05-24 2019-05-24 Fault injection method, fault simulation method, fault injection device, and storage medium

Publications (1)

Publication Number Publication Date
CN111984524A true CN111984524A (en) 2020-11-24

Family

ID=73436645

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910437874.6A Pending CN111984524A (en) 2019-05-24 2019-05-24 Fault injection method, fault simulation method, fault injection device, and storage medium

Country Status (1)

Country Link
CN (1) CN111984524A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113064782A (en) * 2021-03-22 2021-07-02 山东英信计算机技术有限公司 Memory error injection automation system, use method and medium
CN113407394A (en) * 2021-05-31 2021-09-17 浪潮电子信息产业股份有限公司 Method, device, equipment and medium for server RAS function test

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113064782A (en) * 2021-03-22 2021-07-02 山东英信计算机技术有限公司 Memory error injection automation system, use method and medium
CN113064782B (en) * 2021-03-22 2023-03-24 山东英信计算机技术有限公司 Memory error injection automation system, use method and medium
CN113407394A (en) * 2021-05-31 2021-09-17 浪潮电子信息产业股份有限公司 Method, device, equipment and medium for server RAS function test
CN113407394B (en) * 2021-05-31 2023-03-28 浪潮电子信息产业股份有限公司 Method, device, equipment and medium for server RAS function test

Similar Documents

Publication Publication Date Title
US6002869A (en) System and method for automatically testing software programs
CN106909498B (en) Method and system for injecting fault into Java program
US9684587B2 (en) Test creation with execution
US20140109063A1 (en) Capturing test data associated with error conditions in software item testing
US9069902B2 (en) Software test automation
US20140109052A1 (en) Test environment managed within tests
US20140201727A1 (en) Updating firmware compatibility data
US10579513B2 (en) Test run control method and apparatus
CN105468529A (en) Accurate traversal method and apparatus for UI controls of android application
KR20080050118A (en) Method of error detecting method for embedded sofeware
CN112084113B (en) Configurable automatic test method and system based on embedded simulation verification software
CN109902005B (en) Automatic testing method and system
CN107329889B (en) Method for automatically testing C compiler
US9317254B1 (en) Fault tolerance model, methods, and apparatuses and their validation techniques
US20060168568A1 (en) Method, system and computer program product for testing computer programs
JP2010134643A (en) Test case selection method and selection system
CN111984524A (en) Fault injection method, fault simulation method, fault injection device, and storage medium
US10387294B2 (en) Altering a test
KR102141287B1 (en) Fault injection test method and system for vehicle software based on autosar
US10592703B1 (en) Method and system for processing verification tests for testing a design under test
US9292422B2 (en) Scheduled software item testing
CN114546819A (en) Code processing method and device, electronic equipment and readable medium
CN100359485C (en) Testing device and method for flush-bonding system
CN115470141A (en) Fault simulation method, device and related equipment
CN115034165A (en) Chip simulation verification method, system, equipment and storage medium

Legal Events

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