46
©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 22 Slide 1 Verification and Validation

Verification and Validation · PDF fileTo introduce software verification and validation and ... They parse the program text and try to ... Chapter 22 Slide 31 Static analysis checks

  • Upload
    vanhanh

  • View
    256

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Verification and Validation · PDF fileTo introduce software verification and validation and ... They parse the program text and try to ... Chapter 22 Slide 31 Static analysis checks

©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 22 Slide 1

Verification and Validation

Page 2: Verification and Validation · PDF fileTo introduce software verification and validation and ... They parse the program text and try to ... Chapter 22 Slide 31 Static analysis checks

©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 22 Slide 2

Objectives

● To introduce software verification and validation andto discuss the distinction between them

● To describe the program inspection process and itsrole in V & V

● To explain static analysis as a verification technique

● To describe the Cleanroom software developmentprocess

Page 3: Verification and Validation · PDF fileTo introduce software verification and validation and ... They parse the program text and try to ... Chapter 22 Slide 31 Static analysis checks

©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 22 Slide 3

Topics covered

● Verification and validation planning

● Software inspections

● Automated static analysis

● Cleanroom software development

Page 4: Verification and Validation · PDF fileTo introduce software verification and validation and ... They parse the program text and try to ... Chapter 22 Slide 31 Static analysis checks

©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 22 Slide 4

● Verification:"Are we building the product right”.

● The software should conform to itsspecification.

● Validation: "Are we building the right product”.

● The software should do what the user reallyrequires.

Verification vs validation

Page 5: Verification and Validation · PDF fileTo introduce software verification and validation and ... They parse the program text and try to ... Chapter 22 Slide 31 Static analysis checks

©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 22 Slide 5

● Is a whole life-cycle process - V & V must beapplied at each stage in the softwareprocess.

● Has two principal objectives• The discovery of defects in a system;

• The assessment of whether or not the system isuseful and useable in an operational situation.

The V & V process

Page 6: Verification and Validation · PDF fileTo introduce software verification and validation and ... They parse the program text and try to ... Chapter 22 Slide 31 Static analysis checks

©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 22 Slide 6

V& V goals

● Verification and validation should establishconfidence that the software is fit forpurpose.

● This does NOT mean completely free ofdefects.

● Rather, it must be good enough for itsintended use and the type of use willdetermine the degree of confidence that isneeded.

Page 7: Verification and Validation · PDF fileTo introduce software verification and validation and ... They parse the program text and try to ... Chapter 22 Slide 31 Static analysis checks

©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 22 Slide 7

V & V confidence

● Depends on system’s purpose, userexpectations and marketing environment• Software function

• The level of confidence depends on how critical thesoftware is to an organisation.

• User expectations• Users may have low expectations of certain kinds of

software.

• Marketing environment• Getting a product to market early may be more

important than finding defects in the program.

Page 8: Verification and Validation · PDF fileTo introduce software verification and validation and ... They parse the program text and try to ... Chapter 22 Slide 31 Static analysis checks

©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 22 Slide 8

● Software inspections. Concerned with analysis ofthe static system representation to discoverproblems (static verification)• May be supplement by tool-based document and code

analysis

● Software testing. Concerned with exercising andobserving product behaviour (dynamic verification)• The system is executed with test data and its operational

behaviour is observed

Static and dynamic verification

Page 9: Verification and Validation · PDF fileTo introduce software verification and validation and ... They parse the program text and try to ... Chapter 22 Slide 31 Static analysis checks

©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 22 Slide 9

Static and dynamic V&V

Page 10: Verification and Validation · PDF fileTo introduce software verification and validation and ... They parse the program text and try to ... Chapter 22 Slide 31 Static analysis checks

©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 22 Slide 10

● Can reveal the presence of errors NOT theirabsence.

● The only validation technique for non-functional requirements as the software hasto be executed to see how it behaves.

● Should be used in conjunction with staticverification to provide full V&V coverage.

Program testing

Page 11: Verification and Validation · PDF fileTo introduce software verification and validation and ... They parse the program text and try to ... Chapter 22 Slide 31 Static analysis checks

©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 22 Slide 11

● Defect testing• Tests designed to discover system defects.

• A successful defect test is one which reveals thepresence of defects in a system.

• Covered in Chapter 23

● Validation testing• Intended to show that the software meets its

requirements.

• A successful test is one that shows that a requirementshas been properly implemented.

Types of testing

Page 12: Verification and Validation · PDF fileTo introduce software verification and validation and ... They parse the program text and try to ... Chapter 22 Slide 31 Static analysis checks

©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 22 Slide 12

● Defect testing and debugging are distinctprocesses.

● Verification and validation is concerned withestablishing the existence of defects in a program.

● Debugging is concerned with locating andrepairing these errors.

● Debugging involves formulating a hypothesisabout program behaviour then testing thesehypotheses to find the system error.

Testing and debugging

Page 13: Verification and Validation · PDF fileTo introduce software verification and validation and ... They parse the program text and try to ... Chapter 22 Slide 31 Static analysis checks

©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 22 Slide 13

The debugging process

Page 14: Verification and Validation · PDF fileTo introduce software verification and validation and ... They parse the program text and try to ... Chapter 22 Slide 31 Static analysis checks

©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 22 Slide 14

● Careful planning is required to get the mostout of testing and inspection processes.

● Planning should start early in thedevelopment process.

● The plan should identify the balancebetween static verification and testing.

● Test planning is about defining standards forthe testing process rather than describingproduct tests.

V & V planning

Page 15: Verification and Validation · PDF fileTo introduce software verification and validation and ... They parse the program text and try to ... Chapter 22 Slide 31 Static analysis checks

©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 22 Slide 15

The V-model of development

Page 16: Verification and Validation · PDF fileTo introduce software verification and validation and ... They parse the program text and try to ... Chapter 22 Slide 31 Static analysis checks

©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 22 Slide 16

The structure of a software test plan

● The testing process.

● Requirements traceability.

● Tested items.

● Testing schedule.

● Test recording procedures.

● Hardware and software requirements.

● Constraints.

Page 17: Verification and Validation · PDF fileTo introduce software verification and validation and ... They parse the program text and try to ... Chapter 22 Slide 31 Static analysis checks

©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 22 Slide 17

The software test plan

The testing processA description of the major phases of the testing process. These might beas described earlier in this chapter.

Requirements traceabilityUsers are most interested in the system meeting its requirements andtesting should be planned so that all requirements are individually tested.

Tested itemsThe products of the software process that are to be tested should bespecified.

Testing scheduleAn overall testing schedule and resource allocation for this schedule.This, obviously, is linked to the more general project developmentschedule.

Test recording proceduresIt is not enough simply to run tests. The results of the tests must besystematically recorded. It must be possible to audit the testing processto check that it been carried out correctly.

Hardware and software requirementsThis section should set out software tools required and estimatedhardware utilisation.

ConstraintsConstraints affecting the testing process such as staff shortages shouldbe anticipated in this section.

Page 18: Verification and Validation · PDF fileTo introduce software verification and validation and ... They parse the program text and try to ... Chapter 22 Slide 31 Static analysis checks

©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 22 Slide 18

Software inspections

● These involve people examining the sourcerepresentation with the aim of discovering anomaliesand defects.

● Inspections not require execution of a system somay be used before implementation.

● They may be applied to any representation of thesystem (requirements, design,configuration data,test data, etc.).

● They have been shown to be an effective techniquefor discovering program errors.

Page 19: Verification and Validation · PDF fileTo introduce software verification and validation and ... They parse the program text and try to ... Chapter 22 Slide 31 Static analysis checks

©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 22 Slide 19

Inspection success

● Many different defects may be discovered ina single inspection. In testing, one defect,may mask another so several executionsare required.

● The reuse domain and programmingknowledge so reviewers are likely to haveseen the types of error that commonly arise.

Page 20: Verification and Validation · PDF fileTo introduce software verification and validation and ... They parse the program text and try to ... Chapter 22 Slide 31 Static analysis checks

©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 22 Slide 20

Inspections and testing

● Inspections and testing are complementary and notopposing verification techniques.

● Both should be used during the V & V process.

● Inspections can check conformance with aspecification but not conformance with thecustomer’s real requirements.

● Inspections cannot check non-functionalcharacteristics such as performance, usability, etc.

Page 21: Verification and Validation · PDF fileTo introduce software verification and validation and ... They parse the program text and try to ... Chapter 22 Slide 31 Static analysis checks

©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 22 Slide 21

Program inspections

● Formalised approach to document reviews

● Intended explicitly for defect detection (notcorrection).

● Defects may be logical errors, anomalies inthe code that might indicate an erroneouscondition (e.g. an uninitialised variable) ornon-compliance with standards.

Page 22: Verification and Validation · PDF fileTo introduce software verification and validation and ... They parse the program text and try to ... Chapter 22 Slide 31 Static analysis checks

©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 22 Slide 22

Inspection pre-conditions

● A precise specification must be available.

● Team members must be familiar with theorganisation standards.

● Syntactically correct code or other systemrepresentations must be available.

● An error checklist should be prepared.

● Management must accept that inspection willincrease costs early in the software process.

● Management should not use inspections for staffappraisal ie finding out who makes mistakes.

Page 23: Verification and Validation · PDF fileTo introduce software verification and validation and ... They parse the program text and try to ... Chapter 22 Slide 31 Static analysis checks

©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 22 Slide 23

The inspection process

Page 24: Verification and Validation · PDF fileTo introduce software verification and validation and ... They parse the program text and try to ... Chapter 22 Slide 31 Static analysis checks

©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 22 Slide 24

Inspection procedure

● System overview presented to inspectionteam.

● Code and associated documents aredistributed to inspection team in advance.

● Inspection takes place and discovered errorsare noted.

● Modifications are made to repair discoverederrors.

● Re-inspection may or may not be required.

Page 25: Verification and Validation · PDF fileTo introduce software verification and validation and ... They parse the program text and try to ... Chapter 22 Slide 31 Static analysis checks

©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 22 Slide 25

Inspection roles

Author or owner The programmer or designer responsible forproducing the program or document. Responsiblefor fixing defects discovered during the inspectionprocess.

Inspector Finds errors, omissions and inconsistencies inprograms and documents. May also identifybroader issues that are outside the scope of theinspection team.

Reader Presents the code or document at an inspectionmeeting.

Scribe Records the results of the inspection meeting.

Chairman or moderator Manages the process and facilitates the inspection.Reports process results to the Chief moderator.

Chief moderator Responsible for inspection process improvements,checklist updating, standards development etc.

Page 26: Verification and Validation · PDF fileTo introduce software verification and validation and ... They parse the program text and try to ... Chapter 22 Slide 31 Static analysis checks

©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 22 Slide 26

Inspection checklists

● Checklist of common errors should be used todrive the inspection.

● Error checklists are programming languagedependent and reflect the characteristic errors thatare likely to arise in the language.

● In general, the 'weaker' the type checking, the largerthe checklist.

● Examples: Initialisation, Constant naming, looptermination, array bounds, etc.

Page 27: Verification and Validation · PDF fileTo introduce software verification and validation and ... They parse the program text and try to ... Chapter 22 Slide 31 Static analysis checks

©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 22 Slide 27

Inspection checks 1

Data faults Are all program variables initialised before their values areused?Have all constants been named?Should the upper bound of arrays be equal to the size of thearray or Size -1?If character strings are used, is a de limiter explicitlyassigned?Is there any possibility of buffer overflow?

Control faults For each conditional statement, is the condition correct?Is each loop certain to terminate?Are compound statements correctly bracketed?In case statements, are all possible cases accounted for?If a break is required after each case in case statements, hasit been included?

Input/output faults Are all input variables used?Are all output variables assigned a value before they areoutput?Can unexpected inputs cause corruption?

Page 28: Verification and Validation · PDF fileTo introduce software verification and validation and ... They parse the program text and try to ... Chapter 22 Slide 31 Static analysis checks

©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 22 Slide 28

Inspection checks 2

Interface faults Do all function and method calls have the correct numberof parameters?Do formal and actual parameter types match?Are the parameters in the right order?If components access shared memory, do they have thesame model of the shared memory structure?

Storagemanagement faults

If a linked structure is modified, have all links beencorrectly reassigned?If dynamic storage is used, has space been allocatedcorrectly?Is space explicitly de-allocated after it is no longerrequired?

Exceptionmanagement faults

Have all possible error conditions been taken into account?

Page 29: Verification and Validation · PDF fileTo introduce software verification and validation and ... They parse the program text and try to ... Chapter 22 Slide 31 Static analysis checks

©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 22 Slide 29

Inspection rate

● 500 statements/hour during overview.

● 125 source statement/hour during individualpreparation.

● 90-125 statements/hour can be inspected.

● Inspection is therefore an expensiveprocess.

● Inspecting 500 lines costs about 40man/hours effort - about £2800 at UK rates.

Page 30: Verification and Validation · PDF fileTo introduce software verification and validation and ... They parse the program text and try to ... Chapter 22 Slide 31 Static analysis checks

©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 22 Slide 30

Automated static analysis

● Static analysers are software tools for sourcetext processing.

● They parse the program text and try todiscover potentially erroneous conditions andbring these to the attention of the V & Vteam.

● They are very effective as an aid toinspections - they are a supplement to butnot a replacement for inspections.

Page 31: Verification and Validation · PDF fileTo introduce software verification and validation and ... They parse the program text and try to ... Chapter 22 Slide 31 Static analysis checks

©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 22 Slide 31

Static analysis checks

Fault class Static analysis check

Data faults Variables used before initialisationVariables declared but never usedVariables assigned twice but never used betweenassignmentsPossible array bound violationsUndeclared variables

Control faults Unreachable codeUnconditional branches into loops

Input/output faults Variables output twice with no interveningassignment

Interface faults Parameter type mismatchesParameter number mismatchesNon-usage of the results of functionsUncalled functions and procedures

Storage managementfaults

Unassigned pointersPointer arithmetic

Page 32: Verification and Validation · PDF fileTo introduce software verification and validation and ... They parse the program text and try to ... Chapter 22 Slide 31 Static analysis checks

©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 22 Slide 32

Stages of static analysis

● Control flow analysis. Checks for loops withmultiple exit or entry points, finds unreachablecode, etc.

● Data use analysis. Detects uninitialisedvariables, variables written twice without anintervening assignment, variables which aredeclared but never used, etc.

● Interface analysis. Checks the consistency ofroutine and procedure declarations and theiruse

Page 33: Verification and Validation · PDF fileTo introduce software verification and validation and ... They parse the program text and try to ... Chapter 22 Slide 31 Static analysis checks

©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 22 Slide 33

Stages of static analysis

● Information flow analysis. Identifies thedependencies of output variables. Does notdetect anomalies itself but highlightsinformation for code inspection or review

● Path analysis. Identifies paths through theprogram and sets out the statementsexecuted in that path. Again, potentiallyuseful in the review process

● Both these stages generate vast amounts ofinformation. They must be used with care.

Page 34: Verification and Validation · PDF fileTo introduce software verification and validation and ... They parse the program text and try to ... Chapter 22 Slide 31 Static analysis checks

©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 22 Slide 34

LINT static analysis

138% more lint_ex.c#include <stdio.h>printarray (Anarray) int Anarray;{ printf(“%d”,Anarray); }

main (){ int Anarray[5]; int i; char c; printarray (Anarray, i, c); printarray (Anarray) ;}

139% cc lint_ex.c140% lint lint_ex.c

lint_ex.c(10): warning: c may be used before setlint_ex.c(10): warning: i may be used before setprintarray: variable # of args. lint_ex.c(4) :: lint_ex.c(10)printarray, arg. 1 used inconsistently lint_ex.c(4) :: lint_ex.c(10)printarray, arg. 1 used inconsistently lint_ex.c(4) :: lint_ex.c(11)printf returns value which is always ignored

Page 35: Verification and Validation · PDF fileTo introduce software verification and validation and ... They parse the program text and try to ... Chapter 22 Slide 31 Static analysis checks

©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 22 Slide 35

Use of static analysis

● Particularly valuable when a language suchas C is used which has weak typing andhence many errors are undetected by thecompiler,

● Less cost-effective for languages like Javathat have strong type checking and cantherefore detect many errors duringcompilation.

Page 36: Verification and Validation · PDF fileTo introduce software verification and validation and ... They parse the program text and try to ... Chapter 22 Slide 31 Static analysis checks

©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 22 Slide 36

Verification and formal methods

● Formal methods can be used when amathematical specification of the system isproduced.

● They are the ultimate static verificationtechnique.

● They involve detailed mathematical analysisof the specification and may develop formalarguments that a program conforms to itsmathematical specification.

Page 37: Verification and Validation · PDF fileTo introduce software verification and validation and ... They parse the program text and try to ... Chapter 22 Slide 31 Static analysis checks

©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 22 Slide 37

Arguments for formal methods

● Producing a mathematical specificationrequires a detailed analysis of therequirements and this is likely to uncovererrors.

● They can detect implementation errorsbefore testing when the program is analysedalongside the specification.

Page 38: Verification and Validation · PDF fileTo introduce software verification and validation and ... They parse the program text and try to ... Chapter 22 Slide 31 Static analysis checks

©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 22 Slide 38

Arguments against formal methods

● Require specialised notations that cannot beunderstood by domain experts.

● Very expensive to develop a specificationand even more expensive to show that aprogram meets that specification.

● It may be possible to reach the same level ofconfidence in a program more cheaply usingother V & V techniques.

Page 39: Verification and Validation · PDF fileTo introduce software verification and validation and ... They parse the program text and try to ... Chapter 22 Slide 31 Static analysis checks

©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 22 Slide 39

● The name is derived from the 'Cleanroom'process in semiconductor fabrication. Thephilosophy is defect avoidance rather thandefect removal.

● This software development process is based on:• Incremental development;

• Formal specification;

• Static verification using correctness arguments;

• Statistical testing to determine program reliability.

Cleanroom software development

Page 40: Verification and Validation · PDF fileTo introduce software verification and validation and ... They parse the program text and try to ... Chapter 22 Slide 31 Static analysis checks

©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 22 Slide 40

The Cleanroom process

Page 41: Verification and Validation · PDF fileTo introduce software verification and validation and ... They parse the program text and try to ... Chapter 22 Slide 31 Static analysis checks

©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 22 Slide 41

Cleanroom process characteristics

● Formal specification using a state transitionmodel.

● Incremental development where thecustomer prioritises increments.

● Structured programming - limited control andabstraction constructs are used in theprogram.

● Static verification using rigorous inspections.● Statistical testing of the system (covered in

Ch. 24).

Page 42: Verification and Validation · PDF fileTo introduce software verification and validation and ... They parse the program text and try to ... Chapter 22 Slide 31 Static analysis checks

©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 22 Slide 42

Formal specification and inspections

● The state based model is a systemspecification and the inspection processchecks the program against this mode.l

● The programming approach is defined sothat the correspondence between the modeland the system is clear.

● Mathematical arguments (not proofs) areused to increase confidence in the inspectionprocess.

Page 43: Verification and Validation · PDF fileTo introduce software verification and validation and ... They parse the program text and try to ... Chapter 22 Slide 31 Static analysis checks

©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 22 Slide 43

● Specification team. Responsible for developingand maintaining the system specification.

● Development team. Responsible fordeveloping and verifying the software. Thesoftware is NOT executed or even compiledduring this process.

● Certification team. Responsible for developinga set of statistical tests to exercise the softwareafter development. Reliability growth modelsused to determine when reliability is acceptable.

Cleanroom process teams

Page 44: Verification and Validation · PDF fileTo introduce software verification and validation and ... They parse the program text and try to ... Chapter 22 Slide 31 Static analysis checks

©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 22 Slide 44

● The results of using the Cleanroom process havebeen very impressive with few discovered faults indelivered systems.

● Independent assessment shows that theprocess is no more expensive than otherapproaches.

● There were fewer errors than in a 'traditional'development process.

● However, the process is not widely used. It is notclear how this approach can be transferredto an environment with less skilled or lessmotivated software engineers.

Cleanroom process evaluation

Page 45: Verification and Validation · PDF fileTo introduce software verification and validation and ... They parse the program text and try to ... Chapter 22 Slide 31 Static analysis checks

©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 22 Slide 45

Key points

● Verification and validation are not the samething. Verification shows conformance withspecification; validation shows that theprogram meets the customer’s needs.

● Test plans should be drawn up to guide thetesting process.

● Static verification techniques involveexamination and analysis of the program forerror detection.

Page 46: Verification and Validation · PDF fileTo introduce software verification and validation and ... They parse the program text and try to ... Chapter 22 Slide 31 Static analysis checks

©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 22 Slide 46

Key points

● Program inspections are very effective indiscovering errors.

● Program code in inspections is systematicallychecked by a small team to locate software faults.

● Static analysis tools can discover programanomalies which may be an indication of faults in thecode.

● The Cleanroom development process depends onincremental development, static verification andstatistical testing.