fsm based testing · verona university 12 traditional fsm based testing for complete deterministic...

75
FSM BASED TESTING Nina Yevtushenko Tomsk State University, Russia April, 18, 2011

Upload: others

Post on 18-Aug-2020

11 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: FSM BASED TESTING · Verona University 12 Traditional FSM based testing for complete deterministic FSMs Fault model: < S, ≅, ℜ> • Sis an initialized complete deterministic

FSM BASED TESTING

Nina Yevtushenko

Tomsk State University, Russia

April, 18, 2011

Page 2: FSM BASED TESTING · Verona University 12 Traditional FSM based testing for complete deterministic FSMs Fault model: < S, ≅, ℜ> • Sis an initialized complete deterministic

Verona University 2

Outline

FSM based testing – what is it? Testing based on deterministic FSMs- white box testing approach- black box testing approach- grey box testing approach Testing against nondeterministic FSMs- Why do we need to perform nondeterministic FSM

based testing?- testing trace equivalence relation- testing reduction relation- testing separability relation- testing r-compatibility relation

Page 3: FSM BASED TESTING · Verona University 12 Traditional FSM based testing for complete deterministic FSMs Fault model: < S, ≅, ℜ> • Sis an initialized complete deterministic

Verona University 3

Active and Passive Testing

Active testing Passive testing

TESTER

IUT

PC PO

TESTER

IUT

PO

PO – points of observationPC – points of control

Page 4: FSM BASED TESTING · Verona University 12 Traditional FSM based testing for complete deterministic FSMs Fault model: < S, ≅, ℜ> • Sis an initialized complete deterministic

Verona University 4

Active and Passive testing (cont-d)

Active (off-line) testing

Test are generated and applied during the special mode at PCs

Passive (on-line) testing

No PCs, no special mode

an IUT is observed at POs and a conclusion is drawn based on these observations

Page 5: FSM BASED TESTING · Verona University 12 Traditional FSM based testing for complete deterministic FSMs Fault model: < S, ≅, ℜ> • Sis an initialized complete deterministic

Verona University 5

Model based conformance testing

Spec Imp

Tests Test execution

Does Imp conform to Spec?

Fault model

Page 6: FSM BASED TESTING · Verona University 12 Traditional FSM based testing for complete deterministic FSMs Fault model: < S, ≅, ℜ> • Sis an initialized complete deterministic

Verona University 6

Formal model

What is a test architecture?

What is the formal description of the specification and of an implementation?

What is the formal description of a fault?

What conformance relation is used for testing?

Page 7: FSM BASED TESTING · Verona University 12 Traditional FSM based testing for complete deterministic FSMs Fault model: < S, ≅, ℜ> • Sis an initialized complete deterministic

Verona University 7

Finite State Machines (FSM)

When an input is applied an FSM moves from state to state and produces an output

FSM maps input sequences into output sequences

FSM AInput

I

Output

O

s1 s3 …s2 sn

Initialized FSM is a 5-tuple (S, I, O, TS, s1)

Page 8: FSM BASED TESTING · Verona University 12 Traditional FSM based testing for complete deterministic FSMs Fault model: < S, ≅, ℜ> • Sis an initialized complete deterministic

Verona University 8

FSM based conformance testing

Behaviors of the specification and of an implementation are described by FSMs

Applying input sequences to an implementation and observing its output sequences one could be able

to conclude whether the implementation conformsto its specification

Spec Imp

I

O

I

O

Page 9: FSM BASED TESTING · Verona University 12 Traditional FSM based testing for complete deterministic FSMs Fault model: < S, ≅, ℜ> • Sis an initialized complete deterministic

Verona University 9

TRADITIONAL FAULT MODEL WHEN PERFORMING FSM BASED TESTING

< SSSS, ∼ ∼ ∼ ∼, FD >

Specification FSM

a conformancerelation

fault domainthe set of all possible implementation FSMs

! Each implementation FSM is complete! A fault is modeled by a faulty FSM

Page 10: FSM BASED TESTING · Verona University 12 Traditional FSM based testing for complete deterministic FSMs Fault model: < S, ≅, ℜ> • Sis an initialized complete deterministic

Verona University 10

Variety of FSM based fault models

Fault model: <Spec, ∼, FD>• Spec can be deterministic or nondeterministic, complete or partial• the conformance relation ∼ is

For deterministic FSMs ∼ is- equivalence (for complete FSMs)- quasi-equivalence (for partial FSMs)For nondeterministic FSMs- trace equivalence (for complete FSMs)- trace quasi-equivalence (for partial FSMs)- reduction (for complete FSMs)- quasi-reduction (for partial FSMs)- r-compatibility- non-separability• fault domain FD- FSMs of FD are explicitly enumerated- only the upper bound on the number of states of an implementation FSM is known- implementation FSM is a submachine of a given mutation FSM; usually this

machine is based on the specification and faulty implementations that should be detected by a derived test suite

Page 11: FSM BASED TESTING · Verona University 12 Traditional FSM based testing for complete deterministic FSMs Fault model: < S, ≅, ℜ> • Sis an initialized complete deterministic

Verona University 11

What faults can be detected when performing FSM based testing

Output fault: the output of a transition

is wrong

Transfer fault: the next state of a transition is wrong

Mixed faults (output and transfer faults can occur in an implementation under test)

Page 12: FSM BASED TESTING · Verona University 12 Traditional FSM based testing for complete deterministic FSMs Fault model: < S, ≅, ℜ> • Sis an initialized complete deterministic

Verona University 12

Traditional FSM based testing for complete deterministic FSMs

Fault model: <S, ≅, ℜ>

• S is an initialized complete deterministic FSM

• ≅ is the trace equivalence relation

• ℜ is the set of initialized implementation FSMs

- has a finite (not too big) list of faulty FSMs (white box testing)

- only the upper bound on the number of states of an implementation FSM is known (black box testing)

- implementation FSM is a submachine of some nondeterministic FSM (grey box testing)

Page 13: FSM BASED TESTING · Verona University 12 Traditional FSM based testing for complete deterministic FSMs Fault model: < S, ≅, ℜ> • Sis an initialized complete deterministic

Verona University 13

Test architecture

Test architecture

Test Generator

Imp

Spec

comparator

Page 14: FSM BASED TESTING · Verona University 12 Traditional FSM based testing for complete deterministic FSMs Fault model: < S, ≅, ℜ> • Sis an initialized complete deterministic

Verona University 14

Complete test suite

Fault domain ℜ is the set of FSMs that describe all possible faults (all possible implementations):

ℑ = Imp1, …, Impn, …A test suite TS is a finite set of finite input sequences of S

TS is complete w.r.t. <S, ≅, ℜ> if it detects each FSM Imp ∈ ℑthat is not trace equivalent to S

! If the fault domain is not limited then there is no complete test suite w.r.t. such fault domain

! A test suite is a set of test sequences (not a single input sequence), i.e., a reliable reset is assumed in the specification and in an implementation

Page 15: FSM BASED TESTING · Verona University 12 Traditional FSM based testing for complete deterministic FSMs Fault model: < S, ≅, ℜ> • Sis an initialized complete deterministic

Verona University 15

Trace equivalence relation

To be equivalent FSMs Impand Spec have to havethe same outputresponse to each input sequence

! The number of input sequences is infinite, while we can apply only finite number of input sequences when testing the conformance

Trace equivalent FSMs have the same sets of traces

Spec

I O

s1sn

Imp

I O

p1pm

Page 16: FSM BASED TESTING · Verona University 12 Traditional FSM based testing for complete deterministic FSMs Fault model: < S, ≅, ℜ> • Sis an initialized complete deterministic

Verona University 16

White box testing for complete deterministic FSMs

Where to apply- Software testing (mutant testing) Given software golden sample, extract a flow table (FSM S)Insert a fault and extract a flow table (FSM Imp)Determine sequence to distinguish S and Imp (if it exists)

- Testing logic networks (gate level)For each single stuck-at-fault that is hard to be detected, a

distinguishing sequence is derived by comparison of the specification network and a network with this stuck-at- fault

! More applications for other discrete event systems

Page 17: FSM BASED TESTING · Verona University 12 Traditional FSM based testing for complete deterministic FSMs Fault model: < S, ≅, ℜ> • Sis an initialized complete deterministic

Verona University 17

Explicit enumeration of mutants

- to explicitly enumerate all possible implementation

FSMs

- for each non-conforming Imp to determine a test case that detects Imp

- to collect all the sequences into a single test suite(minimize if possible)

! When testing logic networks the approach is applied only for single stuck-at- faults which are hard to be detected

! Moreover, a test suite can be derived simultaneouly for a set of single stuck-at-faults

Page 18: FSM BASED TESTING · Verona University 12 Traditional FSM based testing for complete deterministic FSMs Fault model: < S, ≅, ℜ> • Sis an initialized complete deterministic

Verona University 18

Explicit enumeration of mutants (cont-d)

Advantage: test suites are short enough and detect faults which can often occur

Disadvantage:

The number of mutants (faults) should be small enough

Possible solution: to derive a test suite without explicit mutant enumeration, i.e., a complete test suite is derived based on the specification and some knowledge of an implementations under test

Page 19: FSM BASED TESTING · Verona University 12 Traditional FSM based testing for complete deterministic FSMs Fault model: < S, ≅, ℜ> • Sis an initialized complete deterministic

Verona University 19

Specification coverage

Theorem. A test suite that traverseseach transition of the specification is complete w.r.t. output faults if the implementation has the same number of states as Spec

! How to check transition faults depends on the selected fault model

Page 20: FSM BASED TESTING · Verona University 12 Traditional FSM based testing for complete deterministic FSMs Fault model: < S, ≅, ℜ> • Sis an initialized complete deterministic

Verona University 20

Deriving tests for easily testable logic networks

If a combinational circuit is constructed in a special way in order to simplify the procedure of test derivation then a test suite that detects not only single stuck-at-faults but also multi stuck-at-faults can be derived based on a corresponding system of Boolean functions

Page 21: FSM BASED TESTING · Verona University 12 Traditional FSM based testing for complete deterministic FSMs Fault model: < S, ≅, ℜ> • Sis an initialized complete deterministic

Verona University 21

Testing FSM output and transition faults (black box testing)

Fault model: <S, ≅, Ωn> S is a reduced complete deterministic FSM with n states

Fault domain Ωn is the set of all complete deterministic FSMs with at most n states

Problem: It is impossible to explicitly enumerate all FSMs with two inputs, two outputs and ten states; the number of such FSMs is approximately 2020

Solution: to derive a complete test suite based on the specification FSM only

Page 22: FSM BASED TESTING · Verona University 12 Traditional FSM based testing for complete deterministic FSMs Fault model: < S, ≅, ℜ> • Sis an initialized complete deterministic

Verona University 22

Black box testing

The structure of an FSM under test is unknown

Only the upper bound on the number of states of an FSM under test is known

We cannot observe states of an FSM under test

What to do?

Page 23: FSM BASED TESTING · Verona University 12 Traditional FSM based testing for complete deterministic FSMs Fault model: < S, ≅, ℜ> • Sis an initialized complete deterministic

Verona University 23

Test suite derivation using only the specification FSM

Two states sj and sk of complete FSM S are trace equivalent if the FSM S has the same

output response at states sj and sk to each input sequence

Proposition. If a complete initialized FSM S is

reduced and connected then initialized connected FSM P is equivalent to S iff P is isomorphic to S

Page 24: FSM BASED TESTING · Verona University 12 Traditional FSM based testing for complete deterministic FSMs Fault model: < S, ≅, ℜ> • Sis an initialized complete deterministic

Verona University 24

Isomorphic FSMs

Two FSMs S and

P are isomorphic iff

There exists one-to-one h:P → S between states, h(p1) = s1 s.t. h is preserved for transitions

outP(p, i) = outS(h(p), i)

and

h(nsP(p, i)) = nsS(h(p), i)

S and implementation FSM P have the same

number of states

S

I O

s1sn

P

I O

p1pn

h : ↑↓ …………... ↑↓

Page 25: FSM BASED TESTING · Verona University 12 Traditional FSM based testing for complete deterministic FSMs Fault model: < S, ≅, ℜ> • Sis an initialized complete deterministic

Verona University 25

How to externally check if an implementation FSM is isomorphic to SSSS

We need:

• To insure that a given implementation P has n states (need to reach each state of P)

• To insure that for each transition of S

there exists a corresponding transition in the FSM P

Checking states and transitions of implementation FSM P

S

I O

s1sn

P

I O

p1pn

h : ↑↓ …………... ↑↓

Page 26: FSM BASED TESTING · Verona University 12 Traditional FSM based testing for complete deterministic FSMs Fault model: < S, ≅, ℜ> • Sis an initialized complete deterministic

Verona University 26

State cover set

For each initially connected FSM there always exists a state cover set SC of input sequences that reaches each state of S

Sequences of a state cover SC:α(s1) = εα(s2) = xα(s3) = z

s1 s2x/1

x/0, y/1

s3z/1y/0

y/0z/0

z/1x/1

! State cover SC always contains the empty sequence

Page 27: FSM BASED TESTING · Verona University 12 Traditional FSM based testing for complete deterministic FSMs Fault model: < S, ≅, ℜ> • Sis an initialized complete deterministic

Verona University 27

Distinguishing sequences

0001s4

0000s3

1011s2

0101s1

yyyxs1

s3

s2

s4

y/0

x/0x/1y/0

x/1

x/1

y/0

y/1

s1

s2

y/0

y/1

y distinguishes s1 and s2

Page 28: FSM BASED TESTING · Verona University 12 Traditional FSM based testing for complete deterministic FSMs Fault model: < S, ≅, ℜ> • Sis an initialized complete deterministic

Verona University 28

Distinguishability (characterization) set

For each complete reduced FSM there always exists a distinguishability (characterization) set W of input sequences that distinguishes every two different states

Distinguishing sequences:

γ(s1, s2) = xγ(s2, s3) = yγ(s1, s3) = z

! Distinguishability set W may not exist for a reduced partial FSM

s1 s2x/1

x/0, y/1

s3z/1y/0

y/0z/0

z/1x/1

Page 29: FSM BASED TESTING · Verona University 12 Traditional FSM based testing for complete deterministic FSMs Fault model: < S, ≅, ℜ> • Sis an initialized complete deterministic

Verona University 29

W-method (1)

1. For each two states sj and sk of the specification FSM S derive a distinguishing sequence γjk

Derive a distinguishability set W that has a distinguishing sequence for each pair of different states

2. For each state sj of the FSM S derive an input sequence that takes the FSM S from the initial state to state sj

Derive a state cover set SC that has a transfer sequence to each state of S

! The empty sequence is mandatory in SC

Page 30: FSM BASED TESTING · Verona University 12 Traditional FSM based testing for complete deterministic FSMs Fault model: < S, ≅, ℜ> • Sis an initialized complete deterministic

Verona University 30

W-method (2)

3. Concatenate the state cover set SC with the distinguishability set W: TS1 = SC.W

Proposition If an implementation FSM Ppasses TS1 then

- P has exactly n states

- SC is a state cover set of P

- there exists one-to-one mapping h: P → S

s. t. h(p) = s ⇔ p ≅W s

Page 31: FSM BASED TESTING · Verona University 12 Traditional FSM based testing for complete deterministic FSMs Fault model: < S, ≅, ℜ> • Sis an initialized complete deterministic

Verona University 31

W-method (3)

4. Concatenate the state cover set SC with the set iWfor each input i: TS2 = SC.I.W

Proposition If an implementation FSM P that passed TS1 passes also TS2 then one-to-one mapping h satisfies the property:

outP(p, i) = outS(h(p), i) andh(nsP(p, i)) = nsS(h(p), i)

Thus, if FSM P passes TS1 ∪TS2 then FSM P is isomorphic to S, and thus, P is trace equivalent to S

Page 32: FSM BASED TESTING · Verona University 12 Traditional FSM based testing for complete deterministic FSMs Fault model: < S, ≅, ℜ> • Sis an initialized complete deterministic

Verona University 32

W-method (4)

Test suite returned by W-method

All the sequences that are prefixes of other sequences can be deleted from a complete test suite without loss of its completeness

… State cover set SC

W

W

I/o

I/o

W

W

Page 33: FSM BASED TESTING · Verona University 12 Traditional FSM based testing for complete deterministic FSMs Fault model: < S, ≅, ℜ> • Sis an initialized complete deterministic

Verona University 33

W-method (5)

Theorem (Vasilevskiy, 1973) If a state cover SC is prefix closed and a distinguishability set W is suffix closed then the set

SC.I.Wis a complete test suite for the case when faults do not increase the number of states of the specification

!Reliable reset is assumed in the specification and implementation FSMs

Page 34: FSM BASED TESTING · Verona University 12 Traditional FSM based testing for complete deterministic FSMs Fault model: < S, ≅, ℜ> • Sis an initialized complete deterministic

Verona University 34

W-method when implementation FSM can have more states than the specification

Let the specification FSM S have n states and an implementation FSM P have at most m states, m > n

In order to completely test FSM P when the transition relation of Pis unknown we need:

to reach by test suite each state of P to check each transition of P

1. If SC is a state cover set of S ⇒ SC.Im-n is a state cover set for each implementation FSM with at most m states

2. If W is a distinguishability set of S then the set SC.Im-n.W ∪SC.Im-n+1.W is a complete test suite under the assumption that an implementation FSM has at most m states

Page 35: FSM BASED TESTING · Verona University 12 Traditional FSM based testing for complete deterministic FSMs Fault model: < S, ≅, ℜ> • Sis an initialized complete deterministic

Verona University 35

Experimental results (m = n)

1720410001010100

6773500101050

52033006650

3393300101030

25451806630

Average length

Trans. num.

Output num.

Input num.

State num.

Page 36: FSM BASED TESTING · Verona University 12 Traditional FSM based testing for complete deterministic FSMs Fault model: < S, ≅, ℜ> • Sis an initialized complete deterministic

Verona University 36

Complexity of W-based

methods

Theoretical complexity:

If m = n then TS = SC.I.W

TS length is O(kn3) where

k – number of inputs

n - number of states

If m > n then TS = SC.Im-n+1.W

TS length is O(km-n+1n3)

Page 37: FSM BASED TESTING · Verona University 12 Traditional FSM based testing for complete deterministic FSMs Fault model: < S, ≅, ℜ> • Sis an initialized complete deterministic

Verona University 37

Modifications of W-method

1. DS-method

2. UIO-method

3. Wp-method

4. UiOv-method

5. HSI-method

6. H-method

7. SPY method

Depending how a set of separating sequences is defined

! Theoretical complexity is the same

Experimental results can be found in:

R. Dorofeeva, K. El-Fakih, S. Maag, A. Cavalli, N. Yevtushenko. FSM-based conformance testing methods: A survey annotated with experimental evaluation // Information and Software Technology. – 2010. –V. 52. – 12. – PP. 1286 – 129

Page 38: FSM BASED TESTING · Verona University 12 Traditional FSM based testing for complete deterministic FSMs Fault model: < S, ≅, ℜ> • Sis an initialized complete deterministic

Verona University 38

Advantages and disadvantages of W-based methods

Advantage: Tests are derived based on the specification FSM and have high quality

Disadvantages: Test suites are very long Test derivation significantly depends on the integer m that sometimes is difficult to determine

S can be partial S can be non-deterministic

Page 39: FSM BASED TESTING · Verona University 12 Traditional FSM based testing for complete deterministic FSMs Fault model: < S, ≅, ℜ> • Sis an initialized complete deterministic

Verona University 39

Grey-box testing approach

The structure of an FSM under test is partially known

Where to apply

User-driven faults

Incremental testing

Page 40: FSM BASED TESTING · Verona University 12 Traditional FSM based testing for complete deterministic FSMs Fault model: < S, ≅, ℜ> • Sis an initialized complete deterministic

Verona University 40

Incremental testing or testing user-driven faults

The specification is modified incrementally

An implementation also is incrementally modified

S1 S2

S3 S4

y/1y/0

x/0

y/1 y/0

x/1 S1 S2

S3 S4

y/1y/0

x/0

y y/0

x/1

??

x/1x/1

yy/1

Only some transitions can be faulty

Page 41: FSM BASED TESTING · Verona University 12 Traditional FSM based testing for complete deterministic FSMs Fault model: < S, ≅, ℜ> • Sis an initialized complete deterministic

Verona University 41

Fault domain for grey-box testing

We assume

1. Each possible implementation is complete and deterministic

2. Each possible implementation FSM is a submachine of a nondeterministic FSM that is called a mutation FSM

Page 42: FSM BASED TESTING · Verona University 12 Traditional FSM based testing for complete deterministic FSMs Fault model: < S, ≅, ℜ> • Sis an initialized complete deterministic

Verona University 42

Straightforward solution for incremental testing

Straightforward solution for incremental testing:

To check only modified transitions using state identifiers

This is not enough

The reason is the correspondence between states of initial S and Imp is not

always preserved for modified S and Imp

Page 43: FSM BASED TESTING · Verona University 12 Traditional FSM based testing for complete deterministic FSMs Fault model: < S, ≅, ℜ> • Sis an initialized complete deterministic

Verona University 43

Experimental results

887636345893737540

1537101353914865881035

145095751813553331030

151399947714858182020

7854903379329921020

15-20%

suspicious transitions

10-

15% suspicious transitions

5-10% suspicious transitions

0-5% suspicious transitions

HSI length

is

Page 44: FSM BASED TESTING · Verona University 12 Traditional FSM based testing for complete deterministic FSMs Fault model: < S, ≅, ℜ> • Sis an initialized complete deterministic

Verona University 44

Nondeterministic FSM

Non-determinism

s0 s1

i/o1

>>>

s2

i/o2

Page 45: FSM BASED TESTING · Verona University 12 Traditional FSM based testing for complete deterministic FSMs Fault model: < S, ≅, ℜ> • Sis an initialized complete deterministic

Verona University 45

Testing nondeterministic FSMs

Nondeterministic behavior occurs in formal descriptions (formal models) according to

flexibility

performance

limited controllability and/or observability

abstraction level

???

Page 46: FSM BASED TESTING · Verona University 12 Traditional FSM based testing for complete deterministic FSMs Fault model: < S, ≅, ℜ> • Sis an initialized complete deterministic

Verona University 46

Complexity of test derivation when implementation FSMs are explicitly enumerated

Suppose that all possible implementation FSMs (faults) are explicitly enumerated

length of a distinguishing sequence w.r.t. trace equivalence is polynomial (in the number of states of FSMs to be compared)

length of a distinguishing sequence w.r.t. reduction is polynomial (in the number of states of FSMs to be compared)

complexity of a distinguishing sequence w.r.t. r-distinguishability is polynomial (in the number of states of FSMs to be compared)if adaptive test execution is used

length of a distinguishing sequence w.r.t. separability is exponential (in the number of states of FSMs to be compared)

! There exist test derivation methods w.r.t. a number of fault models without explicit enumeration

Page 47: FSM BASED TESTING · Verona University 12 Traditional FSM based testing for complete deterministic FSMs Fault model: < S, ≅, ℜ> • Sis an initialized complete deterministic

Verona University 47

‘All weather conditions’assumption

Assumptions:

- All FSMs are complete and initialized (a reliable reset is assumed in the specification and implementation FSMs)

- When testing a nondeterministic FSM w.r.t. trace equivalence and reduction relations we assume that ‘all weather conditions”assumption holds, i.e., an FSM under test (IUT) shows all possible output responses to each applied input sequence (test case)

Page 48: FSM BASED TESTING · Verona University 12 Traditional FSM based testing for complete deterministic FSMs Fault model: < S, ≅, ℜ> • Sis an initialized complete deterministic

Verona University 48

Testing nondeterministic FSMs

‘all weather conditions assumption ’

+ realistic+ each test case is applied only once- existing test derivation methods do not guarantee the fault coverage

+ there exist test suite derivation methods- sometimes this assumption is not realistic- each test case is applied several times

holds does not hold

Page 49: FSM BASED TESTING · Verona University 12 Traditional FSM based testing for complete deterministic FSMs Fault model: < S, ≅, ℜ> • Sis an initialized complete deterministic

Verona University 49

W-method for nondeterministic FSMs

Fault model: <S, ≅, Ωn> S is an initialized reduced complete nondeterministic observable

FSM with n statesFault domain Ωn is the set of all initialized complete

nondeterministic observable FSMs with at most n states

Assumptions:- The specification and each implementation FSM have a reliable

reset- ‘All weather conditions’ assumption holds, i.e., each input

sequence (test case) of a complete test suite is applied to an implementation under test several times

Page 50: FSM BASED TESTING · Verona University 12 Traditional FSM based testing for complete deterministic FSMs Fault model: < S, ≅, ℜ> • Sis an initialized complete deterministic

Verona University 50

W-method for nondeterministic FSMs (1)

1. For each two states sj and sk of the specification FSM S derive a distinguishing sequence γjk

Derive a distinguishability set W that has a distinguishing sequence for each pair of different states

2. For each state sj of the FSM S derive an input sequence that can take the FSM S from the initial state to state sj

Derive a state cover set SC that has such a sequence for each state of S

! The empty sequence is mandatory in SC! The same input sequence can take S to different states, i.e., SC

can be shorter than that for deterministic FSMs

Page 51: FSM BASED TESTING · Verona University 12 Traditional FSM based testing for complete deterministic FSMs Fault model: < S, ≅, ℜ> • Sis an initialized complete deterministic

Verona University 51

W-method (2)

3. Concatenate the state cover set SC with the distinguishability set W: TS1 = SC.W

4. Concatenate the state cover set SC with the set iW for each input i: TS2 = SC.I.W

Proposition. If an implementation FSM P passes TS1 ∪TS2 then there exists one-to-one mapping h: P → S s.t.

outP(p, i) = outS(h(p), i) andh(nsP(p, i)) = nsS(h(p), i)

Thus, if FSM P passes TS1 ∪TS2 then FSM P is isomorphic to S, and thus, is trace equivalent to S

Page 52: FSM BASED TESTING · Verona University 12 Traditional FSM based testing for complete deterministic FSMs Fault model: < S, ≅, ℜ> • Sis an initialized complete deterministic

Verona University 52

W-method (3)

Test suite returned by W-method

All the sequences that are prefixes of other sequences can be deleted from a complete test suite without loss of its completeness

… State cover set SC

W

W

I/o

I/o

W

W

Page 53: FSM BASED TESTING · Verona University 12 Traditional FSM based testing for complete deterministic FSMs Fault model: < S, ≅, ℜ> • Sis an initialized complete deterministic

Verona University 53

W-method when implementation FSM can have more states than the specification

Let the specification FSM S have n states and an implementation FSM P have at most m states, m > n

Complete TS is SC.Im-n+1.W

- SC – a state cover of S- W - a distinguishability set of S

The complexity is the same as for deterministic FSMsbut according to the ‘all weather assumption’ each input sequence is applied several number of times

Page 54: FSM BASED TESTING · Verona University 12 Traditional FSM based testing for complete deterministic FSMs Fault model: < S, ≅, ℜ> • Sis an initialized complete deterministic

Verona University 54

W-based test derivation methods for nondeterministic FSMs

W-method is modified to deal with partial FSMsAs in this case, a distinguishability set may not exist, such

methods rely on state identifiers Adaptive test execution, since some input can be defined

after one output and undefined after another output

There are attempts to modify W-method to deal with non-observable FSMs

! Applicable only to observable FSMs

Page 55: FSM BASED TESTING · Verona University 12 Traditional FSM based testing for complete deterministic FSMs Fault model: < S, ≅, ℜ> • Sis an initialized complete deterministic

Verona University 55

Modifications of W-method for nondeterministic FSMs

• HSI-method

• H-method

Depending on how a set of distinguishing sequences is derived

Page 56: FSM BASED TESTING · Verona University 12 Traditional FSM based testing for complete deterministic FSMs Fault model: < S, ≅, ℜ> • Sis an initialized complete deterministic

Verona University 56

Deriving tests w.r.t. the reduction relation

- For trace equivalence relation two initialized observable reduced FSMs are equivalent iff they are isomorphic, i.e., an implementation FSM has to have the same number of states as the specification FSM

- Two different states of the reduced specification FSM have to be implemented as different states of a conforming implementation FSM

- Each state of the reduced specification FSM has to be implemented in a conforming implementation

- For each complete initialized observable FSM there always exists a reduced complete initialized observable FSM

- For reduction relation a conforming implementation of initialized observable reduced FSM can have less states than FSM S

!Can be a submachine of S

- Two different states of FSM S can be implemented as a single state of a conforming implementation FSM that is a reduction of S

!If two states of S are r-distinguishable only then they have to be implemented as different states of each conforming implementation FSM that is a reduction of S

- Not each state of the reduced specification FSM has to be implemented in a conforming implementation that is a reduction of S

!Can be a submachine of S

- Given a complete initialized observable FSM, there not necessarily exists a trace equivalent complete initialized observable FSM where each two states are r-distinguishable

Page 57: FSM BASED TESTING · Verona University 12 Traditional FSM based testing for complete deterministic FSMs Fault model: < S, ≅, ℜ> • Sis an initialized complete deterministic

Verona University 57

Deriving tests w.r.t. the reduction relation (example)

FSM S

1 2

3

a/0,2

a/0

a,b/0,1

a/1b/0,1

b/0 b/2

x y

b/0

b/1

a/1a/1

FSM P is a reductionof S but state 2 of S does

not have a matching statein P

Page 58: FSM BASED TESTING · Verona University 12 Traditional FSM based testing for complete deterministic FSMs Fault model: < S, ≅, ℜ> • Sis an initialized complete deterministic

Verona University 58

Reduction properties

An input sequence α is a deterministic transfer (d-transfer) sequence to state s if for each possible output sequence β the trace α/β takes the FSM S from the initial state to state s

State s is a d-reachable state

Theorem 1. If state s is a d-reachable state of the specification FSM S then state s is implemented in any reduction P of S, i.e., the intersection S ∩ P has a state sp for some state p ∈ P

Theorem 2. If states s1 and s2 are r-distinguishable states of the specification FSM S then they can be distinguished by an r-distinguishing set R(s1, s2). Moreover, for any reduction P of S it holds that if the intersection S ∩ P has a state s1p (s2p ) for some state p ∈ P then the intersection S ∩ P has no state s2p(s1p )

Page 59: FSM BASED TESTING · Verona University 12 Traditional FSM based testing for complete deterministic FSMs Fault model: < S, ≅, ℜ> • Sis an initialized complete deterministic

Verona University 59

State counting method (SC-method)

Let R be a subset of pair-wise r-distinguishable states of FSM S and states of Rd ⊆ R are d-reachable

Let there be a path of a successor tree s.t. states of R occur (m - |Rd| + 1) times

Implementation FSM has at most m states and

|Rd| different states of the implementation FSM already correspond to d-reachable states of the FSM S

Thus, two cases are possible1) One and the same state p of the

implementation FSM P corresponds to two different states s1 and s2 of R (this can be detected by a corresponding r-distinguishing set R(s1, s2))

2) There are two states s1p in the path (i.e. the sequence that labels the path is not a shortest r-distinguishing sequence)

Termination rules for the successor tree of the intersection S ∩ P

d-reachablestates

States s1and s2 are r-distinguishable

s1p1

s1p

s1p

s1p

s2p

d-SC

R(s1, s2)

R(s1, s2)

Page 60: FSM BASED TESTING · Verona University 12 Traditional FSM based testing for complete deterministic FSMs Fault model: < S, ≅, ℜ> • Sis an initialized complete deterministic

Verona University 60

Example of deriving a complete test suite w.r.t. reduction relation

1 2

3

a/0,2

a/0

a,b/0,1

a/1b/0,1

b/0 b/2x y

b/0

b/1

a/1a/1

FSM S Implementation FSM Pthat is a reduction of S

Derive a complete TS w.r.t. the reduction relation when animplementation FSM has at most 2 states

Page 61: FSM BASED TESTING · Verona University 12 Traditional FSM based testing for complete deterministic FSMs Fault model: < S, ≅, ℜ> • Sis an initialized complete deterministic

Verona University 61

Example of deriving a complete test suite w.r.t. reduction relation (cont-d)

FSM S Truncated successor tree of S

1 2

3

a/0,2

a/0

a,b/0,1

a/1b/0,1

b/0 b/2

Each two states are r-compatible

States 1 and 3 are d-reachableAs m = 2, states 1 and 3 should occur twice through a path

State 2 should occur three times

a/0,1b/0,1

1

332

3

b/0,1a/0

a/1

3

3…

At the last step take the inputprojection

a/0,1b/0,1

a/0,1b/0,1

Page 62: FSM BASED TESTING · Verona University 12 Traditional FSM based testing for complete deterministic FSMs Fault model: < S, ≅, ℜ> • Sis an initialized complete deterministic

Verona University 62

Test derivation w.r.t. the reduction relation (references)

1. Petrenko, A., Yevtushenko, N., Bochmann, G. v.: Testing Deterministic Implementations from their Nondeterministic Specifications. In Proc. of the IFIP Ninth International Workshop on Testing of Communicating Systems, 1996, pp. 125--140

2. R. M. Hierons. Using Candidates to Test a Deterministic Implementation Against a Non-deterministic Finite State Machine, The Computer Journal, 2003, 46, 3, pp. 307-318

3. Petrenko, A., Yevtushenko, N.: Conformance Tests as Checking Experiments for Partial Nondeterministic FSM. In Proceedings of the 5th International Workshop on Formal Approaches to Testing of Software, LNCS vol. 3997, 2005, pp. 118—133

4. Petrenko, A., Yevtushenko, N.: Testing from Partial Deterministic FSM Specifications. IEEE Trans. Computers, 2005, 54(9), pp. 1154-1165

Page 63: FSM BASED TESTING · Verona University 12 Traditional FSM based testing for complete deterministic FSMs Fault model: < S, ≅, ℜ> • Sis an initialized complete deterministic

Verona University 63

If ‘all weather condition’assumption does not hold

A test suite with the guaranteed fault coverage can be derived w.r.t.

- non-separability relation

- r-compatibility relation

Page 64: FSM BASED TESTING · Verona University 12 Traditional FSM based testing for complete deterministic FSMs Fault model: < S, ≅, ℜ> • Sis an initialized complete deterministic

Verona University 64

Separability relation

FSMs P and S are separable

if

∀α∈I*(outP(t1,α) ∩ outS(s1,α) = ∅)

When we apply α we always know which FSM P or S is under test

Page 65: FSM BASED TESTING · Verona University 12 Traditional FSM based testing for complete deterministic FSMs Fault model: < S, ≅, ℜ> • Sis an initialized complete deterministic

Verona University 65

GENERALIZED FAULT MODEL

Solutionto generalize the fault model to

<S, (≤, ≄≄≄≄), FD>

Test suite TS is complete w.r.t. to <S, (≤, ≄≄≄≄), FD>

if each FSM PPPP ∈∈∈∈ FDsuch that PPPP ≄≄≄≄ SSSS can be detected with TS

Differences! Each test case is applied only once! Some implementations which are non-separable from S

also are detected

Page 66: FSM BASED TESTING · Verona University 12 Traditional FSM based testing for complete deterministic FSMs Fault model: < S, ≅, ℜ> • Sis an initialized complete deterministic

Verona University 66

EXPLICIT ENUMERATION

- Subnd(MM) – the set of all complete submachines of FSM MM- ℜm - the set of all initialized complete FSMs with at most m

states

Fault models <S, (≤, ≄), Subnd(MM)> and <S, (≤, ≄), ℜm>

have finite fault domains

⇓A test suite can be derived by explicit enumeration

Page 67: FSM BASED TESTING · Verona University 12 Traditional FSM based testing for complete deterministic FSMs Fault model: < S, ≅, ℜ> • Sis an initialized complete deterministic

Verona University 67

DERIVING A COMPLETE TEST SUITE W.R.T. <S, (≤≤≤≤, ≄≄≄≄), Subnd(MM)> and <S, (≤, ≄≄≄≄), ℜℜℜℜm>

A complete test suite w.r.t. <S, (≤, ≄), Subnd(MM)>is derived based on a truncated successor tree of the intersection S ∩ MM

A complete test suite w.r.t. <S, (≤, ≄), ℜm> is

derived based on a truncated successor tree of the specification S

Page 68: FSM BASED TESTING · Verona University 12 Traditional FSM based testing for complete deterministic FSMs Fault model: < S, ≅, ℜ> • Sis an initialized complete deterministic

Verona University 68

Testing w.r.t. the separabilityrelation

More results can be found in:1. Shabaldina, N., El-Fakih, K., Yevtushenko, N. Testing

Nondeterministic Finite State Machines with respect to the Separability Relation. In Proc. of the IFIP 19th International Conference on Testing of Communicating Systems and the 7th International Workshop on Formal Approaches to Testing of Software, 2007, Lecture Notes in Computer Science vol. 4581, pp. 305-318.

2. E. Akenshina, N. Shabaldina, N. Yevtushenko Deriving exhaustive test suites for nondeterministic FSMs w.r.t. non-separability relation // 2010 Third International Conference on Software Testing, Verification, and Validation Workshops, pp. 46– 53, CS Digital Library, 2010, ISBN 978 – 0 – 7695 – 4050 – 4, http://doi.ieeecomputersociety.org/10.1109/ICSTW.2010.29

Page 69: FSM BASED TESTING · Verona University 12 Traditional FSM based testing for complete deterministic FSMs Fault model: < S, ≅, ℜ> • Sis an initialized complete deterministic

Verona University 69

Experimental results when deriving a complete test suite w.r.t.

separability relation

FSM S is a complete nondeterministic FSM with 5 states

For 20% of pairs (s, i) there is more than one outgoing transition from state s under input i

Each FSM MM is derived by adding up to 25% transitions to S

682643

1540733

243222

Average test suite length

|O||I|

Page 70: FSM BASED TESTING · Verona University 12 Traditional FSM based testing for complete deterministic FSMs Fault model: < S, ≅, ℜ> • Sis an initialized complete deterministic

Verona University 70

Deriving adaptive test suites w.r.t. r-compatibility relation

Most such tests are only partially adaptive

For deriving adaptive tests we have got only preliminary results

- Testing deterministic implementations against a nondeterministic observable specification FSM

- Explicit enumeration when testing w.r.t. r-compatibility relation

Page 71: FSM BASED TESTING · Verona University 12 Traditional FSM based testing for complete deterministic FSMs Fault model: < S, ≅, ℜ> • Sis an initialized complete deterministic

Verona University 71

Conclusions (1)

FSM based testing is widely used for testing discrete event systems

Advantage: FSM is a unique model for which there exist test generation methods for black box testing without explicit mutant enumeration

Disadvantage: Tests are too longSolutions: - usually are shortened losing the completeness- test purposes are used instead of the fault coverage- to use passive testing

Page 72: FSM BASED TESTING · Verona University 12 Traditional FSM based testing for complete deterministic FSMs Fault model: < S, ≅, ℜ> • Sis an initialized complete deterministic

Verona University 72

Conclusions (cont-d)

Testing based on nondeterministic FSMs is a challenging problem

Not too much is known how to derive complete tests for nondeterministic FSMs

Adaptive testing needs more research

! There are other formal models and methods how to derive high-quality tests based on these models

! There are other test architectures which were not considered in this lecture

Page 73: FSM BASED TESTING · Verona University 12 Traditional FSM based testing for complete deterministic FSMs Fault model: < S, ≅, ℜ> • Sis an initialized complete deterministic

Verona University 73

References

FSM based testing

1. Bochmann, G., and Petrenko, A. Protocol testing: review of methods and relevance for software testing. Proc. International Symposium on Software Testing and Analysis, Seattle, 1994, pp. 109--123

2. Chow, T.S. Test design modeled by finite-state machines. IEEE Transactions on Software Engineering, 1978,4(3), pp. 178--187

3. R. Dorofeeva, K. El-Fakih, S. Maag, A. Cavalli, N. Yevtushenko FSM-based conformance testing methods: A survey annotated with experimental evaluation // Information and Software Technology. 2010, V. 52, 12, pp. 1286 – 1298

4. El-Fakih, K., Yevtushenko, N., Bochmann, G. v. FSM-based incremental conformance testing methods. IEEE Transactions on Software Engineering. 2004, 30(7), pp. 425-436.

5. Fujiwara, S. Bochmann, G.v., Khendek, F., Amalou, M., and Ghedamsi, A. Test selection based on finite state models. IEEE Transactions on Software Engineering. 1991, 17(6), pp. 591--603.

6. Kohavi, Z. Switching and Finite Automata Theory. New York, McGraw- Hill, 1978, 658 p7. Lai, R. A survey of communication protocol testing. The Journal of Systems and Software. 2002, 62, pp. 21--

468. Lee D. and Yannakakis, M. Principles and methods of testing finite state machines-a survey. Proceedings of

the IEEE, 1996, 84(8), pp. 1090--11239. Lee D. and Yannakakis, M. Testing finite state machines: state identification and verification. IEEE

Transactions on Computers, 1994, 43(3), pp. 306-32010. Petrenko, A., Yevtushenko, N.: Testing from Partial Deterministic FSM Specifications. IEEE Trans.

Computers. 2005, 54(9), pp. 1154-1165.11. Vasilevskii, M. P. Failure diagnosis of automata. 1973, translated from Kibernetika, 4, pp. 98--108.12. Yannakakis M., Lee, D. Testing finite state machines: fault detection. Journal of Computer and System

Sciences. 1995, 50, pp. 209-227.

Page 74: FSM BASED TESTING · Verona University 12 Traditional FSM based testing for complete deterministic FSMs Fault model: < S, ≅, ℜ> • Sis an initialized complete deterministic

Verona University 74

References (cont-d)

Testing non-deterministic FSMs1. H. AboElFotoh, O. Abou-Rabia, and H. Ural. A Test Generation Algorithm for Protocols

Modeled as Non-Deterministic FSMs. The Software Eng. Journal, 1993, 8(4), pp.184-1882. R. Alur, C. Courcoubetis, and M. Yannakakis. Distinguishing Tests for Nondeterministic and

Probabilistic Machines. 27th ACM Symp. on Theory of Comp., 1995, pp. 363-3723. R. M. Hierons. Adaptive Testing of a Deterministic Implementation against a Nondeterministic

Finite State Machine. The Computer Journal, 1998, 41(5), pp. 349-3554. R. M. Hierons, Testing from a Non-Deterministic Finite State Machine Using Adaptive State

Counting, IEEE Transactions on Computers, 2004, 53, 10, pp. 1330-13425. R. M. Hierons. Using Candidates to Test a Deterministic Implementation Against a Non-

deterministic Finite State Machine, The Computer Journal, 2003, 46, 3, pp. 307-3186. G. L. Luo, G. v. Bochmann, and A. Petrenko. Test Selection Based on Communicating

Nondeterministic Finite-State Machines Using a Generalized Wp-method. IEEE Transactions on Software Engineering, 1994, 20(2), pp. 149–161

7. L. Nachmanson, M. Veanes, W. Schulte, N Tillmann, W. Grieskamp, Optimal Strategies for Testing Nondeterministic Systems, Software Engineering Notes ACM, 29, pp. 55–64

8. Spitsyna, N., El-Fakih, K., Yevtushenko, N.: Studying the Separability Relation between Finite State Machines. Software Testing, Verification and Reliability, 2007, 17(4), 227—241

Page 75: FSM BASED TESTING · Verona University 12 Traditional FSM based testing for complete deterministic FSMs Fault model: < S, ≅, ℜ> • Sis an initialized complete deterministic

Verona University 75

Thanks for your attention!