-
Notifications
You must be signed in to change notification settings - Fork 4
/
L36-slides.tex
381 lines (335 loc) · 9.19 KB
/
L36-slides.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
\documentclass{beamer}
\usetheme{Boadilla}
%\includeonlyframes{current}
\usepackage{times}
\usefonttheme{structurebold}
\usepackage{listings}
\usepackage{ragged2e}
\usepackage{pgf}
\usepackage{tikz}
\usepackage{alltt}
\usepackage[normalem]{ulem}
\usetikzlibrary{arrows}
\usetikzlibrary{automata}
\usetikzlibrary{shapes}
\usepackage{amsmath,amssymb}
\usepackage{rotating}
\usepackage{ulem}
\usepackage{listings}
\usepackage{enumerate}
\usepackage{tikz}
\tikzset{
every overlay node/.style={
draw=black,fill=white,rounded corners,anchor=north west,
},
}
\def\tikzoverlay{%
\tikz[baseline,overlay]\node[every overlay node]
}%
%\setbeamercovered{dynamic}
\setbeamertemplate{footline}[page number]{}
\setbeamertemplate{navigation symbols}{}
\usefonttheme{structurebold}
\title{Software Testing, Quality Assurance \& Maintenance---Lecture 36}
\author{Patrick Lam}
\date{April 6, 2015}
\colorlet{redshaded}{red!25!bg}
\colorlet{shaded}{black!25!bg}
\colorlet{shadedshaded}{black!10!bg}
\colorlet{blackshaded}{black!40!bg}
\colorlet{darkred}{red!80!black}
\colorlet{darkblue}{blue!80!black}
\colorlet{darkgreen}{green!80!black}
\newcommand{\rot}[1]{\rotatebox{90}{\mbox{#1}}}
\newcommand{\gray}[1]{\mbox{#1}}
\newenvironment{changemargin}[1]{%
\begin{list}{}{%
\setlength{\topsep}{0pt}%
\setlength{\leftmargin}{#1}%
\setlength{\rightmargin}{1em}
\setlength{\listparindent}{\parindent}%
\setlength{\itemindent}{\parindent}%
\setlength{\parsep}{\parskip}%
}%
\item[]}{\end{list}}
\lstset{ %
language=C++,
basicstyle=\ttfamily,commentstyle=\scriptsize\itshape,showstringspaces=false,breaklines=true}
\begin{document}
\begin{frame}
\titlepage
\end{frame}
\begin{frame}
\frametitle{Summary: Useful Terms}
\Large
\begin{changemargin}{1cm}
\begin{itemize}
\item software faults, errors and failures;
\item tests and test requirements; and
\item coverage criteria and subsumption.
\end{itemize}
\end{changemargin}
\end{frame}
\begin{frame}
\frametitle{Summary: Theory}
\Large
\begin{changemargin}{1.5cm}
Key Coverage Criteria:
\begin{itemize}
\item graph coverage;
\item logic coverage;
\item syntax-based coverage \\ \hspace*{1cm} (and mutation and fuzzing); and
\item input-space coverage.
\end{itemize}
Evaluate test suites against these criteria.\\
\hspace*{1cm}(guides test suite construction.)
\end{changemargin}
\end{frame}
\begin{frame}
\frametitle{Summary: Practice}
\begin{changemargin}{1.8cm}
We gained experience with:
\begin{itemize}
\item using tools for unit testing (JUnit) \& \\ \hspace*{1cm} bug detection (Valgrind)
\item test design: \\ ~~testability, badly designed tests, self-checking tests;
\item writing an invariant detection and bug detection tool (using
LLVM and the idea behind Coverity);\\
\item using the state-of-the-art tool Coverity for bug finding;
\item writing good bug reports.
\end{itemize}
and learned about automated testing and bug detection tools,
regression testing, testing for concurrency (Helgrind), and
state-of-the-art techniques (Daikon, Coverity, iComment).
\end{changemargin}
\end{frame}
\begin{frame}
\frametitle{About the Final}
\Large
\begin{changemargin}{1.5cm}
\begin{itemize}
\item Tuesday, April 21, 2015, 12:30-3:00, PAC.
\item Open-book, open note exam.
\item You may consult any printed material
(books, slides, notes, etc).
\item No electronic devices.
\end{itemize}
\end{changemargin}
\end{frame}
\begin{frame}
\frametitle{Review: Input Space Partitioning}
\large
\begin{changemargin}{2cm}
\begin{itemize}
\item Can't feed all inputs to the program---\\ test a representative set.
\item Input space partitioning makes this idea more
formal: test one input from each partition.
\item Two properties for partitions:\\
\hspace*{1cm} Completeness\\
\hspace*{1cm} Disjointness
\end{itemize}
\end{changemargin}
\end{frame}
\begin{frame}
\frametitle{Review: Input Domain Models}
\Large
\begin{changemargin}{1.7cm}
Require creativity and
analysis to formulate.
Two general approaches:
\begin{itemize}
\item Interface-based, using the input space directly, or
\item Functionality-based, using a functional or behavioural
view of the program.
\end{itemize}
\end{changemargin}
\end{frame}
\begin{frame}[fragile]
\frametitle{Review: Cross-checking program beliefs (MUST)}
\begin{changemargin}{1cm}
\begin{itemize}
\item MUST beliefs:
inferred from acts that imply beliefs code {\bf must} have.
\begin{lstlisting}
x = *p / z;
// MUST belief: p not null
// MUST: z != 0
unlock(l);
// MUST: l acquired
x++;
// MUST: x not protected by l
\end{lstlisting}
Check using internal consistency: \\
infer beliefs at different
locations, then cross-check for contradiction.
\end{itemize}
\end{changemargin}
\end{frame}
\begin{frame}[fragile]
\frametitle{Review: Cross-checking program beliefs (MAY)}
\begin{changemargin}{1cm}
\begin{itemize}
\item MAY beliefs:
Could be coincidental.
Inferred from acts that imply beliefs code {\bf may} have.
\begin{lstlisting}
A(); A(); A(); A();
... ... ... ...
B(); B(); B(); B();
// MAY: A() and B()
// must be paired
\end{lstlisting}
Check as MUST beliefs; rank errors by belief confidence.
\end{itemize}
\end{changemargin}
\end{frame}
\begin{frame}
\frametitle{Review: Static vs Dynamic Analysis}
\begin{changemargin}{2cm}
Static analysis:
\begin{itemize}
\item Conceptually, can find everything.
\item Problems: pointer aliasing, false positives.
\end{itemize}
Dynamic analysis:
\begin{itemize}
\item Imposes run-time overhead.
\item Depends on the quality of inputs/environments.
\item May report false negatives.
\end{itemize}
\end{changemargin}
\end{frame}
\begin{frame}
\frametitle{Review: Race conditions and Deadlocks}
\begin{changemargin}{2cm}
Race condition: \\
two concurrent
accesses to the same state, \\
at least one of
which is a write.\\[1em]
Deadlock: \\
cyclic structure between lock acquisitions\\
that
will never succeed.
\end{changemargin}
\end{frame}
\begin{frame}
\frametitle{Review: Testing Concurrent Programs}
\begin{changemargin}{2cm}
Some options:
\begin{itemize}
\item Run them multiple times.
\item Add noise: sleep, background load, \ldots.
\item Use tools: Helgrind, etc.
\item Force different scheduling.
\end{itemize}
Some of these options use the following technologies:
\begin{itemize}
\item lock-set;
\item happens-before;
\item other state-of-art techniques.
\end{itemize}
\end{changemargin}
\end{frame}
\begin{frame}
\frametitle{Review: Regression Tests}
\begin{changemargin}{2cm}
\large
\begin{itemize}
\item Gotta automate them.
\item Have enough regression tests:
\begin{itemize}
\item Too few: you'll miss bugs.
\item Too many: maintenance overhead, and if badly designed, too slow to run.
\end{itemize}
\item Keep them up-to-date.
\end{itemize}
\end{changemargin}
\end{frame}
\begin{frame}
\frametitle{Review: Output validation}
\begin{changemargin}{2cm}
\Large
How do you know your test outputs are correct?
\begin{itemize}
\item Hope for the best.
\item Manual effort.
\item Compute multiple ways.
\item Checksums, redundant data, etc.
\end{itemize}
\end{changemargin}
\end{frame}
\begin{frame}
\frametitle{Review: Syntax-based Testing}
{\scriptsize
\begin{tabular}{l|ll}
& Program-based & Input Space \\ \hline
Grammar & Programming language & Input languages / XML \\
Summary & Mutates programs / tests integration & Input space testing \\
Use Ground String? & Yes (compare outputs) & No \\
Use Valid Strings Only? & Yes (mutants must compile) & Invalid only \\
Tests & Mutants are not tests & Mutants are tests \\
Killing & Generate tests by killing & Not applicable \\
\end{tabular}
}
\begin{changemargin}{2cm}
Strong and weak mutants.
\end{changemargin}
\end{frame}
\begin{frame}
\frametitle{Sample Questions}
\begin{changemargin}{1cm}
\begin{itemize}
\item Give an example of a prime path.
\item Exhibit a case where a clause always determines
a predicate.
\item Exhibit a case where a clause never determines
a predicate.
\item Why might GACC be infeasible?
\item What causes node coverage to be infeasible?
\item Give an example of a $du$-path.
\item Given a function, draw the CFG. Identify the def-set and use-set of each node,
and list the TR for ADC and AUC.
\item The exercise questions seen in class.
\end{itemize}
\end{changemargin}
\end{frame}
\begin{frame}
\frametitle{More Sample Questions}
\begin{changemargin}{1cm}
\begin{itemize}
\item Read given program, give an input that
strongly kills this mutant.
\item Enumerate requirements for Prime Path
Coverage on given example. If PPC is feasible,
provide a test set which achieves it. Otherwise,
provide the test set that you feel comes closest
to achieving PPC.
\end{itemize}
\end{changemargin}
\end{frame}
\begin{frame}[fragile]
\frametitle{Input Space Partitioning: Sample Questions}
\begin{changemargin}{1cm}
\begin{itemize}
\item Propose an input space partition for this method
(use a functionality-based input domain model):
\begin{lstlisting}
static boolean isPrime (int n) {
if (n<=1) return false;
for (int i = 2; i <= (int)(Math.sqrt(n)); i++)
if (n % i == 0)
return false;
return true;
}
\end{lstlisting}
\end{itemize}
\end{changemargin}
\end{frame}
\begin{frame}
\begin{center}\Huge
Best of luck\\
\alert{\sout{after Convocation}} \\
on your work term.
\end{center}
\end{frame}
\end{document}