• Aucun résultat trouvé

Symbolic Execution of Satellite Control Procedures in Graph-Transformation-Based EMF Ecosystems

N/A
N/A
Protected

Academic year: 2022

Partager "Symbolic Execution of Satellite Control Procedures in Graph-Transformation-Based EMF Ecosystems"

Copied!
6
0
0

Texte intégral

(1)

EMF Ecosystems

Nico Nachtigall, Benjamin Braatz, and Thomas Engel

Universit´e du Luxembourg, Luxembourg firstname.lastname@uni.lu

Abstract. Symbolic execution is a well-studied technique for analysing the behaviour of software components with applications to test case gen- eration. We propose a framework for symbolically executing satellite con- trol procedures and generating test cases based on graph transformation techniques. A graph-based operational symbolic execution semantics is defined and the executed procedure models are used for generating test cases by performing model transformations. The approach is discussed based on a prototype implementation using the Eclipse Modelling Frame- work (EMF), Henshin and ECLiPSe-CLP tool ecosystem.

Keywords: symbolic execution, graph transformation, test case gener- ation, triple graph grammars, EMF henshin

1 Introduction

Symbolic execution [4] is a well-studied technique for analysing the behaviour of software components with applications to test case generation. The main idea is to abstract from possibly infinite or unspecified behaviour. Uninitialised input variables or external function calls are represented by symbolic variables with the sets of possible concrete input values as value domains. Consequently, symbolic program execution is rather based on symbols than on concrete values leading to symbolic expressions which may restrict the value domains of the symbols. For each execution path, a path constraint (PC) is defined by a dedicated boolean symbolic expression. Solving the expression, i.e., finding a valuation for all con- tained symbolic variables so that the expression is evaluated to true, provides concrete input values under which the corresponding path is traversable. An execution path is traversable as long as its path constraint is solvable.

In this paper, we propose a framework for symbolically executing satellite control procedures (SCPs) and generating test cases based on graph transfor- mation techniques [6]. We successfully apply graph transformation techniques in an industrial project with the satellite operator SES (Soci´et´e Europ´eenne des Satellites) for an automatic translation of SCPs from proprietary programming languages to SPELL (Satellite Procedure Execution Language & Library) [8].

The safety-critical nature of SCPs implies that extensive testing is required after

(2)

translation. The presented approach allows us to generate tests without leaving this graph-transformation-based ecosystem. We define a graph-based operational semantics for symbolically executing SCPs for a subset of the SPELL language.

The executed procedure models are used for generating test cases by performing model transformations. We discuss our approach based on a prototype imple- mentation using the EMF Henshin [7] and ECLiPSe-CLP [9] tools.

Sec. 2 introduces the symbolic execution framework. In Sec. 3, the graph- based operational symbolic execution semantics is defined. Sec. 4 presents model transformation rules for test case generation and a prototype implementation for the approach. Sec. 5 concludes the paper and compares with related work.

2 Models & Symbolic Execution Framework

The symbolic execution framework in Fig. 1 uses the abstract syntax tree (AST) of a procedure, which defines a typed attributed graph [6]. The AST can be con- structed by parsing the source code with appropriate tools (see Sec. 4). The AST graph is symbolically executed using two graph transformation systems (GTSs).

A GTS is a set of graph transformation rules where each rule may create or delete nodes and edges or update attribute values. In phase one, the GTS GTSF low

is used to annotate AST with execution flow information leading to graph AF = AST +FLOW. In phase two (symbolic execution), the GTS GTSSym

is exhaustively applied to AF leading to graphsStatei=AF+SYMi, i= 1..n representing the status of the execution.

Fig. 2 shows the running example in a small subset of the SPELL language [8]. SCP “Charge Batteries” retrieves the state of charge (SC) of both batteries of a satellite, defines a minimal thresholdminof 50%, and switches to the battery with higher SC if it exceedsmin. Otherwise, an alert is issued. Meta-modelSCP specifies the general syntax of ASTs for such procedures. A procedureProccon- sists of a list of statementsStmnt(assignmentsAsg, function callsFnCall, defini- tionsFnDefor branchingIfstructures) with explicitnextpointers. Function calls contain a list of arguments (arg) and function definitions contain a list of param- eters (pm). An assignment contains a variable (var) and an assigned expression (ex). Expressions (Expr) are either numbers (Number), variables (Var) or Boolean expressions (Bool) with operator (<, <=, >, >=, and, or) and operands (left (le) and right (ri)). Complex statements (If,FnDef) contain a block (B) that references a list of statements. Furthermore, If statements have a boolean conditioncond and may haveelseand ElIf structures (edgeel). TheAST for the procedure is a graph typed over meta-modelSCP. GraphFLOW represents the flow annotation ofAST. Places Pare assigned (dotted edgesasg) to nodes inAST that should

Graph based SCP Model

Annotate E-Flow Information

(apply ) ASTASTP0P0

Stepwise Symbolic Execution (apply ) AST

AF State1..n

Model checking invariant properties Detection of unreachable („dead“) model fragments Test case generation GTSSym

GTSFlow

Fig. 1.Steps of Symbolic Model Execution

(3)

le,ri

Number

Int i Var

Id v

Asg Bool

Op op

If FnCall

Id fn

Proc Stmnt

Expr

first FnDef

Id fn

Pm Arg arg

pm body

pm

bl,else ex

var

cond

f B

arg el

next

1 DEF switch & charge (x ,

2 y ,

3 min ):

4 IF x > y AND 5 x > min :

6 Send(’ S W I T C H _ B 1 &

7 C H A R G E _ B 2 ’)

89 ELIF y > min :

10 Send(’ S W I T C H _ B 2 &

11 C H A R G E _ B 1 ’)

1213 s0 =GetTM(’ SC1 ’) 14 s1 =GetTM(’ SC2 ’) 15 min =50

16

17 switch & charge ( s0 ,

18 s1 ,

19 min )

2021 IF s0 <= min AND 22 s1 <= min : 23 Alert()

:FnDef fn=switch&charge

pm

:If cond body

var ex next

lines 1-11

:Bool op=AND

v=‘x‘:Var :Bool op=>

ri

le ri

le :Proc first

v=‘x‘:Pm pm

next ...

...

...

...

...

l.13lines 14-23 arg :Arg ...

v=‘s0‘

... arg

... ...

:Asg next

:P :P asg

:P :If

bl

el :P

:P :P

:P :P

:P

:P :P :B

f

:P

next

f

l f

n ...

n l n

:FnCall ...

fn=swi... n

n

f,l ...

f

l n

n ...

f,l f

...

ll...

lo hi

...

f l

n ...

f l

n

:Token eval=true pc=…and(S0>S1,…)… sym=2

:Symb term=S0:Symb term=S1

c c

... c

c on

lst

nxt

AST FLOW SYMn

Fig. 2.SCPmeta-model (top), SCP “Charge Batteries” (left), SCP model (AST), flow annotation (FLOW) and symbolic execution elements (SYMn)

be executed.Pnodes can be connected byf,lornedges in order to indicate which other nodes need to be executed at first, next or last before finishing the execu- tion of a node, e.g., in order to execute the procedure (nodeProc), the assignment in line 13 (nodeAsg) needs to be executed first. For each execution path, aToken representing the current execution point with path constraint is created (in total six Tokens for the example). In graph SYMn, the Tokennode on place P that is assigned to nodeProcindicates that the procedure was evaluated (eval=true) with path constraintpc=and(and(S0>S1,S0>50),not(and(S0<=50,S1<=50)))and symbolic variablesS0, S1 (Symb) forGetTM(’SC1’)andGetTM(’SC2’)by enter- ing line 6 but not line 23. The resulting graphsState1..n can be used for model checking invariants, detection of dead model fragments or test generation.

3 Operational Execution Semantics

The execution semantics is divided into the execution flow of the AST graph and the token semantics for traversing all flow paths. Fig. 3 shows the rules of GTSF low and GTSSym in short-hand notation, i.e., nodes and edges marked

with<+>are created, those marked with<->are deleted and attribute values of

the form[x=>y]are updated from xtoywhen applying the rule. Nodes marked

with <tr> have a “hidden” translation attribute that is updated [false=>true]

during rule application so that the rule is only applied once. A more formal definition of graph transformation in general is given in [6].

(4)

RuleInit1 specifies that the first statement of a procedure needs to be exe- cuted first. An initial token is put on the first place with path constraint true and eval=false. Rule Stmnt1 defines that successive statements need to be exe- cuted successively. Note that the first statement in Fig. 2 is aFnDef. Therefore, another rule defines that the succeeding statement needs to be executed first until there is no moreFnDef. RuleAsg1 defines that the expression of an assign- ment needs to be evaluated first before assigning the resulting value. The rule for blocks is defined analogously. RuleBool1defines that the left operand has to be evaluated before the right operand. RuleIf1, branches the flow - the condition is evaluated before executing the block (hi - positive condition) or an “empty”

place (lo - negative condition). RuleElIf1 links the “empty” place of rule If1 to the alternativeIf. Rule Else1 is defined analogously.

RuleTFst2moves the token to the first child place (edgef) as long as possible.

RuleTNxt2moves the token of an evaluated place to the next place (edgen) and changes attributeevaltofalse. The rules implement a left-most inner-most evalu- ation strategy. RuleGetTM2evaluates eachGetTM-FnCallto a path-wide unique symbolic variable (Symb)Si(uniqueness is given by token attributesymwhich is increased by one). Note thatSymbs are ordered in their occurence of evaluation which is important for a later test generation. RuleGetTM2requires that a last Symbalready exists. An analogue rule creates a last Symbif not existent. Rule Asg2assigns the term of the evaluated expression to the variableVarand sets the assignment as evaluated by moving token edgeon. Rule BoolAnd2 concatenates

Init1

:Proc

<tr> :Stmnt

<tr>

first

<+>:P :P

<+>

f,l on

Stmnt1

:Stmnt :Stmnt<tr>

next :P :P l

<+>:P l

Bool1

:Bool :Expr

<tr>

:P

:Expr

<tr>

<+>:P :P

<+>

If1

<tr>:B :P

:Bool

<tr>

<+>:P

<+>:P

<+>:P

ElIf1

:P :P :P Asg1

:Expr

<tr>

:P f,l

:Asg ex

<+>:P

:If

<+>

<+> n f

:Token<+>

eval=false pc=true sym=0

<+> <+>

<+>

<+>

<->

<+>

<+>

<+>

l n

le ri

<+>

<+> <+> <+>

<+>

f

l l

lo hi

bl cond

<+> <+>

<+> <+>

<+>

<+>

<+>

f l

lo

el :If

<tr>:If

<+>

TFst2

:P f :P on

TNxt2

:P n :P :P

nxt

GetTM2 Asg2

:P :P

c on on

var

BoolAnd2

f l

c

c c

c

:Symb

Branch2 :P hi :P lo :P on c

c

lst

c

l :Asg

c

on

on c on

c c

on

Check2

sat(pc)=true

:Bool op=‘and‘

:Var<+>

name=v val=t

Id v:Var

:Token eval=true

:Term term=t

in :Token

eval=[false=>true]

sym=[i=>i+1]

:FnCall fn='GetTM' :Symb<+>

term=Si

:Token lst eval=[true =>false]

on on

:Token eval=false

on

:Term term=t1

:Term term=t2

<+>

<->

<+>

<+>

<-> <+>

<-> <+> <+>

<+>

<->

:P

<+>

:P :P

<+>

c :Token eval=true :Term<+>

term=and(t1,t2)

<+> on

<+> <->

:Token<+>

eval=check pc=[pc=>

and(pc, not(t))]

sym=i name=v:Var

val=vt

:Var<+>

name=v val=vt c

:Token eval=[check=>false] pc=pc :Term

term=t :Token eval=[true=>check]

pc=[pc=>and(pc,t)]

sym=i :Symb in

in

<+> <-> <+>

<+>

<+>

Fig. 3.Rules for annotation (top,GTSFlow) and symbolic execution (bottom,GTSSym)

(5)

both evaluated operands withand. Analogue rules for boolean expressions with other operators (or,<,>,etc.) are defined. Amalgamated rule Branch2 duplicates the token with all connected variables and symbols, negates the condition (not(t)) for the lo path and concatenates the condition with the path constraint. Rule Check2checks, if the path constraints of duplicated tokens are still satisfiable af- ter a branch (attribute conditionsat(pc)=true). If the path constraint of a token becomes unsatisfiable, the token statusevalremainscheckand the token can not be moved any more. After simulating the example in Fig. 2, three tokens from six possible paths are assigned to nodeProcwitheval=truewhile the other three tokens remain at the last If statement with unsolvable path constraints. Only tokens that are assigned to nodeProcwitheval=trueare considered during test case generation (they represent execution paths with solvable path constraints).

Additional rules are defined for annotating and traversing function calls and def- initions. A function is traversed every time it is called so that global side effects in execution can be respected, e.g., operations on call by reference arguments.

4 Implementation & Test Case Generation

A procedure is parsed with Xtext [5] to an EMF AST graph first. Then, the EMF Henshin tool [7] is used in combination with the ECLiPSe constraint solver [9] to execute the AST graph by automatic rule applications and satisfiability checking / solving constraints. The AST graph is completely preserved during execution.

Correspondences between symbolic variables of path constraints (nodes of type Symb) and AST graph structures are used for test generation by applying the forward model transformation (FT) rules in Fig. 4. An FT rule [8] consists of a source graphGS, correspondence graph GC and target graph GT. WhileGS

is parsed, nodes and edges in GC, GT are created. Applying the rules yields a graph that is serialised to test case files with Xtext. RuleProc2Testcreates aTest suite for a procedure. RuleToken2Casecreates a test case for each execution path with solvable path constraint. RuleLstSymb2KeyElemadds a keytmfor each last (edge lst) evaluated GetTM(tm) function call of an execution path to the test case with a list containing a test input valuation for symbolic variablesas first (edgefst) element so that path constraintpcis satisfied (solve(s,pc)). A second rule handles all previous symbolic variables. Symbolic variables are ordered in order to reflect the sequential execution order of the representedGetTMfunction calls which is needed for proper test generation with test inputs in correct order.

lst c

:C

:Case

<+>

:Case GT

GC

GS

case :Test

:C GT

GC

GS

:Proc

<tr> :Test

<+>

:C GT

GC

GS

Proc2Test Token2Case

k LstSymb2KeyElem

fst arg

<+> <+>

<+>

:Proc

<+> <+><+>

:C

on

<+>

:Symb<tr>

term=s :ListElem<+> val=solve(s,pc) :FnCall

fn=‘GetTM‘

:Token pc=pc :P

:Token

<tr> :Arg

val=tm :P

:Key<+>

name=tm

<+> <+>

Fig. 4.Rules for test case generation

(6)

5 Conclusion & Related Work

We have presented a framework for symbolically executing simple satellite proce- dures. The approach preserves the correspondences between symbolic variables and the AST, so that the result graph can be used for test case generation by performing model transformations afterwards. A prototype implementation for the symbolic execution and test case generation framework has been presented.

In contrast to interpreter based symbolic execution engines [1,3] of program- ming languages, our graph-transformation-based approach allows symbolic exe- cution on a more abstract level enabling its formal analysis and application to other languages and behavioural diagrams in future work. In [2], an abstract symbolic execution framework based on term rewriting is proposed. In contrast to our approach, the correspondences between symbolic variables and the pro- gram term are not preserved. Research on how to transfer and enhance results from term to graph rewriting approaches for symbolic execution is topic of future work. In [10], the execution of UML state machines is presented but diagram–

path-constraint correspondences are not specified explicitly.

In future work, we plan to extend the symbolic execution semantics for ap- plicability to industrial SPELL SCPs [8] and analyse its correctness w.r.t. a formal SPELL semantics that needs to be defined first. We will investigate im- portant properties of symbolically executed models that should be preserved during model refactorings and how to ensure their preservation. Moreover, we will assess the scalability of our approach.

References

1. Anand, S., Pasareanu, C.S., Visser, W.: JPF-SE: A symbolic execution extension to java pathfinder. In: TACAS. pp. 134–138 (2007)

2. Arusoaie, A., Lucanu, D., Rusu, V.: A Generic Approach to Symbolic Execution.

Tech. Rep. RR-8189, INRIA (Dec 2012)

3. Cadar, C., Dunbar, D., Engler, D.: Klee: unassisted and automatic generation of high-coverage tests for complex systems programs. In: Proceedings of the 8th USENIX conference on Operating systems design and implementation. pp. 209–

224. OSDI’08, USENIX Association, Berkeley, CA, USA (2008)

4. Cadar, C., Sen, K.: Symbolic execution for software testing: three decades later.

Commun. ACM 56(2), 82–90 (Feb 2013)

5. The Eclipse Foundation: Xtext (2013),http://www.eclipse.org/Xtext/

6. Ehrig, H., Ehrig, K., Prange, U., Taentzer, G.: Fundamentals of Algebraic Graph Transformation, vol. EATCS Monographs in Theoretical Computer Science.

Springer (2006)

7. EMF Henshin (2013),http://www.eclipse.org/modeling/emft/henshin/

8. Hermann, F., Gottmann, S., Nachtigall, N., Braatz, B., Morelli, G., Pierre, A., En- gel, T.: On an Automated Translation of Satellite Procedures Using Triple Graph Grammars. In: Proc. ICMT’13, LNCS, vol. 7909, pp. 50–51. Springer (2013) 9. Schimpf, J., Shen, K.: Eclipse - from lp to clp. Theory and Practice of Logic

Programming 12, 127–156 (2012)

10. Zurowska, K., Dingel, J.: Symbolic execution of UML-RT State Machines. In: Proc.

of SAC ’12. pp. 1292–1299. SAC ’12, ACM (2012)

Références

Documents relatifs

• Dependency Analysis - A component for computing the set of transitions that have an impact or are impacted by any of the updated transitions found in T updated. The two inputs to

shows an overview of the overall workflow using the main tool features of H ENSHIN TGG... 1) import EMF models Imports 3) draw triple rules Rules 2) draw source models Graphs

We show three use cases for our tool: the first one illustrates the execution and LTL model checking for imp programs extended with I/O instructions, the second one demonstrates the

We argue that the fulfillment of these two directions can be achieved through path testing in a systematic and automated way, relying on the ESPM me- thod (hereafter called

Then we try to close all open premises that contain temporal logic formulas, which results in a similar proof graph as shown in figure 1, but with several additional open premises

It relies on a more general way of defining programming languages, consisting in using (Topmost) Matching Logic to denote sets of program states and Reachability Logic for

In this section we present some theoretical material used in the rest of the pa- per: induction and coinduction (Section 3.1), a general technique for reasoning about finite

In particular, we will outline the key characteristics of the SMT queries generated during symbolic execution, introduce an extension of KLEE that uses a number of state-of-the-art