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

Side by Side Diff: third_party/sqlite/src/test/incrblob_err.test

Issue 901033002: Import SQLite 3.8.7.4. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Chromium changes to support SQLite 3.8.7.4. 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
1 # 2007 May 1 1 # 2007 May 1
2 # 2 #
3 # The author disclaims copyright to this source code. In place of 3 # The author disclaims copyright to this source code. In place of
4 # a legal notice, here is a blessing: 4 # a legal notice, here is a blessing:
5 # 5 #
6 # May you do good and not evil. 6 # May you do good and not evil.
7 # May you find forgiveness for yourself and forgive others. 7 # May you find forgiveness for yourself and forgive others.
8 # May you share freely, never taking more than you give. 8 # May you share freely, never taking more than you give.
9 # 9 #
10 #*********************************************************************** 10 #***********************************************************************
11 # 11 #
12 # $Id: incrblob_err.test,v 1.14 2008/07/18 17:16:27 drh Exp $ 12 # $Id: incrblob_err.test,v 1.14 2008/07/18 17:16:27 drh Exp $
13 # 13 #
14 14
15 set testdir [file dirname $argv0] 15 set testdir [file dirname $argv0]
16 source $testdir/tester.tcl 16 source $testdir/tester.tcl
17 set ::testprefix incrblob_err
17 18
18 ifcapable {!incrblob || !memdebug || !tclvar} { 19 ifcapable {!incrblob || !memdebug || !tclvar} {
19 finish_test 20 finish_test
20 return 21 return
21 } 22 }
22 23
23 source $testdir/malloc_common.tcl 24 source $testdir/malloc_common.tcl
24 25
25 unset -nocomplain ::fd ::data 26 unset -nocomplain ::fd ::data
26 set ::fd [open [info script]] 27 set ::fd [open [info script]]
27 set ::data [read $::fd] 28 set ::data [read $::fd]
28 close $::fd 29 close $::fd
29 30
30 do_malloc_test 1 -tclprep { 31 do_malloc_test 1 -tclprep {
31 set bytes [file size [info script]] 32 set bytes [file size [info script]]
32 execsql { 33 execsql {
33 CREATE TABLE blobs(k, v BLOB); 34 CREATE TABLE blobs(k, v BLOB);
34 INSERT INTO blobs VALUES(1, zeroblob($::bytes)); 35 INSERT INTO blobs VALUES(1, zeroblob($::bytes));
35 } 36 }
36 } -tclbody { 37 } -tclbody {
37 set ::blob [db incrblob blobs v 1] 38 set ::blob [db incrblob blobs v 1]
39 fconfigure $::blob -translation binary
38 set rc [catch {puts -nonewline $::blob $::data}] 40 set rc [catch {puts -nonewline $::blob $::data}]
39 if {$rc} { error "out of memory" } 41 if {$rc} { error "out of memory" }
40 } 42 }
41 43
42 do_malloc_test 2 -tclprep { 44 do_malloc_test 2 -tclprep {
43 execsql { 45 execsql {
44 CREATE TABLE blobs(k, v BLOB); 46 CREATE TABLE blobs(k, v BLOB);
45 INSERT INTO blobs VALUES(1, $::data); 47 INSERT INTO blobs VALUES(1, $::data);
46 } 48 }
47 } -tclbody { 49 } -tclbody {
(...skipping 16 matching lines...) Expand all
64 set rc [catch {set ::r [read $::blob]}] 66 set rc [catch {set ::r [read $::blob]}]
65 if {$rc} { 67 if {$rc} {
66 error "out of memory" 68 error "out of memory"
67 } elseif {$::r ne $::data} { 69 } elseif {$::r ne $::data} {
68 error "Bad data read..." 70 error "Bad data read..."
69 } 71 }
70 set rc [catch {close $::blob}] 72 set rc [catch {close $::blob}]
71 if {$rc} { 73 if {$rc} {
72 error "out of memory" 74 error "out of memory"
73 } 75 }
74 } 76 }
75
76 77
77 do_ioerr_test incrblob_err-4 -cksum 1 -sqlprep { 78 do_ioerr_test incrblob_err-4 -cksum 1 -sqlprep {
78 CREATE TABLE blobs(k, v BLOB); 79 CREATE TABLE blobs(k, v BLOB);
79 INSERT INTO blobs VALUES(1, $::data); 80 INSERT INTO blobs VALUES(1, $::data);
80 } -tclbody { 81 } -tclbody {
81 set ::blob [db incrblob blobs v 1] 82 set ::blob [db incrblob blobs v 1]
82 read $::blob 83 read $::blob
83 } 84 }
84 85
85 do_ioerr_test incrblob_err-5 -cksum 1 -sqlprep { 86 do_ioerr_test incrblob_err-5 -cksum 1 -sqlprep {
86 CREATE TABLE blobs(k, v BLOB); 87 CREATE TABLE blobs(k, v BLOB);
87 INSERT INTO blobs VALUES(1, zeroblob(length(CAST($::data AS BLOB)))); 88 INSERT INTO blobs VALUES(1, zeroblob(length(CAST($::data AS BLOB))));
88 } -tclbody { 89 } -tclbody {
89 set ::blob [db incrblob blobs v 1] 90 set ::blob [db incrblob blobs v 1]
91 fconfigure $::blob -translation binary
90 puts -nonewline $::blob $::data 92 puts -nonewline $::blob $::data
91 close $::blob 93 close $::blob
92 } 94 }
93 95
94 do_ioerr_test incrblob_err-6 -cksum 1 -sqlprep { 96 do_ioerr_test incrblob_err-6 -cksum 1 -sqlprep {
95 CREATE TABLE blobs(k, v BLOB); 97 CREATE TABLE blobs(k, v BLOB);
96 INSERT INTO blobs VALUES(1, $::data || $::data || $::data); 98 INSERT INTO blobs VALUES(1, $::data || $::data || $::data);
97 } -tclbody { 99 } -tclbody {
98 set ::blob [db incrblob blobs v 1] 100 set ::blob [db incrblob blobs v 1]
101 fconfigure $::blob -translation binary
99 seek $::blob -20 end 102 seek $::blob -20 end
100 puts -nonewline $::blob "12345678900987654321" 103 puts -nonewline $::blob "12345678900987654321"
101 close $::blob 104 close $::blob
102 } 105 }
103 106
104 do_ioerr_test incrblob_err-7 -cksum 1 -sqlprep { 107 do_ioerr_test incrblob_err-7 -cksum 1 -sqlprep {
105 PRAGMA auto_vacuum = 1; 108 PRAGMA auto_vacuum = 1;
106 CREATE TABLE blobs(k INTEGER PRIMARY KEY, v BLOB); 109 CREATE TABLE blobs(k INTEGER PRIMARY KEY, v BLOB);
107 INSERT INTO blobs VALUES(1, zeroblob(500 * 1020)); 110 INSERT INTO blobs VALUES(1, zeroblob(500 * 1020));
108 } -tclbody { 111 } -tclbody {
(...skipping 19 matching lines...) Expand all
128 # 131 #
129 sqlite3 db2 test.db 132 sqlite3 db2 test.db
130 set ::blob [db2 incrblob blobs v 1] 133 set ::blob [db2 incrblob blobs v 1]
131 sqlite3_blob_write $::blob [expr 500*1020-20] 12345678900987654321 134 sqlite3_blob_write $::blob [expr 500*1020-20] 12345678900987654321
132 close $::blob 135 close $::blob
133 } 136 }
134 137
135 catch {db2 close} 138 catch {db2 close}
136 139
137 finish_test 140 finish_test
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698