SQLite

Check-in [e380cd3ce3]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Add extra tests for secure-delete mode.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: e380cd3ce34d509e184081ecccf27fda11ce1da7
User & Date: dan 2012-08-07 17:41:50.005
Context
2012-08-07
22:53
Simplifications to the sorter to support full-coverage testing. (check-in: de804f4c90 user: drh tags: trunk)
17:41
Add extra tests for secure-delete mode. (check-in: e380cd3ce3 user: dan tags: trunk)
15:19
Fix a bug in hash.c introduced by [305b66672653]. (check-in: 17cb5e951e user: dan tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to test/permutations.test.
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
  misc7.test mutex2.test notify2.test onefile.test pagerfault2.test 
  savepoint4.test savepoint6.test select9.test 
  speed1.test speed1p.test speed2.test speed3.test speed4.test 
  speed4p.test sqllimits1.test tkt2686.test thread001.test thread002.test
  thread003.test thread004.test thread005.test trans2.test vacuum3.test 
  incrvacuum_ioerr.test autovacuum_crash.test btree8.test shared_err.test
  vtab_err.test walslow.test walcrash.test walcrash3.test
  walthread.test rtree3.test indexfault.test 
}]
if {[info exists ::env(QUICKTEST_INCLUDE)]} {
  set allquicktests [concat $allquicktests $::env(QUICKTEST_INCLUDE)]
}

#############################################################################
# Start of tests







|







107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
  misc7.test mutex2.test notify2.test onefile.test pagerfault2.test 
  savepoint4.test savepoint6.test select9.test 
  speed1.test speed1p.test speed2.test speed3.test speed4.test 
  speed4p.test sqllimits1.test tkt2686.test thread001.test thread002.test
  thread003.test thread004.test thread005.test trans2.test vacuum3.test 
  incrvacuum_ioerr.test autovacuum_crash.test btree8.test shared_err.test
  vtab_err.test walslow.test walcrash.test walcrash3.test
  walthread.test rtree3.test indexfault.test securedel2.test
}]
if {[info exists ::env(QUICKTEST_INCLUDE)]} {
  set allquicktests [concat $allquicktests $::env(QUICKTEST_INCLUDE)]
}

#############################################################################
# Start of tests
Added test/securedel2.test.




























































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
# 2012 August 7
#
# The author disclaims copyright to this source code.  In place of
# a legal notice, here is a blessing:
#
#    May you do good and not evil.
#    May you find forgiveness for yourself and forgive others.
#    May you share freely, never taking more than you give.
#
#*************************************************************************
#
# Tests for the secure_delete pragma.
#

set testdir [file dirname $argv0]
source $testdir/tester.tcl
set ::testprefix securedel2

# Generate 1000 pseudo-random 64-bit blobs.
#
for {set i 1} {$i <= 1000} {incr i} {
  set aBlob($i) [string range [db one {SELECT quote(randomblob(8))}] 2 end-1]
}

proc detect_blob_prepare {zFile} {
  set nByte [file size $zFile]
  set ::detect_blob_data [hexio_read $zFile 0 $nByte]
}

proc detect_blob {zFile iBlob} {
  if {$zFile != ""} { detect_blob_prepare $zFile }
  string match "*$::aBlob($iBlob)*" $::detect_blob_data
}

do_test 1.1 {
  execsql { PRAGMA secure_delete = 1 }
  execsql { CREATE TABLE t1(x, y) }
  for {set i 1} {$i <= 1000} {incr i} {
    set x "X'[string repeat $aBlob($i) 1]'"
    set y "X'[string repeat $aBlob($i) 500]'"
    execsql "INSERT INTO t1 VALUES($x, $y)"
  }
} {}

do_test         1.2   { detect_blob test.db 1 } {1}

forcecopy test.db test.db.bak
do_execsql_test 1.3.1 { PRAGMA secure_delete = 0 } {0}
do_execsql_test 1.3.2 { DELETE FROM t1 WHERE rowid = 1 }
do_test         1.3.3 { detect_blob test.db 1 } {1}

db close
forcecopy test.db.bak test.db
sqlite3 db test.db
do_execsql_test 1.4.1 { PRAGMA secure_delete = 1 } {1}
do_execsql_test 1.4.2 { DELETE FROM t1 WHERE rowid = 1 }
do_test         1.4.3 { detect_blob test.db 1 } {0}

do_execsql_test 1.5.1 { DELETE FROM t1 WHERE rowid>850 } {}
do_test 1.5.2 { 
  set n 0
  detect_blob_prepare test.db
  for {set i 851} {$i <= 1000} {incr i 5} {
    incr n [detect_blob {} $i]
  }
  set n
} {0}

db close
sqlite3 db test.db
do_test 1.6.1 { 
  execsql {
    PRAGMA cache_size = 200;
    PRAGMA secure_delete = 1;
    CREATE TABLE t2(x);
    SELECT * FROM t1;
  }
  for {set i 100} {$i < 5000} {incr i} {
    execsql { INSERT INTO t2 VALUES(randomblob($i)) }
  }
  execsql { DELETE FROM t1 }
} {}

do_test 1.6.2 { 
  set n 0
  detect_blob_prepare test.db
  for {set i 2} {$i <= 850} {incr i 5} {
    incr n [detect_blob {} $i]
  }
  set n
} {0}

finish_test