drh | d13b231 | 2015-05-11 17:46:14 +0000 | [diff] [blame] | 1 | # 2015-05-11 |
| 2 | # |
| 3 | # The author disclaims copyright to this source code. In place of |
| 4 | # a legal notice, here is a blessing: |
| 5 | # |
| 6 | # May you do good and not evil. |
| 7 | # May you find forgiveness for yourself and forgive others. |
| 8 | # May you share freely, never taking more than you give. |
| 9 | # |
| 10 | #*********************************************************************** |
| 11 | # |
| 12 | # Quick tests for the sqlite3_analyzer tool |
| 13 | # |
| 14 | set testdir [file dirname $argv0] |
| 15 | source $testdir/tester.tcl |
drh | 6582ae5 | 2015-05-12 12:24:50 +0000 | [diff] [blame] | 16 | |
| 17 | ifcapable !vtab { |
| 18 | finish_test |
| 19 | return |
| 20 | } |
| 21 | |
drh | d13b231 | 2015-05-11 17:46:14 +0000 | [diff] [blame] | 22 | if {$tcl_platform(platform)=="windows"} { |
| 23 | set PROG "sqlite3_analyzer.exe" |
| 24 | } else { |
| 25 | set PROG "./sqlite3_analyzer" |
| 26 | } |
drh | 905da63 | 2015-06-10 18:53:09 +0000 | [diff] [blame] | 27 | if {![file exe $PROG]} { |
drh | d5704a8 | 2016-03-14 13:42:29 +0000 | [diff] [blame] | 28 | set PROG [file normalize [file join $::cmdlinearg(TESTFIXTURE_HOME) $PROG]] |
| 29 | if {![file exe $PROG]} { |
| 30 | puts "analyzer1 cannot run because $PROG is not available" |
| 31 | finish_test |
| 32 | return |
| 33 | } |
drh | 905da63 | 2015-06-10 18:53:09 +0000 | [diff] [blame] | 34 | } |
drh | d13b231 | 2015-05-11 17:46:14 +0000 | [diff] [blame] | 35 | db close |
| 36 | forcedelete test.db test.db-journal test.db-wal |
| 37 | sqlite3 db test.db |
| 38 | |
| 39 | do_test analyzer1-1.0 { |
| 40 | db eval { |
| 41 | CREATE TABLE t1(a INTEGER PRIMARY KEY, b); |
| 42 | CREATE TABLE t2(a INT PRIMARY KEY, b) WITHOUT ROWID; |
| 43 | WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<250) |
| 44 | INSERT INTO t1(a,b) SELECT x, randomblob(200) FROM c; |
| 45 | INSERT INTO t2(a,b) SELECT a, b FROM t1; |
| 46 | } |
| 47 | set line "exec $PROG test.db" |
| 48 | unset -nocomplain ::MSG |
| 49 | catch {eval $line} ::MSG |
| 50 | } {0} |
| 51 | do_test analyzer1-1.1 { |
| 52 | regexp {^/\*\* Disk-Space Utilization.*COMMIT;\W*$} $::MSG |
| 53 | } {1} |
drh | 8906b7d | 2015-05-11 18:48:52 +0000 | [diff] [blame] | 54 | |
| 55 | finish_test |