930 likes | 1.06k Views
Theory and Practice of Co-verification Process: UniTesK Story. RedVerst group of ISP RAS http://www.ispras.ru/groups/rv/rv.html Alexander K. Petrenko (petrenko@ispras.ru) Victor V. Kuliamin (kuliamin@ispras.ru). Overview. Introduction : Why co-verification? Main part : What is UniTesK?
E N D
Theory and Practice ofCo-verification Process: UniTesK Story RedVerst group of ISP RAS http://www.ispras.ru/groups/rv/rv.html Alexander K. Petrenko (petrenko@ispras.ru) Victor V. Kuliamin (kuliamin@ispras.ru)
Overview Introduction : Why co-verification? Main part : What is UniTesK? Case studies
Waterflow Process Model Requirements Design Implementation Testing Deployment
Iterative Process Model Inception Elaboration Construction Transition Requirements Design Implementation Testing Deployment
CMM Certified Organizations According to Compiled List of Organizations Publicly Announced their Maturity Levels, http://seir.sei.cmu.edu/pml/
New Development Technologies Expansion Percent of organizations using modern development processes According to “The Decision is in: Agile versus Heavy Methodologies” by Robert Charette, Cutter IT Journal, vol. 2, No. 19 http://www.cutter.com/freestuff/apmupdate.html
Need for Quick Change Response Percent of organizations recognizing more than 50% of projects as agile According to “The Decision is in: Agile versus Heavy Methodologies” by Robert Charette, Cutter IT Journal, vol. 2, No. 19 http://www.cutter.com/freestuff/apmupdate.html
Inadequate Quality of Software The Economic Impacts of Inadequate Infrastructure for Software Testing, NIST Report, May 2002
Evolution of Testing Localization of errors Demonstration of errors Testing is the process of executing a program or system with the intent of finding errors [Myers, 1979] The purpose of testing is to show that aprogramhas bugs [Hetzel, 1988] Evaluation of quality Testing is the process of operating a system or component under specified conditions, observing or recording the results, and making an evaluation of some aspect of the system or component [IEEE 90]
Traditional Development Process Business Modeling Deployment Requirements Integration Architecture Design Implementation Component Design
Co-verification Development Process Business Modeling Deployment Requirements Integration Architecture Design Implementation Component Design
Main Part Overview Traditional approaches to verification UniTesK approach Example
Traditional Test Development E Requirements Elicitation Test Case Design Test Implementation Test Execution Test Result Analysis
UniTesK Approach UniTesK Tools .N@T J@T CTesK VDM++TesK Uniform Specification Extension Uniform Test Architecture Integration with Development Environments Foundations Model Based Testing
Requirements Formalization Requirements Formal Specifications
Engineering Problems Specification technique should be suitable for Easy transformation of requirements Easy automation of further test development Easy adaptation to needs of the industry Functional test coverage definition Specification notation should require minimum education and special skills
Specification Techniques ExecutableImperative state based specifications ConstraintsState based data type constraints, pre- and postconditions, internal invariants AxiomaticAction based axioms
Executable Specifications Are very close to some implementation Are easy to use in the industry Can be transformed into prototypes Are not close to requirements( √¯ = e½ln = lim(xn+1 = ½(xn +x/xn)) ) Unsuitable for test coverage measurement Can cause problems with conformance checkingHow to compare the results? Are highly reusable as executable code But are low reusable as criteria of correctness
Constraint Specifications Have the structure similar with implementation Are easy to use in the industry But have different form Are close to requirements in most cases Are easy to construct from requirements Suitable for test coverage measurement Counterexample: memory management subsystem Can be directly used in conformance checking Special constructs enabling reuse can be added
Axiomatic Specifications Are far from common implementations and have greatly different structure Can hardly be introduced in the industry Are usually far from requirements Are hard to develop in real-life projects Can hardly be used for coverage measurement But sometimes are the only appropriate form Can be used for conformance checking But sharpen error localization problems Reusability is a problem
Specification Notation Specification language Suitable for capture abstract properties Has formal semantics Requires complex mediator layer for implementation Requires special education, mastering is enduring Extension of programming language Abstract concepts can be added by libraries Ambiguous parts of language can be excluded Complex mediators are not required Mastering can be made more effective Facilitates co-verification
UniTesK Specification Technique Uniform Specification Extension Constraint Specifications Preconditions and postconditions of operations Data type constraints Functional coverage description based on specification structure UniTesK .N@T J@T CTesK VDM++TesK Uniform Specification Extension Uniform Test Architecture Integration with Development Environments Model Based Testing
UniTesK Specification Technique Constraint Specifications Preconditions and postconditions of operations Data type constraints specification Operation() preblock, returning Boolean value post block, returning Boolean value use @to refer to pre-value of expressions invariant Inv()block, returning Boolean value
void enq (Object obj, int priority)priority [Min_Priority, Max_Priority] Object deq () int size () Priority Queue Example 0 5 2 enq () enq () deq () enq () 5 5 4 3 1 1 size ()
J@va : Specification Extension of Java specification package pqueue; public class PQueueSpecification { specification publicvoid enq(Object obj, int prty) readsobj, prty updates items.?, priorities.? { pre { return obj !=null; } post { int i = 0; for(i = 0; i < items.size() && priorities.elementAt(i) > prty; i++ ); ... UniTesK .N@T J@T CTesK VDM++TesK Uniform Specification Extension Uniform Test Architecture Integration with Development Environments Model Based Testing
Model State Definition public class PQueueSpecification { // List of elements of the queue public Vector items =new Vector(); // Accompanying list of their priorities public IntList priorities =new IntList(); }
Data Integrity Constraints : Lists are not Null public class PQueueSpecification { public List items =new List(); public IntList priorities =new IntList(); invariant ListsAreNotNull() { return items != null && priorities != null; } }
Data Integrity Constraints : Lists’ Sizes are Equal public class PQueueSpecification { invariant ListsSizesAreEqual() { return items.size()== priorities.size(); } }
Data Integrity Constraints : Priorities Lie in the Range public class PQueueSpecification { public static int Min_Priority; public static int Max_Priority; invariant PrioritiesLieInTheRange() { for(int i = 0; i < priorities.size(); i++) { if( priorities.get(i) < Min_Priority || priorities.get(i) > Min_Priority ) return false; } return true; } }
Data Integrity Constraints : Priorities do not Increase public class PQueueSpecification { invariant PrioritiesDoNotIncrease() { for(int i = 1; i < priorities.size(); i++) { if( priorities.get(i-1) < priorities.get(i)) return false; } return true; } }
Operation Specification : size() Method public class PQueueSpecification { specification public int size () reads this.? { pre { return true; } post { return size == items.size(); } } }
Operation Specification : enq() Method public class PQueueSpecification { specification public void enq (Object obj, int prty) readsobj, prty updates this.? { pre { return obj != null; } post { int i = 0; for(i = 0; i < items.size() && priorities.get(i) >= prty; i++ ); PQueueSpecification new_state =(PQueueSpecification)@clone(); new_state.items.add(i, obj); new_state.priorities.add(i, prty); returnthis.equals(new_state); } } }
Auxiliary Methods public class PQueueSpecification { public boolean equals (PQueueSpecification other) { return items.equals(other.items) && priorities.equals(other.priorities); } public Object clone () { PQueueSpecification result = new PQueueSpecification(); result.items = (List)items.clone(); result.priorities = (IntList)priorities.clone(); return result; } }
Operation Specification : deq() Method public class PQueueSpecification { specification public Objectdeq () updates this.? { post { if(items.isEmpty()) returndeq == null && items.isEmpty(); else { PQueueSpecification new_state =(PQueueSpecification)@clone(); Object result = new_state.items.first(); new_state.items.removeFirst(); new_state.priorities.removeFirst(); returnthis.equals(new_state) && deq == result; } } } }
Coverage Tasks Definition Formal Specifications pre --------------------------- post --------------------------- -------------------------------------------------- ---------------------------------------------- ------------ ------------------------------------- ---------------------------------------------- --------------------------------------------- -------------------------------------------------- ---- ------------------------------------- Requirements Formal Specifications pre --------------------------- post --------------------------- -------------------------------------------------- ---------------------------------------------- ------------ ------------------------------------- ---------------------------------------------- ---------------------------------------------- -------------------------------------------------- ---- ------------------------------------- Test Case 1 --------------- --------------- -------- 1 2 3
Engineering Problems More than one coverage metrics is needed Automatic coverage goals extraction Enabling test designer to introduce additional goals
Several Levels of Coverage Metrics 1.2.1 1.2.2 1.1 1.2 1.3 Formal Specifications pre --------------------------- post --------------------------- -------------------------------------------------- ---------------------------------------------- ------------ ------------------------------------- ---------------------------------------------- ---------------------------------------------- -------------------------------------------------- ---- ------------------------------------- 1.3.1 1.3.2 1.3.3 1 2 2.1 2.2 3 3.1.1 3.1.2 3.1.3 3.1 3.2
Definition of Coverage Tasks : Functionality Branches • Functional coverage description based on specification structure post if(a || b) ... branch“Case 1”; ... else if(!c && d) ... branch“Case 2”; ... else ... branch“Case 3”; ...
public class PQueueSpecification { specification public int size () reads this.? { pre { return true; } post { branch“Single branch”; return size == items.size(); } } } Functionality Branches in size() Method
specification public void enq (Object obj, int prty) readsobj, prty updates this.? { pre { return obj != null; } post { int i = 0; for(i = 0; i < items.size() && priorities.get(i) >= prty; i++ ); branch“Single branch”; PQueueSpecification new_state =(PQueueSpecification)@clone(); new_state.items.add(i, obj); new_state.priorities.add(i, prty); returnthis.equals(new_state); } } Functionality Branches in enq() Method
specification public Objectdeq () updates this.? { post { if(items.isEmpty()) { branch “Empty queue”; returndeq == null && items.isEmpty(); } else { branch “Nonempty queue”; PQueueSpecification new_state =(PQueueSpecification)@clone(); Object result = new_state.items.firstElement(); new_state.items.removeFirstElement(); new_state.priorities.removeFirstElement(); returnthis.equals(new_state) && deq == result; } } } Functionality Branches in deq() Method
Additional Coverage Tasks : enq() 1 7 5 4 2 0 5 5 4 3 1 1 1 1 1 1
Additional Coverage Tasks : deq() 5 5 4 3 1 1 5 4 3 1
Definition of Coverage Tasks : Marked Paths post if(a || b || c) { if(a) mark “a holds”; branch“Case 1”; ... }
Marked Paths in enq() Method post { int i = 0; for(i = 0; i < items.size() && priorities.get(i) >= prty; i++ ); if( items.isEmpty() ) mark "Insertion in the empty queue"; else if( prty > priorities.maximum() ) mark "Insertion in the head"; else if( prty == priorities.maximum()&& prty == priorities.minimum() ) mark "Insertion with single existing priority"; else if( prty == priorities.maximum() ) mark "Insertion with maximum priority"; else if( prty < priorities.minimum() ) mark "Insertion in the tail with new priority"; else if( prty == priorities.minimum() ) mark "Insertion with minimum priority"; else if( !priorities.contains(prty) ) mark "Insertion in the middle with new priority"; else mark "Insertion in the middle with existing priority"; branch“Single branch”; ... }
post { if(items.isEmpty()) { branch “Empty queue”; ... } else { if( items.size() == 1 ) mark "Single element in the queue"; else if( !(priorities.maximum() == priorities.get(1)) ) mark "Single element with maximum priority, several elements in the queue"; else if( priorities.toSet().size() > 1 ) mark "Several elements with maximum priority, there are other priorities"; else mark "Several elements in the queue with the same priority"; branch “Nonempty queue”; ... } } Marked Paths in deq() Method
Test Implementation Formal Specifications pre --------------------------- post --------------------------- -------------------------------------------------- ---------------------------------------------- ------------ ------------------------------------- ---------------------------------------------- ---------------------------------------------- -------------------------------------------------- ---- ------------------------------------- Test Case 1 --------------- --------------- -------- Test Program Test Scenario
Engineering Problems Test construction technique should ensure coverage goals achievement Enabling test designer to introduce additional tests Tests should be decoupled with implementation