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

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

Issue 6990047: Import SQLite 3.7.6.3. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « third_party/sqlite/src/test/notify3.test ('k') | third_party/sqlite/src/test/pager1.test » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 # 2011 February 19
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 # This file implements regression tests for SQLite library. The
12 # focus of this file is testing that error messages are logged via the
13 # sqlite3_log() mechanism when certain errors are encountered in the
14 # default unix or windows VFS modules.
15 #
16
17 set testdir [file dirname $argv0]
18 source $testdir/tester.tcl
19 if {$::tcl_platform(platform)!="unix"} { finish_test ; return }
20 set ::testprefix oserror
21
22 db close
23 sqlite3_shutdown
24 test_sqlite3_log xLog
25 proc xLog {error_code msg} {
26 if {[string match os_* $msg]} {
27 lappend ::log $msg
28 }
29 }
30
31 proc do_re_test {tn script expression} {
32 uplevel do_test $tn [list [subst -nocommands {
33 set res [eval { $script }]
34 if {[regexp {$expression} [set res]]} {
35 set {} {$expression}
36 } else {
37 set res
38 }
39 }]] [list $expression]
40
41 }
42
43 #--------------------------------------------------------------------------
44 # Tests oserror-1.* test failures in the open() system call.
45 #
46
47 # Test a failure in open() due to too many files.
48 #
49 # The xOpen() method of the unix VFS calls getcwd() as well as open().
50 # Although this does not appear to be documented in the man page, on OSX
51 # a call to getcwd() may fail if there are no free file descriptors. So
52 # an error may be reported for either open() or getcwd() here.
53 #
54 do_test 1.1.1 {
55 set ::log [list]
56 list [catch {
57 for {set i 0} {$i < 2000} {incr i} { sqlite3 dbh_$i test.db -readonly 1 }
58 } msg] $msg
59 } {1 {unable to open database file}}
60 do_test 1.1.2 {
61 catch { for {set i 0} {$i < 2000} {incr i} { dbh_$i close } }
62 } {1}
63 do_re_test 1.1.3 {
64 lindex $::log 0
65 } {^os_unix.c:\d+: \(\d+\) (open|getcwd)\(.*test.db\) - }
66
67
68 # Test a failure in open() due to the path being a directory.
69 #
70 do_test 1.2.1 {
71 file mkdir dir.db
72 set ::log [list]
73 list [catch { sqlite3 dbh dir.db } msg] $msg
74 } {1 {unable to open database file}}
75
76 do_re_test 1.2.2 { lindex $::log 0 } {^os_unix.c:\d+: \(\d+\) open\(.*dir.db\) - }
77
78 # Test a failure in open() due to the path not existing.
79 #
80 do_test 1.3.1 {
81 set ::log [list]
82 list [catch { sqlite3 dbh /x/y/z/test.db } msg] $msg
83 } {1 {unable to open database file}}
84
85 do_re_test 1.3.2 { lindex $::log 0 } {^os_unix.c:\d+: \(\d+\) open\(.*test.db\) - }
86
87 # Test a failure in open() due to the path not existing.
88 #
89 do_test 1.4.1 {
90 set ::log [list]
91 list [catch { sqlite3 dbh /root/test.db } msg] $msg
92 } {1 {unable to open database file}}
93
94 do_re_test 1.4.2 { lindex $::log 0 } {^os_unix.c:\d*: \(\d+\) open\(.*test.db\) - }
95
96 #--------------------------------------------------------------------------
97 # Tests oserror-1.* test failures in the unlink() system call.
98 #
99 do_test 2.1.1 {
100 set ::log [list]
101 file mkdir test.db-wal
102 forcedelete test.db
103 list [catch {
104 sqlite3 dbh test.db
105 execsql { SELECT * FROM sqlite_master } dbh
106 } msg] $msg
107 } {1 {disk I/O error}}
108
109 do_re_test 2.1.2 {
110 lindex $::log 0
111 } {^os_unix.c:\d+: \(\d+\) unlink\(.*test.db-wal\) - }
112 do_test 2.1.3 {
113 catch { dbh close }
114 forcedelete test.db-wal
115 } {}
116
117
118 test_syscall reset
119 sqlite3_shutdown
120 test_sqlite3_log
121 sqlite3_initialize
122 finish_test
OLDNEW
« no previous file with comments | « third_party/sqlite/src/test/notify3.test ('k') | third_party/sqlite/src/test/pager1.test » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698