W01P1-Intro
W01P1-Intro
Quality Assurance
Software Testing, Quality Assurance, and Maintenance
Winter 2018
2
2
Software is Everywhere
3
3
Infamous Software Disasters
http://www5.in.tum.de/~huckle/bugse.html
4
4
http://envisage-project.eu/proving-android-java-and-python-sorting-algorithm-is-broken-and-how-to-fix-it/
5
5
Why so many bugs?
6
6
What Software Engineers Need Are …
Tools that give better confidence than ad-hoc testing while remaining
easy to use
7
7
Testing
8
8
“Program testing can be a very effective way to show the
presence of bugs, but is hopelessly inadequate for showing
their absence.”
Edsger W. Dijkstra
input x
if (hash(x) == 10) {
...
}
9
9
“Beware of bugs in the above code; I have only proved it correct, not
tried it.”
Donald Knuth
10
10
Verification / Quality Assurance
11
11
Ultimate Goal: Static Program Analysis
Automated Correct
Program
Analysis
Specification Incorrect
13
13
Undecidability
Rice’s Theorem
• for any non-trivial property of partial functions, no general and effective
method can decide whether an algorithm computes a partial function with that
property
• in practice, this means that there is no machine that can always decide
whether the language of a given Turing machine has a particular nontrivial
property
• https://en.wikipedia.org/wiki/Rice%27s_theorem
14
14
LEGO Turing Machine
BEGIN:
READ
CJUMP0 CASE_0
CASE_1:
WRITE 0
MOVE R
JUMP BEGIN
CASE_0:
WRITE 1
MOVE R
JUMP BEGIN
15
15
Living with Undecidability
Programmer Assistance
• annotations, pre-, post-conditions, inductive invariants
Deductive Verification 16
16
(User) Effort vs (Verification) Assurance
Deductive
Assurance/Coverage
Verification
Automated
Verification
Symbolic
Execution
Testing
Effort 17
17
Formal Software Analysis
J. McCarthy, “A basis for mathematical theory of computation”,
1963.
19
19
Turing, 1949 Alan M. Turing. “Checking a large routine”, 1949
20
20
20
21
21
method factorial (n: int) returns (v:int)
{
v := 1;
if (n == 1) { return v; }
var i := 2;
while (i <= n)
{
v := i * v;
i := i + 1;
}
return v;
}
22
22
method factorial (n: int) returns (v:int)
requires n >= 0;
ensures v = fact(n);
{
v := 1;
if (n <= 1) { return v; }
var i := 2;
while (i <= n)
invariant i <= n+1
invariant v = fact(i-1)
{
v := i * v;
i := i + 1;
}
return v;
}
23
23
Proving inductive invariants
24
24
Proving inductive invariants
Deductive Verification
• A user provides a program and a verification certificate
– e.g., inductive invariant, pre- and post-conditions, function summaries, etc.
• A tool automatically checks validity of the certificate
– this is not easy! (might even be undecidable)
• Verification is manual but machine certified
26
26
Available Tools
Testing
• many tools actively used in industry. We will use Python unittest
Symbolic Execution
• mostly academic tools with emerging industrial applications
• KLEE, S2E, jDART, Pex (now Microsoft IntelliTest)
Automated Verification
• built into compilers, may lightweight static analyzers
– clang analyzer, Facebook Infer, Coverity, …
• academic pushing the coverage/automation boundary
– SeaHorn (my tool), JayHorn, CPAChecker, SMACK, T2, …
(Automated) Deductive Verification
• academic, still rather hard to use, we’ll experience in class J
• Dafny/Boogie (Microsoft), Viper, Why3, KeY, ...
27
27
Key Challenges
Testing
• Coverage
Deductive Verification
• Usability
Common Challenge
• Specification / Oracle
28
28
Topics Covered in the Course
Foundations
• syntax, semantics, abstract syntax trees, visitors, control flow graphs
Testing
• coverage: structural, dataflow, and logic
Symbolic Execution
• using SMT solvers, constraints, path conditions, exploration strategies
• building a (toy) symbolic execution engine
Deductive Verification
• Hoare Logic, weakest pre-condition calculus, verification condition generation
• verifying algorithm using Dafny, building a small verification engine
Automated Verification
• (basics of) software model checking
29
29
A little about me
SPACER
UFO FrankenBit
Avy SeaHorn
30
30
Interests and Tools
Interests
• Software Model Checking, Program Verification, Decision Procedures,
Abstract Interpretation, SMT, Horn Clauses, …
Active Tools
• SeaHorn – Algorithmic Logic-Based Verification framework for C
• AVY – Hardware Model Checker with Interpolating PDR
• SPACER – Horn Clause Solver based on Z3 GPDR
• for more, see http://arieg.bitbucket.org/tools.html
Current Work
• parametric symbolic reachability – verifying safety properties of parametric
systems
• automated verification of C
•…
31
31