Enhance the command-line completion extension to return the names of
[sqlite.git] / test / win32longpath.test
blob9e9ed359c634cf91650b497bf30bc825f77a7c48
1 # 2013 August 27
3 # The author disclaims copyright to this source code.  In place of
4 # a legal notice, here is a blessing:
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.
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.
16 if {$tcl_platform(platform)!="windows"} return
18 set testdir [file dirname $argv0]
19 source $testdir/tester.tcl
20 set testprefix win32longpath
22 do_test 1.0 {
23   file_control_vfsname db
24 } win32
26 db close
27 set path [file nativename [get_pwd]]
28 sqlite3 db [file join $path test.db] -vfs win32-longpath
30 do_test 1.1 {
31   file_control_vfsname db
32 } win32-longpath
34 do_test 1.2 {
35   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}
47 set longPath(1) \\\\?\\$path\\[pid]
48 make_win32_dir $longPath(1)
50 set longPath(2) $longPath(1)\\[string repeat X 255]
51 make_win32_dir $longPath(2)
53 set longPath(3) $longPath(2)\\[string repeat Y 255]
54 make_win32_dir $longPath(3)
56 set fileName $longPath(3)\\test.db
58 do_test 1.3 {
59   list [catch {sqlite3 db2 [string range $fileName 4 end]} msg] $msg
60 } {1 {unable to open database file}}
62 sqlite3 db3 $fileName -vfs win32-longpath
64 do_test 1.4 {
65   db3 eval {
66     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}
77 db3 close
78 # puts "  Database exists \{[exists_win32_path $fileName]\}"
80 sqlite3 db3 $fileName -vfs win32-longpath
82 do_test 1.5 {
83   db3 eval {
84     PRAGMA journal_mode = WAL;
85   }
86 } {wal}
88 do_test 1.6 {
89   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}
100 db3 close
101 # puts "  Database exists \{[exists_win32_path $fileName]\}"
103 do_delete_win32_file $fileName
104 # puts "  Files remaining \{[find_win32_file $longPath(3)\\*]\}"
106 do_remove_win32_dir $longPath(3)
107 do_remove_win32_dir $longPath(2)
108 do_remove_win32_dir $longPath(1)
110 finish_test