Testing. ECE/CS 5780/6780: Embedded System Design. Why is testing so hard? Why do testing?

Similar documents
In this Lecture you will Learn: Testing in Software Development Process. What is Software Testing. Static Testing vs.

Administrivia. ECE/CS 5780/6780: Embedded System Design. Acknowledgements. What is verification?

WHY TEST SOFTWARE?...

Lecture 15 Software Testing

Darshan Institute of Engineering & Technology for Diploma Studies

Testing. Prof. Clarkson Fall Today s music: Wrecking Ball by Miley Cyrus

Black Box Testing. EEC 521: Software Engineering. Specification-Based Testing. No Source Code. Software Testing

Testing! Prof. Leon Osterweil! CS 520/620! Spring 2013!

No Source Code. EEC 521: Software Engineering. Specification-Based Testing. Advantages

CS 520 Theory and Practice of Software Engineering Fall 2018

Computer Science and Software Engineering University of Wisconsin - Platteville 9-Software Testing, Verification and Validation

Principles of Software Construction: Objects, Design, and Concurrency (Part 2: Designing (Sub )Systems)

(From Glenford Myers: The Art of Software Testing)

Testing Objectives. Successful testing: discovers previously unknown errors

Learning outcomes. Systems Engineering. Debugging Process. Debugging Process. Review

Part 5. Verification and Validation

CS/ECE 5780/6780: Embedded System Design

Regression testing. Whenever you find a bug. Why is this a good idea?

Introduction to Dynamic Analysis

Software Testing CS 408

Overview. State-of-the-Art. Relative cost of error correction. CS 619 Introduction to OO Design and Development. Testing.

Software Quality. Richard Harris

CSE 374 Programming Concepts & Tools. Hal Perkins Fall 2015 Lecture 15 Testing

Ingegneria del Software Corso di Laurea in Informatica per il Management

Basic Definitions: Testing

Introduction to Problem Solving and Programming in Python.

Oracle Developer Studio Code Analyzer

CSE 403: Software Engineering, Fall courses.cs.washington.edu/courses/cse403/16au/ Unit Testing. Emina Torlak

Chapter 9. Software Testing

Software Design Models, Tools & Processes. Lecture 6: Transition Phase Cecilia Mascolo

Chapter 8 Software Testing. Chapter 8 Software testing

Steps for project success. git status. Milestones. Deliverables. Homework 1 submitted Homework 2 will be posted October 26.

Examination Questions Time allowed: 1 hour 15 minutes

Objectives. Chapter 19. Verification vs. validation. Topics covered. Static and dynamic verification. The V&V process

Outline. software testing: search bugs black-box and white-box testing static and dynamic testing

Software Testing 101 or Why Should We Bother With Software Testing?

Chap 2. Introduction to Software Testing

CMSC 132: OBJECT-ORIENTED PROGRAMMING II

Simulink 모델과 C/C++ 코드에대한매스웍스의정형검증툴소개 The MathWorks, Inc. 1

ECE 587 Hardware/Software Co-Design Lecture 11 Verification I

Ready to Automate? Ready to Automate?

Software Testing. Testing: Our Experiences

Improving Software Testability

Quote by Bruce Sterling, from: A Software Testing Primer, Nick Jenkins

Verification and Validation

Verification and Validation

White-Box Testing Techniques

Second assignment came out Monday evening. Find defects in Hnefetafl rules written by your classmates. Topic: Code Inspection and Testing

Three General Principles of QA. COMP 4004 Fall Notes Adapted from Dr. A. Williams

Cursul Aprilie

CS 520 Theory and Practice of Software Engineering Fall 2018

Chapter 11, Testing. Using UML, Patterns, and Java. Object-Oriented Software Engineering

Why testing and analysis. Software Testing. A framework for software testing. Outline. Software Qualities. Dependability Properties

Verification and Test with Model-Based Design

An Introduction to Systematic Software Testing. Robert France CSU

Testing is executing a system in order to identify any gaps, errors, or missing requirements in contrary to the actual requirements.

International Journal of Computer Engineering and Applications, Volume XII, Special Issue, September 18, ISSN SOFTWARE TESTING

Software Engineering and Scientific Computing

Topics in Software Testing

Manuel Oriol, CHCRC-C, Software Testing ABB

Program Analysis. Program Analysis

Computer aided verification

1 Visible deviation from the specification or expected behavior for end-user is called: a) an error b) a fault c) a failure d) a defect e) a mistake

Honours/Master/PhD Thesis Projects Supervised by Dr. Yulei Sui

WHITE PAPER. 10 Reasons to Use Static Analysis for Embedded Software Development

Introduction to Software Testing Chapter 5.1 Syntax-based Testing

MONIKA HEINER.

DART: Directed Automated Random Testing. CUTE: Concolic Unit Testing Engine. Slide Source: Koushik Sen from Berkeley

VERIFYING SOFTWARE ROBUSTNESS. Ross Collard Collard & Company

Sample Question Paper. Software Testing (ETIT 414)

International Journal of Computer Engineering and Applications, Volume XII, Special Issue, April- ICITDA 18,

Software Testing part II (white box) Lecturer: Giuseppe Santucci

Security Testing. John Slankas

Software Testing Lecture 1. Justin Pearson

Topics. Software Testing Test Driven Development Black Box Testing Unit Testing White Box Testing Coverage Testing Software Debugging

DESIGN AS RISK MINIMIZATION

People tell me that testing is

Sample Exam Syllabus

Functional verification on PIL mode with IAR Embedded Workbench

Program Analysis Tools

Verification and Validation

lecture'7:' quality'assurance'

Verification Using Static Analysis

Types of Software Testing: Different Testing Types with Details

csc444h:& so(ware&engineering&i&

Implementation and Verification Daniel MARTINS Application Engineer MathWorks

Static Analysis and Bugfinding

(See related materials in textbook.) CSE 435: Software Engineering (slides adapted from Ghezzi et al & Stirewalt

Write perfect C code to solve the three problems below.

Testing, code coverage and static analysis. COSC345 Software Engineering

Verification Overview Testing Theory and Principles Testing in Practice. Verification. Miaoqing Huang University of Arkansas 1 / 80

Reset and Initialization, the Good, the Bad and the Ugly

Finding Firmware Defects Class T-18 Sean M. Beatty

Global Optimization. Lecture Outline. Global flow analysis. Global constant propagation. Liveness analysis. Local Optimization. Global Optimization

Program Correctness and Efficiency. Chapter 2

It is primarily checking of the code and/or manually reviewing the code or document to find errors This type of testing can be used by the developer

Programming Embedded Systems

Leveraging Formal Methods for Verifying Models and Embedded Code Prashant Mathapati Application Engineering Group

Developing AUTOSAR Compliant Embedded Software Senior Application Engineer Sang-Ho Yoon

Chapter 10. Testing and Quality Assurance

Transcription:

Testing ECE/CS 5780/6780: Embedded System Design Scott R. Little Lecture 24: Introduction to Software Testing and Verification What is software testing? Running a program in order to find bugs (faults, defects, errors, flaws, etc.). What is not software testing? Static analysis: examining the source code to find bugs without executing the code. This is useful but technically not testing. Scott R. Little (Lecture 24: SW Testing) ECE/CS 5780/6780 1 / 25 Scott R. Little (Lecture 24: SW Testing) ECE/CS 5780/6780 2 / 25 Why do testing? Why is testing so hard? You need some tests to pass the code review. Your boss requires it. The product must adhere to specific safety standards. You want to prove your code correct. The number of possible input combinations is astronomical. How do you choose the input combinations to test? It requires extra time and effort. Scott R. Little (Lecture 24: SW Testing) ECE/CS 5780/6780 3 / 25 Scott R. Little (Lecture 24: SW Testing) ECE/CS 5780/6780 4 / 25

Stages of testing Unit Testing Unit testing: the first phase done by module developers. Integration testing: combines the modules (that have already been thoroughly tested at the unit level) and tests interactions. System testing: tests the entire program. Unit testing is more than just testing I/O relations. Unit tests should check intermediate computations, execution paths, etc. Three key components to a unit testing framework are: Harnesses. Stubs. Instrumentation. Many frameworks exist to aid in writing unit tests. Scott R. Little (Lecture 24: SW Testing) ECE/CS 5780/6780 5 / 25 Scott R. Little (Lecture 24: SW Testing) ECE/CS 5780/6780 6 / 25 Harnesses Stubs A framework used to run tests and analyze their results. Are often automatically generated. Include a suite of tests to run. Automatically generated tests are a start but should not be the end as they tend to be too generic. Code that replaces the actual implementation. Some code may run very slowly, so using a stub is efficient. Some code may not yet be written, so using a stub is necessary. Some code may be complex, so using a stub is impractical. Scott R. Little (Lecture 24: SW Testing) ECE/CS 5780/6780 7 / 25 Scott R. Little (Lecture 24: SW Testing) ECE/CS 5780/6780 8 / 25

Instrumentation Regression Testing Adding debug information into your code. For example: timing, resource usage, etc. Should be easily compiled in or out. Often the information is written to log files. Automated tools can be very useful here. Profilers fall into this category. Changes to the code can and often break the code (i.e. the software regresses). To help prevent this a set of tests are run on the code to find errors introduced by code changes. This regression suite is automatically run periodically (at check-in, every night, etc.). Developers are notified when the regression suite uncovers a flaw in their code. Selecting a small but effective set of tests for the regression is the hard part. Scott R. Little (Lecture 24: SW Testing) ECE/CS 5780/6780 9 / 25 Scott R. Little (Lecture 24: SW Testing) ECE/CS 5780/6780 10 / 25 How do we know if a test fails? Black-box Testing The program should not crash (seg fault). Assertions should not be violated. Use a golden reference (it is automatable). Hand inspection. Testing does not look at the source code or internal structure of the program. Send the program a stream of inputs then observe the outputs. Abstracts away the internals which is useful for high-level testing. Scott R. Little (Lecture 24: SW Testing) ECE/CS 5780/6780 11 / 25 Scott R. Little (Lecture 24: SW Testing) ECE/CS 5780/6780 12 / 25

White-box Testing Coverage Metrics I Use the source code or code structure to design test cases. This leads us to the ideas of coverage. Used to measure the quality of the test suite. Helps answer questions like: Do I need more tests? What areas of the system are well tested? Which tests should I write next? Coverage metrics are not perfect, but they are a useful guide. Scott R. Little (Lecture 24: SW Testing) ECE/CS 5780/6780 13 / 25 Scott R. Little (Lecture 24: SW Testing) ECE/CS 5780/6780 14 / 25 Coverage Metrics II Code Coverage Metrics Achieving 100% coverage is not the goal. Finding bugs in the goal. 100% coverage does not prove that the program cannot fail. Line: Is every line of code executed? Branch: Is the positive and negative of every branch taken? Expression: Are all legal expression values executed? Path: Are all paths in the CFG executed? Scott R. Little (Lecture 24: SW Testing) ECE/CS 5780/6780 15 / 25 Scott R. Little (Lecture 24: SW Testing) ECE/CS 5780/6780 16 / 25

Mutation Testing Faults, Errors, and Failures A mutation of a program is a version of the program with one or more random changes. Mutation testing is another way to measure test suite quality. The test suite is run on the mutations. If these mutations are not found by the test suite there should be concern. Of course, it is not trivial to generate good mutants. Fault: a static flaw in a program. Error: a bad program state that results from a fault. Failure: an observable incorrect behavior of a program as a result of an error. Scott R. Little (Lecture 24: SW Testing) ECE/CS 5780/6780 17 / 25 Scott R. Little (Lecture 24: SW Testing) ECE/CS 5780/6780 18 / 25 Exposing a fault Controllability and Observability Reachability: the test must actually reach and execute the location of the fault. Infection: the fault must actually corrupt the program state. Propagation: the error must persist and cause incorrect output. To expose faults we need to be able to control the program and observe the fault. Controllability: How easy is it to drive the program into a desired state? Observability: How easy is it to push faults to the output? Scott R. Little (Lecture 24: SW Testing) ECE/CS 5780/6780 19 / 25 Scott R. Little (Lecture 24: SW Testing) ECE/CS 5780/6780 20 / 25

Test-driven Development Simulation and Stubbing One way to design for testability is to write the test cases before the code (extreme programming and agile development). This forces observability and controllability. Reduces the temptation to adjust tests to the program behavior. A key to controllable code is simulation and stubbing. Simulation Usually done for hardware interfaces. Real hardware may be slow, scarce, and hard to control. Stubbing Usually done for other code. Not all code is complete, fast, or easy to control. Scott R. Little (Lecture 24: SW Testing) ECE/CS 5780/6780 21 / 25 Scott R. Little (Lecture 24: SW Testing) ECE/CS 5780/6780 22 / 25 Assertions Static Analysis Assertions can improve observability by making errors into failures. Assertions can also improve observability by making the error rather than the failure visible. Identifies potential bugs without actually executing the code. For example: Uninitialized variables. Stack/buffer overflow. Out of bounds array accesses. Resource leaks. Historically static analysis has been plagued with excessive false positives. Lint was developed in the late 1970s. The ratio of reported to actual defects was often 10:1 or greater. Tools are improving, but scalability is still a problem. Scott R. Little (Lecture 24: SW Testing) ECE/CS 5780/6780 23 / 25 Scott R. Little (Lecture 24: SW Testing) ECE/CS 5780/6780 24 / 25

Formal tools Formal methods can prove programs correct. In reality, they find a different set of bugs. Formal tools are currently used for very specific tasks. SPIN - detects deadlock in concurrent programs. SLAM - checks that Windows Device Drivers meet common specifications. Scott R. Little (Lecture 24: SW Testing) ECE/CS 5780/6780 25 / 25