lecture 16 testing review
play

Lecture 16: Testing & Review 2015-07-13 Prof. Dr. Andreas - PDF document

Softwaretechnik / Software-Engineering Lecture 16: Testing & Review 2015-07-13 Prof. Dr. Andreas Podelski, Dr. Bernd Westphal 16 2015-07-13 main Albert-Ludwigs-Universit at Freiburg, Germany Contents of the Block


  1. Softwaretechnik / Software-Engineering Lecture 16: Testing & Review 2015-07-13 Prof. Dr. Andreas Podelski, Dr. Bernd Westphal – 16 – 2015-07-13 – main – Albert-Ludwigs-Universit¨ at Freiburg, Germany Contents of the Block “Quality Assurance” L 1: 20.4., Mo Introduction (i) Introduction and Vocabulary T 1: 23.4., Do L 2: 27.4., Mo Development • correctness illustrated L 3: 30.4., Do Process, Metrics • vocabulary: fault, error, failure L 4: 4.5., Mo • three basic approaches T 2: 7.5., Do L 5: 11.5., Mo (ii) Formal Verification - 14.5., Do L 6: 18.5., Mo Requirements • Hoare calculus L 7: 21.5., Do Engineering • Verifying C Compiler (VCC) - 25.5., Mo • over- / under-approximations - 28.5., Do T 3: 1.6., Mo - 4.6., Do (iii) (Systematic) Tests L 8: 8.6., Mo • systematic test vs. experiment L 9: 11.6., Do • classification of test procedures L 10: 15.6., Mo T 4: 18.6., Do • model-based testing L 11: 22.6., Mo • glass-box tests: coverage measures Architecture & L 12: 25.6., Do – 16 – 2015-07-13 – Scontents – Design, Software L 13: 29.6., Mo (iv) Runtime Verification L 14: 2.7., Do Modelling (v) Review T 5: 6.7., Mo L 15: 9.7., Do Quality Assurance (vi) Concluding Discussion L 16: 13.7., Mo Invited Talks L 17: 16.7., Do • Dependability T 6: 20.7., Mo Wrap-Up L 18: 23.7., Do 2 /65

  2. Contents & Goals Last Lecture: • Completed the block “Architecture & Design” This Lecture: • Educational Objectives: Capabilities for following tasks/questions. • What can we conclude from the outcome of tools like VCC? • What is an example for not a test, non-systematic test, systematic test? • Given a test case and a software, is the outcome successful or unsuccesful? • How many test cases are necessary for exhaustive testing of a given software? • Content: • The Verifying C Compiler (VCC) • Systematic test, test case, test suite – 16 – 2015-07-13 – Sprelim – • Testing notions • Coverage measures 3 /65 The Verifying C Compiler – 16 – 2015-07-13 – main – 4 /65

  3. VCC • The Verifying C Compiler (VCC) basically implements Hoare-style reasoning. • Special syntax : • #include <vcc.h> • (requires p ) — pre-condition, p is a C expression • (ensures q ) — post-condition, q is a C expression • (invariant expr ) — looop invariant, expr is a C expression • (assert p ) — intermediate invariant, p is a C expression • (writes &v) — VCC considers concurrent C programs; we need to declare for each procedure which global variables it is allowed to write to (also checked by VCC) • Special expressions : • \ thread local(&v) — no other thread writes to variable v (in pre-conditions) – 16 – 2015-07-13 – Svcc – • \ old(v) — the value of v when procedure was called (useful for post-conditions) • \ result — return value of procedure (useful for post-conditions) 5 /65 VCC Syntax Example #include < vcc . h > 1 2 i nt q , r ; 3 4 void div ( i nt x , i nt y ) 5 ( r e q u i r e s x > = 0 && y > = 0) 6 ( ensures q ∗ y + r == x && r < y ) 7 ( w r i t e s &q) 8 ( w r i t e s &r ) 9 { 10 q = 0; 11 r = x ; 12 while ( r > = y ) 13 ( i n v a r i a n t q ∗ y + r == x && r > = 0) 14 { 15 r = r − y ; 16 q = q + 1; 17 } 18 } 19 – 16 – 2015-07-13 – Svcc – DIV ≡ q := 0; r := x ; while r ≥ y do r := r − y ; q := q + 1 do { x ≥ 0 ∧ y ≥ 0 } DIV { q · y + r = x ∧ r < y } 6 /65

  4. – 16 – 2015-07-13 – Svcc – – 16 – 2015-07-13 – Svcc – VCC Architecture VCC Web-Interface 8 /65 7 /65

  5. VCC Features • For the exercises, we use VCC only for sequential, single-thread programs . • VCC checks a number of implicit assertions : • no arithmetic overflow in expressions (according to C-standard), • array-out-of-bounds access , • NULL-pointer dereference , • and many more. • VCC also supports: • concurrency : different threads may write to shared global variables; VCC can check whether concurrent access to shared variables is properly managed; • data structure invariants : we may declare invariants that have to hold for, e.g., records (e.g. the length field l is always equal to the length of the string field str ); those invariants may temporarily be violated when updating the data structure. • and much more. • Verification does not always succeed : – 16 – 2015-07-13 – Svcc – • The backend SMT-solver may not be able to discharge proof-obligations (in particular non-linear multiplication and division are challenging); • In many cases, we need to provide loop invariants manually. 9 /65 Interpretation of Results • VCC says: “ verification succeeded We can only conclude that the tool — under its interpretation of the C-standard, under its platform assumptions (32-bit), etc. — “thinks” that it can prove | = { p } DIV { q } . Can be due to an error in the tool! Yet we can ask for a printout of the proof and check it manually (hardly possible in practice) or with other tools like interactive theorem provers. Note : | = { false } f { q } always holds — so a mistake in writing down the pre-condition can provoke a false negative . • VCC says: “ verification failed – 16 – 2015-07-13 – Svcc – • One case: “timeout” etc. — completely inconclusive outcome. • The tool does not provide counter-examples in the form of a computation path. It (only) gives hints on input values satisfying p and causing a violation of q . May be a false negative if these inputs are actually never used. Make pre-condition p stronger, and try again. 10 /65

  6. – 16 – 2015-07-13 – main – Testing 12 /65

  7. Quotes On Testing “Testing is the execution of a program with the goal to discover errors.” G. J. Myers, 1979 “Testing is the demonstration of a program or system with the goal to show that it does what it is supposed to do.” W. Hetzel, 1984 “Software can be used to show the presence of bugs, but never to show their absence!” E. W. Dijkstra, 1970 – 16 – 2015-07-13 – Stestintro – Rule-of-thumb: (fairly systematic) tests discover half of all errors. (Ludewig and Lichter, 2013) 13 /65 Tests vs. Systematic Tests Test — (one or multiple) execution(s) of a program on a computer with the goal to find errors. (Ludewig and Lichter, 2013) (Our) Synonyms : Experiment, ‘Rumprobieren’. Not (even) a test (in the sense of this weak definition) : • any inspection of the program, • demo of the program, • analysis by software-tools, e.g. for values of metrics, • investigation of the program with a debugger. Systematic Test — a test with • (environment) conditions are defined or precisely documented, • inputs have been chosen systematically, – 16 – 2015-07-13 – Stestintro – • results documented and assessed according to criteria that have been fixed before. (Ludewig and Lichter, 2013) In the following : experiment := test — test := systematic test. 14 /65

  8. More Formally: Test Case • A test case T is a set of pairs { ( In 1 , Soll 1 ) , . . . } consisting of • a (description of a) finite input sequence In i (pairwise different in T ), • a (description of a) finite set of expected computation path Soll i . Examples : • T 1 = ( FILLUP , C50 ; water button on ) (shorthand notation) (fill up vending machine (at any time after power on), insert C50 coin (at any time), expect water button is enabled (some time later)) α i α 1 • T 2 = { ( σ i → σ i 1 → σ 1 ) | σ i − − 1 ; σ 0 − − 0 ( x ) = 7 ∧ σ 1 ( y ) = 49 } 0 (input 7, expect output 49, don’t care for other variables’ values; shorthand notation: (7; 49) ) ǫ ǫ • T 3 = { ( σ i → σ i → σ 1 ) } σ i 0 = σ i − 1 ; σ 0 − 0 = 0[ x := 7] , σ 0 = 0 , σ 1 = 0[ y := 49] 0 – 16 – 2015-07-13 – Stestintro – (each and every variable value at start and at end fixed) 15 /65 Test Case Execution, Test Suite – 16 – 2015-07-13 – Stestintro – 16 /65

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend