Testing functionality independent on history of system-environment interactions Study 2.

Slides:



Advertisements
Similar presentations
AP Computer Science Anthony Keen. Computer 101 What happens when you turn a computer on? –BIOS tries to start a system loader –A system loader tries to.
Advertisements

Core Java Lecture 4-5. What We Will Cover Today What Are Methods Scope and Life Time of Variables Command Line Arguments Use of static keyword in Java.
CSCI 160 Midterm Review Rasanjalee DM.
C# Language Report By Trevor Adams. Language History Developed by Microsoft Developed by Microsoft Principal Software Architect Principal Software Architect.
Lecture # 21 Chapter 6 Uptill 6.4. Type System A type system is a collection of rules for assigning type expressions to the various parts of the program.
CSE 332: C++ exceptions Overview of C++ Exceptions Normal program control flow is halted –At the point where an exception is thrown The program call stack.
Programming Review: Functions, pointers and strings.
What does this program do ? #include int main(int argc, char* argv[]) { int i; printf("%d arguments\n", argc); for(i = 0; i < argc; i++) printf(" %d: %s\n",
Exercise 10 Review: pointers, strings and recursion.
Command line arguments. – main can take two arguments conventionally called argc and argv. – Information regarding command line arguments are passed to.
VARIABLES, TYPES, INPUT/OUTPUT, ASSIGNMENT OPERATION Shieu-Hong Lin MATH/CS Department Chapel.
Modular Programming Chapter Value and Reference Parameters t Function declaration: void computesumave(float num1, float num2, float& sum, float&
1 Stacks Stack Examples Stack API More Examples/Uses Base Conversion Activation Records RPN Implementing a Stack Stacks.
Modular Programming Chapter Value and Reference Parameters computeSumAve (x, y, sum, mean) ACTUALFORMAL xnum1(input) ynum2(input) sumsum(output)
1 Chapter 13 Recursion. 2 Chapter 13 Topics l Meaning of Recursion l Base Case and General Case in Recursive Function Definitions l Writing Recursive.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Command Line Arguments.
APS105 Strings. C String storage We have used strings in printf format strings –Ex: printf(“Hello world\n”); “Hello world\n” is a string (of characters)
Chapter 8 Scope of variables Name reuse. Scope The region of program code where it is legal to reference (use) a variable The scope of a variable depends.
CS 261 – Data Structures C Pointers Review. C is Pass By Value Pass-by-value: a copy of the argument is passed in to a parameter void foo (int a) { a.
(3-1) Functions II H&K Chapter 3 Instructor - Andrew S. O’Fallon CptS 121 (September 9, 2015) Washington State University.
CS415 C++ Programming Takamitsu Kawai x4212 G11 CERC building WV Virtual Environments Lab West Virginia University.
ISP RAS Java Specification Extension for Automated Test Development Igor B. Bourdonov, Alexei V. Demakov, Andrei A. Jarov, Alexander S. Kossatchev, Victor.
Copyright 2004 Scott/Jones Publishing Alternate Version of STARTING OUT WITH C++ 4 th Edition Chapter 6 Functions.
Pre/Post Condition Discussion 03/13/2013. Quicksort int main(int argc, char* argv[]) { int numbers[SIZE] = {2,5,3…} struct Sorter s; // initialize generic.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Recursion.
Reading from a file, Sorting, and a little Searching Data Structures and Algorithms CS 244 Brent M. Dingle, Ph.D. Department of Mathematics, Statistics,
C:\Temp\Templates 4 5 Use This Main Program 6.
Study 1 Purpose of the tool. Test architecture.. Testing Target system Test system Testing results results affecting.
Assignment #2. Regular Expression (RE) Represent a string pattern – Consists of regular characters and wild cards Assignment #2: implement a subset of.
Study 1 Purpose of the tool. Test architecture.. Testing Target system Test system Testing results results affecting.
Testing It is much better to have a plan when testing your programs than it is to just randomly try values in a haphazard fashion. Testing Strategies:
White Box Testing. Agenda White-box vs Black-box Program Flow Controls White-box Test Methods Exercises Complexity Q&A.
CSE 332: C++ Exceptions Motivation for C++ Exceptions Void Number:: operator/= (const double denom) { if (denom == 0.0) { // what to do here? } m_value.
Pointers to pointers & multi-dimensional arrays
Generic Programming in C
Types CSCE 314 Spring 2016.
Chapter 6 CS 3370 – C++ Functions.
Control Flow Testing Handouts
A bit of C programming Lecture 3 Uli Raich.
Haskell Chapter 2.
Bill Tucker Austin Community College COSC 1315
Command Line Arguments
Understand argc and argv
OOP-4-Templates, ListType
Command Line Arguments
Review Session.
Specifications What? Not how!.
typedef typedef int Index; typedef char Letter; Index i; i = 17;
More Examples of argc and argv
Multiple Files Revisited
Command Line Arguments
نوع داده هاي انتزاعي Abstract Data Types
הרצאה 08 פרמטרים ל- main קרן כליף.
Elements of Programming Languages
Subprograms and Programmer Defined Data Type
C++ File Structure and Intro to the STL
Command Line Parameters
Fundamentals of Functional Programming
Jordi Cortadella and Jordi Petit Department of Computer Science
ECE 103 Engineering Programming Chapter 46 argc, argv, envp
CS150 Introduction to Computer Science 1
Fundamental Programming
C++ File Structure and Intro to the STL
CS150 Introduction to Computer Science 1
Chapter 18 Recursion.
CSE 1020:Software Development
Functions Reasons Concepts Passing arguments to a function
Functions Students should understand the concept and basic mechanics of the function call/return pattern from CS 1114/2114, but some will not. A function.
The List Container and Iterators
Presentation transcript:

Testing functionality independent on history of system-environment interactions Study 2

Specifications Test sequence generator Specifications Test action iterator Test scenario Mediators on SeC Target system Test engine Оракул Oracle Медиатор Mediator Спецификации Specifications Specification development Mediator development Test scenario development Steps of test development using the tool:

Specification function trunc_spec specification mix_num trunc_spec(mix_num* mn) { pre { return mn->denom > 0 && ( mn->integral >= 0 && mn->num >= 0 || mn->integral num denom && abs(mn->num) denom && mn->integral * mn->denom + mn->num } }

Specification function specification (,..., ) { pre {... } coverage {... } post {... } } signature body

Pointers as parameters of specification functions specification f( int* i, int* iarray ) {... if(*i == 0) if(iarray[3] != 0) }

; * ; Specification types void* create(& _type,…); int compare(Object*,Object*); bool equal(Object*,Object*); void* copy(Object*,Object*); void* clone(Object*); String* toString(Object* ref) Integer, Double, Char, String, Set, List, Map

Definition of specification type specification typedef = {.init = pointer_to_initialization_function,.copy = pointer_to_finalization_function,.compare = pointer_to_comparing_function,.to_string = pointer_to_string_mapping_function,.enumerator = pointer_to_reference_counting_function,.destroy = pointer_to_destroying_function }; specification typedef = {}; specification typedef ;

Specification type MixNum int compare_MixNum(MixNum* left, MixNum* right) { int l = left->num * right->denom, r = right->num * left->denom; if(left->integral != 0) l += left->integral * right->denom * left->denom; if(right->integral != 0) r += right->integral * left->denom * right->denom; return l – r; } specification typedef mix_num MixNum = {.compare = (Compare)compare_MixNum };

Signature of specification function trunc_spec specification MixNum* trunc_spec(MixNum* mn);

Structure of a body of specification function specification ( ) { pre {... } coverage {... } post {... } }

pre { if(...) /* values of inputs meet precondition requirements */ return true; else return false; } specification (...) { pre { if(...) /* values of inputs meet precondition requirements */ return true; else return false; }... } Precondition outputs ( *arg, result ) Target system call inputs ( arg, *arg )

Precondition of specification function trunc_spec pre return mn->denum > 0 specification MixNum* trunc_spec(MixNum* mn) { pre { return mn->denum > 0 && ( mn->integral > 0 && mn->num > 0 && ( mn->integral > 0 && mn->num > 0 || mn->integral num integral num < 0 || mn->integral == 0 && mn->num == 0 ); || mn->integral == 0 && mn->num == 0 ); }... }

Type invariants /* invariant of C type */ invariant typedef ; invariant( value) { if(/* invariant are held for the value of value */) return true; else return false; } /* invariant of specification type */ invariant specification typedef = {...}; invariant( *r) {...}

invariant( value); invariant( value); specification ( * arg) { pre {...} coverage {...} post {...} } Automatic checking invariants for specification function arguments outputs ( *arg, result ) Target system call inputs ( arg, *arg ) Prevalues Postvalues invariant(*arg); invariant(*arg); invariant( );

Invariant of specification type MixNum invariant specification typedef mix_num MixNum; invariant(MixNum* mn) { return mn->denum > 0 && ( mn->integral >= 0 && mn->num >= 0 || mn->integral num integral == 0 && mn->num == 0 ); } pre return mn->denum >0 && ( mn->integral >= 0 && mn->num >= 0 || mn->integral num denum >0 && ( mn->integral >= 0 && mn->num >= 0 || mn->integral num <= 0 || mn->integral == 0 && mn->num == 0 ); || mn->integral == 0 && mn->num == 0 ); }... }

Coverage criteria coverage {... if(...) /* with given values of arguments the functionality branch is covered */ return {, };... } specification (...) { pre {...} coverage {... if(...) /* with given values of arguments the functionality branch is covered */ return {, };... } post {...} } outputs ( *arg, result ) Target system call inputs ( arg, *arg )

Coverage criteria completeness coverage С { if(...) /* Condition 1 */ return { BRANCH_1, "1 st branch" }; else if(...) /* Condition 2 */... else return { LAST_BRANCH, "Last branch" }; } Any set of argument prevalues should belong to one of functionality branches defined be coverage criteria

Coverage criterion of specification function trunc_spec coverage С { if(mn->integral == 0 && mn->denom > mn->num) return {PROP_FRACT, "Proper fraction"}; if(mn->integral == 0 && mn->denom num) return {IMPROP_FRACT, "Improper fraction"}; if(mn->integral != 0 && mn->denom > mn->num) return {PROP_MIXED, "Proper mixed number"}; else/*(mn->integral!=0 && mn->denom num)*/ return {IMPROP_MIXED, "Improper mixed number"}; } specification MixNum* trunc_spec(MixNum* mn) { coverage С { if(mn->integral == 0 && mn->denom > mn->num) return {PROP_FRACT, "Proper fraction"}; if(mn->integral == 0 && mn->denom num) return {IMPROP_FRACT, "Improper fraction"}; if(mn->integral != 0 && mn->denom > mn->num) return {PROP_MIXED, "Proper mixed number"}; else/*(mn->integral!=0 && mn->denom num)*/ return {IMPROP_MIXED, "Improper mixed number"}; }... }

Postcondition post { if(...) /* values of outputs meet postcondition requirements */ return true; else return false; } specification (...) { pre {...} coverage {... } post { if(...) /* values of outputs meet postcondition requirements */ return true; else return false; } } point of affecting outputs ( *arg, result ) Target system call inputs ( arg, *arg )

Prevalues of arguments and returned result in poctcondition specification int func(int *u) { post { != 0 && func == *u } } outputs ( *arg, result ) Target system call inputs ( arg, *arg )

Postcondition of specification function trunc_spec post { return trunc_spec->integral == mn->integral && trunc_spec->denom == mn->denom && trunc_spec->num == mn->num /* !memcmp(trunc_spec, mn) */ && mn->denom && abs(mn->num) denum && } specification MixNum* trunc_spec(MixNum* mn) { coverage С { if(mn->integral == 0 && mn->denom > mn->num) return {PROP_FRACT, "Proper fraction"}; if(mn->integral == 0 && mn->denom num) return {IMPROP_FRACT, "Improper fraction"}; if(mn->integral != 0 && mn->denom > mn->num) return {PROP_MIXED, "Proper mixed number"}; if(mn->integral != 0 && mn->denom num) return {IMPROP_MIXED, "Improper mixed number"}; } post { return trunc_spec->integral == mn->integral && trunc_spec->denom == mn->denom && trunc_spec->num == mn->num /* !memcmp(trunc_spec, mn) */ && mn->denom && abs(mn->num) denum && } }

Mediators Test sequence generator Specifications Test action iterator Test scenario Mediators on SeC Target system Test engine Оракул Oracle Медиатор Mediator Specification development Mediator development Test scenario development Steps of test development using the tool: Mediators on SeC

Definition of mediators on SeC mediator for specification ( ) { call { /* map specification args to implementation ones */... if(.../* if something wrong */) setBadVerdict( ); /* implementation call */... /* map implementation results to specification ones */... if(.../* if something wrong */) setBadVerdict( ); return ; } }

Mediatorof specification function trunc_spec mediator trunc_media for specification MixNum* trunc_spec(MixNum* mn) { call { mix_num imn, res; imn.entire = mn->integral; imn.num = mn->num; imn.denom = mn->denom; res = trunc(&imn); mn->integral = imn.entire; mn->num = imn.num; mn->denom = imn.denom; return create(&MixNum_type, res.entire,res.num,res.denom); } }

Test sequence generator Scenarios Test scenario Scenario Specifications Mediators on SeC Target system Оракул Oracle Медиатор Mediator Specification development Mediator development Test scenario development Steps of test development using the tool: Test action iterator Test engine

Scenario definition scenario dfsm = {.init =,.actions = {,..., NULL },.finish = } set_coverage_ ( );

Scenario functions scenario bool () {... ( );... return ; }

Operator iterate scenario bool () {... iterate( ; ; ; ) { }... return ; } =

Control flow in scenario function scenario bool () {... iterate( ; ; ; ) {... }... return ; } Test engine

Scenario of specification function trunc_spec bool trunc_scen_init (int argc, char **argv) { set_mediator_trunc_spec (trunc_media); return true; } scenario bool trunc_sf () { iterate (int i = -10; i = 0) iterate (int denom = 1; denom <= 10; denom++;) { MixNum mn = create(&MixNum_type, res.entire, res.num, res.denom); trunc_spec (mn); } return true; } scenario dfsm trunc_scen = {.init = trunc_scen_init,.actions = { trunc_sf, NULL } };

Function main, starting scenario int main(int argc, char** argv) { ( argc, argv ); }

Function main of test for function trunc int main(int argc, char **argv) { trunc_scen(argc, argv); }