blob: 9e9ed359c634cf91650b497bf30bc825f77a7c48 [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
27set path [file nativename [get_pwd]]
28sqlite3 db [file join $path test.db] -vfs win32-longpath
29
30do_test 1.1 {
mistachkin40138752013-12-09 21:48:49 +000031 file_control_vfsname db
32} win32-longpath
33
34do_test 1.2 {
mistachkin37418272013-08-28 05:49:39 +000035 db eval {
36 BEGIN EXCLUSIVE;
37 CREATE TABLE t1(x);
38 INSERT INTO t1 VALUES(1);
39 INSERT INTO t1 VALUES(2);
40 INSERT INTO t1 VALUES(3);
41 INSERT INTO t1 VALUES(4);
42 SELECT x FROM t1 ORDER BY x;
43 COMMIT;
44 }
45} {1 2 3 4}
46
47set longPath(1) \\\\?\\$path\\[pid]
48make_win32_dir $longPath(1)
49
50set longPath(2) $longPath(1)\\[string repeat X 255]
51make_win32_dir $longPath(2)
52
53set longPath(3) $longPath(2)\\[string repeat Y 255]
54make_win32_dir $longPath(3)
55
56set fileName $longPath(3)\\test.db
57
mistachkin40138752013-12-09 21:48:49 +000058do_test 1.3 {
mistachkin37418272013-08-28 05:49:39 +000059 list [catch {sqlite3 db2 [string range $fileName 4 end]} msg] $msg
60} {1 {unable to open database file}}
61
62sqlite3 db3 $fileName -vfs win32-longpath
63
mistachkin40138752013-12-09 21:48:49 +000064do_test 1.4 {
mistachkin37418272013-08-28 05:49:39 +000065 db3 eval {
mistachkin37418272013-08-28 05:49:39 +000066 BEGIN EXCLUSIVE;
67 CREATE TABLE t1(x);
68 INSERT INTO t1 VALUES(5);
69 INSERT INTO t1 VALUES(6);
70 INSERT INTO t1 VALUES(7);
71 INSERT INTO t1 VALUES(8);
72 SELECT x FROM t1 ORDER BY x;
73 COMMIT;
74 }
75} {5 6 7 8}
76
77db3 close
78# puts " Database exists \{[exists_win32_path $fileName]\}"
79
80sqlite3 db3 $fileName -vfs win32-longpath
81
mistachkin40138752013-12-09 21:48:49 +000082do_test 1.5 {
mistachkin70e9ffa2013-08-28 07:42:43 +000083 db3 eval {
84 PRAGMA journal_mode = WAL;
85 }
86} {wal}
87
mistachkin40138752013-12-09 21:48:49 +000088do_test 1.6 {
mistachkin37418272013-08-28 05:49:39 +000089 db3 eval {
90 BEGIN EXCLUSIVE;
91 INSERT INTO t1 VALUES(9);
92 INSERT INTO t1 VALUES(10);
93 INSERT INTO t1 VALUES(11);
94 INSERT INTO t1 VALUES(12);
95 SELECT x FROM t1 ORDER BY x;
96 COMMIT;
97 }
98} {5 6 7 8 9 10 11 12}
99
100db3 close
101# puts " Database exists \{[exists_win32_path $fileName]\}"
102
103do_delete_win32_file $fileName
104# puts " Files remaining \{[find_win32_file $longPath(3)\\*]\}"
105
106do_remove_win32_dir $longPath(3)
107do_remove_win32_dir $longPath(2)
108do_remove_win32_dir $longPath(1)
109
110finish_test