S. Hallé, R. Khoury
Sylvain Hallé and Raphaël Khoury
Université du Québec à Chicoutimi
CANADA
Test Sequence Generation with
Cayley Graphs
CRSNG
NSERC
17th Workshop on Advances in Model Based Testing (A-MOST), April 12th, 2021
S. Hallé, R. Khoury
Model-based testing for reactive systems
S. Hallé, R. Khoury
system
Model-based testing for reactive systems
S. Hallé, R. Khoury
system
Model-based testing for reactive systems
reactive
receives inputs ("actions")
accepts or rejects inputs
stateful
S. Hallé, R. Khoury
system
Model-based testing for reactive systems
reactive
receives inputs ("actions")
accepts or rejects inputs
stateful
specification
S. Hallé, R. Khoury
system
Model-based testing for reactive systems
reactive
receives inputs ("actions")
accepts or rejects inputs
stateful
state-based
incomplete
formal specification
S. Hallé, R. Khoury
Model-based testing for reactive systems
, ,
, ✓
test
S. Hallé, R. Khoury
Model-based testing for reactive systems
, ,
, ✓
test sequence
finite
associated outcome
S. Hallé, R. Khoury
Model-based testing for reactive systems
, ,
, ✓
test sequence
finite
associated outcome
test
generation
S. Hallé, R. Khoury
Model-based testing for reactive systems
, ,
, ✓
test sequence
finite
associated outcome
test
generation
model-based
sequence
S. Hallé, R. Khoury
Formal model
Let...
Q be a set of observable states
A be a set of actions
S. Hallé, R. Khoury
Formal model
Let...
Q be a set of observable states
A be a set of actions
1
3
4
2
A reactive specification is a Moore machine
S. Hallé, R. Khoury
Formal model
Let...
Q be a set of observable states
A be a set of actions
1
3
4
2
A reactive specification is a Moore machine
a
b
b
b
c
d
with
input alphabet A
S. Hallé, R. Khoury
Formal model
Let...
Q be a set of observable states
A be a set of actions
1
3
4
2
A reactive specification is a Moore machine
a
b
b
b
c
d
with
input alphabet A
?
⊤
⊤
⊤
and output alphabet {⊤, ⊥, ?}
S. Hallé, R. Khoury
Goal: find sequences that "exercise" the
specification in various ways
Intuition
S. Hallé, R. Khoury
Goal: find sequences that "exercise" the
specification in various ways
Intuition
Never press right after
S. Hallé, R. Khoury
Goal: find sequences that "exercise" the
specification in various ways
Intuition
Never press right after
If you press or , then next
S. Hallé, R. Khoury
= coverage
Goal: find sequences that "exercise" the
specification in various ways
Intuition
Never press right after
If you press or , then next
S. Hallé, R. Khoury
FSM-based coverage criteria
1
3
4
2
a
b
b
b
c
d
?
⊤
⊤
⊤
What does "covering the spec" mean? Is it...
visiting each state?
executing each action?
taking each transition?
ending in each state?
...or in each transition?
visiting each triplet of states?
a, db
ab, dc
ab, dc, dbb
a, ab, d, dc
a, ab, d, dc, db, dbb
aba, abcd, dbbd,
dbba
. . . . . . . . .
. . . . . .
. . . . . .
. . . . . . .
. . . . .
S. Hallé, R. Khoury
FSM-based coverage criteria
1
3
4
2
a
b
b
b
c
d
?
⊤
⊤
⊤
What does "covering the spec" mean? Is it...
visiting each state?
executing each action?
taking each transition?
ending in each state?
...or in each transition?
visiting each triplet of states?
a, db
ab, dc
ab, dc, dbb
a, ab, d, dc
a, ab, d, dc, db, dbb
aba, abcd, dbbd,
dbba
. . . . . . . . .
. . . . . .
. . . . . .
. . . . . . .
. . . . .
One distinct algorithm
for each criterion
S. Hallé, R. Khoury
Contribution
We propose a theoretical framework where:
each coverage criterion becomes a particular
case of a general definition
a test suite achieving full coverage can be
generated by the same algorithm for all criteria
Key concepts:
triaging function
Cayley graph
S. Hallé, R. Khoury
Triaging function
Given a specification M, a test is a sequence:
q0 q1 qn
a0
...
a1 an−1
i.e. a finite word over Σ ⊆ (Q × A × Q)*.
S. Hallé, R. Khoury
Triaging function
Given a specification M, a test is a sequence:
q0 q1 qn
a0
...
a1 an−1
i.e. a finite word over Σ ⊆ (Q × A × Q)*. A triaging
function is any surjective function
κ : Σ → C
"categories"
S. Hallé, R. Khoury
A triaging function κ induces an equivalence
relation ~ over test sequences
Σ
Triaging function
S. Hallé, R. Khoury
Triaging function
A triaging function κ induces an equivalence
relation ~ over test sequences
σ ~ σ' iff κ(σ) = κ(σ')
Σ
S. Hallé, R. Khoury
A triaging function κ induces an equivalence
relation ~ over test sequences
A test suite covers
a triaging function
if it contains one
sequence in each
category.
σ ~ σ' iff κ(σ) = κ(σ')
Σ
Triaging function
S. Hallé, R. Khoury
Coverage ratio
A numerical value can be associated to a set of test
sequences ΣT ⊆ Σ:
ρ(ΣT) =
{κ(σ)}
∪
σ∈ΣT
C
S. Hallé, R. Khoury
Coverage ratio
A numerical value can be associated to a set of test
sequences ΣT ⊆ Σ:
ρ(ΣT) =
{κ(σ)}
∪
σ∈ΣT
C
categories
covered
all categories
S. Hallé, R. Khoury
Examples
Different coverage criteria correspond to different
definitions of κ.
κ( ) = ...
q0 q1 qn
a0
...
a1 an−1
S. Hallé, R. Khoury
Examples
Different coverage criteria correspond to different
definitions of κ.
κ( ) = ...
q0 q1 qn
a0
...
a1 an−1
qn
S. Hallé, R. Khoury
Examples
Different coverage criteria correspond to different
definitions of κ.
κ( ) = ...
q0 q1 qn
a0
...
a1 an−1
qn state residual coverage
S. Hallé, R. Khoury
Examples
Different coverage criteria correspond to different
definitions of κ.
κ( ) = ...
q0 q1 qn
a0
...
a1 an−1
qn
an−1
state residual coverage
action residual coverage
S. Hallé, R. Khoury
Examples
Different coverage criteria correspond to different
definitions of κ.
κ( ) = ...
q0 q1 qn
a0
...
a1 an−1
qn
an−1
qn−1 qn
state residual coverage
action residual coverage
transition residual coverage
an−1
S. Hallé, R. Khoury
Examples
Different coverage criteria correspond to different
definitions of κ.
κ( ) = ...
q0 q1 qn
a0
...
a1 an−1
qn
an−1
qn−1 qn
n
state residual coverage
action residual coverage
transition residual coverage
length coverage
an−1
S. Hallé, R. Khoury
Prefix closure
We may also want to consider as "covered"
categories generated by all prefixes of a sequence.
The prefix closure of κ is the function ∫κ defined as:
∫κ(σ) = {κ(σ')}
∪
σ' σ
Output values of a prefix closure are called families
(i.e. sets of categories).
S. Hallé, R. Khoury
Examples (prefix closure)
Taking the prefix closure of the functions defined
earlier produce other coverage criteria.
κ( ) = ...
q0 q1 qn
a0
...
a1 an−1
qn
an−1
qn−1 qn
state residual coverage
action residual coverage
transition residual coverage
an−1
S. Hallé, R. Khoury
Examples (prefix closure)
Taking the prefix closure of the functions defined
earlier produce other coverage criteria.
κ( ) = ...
q0 q1 qn
a0
...
a1 an−1
{q0, ..., qn}
{a0, ..., an−1}
{q0 q1, ...,
qn−1 qn
state residual coverage
action residual coverage
transition residual coverage
an−1
∫
}
a0
...and a few others (see the paper)
S. Hallé, R. Khoury
Test sequence generation
Problem
Solution
Given a triaging function κ over an alphabet
A, generate a set of sequences that
completely covers κ
1. Generate the Cayley graph of κ
2. Pick important vertices of the graph
3. Compute the corresponding Steiner tree
S. Hallé, R. Khoury
Step 1: Cayley graph
Given a triaging function κ : Σ → C, a Cayley graph
is a Moore machine Gκ such that...
Σ is the input alphabet
C is the output alphabet
for every sequence σ,
the output of Gκ is κ(σ)
In other words, Gκ "encodes" the triaging function.
S. Hallé, R. Khoury
Step 1: Cayley graph
Given a triaging function κ : Σ → C, a Cayley graph
is a Moore machine Gκ such that...
Σ is the input alphabet
C is the output alphabet
for every sequence σ,
the output of Gκ is κ(σ)
In other words, Gκ "encodes" the triaging function.
1
3
4
2
a
b
b
b
c
d
?
⊤
⊤
⊤
# d
d
b
a
b
c
b
a
b
a
d
d
c
a
1
3
a
b
4
b
b
2
c
d
state
residual
action
residual
b
S. Hallé, R. Khoury
Step 1: Cayley graph
Given a triaging function κ : Σ → C, a Cayley graph
is a Moore machine Gκ such that...
Σ is the input alphabet
C is the output alphabet
for every sequence σ,
the output of Gκ is κ(σ)
In other words, Gκ "encodes" the triaging function.
1
3
4
2
a
b
b
b
c
d
?
⊤
⊤
⊤
# d
d
b
a
b
c
b
a
b
a
d
d
c
a
1
3
a
b
4
b
b
2
c
d
state
residual
action
residual
b
1
#
1
d c a b
S. Hallé, R. Khoury
Step 1: Cayley graph
Given a triaging function κ : Σ → C, a Cayley graph
is a Moore machine Gκ such that...
Σ is the input alphabet
C is the output alphabet
for every sequence σ,
the output of Gκ is κ(σ)
In other words, Gκ "encodes" the triaging function.
1
3
4
2
a
b
b
b
c
d
?
⊤
⊤
⊤
# d
d
b
a
b
c
b
a
b
a
d
d
c
a
1
3
a
b
4
b
b
2
c
d
state
residual
action
residual
b
2
d
d
d
2
d
d c a b
S. Hallé, R. Khoury
Step 1: Cayley graph
Given a triaging function κ : Σ → C, a Cayley graph
is a Moore machine Gκ such that...
Σ is the input alphabet
C is the output alphabet
for every sequence σ,
the output of Gκ is κ(σ)
In other words, Gκ "encodes" the triaging function.
1
3
4
2
a
b
b
b
c
d
?
⊤
⊤
⊤
# d
d
b
a
b
c
b
a
b
a
d
d
c
a
1
3
a
b
4
b
b
2
c
d
state
residual
action
residual
b
1
c
c
c
1
c
d c a b
S. Hallé, R. Khoury
Step 1: Cayley graph
Given a triaging function κ : Σ → C, a Cayley graph
is a Moore machine Gκ such that...
Σ is the input alphabet
C is the output alphabet
for every sequence σ,
the output of Gκ is κ(σ)
In other words, Gκ "encodes" the triaging function.
1
3
4
2
a
b
b
b
c
d
?
⊤
⊤
⊤
# d
d
b
a
b
c
b
a
b
a
d
d
c
a
1
3
a
b
4
b
b
2
c
d
state
residual
action
residual
b
3
a
a
a
3
a
d c a b
S. Hallé, R. Khoury
Step 1: Cayley graph
Given a triaging function κ : Σ → C, a Cayley graph
is a Moore machine Gκ such that...
Σ is the input alphabet
C is the output alphabet
for every sequence σ,
the output of Gκ is κ(σ)
In other words, Gκ "encodes" the triaging function.
1
3
4
2
a
b
b
b
c
d
?
⊤
⊤
⊤
# d
d
b
a
b
c
b
a
b
a
d
d
c
a
1
3
a
b
4
b
b
2
c
d
state
residual
action
residual
b
1
b
b
b
1
b
d c a b
S. Hallé, R. Khoury
Step 1: Cayley graph
For a given κ and alphabet A, Gκ can be generated
by an exploratory algorithm. States are triplets of
the form (c,q,a).
S. Hallé, R. Khoury
Step 1: Cayley graph
For a given κ and alphabet A, Gκ can be generated
by an exploratory algorithm. States are triplets of
the form (c,q,a).
For each state (c,q,a)...
S. Hallé, R. Khoury
Step 1: Cayley graph
For a given κ and alphabet A, Gκ can be generated
by an exploratory algorithm. States are triplets of
the form (c,q,a).
For each state (c,q,a)...
category
sequence
state of M
S. Hallé, R. Khoury
Step 1: Cayley graph
For a given κ and alphabet A, Gκ can be generated
by an exploratory algorithm. States are triplets of
the form (c,q,a).
For each state (c,q,a)...
For each a ∈ A...
category
sequence
state of M
S. Hallé, R. Khoury
Step 1: Cayley graph
For a given κ and alphabet A, Gκ can be generated
by an exploratory algorithm. States are triplets of
the form (c,q,a).
For each state (c,q,a)...
For each a ∈ A...
q' = δ(q,a)
c' = κ(a a)
// Next state in M
// Category of a a
category
sequence
state of M
S. Hallé, R. Khoury
Step 1: Cayley graph
For a given κ and alphabet A, Gκ can be generated
by an exploratory algorithm. States are triplets of
the form (c,q,a).
For each state (c,q,a)...
For each a ∈ A...
q' = δ(q,a)
c' = κ(a a)
If a state (c',q',a') already exists
Link (c,q,a) (c',q',a')
a
// Next state in M
// Category of a a
category
sequence
state of M
S. Hallé, R. Khoury
Step 1: Cayley graph
For a given κ and alphabet A, Gκ can be generated
by an exploratory algorithm. States are triplets of
the form (c,q,a).
For each state (c,q,a)...
For each a ∈ A...
q' = δ(q,a)
c' = κ(a a)
If a state (c',q',a') already exists
Link (c,q,a) (c',q',a')
a
// Next state in M
// Category of a a
category
sequence
state of M
S. Hallé, R. Khoury
Step 1: Cayley graph
For a given κ and alphabet A, Gκ can be generated
by an exploratory algorithm. States are triplets of
the form (c,q,a).
For each state (c,q,a)...
For each a ∈ A...
q' = δ(q,a)
c' = κ(a a)
If a state (c',q',a') already exists
Link (c,q,a) (c',q',a')
Else
Create state (c',q',a a)
Link (c,q,a) (c',q',a a)
a
a
// Next state in M
// Category of a a
category
sequence
state of M
S. Hallé, R. Khoury
1
3
4
2
a
b
b
b
c
d
?
⊤
⊤
⊤
Example
S. Hallé, R. Khoury
1
3
4
2
a
b
b
b
c
d
?
⊤
⊤
⊤
Example
κ(ε) = #
S. Hallé, R. Khoury
1
3
4
2
a
b
b
b
c
d
?
⊤
⊤
⊤
Example
κ(ε) = #
# 1 ε
S. Hallé, R. Khoury
1
3
4
2
a
b
b
b
c
d
?
⊤
⊤
⊤
Example
# 1 ε
S. Hallé, R. Khoury
1
3
4
2
a
b
b
b
c
d
?
⊤
⊤
⊤
Example
κ(a) = a
δ(1,a) = 3
# 1 ε
S. Hallé, R. Khoury
1
3
4
2
a
b
b
b
c
d
?
⊤
⊤
⊤
Example
a
a 3 a
κ(a) = a
δ(1,a) = 3
# 1 ε
S. Hallé, R. Khoury
1
3
4
2
a
b
b
b
c
d
?
⊤
⊤
⊤
Example
a
a 3 a
# 1 ε
S. Hallé, R. Khoury
1
3
4
2
a
b
b
b
c
d
?
⊤
⊤
⊤
Example
a
a 3 a
κ(d) = d
δ(1,d) = 2
# 1 ε
S. Hallé, R. Khoury
1
3
4
2
a
b
b
b
c
d
?
⊤
⊤
⊤
Example
d
d 2 d
a
a 3 a
κ(d) = d
δ(1,d) = 2
# 1 ε
S. Hallé, R. Khoury
1
3
4
2
a
b
b
b
c
d
?
⊤
⊤
⊤
Example
d
d 2 d
a
a 3 a
# 1 ε
S. Hallé, R. Khoury
1
3
4
2
a
b
b
b
c
d
?
⊤
⊤
⊤
Example
d
d 2 d
a
a 3 a
κ(ab) = b
δ(3,b) = 1
# 1 ε
S. Hallé, R. Khoury
1
3
4
2
a
b
b
b
c
d
?
⊤
⊤
⊤
Example
d
d 2 d
b
b 1 ab
a
a 3 a
κ(ab) = b
δ(3,b) = 1
# 1 ε
S. Hallé, R. Khoury
1
3
4
2
a
b
b
b
c
d
?
⊤
⊤
⊤
Example
d
d 2 d
b
b 1 ab
a
a 3 a
# 1 ε
S. Hallé, R. Khoury
1
3
4
2
a
b
b
b
c
d
?
⊤
⊤
⊤
Example
d
d 2 d
b
b 1 ab
a
a 3 a
κ(dc) = c
δ(2,c) = 1
# 1 ε
S. Hallé, R. Khoury
1
3
4
2
a
b
b
b
c
d
?
⊤
⊤
⊤
Example
c
c 1 dc
d
d 2 d
b
b 1 ab
a
a 3 a
κ(dc) = c
δ(2,c) = 1
# 1 ε
S. Hallé, R. Khoury
1
3
4
2
a
b
b
b
c
d
?
⊤
⊤
⊤
Example
c
c 1 dc
d
d 2 d
b
b 1 ab
a
a 3 a
# 1 ε
S. Hallé, R. Khoury
1
3
4
2
a
b
b
b
c
d
?
⊤
⊤
⊤
Example
c
c 1 dc
d
d 2 d
b
b 1 ab
a
a 3 a
κ(dcd) = d
δ(1,d) = 2
# 1 ε
S. Hallé, R. Khoury
1
3
4
2
a
b
b
b
c
d
?
⊤
⊤
⊤
Example
c
c 1 dc
d
d 2 d
b
b 1 ab
a
a 3 a
κ(dcd) = d
δ(1,d) = 2
# 1 ε
S. Hallé, R. Khoury
1
3
4
2
a
b
b
b
c
d
?
⊤
⊤
⊤
Example
d
c
c 1 dc
d
d 2 d
b
b 1 ab
a
a 3 a
κ(dcd) = d
δ(1,d) = 2
# 1 ε
S. Hallé, R. Khoury
1
3
4
2
a
b
b
b
c
d
?
⊤
⊤
⊤
Example
a
b
d
b
a
b 4 db
d
c
c 1 dc
d
d 2 d
b
b 1 ab
a
a 3 a
# 1 ε
S. Hallé, R. Khoury
1
3
4
2
a
b
b
b
c
d
?
⊤
⊤
⊤
Example
a
b
d
b
a
b 4 db
d
c
c 1 dc
d
d 2 d
b
b 1 ab
a
a 3 a
# 1 ε
S. Hallé, R. Khoury
Step 2: picking vertices of Gκ
# d
d
b
a
b
c
b
a
b
a
d
d
c
a
1
3
a
b
4
b
b
2
c
d
state
residual
action
residual
b
The resulting graph can contain multiple states
with the same label. Pick a set VI of important
vertices that contains each label once.
S. Hallé, R. Khoury
Step 2: picking vertices of Gκ
# d
d
b
a
b
c
b
a
b
a
d
d
c
a
1
3
a
b
4
b
b
2
c
d
state
residual
action
residual
b
The resulting graph can contain multiple states
with the same label. Pick a set VI of important
vertices that contains each label once.
How to select "best" set is left open...
S. Hallé, R. Khoury
Step 3: find a Steiner tree
# d
d
b
a
b
c
b
a
b
a
d
d
c
a
1
3
a
b
4
b
b
2
c
d
state
residual
action
residual
b
A (minimal) Steiner tree is a subgraph of Gκ that
includes all the VI.
S. Hallé, R. Khoury
Step 3: find a Steiner tree
# d
d
a
b
c
c
a
1
3
a
4
b
2
d
state
residual
action
residual
A (minimal) Steiner tree is a subgraph of Gκ that
includes all the VI.
b
S. Hallé, R. Khoury
Step 3: find a Steiner tree
# d
d
a
b
c
c
a
1
3
a
4
b
2
d
state
residual
action
residual
A (minimal) Steiner tree is a subgraph of Gκ that
includes all the VI.
b
Use the tree to generate paths that end in each
element of VI.
d, db, a d, dc, db, a
S. Hallé, R. Khoury
Dealing with transitive closure
Given a triaging function κ, the previous
construction guarantees full coverage for both κ
and ∫κ.
⇒ optimal if the labeling of Gκ is injective
S. Hallé, R. Khoury
Dealing with transitive closure
Given a triaging function κ, the previous
construction guarantees full coverage for both κ
and ∫κ.
⇒ optimal if the labeling of Gκ is injective
We can do better for ∫κ!
Post-processing step: elimiate sequences
that provide no new coverage
state
residual
action
residual
d, db, a d, dc, db, a
S. Hallé, R. Khoury
Implementation and experiments
Technique concretely implemented as an extension
of SealTest
Compared to GraphWalker and original SealTest
Sample of 33 reactive specifications
44 variants of coverage criteria
S. Hallé, R. Khoury
Implementation and experiments
Technique concretely implemented as an extension
of SealTest
Compared to GraphWalker and original SealTest
Sample of 33 reactive specifications
44 variants of coverage criteria
GW and ST fail to achieve full coverage
in 23% and 38% of problem instances
Cayley generates tests suites that are about
4× smaller than both tools
But test suites contain about 2× more
sequences
Results:
S. Hallé, R. Khoury
Key result
Generating a (minimal) test suite for
a coverage criterion
Finding a (minimal) coverage on
its Cayley graph
=
S. Hallé, R. Khoury
Take-home points
Multiple coverage criteria handled in a uniform
formal framework
What other criteria can be modeled in this way?
The algorithm for generating Gκ is (probably)
optimal*
The procedure to generate a test suite from Gκ is
definitely not
Results apply to all coverage criteria at once
S. Hallé, R. Khoury
Take-home points
Multiple coverage criteria handled in a uniform
formal framework
What other criteria can be modeled in this way?
The algorithm for generating Gκ is (probably)
optimal*
The procedure to generate a test suite from Gκ is
definitely not
Results apply to all coverage criteria at once
Thank you!

Test Sequence Generation with Cayley Graphs (Talk @ A-MOST 2021)

  • 1.
    S. Hallé, R.Khoury Sylvain Hallé and Raphaël Khoury Université du Québec à Chicoutimi CANADA Test Sequence Generation with Cayley Graphs CRSNG NSERC 17th Workshop on Advances in Model Based Testing (A-MOST), April 12th, 2021
  • 2.
    S. Hallé, R.Khoury Model-based testing for reactive systems
  • 3.
    S. Hallé, R.Khoury system Model-based testing for reactive systems
  • 4.
    S. Hallé, R.Khoury system Model-based testing for reactive systems reactive receives inputs ("actions") accepts or rejects inputs stateful
  • 5.
    S. Hallé, R.Khoury system Model-based testing for reactive systems reactive receives inputs ("actions") accepts or rejects inputs stateful specification
  • 6.
    S. Hallé, R.Khoury system Model-based testing for reactive systems reactive receives inputs ("actions") accepts or rejects inputs stateful state-based incomplete formal specification
  • 7.
    S. Hallé, R.Khoury Model-based testing for reactive systems , , , ✓ test
  • 8.
    S. Hallé, R.Khoury Model-based testing for reactive systems , , , ✓ test sequence finite associated outcome
  • 9.
    S. Hallé, R.Khoury Model-based testing for reactive systems , , , ✓ test sequence finite associated outcome test generation
  • 10.
    S. Hallé, R.Khoury Model-based testing for reactive systems , , , ✓ test sequence finite associated outcome test generation model-based sequence
  • 11.
    S. Hallé, R.Khoury Formal model Let... Q be a set of observable states A be a set of actions
  • 12.
    S. Hallé, R.Khoury Formal model Let... Q be a set of observable states A be a set of actions 1 3 4 2 A reactive specification is a Moore machine
  • 13.
    S. Hallé, R.Khoury Formal model Let... Q be a set of observable states A be a set of actions 1 3 4 2 A reactive specification is a Moore machine a b b b c d with input alphabet A
  • 14.
    S. Hallé, R.Khoury Formal model Let... Q be a set of observable states A be a set of actions 1 3 4 2 A reactive specification is a Moore machine a b b b c d with input alphabet A ? ⊤ ⊤ ⊤ and output alphabet {⊤, ⊥, ?}
  • 15.
    S. Hallé, R.Khoury Goal: find sequences that "exercise" the specification in various ways Intuition
  • 16.
    S. Hallé, R.Khoury Goal: find sequences that "exercise" the specification in various ways Intuition Never press right after
  • 17.
    S. Hallé, R.Khoury Goal: find sequences that "exercise" the specification in various ways Intuition Never press right after If you press or , then next
  • 18.
    S. Hallé, R.Khoury = coverage Goal: find sequences that "exercise" the specification in various ways Intuition Never press right after If you press or , then next
  • 19.
    S. Hallé, R.Khoury FSM-based coverage criteria 1 3 4 2 a b b b c d ? ⊤ ⊤ ⊤ What does "covering the spec" mean? Is it... visiting each state? executing each action? taking each transition? ending in each state? ...or in each transition? visiting each triplet of states? a, db ab, dc ab, dc, dbb a, ab, d, dc a, ab, d, dc, db, dbb aba, abcd, dbbd, dbba . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
  • 20.
    S. Hallé, R.Khoury FSM-based coverage criteria 1 3 4 2 a b b b c d ? ⊤ ⊤ ⊤ What does "covering the spec" mean? Is it... visiting each state? executing each action? taking each transition? ending in each state? ...or in each transition? visiting each triplet of states? a, db ab, dc ab, dc, dbb a, ab, d, dc a, ab, d, dc, db, dbb aba, abcd, dbbd, dbba . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . One distinct algorithm for each criterion
  • 21.
    S. Hallé, R.Khoury Contribution We propose a theoretical framework where: each coverage criterion becomes a particular case of a general definition a test suite achieving full coverage can be generated by the same algorithm for all criteria Key concepts: triaging function Cayley graph
  • 22.
    S. Hallé, R.Khoury Triaging function Given a specification M, a test is a sequence: q0 q1 qn a0 ... a1 an−1 i.e. a finite word over Σ ⊆ (Q × A × Q)*.
  • 23.
    S. Hallé, R.Khoury Triaging function Given a specification M, a test is a sequence: q0 q1 qn a0 ... a1 an−1 i.e. a finite word over Σ ⊆ (Q × A × Q)*. A triaging function is any surjective function κ : Σ → C "categories"
  • 24.
    S. Hallé, R.Khoury A triaging function κ induces an equivalence relation ~ over test sequences Σ Triaging function
  • 25.
    S. Hallé, R.Khoury Triaging function A triaging function κ induces an equivalence relation ~ over test sequences σ ~ σ' iff κ(σ) = κ(σ') Σ
  • 26.
    S. Hallé, R.Khoury A triaging function κ induces an equivalence relation ~ over test sequences A test suite covers a triaging function if it contains one sequence in each category. σ ~ σ' iff κ(σ) = κ(σ') Σ Triaging function
  • 27.
    S. Hallé, R.Khoury Coverage ratio A numerical value can be associated to a set of test sequences ΣT ⊆ Σ: ρ(ΣT) = {κ(σ)} ∪ σ∈ΣT C
  • 28.
    S. Hallé, R.Khoury Coverage ratio A numerical value can be associated to a set of test sequences ΣT ⊆ Σ: ρ(ΣT) = {κ(σ)} ∪ σ∈ΣT C categories covered all categories
  • 29.
    S. Hallé, R.Khoury Examples Different coverage criteria correspond to different definitions of κ. κ( ) = ... q0 q1 qn a0 ... a1 an−1
  • 30.
    S. Hallé, R.Khoury Examples Different coverage criteria correspond to different definitions of κ. κ( ) = ... q0 q1 qn a0 ... a1 an−1 qn
  • 31.
    S. Hallé, R.Khoury Examples Different coverage criteria correspond to different definitions of κ. κ( ) = ... q0 q1 qn a0 ... a1 an−1 qn state residual coverage
  • 32.
    S. Hallé, R.Khoury Examples Different coverage criteria correspond to different definitions of κ. κ( ) = ... q0 q1 qn a0 ... a1 an−1 qn an−1 state residual coverage action residual coverage
  • 33.
    S. Hallé, R.Khoury Examples Different coverage criteria correspond to different definitions of κ. κ( ) = ... q0 q1 qn a0 ... a1 an−1 qn an−1 qn−1 qn state residual coverage action residual coverage transition residual coverage an−1
  • 34.
    S. Hallé, R.Khoury Examples Different coverage criteria correspond to different definitions of κ. κ( ) = ... q0 q1 qn a0 ... a1 an−1 qn an−1 qn−1 qn n state residual coverage action residual coverage transition residual coverage length coverage an−1
  • 35.
    S. Hallé, R.Khoury Prefix closure We may also want to consider as "covered" categories generated by all prefixes of a sequence. The prefix closure of κ is the function ∫κ defined as: ∫κ(σ) = {κ(σ')} ∪ σ' σ Output values of a prefix closure are called families (i.e. sets of categories).
  • 36.
    S. Hallé, R.Khoury Examples (prefix closure) Taking the prefix closure of the functions defined earlier produce other coverage criteria. κ( ) = ... q0 q1 qn a0 ... a1 an−1 qn an−1 qn−1 qn state residual coverage action residual coverage transition residual coverage an−1
  • 37.
    S. Hallé, R.Khoury Examples (prefix closure) Taking the prefix closure of the functions defined earlier produce other coverage criteria. κ( ) = ... q0 q1 qn a0 ... a1 an−1 {q0, ..., qn} {a0, ..., an−1} {q0 q1, ..., qn−1 qn state residual coverage action residual coverage transition residual coverage an−1 ∫ } a0 ...and a few others (see the paper)
  • 38.
    S. Hallé, R.Khoury Test sequence generation Problem Solution Given a triaging function κ over an alphabet A, generate a set of sequences that completely covers κ 1. Generate the Cayley graph of κ 2. Pick important vertices of the graph 3. Compute the corresponding Steiner tree
  • 39.
    S. Hallé, R.Khoury Step 1: Cayley graph Given a triaging function κ : Σ → C, a Cayley graph is a Moore machine Gκ such that... Σ is the input alphabet C is the output alphabet for every sequence σ, the output of Gκ is κ(σ) In other words, Gκ "encodes" the triaging function.
  • 40.
    S. Hallé, R.Khoury Step 1: Cayley graph Given a triaging function κ : Σ → C, a Cayley graph is a Moore machine Gκ such that... Σ is the input alphabet C is the output alphabet for every sequence σ, the output of Gκ is κ(σ) In other words, Gκ "encodes" the triaging function. 1 3 4 2 a b b b c d ? ⊤ ⊤ ⊤ # d d b a b c b a b a d d c a 1 3 a b 4 b b 2 c d state residual action residual b
  • 41.
    S. Hallé, R.Khoury Step 1: Cayley graph Given a triaging function κ : Σ → C, a Cayley graph is a Moore machine Gκ such that... Σ is the input alphabet C is the output alphabet for every sequence σ, the output of Gκ is κ(σ) In other words, Gκ "encodes" the triaging function. 1 3 4 2 a b b b c d ? ⊤ ⊤ ⊤ # d d b a b c b a b a d d c a 1 3 a b 4 b b 2 c d state residual action residual b 1 # 1 d c a b
  • 42.
    S. Hallé, R.Khoury Step 1: Cayley graph Given a triaging function κ : Σ → C, a Cayley graph is a Moore machine Gκ such that... Σ is the input alphabet C is the output alphabet for every sequence σ, the output of Gκ is κ(σ) In other words, Gκ "encodes" the triaging function. 1 3 4 2 a b b b c d ? ⊤ ⊤ ⊤ # d d b a b c b a b a d d c a 1 3 a b 4 b b 2 c d state residual action residual b 2 d d d 2 d d c a b
  • 43.
    S. Hallé, R.Khoury Step 1: Cayley graph Given a triaging function κ : Σ → C, a Cayley graph is a Moore machine Gκ such that... Σ is the input alphabet C is the output alphabet for every sequence σ, the output of Gκ is κ(σ) In other words, Gκ "encodes" the triaging function. 1 3 4 2 a b b b c d ? ⊤ ⊤ ⊤ # d d b a b c b a b a d d c a 1 3 a b 4 b b 2 c d state residual action residual b 1 c c c 1 c d c a b
  • 44.
    S. Hallé, R.Khoury Step 1: Cayley graph Given a triaging function κ : Σ → C, a Cayley graph is a Moore machine Gκ such that... Σ is the input alphabet C is the output alphabet for every sequence σ, the output of Gκ is κ(σ) In other words, Gκ "encodes" the triaging function. 1 3 4 2 a b b b c d ? ⊤ ⊤ ⊤ # d d b a b c b a b a d d c a 1 3 a b 4 b b 2 c d state residual action residual b 3 a a a 3 a d c a b
  • 45.
    S. Hallé, R.Khoury Step 1: Cayley graph Given a triaging function κ : Σ → C, a Cayley graph is a Moore machine Gκ such that... Σ is the input alphabet C is the output alphabet for every sequence σ, the output of Gκ is κ(σ) In other words, Gκ "encodes" the triaging function. 1 3 4 2 a b b b c d ? ⊤ ⊤ ⊤ # d d b a b c b a b a d d c a 1 3 a b 4 b b 2 c d state residual action residual b 1 b b b 1 b d c a b
  • 46.
    S. Hallé, R.Khoury Step 1: Cayley graph For a given κ and alphabet A, Gκ can be generated by an exploratory algorithm. States are triplets of the form (c,q,a).
  • 47.
    S. Hallé, R.Khoury Step 1: Cayley graph For a given κ and alphabet A, Gκ can be generated by an exploratory algorithm. States are triplets of the form (c,q,a). For each state (c,q,a)...
  • 48.
    S. Hallé, R.Khoury Step 1: Cayley graph For a given κ and alphabet A, Gκ can be generated by an exploratory algorithm. States are triplets of the form (c,q,a). For each state (c,q,a)... category sequence state of M
  • 49.
    S. Hallé, R.Khoury Step 1: Cayley graph For a given κ and alphabet A, Gκ can be generated by an exploratory algorithm. States are triplets of the form (c,q,a). For each state (c,q,a)... For each a ∈ A... category sequence state of M
  • 50.
    S. Hallé, R.Khoury Step 1: Cayley graph For a given κ and alphabet A, Gκ can be generated by an exploratory algorithm. States are triplets of the form (c,q,a). For each state (c,q,a)... For each a ∈ A... q' = δ(q,a) c' = κ(a a) // Next state in M // Category of a a category sequence state of M
  • 51.
    S. Hallé, R.Khoury Step 1: Cayley graph For a given κ and alphabet A, Gκ can be generated by an exploratory algorithm. States are triplets of the form (c,q,a). For each state (c,q,a)... For each a ∈ A... q' = δ(q,a) c' = κ(a a) If a state (c',q',a') already exists Link (c,q,a) (c',q',a') a // Next state in M // Category of a a category sequence state of M
  • 52.
    S. Hallé, R.Khoury Step 1: Cayley graph For a given κ and alphabet A, Gκ can be generated by an exploratory algorithm. States are triplets of the form (c,q,a). For each state (c,q,a)... For each a ∈ A... q' = δ(q,a) c' = κ(a a) If a state (c',q',a') already exists Link (c,q,a) (c',q',a') a // Next state in M // Category of a a category sequence state of M
  • 53.
    S. Hallé, R.Khoury Step 1: Cayley graph For a given κ and alphabet A, Gκ can be generated by an exploratory algorithm. States are triplets of the form (c,q,a). For each state (c,q,a)... For each a ∈ A... q' = δ(q,a) c' = κ(a a) If a state (c',q',a') already exists Link (c,q,a) (c',q',a') Else Create state (c',q',a a) Link (c,q,a) (c',q',a a) a a // Next state in M // Category of a a category sequence state of M
  • 54.
    S. Hallé, R.Khoury 1 3 4 2 a b b b c d ? ⊤ ⊤ ⊤ Example
  • 55.
    S. Hallé, R.Khoury 1 3 4 2 a b b b c d ? ⊤ ⊤ ⊤ Example κ(ε) = #
  • 56.
    S. Hallé, R.Khoury 1 3 4 2 a b b b c d ? ⊤ ⊤ ⊤ Example κ(ε) = # # 1 ε
  • 57.
    S. Hallé, R.Khoury 1 3 4 2 a b b b c d ? ⊤ ⊤ ⊤ Example # 1 ε
  • 58.
    S. Hallé, R.Khoury 1 3 4 2 a b b b c d ? ⊤ ⊤ ⊤ Example κ(a) = a δ(1,a) = 3 # 1 ε
  • 59.
    S. Hallé, R.Khoury 1 3 4 2 a b b b c d ? ⊤ ⊤ ⊤ Example a a 3 a κ(a) = a δ(1,a) = 3 # 1 ε
  • 60.
    S. Hallé, R.Khoury 1 3 4 2 a b b b c d ? ⊤ ⊤ ⊤ Example a a 3 a # 1 ε
  • 61.
    S. Hallé, R.Khoury 1 3 4 2 a b b b c d ? ⊤ ⊤ ⊤ Example a a 3 a κ(d) = d δ(1,d) = 2 # 1 ε
  • 62.
    S. Hallé, R.Khoury 1 3 4 2 a b b b c d ? ⊤ ⊤ ⊤ Example d d 2 d a a 3 a κ(d) = d δ(1,d) = 2 # 1 ε
  • 63.
    S. Hallé, R.Khoury 1 3 4 2 a b b b c d ? ⊤ ⊤ ⊤ Example d d 2 d a a 3 a # 1 ε
  • 64.
    S. Hallé, R.Khoury 1 3 4 2 a b b b c d ? ⊤ ⊤ ⊤ Example d d 2 d a a 3 a κ(ab) = b δ(3,b) = 1 # 1 ε
  • 65.
    S. Hallé, R.Khoury 1 3 4 2 a b b b c d ? ⊤ ⊤ ⊤ Example d d 2 d b b 1 ab a a 3 a κ(ab) = b δ(3,b) = 1 # 1 ε
  • 66.
    S. Hallé, R.Khoury 1 3 4 2 a b b b c d ? ⊤ ⊤ ⊤ Example d d 2 d b b 1 ab a a 3 a # 1 ε
  • 67.
    S. Hallé, R.Khoury 1 3 4 2 a b b b c d ? ⊤ ⊤ ⊤ Example d d 2 d b b 1 ab a a 3 a κ(dc) = c δ(2,c) = 1 # 1 ε
  • 68.
    S. Hallé, R.Khoury 1 3 4 2 a b b b c d ? ⊤ ⊤ ⊤ Example c c 1 dc d d 2 d b b 1 ab a a 3 a κ(dc) = c δ(2,c) = 1 # 1 ε
  • 69.
    S. Hallé, R.Khoury 1 3 4 2 a b b b c d ? ⊤ ⊤ ⊤ Example c c 1 dc d d 2 d b b 1 ab a a 3 a # 1 ε
  • 70.
    S. Hallé, R.Khoury 1 3 4 2 a b b b c d ? ⊤ ⊤ ⊤ Example c c 1 dc d d 2 d b b 1 ab a a 3 a κ(dcd) = d δ(1,d) = 2 # 1 ε
  • 71.
    S. Hallé, R.Khoury 1 3 4 2 a b b b c d ? ⊤ ⊤ ⊤ Example c c 1 dc d d 2 d b b 1 ab a a 3 a κ(dcd) = d δ(1,d) = 2 # 1 ε
  • 72.
    S. Hallé, R.Khoury 1 3 4 2 a b b b c d ? ⊤ ⊤ ⊤ Example d c c 1 dc d d 2 d b b 1 ab a a 3 a κ(dcd) = d δ(1,d) = 2 # 1 ε
  • 73.
    S. Hallé, R.Khoury 1 3 4 2 a b b b c d ? ⊤ ⊤ ⊤ Example a b d b a b 4 db d c c 1 dc d d 2 d b b 1 ab a a 3 a # 1 ε
  • 74.
    S. Hallé, R.Khoury 1 3 4 2 a b b b c d ? ⊤ ⊤ ⊤ Example a b d b a b 4 db d c c 1 dc d d 2 d b b 1 ab a a 3 a # 1 ε
  • 75.
    S. Hallé, R.Khoury Step 2: picking vertices of Gκ # d d b a b c b a b a d d c a 1 3 a b 4 b b 2 c d state residual action residual b The resulting graph can contain multiple states with the same label. Pick a set VI of important vertices that contains each label once.
  • 76.
    S. Hallé, R.Khoury Step 2: picking vertices of Gκ # d d b a b c b a b a d d c a 1 3 a b 4 b b 2 c d state residual action residual b The resulting graph can contain multiple states with the same label. Pick a set VI of important vertices that contains each label once. How to select "best" set is left open...
  • 77.
    S. Hallé, R.Khoury Step 3: find a Steiner tree # d d b a b c b a b a d d c a 1 3 a b 4 b b 2 c d state residual action residual b A (minimal) Steiner tree is a subgraph of Gκ that includes all the VI.
  • 78.
    S. Hallé, R.Khoury Step 3: find a Steiner tree # d d a b c c a 1 3 a 4 b 2 d state residual action residual A (minimal) Steiner tree is a subgraph of Gκ that includes all the VI. b
  • 79.
    S. Hallé, R.Khoury Step 3: find a Steiner tree # d d a b c c a 1 3 a 4 b 2 d state residual action residual A (minimal) Steiner tree is a subgraph of Gκ that includes all the VI. b Use the tree to generate paths that end in each element of VI. d, db, a d, dc, db, a
  • 80.
    S. Hallé, R.Khoury Dealing with transitive closure Given a triaging function κ, the previous construction guarantees full coverage for both κ and ∫κ. ⇒ optimal if the labeling of Gκ is injective
  • 81.
    S. Hallé, R.Khoury Dealing with transitive closure Given a triaging function κ, the previous construction guarantees full coverage for both κ and ∫κ. ⇒ optimal if the labeling of Gκ is injective We can do better for ∫κ! Post-processing step: elimiate sequences that provide no new coverage state residual action residual d, db, a d, dc, db, a
  • 82.
    S. Hallé, R.Khoury Implementation and experiments Technique concretely implemented as an extension of SealTest Compared to GraphWalker and original SealTest Sample of 33 reactive specifications 44 variants of coverage criteria
  • 83.
    S. Hallé, R.Khoury Implementation and experiments Technique concretely implemented as an extension of SealTest Compared to GraphWalker and original SealTest Sample of 33 reactive specifications 44 variants of coverage criteria GW and ST fail to achieve full coverage in 23% and 38% of problem instances Cayley generates tests suites that are about 4× smaller than both tools But test suites contain about 2× more sequences Results:
  • 84.
    S. Hallé, R.Khoury Key result Generating a (minimal) test suite for a coverage criterion Finding a (minimal) coverage on its Cayley graph =
  • 85.
    S. Hallé, R.Khoury Take-home points Multiple coverage criteria handled in a uniform formal framework What other criteria can be modeled in this way? The algorithm for generating Gκ is (probably) optimal* The procedure to generate a test suite from Gκ is definitely not Results apply to all coverage criteria at once
  • 86.
    S. Hallé, R.Khoury Take-home points Multiple coverage criteria handled in a uniform formal framework What other criteria can be modeled in this way? The algorithm for generating Gκ is (probably) optimal* The procedure to generate a test suite from Gκ is definitely not Results apply to all coverage criteria at once Thank you!