990 likes | 1.17k Views
Theory and Practice of Co-verification Process: UniTesK Story. RedVerst group of ISP RAS Alexander K. Petrenko Victor V. Kuliamin http://www.ispras.ru. Overview. Introduction : Why co-verification? Main part : What is UniTesK? Solving Engineering Problems Case studies.
E N D
Theory and Practice ofCo-verification Process: UniTesK Story RedVerst group of ISP RAS Alexander K. Petrenko Victor V. Kuliamin http://www.ispras.ru
Overview Introduction : Why co-verification? Main part : What is UniTesK?Solving Engineering Problems Case studies
What these numbers mean? • The Economic Impacts of Inadequate Infrastructure for Software Testing, • NIST Report, May 2002
Waterflow Process Model Requirements Design Implementation Testing Deployment
Iterative Process Model Inception Elaboration Construction Transition Requirements Design Implementation Testing Deployment
Agile Development Methods Expansion Percent of organizations using modern development methods According to “The Decision is in: Agile versus Heavy Methodologies” by Robert Charette, Cutter IT Journal, vol. 2, No. 19, 2002 http://www.cutter.com/freestuff/apmupdate.html
Agile Development Methods Expansion 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, 2002 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]
Co-verification Verification confirms that activity products properly reflect the requirements specified for them at the beginning of the activity. Co-verification process Perform verification of activity before proceeding to the dependent activities Prepare all the artifacts needed for verification concurrently with main activity products
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 Software Development Process Requirements Analysis Design Implementation-debugging Requirements Elicitation Test Case Design Test Implementation Test Execution Test Result Analysis Design and development Verification
Co-verification Process Requirements Analysis Design Implementation-debugging Requirements Elicitation Test Case Design Test Implementation Test Execution Test Result Analysis Design and development Verification
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 Requirements Formal Specifications
Co-verification Support Formal Specifications Requirements Ambiguity? Incompleteness? Inconsistency?
Engineering Problems (1) Specification technique should support Easy transformation of requirements into specifications Easy automation of further test development Functional test coverage definition High reusability of specifications Specification notation should not require special education and 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 provide poor error localization 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 process
Constraint Specifications Preconditions and postconditions of operations Data type constraints Functional coverage description based on specification structure UniTesK Specification Technique 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 Invariant()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() && ((Integer)priorities.elementAt(i)).intValue() > 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 specification package; public class PQueueSpecification { // List of elements of the queue public List items =new List(); // 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) > Max_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 && Min_Priority <= prty && prty <= Max_Priority; } 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 Goals Definition Formal Specifications pre --------------------------- post --------------------------- -------------------------------------------------- ---------------------------------------------- ------------ ------------------------------------- ---------------------------------------------- --------------------------------------------- -------------------------------------------------- ---- ------------------------------------- Requirements Testable Specifications pre --------------------------- post --------------------------- -------------------------------------------------- ---------------------------------------------- ------------ ------------------------------------- ---------------------------------------------- ---------------------------------------------- -------------------------------------------------- ---- ------------------------------------- Test Case 1 --------------- --------------- -------- 1 2 3
Co-verification Support Formal Specifications pre --------------------------- post --------------------------- -------------------------------------------------- ---------------------------------------------- ------------ ------------------------------------- ---------------------------------------------- --------------------------------------------- -------------------------------------------------- ---- ------------------------------------- UniTesK supports this transformation with techniques and tools Software --------------------------------------------------- --------------------------------------------------- --------------------------------------------------- --------------------------------------------------- --------------------------------------------------- --------------------------------------------------- --------------------------------------------------- --------------------------------------------------- --------------------------------------------------- Testable Specifications pre --------------------------- post --------------------------- -------------------------------------------------- ---------------------------------------------- ------------ ------------------------------------- ---------------------------------------------- ---------------------------------------------- -------------------------------------------------- ---- -------------------------------------
Engineering Problems (2) More than one coverage metric is needed Automatic extraction of coverage goals 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 Goals : 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.? { 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 Goals : enq() 1 7 5 4 2 0 5 5 4 3 1 1 1 1 1 1
Additional Coverage Goals : deq() 5 5 4 3 1 1 5 4 3 1
Definition of Coverage Goals : Marked Paths post if(a || b || c) { branch“Case 1”; ... } if(a) mark “a holds”;
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