Software Architecture-based Testing and Model-checking
Software Architecture-based Testing and Model-checking
Software Architecture-based Testing and Model-checking
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
<strong>Software</strong> <strong>Architecture</strong>-<strong>based</strong><br />
<strong>Testing</strong> <strong>and</strong> <strong>Model</strong>-<strong>checking</strong><br />
- ECI 2005, University of Buenos Aires -<br />
Course Web-site: [www.di.univaq.it/muccini/ECI05/]<br />
Lecture 4(part 1): Charmy<br />
SEA Group<br />
2<br />
SEA Group<br />
3<br />
Lecturer:<br />
Henry Muccini<br />
Assistant Professor, Computer Science Department<br />
University of L'Aquila -Italy<br />
muccini@di.univaq.it<br />
[www.di.univaq.it/muccini] – [www.HenryMuccini.com]<br />
Copyright Notice<br />
» The material in these slidesmaybe freelyreproduced <strong>and</strong><br />
distributed, partiallyor totally, asfar asan explicit reference<br />
or acknowledge to the material author ispreserved.<br />
© 2005 by H. Muccini / ECI 2005 Course<br />
Acknowledgment<br />
© 2005 by H. Muccini / ECI 2005 Course<br />
Henry Muccini<br />
» This work is joined with Patrizio Pelliccione <strong>and</strong> Paola<br />
Inverardi, University of L’Aquila.<br />
» The CharmyWebsite isavailable online:<br />
www.di.univaq.it/charmy<br />
1
SEA Group<br />
4<br />
SEA Group<br />
5<br />
SEA Group<br />
6<br />
Agenda<br />
» <strong>Model</strong>-Checking<br />
» Charmy<br />
» SPIN<br />
© 2005 by H. Muccini / ECI 2005 Course<br />
<strong>Software</strong> <strong>Model</strong> Checking<br />
» <strong>Model</strong> Checking:<br />
- It checks whether a certain property isvalid for a certain<br />
model of a system [Ruys_PhDThesis]<br />
> <strong>Model</strong> <strong>checking</strong>is a model-<strong>based</strong>, automatic techniquethat,<br />
given a finite-state model M of a system <strong>and</strong> a propertyP,<br />
checks the validity of P in M<br />
© 2005 by H. Muccini / ECI 2005 Course<br />
<strong>Model</strong> Checking steps<br />
» Used in studying behaviors of reactive systems<br />
» Typically involves three steps:<br />
1. Create a finite state model (FSM) of the system design<br />
> Formal languages<br />
2. Specify critical correctness properties<br />
> Formal languages<br />
3. Validate the model w/r to the specifications<br />
- It checks whether a certain property is valid for a certain model of a<br />
system [Ruys_PhDThesis]<br />
© 2005 by H. Muccini / ECI 2005 Course<br />
2
SEA Group<br />
7<br />
SEA Group<br />
8<br />
SEA Group<br />
9<br />
<strong>Model</strong> Checking Activities <strong>and</strong> Artifacts<br />
Input <strong>Model</strong> Checker Output<br />
System<br />
Specification<br />
Properties<br />
Formal<br />
Languages<br />
© 2005 by H. Muccini / ECI 2005 Course<br />
Create a FSM<br />
» FSM languages<br />
© 2005 by H. Muccini / ECI 2005 Course<br />
Internal<br />
representation<br />
Internal<br />
representation:<br />
Properties<br />
feedback<br />
<strong>Model</strong> Checking<br />
Algorithm<br />
- focus on expressing concurrency, synchronization, <strong>and</strong><br />
communication<br />
- abstract details of internal computations<br />
- must be precise <strong>and</strong> unambiguous (formally defined syntax <strong>and</strong><br />
semantics)<br />
» We will use Promela for giving system<br />
descriptions<br />
Specify correctness properties<br />
» Safety properties:<br />
- Nothing “bad” ever happens<br />
> Formalized using state invariants<br />
- execution never reaches a “bad” state<br />
» Liveness properties:<br />
- Something “good” eventually happens<br />
> Formalized using temporal logic<br />
- special logic for describing sequences<br />
© 2005 by H. Muccini / ECI 2005 Course<br />
Exhaustive <strong>and</strong><br />
automated<br />
True or false<br />
with<br />
counter-example<br />
3
SEA Group<br />
10<br />
SEA Group<br />
11<br />
SEA Group<br />
12<br />
Validate the model<br />
» “Execute” the model to test it<br />
- simulate executions of the system<br />
- check satisfaction of safety properties along simulated executions<br />
» Exhaustive analysis<br />
- generate reachability graph to verify safety <strong>and</strong> livenessproperties<br />
» Generate counterexamples to illustrate failures<br />
© 2005 by H. Muccini / ECI 2005 Course<br />
<strong>Model</strong> Checking <strong>and</strong> Design Validation<br />
» <strong>Model</strong> Checker<br />
- advantages:<br />
> automatic<br />
> exhaustive<br />
> it produces a counter-example(in the case of fail)<br />
- limitations:<br />
> state explosionproblem<br />
> skills on formal methods are required<br />
© 2005 by H. Muccini / ECI 2005 Course<br />
<strong>Model</strong>-Checking limitation <strong>and</strong> solutions<br />
» State Explosion Problem<br />
» Solutions:<br />
- Compress<br />
> BDDs (Binary DecisionDiagrams) [Bryant 1986]<br />
- Reduce<br />
> Partial-Order Reduction<br />
- Exploresonly relevantportions of the state space<br />
- Idea: usually the validity of a search is independentfrom the<br />
orderof intearleavingof concurrentevents<br />
© 2005 by H. Muccini / ECI 2005 Course<br />
4
SEA Group<br />
13<br />
14<br />
<strong>Model</strong> Checker: BDDs<br />
© 2005 by H. Muccini / ECI 2005 Course<br />
<strong>Model</strong> Checker: other solutions to state explosion<br />
» Compositional reasoning<br />
- Idea: to decompose a propertyinto sub-properties which maybe checkedon<br />
sub-systems.<br />
Assumptionon the environment are necessary:<br />
> Assume-guarantee paradigm<br />
» Abstraction<br />
- Cone of influence reduction:<br />
> Idea: to eliminate unnecessary variables<br />
- Data abstraction<br />
» Symmetry<br />
» Induction<br />
SEA Group<br />
SEA Group<br />
15<br />
> Idea: substitute current variables with abstract ones<br />
© 2005 by H. Muccini / ECI 2005 Course<br />
Charmy<br />
© 2005 by H. Muccini / ECI 2005 Course<br />
5
SEA Group<br />
16<br />
SEA Group<br />
17<br />
<strong>Model</strong> Checking Activities <strong>and</strong> Artifacts<br />
Input <strong>Model</strong> Checker Output<br />
System<br />
Specification<br />
Properties<br />
Formal<br />
Languages<br />
© 2005 by H. Muccini / ECI 2005 Course<br />
© 2005 by H. Muccini / ECI 2005 Course<br />
Internal<br />
representation<br />
Internal<br />
representation:<br />
Properties<br />
feedback<br />
CHARMY: CHARMY <strong>Model</strong>-<strong>checking</strong> SAs<br />
System<br />
Specification Properties<br />
Engines:<br />
SEA Group diagrams to formal<br />
18 © 2005 by languages H. Muccini / ECI 2005 Course<br />
<strong>Model</strong> Checking<br />
Algorithm<br />
properties<br />
SA validation wrt Requirements [CharmyWeb]<br />
Notations:<br />
UML-<strong>based</strong><br />
SA spec<br />
Step1<br />
SA spec properties<br />
Step3<br />
Exhaustive <strong>and</strong><br />
automated<br />
True or false<br />
with<br />
counter-example<br />
(www.di.univaq.it/charmy)<br />
Step2<br />
6
SEA Group<br />
19<br />
SEA Group<br />
20<br />
SEA Group<br />
21<br />
CHARMY<br />
» Iterative process<br />
» Tool support:<br />
- offers a graphicaluser interface to drawstate diagrams <strong>and</strong><br />
scenarios<br />
- a plugin which allows to input existingdiagram in the XMI<br />
format<br />
- a translation engine to automatically derive Promela code <strong>and</strong><br />
Buchi Automaton<br />
© 2005 by H. Muccini / ECI 2005 Course<br />
Experience<br />
» SA-<strong>based</strong> <strong>Model</strong>-Checking<br />
- Telcordia [FIDJI02]<br />
- Marconi [FME03]<br />
- Siemens C.N.X.<br />
- TermaGmbH<br />
» SA-<strong>based</strong> Code <strong>Testing</strong>:<br />
- PSTDA Italy[ICSE00,ICSE01]<br />
- The Whiteboard study [BookChapter03]<br />
» ModTest:<br />
- Siemens [ITM04, Subm05]<br />
- TermaGmbH<br />
© 2005 by H. Muccini / ECI 2005 Course<br />
The ModTest/Charmy Team<br />
» SEA Group, University of L’Aquila:<br />
- Paola Inverardi, Henry Muccini, Patrizione Pelliccione (Caporuscio, Cortellessa, Di Marco)<br />
- Ezio di Nisio (funded by Siemens C.N.X.) <strong>and</strong> Maya Cardone (funded by Terma GmbH)<br />
- Currently: 10 bachelor <strong>and</strong> master thesis<br />
» CurrentIndustrialpartners:<br />
- Siemens C.N.X.<br />
- Terma GmbH<br />
» Currentaccademiccollaborations:<br />
- ISTI, CNR (Pisa)<br />
- ITM, Lucca<br />
- University of Luxembourg<br />
- University of California, Irvine<br />
- University of Paderborn<br />
© 2005 by H. Muccini / ECI 2005 Course<br />
7
SEA Group<br />
22<br />
SEA Group<br />
23<br />
SEA Group<br />
24<br />
Challenge 1 : informal but formal<br />
» Formal ADLs<br />
+ Automatic analysis<br />
- Time, cost <strong>and</strong> skills<br />
» Informal or Semi-Formal description<br />
+ Faster <strong>and</strong> easier<br />
- Low automation<br />
» Charmy:<br />
- model-<strong>based</strong> specifications used to specify the SA topology <strong>and</strong><br />
behavior<br />
- a formal Promela prototype is automatically generated<br />
© 2005 by H. Muccini / ECI 2005 Course<br />
Challenge 2 : incremental analysis<br />
» SA-<strong>based</strong> software process:<br />
- It is not clear how to incrementally identify <strong>and</strong> analyze components<br />
<strong>and</strong> connectors<br />
- Refinement <strong>and</strong> Analysis<br />
- Goal:<br />
> To identify a way to detect faulty components that can be successively<br />
refined <strong>and</strong> analyzed again<br />
» Charmy:<br />
- An high-level architecture is analyzed;<br />
- Faulty components are refined <strong>and</strong> re-analyzed<br />
© 2005 by H. Muccini / ECI 2005 Course<br />
Challenge 3 : Automation<br />
» To generate Promela specification automatically from<br />
model-<strong>based</strong> specifications<br />
» Goal: to help the industry to meet model <strong>checking</strong> <strong>and</strong><br />
formal analysis<br />
» Charmy:<br />
- A tool is under development<br />
© 2005 by H. Muccini / ECI 2005 Course<br />
8
SEA Group<br />
25<br />
SEA Group<br />
26<br />
SEA Group<br />
27<br />
Summarizing<br />
» <strong>Model</strong>-<strong>checking</strong> analysis without formal specification<br />
knowlege<br />
» Incremental analysis of refined components<br />
» Deadlock, liveness, inconsistency, incompleteness<br />
detected at the architecture level<br />
» <strong>Testing</strong> <strong>and</strong> <strong>Model</strong>-<strong>checking</strong> of <strong>Software</strong> <strong>Architecture</strong><br />
© 2005 by H. Muccini / ECI 2005 Course<br />
SPIN<br />
† The selected <strong>Model</strong> Checker [BellLabs 1980]<br />
† The specification language is Promela (PROcess MEtaLAnguage)<br />
† The properties can be expressed using the temporal logic LTL (Linear-time<br />
Temporal Logic)<br />
† Features:<br />
† on-the-fly verification i.e. it no need to construct a global state graph as<br />
a prerequisite for the verification<br />
† r<strong>and</strong>om, interactive e guided simulations<br />
† partial order reduction techniques, <strong>and</strong> (optionally) BDD-like storage<br />
techniques to optimize the verification runs<br />
© 2005 by H. Muccini / ECI 2005 Course<br />
SPIN: Promela<br />
† Promela supports the not-determinism<br />
† A Promela program consists of:<br />
† Processes<br />
† Communication channels<br />
† Variables<br />
† Concurrent processes communication:<br />
† Shared memory<br />
† Buffered channels (asynchronous communication)<br />
† 0 dimension channels (rendez-vous communication)<br />
© 2005 by H. Muccini / ECI 2005 Course<br />
9
SEA Group<br />
28<br />
SEA Group<br />
29<br />
SEA Group<br />
30<br />
CHARMY (www.di.univaq.it/charmy)<br />
Step1<br />
© 2005 by H. Muccini / ECI 2005 Course<br />
© 2005 by H. Muccini / ECI 2005 Course<br />
Step3<br />
Step2<br />
Step 1: Promela code<br />
† Each components state diagram is translated in a Promela process,<br />
proctype<br />
† A special process connector is added to manipulate the communication<br />
between the components<br />
† The translation maintain the connectors only for the complex<br />
communications<br />
† Synchronous /Asynchronous communications are realized with<br />
Promelaprimitives<br />
Component transparency<br />
to connectors<br />
Step 1: Promela code<br />
a<br />
?ch1<br />
!ch2<br />
b<br />
c<br />
…<br />
Statecharts<br />
!ch1<br />
x<br />
?ch2<br />
© 2005 by H. Muccini / ECI 2005 Course<br />
y<br />
Ch1Connector<br />
Q P<br />
!ch1<br />
OP()<br />
?ch1<br />
proctypeComponente1()<br />
{<br />
s0:<br />
sn:<br />
}<br />
.<br />
.<br />
;goto si ;<br />
.<br />
.<br />
;goto sj ;<br />
proctypeComponenteM ()<br />
{…}<br />
proctypeConnettore()<br />
{…}<br />
10
SEA Group<br />
31<br />
SEA Group<br />
32<br />
SEA Group<br />
33<br />
Step 1: Promela code<br />
Basic<br />
† :<br />
messages exchange<br />
Complete<br />
† :<br />
messages exchange +<br />
stored the exchange time<br />
†Generated states<br />
8 states for the basic<br />
15 states for the complete<br />
© 2005 by H. Muccini / ECI 2005 Course<br />
Step2: LTL Formula<br />
Algorithm:<br />
© 2005 by H. Muccini / ECI 2005 Course<br />
Expressing power:<br />
•After m1 eventually m2 message<br />
•Invalid end-states<br />
•Unreachable code<br />
•Invariants<br />
Expressing power:<br />
•All basic verifications<br />
•The message is exchanged at the time t<br />
•Message ordered punctually<br />
•Used principally for the “negative<br />
scenarios”<br />
9684 states for the basic<br />
2263030 states for the complete<br />
† To analyze the message order in the scenario<br />
† To analyze the arrows type (synchronous, asynchronous,…)<br />
† To identify “when” a send or receive action is performed over<br />
each channel<br />
† To generate an LTL formula containing the same message order<br />
Step2: LTL formula<br />
† Other information used:<br />
† The only allowed actions are expressed in the scenario: Strict check<br />
† It is allowed only with the Complete translation algorithm<br />
† Also other actions not expressed in the scenario are allowed: Loose check<br />
† These checks type are embedded in the LTL formula. To define the LTL<br />
formula we are interested in, we need information not expressed in the<br />
scenarios<br />
© 2005 by H. Muccini / ECI 2005 Course<br />
11
SEA Group<br />
34<br />
SEA Group<br />
35<br />
Step3: SPIN<br />
† Is the temporal order described in the scenarios satisfied<br />
by “some” paths in the model generated from SPIN?<br />
† Two verifications type:<br />
1. Exist at least one behavior satisfying the LTL formula<br />
2. All architectural paths are conform with the selected scenario<br />
© 2005 by H. Muccini / ECI 2005 Course<br />
Summarizing the parameters<br />
EXIST<br />
FOR<br />
ALL<br />
SEA Group<br />
36<br />
» Frequency: High<br />
STRICT<br />
» Use: negative scenarios<br />
» Algorithm: Complete<br />
Do not sound<br />
© 2005 by H. Muccini / ECI 2005 Course<br />
Tool Support<br />
© 2005 by H. Muccini / ECI 2005 Course<br />
LOOSE<br />
» Frequency: Very High<br />
» Use: negative scenarios<br />
» Algorithm: Basic<br />
» Frequency: Very High<br />
» Use: Properties that the<br />
system must satisfy<br />
» Algorithm: Basic<br />
www.di.univaq.it/charmy<br />
12
SEA Group<br />
37<br />
SEA Group<br />
38<br />
SEA Group<br />
39<br />
Case Studies<br />
† NICE (Naval Integrated Communication Environment) [FME03]<br />
† Work developed with Marconi-Selenia-L’Aquila<br />
† Found malfunctioning caused by message loosing<br />
† Cometa [MasterThesis<br />
MasterThesis]<br />
† Extension to the mobility for Siena, a publish/subscribe middleware<br />
† Analyzed two solutions in order to select the better<br />
† AOJ2EE [FIDJI02]<br />
† Active Object on J2EE reference implementation<br />
† Analyzed two solutions in order to select the better<br />
© 2005 by H. Muccini / ECI 2005 Course<br />
Advantages<br />
» <strong>Model</strong> complexity<strong>and</strong> the state explosion reduction<br />
obtained bySA-levelmodel <strong>checking</strong>;<br />
» Iterative approach: continuousrefinement<br />
» Charmy → easy to use, practicalapproach to model<strong>checking</strong>,<br />
hidingthe modelingcomplexity;<br />
» Test specificationsare identified from the architectural<br />
model (not from requirements)<br />
- Easiest alignment betweenSA <strong>and</strong> Test specifications;<br />
- Easiest control of the design steps <strong>and</strong> evolution<br />
© 2005 by H. Muccini / ECI 2005 Course<br />
Future work (1/2)<br />
†Possible solution at the state explosion problem<br />
† Compositional reasoning<br />
Idea: it is interesting to decompose the system specification into properties that<br />
describe the behavior of a system's subset.<br />
To make it, we need of assumptions over the environment:<br />
† Assume-guarantee paradigm<br />
† Slicing-Abstraction<br />
Idea: to cut from the system behaviors not interesting for the verification<br />
† More abstraction level zooming in the subparts<br />
† Supported by the tool in the static architecture part<br />
© 2005 by H. Muccini / ECI 2005 Course<br />
13
SEA Group<br />
40<br />
SEA Group<br />
41<br />
SEA Group<br />
42<br />
Future work (2/2)<br />
†What formulas we can derive starting from the scenarios?<br />
Message Sequence Charts<br />
UML Sequence Diagrams<br />
Extensions<br />
†Considering other properties<br />
†Tool<br />
Introducing the time<br />
Increasing the usability<br />
Integrate the tool with other tools (ArgoUML, LTSA,…)<br />
†Integrated analysis<br />
© 2005 by H. Muccini / ECI 2005 Course<br />
Some (of our) References<br />
• [Straw01] P. Inverardi, H. Muccini <strong>and</strong> P. Pelliccione. "Checking<br />
consistency between architectural models using SPIN". In Proc. ICSE2001 Workshop ``From <strong>Software</strong><br />
Requirements to <strong>Architecture</strong>s" (STRAW'01), May 2001.<br />
• [ASE2001] P. Inverardi, H. Muccini <strong>and</strong> P. Pelliccione. "Automated Check ofArchitectural <strong>Model</strong>s<br />
Consistency using SPIN”. In Proc.<br />
Automated <strong>Software</strong> Engineering conference, ASE2001, year 2001.<br />
» [PhDThesis PhDThesis] H. Muccini. <strong>Software</strong> <strong>Architecture</strong> for <strong>Testing</strong>, Coordination <strong>Model</strong>s <strong>and</strong> Views <strong>Model</strong><br />
Checking, PhD thesis, year 2002.<br />
» [FIDJI02] P. Inverardi, F. Mancinelli, H. Muccini, <strong>and</strong> P. Pelliccione. An Experience in Architectural<br />
Extensions: Active Objects in J2EE. In Proc. Int. Workshop on Scientific Engineering of Distributed Java<br />
Applications (FIDJI'2002), November 2002, Luxembourg. Lecture Notes in Computer Science (LNCS)<br />
2604, pp. 87 ff.<br />
» [FME03] D.Compare, P. Inverardi, P. Pelliccione <strong>and</strong> A. Sebastiani. Integrating model-<strong>checking</strong><br />
architectural analysis <strong>and</strong> validation in a real software life-cycle. In Proc. FM 2003: the 12th International<br />
FME Symposium, September 2003, Pisa. LNCS series.<br />
» [MasterThesis<br />
MasterThesis] ] M.Caporuscio. CoMETA-mobility support in the Siena publish/subscribe middleware.<br />
Master’s thesis, Università degliStudi dell’Aquila -Dipartimento di Informatica, L’Aquila- Italy, March<br />
2002.<br />
» [ITB03] P. Inverardi, M. Tivoli, <strong>and</strong> A. Bucchiarone. Coordinators synthesis for COTSgroup-ware systems: an<br />
example. Published in DMC 2003. Also Technical Report, University of LAquila, Department of Computer Science,<br />
http://www.di.univaq.it/tivoli/cscw techrep.pdf, March 2003.<br />
© 2005 by H. Muccini / ECI 2005 Course<br />
Required Readings<br />
» Required reading:<br />
P. Inverardi, H. Muccini, <strong>and</strong> P. Pelliccione. Charmy:<br />
A framework for model <strong>based</strong> consistency <strong>checking</strong>.<br />
Technical Report, Dept. of Comp. Science, Univ. of<br />
L'Aquila, May 2004. http://www.di.univaq.it/charmy<br />
© 2005 by H. Muccini / ECI 2005 Course<br />
14
<strong>Software</strong> <strong>Architecture</strong>-<strong>based</strong><br />
<strong>Testing</strong> <strong>and</strong> <strong>Model</strong>-<strong>checking</strong><br />
- ECI 2005, University of Buenos Aires -<br />
Course Web-site: [www.di.univaq.it/muccini/ECI05/]<br />
Lecture 4(part 2): Charmy in Practice<br />
SEA Group<br />
2<br />
SEA Group<br />
3<br />
Lecturer:<br />
Henry Muccini<br />
Assistant Professor, Computer Science Department<br />
University of L'Aquila -Italy<br />
muccini@di.univaq.it<br />
[www.di.univaq.it/muccini] – [www.HenryMuccini.com]<br />
Copyright Notice<br />
» The material in these slidesmaybe freelyreproduced <strong>and</strong><br />
distributed, partiallyor totally, asfar asan explicit reference<br />
or acknowledge to the material author ispreserved.<br />
© 2005 by H. Muccini / ECI 2005 Course<br />
Agenda<br />
» The CharmyTool<br />
» Toolextensibility<br />
» Get Started<br />
» An Example<br />
© 2005 by H. Muccini / ECI 2005 Course<br />
Henry Muccini<br />
1
SEA Group<br />
4<br />
SEA Group<br />
5<br />
SEA Group<br />
6<br />
Introduction –Charmy tool<br />
» Charmy tool allowsthe descriptionof software<br />
architectures<strong>and</strong> propertiesthrougha UML <strong>based</strong><br />
specification<br />
- Structural <strong>Model</strong> usedto specifycomponents<strong>and</strong><br />
connections<br />
- State Diagrams are used to specifycomponentsbehaviour<br />
- Scenarios (Sequence Diagrams) are used to specify<br />
properties<br />
» Charmy generates Promela code (formal prototypes)<br />
from models<br />
» Formal prototypescanbe validated usingthe model<br />
checkerSPIN<br />
© 2005 by H. Muccini / ECI 2005 Course<br />
Case Study –The TC Chain modeling<br />
» WithinSA·X we modeleda simplified version of thereal<br />
SCOS-2000 TC Chain<br />
» Somesimplificationhave beendone, the most relevent of<br />
thoseare:<br />
- No blocks<strong>and</strong> sequences<br />
- No interlock<br />
- Onlyone CEV stage<br />
» We focusedon theVerifier <strong>and</strong> CEV stage components<br />
© 2005 by H. Muccini / ECI 2005 Course<br />
The Charmy Plugin <strong>Architecture</strong><br />
© 2005 by H. Muccini / ECI 2005 Course<br />
2
SEA Group<br />
7<br />
SEA Group<br />
8<br />
SEA Group<br />
9<br />
Tool Support [ESEC/FSE05 Demo]<br />
© 2005 by H. Muccini / ECI 2005 Course<br />
Charmy Notation<br />
» SA Topology:<br />
© 2005 by H. Muccini / ECI 2005 Course<br />
Promela Code<br />
generation<br />
- The SA topology is modeled via UML-like<br />
component diagrams<br />
> UML 2.0 component diagrams<br />
» SA Behavior:<br />
- The behavior of each single component is<br />
modeled via Charmy annotatedState Diagrams<br />
» Propertiesto be validated:<br />
- Properties are modeled via Property Sequence<br />
- Charts (PSCs)<br />
SA Topology<br />
© 2005 by H. Muccini / ECI 2005 Course<br />
: Notation<br />
SA <strong>and</strong><br />
properties<br />
specification<br />
Buchi<br />
Automaton<br />
generation<br />
SA Topology<br />
SA Behavior<br />
Properties<br />
SA<br />
components<br />
Messages<br />
Next release<br />
with UML 2.0<br />
component<br />
diagrams<br />
3
!m1(e)<br />
S0 s1<br />
SA Behavior<br />
: Notation<br />
?m3 ?m2<br />
!m2<br />
S0 s1<br />
S2<br />
[x!=0]?m1(e)/Op();<br />
!m3<br />
Properties<br />
Comp P Comp Q<br />
e: m1<br />
f: m2<br />
r: m3<br />
Component P Component Q<br />
State machine State machine<br />
b)<br />
Between a pair of messages we can<br />
Regular Fail specify messages: if other messages messages that constituting can should occur<br />
Constraints: define a set of messages<br />
Send (“!”) or Receive (“?”) the<br />
Required (loose never precondition relation) exchanged,<br />
messages: or for not a<br />
if<br />
when desired<br />
the (strict precondition<br />
their relation)<br />
that must never occur in between (or an the<br />
of a message<br />
is<br />
precondition<br />
satisfied,<br />
undesired)<br />
then<br />
becomes behavior<br />
the system<br />
true<br />
must<br />
message containing the constraint<br />
exchange this message.<br />
SEA Group<br />
<strong>and</strong> its predecessor<br />
‘[‘ 10 guard © ’]’event 2005 by H. Muccini channel_name / ECI 2005 Course ‘/’ op1 ‘;’op2 ‘;’… ‘;’opn<br />
SEA Group<br />
11<br />
SEA Group<br />
12<br />
Charmy notation - Topology<br />
» Each System component is represented by a box<br />
labeled with its name<br />
» The relation that lies between two components is<br />
represented by an arrow<br />
» With a topology diagram we can only describe the<br />
System from a statical point of view.<br />
© 2005 by H. Muccini / ECI 2005 Course<br />
Scenarios <strong>and</strong> LTL formulae<br />
» In an industrial context it is unfeasible to write by h<strong>and</strong><br />
complex LTL formulae, as pointed out by Holzmann<br />
[Holzmann, FSE02].<br />
To this extent, he proposes a tool to write temporal<br />
properties in a graphical notation.<br />
» An alternative approach to the specification of LTL<br />
formulae is presented in [Dwyer, ICSE99], where the user<br />
may choose an LTL formula from a library of predefined<br />
formulae.<br />
» Differently from both approaches, we specify behavioral<br />
properties using the familiar formalism of sequence<br />
diagrams <strong>and</strong> automatically translate them into B¨uchi<br />
automata<br />
© 2005 by H. Muccini / ECI 2005 Course<br />
C1<br />
4
13<br />
Charmy notation – Scenarios<br />
PSC<br />
Property Sequence Charts<br />
•Regular messages: are identified by the e label <strong>and</strong> they denote a set of<br />
messages that constitute the precondition for a desired (or an undesired)<br />
behavior. A Regular message must not necessary happen in every system<br />
execution. However, if it happens, it is relevant<br />
•Required messages: are identified by the r label. If the precondition for a<br />
Required message is satisfied, then this message must occur<br />
•Fail messages: are identified by the f label <strong>and</strong> identify messages that must<br />
never occur when its precondition becomes true<br />
SEA Group<br />
SEA Group<br />
14<br />
SEA Group<br />
15<br />
© 2005 by H. Muccini / ECI 2005 Course<br />
Charmy notation – Scenarios<br />
» Between a pair of messages we can select<br />
if other messages can occur (loose<br />
relation) or not (strict relation).<br />
Graphically, the strict relation is realized<br />
whit a thick line that lies the messages<br />
pair<br />
» Constraints, graphically represented as a<br />
filled circle, are introduced to define a set<br />
of messages that must never occur in<br />
between the message containing the<br />
constraint <strong>and</strong> its predecessor<br />
© 2005 by H. Muccini / ECI 2005 Course<br />
Charmy Scenario Editor<br />
© 2005 by H. Muccini / ECI 2005 Course<br />
5
SEA Group<br />
16<br />
SEA Group<br />
17<br />
SEA Group<br />
18<br />
Charmy notation – State machines<br />
To allow the translation process we need to add some semantics<br />
to make state diagrams close to the Promela sintax<br />
‘[‘ guard ’]’event channel_name ‘/’ op1 ‘;’op2 ‘;’… ‘;’opn<br />
© 2005 by H. Muccini / ECI 2005 Course<br />
Charmy State Editor<br />
© 2005 by H. Muccini / ECI 2005 Course<br />
Some examples on scenarios<br />
» (desired behaviour)<br />
- if A is followed by B than C must happen<br />
» (undesired behaviour)<br />
- A must be never followed by B<br />
© 2005 by H. Muccini / ECI 2005 Course<br />
6
SEA Group<br />
19<br />
SEA Group<br />
20<br />
SEA Group<br />
21<br />
Step 1: From State Machine to Promela code<br />
#define SMN <br />
#define AMN <br />
#define TMN <br />
#define CMN <br />
#define 0<br />
:<br />
a)<br />
#define MN-1<br />
» Each components<br />
state diagram is<br />
translated in a<br />
Promela proctype<br />
» A special process<br />
connector is added<br />
to manipulate the<br />
communication<br />
between the<br />
components<br />
© 2005 by H. Muccini / ECI 2005 Course<br />
!ch1<br />
s0 s1<br />
?ch3<br />
s2<br />
?ch1<br />
© 2005 by H. Muccini / ECI 2005 Course<br />
© 2005 by H. Muccini / ECI 2005 Course<br />
!ch2<br />
State description<br />
Component P<br />
?ch2<br />
s0 s1<br />
!ch3<br />
Component Q<br />
chan syncChannel[SMN] = [0] of {byte};<br />
chan asyncChannel[AMN] = [1] of {byte};<br />
chan tauChannel[TMN] =[1] of {byte};<br />
bool communicationReq[CMN];<br />
b)<br />
bool communicationOk[CMN];<br />
active proctype P()<br />
{s0:<br />
<br />
if<br />
::atomic{; goto s1};<br />
::atomic{; goto s2};<br />
fi;<br />
s1:<br />
atomic{; goto s0};<br />
s2:<br />
skip;<br />
}<br />
c)<br />
active proctype Q()<br />
{so:<br />
if<br />
::atomic{; goto s0};<br />
::atomic{; goto s0};<br />
::atomic{; goto s1};<br />
fi;<br />
s1:<br />
skip;<br />
}<br />
Step 2: PSC2BA - From PSC to Buchi Automaton<br />
» The algorithm:<br />
- analyzes the message<br />
order in the scenario<br />
- analyzes the arrows type<br />
- identifies “when” a send<br />
or receive action is<br />
performed over each<br />
channel<br />
- generates a Buchi<br />
Automaton containing<br />
the same message order<br />
PSC<br />
Property<br />
Sequence<br />
Charts<br />
User<br />
e: a<br />
b,c<br />
e: d<br />
f: c<br />
r: e<br />
ATM<br />
PSC2BA<br />
b,c<br />
e: a<br />
e: d<br />
f: c<br />
r: e<br />
!b&!c<br />
S0<br />
a<br />
b||c<br />
1<br />
S1<br />
S0<br />
d<br />
!d<br />
1<br />
S1<br />
S0<br />
S1<br />
S0<br />
S1<br />
c<br />
e<br />
!c<br />
1<br />
!e<br />
1<br />
S2<br />
S2<br />
1<br />
1<br />
7
SEA Group<br />
22<br />
SEA Group<br />
23<br />
SEA Group<br />
24<br />
© 2005 by H. Muccini / ECI 2005 Course<br />
Step 3: SPIN Verification<br />
© 2005 by H. Muccini / ECI 2005 Course<br />
Properties – Validation results (1)<br />
(Spin Version 4.2.3 -- 5 February2005)<br />
+ Graph Encoding(-DMA=173)<br />
Full statespacesearchfor:<br />
never claim +<br />
assertionviolations + (if withinscopeof claim)<br />
acceptance cycles + (fairness disabled)<br />
invalid end states -(disabledbynever claim)<br />
State-vector 432 byte, depthreached273, errors: 0<br />
MA stats: -DMA=165 is sufficient<br />
Minimized Automaton: 243572 nodes <strong>and</strong> 819532 edges<br />
5.00225e+07 states, stored(5.11589e+07 visited)<br />
2.85938e+08 states, matched<br />
3.37097e+08 transitions (= visited+matched)<br />
5.71893e+07 atomic steps<br />
hashconflicts: 0 (resolved)<br />
Stats on memoryusage(in Megabytes):<br />
21809.831 equivalent memoryusage for states (stored*(State-vector + overhead))<br />
16.463 actualmemoryusagefor states (compression: 0.08%)<br />
0.280 memoryusedfor DFS stack(-m10000)<br />
0.072 other (proc <strong>and</strong> chan stacks)<br />
0.104 memorylost to fragmentation<br />
16.638 total actualmemoryusage<br />
5837.50user 0.38system 1:37:18elapsed 99%CPU (0avgtext+0avgdata 0maxresident)k<br />
0inputs+0outputs (0major+4227minor)pagefaults 0swaps<br />
© 2005 by H. Muccini / ECI 2005 Course<br />
8
SEA Group<br />
25<br />
SEA Group<br />
26<br />
SEA Group<br />
27<br />
Properties – Validation results (2)<br />
(Spin Version 4.2.3 -- 5 February2005)<br />
+ Graph Encoding(-DMA=173)<br />
Full statespacesearchfor:<br />
never claim +<br />
assertionviolations + (if withinscopeof claim)<br />
acceptance cycles + (fairness disabled)<br />
invalid end states -(disabledbynever claim)<br />
State-vector 432 byte, depthreached273, errors: 0<br />
MA stats: -DMA=165 is sufficient<br />
Minimized Automaton: 239561 nodes <strong>and</strong> 833865 edges<br />
4.98823e+07 states, stored<br />
2.7958e+08 states, matched<br />
3.29462e+08 transitions (= stored+matched)<br />
5.58856e+07 atomic steps<br />
hashconflicts: 0 (resolved)<br />
Stats on memoryusage(in Megabytes):<br />
21748.675 equivalent memoryusage for states (stored*(State-vector + overhead))<br />
16.768 actualmemoryusagefor states (compression: 0.08%)<br />
0.280 memoryusedfor DFS stack(-m10000)<br />
0.076 other (proc <strong>and</strong> chan stacks)<br />
0.102 memorylost to fragmentation<br />
16.946 total actualmemoryusage<br />
4908.76user 0.30system 1:21:51elapsed 99%CPU (0avgtext+0avgdata 0maxresident)k<br />
0inputs+0outputs (179major+4124minor)pagefaults 0swaps<br />
© 2005 by H. Muccini / ECI 2005 Course<br />
Properties – Validation results (3)<br />
pan: acceptancecycle(at depth139)<br />
pan: wrotepan_in.trail<br />
(Spin Version 4.2.3 -- 5 February2005)<br />
Warning: Searchnot completed<br />
+ Graph Encoding(-DMA=173)<br />
Full statespacesearchfor:<br />
never claim +<br />
assertionviolations + (if withinscopeof claim)<br />
acceptance cycles + (fairness disabled)<br />
invalid end states -(disabledbynever claim)<br />
State-vector 432 byte, depthreached232, errors: 1<br />
1.50845e+06 states, stored<br />
8.0948e+06 states, matched<br />
9.60326e+06 transitions (= stored+matched)<br />
1.99902e+06 atomic steps<br />
hashconflicts: 0 (resolved)<br />
Stats on memoryusage(in Megabytes):<br />
657.686 equivalent memoryusage for states (stored*(State-vector + overhead))<br />
2.432 actualmemoryusagefor states (compression: 0.37%)<br />
0.280 memoryusedfor DFS stack(-m10000)<br />
0.075 other (proc <strong>and</strong> chan stacks)<br />
0.102 memorylost to fragmentation<br />
2.610 total actualmemoryusage<br />
148.38user 0.00system 2:28.40elapsed 99%CPU (0avgtext+0avgdata 0maxresident)k<br />
0inputs+0outputs (0major+806minor)pagefaults 0swaps<br />
© 2005 by H. Muccini / ECI 2005 Course<br />
Error investigation – Guided simulation<br />
© 2005 by H. Muccini / ECI 2005 Course<br />
9
SEA Group<br />
28<br />
SEA Group<br />
29<br />
SEA Group<br />
30<br />
Tool extensibility<br />
© 2005 by H. Muccini / ECI 2005 Course<br />
Tool Extension: Charmy Studio<br />
© 2005 by H. Muccini / ECI 2005 Course<br />
Our experience with Plugin Systems: CHARMY<br />
© 2005 by H. Muccini / ECI 2005 Course<br />
10
SEA Group<br />
31<br />
SEA Group<br />
32<br />
SEA Group<br />
33<br />
Plugin Systems<br />
» A plugin is a component, which can optionally be added<br />
to an existing system at runtime, to extend its<br />
functionality<br />
» By using a plugin architecture, we may incrementally<br />
build software systems, by adding new components to the<br />
initial core<br />
© 2005 by H. Muccini / ECI 2005 Course<br />
Eclipse<br />
» IBM Eclipse<br />
- Is a platform which provides the engine to implement systems as<br />
extensions to the platform itself, by means of plugins<br />
- To have an idea of the success of this platform, readers can refer<br />
to several plugins developed for Eclipse, <strong>and</strong> open source<br />
projects <strong>based</strong> on it<br />
> Eclipse Community Projects <strong>and</strong> plug-ins.<br />
http://www.eclipse.org/community/index.html.<br />
© 2005 by H. Muccini / ECI 2005 Course<br />
Other plugin systems<br />
» Text editor Jedit<br />
» the integrated environment for Java developers NetBeans<br />
» the music player Nullsoft Winamp<br />
» the browser Mozilla<br />
» the model checker Bogor<br />
- extensible in both the input language <strong>and</strong> the search <strong>and</strong><br />
optimization engine.<br />
© 2005 by H. Muccini / ECI 2005 Course<br />
11
SEA Group<br />
34<br />
SEA Group<br />
35<br />
SEA Group<br />
36<br />
Why Plugin Systems<br />
» i) we want to be able to extend the kind of analysis we may perform on an<br />
SA.<br />
- We recently extended the approach in order to integrate compositional<br />
verification techniques for architectural analysis, for formal analysis of<br />
architectural patterns <strong>and</strong> charmyintegration in the st<strong>and</strong>ard life-cycle process.<br />
» ii) We want charmy to be integrated with other existing tools.<br />
- We developed a plug which allows to describe the SA through st<strong>and</strong>ard UML<br />
tools, by means of an XMI representation, which may be imported/exported<br />
from charmy.<br />
- We developed a plug that, exploiting JSpin, a java interface for SPIN, aims at<br />
embedding SPIN in charmy.<br />
» iii) Moreover, we want charmy to be open with respect to the engines used to<br />
perform analysis.<br />
- Since we are not tied down to use the model checker SPIN, we are planning to<br />
use the model checker SMV or the model checker Bogor.<br />
© 2005 by H. Muccini / ECI 2005 Course<br />
Get Started<br />
© 2005 by H. Muccini / ECI 2005 Course<br />
How to Install<br />
» Needed Files:<br />
- Download the latest Charmy version from<br />
http://www.di.univaq.it/~charmy. Extract the zip folder where<br />
you want. To run Charmy, you need only to click on runCharmy<br />
file;<br />
- Download SPIN from http://spinroot.com/spin;<br />
> The easiest way to get started with SPIN is to use the graphical interface<br />
XSPIN. If you want to use the GUI you need to download the Tcl/Tk<br />
libraries (easy to search on google);<br />
- You also need a working C-compiler <strong>and</strong> a C-preprocessor<br />
© 2005 by H. Muccini / ECI 2005 Course<br />
12
SEA Group<br />
37<br />
SEA Group<br />
38<br />
SEA Group<br />
39<br />
Charmy use example (1/2)<br />
» Start Charmy;<br />
» In the Topology Editor you can create the software architecture<br />
component diagram using processes <strong>and</strong> channels;<br />
» For each process created in the topology editor, you must specify its<br />
bahaviorthrough the State Editor using State Machine models;<br />
» At this point, it’s possible to generate the Promela Code (Plug -><br />
Promela specified -> Promela Code); if there aren’t errors, in the<br />
Promela Window is displayed the Promela Source Code referred to<br />
the architecture;<br />
» Now you have to copy the Promela Code into a txt file (ex.<br />
promela.txt); take a look at the code <strong>and</strong> add (if not done) variables<br />
used in the pre condition section (ex. bit elapsed; bit time; bit ok; ...);<br />
© 2005 by H. Muccini / ECI 2005 Course<br />
Charmy use example (2/2)<br />
» At this moment, it’s possible to run either a simulation with SPIN<br />
(see next paragraph) or to create verification properties;<br />
» To create verification properties you need to define Sequence<br />
Diagrams from the Sequence Editor;<br />
- After that it’s possible to generate the BuchiAutomata from the<br />
Sequence Diagram (Plug -> BuchiAutomata Menu -> BuchiAutomata<br />
Generation);<br />
» Copy the code displayed in the BuchiAutomata Window in a txt file<br />
(ex. automata.txt);<br />
» It is the moment to validate the SA model conformance with respect<br />
to selected properties.<br />
© 2005 by H. Muccini / ECI 2005 Course<br />
Spin use example (1/4)<br />
» To start SPIN click on Xspin423 file;<br />
» You should now have the main Spin control window on<br />
the display; The main text window that you see offers<br />
some rudimentary edit <strong>and</strong> search capabilities.<br />
» Load the Promela Code: File -> Open -> select file<br />
promela.txt<br />
» Next, press the “Run..” button <strong>and</strong> then select Set<br />
Simulation Parameters...<br />
© 2005 by H. Muccini / ECI 2005 Course<br />
13
SEA Group<br />
40<br />
SEA Group<br />
41<br />
SEA Group<br />
42<br />
Spin use example (2/4)<br />
» For now, just accept the default settings that are shown, <strong>and</strong> press the<br />
Start button, to start a first simulation run.<br />
- A number of new windows appear.<br />
> The large panel to the right, labeledMessage Sequence Chart is empty at first, but<br />
it will display all messages sent <strong>and</strong> received during the simulation that we are<br />
about to start.<br />
> The lower panel, labeledVariable Values, will print the current values of all<br />
variables <strong>and</strong> channels that are used during the simulation run.<br />
> The main panel that appears is labeledSimulation Output. It allows you to<br />
perform either a single-step simulation, or a continuous r<strong>and</strong>om simulation run.<br />
Choose the latter, by pressing the Run button. Let the run proceed until<br />
completion. The main panel will show the raw printout from Spin (which is<br />
running in the background to perform the actual simulation), prefixed by a stepnumber<br />
in the left margin;<br />
» When the run completes, the main panel will print the number of<br />
processes that has been created;<br />
© 2005 by H. Muccini / ECI 2005 Course<br />
Spin use example (3/4)<br />
» Make the main Spin control window that displays the<br />
Promela text of the leader election protocol visible again;<br />
» Move the mouse cursor over the boxes <strong>and</strong> arrows in the<br />
Message Sequence Chart display on the right.<br />
- When the mouse cursor is over a square box in the message<br />
sequence chart, the corresponding Promela source line in the text<br />
window is indicated, <strong>and</strong> the source text is shown in the<br />
sequence chart.<br />
- The number that is shown in the square boxes if the mouse is not<br />
hovering over them is a simulation step number, that matches the<br />
numbers in the left margin of the Simulation Output panel.<br />
© 2005 by H. Muccini / ECI 2005 Course<br />
Spin use example (4/4)<br />
» Now let’s verify the system:<br />
» Add the buchiautomata source code at the bottom of the Promela<br />
Code; then select the Set Verification Parameters option from the<br />
Run.. menu. Accept the default settings of the parameters, or, click<br />
Advanced Option in order to allow Partial Order Reduction <strong>and</strong><br />
Compression, <strong>and</strong> press the Run button. Notice again the comm<strong>and</strong>s<br />
that Xspin synthesizes, printed in the log. At this time, Spin is asked<br />
to generate a verifier, the verifier is compiled <strong>and</strong> executed, <strong>and</strong> the<br />
results are fed back to Xspin for display.<br />
- If all is well, the results show that there are no errors detected in the<br />
specification.<br />
- If in the verification run, Spin detects that some statements are<br />
unreachable for the given parameters, those statements are highlighted<br />
in the main Xspin control window with the text of the specification;<br />
Wait for the simulation completed…. <strong>and</strong> look at the results!!!<br />
© 2005 by H. Muccini / ECI 2005 Course<br />
14
SEA Group<br />
43<br />
SEA Group<br />
44<br />
SEA Group<br />
45<br />
Example: SCOS-2000 TC Chain -<br />
with Terma GmbH<br />
PIF<br />
TCP/IP<br />
TCP/IP<br />
User<br />
MMI<br />
TC Chain<br />
TCP/I<br />
P<br />
NCTRS<br />
© 2005 by H. Muccini / ECI 2005 Course<br />
Example<br />
» Read the TermaSAXProject.pdf document:<br />
- It describes the SA.X project<br />
» Use the TermaBuffer060705.Charmy example to learn<br />
how Charmy<strong>and</strong> SPIN work<br />
- This specification is related to the TermaSAXProject.pdf<br />
document<br />
© 2005 by H. Muccini / ECI 2005 Course<br />
References: Charmy<br />
» [FIDJI02] P. Inverardi, F. Mancinelli, H. Muccini, <strong>and</strong> P. Pelliccione. An Experience in<br />
Architectural Extensions: Active Objects in J2EE. In Proc. Int. Workshop on Scientific<br />
Engineering of Distributed Java Applications (FIDJI'2002), November 2002, Luxembourg.<br />
Lecture Notes in Computer Science (LNCS) 2604, pp. 87 ff.<br />
» [FME03] D.Compare, P. Inverardi, P. Pelliccione <strong>and</strong> A. Sebastiani. Integrating model<strong>checking</strong><br />
architectural analysis <strong>and</strong> validation in a real software life-cycle. In Proc. FM 2003:<br />
the 12th International FME Symposium, September 2003, Pisa. LNCSseries.<br />
» [CharmyWeb] CHARMY Project. University of L’Aquila. CharmyWeb Site.<br />
http://www.di.univaq.it/charmy, 2005.<br />
» [CBSE05] Patrizio Pelliccione, Henry Muccini, Antonio Bucchiarone, <strong>and</strong> Fabrizio<br />
Facchini. TeStor: Deriving Test Sequences from <strong>Model</strong>-<strong>based</strong> Specifications“. Eighth<br />
International SIGSOFT Symposium on Component-<strong>based</strong> <strong>Software</strong> Engineering (CBSE<br />
2005), St. Louis, Missouri (USA), 15-21 May, 2005. Lecture Notes in Computer Science,<br />
LNCS 3489, pp. 267-282.<br />
» [ITM04] A Bucchiarone, H.Muccini, P.Pelliccione, <strong>and</strong> P.Pierini. <strong>Model</strong>-Checkingplus<br />
<strong>Testing</strong>: from<strong>Software</strong> <strong>Architecture</strong> Analysis toCode <strong>Testing</strong>. Proc. International <strong>Testing</strong><br />
Methodologyworksho, LNCS vol. 3236, pp. 351 -365 (2004), October<br />
» [Subm05] H.Muccini, P.Pelliccione, P.Pierini <strong>and</strong> A Bucchiarone, An <strong>Architecture</strong>-centric<br />
Approach for <strong>Model</strong>-<strong>checking</strong> <strong>based</strong> <strong>Testing</strong> in Industrial Contexts. Submitted, April 05<br />
© 2005 by H. Muccini / ECI 2005 Course<br />
15