blob: 0a6a8f98e66bd991742198b759aec4c3c817b728 [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
mistachkin37418272013-08-28 05:49:39 +000022db close
23set path [file nativename [get_pwd]]
24sqlite3 db [file join $path test.db] -vfs win32-longpath
25
26do_test 1.1 {
27 db eval {
28 BEGIN EXCLUSIVE;
29 CREATE TABLE t1(x);
30 INSERT INTO t1 VALUES(1);
31 INSERT INTO t1 VALUES(2);
32 INSERT INTO t1 VALUES(3);
33 INSERT INTO t1 VALUES(4);
34 SELECT x FROM t1 ORDER BY x;
35 COMMIT;
36 }
37} {1 2 3 4}
38
39set longPath(1) \\\\?\\$path\\[pid]
40make_win32_dir $longPath(1)
41
42set longPath(2) $longPath(1)\\[string repeat X 255]
43make_win32_dir $longPath(2)
44
45set longPath(3) $longPath(2)\\[string repeat Y 255]
46make_win32_dir $longPath(3)
47
48set fileName $longPath(3)\\test.db
49
50do_test 1.2 {
51 list [catch {sqlite3 db2 [string range $fileName 4 end]} msg] $msg
52} {1 {unable to open database file}}
53
54sqlite3 db3 $fileName -vfs win32-longpath
55
56do_test 1.3 {
57 db3 eval {
mistachkin37418272013-08-28 05:49:39 +000058 BEGIN EXCLUSIVE;
59 CREATE TABLE t1(x);
60 INSERT INTO t1 VALUES(5);
61 INSERT INTO t1 VALUES(6);
62 INSERT INTO t1 VALUES(7);
63 INSERT INTO t1 VALUES(8);
64 SELECT x FROM t1 ORDER BY x;
65 COMMIT;
66 }
67} {5 6 7 8}
68
69db3 close
70# puts " Database exists \{[exists_win32_path $fileName]\}"
71
72sqlite3 db3 $fileName -vfs win32-longpath
73
mistachkin70e9ffa2013-08-28 07:42:43 +000074do_test 1.4 {
75 db3 eval {
76 PRAGMA journal_mode = WAL;
77 }
78} {wal}
79
mistachkin37418272013-08-28 05:49:39 +000080do_test 1.5 {
81 db3 eval {
82 BEGIN EXCLUSIVE;
83 INSERT INTO t1 VALUES(9);
84 INSERT INTO t1 VALUES(10);
85 INSERT INTO t1 VALUES(11);
86 INSERT INTO t1 VALUES(12);
87 SELECT x FROM t1 ORDER BY x;
88 COMMIT;
89 }
90} {5 6 7 8 9 10 11 12}
91
92db3 close
93# puts " Database exists \{[exists_win32_path $fileName]\}"
94
95do_delete_win32_file $fileName
96# puts " Files remaining \{[find_win32_file $longPath(3)\\*]\}"
97
98do_remove_win32_dir $longPath(3)
99do_remove_win32_dir $longPath(2)
100do_remove_win32_dir $longPath(1)
101
102finish_test