Documente Academic
Documente Profesional
Documente Cultură
Tudor Balanescu
Department of Computer Science
Faculty of Mathematics and
Computer Science
University of Pitesti
ROMANIA
Romania
Pitesti
Bucharest
University of Pitesti
Founded in 1962
11 faculties,
12000 students,
500 teachers and researchers
BSc, 6 semesters
Master, 4 semesters:
Computer Science
Advanced techniques for information procesing
(English),
Software systems modeling, design and implementation
(Romanian)
Ph D studies, 6 semesters
4 supervisors
Some
information
about IUT
(formal specification)
(IUT)
In that presentation:
the W-method
the transition tour (TT) method
the distinguishing sequence (DS) method,
the unique input/output (UIO) method
the partial-W (Wp) method.
Bibliographic Notes
the W-method
[Chow78] T.S. Chow, "Testing Design Modelled by Finite-State
Machines", IEEE Trans. S.E. 4, 3, 1978.
the partial-W (Wp) method
S. Fujiwara, G. Bochman, F. Khendek, M. Amalou, and A.
Ghedasmi. Test selection based on finite state models. IEEE
Transactions on Software Engineering, 17(6):591{603, June 1991.
the unique input/output (UIO) method
K.K. Sabnani and A.T. Dahbura, "A protocol Testing Procedure",
Computer Networks and ISDN Systems, Vol. 15, No. 4, pp. 285-297,
1988.
the transition tour (TT) method
S. Naito and M. Tsunoyama, "Fault Detection for Sequential
Machines by Transition Tours", Proc. of FTCS (Fault Tolerant
Computing Systems), pp.238-243, 1981.
the distinguishing sequence (DS) method
G. Gonenc, A method for the design of fault detection experiments,
IEEE Trans. Computer, Vol. C-19, pp. 551-558, June 1970.
Presentation mainly based on:
Aditya P. Mathur, Foundations of Software Testing,
Pearson Education. 2008, 689 pages
X : (finite)Set of inputs
Y : (finite)Set of outputs
Q: (finite)Set of states
q0: the initial state,
T : Transition function, X x Q --> Q,
O : Output function, X x Q --> Y.
T(x,q)
DFSM
X={*,/,a}
Y= {ignore, empty, acc-bf, deacc-bf, print-bf, deacc&print-bf }
T and O, given by the following diagram:
/ :ignore
a :ignore
2
/ :ignore
* :empty
/ :deacc-bf ; print-bf
/,a :acc-bf
* :acc-bf
3
4
* :acc-bf
a :acc-bf
T(aab,S0)=S1
O(aab,S0)=eff
O(aab,S1)=fef
S0
aab/eff
S1
a/!
1
Completely specified,
not connected
(hence, not strongly connected)
(widely used)
Operation error
Transfer error
Extra state error
Missing state error:
Correct
design
a/1
b/0
missing
state
Extra state
Transfer
Equivalence
Given a set V of input sequences, two states q and p are
V-equivalent (written as q (V) p), if q and p respond
with identical output sequences to each input sequence
in V.
x(xV O(x,q)=O(x,p))
Note. Q and p are distinguishable by V if not equivalent
on V
Two states q and p are equivalent (written as q p), if
they are V-equivalent for any set V.
x(O(x,q)=O(x,p))
Two FSMs S and I are equivalent if their initial states
So and Io are equivalent.
Two states q and p are k-equivalent, k1 if they are Xk
equivalent
b/1
a/1
b/1
errors
errors
Remark. The error is present in [Chow78]. Only 5% of my students catch the inadequacy!
Remarks on proof ?
Minimal FSM
An FSM M is minimal if the number of states in
M is less than or equal to the number of states
for any machine M' which is equivalent to M.
a/1
a/1, b/1
0
b/1
2
a/1, b/0
1v2
a/1, b/0
a/1, b/0
Not minimal:
States 1 and 2
are equivalent,
might be merged
Minimal:
(how to prove?
Note: States 0 and 1v2
are distinguishable (O(b,0)=1, O(b,1)=0)
Characterization set
Most methods for generating tests from finite
state machines make use of an important set
known as the characterization set.
Let M = (X,Y,Q, q0, T,O) be an FSM that is
minimal and complete.
A characterization set of M, denoted as W, is a
finite set of input sequences that distinguish
the behavior of any pair of states in M.
p,q (pq wW O(w,p)O(w,q))
or
p,q (pq pWq)
baaa aa
aa
aaa
FSM Aditya
b/0
0
a/1
W1={a}
W2={b}
2. The W- procedure: in the second step these kequivalence partitions are traversed, in reverse
order, to obtain the distinguishing sequences
for every pair of states.
k-equivalence partition
Given an FSM M = (X,Y,Q, q1,,O), a kequivalence partition of Q, denoted by Pk,
is a collection of n finite sets of states
denoted as Qk 1,Qk 2, . . .,Qk n such that
Union of Qkj is Q
States in Qkj are k-equivalent,
If qQki, p Qkj and ij, then q and p
are k-distinguishable
1. T and O of
FSM, in tabular
form
P1 has
Q11={q1,q2,q3}
Q12={q4,q5}
2. regroup
P1 table
3. Construct P1 table
copy the Next State sub-table
rename each Next State entry by appending a second
subscript which indicates the group to which that state
belongs.
Important note.
States in the same group
are 1-equivalent
In every Pk group, regroup all rows with identical second subscripts in its
row entries under the Next State column
states from the same new group, for every input, lead into states from the same
old group (these are k-equivalent)
They are already 1-equivalent (were in the same group in P1)
Hence, states from the same new group are (k+1) equivalent
a/x
Another old
group, k
equivalence
Hence,p and q
are k+1 equiv
a/x
p
b/y
b/y
Same output, p
and q are already
1-equiv
P2 P3 tables
P4 table
The W- procedure
{P1, Pn is the set of k-equiv partitions}
W=;
forall pq do
G(q , x ) denotes the
if r(1r<n (p,q) equiv in Pr but not equiv in Pr+1) then
label of the group to
choose such an r; //(p,q) r equiv but not (r+1)-equiv
which the machine
moves
z=; p1=p; p2=q;
when excited using
for m=r downto 1 do
input x in state q .
choose x in X such that G(p1,x)G(p2,x) in
For Pm;
example, in the
table for P3
z=zx;
G(q2, b) = 4
p1=T(x, p1); p2=T(x, p2)
and
end for
G(q5, a) = 1.
choose x such that O(x,p1) O(x,p2);
z=zx;
W=W u {z};
else {(p,q) not equiv in P1} do
find x in X such that O(x,q) O(x,p);
W=W u {x}; // x distinguishes q and p
end if
end forall
Example: W procedure
For q1 and q2 we may find baaa, baba etc.
(r=3; part if then of the W procedure)
For q3 and q4 we find a
(no r; part ifelse of the W procedure)
For q4 and q5 we may find aaa or aba.
(r=2; part if then of the W procedure)
For q2 and q3 we may find aa or ba.
(r=1; part if then of the W procedure)
Identification sets
Analogous to the characterization set for M, we
associate an identification set with each state of M.
An identification set for state q is denoted by Wq and has
the following properties:
Wq W
Wq is minimal with respect to
p (pq sWq O(s,p)O(s,q))
I is assumed to be deterministic
P is a transition cover of S
W is a characterization set of S
Testing tree
Example, for
FSM Aditya
P=
{,
a, b,
bb, ba,
bab, baa,
baab, baaa,
baaab, baaaa}
Constructing Z
Suppose that the number of states estimated to be in the IUT
is m and the number of states in the design specification is n,
mn. Given this information we compute Z as:
Z = X[m n].W,
for m = n, i.e. when the number of states in the IUT is
the same as that in the specification.
Z = X.W
For m < n we still use
Z = X.W.
The file IUT_Aditya/input.txt containes the test set T for FSM Aditya,
with m=n=5.
The file IUT_Aditya/output.txt containes the outputs from T. The
output is obtained with the program IUT_Aditya/Aditya.cpp, a direct
transposition of the design FSM Aditya. (It is supposed that
Aditya.cpp is correct with respect to the design!)
The input , (a comma) is used as a reset operation, in order to
avoid the restarting of IUT after each sting processing. Hence,
strings in T have to be separated by reset.
The input s stops the test.
Adytia.cpp is robust: any other input is simply transferred to output
and keeps the FSM in the current state.
Such inputs are useful in identifying strings in T and their
corresponding outputs.
For instance, 2:aa, 3:aaa are the second and the third strigs in T.
Their corresponding outputs are 2:00, 3:000
AdityaTR
FSM
transfer error in
q2
Exercise
In the previous example, AdityaEX.cpp was tested with
an inappropriate T (in fact, m is 6). By chance, the error
is discovered, even T was constructed for m=5.
Let us consider an AdityaNewEX FSM, obtained from
AdityaEX by having outputs in the new state q6 as in q5 :
O(a,q6)=O(b,q6)=1.
Adapt AdityaEX.cpp to obtain AdityaNewEX.cpp
Test AdityaNewEX.cpp with both T(m=5) and T(m=6)
qi
but
q0
qi
a/x
a/y
q
q
in S
in I
qi
qi
a/x
in S
but
q0
qi
a/x
in I, and qr
Wp- method
The assumptions about S and I made for this
method are similar to those made for the Wmethod.
The main advantage of the Wp-method, over the
W-method, is to reduce the length of the test
suite.
Instead of using the set W to check each
reached state Si, only a subset of this set can be
used in certain cases.
This subset Wi depends on the reached state Si, and
is called an identification set for Si.
The union of identification sets Wi for all states Si is a
characterization set .
Phases of Wp-method
The Wp-method consists of two phases which
have the following purposes:
Phase 1: This phase checks that all the states
defined by the specification are identifiable in the
implementation, and also checks, for each state
Ik, that it can be identified by the smaller set Wk.
At the same time, the transitions leading from
the initial state to these states are checked for
correct output and state transfer.
Phase 2: This phase checks the implementation
for all the transitions defined by the specification,
which were not checked during the first phase.
Note1: If
Specification S
Note: for the same sets P and W, the Wmethod generates the following additional
test sequences:
b.a.b, b.b.a, c.a.a, c.b.b.
a/f
Phase 2 (RW):
Input cab
Output ef f
instead of ef e,
Error detected.
R.
Phase 1: The test sequences for this phase are:
Q.W = {a, b, c, b.a, b.b, b.c, c.a, c.b, c.c}
Phase 2 : The test sequences for this phase are:
R W = {a.c, b.c.c, b.a.a, b.b.b, c.a.b, c.c.c, c.b.a }
Phase 1 may be skiped.
Wp-method (m>n)
For implementations with additional states (m>n),
Phase 1 uses QZ (Z = X[m-n].W )instead of QW
Phase 2 uses
RX[m-n]W =
Union (forall r in R) {r} Zi
where
Wk is the identification set of Sk
Sk is reached from Si by x
Si is reached from S0 by r
Zi= [Union (forall x in X[m-n]){x}Wk ],
S0
Si
Sk
WK
union
Zi
The extra state I3 has the same outputs as Io for all inputs,
but differs in the next states.
UIO property
Unique I/O property:
q (p(pq O(q, ) O(p, ) )
AdityaUIO
UIOs:
O(ac,1)=01
O(ac,2)=0
O(ac,3)=0
O(ac,4)=
O(ac,5)=0
O(ac,6)=1
a/y
a/x
a/y
b/x
2
IUT
b/x
S
(transfer +
a/x
0
a/y
b/x
output fault )
a/y
2
b/x
b/y
S0I0 on {a}
S1I1 on {aa}
S2I2 on {aa}
minimality assumption
Note.
FSM specification may be incomplete.
A machine that depicts only the core behavior of an FSM is
referred to as its core-FSM.
Aditya-Core
An incomplete FSM
Aditya-null
Addition of null transitions to
satisfy the completeness
assumption
UIO, DS, Wp
In case
Wi has a single element:
Wp is Unique I/O (UIO)
All Wi have the same single element:
Wp is Distinguishing Sequence (DS *)
*G. Gonenc, A method for the design of fault
detection experiments, IEEE Trans. Computer,
Vol. C-19, pp. 551-558, June 1970.
EXERCICES
Exercises
Apply the algorithm for k-equivalence
partitions construction to the following
FSM
b/1
1
a/0
0
b/1
a/0
a/0
b/1
b/1
0
a/0
a/0
b/1
a/0, b/1
0
Exercises
Generate a test set T that distinguishes all wrong
implementation with an extra state.
Exercise
Construct the characterization set W and the transition cover for
the machine S
Using the W-method construct set Z assuming that m = 3 and
derive a test set T.
Does any element of T reveal the transfer error in the IUT?
IUT
S
It
Exercise. W or WP (1/2)
Derive tests for the specification below, taking into
consideration each of the IUTs from the next slide
Exercise. W or WP (2/2)
Exercise
Apply W and Wp to the FSMs on the slide
Example: extra state
may or may not be an error