Physics
Computer Science-2021.gz:143210
Computer Science
68d6e7158b5d0c00c0c34ccb512e55adbb9d0579
Research on automatic test case generation method of flight control system based on UML state diagram

In order to realize the automatic test of flight control system, the automatic generation method of flight control system test case is studied by using UML state diagram. Using UML extension mechanism, the real-time extension scheme of UML state diagram of flight control system is given. Aiming at the real-time performance of flight control system, the migration equivalence class is constructed by using the time domain equivalence partition method. After the test path is generated according to the corresponding test standard, the test case is generated automatically. Taking a simplified flight control system as an example, the feasibility and practicability of the method are verified by comparing the time of generating test cases with that of generating test cases manually.


Introduction
As one of the core systems of aircraft, it is necessary to fully and effectively test the flight control system in the test process [1].In the traditional flight control system test, due to its complexity and real-time, test cases are often written manually, but this way requires a lot of manpower and material resources, and low efficiency, easy to miss some test cases [2].Therefore, this paper proposes an automatic test case generation method for flight control system based on UML state diagram, and extends the UML state diagram in real time according to the strong real-time characteristics of flight control system. In this paper, a real-time extension scheme of UML state diagram is given. According to the time characteristics, the migration equivalence class [3] is constructed by using the method of time domain equivalence partition, and the migration test tree is generated by using the migration equivalence class. Combined with the defined test coverage criterion, the corresponding test paths and test cases are generated.

Test case design process based on UML state diagram
Test case is a set of operation and input data designed according to test requirements for driving system to perform a specific action [4]. Typically, a test case includes a test path and the corresponding test data. Therefore, generating test cases should include generating test cases and generating test data.
When testing the flight control system, we should not only analyze the requirements, but also refer to the interface control document (ICD), which stipulates the specific interface relationship between each subsystem, equipment or other systems, subsystems, equipment in the flight control system. Figure  1 shows the design process of flight control system test cases. Firstly, UML state diagram is used to

UML extension mechanism
UML provides a large number of views for system modelling, but in order to avoid the overall complexity of UML, UML does not absorb all object-oriented modelling techniques and mechanisms, and support their own expansion and adjustment, which is the expansion mechanism of UML.
UML provides three extension mechanisms: prototype, tag value and constraint to facilitate users to extend UML [5].
 Stereotype: Define new UML modelling elements based on existing model elements.  Tagged value: Add specification of special information extension model elements.  Constraints: Extending element semantics by adding new rules.

Characteristics of Flight Control System
Flight control system is the core component of aircraft, which undertakes flight control, task scheduling management and other functions. It has the characteristics of strong real-time, concurrency, high reliability, and is often cross-linked with multiple subsystems. Therefore, it is difficult to develop and test the flight control system. In the traditional flight control system test, test cases are often completed by manual input or manual script writing, but this method requires a lot of manpower and material resources, and the efficiency is low. Therefore, it is meaningful to apply UML modeling automation testing technology to large flight control system testing.

Real-time extension scheme
UML state diagram can provide very limited methods to describe the timing characteristics of the system, which can not provide a specific method to deal with the timing-related characteristics of the system and the complex of these characteristics. In order to solve the problem that UML state diagram describes the time characteristics of flight control system, this paper extends the state diagram in real time, including:  clock. The event can be associated with time by introducing the concept of clock, which can be divided into global clock and local clock according to the system requirements. The global clock starts from the test, and the local clock records the time when an activity or a function is called during the test execution. When the system enters each activity, the local clock will be reset once.  time constraint. The transition of many events in flight control system is associated with time constraints. The occurrence of events in a specific time period will affect the state of the whole system, thus affecting the behaviors of the system, which is called time constraints

Constructing Transfer Equivalent Classes
In the UML state diagram, time constraints divide the clock range into several time zones, each of which has different effects on the number of migration trigger events. To facilitate discussion, some conceptual definitions are given:

Time zone
T is a set of clocks, t is a clock in X with a range of ( 0, +∞). The time constraint σ of T divides the value range of the clock into multiple continuous intervals, that is, the time domain division, which is represented by symbol D, and each interval becomes the time domain. Specific definitions are given below:  Definition 3.1 Time zone Assuming that σ is a time constraint, the time points contained in its expression are as follows: , , … , ,k are positive integers, and ⋯ , then the time of σ is divided into 0, * , , ∞ is a time zone in the partition, expressed as d1,d2,…,dk, with , )* denotes ] or).

Constructing Transfer Equivalent Classes
Events trigger different migrations in different time regions. In this paper, the migration equivalence class is constructed by using the method of clock region equivalence partition. The equivalence class includes a state set and three action sets, which are necessary, possible, and not. In this article, a migration equivalence class contains four parts: number, event, time constraint, and subsequent state. Because of the coexistence of multiple clocks in the flight control system, when describing this kind of situation, the time region is equivalently divided, and all possible time regions are combined. As there are more clocks, the dimension of division is higher. This paper only discusses one and two clocks. The method description of constructing migration equivalence class is given as follows:  firstly, the migration set ES of the trigger event of state S is generated. Events in ES trigger state migration.  select the events in the collection ES in turn, set to e, and follow the following steps:  the migration set of event e is generated, and its time constraint set is constructed by the migration set, and the time domain division of event e is generated.  the migration equivalence class is generated according to the following rules: If there is only one clock, then each time domain corresponds to a migration equivalence class. If the time domain corresponds to the time constraint of a state migration, the next state of the migration equivalence class is the target state of the migration. If the state transition is not triggered, the next state is NULL. If there are two clock variables, the time regions of the two clock variables are combined to generate a new time region. If the new time region corresponds to a certain migration time constraint, the next state of the migration equivalence class is the target state of the migration. If no state migration is triggered, it is NULL.

Definition of test coverage criterion
When constructing test cases, certain test coverage criteria should be followed. After studying the white-box test coverage criterion and graph test coverage criterion, this paper defines the following test coverage criterion combined with the extended UML state diagram:  state coverage criterion. When analyzing the UML state diagram to generate test cases, it is required that the generated test case set can fully cover all in UML state diagram.  migration coverage criterion. The migration coverage criterion requires that the test case set generated based on UML state diagram can traverse all migrations in the state diagram.  complete determination of coverage criteria. The complete criterion in real-time systems such as flight control system is the adequacy test for the time domain determined by time constraints. Due to the time constraints of the real-time system, in different time domains, the state of the system will have different migrations for the same input event. Therefore, it is necessary to test all possible time domains of the system in the test, so as to ensure that the description of time characteristics is reasonably realized.

Test paths generation
The above migration equivalence class is used as a node to generate a migration test tree. Combined with the test coverage criterion, all test paths can be obtained by using the depth traversal algorithm.
The following is the description of migration test tree generation algorithm as Node points to the parent node of the current node and goes to step 2).

Else
nstate points to the next state of the node and constructs the migration equivalence class of nstate For each migration equivalent class, backtracking the superior node If migration equivalence class does not appear on the traceback path Then Set the child node of the nstate node node node If nstate points to the node without child nodes Node points to the parent node of the current node and goes to step 2). Else Node points to the first child node of the current node and goes to step 2). (3) If node points to a child node Then For each child node of a node If the node has not been accessed Then node points to the node and marks the node as accessed and goes to step 2). If each node has been accessed and the node points to the root node Then end Else Node points to the parent node of the current node and goes to step 2).
After the algorithm is completed, a migration test tree is built. Use depth traversal to get all possible test paths from root to child nodes.

Test data generation
Test input is mainly obtained from ICD documents, from the following aspects to describe the input data:  data types: In addition to the common int, long, double, and bool data types in the flight control system, there are also a large number of composite data, such as structural body data. A uniform, standardized definition of such composite data is required to facilitate automatic generation of test cases.  value range: Deterministic input variables can be selected directly according to the demand.
Uncertainty variables, such as variables with upper and lower value boundary, the selection is more complex. In order to find as many errors as possible, it is necessary to use a variety of test strategies such as equivalence class division, boundary value and special value.  time constraint: Due to the time characteristics of the flight control system, the test input should also meet certain time constraints. Effective input data in time constraints and abnormal input data not in time constraints.

Test cases generation
Through traversing all the test paths, the control flow, data flow and branch conditions in the execution process can be obtained, the input test data and state conditions required for each path can be determined, and the corresponding test cases can be generated.

Case analysis
Taking a simplified flight control system as an example, the method of automatically generating test cases based on UML state diagram is given. The UML state diagram of the flight control system is mainly described as follows. When the system is in the program control stage, it starts to enter the ground stage. In the ground state, there are two substate navigation states and hydraulic system operation. The two sub-states are controlled by two clocks Timer1 and Timer2. If the hydraulic system failure within 5 minutes into the warning and protection, exit after 2 minutes. If the hydraulic system is good and the navigation algorithm is completed within 3 minutes, it enters the takeoff stage. If a termination take-off order occurs, take-off from taxiing to termination take-off, at the end of take-off, if the speed is less than 5km/h, in the shutdown phase, exit after 4 minutes. If the speed is above 5 km/h within 3 min when the take-off is terminated, it enters the warning and protection state entered, and the forced with draw after 2 minutes.

UML state diagram establishment
For the convenience of subsequent description, the UML state diagram of flight control system after real-time expansion is given, which eliminates the formal description after hierarchy, as shown in Figure  4; Table 2 illustrates the meaning of state and migration.

Conclusion
The test case generation method based on UML state diagram is applied to flight control system test, and the real-time extension scheme of UML state diagram is given. Using the method of time zone partition, the UML state diagram is transformed into a migration test tree with the migration equivalence class as the node, the coverage criteria are defined, the test path is generated, and the test cases are automatically generated through certain transformation rules. In the actual project, compared with the time of generating test cases manually, the time of generating test cases in the original 30 days is shortened to 5 days after using this method. This method can effectively improve the test efficiency of flight control system and reduce the error of test cases caused by human factors.