1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-07-29 08:01:23 +03:00

Coverage testing of pragma.c. (CVS 1744)

FossilOrigin-Name: 0f9c0f0aa9188c46c65cb92203687f37884f685a
This commit is contained in:
drh
2004-06-26 19:35:29 +00:00
parent b089c0b722
commit 5260f7e925
7 changed files with 172 additions and 76 deletions

View File

@ -10,7 +10,7 @@
#***********************************************************************
# This file runs all tests.
#
# $Id: all.test,v 1.19 2003/02/16 22:21:33 drh Exp $
# $Id: all.test,v 1.20 2004/06/26 19:35:30 drh Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@ -20,7 +20,7 @@ proc finish_test {} {memleak_check}
if {[file exists ./sqlite_test_count]} {
set COUNT [exec cat ./sqlite_test_count]
} else {
set COUNT 4
set COUNT 3
}
if {[llength $argv]>0} {
@ -49,6 +49,7 @@ set LeakList {}
set EXCLUDE {
all.test
crash.test
quick.test
malloc.test
misuse.test
@ -57,7 +58,6 @@ set EXCLUDE {
# btree2.test
for {set Counter 0} {$Counter<$COUNT && $nErr==0} {incr Counter} {
set btree_native_byte_order [expr {($Counter>>1)&0x1}]
if {$Counter%2} {
set ::SETUP_SQL {PRAGMA default_synchronous=off;}
} else {
@ -98,6 +98,12 @@ if {$LeakList!=""} {
puts " Ok"
}
# Run the crashtest only on unix and only once.
#
if {$tcl_platform(platform)=="unix"} {
source $testdir/crash.test
}
# Run the malloc tests and the misuse test after memory leak detection.
# Both tests leak memory.
#

View File

@ -10,7 +10,17 @@
#***********************************************************************
# This file implements regression tests for SQLite library.
#
# $Id: crash.test,v 1.5 2004/06/26 09:50:12 danielk1977 Exp $
# The focus of this file is testing the ability of the database to
# uses its rollback journal to recover intact (no database corruption)
# from a power failure during the middle of a COMMIT. The special test
# module "crashtest" compiled with the special "os_test.c" backend is used.
# The os_test.c simulates the kind of file corruption that can occur
# when writes are happening at the moment of power loss.
#
# The special crash-test module with its os_test.c backend only works
# on Unix.
#
# $Id: crash.test,v 1.6 2004/06/26 19:35:30 drh Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@ -305,5 +315,3 @@ for {set i 1} {$i < 5} {incr i} {
signature2
} $sig2
}

View File

@ -12,7 +12,7 @@
#
# This file implements tests for the PRAGMA command.
#
# $Id: pragma.test,v 1.14 2004/06/26 06:37:07 danielk1977 Exp $
# $Id: pragma.test,v 1.15 2004/06/26 19:35:30 drh Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@ -134,6 +134,48 @@ do_test pragma-1.12 {
}
} {123 123 2}
# Make sure the pragma handler understands numeric values in addition
# to keywords like "off" and "full".
#
do_test pragma-1.13 {
execsql {
PRAGMA synchronous=0;
PRAGMA synchronous;
}
} {0}
do_test pragma-1.14 {
execsql {
PRAGMA synchronous=2;
PRAGMA synchronous;
}
} {2}
# Test turning "flag" pragmas on and off.
#
do_test pragma-1.15 {
execsql {
PRAGMA vdbe_listing=YES;
PRAGMA vdbe_listing;
}
} {1}
do_test pragma-1.16 {
execsql {
PRAGMA vdbe_listing=NO;
PRAGMA vdbe_listing;
}
} {0}
do_test pragma-1.17 {
execsql {
PRAGMA parser_trace=ON;
PRAGMA parser_trace=OFF;
}
} {}
do_test pragma-1.18 {
execsql {
PRAGMA bogus = -1234; -- Parsing of negative values
}
} {}
# Test modifying the safety_level of an attached database.
do_test pragma-2.1 {
file delete -force test2.db
@ -258,5 +300,64 @@ do_test pragma-5.2 {
pragma synchronous;
}
} {2}
catchsql {COMMIT;}
# Test schema-query pragmas
#
do_test pragma-6.1 {
foreach {idx name file} [execsql {pragma database_list}] {
lappend res $idx $name
}
set res
} {0 main 1 temp 2 aux}
do_test pragma-6.2 {
execsql {
pragma table_info(t2)
}
} {0 a numeric 0 {} 0 1 b numeric 0 {} 0 2 c numeric 0 {} 0}
do_test pragma-6.3 {
execsql {
CREATE TABLE t3(a int references t2(b), b UNIQUE);
pragma foreign_key_list(t3);
}
} {0 0 t2 a b}
do_test pragma-6.4 {
execsql {
pragma index_list(t3);
}
} {0 sqlite_autoindex_t3_1 1}
do_test pragma-6.5 {
execsql {
CREATE INDEX t3i1 ON t3(a,b);
pragma index_info(t3i1);
}
} {0 0 a 1 1 b}
# Miscellaneous tests
#
do_test pragma-7.1 {
# Make sure a pragma knows to read the schema if it needs to
db close
sqlite3 db test.db
execsql {
pragma index_list(t3);
}
} {0 t3i1 0 1 sqlite_autoindex_t3_1 1}
do_test pragma-7.2 {
db close
sqlite3 db test.db
catchsql {
pragma encoding=bogus;
}
} {1 {unsupported encoding: bogus}}
do_test pragma-7.3 {
db close
sqlite3 db test.db
execsql {
pragma lock_status;
}
} {main unlocked temp closed}
finish_test