Debian Codegraph @

www/th3.html

raw
1 <!DOCTYPE html>
2 <html><head>
3 <meta name="viewport" content="width=device-width, initial-scale=1.0">
4 <meta http-equiv="content-type" content="text/html; charset=UTF-8">
5 <link href="sqlite.css" rel="stylesheet">
6 <title>TH3</title>
7 <!-- path= -->
8 </head>
9 <body>
10 <div class=nosearch>
11 <a href="index.html">
12 <img class="logo" src="images/sqlite370_banner.gif" alt="SQLite" border="0">
13 </a>
14 <div><!-- IE hack to prevent disappearing logo --></div>
15 <div class="tagline desktoponly">
16 Small. Fast. Reliable.<br>Choose any three.
17 </div>
18 <div class="menu mainmenu">
19 <ul>
20 <li><a href="index.html">Home</a>
21 <li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
22 <li class='wideonly'><a href='about.html'>About</a>
23 <li class='desktoponly'><a href="docs.html">Documentation</a>
24 <li class='desktoponly'><a href="download.html">Download</a>
25 <li class='wideonly'><a href='copyright.html'>License</a>
26 <li class='desktoponly'><a href="support.html">Support</a>
27 <li class='desktoponly'><a href="prosupport.html">Purchase</a>
28 <li class='search' id='search_menubutton'>
29 <a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
30 </ul>
31 </div>
32 <div class="menu submenu" id="submenu">
33 <ul>
34 <li><a href='about.html'>About</a>
35 <li><a href='docs.html'>Documentation</a>
36 <li><a href='download.html'>Download</a>
37 <li><a href='support.html'>Support</a>
38 <li><a href='prosupport.html'>Purchase</a>
39 </ul>
40 </div>
41 <div class="searchmenu" id="searchmenu">
42 <form method="GET" action="search">
43 <select name="s" id="searchtype">
44 <option value="d">Search Documentation</option>
45 <option value="c">Search Changelog</option>
46 </select>
47 <input type="text" name="q" id="searchbox" value="">
48 <input type="submit" value="Go">
49 </form>
50 </div>
51 </div>
52 <script>
53 function toggle_div(nm) {
54 var w = document.getElementById(nm);
55 if( w.style.display=="block" ){
56 w.style.display = "none";
57 }else{
58 w.style.display = "block";
59 }
60 }
61 function toggle_search() {
62 var w = document.getElementById("searchmenu");
63 if( w.style.display=="block" ){
64 w.style.display = "none";
65 } else {
66 w.style.display = "block";
67 setTimeout(function(){
68 document.getElementById("searchbox").focus()
69 }, 30);
70 }
71 }
72 function div_off(nm){document.getElementById(nm).style.display="none";}
73 window.onbeforeunload = function(e){div_off("submenu");}
74 /* Disable the Search feature if we are not operating from CGI, since */
75 /* Search is accomplished using CGI and will not work without it. */
76 if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
77 document.getElementById("search_menubutton").style.display = "none";
78 }
79 /* Used by the Hide/Show button beside syntax diagrams, to toggle the */
80 function hideorshow(btn,obj){
81 var x = document.getElementById(obj);
82 var b = document.getElementById(btn);
83 if( x.style.display!='none' ){
84 x.style.display = 'none';
85 b.innerHTML='show';
86 }else{
87 x.style.display = '';
88 b.innerHTML='hide';
89 }
90 return false;
91 }
92 var antiRobot = 0;
93 function antiRobotGo(){
94 if( antiRobot!=3 ) return;
95 antiRobot = 7;
96 var j = document.getElementById("mtimelink");
97 if(j && j.hasAttribute("data-href")) j.href=j.getAttribute("data-href");
98 }
99 function antiRobotDefense(){
100 document.body.onmousedown=function(){
101 antiRobot |= 2;
102 antiRobotGo();
103 document.body.onmousedown=null;
104 }
105 document.body.onmousemove=function(){
106 antiRobot |= 2;
107 antiRobotGo();
108 document.body.onmousemove=null;
109 }
110 setTimeout(function(){
111 antiRobot |= 1;
112 antiRobotGo();
113 }, 100)
114 antiRobotGo();
115 }
116 antiRobotDefense();
117 </script>
118 <div class=fancy>
119 <div class=nosearch>
120 <div class="fancy_title">
121 TH3
122 </div>
123 <div class="fancy_toc">
124 <a onclick="toggle_toc()">
125 <span class="fancy_toc_mark" id="toc_mk">&#x25ba;</span>
126 Table Of Contents
127 </a>
128 <div id="toc_sub"><div class="fancy-toc1"><a href="#overview">1. Overview</a></div>
129 <div class="fancy-toc2"><a href="#history">1.1. History</a></div>
130 <div class="fancy-toc1"><a href="#operation">2. Operation</a></div>
131 <div class="fancy-toc1"><a href="#generating_a_test_program">3. Generating A Test Program</a></div>
132 <div class="fancy-toc2"><a href="#test_automation_scripts">3.1. Test Automation Scripts</a></div>
133 <div class="fancy-toc1"><a href="#test_coverage">4. Test Coverage</a></div>
134 <div class="fancy-toc1"><a href="#mutation_testing">5. Mutation Testing</a></div>
135 <div class="fancy-toc1"><a href="#th3_license">6. TH3 License</a></div>
136 </div>
137 </div>
138 <script>
139 function toggle_toc(){
140 var sub = document.getElementById("toc_sub")
141 var mk = document.getElementById("toc_mk")
142 if( sub.style.display!="block" ){
143 sub.style.display = "block";
144 mk.innerHTML = "&#x25bc;";
145 } else {
146 sub.style.display = "none";
147 mk.innerHTML = "&#x25ba;";
148 }
149 }
150 </script>
151 </div>
152
153
154
155
156 <h1 id="overview"><span>1. </span>Overview</h1>
157
158 <p>SQLite Test Harness #3 (hereafter "TH3") is one of
159 <a href="testing.html#harnesses">three test harnesses</a> used for testing SQLite.
160 TH3 meets the following objectives:</p>
161
162 <ul>
163 <li><p> TH3 is able to run on embedded platforms that lack the support
164 infrastructure of workstations.</p></li>
165
166 <li><p> TH3 tests SQLite in an as-deployed configuration using only
167 published and documented interfaces.
168 In other words, TH3 tests the compiled object code, not
169 the source code, thus verifying that no problems were introduced
170 by compiler bugs. "Test what you fly and fly what you test."</p></li>
171
172 <li><p> TH3 checks SQLite's response to out-of-memory errors, disk I/O
173 errors, and power loss during transaction commit. </p></li>
174
175 <li><p> TH3 exercises SQLite in a variety of run-time configurations
176 (UTF8 vs UTF16, different pages sizes, varying journal modes, etc.)
177 </p></li>
178
179 <li><p> TH3 achieves 100% branch test coverage (and 100%
180 <a href="https://en.wikipedia.org/wiki/Modified_condition/decision_coverage">MC/DC</a>)
181 over the SQLite core.
182 (Test coverage of extensions such as FTS and RTREE is less than 100%).
183 </p></li>
184 </ul>
185
186 <p>TH3 was originally written for validation testing only, but has
187 subsequently been used for development testing and debugging
188 as well, and has proven very helpful in those roles. A full-coverage
189 test takes less than five minutes on a workstation and hence
190 serves as a fast regression test during day-to-day maintenance
191 of the SQLite code base.</p>
192
193 <h2 id="history"><span>1.1. </span>History</h2>
194
195 <p>TH3 originated from an effort to test SQLite on
196 <a href="https://en.wikipedia.org/wiki/Symbian">SymbianOS</a>.
197 Prior to TH3, all SQLite tests were run using the
198 <a href="http://www.tcl.tk/">TCL</a> script language, but TCL would not (easily)
199 compile on SymbianOS which made testing difficult. The first attempt
200 to remedy this problem was the "TH1" (Test Harness #1) scripting
201 language - a reimplementation of parts of the TCL language in a
202 more portable form that would compile and run on SymbianOS, and
203 that was sufficient to run the SQLite tests. TH1
204 did not survive as a standard testing tool for SQLite,
205 but it did find continued service as a
206 scripting language used to customize the
207 <a href="http://www.fossil-scm.org/">Fossil</a> version control system.
208 There was also a "Test Harness #2" which was an attempt to
209 create a simple scripting language using operator prefix notation
210 to drive tests. TH3 was the third attempt.
211
212 </p><p>At about that same time, some avionics manufacturers were
213 expressing interest in SQLite, which prompted the SQLite developers
214 to design TH3 to support the rigorous testing standards of
215 <a href="https://en.wikipedia.org/wiki/DO-178B">DO-178B</a>.
216
217 </p><p>The first code for TH3 was laid down on 2008-09-25.
218 An intense effort over the next 10 months resulted in TH3 achieving
219 100% MC/DC on 2009-07-25. The TH3 code continues to be improved and
220 expanded.
221
222 </p><p>As of 2018-05-19, the TH3 source tree consists
223 and well over 500,000 lines of source code in 1709 separate files.
224
225 </p><h1 id="operation"><span>2. </span>Operation</h1>
226
227 <p>TH3 is a test program generator. The output of TH3 is a program
228 implemented in C-code and intended to be
229 linked against the SQLite library under test. The generated test
230 program is compiled and run on the target platform in order to verify
231 correct operation of SQLite on that platform.</p>
232
233 <p>The inputs to TH3 are test modules written in C or SQL and
234 small configuration
235 files that determine how to initialize SQLite. The
236 TH3 package includes 1,444 test
237 modules and more than 47 configurations (as of 2018-05-19).
238 New modules and configurations
239 can be added to customize TH3 for specialized applications.
240 Each time TH3 is run, it reads
241 a subset of the available test modules and configuration files to generate
242 a custom C program that performs all of the specified tests under all
243 specified configurations. A complete test of SQLite normally involves running
244 TH3 multiple times to generate multiple test programs covering different
245 aspects of SQLite's operation, then linking all test programs against
246 a common SQLite library and running them separately on the target platform.
247 </p>
248
249 <p>There are no arbitrary limits in TH3. One could generate a
250 single test program that contained all test modules and all configuration files.
251 However, such a test program might be too large to deploy on embedded
252 platforms. (As of 2018-05-19, a full-up TH3 test is over 850,000 lines and
253 58MB of C code.) TH3 provides the ability to break the library of test
254 modules up into smaller, more easily digested pieces.</p>
255
256 <p>Each individual test module might contain dozens, hundreds, or thousands
257 of separate tests. The test modules can be written in C or as scripts of
258 SQL or a mixture of the two. About two-thirds of the existing test modules are
259 written in pure SQL with the remainder either in pure C or a combination
260 of C and SQL.
261 </p>
262
263 <p>Each test module file contains a header which describes the circumstances
264 under which the test is valid. For a particular configuration, only those
265 modules that are compatible with the configuration are run. </p>
266
267 <h1 id="generating_a_test_program"><span>3. </span>Generating A Test Program</h1>
268
269 <p>The TH3 program generator is a TCL script named "<tt>mkth3.tcl</tt>".
270 To generate a test program, one has merely to run this script and supply
271 the names of files containing test modules and configurations on the
272 command line. Test modules are files that use the "<tt>.test</tt>" suffix
273 and configurations are files that use the "<tt>.cfg</tt>" suffix. A
274 typical invocation of mkth3.tcl might look something like the following:</p>
275
276 <div class="codeblock"><pre>tclsh mkth3.tcl *.test *.cfg &gt;testprog1.c
277 </pre></div>
278
279 <p>The output from the mkth3.tcl script is a C program that contains
280 everything needed to run the tests - everything that is except for
281 the SQLite library itself. The generated test program contains
282 implementations for all of the support interfaces used by the test
283 modules and it contains the <tt>main()</tt> routine that drives the
284 tests. To convert the test program into a working executable, simply
285 compile it against SQLite:</p>
286
287 <div class="codeblock"><pre>cc -o testprog1 testprog1.c sqlite3.c
288 </pre></div>
289
290 <p>The compilation step shown immediately above is merely representative.
291 In a working installation, one would normally want
292 to specify optimization parameters and compile-time switches on the
293 compiler command line.</p>
294
295 <p>For testing on embedded systems, the mkth3.tcl script and the compiler
296 steps shown above are performed on an ordinary workstation using
297 a cross-compiler, then the resulting test program is
298 transferred onto the device to be run.</p>
299
300 <p>Once the test program is generated, it is run with no arguments to
301 perform the tests. Progress information as well as error diagnostics
302 appear on standard output. (Alternative output arrangements can be made
303 using a compile-time option for embedded devices that lack a standard
304 output channel.) The program returns zero if there are no
305 errors and non-zero if any problems were detected.</p>
306
307 <p>Typical output from a single TH3 test program run looks like this:
308
309 </p><div class="codeblock"><pre>With SQLite 3.8.11 2015-05-15 04:13:15 56ef98a04765c34c1c2f3ed7a6f03a732f3b886e
310 -DSQLITE_COVERAGE_TEST
311 -DSQLITE_NO_SYNC
312 -DSQLITE_SYSTEM_MALLOC
313 -DSQLITE_THREADSAFE=1
314 Config-begin c1.
315 Begin c1.pager08
316 End c1.pager08
317 Begin c1.build33
318 End c1.build33
319 Begin c1.orderby01
320 End c1.orderby01
321 <i>... 15014 lines of output omitted ....</i>
322 Begin 64k.syscall01
323 End 64k.syscall01
324 Begin 64k.build01
325 End 64k.build01
326 Begin 64k.auth01
327 End 64k.auth01
328 Config-end 64k. TH3 memory used: 6373738
329 Config-begin wal1.
330 Begin wal1.wal37
331 End wal1.wal37
332 Config-end wal1. TH3 memory used: 100961
333 All 226 VDBE coverage points reached
334 th3: 0 errors out of 1442264 tests in 213.741 seconds. 64-bit little-endian
335 th3: SQLite 3.8.11 2015-05-15 04:13:15 56ef98a04765c34c1c2f3ed7a6f03a732f3b886e
336 </pre></div>
337
338 <p>The output begins with a report of the <a href="c3ref/c_source_id.html">SQLITE_SOURCE_ID</a>
339 (cross-checked again <a href="c3ref/libversion.html">sqlite3_sourceid()</a>) for the
340 SQLite under test and the compile-time options used as reported
341 by <a href="c3ref/compileoption_get.html">sqlite3_compileoption_get()</a>. The output concludes with a summary
342 of the test results and a repeat of the <a href="c3ref/c_source_id.html">SQLITE_SOURCE_ID</a>. If any
343 errors are detected, additional lines detail the problem. The error
344 reporting lines always begin with a single space character so that they
345 can be quickly extracted from large output files using:
346
347 </p><div class="codeblock"><pre>grep "&#94; "
348 </pre></div>
349
350 <p>The default output shows the beginning and end of each configuration
351 and test module combination. In the example above "c1" and "64k" are
352 configurations and "pager08", "build33", "orderby01", etc. are test modules.
353 Compile-time and run-time options are available to increase or decrease
354 the amount of output.
355 The output can be increased by showing each test case within each
356 test module. The output can be decreased
357 by degrees: omitting test modules starts and stops,
358 omitting configuration starts and stops, and finally by omitting all output.
359
360 </p><h2 id="test_automation_scripts"><span>3.1. </span>Test Automation Scripts</h2>
361
362 <p>TH3 comes with additional TCL scripts that help automate the testing
363 process on workstations. The "th3make" script automatically runs "mkth3.tcl"
364 and "gcc" and then runs the resulting test program and checks the results.
365 Arguments to th3make include all of the "*.test" test modules and
366 "*.cfg" configurations that are to be included in the test. Additional
367 options to th3make can cause the test program to be compiled using different
368 compilers (GCC, Clang, MSVC), to use different output verbosity levels, to
369 run the test program under valgrind, to check the output for coverage using
370 gcov, and so forth. The th3make script also accepts "*.rc" filenames as
371 arguments. These *.rc files are just collections of other arguments that
372 are commonly used together for a single purpose. For example, the "quick.rc"
373 file contains a set of eight arguments to th3make that run a fast (3-minute)
374 full-coverage test. This allows the operator to type "./th3make quick.rc" as
375 a short-cut to typing out all of the required command-line options. The
376 following are a few of the more than 40 available *.rc files:
377
378 </p><ul>
379 <li><b>alignment</b><i>N</i><b>.rc</b> -
380 These files contain -D options to the compiler that are used by
381 various notable downstreams.
382 </li><li><b>cov.rc</b> - Options for measuring test coverage
383 </li><li><b>extensions.rc</b> - Options to enable <a href="fts3.html#fts4">FTS4</a>, <a href="rtree.html">R-Trees</a>,
384 and <a href="fileformat2.html#stat4tab">STAT4</a>.
385 </li><li><b>fast.rc</b> - Run most tests, including those not needed for
386 coverage, skipping only soak tests, using delivery compiler options
387 (ex: -O3)
388 </li><li><b>memdebug.rc</b> - like test.rc but also enable
389 <a href="compile.html#memdebug">-DSQLITE_MEMDEBUG</a>.
390 </li><li><b>min.rc</b> - Run the minimum set of tests needed for 100% coverage.
391 </li><li><b>quick.rc</b> - Run all tests required for 100% coverage tests
392 using -Os and <a href="compile.html#debug">-DSQLITE_DEBUG</a>.
393 </li><li><b>test.rc</b> - Run the same tests as in fast.rc but without
394 compiler optimization and enabling options like
395 <a href="compile.html#debug">-DSQLITE_DEBUG</a> and
396 -DSQLITE_ENABLE_EXPENSIVE_ASSERT.
397 </li><li><b>test-ex.rc</b> - long-running soak tests.
398 </li></ul>
399
400 <p>The TH3 repository also includes the "multitest.tcl" script, another
401 TCL script used to automate TH3 testing on workstations. Multitest.tcl
402 automatically compiles SQLite, then
403 runs ./th3make repeatedly with a variety of alignments, and captures
404 the output in a succinct summary screen. A typical multitest.tcl run
405 generates output that looks like this:
406
407 </p><div class="codeblock"><pre>./multitest.tcl -q --jobs 3
408 start-time: 2018-05-19 03:17:12 UTC
409 file mkdir sqlite3bld
410 cd sqlite3bld
411 exec sh /ramdisk/sqlite/configure
412 file copy -force config.h ../config.h
413 exec make clean sqlite3.c
414 file rename sqlite3.c ../sqlite3.c
415 file rename sqlite3.h ../sqlite3.h
416 exec make clean sqlite3.c OPTS=-DSQLITE_ENABLE_UPDATE_DELETE_LIMIT=1
417 file rename sqlite3.c ../sqlite3udl.c
418 exec make clean sqlite3.c OPTS=-DSQLITE_SMALL_STACK=1
419 file rename sqlite3.c ../sqlite3ss.c
420 cd ..
421 *******************************************************************************
422 t01: cov.rc.................................................... Ok (00:03:42)
423 t02: cov.rc ++STAT4 ++DESERIALIZE -D_HAVE_SQLITE_CONFIG_H...... Ok (00:04:45)
424 t03: vfs-cov.rc................................................ Ok (00:03:59)
425 t04: demo.rc................................................... Ok (00:00:05)
426 t07: test.rc ../th3private/*.test.............................. Ok (00:00:21)
427 t08: test.rc ../th3private/*.test ++STAT4...................... Ok (00:01:41)
428 t05: quick.rc.................................................. Ok (00:04:26)
429 t09: quick.rc ~TEST_REALLOC_STRESS -funsigned-char............. Ok (00:05:39)
430 t10: quick.rc ~THREADSAFE=0 -DLONGDOUBLE_TYPE=double........... Ok (00:03:24)
431 t06: quick.rc extensions.rc -D_HAVE_SQLITE_CONFIG_H............ Ok (00:09:03)
432 t11: quick.rc sqlite3ss.c ~MAX_ATTACHED=125.................... Ok (00:04:39)
433 t12: quick.rc ~BYTEORDER=0 ++RTREE............................. Ok (00:07:28)
434 t13: quick.rc ~DISABLE_INTRINSIC ++RTREE....................... Ok (00:07:31)
435 t16: quick.rc ~TRACE_SIZE_LIMIT=15 cov1/main16.test............ Ok (00:00:22)
436 t14: quick.rc ~DIRECT_OVERFLOW_READ -fsigned-char.............. Ok (00:04:35)
437 t15: quick.rc ~UNTESTABLE ~EXTRA_IFNULLROW..................... Ok (00:01:44)
438 t17: quick.rc ~MAX_MMAP_SIZE=0................................. Ok (00:04:46)
439 t18: quick.rc ++NULL_TRIM ++OFFSET_SQL_FUNC.................... Ok (00:04:47)
440 t19: quick.rc ++BATCH_ATOMIC_WRITE ++DESERIALIZE............... Ok (00:05:41)
441 t20: lean1.rc quick.rc......................................... Ok (00:03:09)
442 t22: test.rc alignment2.rc sqlite3udl.c........................ Ok (00:44:22)
443 t21: test.rc alignment1.rc..................................... Ok (01:02:32)
444 t23: memdebug1.rc extensions.rc................................ Ok (01:49:58)
445 t25: valgrind1.rc -O3 extensions.rc............................ Ok (00:56:08)
446 t24: memdebug2.rc extensions.rc................................ Ok (01:43:34)
447 t27: test-ex1.rc............................................... Ok (00:45:00)
448 t26: valgrind2.rc -O3 extensions.rc............................ Ok (01:02:52)
449 t29: test-ex3.rc............................................... Ok (00:31:48)
450 t28: test-ex2.rc............................................... Ok (01:12:03)
451 t30: test-ex4.rc............................................... Ok (01:09:47)
452 t32: test.rc alignment4.rc -m32 CC=clang....................... Ok (00:48:31)
453 t31: test.rc alignment3.rc sqlite3udl.c........................ Ok (01:22:29)
454 t34: test.rc alignment6.rc..................................... Ok (00:35:31)
455 t33: test.rc alignment5.rc extensions.rc....................... Ok (00:59:33)
456 t35: test.rc alignment7.rc..................................... Ok (00:44:10)
457 t40: fast.rc alignment2.rc sqlite3udl.c........................ Ok (00:15:46)
458 t39: fast.rc alignment1.rc extensions.rc -m32.................. Ok (00:33:19)
459 t36: test.rc ~MUTATION_TEST.................................... Ok (00:35:45)
460 t42: fast.rc alignment4.rc..................................... Ok (00:13:03)
461 t43: fast.rc alignment5.rc..................................... Ok (00:13:32)
462 t44: fast.rc alignment6.rc..................................... Ok (00:11:41)
463 t41: fast.rc alignment3.rc sqlite3udl.c........................ Ok (00:26:31)
464 t45: fast.rc alignment7.rc..................................... Ok (00:12:57)
465 t46: fast.rc -fsanitize=undefined.............................. Ok (00:38:18)
466 *******************************************************************************
467 0 failures on 44 th3makes and 198583082 tests in (07:16:01) 3 cores on bella
468 SQLite 3.24.0 2018-05-18 17:58:33 c6071ac99cfa4b6272ac4d739fc61a85acb544f6c1c2a
469 </pre></div>
470
471 <p>As can be seen above, a single run
472 of multitest.tcl invokes th3make dozens of times and takes between 12 and 24
473 CPU hours. The middle section of the output shows the arguments to each
474 individual th3make run and the result and elapse time for that th3make.
475 All build products and output for the separate th3make runs are
476 captures in subdirectories for post-test analysis.
477 The two-line summary at the bottom shows the total number of errors and tests
478 over all th3make runs and the total elapse time, together with the
479 <a href="c3ref/c_source_id.html">SQLITE_SOURCE_ID</a> information for the version of SQLite that was
480 tested. This summary information is recorded in the
481 <a href="https://www.sqlite.org/checklists">release
482 checklist</a> during final testing.
483
484 </p><p>Abbreviations are applied in the multitest.tcl output so that
485 each th3make invocation will fit on a single 80-column output line.
486 The initial "th3make" verb is omitted.
487 "~" is shorthand for "-DSQLITE_" and "++" is stands for
488 "-DSQLITE_ENABLE". Hence, multitest.tcl output line
489
490 </p><div class="codeblock"><pre>quick.rc ~DISABLE_INTRINSIC ++RTREE
491 </pre></div>
492
493 <p>Really means
494
495 </p><div class="codeblock"><pre>th3make quick.rc -DSQLITE_DISABLE_INTRINSIC -DSQLITE_ENABLE_RTREE
496 </pre></div>
497
498 <h1 id="test_coverage"><span>4. </span>Test Coverage</h1>
499
500 <p>Using one particular subset of the available TH3 test modules (the "cov1"
501 tests) SQLite obtained
502 <a href="testing.html#coverage">100% branch test coverage</a> and 100% <a href="testing.html#mcdc">MC/DC</a> as measured
503 by <a href="http://gcc.gnu.org/onlinedocs/gcc/Gcov.html">gcov</a>
504 on Linux x86 and x86_64 hardware. All releases of SQLite since
505 <a href="releaselog/3_6_17.html">version 3.6.17</a> (2009-08-10) have been tested to this standard.
506 The SQLite developers
507 are committed to maintaining 100% branch coverage and MC/DC for all
508 future releases of SQLite.</p>
509
510 <p>The cov1 test set used to obtain 100% branch test coverage are only a
511 subset of the tests currently implemented using TH3. New test modules are
512 added on a regular basis.</p>
513
514 <a name="muttest"></a>
515
516 <h1 id="mutation_testing"><span>5. </span>Mutation Testing</h1>
517
518 <p>The TH3 source tree contains a scripted name
519 "mutation-test.tcl" that automates the process of
520 <a href="testing.html#mutationtests">mutation testing</a>.
521
522 </p><p>The mutation-test.tcl script takes care of all of the details for
523 running a mutation test:
524
525 </p><ol>
526 <li> The script compiles the TH3 test harness into machine code ("th3.o") if
527 necessary.
528 </li><li> The script compiles the sqlite3.c source file into assembly language
529 ("sqlite3.s") if necessary.
530 </li><li> The script loops through instructions in the assembly language file
531 to locate branch operations.
532 <ol type="a">
533 <li>The script makes a copy of the original sqlite3.s file.
534 </li><li>The copy is edited to change the branch instruction into either
535 a no-op or an unconditional jump.
536 </li><li>The copy of sqlite3.s is assembled into sqlite3.o then linked
537 again th3.o to generate the "th3" executable.
538 </li><li>The "th3" binary is run and the output checked for errors.
539 </li></ol>
540 </li><li> The script shows progress for each cycle of the previous step then
541 displays a summary of "survivors" at the end. A "survivor" is a
542 mutation that was not detected by TH3.
543 </li></ol>
544
545 <p>Mutation testing can be slow, since each test can take up to 5
546 minutes on a fast workstation, and there are two tests for each
547 branch instructions, and over 20,000 branch instructions. Efforts are
548 made to expedite operation. For example, TH3 is compiled in such a
549 way that it exits as soon as it finds the first error, and as many
550 of the mutations are easily detected, many cycles happen in only
551 a few seconds. Nevertheless, the mutation-test.tcl script includes
552 command-line options to limit the range of code lines tested so that
553 mutation testing only needs to be performed on blocks of code that
554 have recently changed.
555
556 </p><h1 id="th3_license"><span>6. </span>TH3 License</h1>
557
558 <p>SQLite itself is in the <a href="copyright.html">public domain</a> and
559 can be used for any purpose. But TH3 is proprietary and requires a license.
560 </p>
561
562 <p>Even though open-source users do not have direct access to TH3, all
563 users of SQLite benefit from TH3 indirectly since each version of SQLite is
564 validated running TH3 on multiple platforms (Linux, Windows, WinRT, Mac,
565 OpenBSD) prior to release. So anyone using an official release
566 of SQLite can deploy their application with the confidence of knowing that
567 it has been tested using TH3. They simply cannot rerun those tests
568 themselves without purchasing a TH3 license.</p>
569 <p align="center"><small><i>This page last modified on <a href="https://sqlite.org/docsrc/honeypot" id="mtimelink" data-href="https://sqlite.org/docsrc/finfo/pages/th3.in?m=7955ba7a18">2022-01-08 05:02:57</a> UTC </small></i></p>
570