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

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

Issue 2751253002: [sql] Import SQLite 3.17.0. (Closed)
Patch Set: also clang on Linux i386 Created 3 years, 9 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
« no previous file with comments | « third_party/sqlite/src/test/superlock.test ('k') | third_party/sqlite/src/test/sync.test » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # 2015 October 31 1 # 2015 October 31
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 #***********************************************************************
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 list [catch { sqlite3 db $name } msg] $msg 76 list [catch { sqlite3 db $name } msg] $msg
77 } {1 {unable to open database file}} 77 } {1 {unable to open database file}}
78 78
79 #------------------------------------------------------------------------- 79 #-------------------------------------------------------------------------
80 # Test that journal and wal files are created next to the real file, 80 # Test that journal and wal files are created next to the real file,
81 # not the symlink. 81 # not the symlink.
82 # 82 #
83 do_test 2.0 { 83 do_test 2.0 {
84 catch { db close } 84 catch { db close }
85 catch { db2 close } 85 catch { db2 close }
86 forcedelete test.db test.db2 86 forcedelete test.db test.db2 test.db3
87 sqlite3 db test.db 87 sqlite3 db test.db
88 execsql { CREATE TABLE t1(x) } 88 execsql { CREATE TABLE t1(x) }
89 file link test.db2 test.db 89 file link test.db2 test.db
90 sqlite3 db2 test.db2 90 file link test.db3 test.db2
91 file exists test.db-journal 91 set {} {}
92 } 0 92 } {}
93 93
94 do_test 2.1 { 94 foreach {tn f} {1 test.db2 2 test.db3} {
95 execsql { 95 do_test 2.$tn.1 {
96 BEGIN; 96 sqlite3 db2 $f
97 INSERT INTO t1 VALUES(1); 97 file exists test.db-journal
98 } db2 98 } 0
99 file exists test.db-journal 99 do_test 2.$tn.2 {
100 } 1 100 execsql {
101 do_test 2.2 { 101 BEGIN;
102 file exists test.db2-journal 102 INSERT INTO t1 VALUES(1);
103 } 0 103 } db2
104 do_test 2.3 { 104 file exists test.db-journal
105 execsql { 105 } 1
106 COMMIT; 106 do_test 2.$tn.3 {
107 PRAGMA journal_mode = wal; 107 list [file exists test2.db-journal] [file exists test3.db-journal]
108 INSERT INTO t1 VALUES(2); 108 } {0 0}
109 } db2 109 do_test 2.$tn.4 {
110 file exists test.db-wal 110 execsql {
111 } 1 111 COMMIT;
112 do_test 2.4 { 112 PRAGMA journal_mode = wal;
113 file exists test.db2-wal 113 INSERT INTO t1 VALUES(2);
114 } 0 114 } db2
115 do_execsql_test 2.5 { 115 file exists test.db-wal
116 SELECT * FROM t1; 116 } 1
117 } {1 2} 117 do_test 2.$tn.5 {
118 list [file exists test2.db-wal] [file exists test3.db-wal]
119 } {0 0}
120 do_execsql_test 2.$tn.6 {
121 SELECT * FROM t1;
122 } {1 2}
123 db2 close
124 do_execsql_test 2.$tn.7 {
125 DELETE FROM t1;
126 PRAGMA journal_mode = delete;
127 } delete
128 }
118 129
119 # Try to open a ridiculously long pathname. Bug found by 130 # Try to open a ridiculously long pathname. Bug found by
120 # Kostya Serebryany using libFuzzer on 2015-11-30. 131 # Kostya Serebryany using libFuzzer on 2015-11-30.
121 # 132 #
122 do_test 3.1 { 133 do_test 3.1 {
123 db close 134 db close
124 catch {sqlite3 db [string repeat [string repeat x 100]/ 6]} res 135 catch {sqlite3 db [string repeat [string repeat x 100]/ 6]} res
125 set res 136 set res
126 } {unable to open database file} 137 } {unable to open database file}
127 138
139 #-------------------------------------------------------------------------
140 # Test that relative symlinks that are not located in the cwd work.
141 #
142 do_test 4.1 {
143 forcedelete x y z
144 file mkdir x
145 file mkdir y
146 file mkdir z
147 sqlite3 db x/test.db
148 file link y/test.db ../x/test.db
149 file link z/test.db ../y/test.db
150 execsql {
151 PRAGMA journal_mode = wal;
152 CREATE TABLE t1(x, y);
153 INSERT INTO t1 VALUES('hello', 'world');
154 }
155 } {wal}
156
157 do_test 4.2.1 {
158 db close
159 sqlite3 db y/test.db
160 db eval { SELECT * FROM t1 }
161 } {hello world}
162 do_test 4.2.2 {
163 list [file exists x/test.db-wal] [file exists y/test.db-wal]
164 } {1 0}
165
166 do_test 4.3.1 {
167 db close
168 sqlite3 db z/test.db
169 db eval { SELECT * FROM t1 }
170 } {hello world}
171 do_test 4.3.2 {
172 list [file exists x/test.db-wal] [file exists y/test.db-wal] \
173 [file exists z/test.db-wal]
174 } {1 0 0}
175
176 do_test 4.4.0 {
177 forcedelete w
178 file mkdir w
179 file link w/test.db [file join [pwd] x/test.db]
180 set {} {}
181 } {}
182 do_test 4.4.1 {
183 db close
184 sqlite3 db w/test.db
185 db eval { SELECT * FROM t1 }
186 } {hello world}
187 do_test 4.4.2 {
188 list [file exists x/test.db-wal] [file exists w/test.db-wal]
189 } {1 0}
128 190
129 finish_test 191 finish_test
OLDNEW
« no previous file with comments | « third_party/sqlite/src/test/superlock.test ('k') | third_party/sqlite/src/test/sync.test » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698