Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(193)

Side by Side Diff: third_party/sqlite/sqlite-src-3080704/test/securedel2.test

Issue 883353008: [sql] Import reference version of SQLite 3.8.7.4. (Closed) Base URL: http://chromium.googlesource.com/chromium/src.git@master
Patch Set: Hold back encoding change which is messing up patch. Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 # 2012 August 7
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 # Tests for the secure_delete pragma.
13 #
14
15 set testdir [file dirname $argv0]
16 source $testdir/tester.tcl
17 set ::testprefix securedel2
18
19 # Generate 1000 pseudo-random 64-bit blobs.
20 #
21 for {set i 1} {$i <= 1000} {incr i} {
22 set aBlob($i) [string range [db one {SELECT quote(randomblob(8))}] 2 end-1]
23 }
24
25 proc detect_blob_prepare {zFile} {
26 set nByte [file size $zFile]
27 set ::detect_blob_data [hexio_read $zFile 0 $nByte]
28 }
29
30 proc detect_blob {zFile iBlob} {
31 if {$zFile != ""} { detect_blob_prepare $zFile }
32 string match "*$::aBlob($iBlob)*" $::detect_blob_data
33 }
34
35 do_test 1.1 {
36 execsql { PRAGMA secure_delete = 1 }
37 execsql { PRAGMA auto_vacuum = 0 }
38 execsql { CREATE TABLE t1(x, y) }
39 for {set i 1} {$i <= 1000} {incr i} {
40 set x "X'[string repeat $aBlob($i) 1]'"
41 set y "X'[string repeat $aBlob($i) 500]'"
42 execsql "INSERT INTO t1 VALUES($x, $y)"
43 }
44 } {}
45
46 do_test 1.2 { detect_blob test.db 1 } {1}
47
48 forcecopy test.db test.db.bak
49 do_execsql_test 1.3.1 { PRAGMA secure_delete = 0 } {0}
50 do_execsql_test 1.3.2 { DELETE FROM t1 WHERE rowid = 1 }
51 do_test 1.3.3 { detect_blob test.db 1 } {1}
52
53 db close
54 forcecopy test.db.bak test.db
55 sqlite3 db test.db
56 do_execsql_test 1.4.1 { PRAGMA secure_delete = 1 } {1}
57 do_execsql_test 1.4.2 { DELETE FROM t1 WHERE rowid = 1 }
58 do_test 1.4.3 { detect_blob test.db 1 } {0}
59
60 do_execsql_test 1.5.1 { DELETE FROM t1 WHERE rowid>850 } {}
61 do_test 1.5.2 {
62 set n 0
63 detect_blob_prepare test.db
64 for {set i 851} {$i <= 1000} {incr i 5} {
65 incr n [detect_blob {} $i]
66 }
67 set n
68 } {0}
69
70 db close
71 sqlite3 db test.db
72 do_test 1.6.1 {
73 execsql {
74 PRAGMA cache_size = 200;
75 PRAGMA secure_delete = 1;
76 CREATE TABLE t2(x);
77 SELECT * FROM t1;
78 }
79 for {set i 100} {$i < 5000} {incr i} {
80 execsql { INSERT INTO t2 VALUES(randomblob($i)) }
81 }
82 execsql { DELETE FROM t1 }
83 } {}
84
85 do_test 1.6.2 {
86 set n 0
87 detect_blob_prepare test.db
88 for {set i 2} {$i <= 850} {incr i 5} {
89 incr n [detect_blob {} $i]
90 }
91 set n
92 } {0}
93
94 finish_test
OLDNEW
« no previous file with comments | « third_party/sqlite/sqlite-src-3080704/test/securedel.test ('k') | third_party/sqlite/sqlite-src-3080704/test/select1.test » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698