blob: 01b4af70ac2360c685d1f3f0cf0099331e94bb30 [file] [log] [blame]
mistachkin37418272013-08-28 05:49:39 +00001# 2013 August 27
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 script is testing the file name handling provided
13# by the "win32-longpath" VFS.
14#
15
16if {$tcl_platform(platform)!="windows"} return
17
18set testdir [file dirname $argv0]
19source $testdir/tester.tcl
20set testprefix win32longpath
21
mistachkin40138752013-12-09 21:48:49 +000022do_test 1.0 {
23 file_control_vfsname db
24} win32
25
mistachkin37418272013-08-28 05:49:39 +000026db close
mistachkina8e41ec2020-05-15 01:18:07 +000027set rawPath [get_pwd]
28set path [file nativename $rawPath]
mistachkin37418272013-08-28 05:49:39 +000029sqlite3 db [file join $path test.db] -vfs win32-longpath
30
31do_test 1.1 {
mistachkin40138752013-12-09 21:48:49 +000032 file_control_vfsname db
33} win32-longpath
34
35do_test 1.2 {
mistachkin37418272013-08-28 05:49:39 +000036 db eval {
37 BEGIN EXCLUSIVE;
38 CREATE TABLE t1(x);
39 INSERT INTO t1 VALUES(1);
40 INSERT INTO t1 VALUES(2);
41 INSERT INTO t1 VALUES(3);
42 INSERT INTO t1 VALUES(4);
43 SELECT x FROM t1 ORDER BY x;
44 COMMIT;
45 }
46} {1 2 3 4}
47
48set longPath(1) \\\\?\\$path\\[pid]
mistachkina8e41ec2020-05-15 01:18:07 +000049set uriPath(1a) %5C%5C%3F%5C$path\\[pid]
50set uriPath(1b) %5C%5C%3F%5C$rawPath/[pid]
51
mistachkin37418272013-08-28 05:49:39 +000052make_win32_dir $longPath(1)
53
54set longPath(2) $longPath(1)\\[string repeat X 255]
mistachkina8e41ec2020-05-15 01:18:07 +000055set uriPath(2a) $uriPath(1a)\\[string repeat X 255]
56set uriPath(2b) $uriPath(1b)/[string repeat X 255]
57
mistachkin37418272013-08-28 05:49:39 +000058make_win32_dir $longPath(2)
59
60set longPath(3) $longPath(2)\\[string repeat Y 255]
mistachkina8e41ec2020-05-15 01:18:07 +000061set uriPath(3a) $uriPath(2a)\\[string repeat Y 255]
62set uriPath(3b) $uriPath(2b)/[string repeat Y 255]
63
mistachkin37418272013-08-28 05:49:39 +000064make_win32_dir $longPath(3)
65
66set fileName $longPath(3)\\test.db
67
mistachkina8e41ec2020-05-15 01:18:07 +000068set uri(1a) file:$uriPath(3a)\\test.db
69set uri(1b) file:$uriPath(3b)/test.db
70set uri(1c) file:///$uriPath(3a)\\test.db
71set uri(1d) file:///$uriPath(3b)/test.db
72set uri(1e) file://localhost/$uriPath(3a)\\test.db
73set uri(1f) file://localhost/$uriPath(3b)/test.db
74
mistachkin40138752013-12-09 21:48:49 +000075do_test 1.3 {
mistachkin37418272013-08-28 05:49:39 +000076 list [catch {sqlite3 db2 [string range $fileName 4 end]} msg] $msg
77} {1 {unable to open database file}}
78
79sqlite3 db3 $fileName -vfs win32-longpath
80
mistachkin40138752013-12-09 21:48:49 +000081do_test 1.4 {
mistachkin37418272013-08-28 05:49:39 +000082 db3 eval {
mistachkin37418272013-08-28 05:49:39 +000083 BEGIN EXCLUSIVE;
84 CREATE TABLE t1(x);
85 INSERT INTO t1 VALUES(5);
86 INSERT INTO t1 VALUES(6);
87 INSERT INTO t1 VALUES(7);
88 INSERT INTO t1 VALUES(8);
89 SELECT x FROM t1 ORDER BY x;
90 COMMIT;
91 }
92} {5 6 7 8}
93
94db3 close
95# puts " Database exists \{[exists_win32_path $fileName]\}"
96
97sqlite3 db3 $fileName -vfs win32-longpath
98
mistachkin40138752013-12-09 21:48:49 +000099do_test 1.5 {
mistachkin70e9ffa2013-08-28 07:42:43 +0000100 db3 eval {
101 PRAGMA journal_mode = WAL;
102 }
103} {wal}
104
mistachkin40138752013-12-09 21:48:49 +0000105do_test 1.6 {
mistachkin37418272013-08-28 05:49:39 +0000106 db3 eval {
107 BEGIN EXCLUSIVE;
108 INSERT INTO t1 VALUES(9);
109 INSERT INTO t1 VALUES(10);
110 INSERT INTO t1 VALUES(11);
111 INSERT INTO t1 VALUES(12);
112 SELECT x FROM t1 ORDER BY x;
113 COMMIT;
114 }
115} {5 6 7 8 9 10 11 12}
116
117db3 close
118# puts " Database exists \{[exists_win32_path $fileName]\}"
119
mistachkina8e41ec2020-05-15 01:18:07 +0000120foreach tn {1a 1b 1c 1d 1e 1f} {
121 sqlite3 db3 $uri($tn) -vfs win32-longpath -uri 1 -translatefilename 0
122
123 do_test 1.7.$tn {
124 db3 eval {
125 SELECT x FROM t1 ORDER BY x;
126 }
127 } {5 6 7 8 9 10 11 12}
128
129 db3 close
130}
131
mistachkin37418272013-08-28 05:49:39 +0000132do_delete_win32_file $fileName
133# puts " Files remaining \{[find_win32_file $longPath(3)\\*]\}"
134
135do_remove_win32_dir $longPath(3)
136do_remove_win32_dir $longPath(2)
137do_remove_win32_dir $longPath(1)
138
139finish_test