73
1 Test des Automates Temporisés Stavros Tripakis Laboratoire Verimag Master 2 Recherche S&L « Méthodes de test »

Test des Automates Temporisés

  • Upload
    paiva

  • View
    26

  • Download
    0

Embed Size (px)

DESCRIPTION

Master 2 Recherche S&L « Méthodes de test ». Test des Automates Temporisés. Stavros Tripakis Laboratoire Verimag. Modèles, modèles, …. Les machines de Mealy Entr é es/sorties synchrones Bonnes pour circuits/programmes synchrones Les systèmes de transitions étiquetés - PowerPoint PPT Presentation

Citation preview

Page 1: Test des Automates Temporisés

1

Test des Automates Temporisés

Stavros Tripakis

Laboratoire Verimag

Master 2 Recherche S&L« Méthodes de test »

Page 2: Test des Automates Temporisés

2

Modèles, modèles, …

• Les machines de Mealy– Entrées/sorties synchrones– Bonnes pour circuits/programmes synchrones

• Les systèmes de transitions étiquetés– Bons pour systèmes asynchrones (ex. protocoles de

communication)– Aspects temps-réel pas bien modélisés

• Les automates temporisés

Page 3: Test des Automates Temporisés

3

Exemple

s1

s2

A? B!

Spécification:pour chaque entrée A,

retourner un B

s1

s2

A?

Implémentation(candidate)

conforme ?

Page 4: Test des Automates Temporisés

4

Exemple

s1

s2

A? B!

Spécification:pour chaque entrée A,

retourner un B

s1

s2

A?

Implémentation(candidate)

Comment capter la non-conformité ?

Page 5: Test des Automates Temporisés

5

Real-time testing

SUT

Tester

outputs

Verdicts(pass/fail)

inputs

Page 6: Test des Automates Temporisés

6

Exemple

s1

s2

A? B!

Spécification:pour chaque entrée A,

retourner un B

s1

s2

A?

Implémentation(candidate)

Comment trouver la valeur « timeout »

lors du test ?

Page 7: Test des Automates Temporisés

7

Plan of talk• Specification model

• Conformance relation

• Analog & digital tests

• Test generation

• Tool and case studies

Page 8: Test des Automates Temporisés

8

Plan of talk• Specification model: timed automata with inputs,

outputs and unobservable actions.

• Conformance relation

• Analog & digital tests

• Test generation

• Tool and case studies

Page 9: Test des Automates Temporisés

9

Simple example 1

a?x:=0 x 4

b!

“Output b at most 4 time units after receiving input a.”

Page 10: Test des Automates Temporisés

10

Simple example 2

a?x:=0 x 4

b!

“Output b at most 4 time units after receiving input a,except if you fail, in which case output a failure notice

at most after 8 time units.”

Unobservable action

x 8fail!

Page 11: Test des Automates Temporisés

11

Compositional specifications

Compositional specificationswith internal (unobservable) actions.

A B

C

Page 12: Test des Automates Temporisés

12

Compositional specifications

internal (unobservable) actions.

Page 13: Test des Automates Temporisés

13

Modeling assumptions on the environment

env spec

Export (make observable) interactionsbetween the specification and its environment.

Page 14: Test des Automates Temporisés

14

Simple example 3

a!y 10

“Output b at most 4 time units after receiving input a,provided a is received no later than 10 time units.”

A compositional modeling of the same example.

y:=0

a?x:=0 x 4

b!

a? b!

Page 15: Test des Automates Temporisés

15

Simple example 3

a?x 10 x 4

b!

“Output b at most 4 time units after receiving input a,provided a is received no later than 10 time units.”

Constraints on the inputs model assumptions.

x:=0x:=0

Constraints on the outputs model requirements.

Specification is not always input-complete.

Page 16: Test des Automates Temporisés

16

Conclusion: a rich TA model• Time non-determinism:

– Cannot impose exact input or output times.

• Action non-determinism:– Model failures, abstract details.

• Partial observability:– Internal actions of compositional specifications.

• Not input-complete:– Model assumptions on the environment.

Page 17: Test des Automates Temporisés

17

Plan of talk• Specification model

• Conformance relation: an extension of the “untimed” relation “ioco”.

• Analog & digital tests

• Test generation

• Tool and case studies

Page 18: Test des Automates Temporisés

18

Conformance relation• A timed extension of Tretmans’ “ioco”:

timed input-output conformance relation (tioco).

• Informally, A tioco B if– For any observable behavior p of B, any possible

observable output of A after p (including a delay) is also a possible observable output of B after p.

• To put it otherwise:– Implementation accepts more inputs and produces fewer

outputs than specification.

Page 19: Test des Automates Temporisés

19

Conformance relation• Formally:

A tioco B (A: implementation, B:specification)iff

Traces(B). out(A after ) out(B after )

Page 20: Test des Automates Temporisés

20

Conformance relation• where:

A after = {s | Seq. s0 s proj(,Obs)=}

out(S) = delays(S) outputs(S)

Page 21: Test des Automates Temporisés

21

Conformance relation• where:

outputs(S) = {aOutputs | sS . s }a

delays(S) ={tR | sS. UnobsSeq. time() = t s }

Page 22: Test des Automates Temporisés

22

Examples“Output b at most 4 time units after receiving input a.”

a?x:=0 x 4

b!Spec:

Page 23: Test des Automates Temporisés

23

Examples“Output b at most 4 time units after receiving input a.”

a?x:=0 x 4

b!Spec:

a?x:=0 x = 4

b!Impl 1:

Page 24: Test des Automates Temporisés

24

Examples“Output b at most 4 time units after receiving input a.”

a?x:=0 x 4

b!Spec:

a?x:=0 x = 4

b!Impl 1: OK!

Page 25: Test des Automates Temporisés

25

Examples“Output b at most 4 time units after receiving input a.”

a?x:=0 x 4

b!Spec:

a?x:=0 x = 4

b!Impl 1:

a?x:=0 x 2

b!Impl 2:

OK!

Page 26: Test des Automates Temporisés

26

Examples“Output b at most 4 time units after receiving input a.”

a?x:=0 x 4

b!Spec:

a?x:=0 x = 4

b!Impl 1:

a?x:=0 x 2

b!Impl 2:

OK!

OK!

Page 27: Test des Automates Temporisés

27

Examples“Output b at most 4 time units after receiving input a.”

a?x:=0 x 4

b!Spec:

a?x:=0 x = 5

b!Impl 3:

Page 28: Test des Automates Temporisés

28

Examples“Output b at most 4 time units after receiving input a.”

a?x:=0 x 4

b!Spec:

a?x:=0 x = 5

b!Impl 3: NOT OK!

Page 29: Test des Automates Temporisés

29

Examples“Output b at most 4 time units after receiving input a.”

a?x:=0 x 4

b!Spec:

a?x:=0 x = 5

b!Impl 3:

a?Impl 4:

NOT OK!

Page 30: Test des Automates Temporisés

30

Examples“Output b at most 4 time units after receiving input a.”

a?x:=0 x 4

b!Spec:

a?x:=0 x = 5

b!Impl 3:

a?Impl 4:

NOT OK!

NOT OK!

Page 31: Test des Automates Temporisés

31

Plan of talk• Specification model

• Conformance relation

• Analog & digital-clock tests

• Test generation

• Tool and case studies

Page 32: Test des Automates Temporisés

32

Real-time testing

SUT

Tester

outputs

Verdicts(pass/fail)

inputs

How accurate is this clock ?

Page 33: Test des Automates Temporisés

33

Example“Output b exactly 4 time units after receiving input a.”

a?x:=0 x = 4

b!Spec:

a?x:=0 x = 4

b!Impl 1:

a?x:=0 x = 3.99

b!Impl 2:

OK!

NOT OK!

Page 34: Test des Automates Temporisés

34

Timed tests• Two types of tests:• Analog-clock tests:

– Can measure real-time precisely– Difficult (impossible) to implement for real-time SUTs– Good (flexible) for discrete-time SUTs with unknown

time step

• Digital-clock tests:– Can count “ticks” of a periodic clock/counter– Implementable for any SUT– Conservative (may say PASS when it’s FAIL)

Page 35: Test des Automates Temporisés

35

Timed tests• Analog-clock tests:

– They can observe real-time precisely, e.g.:

• Digital-clock (or periodic-sampling) tests: – They only have access to a periodic clock, e.g.:

ba

1.3 2.4 2.7

c

time

ba c

time1 2 3

Page 36: Test des Automates Temporisés

36

Note

• Digital-clock tests does not mean we discretize time:– The specification is still dense-time– The capabilities of the observer are discrete-time )– Many dense-time traces will look the same to the digital

observer

Page 37: Test des Automates Temporisés

37

Untimed tests• Can be represented as finite trees (“strategies”):

i

o1 o2 o3 o4

faili1 i2 i3

……

failpass

Page 38: Test des Automates Temporisés

38

Digital-clock tests• Can also be represented as finite trees:

i

o1 o2 o3 o4 tick

fail …i1 i2 i3

……

failpass

Models the tick ofthe tester’s clock

Page 39: Test des Automates Temporisés

39

Analog-clock tests• Cannot be represented as finite trees:

i

o1 o2 o3 o4 0.1

faili1 i2 i3

……

failpass

0.11 0.2…

Infinite number ofpossible delays

Page 40: Test des Automates Temporisés

40

Analog-clock tests• Solution: build the test on-the-fly

1.3

i

time0 1.3

a

i

a

b

2.1

0.8

b

Page 41: Test des Automates Temporisés

41

Test generation• Analog-clock tests:

– Cannot be represented statically as finite trees: infinite number of possible inputs delays

– Solution: on-the-fly testing: compute the test while you are testing !

• Digital-clock tests:– Can be generated both statically and on-the-fly.

• In both cases: symbolic test generation

Page 42: Test des Automates Temporisés

42

Test generation principle

• The tester is a state-estimator: it keeps a set of possible states of the SUT,

according to the specification.

• Updates this set with each new observation.

• Gives inputs to SUT from time to time.

• Announces FAIL if ever set becomes empty.

• Announces PASS when tired of testing …

Page 43: Test des Automates Temporisés

43

Test generation principle

currentestimate

observation

(event or delay)

nextestimate

runs matchingobservation

Page 44: Test des Automates Temporisés

44

Test generation principle

• Sets of states are represented symbolically (standard timed automata technology, DBMs, etc.)

• Updates amount to performing some type of symbolic reachability.

• Can be used for on-the-fly testing (both for analog and digital) or static test generation (for digital only).

Page 45: Test des Automates Temporisés

45

Update operators for analog tests• Given current state estimation S …

• Given observed event a (input or output):

dsucc(S, a) : all states that can be reached froma state in S after performing a transition a.

dsucc(S, a) = {s’ | sS. s s’}a

Page 46: Test des Automates Temporisés

46

Update operators for analog tests• Given current state estimation S …

• Given time delay t:

tsucc(S, t) : all states that can be reached froma state in S after performing a run of

unobservable actions of total duration t.

tsucc(S, t) ={s’ | sS. UnobsSeq. s s’ time()=t}

Page 47: Test des Automates Temporisés

47

Putting it all together

i

1.3a

a

1

0.3

S

S’ = dsucc(tsucc(S,1.3), a)

Page 48: Test des Automates Temporisés

48

Update operator for digital tests• First, a trick:

• tick is an observable event:– Models the ticks of the observer’s clock.– Can also model skew, etc, using different

“Tick” automata.

originalspecificationautomaton

“Tick”tick!z = 1z:= 0

Page 49: Test des Automates Temporisés

49

Update operator for digital tests

• Given S and observed event a (could be tick):

succ(S, a) ={s’ | sS. UnobsSeq. s s’}a

succ(S, a) = all states that can be reached froma state in S after performing a run of

unobservable actions that ends with a.

Page 50: Test des Automates Temporisés

50

Updates for digital tests

i

tick

a

S

S’’ = succ(S’, a)

S’ = succ(S, tick)

Page 51: Test des Automates Temporisés

51

Problèmes d’efficacité ?

Page 52: Test des Automates Temporisés

52

Issue 1: cost of on-the-fly testing

i

time0

i

1.3

1.3

a

aSuccessor node:computed withreachability.

Can be problematic

Page 53: Test des Automates Temporisés

53

Issue 2: number of static tests

Which input ?

EXPLOSION: exponential number of tests

Wait or give input ?

Stop the testor continue ?

i

o1 o2 o3 o4 tick

fail …i1 i2 i3

… …failpass

Page 54: Test des Automates Temporisés

54

Improvements• Cost of on-the-fly testing:

– Represent analog testers as (deterministic) timed automata.

– Cost of testing = cost of computing successor state in the tester automaton.

• Number of static tests:– Coverage criteria.– Only generate relevant tests.

Page 55: Test des Automates Temporisés

55

Analog-clock tests• Cannot be represented as finite trees:

i

o1 o2 o3 o4 0.1

faili1 i2 i3

……

failpass

0.11 0.2…

Infinite number ofpossible delays

Page 56: Test des Automates Temporisés

56

Analog-clock tests with intervals• Can be represented as finite trees:

i

o1 o2 o3 o4 [0,1)

faili1 i2 i3

……

failpass

[1,2] (2,)

Page 57: Test des Automates Temporisés

57

This is a timed automaton!• Can be represented as finite trees:

i

o1 o2 o3 o4 x<1

faili1 i2 i3

……

failpass

1x2 x>2

x:=0

Page 58: Test des Automates Temporisés

58

• Generation of timed automata testers

• Generation of timed automata monitors– Monitors = simple testers = no inputs– (see paper for extension to testers)

Page 59: Test des Automates Temporisés

59

Real-time testing & monitoring

SUT

Tester

outputs

Verdicts(pass/fail)

inputs

SUT

MonitorVerdicts

(pass/fail)

Environment

Page 60: Test des Automates Temporisés

60

Timed-automata monitors• Specification: timed automaton A, with observable (o)

and unobservable (-o) actions.

• Monitor: deterministic, input-complete TA M over o.

• Plan A: monitor should accept exactly the behaviors which could be produced by spec:

• Impossible in general: TA not determizable.• Undecidable to check whether possible.

L(M) = (L(A))

Page 61: Test des Automates Temporisés

61

Timed-automata monitors• Specification: timed automaton A, with observable (o)

and unobservable (-o) actions.

• Monitor: deterministic, input-complete TA M over o.

• Plan B: monitor should be conservative

• but also as precise as possible.• Precision depends on monitor resources:

– More clocks, better monitoring.

– Larger guard constants, better monitoring.

L(M) ¶ (L(A))

Page 62: Test des Automates Temporisés

62

Timed-automata monitors• Specification: timed automaton A, with observable (o) and

unobservable (-o) actions.• Monitor: deterministic, input-complete TA M over o.

• Plan C: monitor should be conservative

• given– number of monitor clocks,– maximal guard constant,– reset skeleton

L(M) ¶ (L(A))

tells when to resetmonitor clocks, e.g.:

a? x:=0

y:=0a?

Page 63: Test des Automates Temporisés

63

Monitor synthesis• Based on symbolic reachability of the product

P = Spec || Reset-skeleton

Location of M=

Set of states of Pa? for each observable,

synthesize:1 2

n guards

… successorlocations

Goal: reduce monitor uncertainty

Page 64: Test des Automates Temporisés

64

Guard synthesis• Knowledge inference:

– Infer what you know on A’s guards based on relations of clocks of A and M.

x (clock of A)

y (clock of M)x,y) = relation of x,yin source location

c1yc2 ) ? y<c1 y>c2 c1yc2

2(x) 1(x)

y<c1 ) :1

y>c2 ) :2

Page 65: Test des Automates Temporisés

65

Monitor synthesis• Based on symbolic reachability of the product

P = Spec || Reset-skeleton

Location of M=

Set of states of Pa? for each observable,

synthesize:1 2

n guards

… successorlocations

• successor locations: symbolic reachability• termination: max constants for A,M clocks

Page 66: Test des Automates Temporisés

66

Coverage• Completeness impossible:

– # of SUT states unknown or too large.

• Coverage principle:– Generate tests that “cover” all “interesting”

parts of the specification.– Cover = visit.– Interesting:

• User-defined regions of state-space, or

• Standard: locations, edges, states, etc.

Page 67: Test des Automates Temporisés

67

Coverage principle

State spaceof specification

Test generation

Page 68: Test des Automates Temporisés

68

Coverage principle

State spaceof specification

a!

tick?

b?

1. Find a path reaching the unconvered region

covered

Page 69: Test des Automates Temporisés

69

Coverage principle

State spaceof specification

a!

tick?

b?

b?

2. Complete it into avalid test tree

c?

c?

tick? covered

Page 70: Test des Automates Temporisés

70

The benefits of coverage• Simple example: a lighting device

– 2 automata,– 2 clocks,– 27 locations– 1 input, 3 outputs

• Exhaustive test generation:– >2000 tests for depth=8

• Location (or edge, or state) coverage:– <10 tests of depth <20

Page 71: Test des Automates Temporisés

71

Tool• TTG: implemented on top of IF tool-suite

http://www-verimag.imag.fr/~async/IF/

• Current version:– Dynamic tester and monitor generation– Static test generation up to given depth:

• Interactive• Random• Exhaustive

• Under construction:– Timed automata tester generation– Coverage

Page 72: Test des Automates Temporisés

72

Page 73: Test des Automates Temporisés

73

Lecture

• Papiers sur le test temporisé disponibles en ligne:

http://www-verimag.imag.fr/~tripakis/testing.html