A method for generating completeness test cases based on symbolic finite state machines

By using a method based on symbolic finite state machines and using STPA technology and linear temporal logic properties to generate complete test cases, the problem of insufficient expressiveness and excessive number of test cases of the FSM model in complex safety-critical systems is solved. Efficient test case generation and test time reduction are achieved.

CN118409972BActive Publication Date: 2024-09-20HUAQIAO UNIVERSITY +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410831172.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-06-26
Publication Date
2024-09-20
Estimated Expiration
2044-06-26

AI Technical Summary

Technical Problem

When existing technologies face complex and safety-critical systems, the expressiveness of finite state machine (FSM) models is limited, making it difficult to conduct comprehensive and effective testing, especially when facing infinite input and output domains and uncertain systems. The number of generated test cases is huge, the testing time is long, and the completeness is poor.

Method used

Adopt a completeness test case generation method based on symbolic finite state machines, use STPA technology to analyze safety-related systems, convert them into linear temporal logic attributes, build a symbolic finite state machine model, generate test cases, and divide equivalence classes and observability transformations to ensure the completeness of test cases.

Benefits of technology

It achieves comprehensive testing of safety-related systems, reduces the number of test cases, shortens testing time, and ensures the completeness and efficiency of testing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118409972B
    Figure CN118409972B
Patent Text Reader

Abstract

The invention discloses a completeness test case generation method based on a symbolic finite state machine, which relates to the field of software testing, including: adopting the STPA technology to analyze a safety-critical system, obtaining refined software safety requirements and converting them into linear temporal logic attributes and atomic propositions; adopting the symbolic finite state machine to model the safety-critical system and calculate the valuation function to obtain a test case generation model, and performing refinement and observability conversion based on the first-order expression to obtain an observable test case generation model, and obtaining corresponding input equivalence classes, generating test cases based on the input equivalence class set and proposition abstraction of the observable test case generation model, executing the test cases on the test case generation model and mutants thereof in a fault domain until the test cases meet the refined software safety requirements, thereby solving the problems of a large number of test cases and poor completeness, and meeting the requirements for comprehensive and effective testing of safety-critical systems.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of software testing, and in particular to a method for generating completeness test cases based on a symbolic finite state machine. Background Art

[0002] Safety-critical systems are systems that integrate IoT technology, and their security is of paramount importance. In the current technological context, safety-critical systems face security threats from multiple aspects, such as cyber attacks and privacy leaks. With the widespread application of IoT, the system is large in scale and highly complex, so it is particularly important to conduct comprehensive and effective testing on it.

[0003] Traditional testing methods have certain limitations when facing system complexity and safety requirements, and there is no method that can perform completeness testing. In the prior art: Finite State Machine (FSM) is used to describe safety-critical systems. When modeling complex safety-critical systems, the expressiveness of the FSM model is limited, mainly reflected in the fact that it has a specific restricted specification style when describing the safety attributes of the system. In addition, when facing systems with infinite input and output domains and uncertainties, the number of test cases generated is huge, the test time is long, and the completeness is poor, making it difficult to meet the comprehensive and effective testing requirements of safety-critical systems. Summary of the invention

[0004] The purpose of this application is to propose a completeness test case generation method based on a symbolic finite state machine to address the above-mentioned technical problems.

[0005] In a first aspect, the present invention provides a method for generating a completeness test case based on a symbolic finite state machine, comprising the following steps:

[0006] The safety-critical system is analyzed using STPA technology to obtain refined unsafe control actions and refined software safety requirements. The refined software safety requirements are converted into linear temporal logic attributes and further converted into atomic propositions to form an atomic proposition set.

[0007] A symbolic finite state machine is used to model the safety-critical system and obtain a test case generation model. Based on the test case generation model, several mutants are constructed and the fault domain is obtained. All valuation functions of the safety-critical system are calculated. The symbolic traces in the test case generation model and their corresponding concrete traces are generated according to the valuation functions. The valuation functions are mapped to the set of atomic propositions they satisfy to obtain propositional abstraction. The propositional abstraction is extended to the assignment sequence and concrete traces through recursive definition.

[0008] Refining the test case generation model based on the first-order expression to obtain the refined test case generation model, dividing all valuation functions into equivalence classes based on the refined test case generation model to obtain input equivalence classes, marking the transformations of the refined test case generation model according to the input equivalence classes to obtain the marked test case generation model, constructing an observable test case generation model based on the marked test case generation model, and obtaining an input equivalence class set of the observable test case generation model, wherein the observable test case generation model and the test case generation model are in the same fault domain;

[0009] Generate test cases based on the input equivalence class set and proposition abstraction of the observable test case generation model. Execute the test cases in the test case generation model and its mutants in the fault domain to detect whether the test cases meet the refined software safety requirements. If not, rebuild the fault domain and repeat the above two steps until the test cases meet the refined software safety requirements.

[0010] As a preferred method, the safety-critical system is analyzed by using STPA technology to obtain refined unsafe control actions and refined software safety requirements, and the refined software safety requirements are converted into linear temporal logic attributes, and further converted into atomic propositions to form an atomic proposition set, which specifically includes:

[0011] Identify the services, losses, hazards and system boundaries of safety-critical systems, and determine the system-level constraints of safety-critical systems based on hazards;

[0012] Building a control structure based on services, hazards, system boundaries and system-level constraints. The control structure includes a controller and a controlled process. The controller issues control actions to the controlled process.

[0013] Based on the combination of control actions and their related state variables and key variables, refined unsafe control actions are identified, and refined software safety requirements are generated according to the refined unsafe control actions. The refined unsafe control actions are represented as a quaternary (CA, Cs, C, TC), where CA represents the control action that causes danger, Cs=∪(P 1 =v 1 ,…P n =v n ) represents the combination of state variables and key variables related to the control action CA, C represents the situation where providing or not providing the control action CA is dangerous, TC represents the situation where the control action CA is provided, which is divided into any time, too early or too late;

[0014] The refined software safety requirements are converted into linear temporal logic properties according to the following rules:

[0015] When the combination Cs iThe controller should never provide control action CA when the value is i , where Cs=∪(P 1 =v 1 ,…P n =v n ),i {1,…,n}, the conversion formula is:

[0016] LTL i =G(Cs i →!(controlAction==CA i ));

[0017] In combination Cs i The controller should not provide control actions too early before the value of CA occurs. i , the conversion formula is:

[0018] LTL i =G(((controlAction==CA i )→!Cs i )&!((controlAction==CA i )∪Cs i ));

[0019] In combination Cs i After the value of occurs, the controller should not provide control action CA too late i , the conversion formula is:

[0020] LTL i =G((Cs i →!(controlAction==CA i ))&!(Cs i ∪(controlAction==CA i )));

[0021] When the combination Cs i The controller must immediately provide a control action CA in the next time step when i , the conversion formula is:

[0022] LTL i =G(Cs i →X(controlAction==CA i ));

[0023] Further converted into atomic propositions according to linear temporal logic properties to form an atomic proposition set;

[0024] The syntax of a linear temporal logic property formula η is given by the following grammar:

[0025] ;

[0026] Among them, η AP stands for atomic proposition, and AP stands for the set of atomic propositions, written as a quantifier-free first-order expression for variable symbols from I∪O:

[0027] ;

[0028] in, , represents any linear temporal logic attribute formula, is a proposition trace, i and j are indexes, and the expression Suffix indicating trace ,and , Represents the power set of the atomic proposition set AP, for a proposition trace of infinite length Finite prefix of ,writing To specify yes a finite prefix of ;

[0029] The semantics of the path operators F, G, and W are defined by the following grammatical abbreviations: , , , ≡ means definition, ∨ means or, ¬ means negation;

[0030] A linear temporal logic property formula η is a set P of propositional traces that satisfies , where \ represents the complement, , Respectively represent the proposition trace Two different finite prefixes of .

[0031] As a preferred method, a symbolic finite state machine is used to model the safety-critical system to obtain a test case generation model. Based on the test case generation model, several mutants are constructed, and the fault domain is obtained. All valuation functions of the safety-critical system are calculated. The symbolic traces in the test case generation model and their corresponding specific traces are generated according to the valuation functions. The valuation functions are mapped to the set of atomic propositions they satisfy to obtain propositional abstraction. The propositional abstraction is extended to the assignment sequence and the specific traces through recursive definition, which specifically includes:

[0032] The safety-critical system is modeled using a symbolic finite state machine to obtain a test case generation model, which is represented by an octet , where the finite set S represents the state space, represents the initial state, R represents the conversion relationship, , the finite set I contains the input variable symbols, the finite set O contains the output variable symbols, the set Var represents I∪O, D represents the union of all variables on the type domain, ∑ I represents the input alphabet, which is a set of finite input events, each of which is a quantifier-free first-order expression on the input variables, ∑ O represents the output alphabet, which is the set of output expressions;

[0033] Based on the test case generation model, several mutants are constructed by introducing incorrect behaviors. The incorrect behaviors include: incorrect or swapped input events, incorrect or swapped output expressions, transmission failures, added or lost states. Transmission failures include additional, lost or misleading conversions, and adding incorrect input events to the input alphabet ∑ I In the output alphabet, add the wrong output expression to the output alphabet ∑ O In the test case generation model, the wrong input events and wrong output expressions do not appear anywhere. The fault domain is constructed based on all mutants. The fault domain is represented as Z(I,O,D,∑ I ,∑ O ,AP,n,m), where n means that the test case generation model M has n distinguishable states, and m means that the mutants of the test case generation model M have at most m distinguishable states;

[0034] Valuation Function Indicates that each variable symbol a value of the type corresponding to one in D Connected, Represents the valuation function Is an input event Model, which will input events Each variable symbol v in D is replaced by a value of the corresponding type in D. After that, the resulting Boolean expression is true. Represents the valuation function Is an input event and its corresponding output expression conjunction The model calculates all valuation functions of the safety-critical system. The set of all valuation functions mapped from Var to D is expressed as ;

[0035] The symbolic path ζ of the test case generation model M is an infinite sequence, expressed as:

[0036] ;

[0037] Among them, "." represents the sequence concatenation symbol. Represents the initial state of the test case generation model M. For all , ;

[0038] Test case generation model M symbolic trace is a finite sequence, represented as:

[0039] ,satisfy:

[0040] , , so that ,in, Indicates existence, It means any;

[0041] The set of symbolic traces of the test case generation model M is denoted as T(M);

[0042] The specific path of the test case generation model M is an infinite sequence, expressed as:

[0043] (s 0 ,σ 1 ,s 1 ).(s 1 ,σ 2 ,s 2 )··· (S×D Var ×S) ω ;

[0044] Among them, σ i D Var , so that the test case generation model M has a symbol path:

[0045] satisfy , ;

[0046] The specific trace τ of the test case generation model M is a finite sequence, expressed as:

[0047] κ=σ 1 ... n (D Var ) ∗ ;

[0048] So that the test case generation model M has a symbolic trace satisfy , then the specific trace Symbolic trace Witness, expressed as ;

[0049] The set of specific traces of the test case generation model M is denoted as L(M);

[0050] Map the valuation function σ to the set of atomic propositions AP that it satisfies, and obtain the propositional abstraction ω, as shown in the following formula:

[0051] ;

[0052] Represents the corresponding mapping relationship. Through recursive definition, the propositional abstraction ω is extended to the assignment sequence and the specific trace:

[0053] ;

[0054] Among them, ε represents the empty trace;

[0055] For linear temporal logic attribute formulas and finite prefix , if and only if yes When there is a bad prefix, use the symbol ; if and only if any specific trace of the test case generation model M will not be abstracted by the proposition Abstracted as , then the test case generation model M is the model corresponding to the linear temporal logic attribute, that is .

[0056] As a preferred method, the test case generation model is refined based on the first-order expression to obtain a refined test case generation model, all valuation functions are divided into equivalence classes based on the refined test case generation model to obtain input equivalence classes, the transformation of the refined test case generation model is marked according to the input equivalence classes to obtain a marked test case generation model, an observable test case generation model is constructed based on the marked test case generation model, and an input equivalence class set of the observable test case generation model is obtained, the observable test case generation model and the test case generation model are in the same fault domain, specifically including:

[0057] Provide a finite set Q containing quantifier-free first-order expressions of free variables from I∪O, a subset Q of the finite set Q g = {g 1 ,..., g k The first-order expression in} has only free variables from I. Based on the test case generation model M, a refined test case generation model is constructed, which is expressed as Q(M)=(S,s 0 ,Q(R),I,O,D,Q(∑ I ),∑O ), the refined test case generation model Q(M) and the test case generation model are in the same fault domain. For any subset of the first-order expression , define a Boolean expression:

[0058] ;

[0059] Among them, ∧ means and;

[0060] Define the input alphabet of Q(M) as follows:

[0061] ;

[0062] Among them, D I represents the union of each model in the set of inputs that are applicable to at least that state in each state of the test case generation model M;

[0063] Define the transfer relationship of Q(M) as shown below:

[0064] ;

[0065] All valuation functions are divided into equivalence classes according to the following rules:

[0066] Defining the first-order formula is from Y and the complement The conjunction of the negated formula is as follows:

[0067] ;

[0068] Among them, the alphabetical table of fault domains is the union of all input events, output expressions, and atomic proposition sets of linear temporal logic property formulas to be verified, expressed as , the set Y represents the set constructed according to the above formula with at least one valuation function As all input events of the model The set Y is as follows:

[0069] ;

[0070] For each , define an input equivalence class , expressed as:

[0071] ;

[0072] The set A of all input equivalence classes is expressed as:

[0073] ;

[0074] According to the input equivalence class Mark the transitions of the refined test case generation model Q(M) to obtain the marked test case generation model. If the marked test case generation model has transitions that start from the same starting state s but end at different target states

[0075] Then the power set construction method is applied to the marked test case generation model to obtain the observable test case generation model. , including:

[0076] Determine the initial state: Use the initial state of the labeled test case generation model as an observable test case generation model The initial state of

[0077] Determine the state set: For each state set, deduce the possible states it can be converted to on each input event, form a new state set, and become an observable test case generation model Status in

[0078] Determine the transition function: Based on the transition function of the labeled test case generation model and the trace of each state set on each input event, determine the observable test case generation model The transfer function of

[0079] Determine the acceptance state: Determine the observable test case generation model The acceptance states in the test case generation model are the state sets that contain the acceptance states in the labeled test case generation model;

[0080] Generate models based on observable test cases The accepting states in the sparse matrix refine the input equivalence class and generate an observable test case generation model. Input equivalence class of ;

[0081] Otherwise, the labeled test case generation model is used as the observable test case generation model .

[0082] Preferably, a pair of symbolic traces of the observable test case generation model Mʹ is distinguishable and satisfies: there exists a symbol input / output sequence , the symbol trace , The corresponding state s 1 、s 2 To distinguish, as shown below:

[0083] ;

[0084] in, Represents an observable test case generation model is a collection of symbol traces of , and ,

[0085] use This represents the set of all distinguished sequences:

[0086] .

[0087] Preferably, the test case is a symbolic input / output sequence, and all test cases constitute a test suite TS. , each test case meets the following requirements:

[0088] (1) TS contains an observable test case generation model The minimum state cover V, where ;

[0089] (2) For any different test cases , there exists a symbol input / output sequence , so that ;

[0090] (3) TS contains the following sets:

[0091] ;

[0092] (4) For satisfaction Any and ,exist , so that , represents the empty set;

[0093] (5) For satisfaction and Any ,exist , so that , Indicates a prefix.

[0094] In a second aspect, the present invention provides a completeness test case generation device based on a symbolic finite state machine, comprising:

[0095] An analysis module is configured to analyze the safety-critical system using STPA technology to obtain refined unsafe control actions and refined software safety requirements, convert the refined software safety requirements into linear temporal logic attributes, and further convert them into atomic propositions to form an atomic proposition set;

[0096] A modeling module is configured to use a symbolic finite state machine to model the safety-critical system, obtain a test case generation model, construct a number of mutants based on the test case generation model, obtain a fault domain, and calculate all valuation functions of the safety-critical system, obtain symbolic traces in the test case generation model and their corresponding concrete traces according to the valuation function, map the valuation function to a set of atomic propositions it satisfies, obtain propositional abstraction, and extend the propositional abstraction to an assignment sequence and concrete traces through a recursive definition;

[0097] a refinement module configured to refine the test case generation model based on the first-order expression to obtain the refined test case generation model, divide all valuation functions into equivalence classes based on the refined test case generation model to obtain input equivalence classes, mark the transformations of the refined test case generation model according to the input equivalence classes to obtain the marked test case generation model, build an observable test case generation model based on the marked test case generation model, and obtain an input equivalence class set of the observable test case generation model, wherein the observable test case generation model and the test case generation model are in the same fault domain;

[0098] The test case generation module is configured to generate test cases based on the input equivalence class set and proposition abstraction of the observable test case generation model, execute the test cases in the test case generation model and its mutants in the fault domain, and detect whether the test cases meet the refined software safety requirements. If not, the fault domain is rebuilt and the steps in the above modeling module and refinement module are repeated until the test cases meet the refined software safety requirements.

[0099] In a third aspect, the present invention provides an electronic device comprising one or more processors; a storage device for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement the method described in any implementation manner in the first aspect.

[0100] In a fourth aspect, the present invention provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the method described in any implementation manner in the first aspect.

[0101] In a fifth aspect, the present invention provides a computer program product, comprising a computer program, which, when executed by a processor, implements the method described in any implementation manner in the first aspect.

[0102] Compared with the prior art, the present invention has the following beneficial effects:

[0103] (1) The completeness test case generation method based on symbolic finite state machine proposed in the present invention uses STPA technology to analyze the safety-critical system and obtain comprehensive unsafe control actions, so that the software safety requirements derived further are also complete.

[0104] (2) The completeness test case generation method based on symbolic finite state machine proposed in the present invention converts the software safety requirements of the safety-critical system into linear temporal logic attributes through conversion rules. It can not only strictly represent the software safety requirements of the safety-critical system to facilitate the identification of the tested program, but also abstract the software safety requirements of the safety-critical system in a formalized way, which is more general and intuitive.

[0105] (3) The completeness test case generation method based on symbolic finite state machine proposed in the present invention divides the safety-critical system into equivalence classes when generating test cases. When faced with very complex safety-critical systems, the number of generated test cases can be further reduced, thereby greatly reducing the time required for testing.

[0106] (4) The completeness test case generation method based on symbolic finite state machine proposed in the present invention models the safety-critical system into a symbolic finite state machine, and uses the generated complete linear temporal logic attributes as attribute requirements to generate test cases to verify whether the safety-critical system meets the software safety requirements when facing control actions in different situations, thereby ensuring the completeness of the test. BRIEF DESCRIPTION OF THE DRAWINGS

[0107] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0108] Figure 1 A flowchart of a method for generating completeness test cases based on a symbolic finite state machine according to an embodiment of the present application;

[0109] Figure 2 A flowchart of a method for generating completeness test cases based on a symbolic finite state machine according to an embodiment of the present application for analyzing a safety-critical system and obtaining linear temporal logic properties;

[0110] Figure 3 A control structure diagram of a smartphone insulin pump system according to an embodiment of the present application;

[0111] Figure 4 A state diagram of a portion of states of a smartphone insulin pump system according to an embodiment of the present application;

[0112] Figure 5 A state diagram of a portion of states of a mutant of a smartphone insulin pump system according to an embodiment of the present application;

[0113] Figure 6 An example diagram of the power set construction method of an embodiment of the present application;

[0114] Figure 7 A schematic diagram of a completeness test case generation device based on a symbolic finite state machine according to an embodiment of the present application;

[0115] Figure 8 A schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present invention. DETAILED DESCRIPTION

[0116] In order to make the purpose, technical scheme and advantages of the present invention clearer, the present invention will be further described in detail below with reference to the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0117] Figure 1 A method for generating a completeness test case based on a symbolic finite state machine is shown in an embodiment of the present application, comprising the following steps:

[0118] S1, the safety-critical system is analyzed using STPA technology to obtain refined unsafe control actions and refined software safety requirements, and the refined software safety requirements are converted into linear temporal logic attributes, and further converted into atomic propositions to form an atomic proposition set.

[0119] In a specific embodiment, the safety-critical system is analyzed using STPA technology to obtain refined unsafe control actions and refined software safety requirements, and the refined software safety requirements are converted into linear temporal logic attributes, and further converted into atomic propositions to form an atomic proposition set, specifically including:

[0120] Identify the services, losses, hazards and system boundaries of safety-critical systems, and determine the system-level constraints of safety-critical systems based on hazards;

[0121] Building a control structure based on services, hazards, system boundaries and system-level constraints. The control structure includes a controller and a controlled process. The controller issues control actions to the controlled process.

[0122] Based on the combination of control actions and their related state variables and key variables, refined unsafe control actions are identified, and refined software safety requirements are generated according to the refined unsafe control actions. The refined unsafe control actions are represented as a quaternary (CA, Cs, C, TC), where CA represents the control action that causes danger, Cs=∪(P 1 =v 1 ,…P n =v n ) represents the combination of state variables and key variables related to the control action CA, C represents the situation where providing or not providing the control action CA is dangerous, TC represents the situation where the control action CA is provided, which is divided into any time, too early or too late;

[0123] The refined software safety requirements are converted into linear temporal logic properties according to the following rules:

[0124] When the combination Cs i The controller should never provide control action CA when the value is i , where Cs=∪(P 1 =v 1 ,…P n =v n ),i {1,…,n}, the conversion formula is:

[0125] LTL i =G(Cs i →!(controlAction==CA i ));

[0126] In combination Cs i The controller should not provide control actions too early before the value of CA occurs. i , the conversion formula is:

[0127] LTL i =G(((controlAction==CA i )→!Cs i )&!((controlAction==CA i )∪Cs i ));

[0128] In combination Cs i After the value of occurs, the controller should not provide control action CA too late i , the conversion formula is:

[0129] LTL i =G((Cs i →!(controlAction==CA i ))&!(Csi ∪(controlAction==CA i )));

[0130] When the combination Cs i The controller must immediately provide a control action CA in the next time step when i , the conversion formula is:

[0131] LTL i =G(Cs i →X(controlAction==CA i ));

[0132] Further converted into atomic propositions according to linear temporal logic properties to form an atomic proposition set;

[0133] The syntax of a linear temporal logic property formula η is given by the following grammar:

[0134] ;

[0135] Among them, η AP stands for atomic proposition, and AP stands for the set of atomic propositions, written as a quantifier-free first-order expression for variable symbols from I∪O:

[0136] ;

[0137] in, , represents any linear temporal logic attribute formula, is a proposition trace, i and j are indexes, and the expression Suffix indicating trace ,and , Represents the power set of the atomic proposition set AP, for a proposition trace of infinite length Finite prefix of ,writing To specify yes a finite prefix of ;

[0138] The semantics of the path operators F, G, and W are defined by the following grammatical abbreviations: , , , ≡ means definition, ∨ means or, ¬ means negation;

[0139] A linear temporal logic attribute formula is a set P of propositional traces satisfying , where \ represents the complement, , Respectively represent the proposition trace Two different finite prefixes of .

[0140] Specifically, STPA is a safety analysis method based on STAMP. STAMP is an accident causation model based on system theory, characterized by two pairs of concepts: hierarchy and urgency, and communication and control. STAMP regards accidents and losses as a dynamic control problem and the system as a set of organized elements that interact between itself and the surrounding environment.

[0141] There are four main steps in STPA, which are as follows:

[0142] (1) Define the purpose of the analysis, aiming to identify losses, hazards, and system boundaries;

[0143] (2) Modeling control structures, using STAMP to capture the functions, relationships, and interactions of elements;

[0144] (3) Identify unsafe control actions: Identify potential unsafe control actions (UCAs) and related safety constraints. For each control action, it is necessary to identify whether it may be dangerous;

[0145] (4) Identify loss scenarios and identify potential causes of loss scenarios;

[0146] The STPA technology is used to analyze the unsafe control actions of safety-critical systems. Furthermore, the software safety requirements are analyzed at the system level to ensure the comprehensiveness of the software safety requirements. The linear temporal logic properties (LTL) generated on this basis further guarantee the completeness.

[0147] The safety-critical system is analyzed using STPA technology to obtain software safety requirements, and the software safety requirements are converted into a flow chart with linear temporal logic attributes as shown in the following figure. Figure 2 In the embodiments of the present application, a smartphone insulin pump system (IPwS) is used as an operation example to demonstrate the method, and the smartphone insulin pump system (IPwS) is analyzed using STPA technology, which specifically includes the following steps:

[0148] 1. Define the purpose of the analysis, identify services, loss risks, system boundaries, and system-level constraints

[0149] In this step, the system, its services, components, boundaries, assumptions, losses, and hazards are defined.

[0150] IPwS provides smooth treatment of diabetes, using smartphones to monitor the user's blood sugar levels and control insulin injections. In emergency situations, the system calls medical services via the smartphone. The smartphone receives insulin levels from the sensor, calculates the required amount of insulin, and controls the insulin pump to inject insulin. The sensor measures blood sugar levels every 5 minutes. The smartphone calculates and sets the basal insulin amount based on the history of blood sugar levels. Basal insulin keeps blood sugar levels stable during fasting periods, such as during sleep. Before eating, the patient must enter the expected calorie value using an app.

[0151] If the smartphone receives low or high blood sugar levels multiple times in a row, it will communicate with the healthcare service, which will contact the patient. The smartphone and insulin pump may drain the battery. The patient is responsible for charging the battery and replenishing the insulin reservoir.

[0152] When using STPA technology for analysis, the following conditions are assumed:

[0153] The smartphone and insulin pump are already configured to pair, and they are paired with each other;

[0154] The smartphone and blood glucose sensor have been configured for pairing, and they have been paired with each other;

[0155] Patients always ensure that the smartphone’s battery has the energy required to perform computation, storage, and communication;

[0156] The application is updated promptly by the patient;

[0157] Other running applications will not interfere with the application's control of the insulin pump;

[0158] Patients had access to smartphones, and security and data privacy threats were not considered in this analysis.

[0159] The IPwS system has a service: continuously monitor the patient's blood sugar level; when the blood sugar level is high, the system must pump insulin; when the blood sugar level is low, the pumping must be stopped; when the blood sugar level is outside the limit for a long time, the medical service must be called.

[0160] The IPwS system includes the following components: patient, smartphone, insulin pump controller (IPC), glucose sensor, mechanical pump, battery sensor, reservoir sensor, controlled processes, and links connecting the components. The components and their links describe the system boundaries. Emergency treatment is part of the system, but the medical service component is not part of the system.

[0161] To make the description of the method complete, it is assumed that all components and links may fail.

[0162] For IPwS, a single loss was identified: (L1) patient death or injury due to the inability to control blood glucose levels.

[0163] Hazards are specific system states that, when combined with worst-case environmental conditions, could result in losses. For the IPwS system, the following hazards were identified: (H1) Pumping insulin when blood glucose levels drop (hypoglycemia); (H2) Not pumping insulin when blood glucose levels rise (hyperglycemia); and (H3) The insulin pump operates when the battery charge or insulin reservoir charge is below a minimum value. Hazards H1, H2, and H3 result in unacceptable losses L1.

[0164] System-level constraints are derived from the hazards. They are: (SLC1) the system must stop pumping insulin when the blood glucose level falls below a minimum level; (SLC2) the system must start pumping insulin when the blood glucose level rises above a maximum level; and (SLC3) the system must not run out of insulin and energy used to power the insulin pump and sensor. System-level constraints SLC1, SLC2, and SLC3 are associated with hazards H1, H2, and H3, respectively.

[0165] 2. Modeling control structures

[0166] The control structure is constructed based on the system's services, hazards, system boundaries, and system-level constraints. The control structure is a hierarchical system model that includes the system's components (controllers, sensors, actuators, and controlled processes), the flow of feedback and control actions, environmental disturbances, system inputs, and system outputs. The control structure imposes system-level constraints on the system's control actions. Reference Figure 3 Control structure diagram of the smartphone insulin pump system (IPwS), where the patient, smartphone, and IPC are controllers, and the controller issues control actions to the controlled process consisting of the patient, battery, and reservoir.

[0167] The sensors capture the energy level of the battery, the insulin level of the reservoir, and the blood glucose level of the patient's body. Start pumping and stop pumping are two control actions of the insulin pump controller (IPC), while the battery level and reservoir level are two feedbacks and the emergency flag is an external communication with the healthcare service component. The insulin pump controller (IPC) uses an algorithm to safely start and stop the pump. The algorithm uses a process model to issue control actions. The IPC process model has four variables: battery level, reservoir level, status, and insulin remaining to be pumped. The smartphone has a process model that issues the control actions pump base, pump active, and restore IP status. The patient has a process to interact with the smartphone and the insulin pump device.

[0168] 3. Identify unsafe control actions

[0169] An unsafe control action (UCA) is a control action that can lead to hazards in specific situations and worst-case scenarios. For the IPwS system, we identified 20 unsafe control actions for three controllers, as shown in Table 1. After each UCA, we add the hazard identification (H1, H2, or H3) caused by the unsafe control action (UCA), for example, UCA1 leads to H1.

[0170] Table 1 Unsafe control actions

[0171]

[0172] 4. Identify loss scenarios and software security requirements

[0173] The software safety requirements of the controller can be derived directly from the unsafe control actions UCA1–UCA20.

[0174] When using STPA to analyze safety-critical systems, loss scenarios are used to describe the causes that could lead to unsafe control actions and hazards. There are two types of loss scenarios: The first type explains why an unsafe control action occurred. The second type explains why a control action was incorrectly executed or not executed, resulting in a hazard. Loss scenarios that lead to unsafe control actions include controller-related faults, inadequate control algorithms (flawed specifications, flawed implementations), unsafe control inputs, and inadequate process models (including incorrect / missing / no feedback information).

[0175] For example, a battery sensor failure is the cause of the unsafe control action "IPC does not provide for stopping the pump when there is no insulin left to pump". The second type of loss scenario includes scenarios involving the control path from the controller to the controlled process. For example, a mechanical pump failure is the cause of the unsafe control action "IPC does not provide for stopping the pump when there is no insulin left to pump".

[0176] Among the loss scenarios identified were mechanical pump failure, battery sensor failure, reservoir sensor failure, glucose sensor failure, and battery failure. These failures were chosen because they are examples of the most common device failures.

[0177] The smartphone app must be able to read the battery, reservoir, glucose sensor readings and identify possible failures. The app warns the patient. The patient is responsible for sending the device for maintenance when warned. These recommendations are derived from previously identified loss scenarios.

[0178] For IPwS, a total of 23 software safety requirements (SSRs) were identified, of which 20 software safety requirements (SSR1-SSR20) were derived from unsafe control actions (UCA1-UCA20), and another 3 software safety requirements (SSR21-SSR23) were derived from loss scenario identification, including one software safety requirement related to device reliability (SSR21) and another two software safety requirements related to patient procedures (SSR22 and SSR23). As shown in Table 2, Table 2 shows some software safety requirements, and the displayed software safety requirements will be used to describe the steps of the method provided in the embodiments of the present application.

[0179] Table 2 Software security requirements

[0180]

[0181] Specifically, the refined unsafe control action (RUCA) is represented as a quaternion (CA, Cs, C, TC), where CA represents the control action that leads to the hazard H, and H HA, HA represents the relative risk, Cs=∪(P 1 =v 1 ,…P n =v n ) represents the combination of state variables and key variables related to the control action CA, that is, the key combination of process model variables (PMV), C represents the situation where it is dangerous to provide or not provide the control action CA, and TC represents the situation where the control action CA is provided, which is divided into any time, too early or too late.

[0182] In order to automatically transform the critical combination of process model variables for each control action CA into an unsafe software scenario, the following rules are set:

[0183] Rule 1: When providing control actions CA i In case (C1), each refined unsafe control action (RUCA) can be expressed as: When < Cs=∪(P 1 =v 1 ,…P n =v n )>When it occurs, RUCA i = <ca>supply <tc>is dangerous.

[0184] Rule 2: When no control action CA is provided i In case (C2), each refined unsafe control action (RUCA) can be expressed as: when < Cs=∪(P 1 =v 1 ,…P n =v n )>When it occurs, RUCA i = <ca>Not providing it is dangerous.

[0185] By using Rules 1 and 2, refined unsafe control actions are identified based on the key combinations of control actions and their related process model variables, and refined software safety requirements (RSSR) are generated based on the refined unsafe control actions. The following rules are set:

[0186] Rule 3: When providing control actions CA i In case (C1), each RUCA i can be automatically converted into a new software safety requirement as follows: RSSR i = <ca>Must be in <Cs=∪(P 1 =v 1 ,…P n =v n )>Not provided when it occurs <tc>.

[0187] Rule 4: When no control action CA is provided i In case (C2), each RUCA i can be automatically converted into a new software safety requirement as follows: RSSR i = <ca>Must be in <Cs=∪(P 1 =v 1 ,…P n =v n )> is provided when it occurs.

[0188] By using rules 3 and 4, the unsafe control action RUCA is refined i Each refined software safety requirement identified in the RSSR i can all be automatically converted into formal specifications in LTL, namely linear temporal logic properties.

[0189] Furthermore, Rule 3 defines three types of software safety requirements, which means that in the combination of Cs i TC = Any time, too early or too late, no control action CA can be provided i Each type of software safety requirement can be automatically converted into linear temporal logic properties by the following rules:

[0190] Rule 3.1: Every RSSR derived from any time a control action CAi is provided i Can be automatically converted to linear temporal logic attributes LTL i , the conversion formula is:

[0191] LTL i =G(Cs i →!(controlAction==CA i ));

[0192] Rule 3.1 states that when the combination Cs i The controller should always (G) not provide control action CA i , where i {1,…,n}.

[0193] Rule 3.2: From providing control actions CA i Each RSSR derived in the too early case i Can be automatically converted to linear temporal logic attributes LTL i , the conversion formula is:

[0194] LTL i =G(((controlAction==CA i )→!Cs i )&!((controlAction==CA i )∪Cs i ));

[0195] Rule 3.2 states that in the execution path, combine Cs i Before the value of has not become true, the controller (G) should not be in the combination Cs i The value of the control action CA is provided before the i , and in the combination Cs i The value of CA should be provided when i , that is, in the combination Cs i The controller should not provide control actions too early before the value of CA occurs. i .

[0196] Rule 3.3: Every RSSRi derived from the case where it is too late to provide a control action CAi can be automatically converted to a linear temporal logic property LTL i , the conversion formula is:

[0197] LTL i =G((Cs i →!(controlAction==CA i ))&!(Cs i ∪(controlAction==CA i )));

[0198] Rule 3.3 states that in the execution path, combine Cs i When the value of the occurrence becomes previously true, the controller (G) should always provide the control action CA not too late i , that is, in the combination Cs i After the value of occurs, the controller should not provide control action CA too late i .

[0199] Furthermore, Rule 4 defines a type of software security requirement, namely, no control action CA is provided i This type of software safety requirement can be automatically converted into linear temporal logic properties through the following rules:

[0200] Rule 4.1: Never provide a control action CA i Each RSSR derived in the case of i Can be automatically converted to linear temporal logic attributes LTL i , the conversion formula is:

[0201] LTL i =G(Cs i →X(controlAction==CA i ));

[0202] Rule 4.1 states that the combination Cs i The occurrence of a value of always means that the controller must immediately provide a control action CA in the next time step (X) i , without delay.

[0203] For example, the corresponding linear temporal logic property of IPwS software safety requirement SSR7 (patient cannot enter calories when "battery is low" or "insulin reservoir level is low") is as follows:

[0204] .

[0205] Specifically, for any set X, its power set is 2 X According to the linear temporal logic properties, it is further converted into atomic propositions to form an atomic proposition set AP, which contains atomic propositions that appear in the linear temporal logic properties satisfied by the test case generation model and verify the safety-critical system. The semantics of the linear temporal logic property formula η is in the infinite sequence π of the set (2 AP ) ω In the embodiment of the present application, the syntax of the linear temporal logic attribute formula η is given by the following grammar:

[0206] ;

[0207] Among them, η AP stands for atomic proposition, written as a quantifier-free first-order expression for variable symbols from I∪O:

[0208] ;

[0209] in, , represents any linear temporal logic attribute formula, is a proposition trace, i and j are indexes, and the expression Suffix indicating trace ,and , Represents the power set of the atomic proposition set AP, for a proposition trace of infinite length Finite prefix of ,writing To specify yes The implication operator is introduced by syntactic abbreviation The semantics of the path operators F, G, and W are defined by the following grammatical abbreviations: , , , Indicates the definition, Indicates or Indicates negation.

[0210] A linear temporal logic attribute formula is a set P of propositional traces satisfying ,in, represents the complement, , Respectively represent the proposition trace Two different finite prefixes of .

[0211] Linear temporal logic attribute formula and the set P of proposition traces are all safe properties. Any violation of the safety property (i.e. ) can be traced by a finite prefix (i.e. bad prefix) identification so that Any continuation of will not be part of P. Linear temporal logic property formulas (LTL formulas) are exactly those specifications whose violations can be detected on a finite trace. Therefore, this application restricts itself to property-oriented testing of safety properties. Every linear temporal logic property formula Violation You can use only the operator , , , To express.

[0212] S2, use symbolic finite state machine to model the safety-critical system and obtain the test case generation model. Based on the test case generation model, several mutants are constructed and the fault domain is obtained. All valuation functions of the safety-critical system are calculated. The symbolic traces in the test case generation model and their corresponding concrete traces are generated according to the valuation functions. The valuation functions are mapped to the set of atomic propositions they satisfy to obtain propositional abstraction. The propositional abstraction is extended to the assignment sequence and concrete traces through recursive definition.

[0213] In a specific embodiment, a symbolic finite state machine is used to model a safety-critical system to obtain a test case generation model, a number of mutants are constructed based on the test case generation model, a fault domain is obtained, and all valuation functions of the safety-critical system are calculated. The symbolic traces in the test case generation model and their corresponding specific traces are generated according to the valuation functions, the valuation functions are mapped to the set of atomic propositions they satisfy, and propositional abstraction is obtained. The propositional abstraction is extended to the assignment sequence and the specific traces through recursive definition, which specifically includes:

[0214] The safety-critical system is modeled using a symbolic finite state machine to obtain a test case generation model, which is represented by an octet , where the finite set S represents the state space, represents the initial state, R represents the conversion relationship, , the finite set I contains the input variable symbols, the finite set O contains the output variable symbols, and the set Var represents , D represents the union of all variables on the type domain, represents the input alphabet, which is a set of finite input events, each of which is a quantifier-free first-order expression on the input variables. represents the output alphabet, which is the set of output expressions;

[0215] Based on the test case generation model, several mutants are constructed by introducing incorrect behaviors. The incorrect behaviors include: incorrect or swapped input events, incorrect or swapped output expressions, transmission failures, added or lost states. Transmission failures include additional, lost or misleading conversions, and adding incorrect input events to the input alphabet ∑ I In the output alphabet, add the wrong output expression to the output alphabet ∑ O In the test case generation model, the wrong input events and wrong output expressions do not appear anywhere. The fault domain is constructed based on all mutants. The fault domain is represented as Z(I,O,D,∑ I ,∑ O ,AP,n,m), where n means that the test case generation model M has n distinguishable states, and m means that the mutants of the test case generation model M have at most m distinguishable states;

[0216] Valuation Function Indicates that each variable symbol a value of the type corresponding to one in D Connected, Represents the valuation function Is an input event Model, which will input events Each variable symbol v in D is replaced by a value of the corresponding type in D. After that, the Boolean expression is true. Represents the valuation function Is an input event and its corresponding output expression conjunction The model calculates all valuation functions of the safety-critical system. The set of all valuation functions mapped from Var to D is expressed as ;

[0217] The symbolic path ζ of the test case generation model M is an infinite sequence, expressed as:

[0218] ;

[0219] Among them, "." represents the sequence concatenation symbol, Represents the initial state of the test case generation model M. For all , ;

[0220] The symbol trace τ of the test case generation model M is a finite sequence, expressed as:

[0221] ,satisfy:

[0222] , , so that ,in, Indicates existence, It means any;

[0223] The set of symbolic traces of the test case generation model M is denoted as T(M);

[0224] The specific path of the test case generation model M is an infinite sequence, expressed as:

[0225] (s 0 ,σ 1 ,s 1 ).(s 1 ,σ 2 ,s 2 )··· (S×D Var ×S) ω ;

[0226] Among them, σ i D Var , so that the test case generation model M has a symbol path:

[0227] satisfy , ;

[0228] The specific trace τ of the test case generation model M is a finite sequence, expressed as:

[0229] ;

[0230] So that the test case generation model M has a symbolic trace satisfy , then the specific trace Symbolic trace Witness, expressed as ;

[0231] The set of specific traces of the test case generation model M is denoted as L(M);

[0232] Map the valuation function σ to the set of atomic propositions AP that it satisfies, and obtain the propositional abstraction ω, as shown in the following formula:

[0233] ;

[0234] Represents the corresponding mapping relationship. Through recursive definition, the propositional abstraction ω is extended to the assignment sequence and the specific trace:

[0235] ;

[0236] Among them, ε represents the empty trace;

[0237] For linear temporal logic attribute formulas and finite prefix , if and only if yes When there is a bad prefix, use the symbol ; if and only if any specific trace of the test case generation model M will not be abstracted by the proposition Abstracted as , then the test case generation model M is the model corresponding to the linear temporal logic attribute, that is .

[0238] Specifically, in the test case generation process, a set of atomic propositions AP and a symbolic finite state machine (SFSM) are input as the test case generation model to guide the generation process and serve as the test machine. The test case generation model can be nondeterministic and operate on infinite input and output domains. The generated test suite is used to verify whether the safety-critical system satisfies each linear temporal logic property on the atomic propositions from AP that are satisfied by the test case generation model.

[0239] Symbolic finite state machines clearly display system behavior in graphical form by explicitly defining the states of the system and the transitions between states. In safety-critical systems, the use of symbolic finite state machines can better and more comprehensively describe the safety requirements of the system and model input events of more data types. At the same time, the method proposed in this application provides an intuitive and effective way to generate test cases. Unlike the finite state machine (FSM)-based method, this application operates on potentially uncertain SFSMs and uses LTL formulas as the specification form of properties. When modeling complex reactive systems, SFSMs are more expressive than FSMs, and specifying properties in LTL is more general and intuitive than the FSM-specific restricted specification style used previously.

[0240] In the embodiment of the present application, the test case generation model obtained by modeling the safety-critical system using a symbolic finite state machine is represented as an octet , where the finite set S represents the state space, represents the initial state, R represents the conversion relationship, , the finite set I contains the input variable symbols, the finite set O contains the output variable symbols, and the set Var represents , and the variables are typed, and infinite domains like real numbers or infinite integers are acceptable, D represents the union of all variables over the type domain, represents the input alphabet, which is a set of finite input events, each of which is a quantifier-free first-order expression on the input variables. The output alphabet is the set of output expressions, which are quantifier-free first-order expressions on input variables and at least one output variable, where the input variables are optional. Constants, function symbols, and arithmetic operators are allowed in these expressions, but they are required to be solvable based on some decision theory, such as by an SMT solver. The set of all formulas using Var symbols is denoted by F(Var).

[0241] Example 1:

[0242] refer to Figure 4 , take the partial states of the smartphone insulin pump system as an example to illustrate the symbolic finite state machine, where s 1 is the initial state, indicating that the patient's blood sugar is normal, s 2 The patient is in a state of high blood sugar. 3 The patient is in a state of hypoglycemia. Glucose level is the blood sugar level. The device detects the patient's blood sugar level. When the blood sugar level is higher than 10mmol, IPwS starts to inject insulin and s 1 The state transition is s 2 Status. 2 If the patient's blood sugar is still high, continue to inject. If the blood sugar drops to between 3.9-10mmol, stop injecting insulin and switch to s 1 Status, in s 1 If the patient's blood sugar is stable, there is no need to inject insulin to maintain s 1 If the blood sugar level is lower than 3.9mmol, the patient is prompted to eat, replenish blood sugar, and switch to s 3 Status. 3 If blood sugar rises to between 3.9-10mmol after eating, stop eating and switch to s 1 If the blood sugar level is higher than 10mmol, IPwS starts to inject insulin and 3 The state transition is s 2 state.

[0243] It contains a set of uncertain transformations, in s 1 If the blood sugar level is equal to 3.9, IPwS can choose not to inject insulin and maintain it at s 1 status, or remind the patient to eat and switch to s 2 state.

[0244] Represent the smartphone insulin pump system as: , which has a state space S IPwS = and the initial state s 1 , the variable symbol is , , type domain , which represents the input range and also covers the reachable output variable range When replacing constant identifiers with their actual values ​​and taking into account input variable scope When , the input alphabet for IPwS can be rewritten as:

[0245] ;

[0246] Likewise, the output alphabet can be expressed as:

[0247] ;

[0248] The conversion relationship can be expressed as:

[0249] .

[0250] Example 2:

[0251] refer to Figure 4 , for IPwS, two security properties are considered, which are expressed as two requirements in natural language:

[0252] R1. As long as the value of x does not exceed 10, insulin cannot be injected;

[0253] R2. If you are injecting insulin, continue injecting insulin unless the actual blood sugar level drops below 10.

[0254] Convert R1 and R2 into LTL formulas respectively, as shown below:

[0255] ;

[0256] ;

[0257] According to the definition of operator W, the LTL formula expresses one of two things: on infinite traces, either Never happens and Globally established, either Eventually happens, but at this point make sure At least in The ending trace prefix holds, that is, before x>10. Convert R2 to LTL formula The process is very simple, because the formula structure is exactly the same as the text structure. and The atomic propositions that appear in and Consider η 1 and η 2 For example, any model with the prefix The (infinite) proposition satisfy ,and yes As shown in the general rule, represents the finite number of repetitions of the element e, Represents an infinite sequence of e elements.

[0258] Referring to Example 3, if an LTL formula has a model on its set of atomic propositions, then extending that set will also lead to a model on the extended set.

[0259] Example 3:

[0260] The trace of the proposition in Example 2 Leading to other models , when AP 2 Expand to ,π 2 Each element All can be obtained from The atomic propositions of is compatible as a first-order expression, for example, .

[0261] In the embodiment of the present application, the linear temporal logic attributes have been obtained in step S1, so they can be directly applied. Of course, the linear temporal logic attributes generated according to step 2 should also be integrated into the form of atomic proposition sets AP, and test cases are generated based on this.

[0262] Specifically, mutants usually refer to variants created by introducing intentional errors or changes to the original system or model. These mutants are used to evaluate the system's tolerance to errors and whether the system can correctly detect, handle or prevent these errors. When testing, it is necessary not only to verify whether the system produces correct output when facing correct input events in the state, but also to verify the system's ability to handle erroneous input events. This requires introducing some mutants and including mutants in the test cases. The system can only pass the test if it can correctly detect, handle or prevent all errors. The erroneous behavior of the system is captured by a finite set of mutant SFSMs, whose behavior may deviate from the test case generation model, including (a) erroneous or swapped input events, (b) erroneous or swapped output expressions, (c) transmission failures, including additional, missing or misleading transitions, and (d) added or missing states (always involving transmission failures). In order to handle mutants and test case generation models in the same situation, erroneous input events are included in the input alphabet ∑ I In the output alphabet ∑ O , but does not appear anywhere in the test case generation model.

[0263] Example 4:

[0264] refer to Figure 5 , introduce the wrong behavior to IPwS to construct the mutant I-IPwS. The input events marked with bold have errors: 1 Convert to s 2 The blood sugar level in the state should be greater than 10mmol, but it becomes greater than or equal to 10mmol in I-IPwS. 3 Convert to s 2 The blood glucose level in the state should be greater than 10mmol. Here it becomes 11mmol. I-IPwS does not contain any transmission failure.

[0265] Furthermore, in black box testing, a fault domain is introduced to limit the possibility of erroneous behavior. In the embodiment of the present application, a fault domain Z(I, O, D, ∑ I ,∑ O ,AP,n,m), a fault domain is a set of symbolic finite state machines with the following properties:

[0266] Each member Ms belonging to a fault domain Z has at most m ≥ n states when represented in observable form; it references input and output variables from I and O, and these variables are typed by D;

[0267] Each member of the fault domain uses ∑ I All or part of the input events and ∑ O All or part of the output expression contained in ;

[0268] Linear temporal logic properties have atomic propositions in the set AP, where the free variables are in I∪O.

[0269] The alphabet of fault domain Z is the union of all input events, output expressions, and atomic propositions of the formula to be verified.

[0270] Obviously, any model M with n distinguishable states in this fault domain can be used as a test case generation model. The potential fault implementations captured by the fault domain have real behaviors represented by Ms∈Z, where Ms has at most m distinguishable states and is a mutation of M.

[0271] Therefore, Ms may use ∑ I Other input expressions that are never used by the test case generation model are used to perform transport failures and use ∑ O output expressions in that are never used by the test case generation model. In addition, Ms may use input events and output expressions from the alphabet of the test case generation model, with arbitrary transformations.

[0272] For the actual construction of fault domain Z, collect all input events and output expressions that appear in the test case generation model and add mutations for all potential input events and output expressions that are expected to appear in the faulty implementation. For "pure" black box testing, these mutations must be guessed.

[0273] Specifically, the valuation function is a model of a specific input event and the corresponding output event. Indicates that each variable symbol a value of the type corresponding to one in D For any A subset of express For subdomains The set of all valuation functions mapped from Var to D is represented by D Var Note that in the ordered set of variable symbols Var = {v 1 ,... v m }, D Var Can be used with D m The m-tuple set of tuples corresponds to: 1 ,...,d m )∈Dm and the valuation function One to one correspondence. represents the set of all finite sequences from Var to D. Represents the valuation function Is an input event Model, which will input events Each variable symbol v in D is replaced by a value of the corresponding type in D. After that, the resulting Boolean expression is true. This application only considers well-formed SFSMs: this means that for a certain transformation Each pair that appears in , for input events and its corresponding output expression conjunction At least one model exists Assuming that each SFSM is fully specified, then in each state, the union of each model in the set of inputs that applies to at least that state is equal to the entire set of input valuations , or it can be represented by the fact that the disjunction of all inputs to a state is always a true form.

[0274] Example 5:

[0275] refer to Figure 4 , in IPwS, the valuation function yes A model of . refer to Figure 4 and Figure 5 , it is easy to see that all traces (transitions) of IPwS and I-IPwS have models, so both SFSMs are well-formed. In addition, both SFSMs are fully specified. Further, the valuation function is also used for equivalence class partitioning. In the above description, Represents input When , whether the model still , whose inputs are contained in Within this range, the output of the system is also the same, so they are classified into the same equivalence class.

[0276] Specifically, for any set X, the set of finite sequences is The set of infinite sequences is represented by express.

[0277] The symbolic path ζ of the test case generation model M is an infinite sequence, expressed as:

[0278] ;

[0279] Among them, "." represents the sequence concatenation symbol, Represents the initial state of the test case generation model M. For all , , the symbol trace τ of the test case generation model M is a finite sequence, expressed as:

[0280] ,satisfy:

[0281] , , so that ,in, Indicates existence, represents any. This means that there exists a path to M , so that Prefix The input events and output expressions are the same as Using the intuitive notation inherited from the Mealy machine To represent these predicate pairs, Specify input events. Specifies the output expression. The set of symbolic traces of M is denoted by T(M).

[0282] The specific path of the test case generation model M is an infinite sequence, expressed as:

[0283] (s 0 ,σ 1 ,s 1 ).(s 1 ,σ 2 ,s 2 )··· (S×D Var ×S) ω ;

[0284] Among them, σ i D Var , so that the test case generation model M has a symbol path:

[0285] satisfy , i≥1; the specific trace τ of the test case generation model M is a finite sequence, expressed as:

[0286] κ=σ 1 ... n (D Var ) ∗ ;

[0287] So that the test case generation model M has a symbolic trace satisfy , then the specific trace Symbolic trace Witness, expressed as ; The set of specific traces of the test case generation model M is denoted as L(M).

[0288] A SFSM is deterministic if the sequence of input estimates uniquely determines the associated output sequence. More formally, two specific traces satisfy satisfy Note that nondeterminism can be introduced in SFSMs in two ways: (a) through non-mutually exclusive input events and symbolic traces from the same state, and (b) through nondeterministic output expressions.

[0289] In the field of modeling formalisms for safety-critical systems, the behavior (or language) of a SFSM is usually defined by its specific set of traces and expressed as Representation. Two SFSMs are (linguistically) equivalent if and only if they have the same set of concrete traces. In testing, safety-critical systems require that systems with correct behavior are equivalent, which ensures that they produce the same output when faced with the same input events without errors. Symbolic traces are abstract intervals of concrete traces. Examples 4 and 5 can more intuitively understand symbolic traces and concrete traces. A path is a set of traces from one state to another. It includes every trace in the system and every possible transition. There may be many transition paths from one state to another.

[0290] Example 6:

[0291] Some symbols of IPwS are as follows:

[0292] τ 1 =ε;

[0293] ;

[0294] ;

[0295] As shown in Example 4, the symbol trace has a relatively large range, and any input range of x is acceptable as long as it is within the range required by the symbol trace.

[0296] Example 7:

[0297] It is the witness of the symbol trace τ2 in Example 6.

[0298] It is the specific trace of IPwS and the witness of the symbolic trace τ3 in Example 6. As shown in Example 7, the specific trace corresponds to the specific input event and output expression. It is not like the symbolic trace, as long as the value of x or y is in the corresponding interval. Each specific trace should be unique. Only when the values ​​of x and y are strictly corresponding can it be a corresponding specific trace.

[0299] Furthermore, for specific traces , using the following abbreviations:

[0300] for ,expression represents a sequence with all elements restricted to W ,Right now .

[0301] For disjoint sets and equal length The specific traces ,expression Representation sequence The valuation function of .

[0302] A SFSM is deterministic if the sequence of input estimates uniquely determines the sequence of outputs associated with them. More formally, Two specific traces of satisfy . Note that nondeterminism can be introduced in an SFSM in two ways: (a) by symbolic traces of input events that are not mutually exclusive from the same state, and (b) by nondeterministic output expressions. As in the reactive systems modeling formalism, the behavior (or language) of an SFSM is defined by its collection of concrete traces, expressed as Two SFSMs are (linguistically) equivalent if and only if they have the same set of concrete traces.

[0303] Specifically, propositional abstraction is used to map the valuation functions σ to the set of atomic propositions they satisfy, so as to identify the linear temporal logic properties corresponding to the specific trace or valuation function σ. Therefore, when testing the corresponding specific trace, it is possible to simultaneously verify whether the valuation function σ satisfies its corresponding linear temporal logic properties. If all safety-critical systems satisfy the linear temporal logic properties, this test is complete, because the software safety requirements derived from STPA are complete, and the linear temporal logic properties converted into them are also complete, and this completeness is transitive.

[0304] Example 8:

[0305] Use in equation The atomic proposition AP defined in comes from the specific trace in Example 7:

[0306] ;

[0307] The specific trace Perform propositional abstraction and become propositional trace , for linear temporal logic property formula η and finite proposition trace , if and only if yes Bad prefixes, represented by symbols ,in It is not true. For the test case generation model, the model corresponding to the linear temporal logic attribute formula η is written as , if and only if .

[0308] This means that any specific trace of the test case generation model will not pass Abstracted as Bad prefix. The domain can be set by Further extended to a set of specific traces .

[0309] The following theorem states that if all concrete traces of Ms are abstracted over the atomic propositions of AP and are included in the concrete traces of M that are equally abstract, then any linear temporal logic property formula about AP that M satisfies will also be satisfied by Ms.

[0310] Theorem: Assume , and AP given, and are two well-formed SFSMs, assuming ,let is a linear temporal logic property formula about AP, then .

[0311] S3, refine the test case generation model based on the first-order expression to obtain the refined test case generation model, divide all valuation functions into equivalence classes based on the refined test case generation model to obtain input equivalence classes, mark the transformations of the refined test case generation model according to the input equivalence classes to obtain the marked test case generation model, build an observable test case generation model based on the marked test case generation model, and obtain the input equivalence class set of the observable test case generation model, the observable test case generation model and the test case generation model are in the same fault domain.

[0312] In a specific embodiment, the test case generation model is refined based on the first-order expression to obtain a refined test case generation model, all valuation functions are divided into equivalence classes based on the refined test case generation model to obtain input equivalence classes, the transformation of the refined test case generation model is marked according to the input equivalence classes to obtain a marked test case generation model, an observable test case generation model is constructed based on the marked test case generation model, and an input equivalence class set of the observable test case generation model is obtained, the observable test case generation model and the test case generation model are in the same fault domain, specifically including:

[0313] Provide a finite set Q containing A subset of the finite set Q of quantifier-free first-order expressions of free variables The first-order expression in has only free variables from I. Based on the test case generation model M, a refined test case generation model is constructed, which is expressed as , the refined test case generation model Q(M) and the test case generation model are in the same fault domain, for any subset of the first-order expression , define a Boolean expression:

[0314] ;

[0315] Among them, ∧ means and;

[0316] Define the input alphabet of Q(M) as follows:

[0317] ;

[0318] Among them, D I represents the union of each valuation function in a set of inputs that are applicable to at least this state in each state of the test case generation model M;

[0319] Define the transfer relationship of Q(M) as shown below:

[0320] ;

[0321] All valuation functions are divided into equivalence classes according to the following rules:

[0322] Defining the first-order formula is from Y and the complement The conjunction of the negation formula is as follows:

[0323] ;

[0324] The alphabet ∑ of the fault domain is the union of all input events, output expressions, and atomic proposition sets of the linear temporal logic property formulas to be verified, expressed as , the set Y represents the set constructed according to the above formula with at least one valuation function As all input events of the model The set Y is as follows:

[0325] ;

[0326] For each , define an input equivalence class , expressed as:

[0327] ;

[0328] The set A of all input equivalence classes is expressed as:

[0329] ;

[0330] According to the input equivalence class Mark the transitions of the refined test case generation model Q(M) to obtain the marked test case generation model. If the marked test case generation model has transitions that start from the same starting state s but end at different target states

[0331] Then the power set construction method is applied to the marked test case generation model to obtain the observable test case generation model. , including:

[0332] Determine the initial state: Use the initial state of the labeled test case generation model as an observable test case generation model The initial state of

[0333] Determine the state set: For each state set, deduce the possible states it can be converted to on each input event, form a new state set, and become an observable test case generation model Status in

[0334] Determine the transition function: Based on the transition function of the labeled test case generation model and the trace of each state set on each input event, determine the observable test case generation model The transfer function of

[0335] Determine the acceptance state: Determine the observable test case generation model The acceptance states in the test case generation model are the state sets that contain the acceptance states in the labeled test case generation model;

[0336] Generate models based on observable test cases The accepting states in the sparse matrix refine the input equivalence class and generate an observable test case generation model. Input equivalence class of ;

[0337] Otherwise, the labeled test case generation model is used as the observable test case generation model .

[0338] Specifically, Q(M) is called a refinement of M by means of the first-order expression Q. The term "refinement" here means that the input events associated with the Q(M)-transition are more "refined", i.e., more convenient, than the original language of M. However, this refinement does not change the language of M. The input alphabet of Q(M) consists of the original input events Composition, further through the first-order regular expression and negation table The conjunctions of are restricted so that the resulting conjunctions still have models. Similarly, conjunctions without models are discarded. The refinement here preliminarily divides the input events and output expressions so that the input events and the input alphabet are no longer disordered, but are divided into corresponding intervals.

[0339] Example 9:

[0340] refer to Figure 4 State diagram of some states of the smartphone insulin pump system. When the input event is x∈(10,15], these input events are grouped together, so as to focus on detecting traces caused by the input event x∈(10,15] (i.e., blood glucose level>10mmol). Without refinement, if a sequence such as x=1, x=11, x=1.1, x=12 is tested, the system state will inevitably switch repeatedly during the test. At the same time, Q(M) has preliminarily divided the input alphabet. As mentioned earlier, input events such as x=11, x=12 or other events belonging to x∈(10,15] are grouped together.

[0341] Specifically, the method in this application needs to be able to test safety-critical systems with conceptually infinite and continuous input domains. Therefore, it is usually impossible to apply a test strategy to enumerate all possible input events and check every possible output interface value of the safety-critical system, even if the infinite set in the model (such as the interval of R) is implemented with finite data types, such as floating point numbers or double precision. Therefore, it is necessary to perform equivalence class partitioning and observable transformation for systems with continuous input variables to generate completeness test cases. The input domain is divided into a finite number of subsets, called input equivalence classes, so that two members of the same class are guaranteed to perform the same transformation in the same state. Because the same input events and output expressions fully satisfy the same subset of atomic propositions appearing in the LTL formula to be verified. For example, the detection value of blood sugar level in the IPwS model is an infinite set of values, which can be any value between 0-15. Equivalence class partitioning is to divide these infinite values ​​into equivalent intervals and then process them. For example, when blood sugar is higher than 10mmol, no matter what its specific value is, as long as it is higher than 10mmol, insulin injection will be started.

[0342] Since safety-critical systems may use faulty input expressions, it is not sufficient to use only a subset of the input events created in the test case generation model as the input class, but also to consider faulty input events. In addition, different atomic propositions in the potential output expressions may apply to different inputs that satisfy the same input event. Therefore, the path of the input equivalence class depends on the complete input and output alphabets assumed for the fault domain, as well as the atomic propositions appearing in the formula to be verified. Furthermore, since Q(M) has partitioned the input events and output expressions according to the corresponding intervals, a preliminary partitioning is performed, given the alphabet ∑ = Q(∑ I ) ∪∑ O ∪AP, construct an input equivalence class, and convert the evaluation function set D Var However, in this application, the output expressions are not divided into equivalence classes, because the output of such safety-critical systems is discrete and does not have equivalence class properties. Therefore, this application only focuses on the division of input events with continuous and infinite variable domains. Furthermore, after the equivalence class division, the input events and output expressions are corresponding. After the equivalence class division, the divided input events are linked to the corresponding output events and the corresponding atomic propositions.

[0343] For the valuation set , the following relationship exists:

[0344] ;

[0345] This is an equivalence relation. Intuitively, this is true only if the two evaluation functions are subsets of the alphabet. The model contains exactly the same expressions, and for all negated expressions , where e is contained in the complement of Y They are equivalent only when Two classes of , are disjoint, because Any expression e in must be represented by Each of (Right now ) is satisfied, and Any Need to satisfy , and vice versa. Represents the set of all input equivalence classes.

[0346] Specifically, in the embodiment of the present application, after constructing the input equivalence class, the trace of Q(M) is marked by the input and output expressions related to M and ∑, which define the input equivalence class of Q(M), and it is assumed that the set of symbol traces of Q(M) is contained in the sequence set of the input equivalence class defined by the input events constructed by ∑, that is, , and obtain the labeled test case generation model.

[0347] According to the rules for constructing input equivalence classes, input equivalence classes cover all possible variations of input events that may occur to any member in the fault domain. Therefore, A also contains the input equivalence classes of all fault domain members.

[0348] Specifically, in the embodiment of the present application, the test case generation model M is required to be observable. This means that for any specific trace ,Will Applicable to 0 The target state reached when is uniquely determined. More formally, for any specific trace , there exists exactly one specific path prefix , which has the same sequence of evaluation functions. , we use the notation To represent the uniquely defined target state s k Assumptions It is a satisfying Status The language L(s) is defined as all trace segments The collection of Any non-observable SFSM can be converted into an observable SFSM equivalent to its language. In black-box testing, it is usually impossible to observe which state the system is currently in when the test is executed. Therefore, observability is very important for the testing of this application. Applicable to 0 The target state reached when is uniquely determined, so by observing the output of the system is Which stage in the process is used to determine the current state of the system and whether the execution is complete. In the embodiment of the present application, a strategy for converting an unobservable system into an observable system is introduced. An unobservable SFSM, whose alphabet is contained in By checking that the states start from the same state s but end at different target states All conversion pairs and , to detect unobservability: If the first-order expression There is at least one solution , use this The input value in state s and observe the The output value cannot be determined to have reached s 1 Or s 2 , because it is impossible to observe Determine which transition has been triggered.

[0349] When constructing the input / output equivalence class of the SFSM, the evaluation function σ is contained in the class io(Ψ), where:

[0350] ;

[0351] because and , the formula Ψ can be rewritten as:

[0352] ;

[0353] where f is from The conjunction of all expressions of .

[0354] In the representation of the SFSM after equivalence class partitioning, where all transitions are labeled by the input equivalence class, there exists a transition and .

[0355] Applying the power set construction method to the non-deterministic SFSM will result in a deterministic SFSM whose language contains the same sequence of input equivalence classes as the original non-deterministic SFSM. In an embodiment of the present application, the power set construction method is applied to the marked test case generation model to generate an observable test case generation model. ,Right now ,and . refer to Figure 6 , NFA is a non-deterministic automaton, DFA represents a deterministic automaton, Figure 6 A simple example of the power set construction method is given. In the embodiment of the present application, the power set construction method is applied to the marked test case generation model to generate an observable test case generation model. ,Right now ,and . It can be seen that for NFA, if input event a occurs in state S0, an uncertain transition may occur: it may transition to state S1 or it may self-loop in state S0. In order to convert this NFA to DFA, the power set construction method is used to analyze the trace of state S0 and obtain the new state {S0, S1}. In this way, when input event a occurs in S0, it will transition to state {S0, S1}, which becomes a deterministic system. Then, we can complete the DFA according to other transition conditions of NFA.

[0356] Since the deterministic SFSM is deterministic as an automaton, every pair of different transitions emanating from a state s is represented as: and , different conversions have different labels io( )≠io( ). Therefore, the deterministic SFSM is observable, and the observability transformation is completed for the non-deterministic SFSM.

[0357] In a specific embodiment, the observable test case generation model A pair of symbol traces is distinguishable and satisfies: there exists a symbol input / output sequence , the symbol trace , Corresponding status , To distinguish, as shown below:

[0358] ;

[0359] in, Represents an observable test case generation model is a collection of symbol traces of , and ,

[0360] Use △(α, β) to represent the set of all distinguishing sequences:

[0361] .

[0362] Specifically, in black box testing, it is impossible to know what state the safety-critical system under test is in. In order to distinguish the different states of the safety-critical system and to determine whether the current test has reached the expected target state and whether it has started from the expected state, it is necessary to use distinguishing traces to distinguish different states. If the symbol traces α and β are distinguishable, the symbol input / output sequence γ is said to distinguish α and β. Note that if α.γ is The symbolic trace of , then all the specific traces contained in α.γ are contained in On the contrary, if , then no witness of α.γ exists in middle.

[0363] S4, based on the observable input equivalence class set and propositional abstraction of the test case generation model, generates test cases, executes the test case generation model and its mutants in the fault domain, and detects whether the test case meets the refined software safety requirements. If not, rebuild the fault domain and repeat the above two steps until the test case meets the refined software safety requirements.

[0364] In a specific embodiment, a test case is a symbolic input / output sequence, and all test cases constitute a test suite TS. , each test case meets the following requirements:

[0365] (1) TS contains an observable test case generation model The minimum state cover V, where ;

[0366] (2) For any different test cases α, β V, there exists a symbolic input / output sequence γ △(α,β), such that α.γ, β.γ TS;

[0367] (3) TS contains the following sets:

[0368] ;

[0369] (4) For satisfaction Any and ,exist , so that , represents the empty set;

[0370] (5) For satisfaction and Any ,exist , so that , Indicates a prefix.

[0371] Specifically, an observable test case generation model Status coverage refers to a The set of symbol traces on the input equivalence class of ʹ satisfies Any status , there is a , so that Here, we always assume that the empty trace Included in the state coverage, since it can reach the initial state.

[0372] A test suite represents a collection of test cases. A test suite TS is a collection of symbolic input / output sequences on input equivalence classes, i.e. . Symbolic input / output sequence is called a symbolic test case. For any observable test case, a model is generated , Pass the test case If and only if ;otherwise, Failed test cases . The TS test suite is represented by Pass each test case in TS, i.e. .

[0373] set up are two SFSMs in the same fault domain, where As an observable test case generation model with n states, Ms is a mutant of the test case generation model. We say and Ms are equivalent in terms of TS if and only if .

[0374] Intuitively, this means Exactly the same symbolic test case as Ms passed TS.

[0375] In the embodiment of the present application, a test suite generation method is specified according to the requirements met by the test cases. In step 1, a minimum state coverage is constructed. , the minimal requirement ensures that for any , distinguish the trace set In step 2, for each pair of different symbol traces Find a symbol to distinguish the trace , and , Add to the test suite. The goal of the test cases built in steps 1 and 2 is to check whether the test suite built by Ms here can be used to test the required properties and whether completeness can be guaranteed.

[0376] In step 3, the test suite is extended by a set T of symbolic traces, each consisting of a prefix from the state cover set V and a suffix consisting of a symbolic trace consisting of an arbitrary sequence in class A, with sequence lengths ranging from 1 to m−n+1. Assuming that the safety-critical system under test passes the test cases constructed in steps 1 and 2, the trace subset It is sufficient to reach every implementation state, provided that the test case is a member of the fault domain, so there are at most m states. In addition, T ensures that in every state reached, every applicable input class will be exercised, guaranteeing completeness. Therefore, if the safety-critical system under test passes all the test cases constructed in steps 1 to 3, then the safety-critical system has no output faults.

[0377] It is worth noting that for actual testing, only concrete input traces derived from the projection of symbolic input / output traces are used, and one input value can represent several classes in A. Furthermore, traces in the test suite that are just prefixes of longer test cases can be removed, and some elements of T can overlap with traces already created in step 2. Therefore, T can be added at most

[0378] |V.(A m-n+1 )|=n·|A| m-n+1 This reduces the number of test cases.

[0379] There are also transmission faults in the safety-critical system under test that can lead to violations of the formulas satisfied by the test case generation model. This will be investigated by the test cases created in steps 4 and 5.

[0380] Due to the complexity of safety-critical systems, the testing of safety-critical systems often cannot achieve completeness. Compared with the description of safety-critical systems using finite state machines (FSMs), symbolic finite state machines SFSMs can represent more complex data types and allow very large or even infinite variable domains, such as real numbers or floating point numbers with a very large range, so that safety-critical systems can be described more concisely and conveniently. In the completeness test case generation method based on symbolic finite state machines proposed in the embodiment of the present application, the unsafe control actions of the safety-critical system are first analyzed using STPA technology, unsafe scenarios are derived, and complete software safety requirements are obtained. These software safety requirements are then converted into linear temporal logic attributes. On this basis, the linear temporal logic attributes are used as attributes in attribute-oriented testing and combined with model-based testing to generate complete test cases on the model of the safety-critical system described by the symbolic finite state machine. Because the software safety requirements and linear temporal logic attributes are complete, executing the test cases generated by this method can perform more comprehensive completeness tests, thereby coping with the challenges in current safety-critical system testing and ensuring the safety and reliability of the system.

[0381] Furthermore, the system will produce the same processing results for different input events. If all input events are executed for testing, it will take too long. Therefore, before generating test cases, the present application divides the safety-critical system into equivalence classes, and classifies input events that produce the same processing results into one class. When executing the test, only a few representative input events in one class are tested. For systems with a large number of input events, the test time will be greatly reduced without destroying the completeness of the test. Compared with the method of generating test cases by exhaustive method in the prior art, the present application solves the problem that the number of generated test cases is too large and thus affects the test time, so as to further reduce the number of test cases and reduce the time used for testing.

[0382] The above steps S1-S4 do not necessarily represent the order between the steps, but are represented by step symbols, and the order between the steps can be adjusted.

[0383] Further references Figure 7 As an implementation of the methods shown in the above figures, the present application provides an embodiment of a completeness test case generation device based on a symbolic finite state machine. Figure 1 Corresponding to the method embodiment shown, the device can be specifically applied to various electronic devices.

[0384] The embodiment of the present application provides a completeness test case generation device based on a symbolic finite state machine, comprising:

[0385] The analysis module 1 is configured to analyze the safety-critical system using the STPA technology to obtain refined unsafe control actions and refined software safety requirements, convert the refined software safety requirements into linear temporal logic attributes, and further convert them into atomic propositions to form an atomic proposition set;

[0386] Modeling module 2 is configured to use a symbolic finite state machine to model the safety-critical system, obtain a test case generation model, construct a number of mutants based on the test case generation model, obtain a fault domain, and calculate all valuation functions of the safety-critical system, generate symbolic traces in the test case generation model and their corresponding concrete traces according to the valuation function, map the valuation function to a set of atomic propositions it satisfies, obtain propositional abstraction, and extend the propositional abstraction to the assignment sequence and concrete traces through recursive definition;

[0387] A refinement module 3 is configured to refine the test case generation model based on the first-order expression to obtain a refined test case generation model, divide all valuation functions into equivalence classes based on the refined test case generation model to obtain input equivalence classes, mark the transformation of the refined test case generation model according to the input equivalence classes to obtain a marked test case generation model, build an observable test case generation model based on the marked test case generation model, and obtain an input equivalence class set of the observable test case generation model, wherein the observable test case generation model and the test case generation model are in the same fault domain;

[0388] The test case generation module 4 is configured to generate test cases based on the input equivalence class set and proposition abstraction of the observable test case generation model, execute the test cases in the test case generation model and its mutants in the fault domain, and detect whether the test cases meet the refined software safety requirements. If not, the fault domain is rebuilt and the steps in the above modeling module 2 and refinement module 3 are repeated until the test cases meet the refined software safety requirements.

[0389] Figure 8 Schematic diagram of the hardware structure of the electronic device provided by the embodiment of the present invention. Figure 8 As shown, the electronic device of this embodiment includes: a processor 801 and a memory 802; wherein the memory 802 is used to store computer-executable instructions; the processor 801 is used to execute the computer-executable instructions stored in the memory to implement the various steps performed by the electronic device in the above embodiment. For details, please refer to the relevant description in the above method embodiment.

[0390] Optionally, the memory 802 may be independent or integrated with the processor 801 .

[0391] When the memory 802 is independently provided, the electronic device further includes a bus 803 for connecting the memory 802 and the processor 801 .

[0392] An embodiment of the present invention further provides a computer storage medium, in which computer execution instructions are stored. When a processor executes the computer execution instructions, the above method is implemented.

[0393] An embodiment of the present invention further provides a computer program product, including a computer program. When the computer program is executed by a processor, the above method is implemented.

[0394] In the embodiments provided by the present invention, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic, for example, the division of modules is only a logical function division, and there may be other division methods in actual implementation, such as multiple modules can be combined or integrated into another system, or some features can be ignored or not executed. Another point, the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or modules, which can be electrical, mechanical or other forms.

[0395] The modules described as separate components may or may not be physically separated, and the components shown as modules may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to implement the solution of this embodiment.

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

[0397] The above-mentioned integrated module implemented in the form of a software function module can be stored in a computer-readable storage medium. The above-mentioned software function module is stored in a storage medium, including a number of instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor to perform some steps of the methods of various embodiments of the present application.

[0398] It should be understood that the processor may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), etc. A general-purpose processor may be a microprocessor or any conventional processor. The steps of the method disclosed in the invention may be directly implemented as being executed by a hardware processor, or may be implemented by a combination of hardware and software modules in the processor.

[0399] The memory may include a high-speed RAM memory, and may also include a non-volatile storage NVM, such as at least one disk memory, and may also be a USB flash drive, a mobile hard disk, a read-only memory, a magnetic disk or an optical disk, etc.

[0400] The bus may be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, the bus in the drawings of the present application is not limited to only one bus or one type of bus.

[0401] The above storage medium can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk. The storage medium can be any available medium that can be accessed by a general or special purpose computer.

[0402] An exemplary storage medium is coupled to a processor so that the processor can read information from the storage medium and write information to the storage medium. Of course, the storage medium can also be a component of the processor. The processor and the storage medium can be located in an application specific integrated circuit (ASIC). Of course, the processor and the storage medium can also exist as discrete components in an electronic device or a main control device.

[0403] Those skilled in the art can understand that all or part of the steps of implementing the above-mentioned method embodiments can be completed by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When the program is executed, the steps of the above-mentioned method embodiments are executed; and the aforementioned storage medium includes: ROM, RAM, disk or optical disk and other media that can store program codes.

[0404] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.< / ca> < / tc> < / ca> < / ca> < / tc> < / ca>

Claims

1. A method for generating completeness test cases based on symbolic finite state machines, characterized in that: The following steps are involved: The safety-critical system is analyzed by using STPA technology to obtain refined unsafe control actions and refined software safety requirements, and the refined software safety requirements are converted into linear temporal logic attributes, and further converted into atomic propositions to form an atomic proposition set; The safety-critical system is modeled by a symbolic finite state machine to obtain a test case generation model, a plurality of mutants are constructed based on the test case generation model, a fault domain is obtained, and all valuation functions of the safety-critical system are calculated, a symbolic trace in the test case generation model and its corresponding specific trace are generated according to the valuation function, the valuation function is mapped to a set of atomic propositions satisfied by it to obtain a propositional abstraction, and the propositional abstraction is extended to an assignment sequence and a specific trace by recursive definition, wherein the safety-critical system is modeled by a symbolic finite state machine to obtain a test case generation model, a plurality of mutants are constructed based on the test case generation model, a fault domain is obtained, and all valuation functions of the safety-critical system are calculated, specifically including: The safety-critical system is modeled using a symbolic finite state machine to obtain a test case generation model, which is represented by an octet , where the finite set S represents the state space, represents the initial state, R represents the conversion relationship, , the finite set I contains the input variable symbols, the finite set O contains the output variable symbols, and the set Var represents , D represents the union of all variables on the type domain, Represents the input alphabet, which is a finite set of input events. means that each input event is a quantifier-free first-order expression on the input variables, Represents the output alphabet, which is a set of output expressions. Output expressions are expressed in express; Based on the test case generation model, several mutants are constructed by introducing erroneous behaviors, including: erroneous or swapped input events, erroneous or swapped output expressions, transmission failures, added or lost states, and the transmission failures include additional, lost or misleading transitions, and adding erroneous input events to the input alphabet , add the wrong output expression to the output alphabet In the test case generation model, the erroneous input event and the erroneous output expression do not appear anywhere. The fault domain is constructed based on all the mutants. The fault domain is expressed as , where n means that the test case generation model M has n distinguishable states, and m means that the mutants of the test case generation model M have at most m distinguishable states; Valuation Function : Indicates that each variable symbol a value of the type corresponding to one in D Connected, Represents the valuation function Is an input event Model, which will input events Each variable symbol v in D is replaced by a value of the corresponding type in D. After that, the resulting Boolean expression is true. Represents the valuation function Is an input event and its corresponding output expression conjunction The model calculates all the valuation functions of the safety-critical system. The set of all valuation functions mapped from Var to D is expressed as ; The test case generation model is refined based on a first-order expression to obtain a refined test case generation model, all the valuation functions are divided into equivalence classes based on the refined test case generation model to obtain input equivalence classes, the transformations of the refined test case generation model are marked according to the input equivalence classes to obtain a marked test case generation model, an observable test case generation model is constructed based on the marked test case generation model, and an input equivalence class set of the observable test case generation model is generated, wherein the observable test case generation model and the test case generation model are in the same fault domain, specifically including: Provide a finite set Q containing A subset of the finite set Q of quantifier-free first-order expressions of free variables The first-order expression in has only free variables from I. Based on the test case generation model M, a refined test case generation model is constructed, which is expressed as , the refined test case generation model Q(M) and the test case generation model are in the same fault domain, for any subset of the first-order expression , define a Boolean expression: ; in, means and; Define the input alphabet of Q(M) as follows: ; in, Represents the set of all valuation functions mapped from I to D; Define the transfer relationship of Q(M) as shown below: ; All the valuation functions are divided into equivalence classes according to the following rules: Defining the first-order formula is from Y and the complement The conjunction of the negated formula is as follows: ; Among them, the alphabetical table of fault domains is the union of all input events, output expressions, and atomic proposition sets of linear temporal logic property formulas to be verified, expressed as , the set Y represents the set constructed according to the above formula with at least one valuation function As all input events of the model The set Y is as follows: ; For each , define an input equivalence class , expressed as: ; The set A of all input equivalence classes is expressed as: ; According to the input equivalence class Mark the transitions of the refined test case generation model Q(M) to obtain a marked test case generation model. If the marked test case generation model has transitions that start from the same starting state s but end at different target states Then, the power set construction method is applied to the marked test case generation model to obtain an observable test case generation model. , including: Determine the initial state: Use the initial state of the labeled test case generation model as an observable test case generation model The initial state of Determine the state set: For each state set, deduce the possible states it can be converted to on each input event, form a new state set, and become an observable test case generation model Status in Determine the transition function: Based on the transition function of the labeled test case generation model and the trace of each state set on each input event, determine the observable test case generation model The transfer function of Determine the acceptance state: Determine the observable test case generation model The acceptance states in the test case generation model are the state sets that contain the acceptance states in the labeled test case generation model; Generate a model based on the observable test cases The accepting state in the input equivalence class is refined to generate the observable test case generation model Input equivalence class of ; Otherwise, the marked test case generation model is used as the observable test case generation model ; Generate test cases based on the input equivalence class set and proposition abstraction of the observable test case generation model, execute the test cases using the test case generation model and its mutants in the fault domain, and detect whether the test cases meet the refined software safety requirements. If not, reconstruct the fault domain and repeat the above two steps until the test cases meet the refined software safety requirements.

2. The method for generating completeness test cases based on a symbolic finite state machine according to claim 1, characterized in that: The STPA technology is used to analyze the safety-critical system to obtain refined unsafe control actions and refined software safety requirements, and the refined software safety requirements are converted into linear temporal logic attributes, and further converted into atomic propositions to form an atomic proposition set, which specifically includes: Identify services, losses, hazards and system boundaries of the safety-critical system and determine system-level constraints of the safety-critical system based on the hazards; Building a control structure based on the services, hazards, system boundaries and system-level constraints, the control structure comprising a controller and a controlled process, the controller issuing a control action to the controlled process; Based on the control action and the combination of its related state variables and key variables, a refined unsafe control action is identified, and a refined software safety requirement is generated according to the refined unsafe control action, wherein the refined unsafe control action is represented as a quaternary group (CA, Cs, C, TC), wherein CA represents a control action that causes danger, It represents the combination of state variables and key variables related to the control action CA. C represents the situation where it is dangerous to provide or not provide the control action CA. TC represents the situation where the control action CA is provided, which is divided into any time, too early or too late. The refined software safety requirements are converted into linear temporal logic properties according to the following rules: When a combination occurs The controller should never provide a control action when the value is ,in, , the conversion formula is: ; In combination The controller should not provide control actions too early before the value of , the conversion formula is: ; In combination After the value of occurs, the controller should not provide control actions too late , the conversion formula is: ; When a combination occurs The controller must provide control action immediately in the next time step when , the conversion formula is: ; Further converted into atomic propositions according to linear temporal logic properties to form an atomic proposition set; The linear temporal logic property formula The syntax of is given by the following grammar: ; in, represents an atomic proposition, AP represents an atomic proposition set, written as a pair from A quantifier-free first-order expression of the variable symbol: ; in, , represents any linear temporal logic attribute formula, is a proposition trace, t and j are indices, and the expression Suffix indicating trace ,and , Represents the power set of the atomic proposition set AP, for a proposition trace of infinite length Finite prefix of : ,writing To specify yes a finite prefix of ; The semantics of the path operators F, G, and W are defined by the following grammatical abbreviations: , , , Indicates the definition, Indicates or It means to take the opposite; A linear temporal logic attribute formula is a set P of propositional traces, satisfying, in, represents the complement, , Respectively represent the proposition trace Two different finite prefixes of .

3. The method for generating completeness test cases based on a symbolic finite state machine according to claim 2, characterized in that: The step of generating the symbolic trace and the corresponding specific trace in the test case generation model according to the valuation function, mapping the valuation function to the set of atomic propositions satisfied by the valuation function to obtain propositional abstraction, and extending the propositional abstraction to the assignment sequence and the specific trace through recursive definition specifically includes: The test case generates the symbolic path of model M is an infinite sequence, represented by: ; Among them, "." represents the sequence concatenation symbol, Represents the initial state of the test case generation model M. For all , ; The test case generates a symbolic trace of model M is a finite sequence, represented as: ,satisfy: , , so that ,in, Indicates existence, It means any; The set of symbolic traces of the test case generation model M is denoted as T(M); The specific path of the test case generation model M is an infinite sequence, expressed as: ; in, , so that the test case generation model M has a symbol path: satisfy , ; The test case generates a specific trace of the model M is a finite sequence, represented as: ; So that the test case generation model M has a symbolic trace satisfy , then the specific trace Symbolic trace Witness, expressed as ; The set of specific traces of the test case generation model M is denoted as L(M); The valuation function Map it to the set of atomic propositions AP that it satisfies to obtain propositional abstraction , as shown below: ; Represents the corresponding mapping relationship, and abstracts the proposition through recursive definition Extension to assignment sequences and specific traces: ; in, Indicates empty trace; For linear temporal logic attribute formulas and finite prefix , if and only if yes When there is a bad prefix, use the symbol ; if and only if any specific trace of the test case generation model M will not be abstracted by the proposition Abstracted as , then the test case generation model M is the model corresponding to the linear temporal logic attribute, that is .

4. The method for generating completeness test cases based on a symbolic finite state machine according to claim 3, characterized in that: The observable test case generation model A pair of symbol traces , is distinguishable and satisfies: there exists a symbolic trace , distinguish the states s1 and s2 corresponding to the symbol traces α and β, as shown in the following formula: ; in, Represents an observable test case generation model is a collection of symbol traces of , and , Use △(α, β) to represent the set of all distinguishing sequences: 。 5. The method for generating completeness test cases based on symbolic finite state machines according to claim 4, characterized in that: The test cases are symbolic traces, and all the test cases constitute a test suite TS. , each test case meets the following requirements: (1) TS contains an observable test case generation model The minimum state cover set V of ; (2) For any different test cases , , there is a symbol trace , so that , ; (3) TS contains the following sets: ; (4) For satisfaction Any and ,exist , so that , , represents the empty set; (5) For satisfaction and Any , ,exist , so that , , Indicates a prefix.

6. A completeness test case generation device based on a symbolic finite state machine, characterized in that: include: An analysis module is configured to analyze the safety-critical system using STPA technology to obtain refined unsafe control actions and refined software safety requirements, convert the refined software safety requirements into linear temporal logic attributes, and further convert them into atomic propositions to form an atomic proposition set; The modeling module is configured to use a symbolic finite state machine to model the safety-critical system, obtain a test case generation model, construct a number of mutants based on the test case generation model, obtain a fault domain, and calculate all valuation functions of the safety-critical system, generate a symbolic trace in the test case generation model and its corresponding specific trace according to the valuation function, map the valuation function to a set of atomic propositions satisfied by it, obtain a propositional abstraction, and extend the propositional abstraction to an assignment sequence and a specific trace through a recursive definition, wherein the use of a symbolic finite state machine to model the safety-critical system, obtain a test case generation model, construct a number of mutants based on the test case generation model, obtain a fault domain, and calculate all valuation functions of the safety-critical system specifically includes: The safety-critical system is modeled using a symbolic finite state machine to obtain a test case generation model, which is represented by an octet , where the finite set S represents the state space, represents the initial state, R represents the conversion relationship, , the finite set I contains the input variable symbols, the finite set O contains the output variable symbols, and the set Var represents , D represents the union of all variables on the type domain, Represents the input alphabet, which is a finite set of input events. means that each input event is a quantifier-free first-order expression on the input variables, Represents the output alphabet, which is a set of output expressions. Output expressions are expressed in express; Based on the test case generation model, several mutants are constructed by introducing erroneous behaviors, including: erroneous or swapped input events, erroneous or swapped output expressions, transmission failures, added or lost states, and the transmission failures include additional, lost or misleading transitions, and adding erroneous input events to the input alphabet , add the wrong output expression to the output alphabet In the test case generation model, the erroneous input event and the erroneous output expression do not appear anywhere. The fault domain is constructed based on all the mutants. The fault domain is expressed as , where n means that the test case generation model M has n distinguishable states, and m means that the mutants of the test case generation model M have at most m distinguishable states; Valuation Function : Indicates that each variable symbol a value of the type corresponding to one in D Connected, Represents the valuation function Is an input event Model, which will input events Each variable symbol v in D is replaced by a value of the corresponding type in D. After that, the resulting Boolean expression is true. Represents the valuation function Is an input event and its corresponding output expression conjunction The model calculates all the valuation functions of the safety-critical system. The set of all valuation functions mapped from Var to D is expressed as ; A refinement module is configured to refine the test case generation model based on a first-order expression to obtain a refined test case generation model, divide all the valuation functions into equivalence classes based on the refined test case generation model to obtain input equivalence classes, mark the transformation of the refined test case generation model according to the input equivalence classes to obtain a marked test case generation model, build an observable test case generation model based on the marked test case generation model, and obtain an input equivalence class set of the observable test case generation model, wherein the observable test case generation model and the test case generation model are in the same fault domain, specifically including: Provide a finite set Q containing A subset of the finite set Q of quantifier-free first-order expressions of free variables The first-order expression in has only free variables from I. Based on the test case generation model M, a refined test case generation model is constructed, which is expressed as , the refined test case generation model Q(M) and the test case generation model are in the same fault domain, for any subset of the first-order expression , define a Boolean expression: ; in, means and; Define the input alphabet of Q(M) as follows: ; in, Represents the set of all valuation functions mapped from I to D; Define the transfer relationship of Q(M) as shown below: ; All the valuation functions are divided into equivalence classes according to the following rules: Defining the first-order formula is from Y and the complement The conjunction of the negated formula is as follows: ; Among them, the alphabetical table of fault domains is the union of all input events, output expressions, and atomic proposition sets of linear temporal logic property formulas to be verified, expressed as , the set Y represents the set constructed according to the above formula with at least one valuation function As all input events of the model The set Y is as follows: ; For each , define an input equivalence class , expressed as: ; The set A of all input equivalence classes is expressed as: ; According to the input equivalence class Mark the transitions of the refined test case generation model Q(M) to obtain a marked test case generation model. If the marked test case generation model has transitions that start from the same starting state s but end at different target states Then, the power set construction method is applied to the marked test case generation model to obtain an observable test case generation model. , specifically including: Determine the initial state: Use the initial state of the labeled test case generation model as an observable test case generation model The initial state of Determine the state set: For each state set, deduce the possible states it can be converted to on each input event, form a new state set, and become an observable test case generation model Status in Determine the transition function: Based on the transition function of the labeled test case generation model and the trace of each state set on each input event, determine the observable test case generation model The transfer function of Determine the acceptance state: Determine the observable test case generation model The acceptance states in the test case generation model are the state sets that contain the acceptance states in the labeled test case generation model; Generate a model based on the observable test cases The accepting state in the input equivalence class is refined to generate the observable test case generation model Input equivalence class of ; Otherwise, the marked test case generation model is used as the observable test case generation model ; A test case generation module is configured to generate test cases based on the input equivalence class set and proposition abstraction of the observable test case generation model, execute the test cases in the test case generation model and its mutants in the fault domain, and detect whether the test cases meet the refined software safety requirements. If not, the fault domain is rebuilt and the steps in the above modeling module and refinement module are repeated until the test cases meet the refined software safety requirements.

7. An electronic device comprising: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 5.

8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 5 is implemented.

9. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the method according to any one of claims 1 to 5 is implemented.