mistachkin | 3741827 | 2013-08-28 05:49:39 +0000 | [diff] [blame] | 1 | # 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 | |
| 16 | if {$tcl_platform(platform)!="windows"} return |
| 17 | |
| 18 | set testdir [file dirname $argv0] |
| 19 | source $testdir/tester.tcl |
| 20 | set testprefix win32longpath |
| 21 | |
mistachkin | 4013875 | 2013-12-09 21:48:49 +0000 | [diff] [blame] | 22 | do_test 1.0 { |
| 23 | file_control_vfsname db |
| 24 | } win32 |
| 25 | |
mistachkin | 3741827 | 2013-08-28 05:49:39 +0000 | [diff] [blame] | 26 | db close |
| 27 | set path [file nativename [get_pwd]] |
| 28 | sqlite3 db [file join $path test.db] -vfs win32-longpath |
| 29 | |
| 30 | do_test 1.1 { |
mistachkin | 4013875 | 2013-12-09 21:48:49 +0000 | [diff] [blame] | 31 | file_control_vfsname db |
| 32 | } win32-longpath |
| 33 | |
| 34 | do_test 1.2 { |
mistachkin | 3741827 | 2013-08-28 05:49:39 +0000 | [diff] [blame] | 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} |
| 46 | |
| 47 | set longPath(1) \\\\?\\$path\\[pid] |
| 48 | make_win32_dir $longPath(1) |
| 49 | |
| 50 | set longPath(2) $longPath(1)\\[string repeat X 255] |
| 51 | make_win32_dir $longPath(2) |
| 52 | |
| 53 | set longPath(3) $longPath(2)\\[string repeat Y 255] |
| 54 | make_win32_dir $longPath(3) |
| 55 | |
| 56 | set fileName $longPath(3)\\test.db |
| 57 | |
mistachkin | 4013875 | 2013-12-09 21:48:49 +0000 | [diff] [blame] | 58 | do_test 1.3 { |
mistachkin | 3741827 | 2013-08-28 05:49:39 +0000 | [diff] [blame] | 59 | list [catch {sqlite3 db2 [string range $fileName 4 end]} msg] $msg |
| 60 | } {1 {unable to open database file}} |
| 61 | |
| 62 | sqlite3 db3 $fileName -vfs win32-longpath |
| 63 | |
mistachkin | 4013875 | 2013-12-09 21:48:49 +0000 | [diff] [blame] | 64 | do_test 1.4 { |
mistachkin | 3741827 | 2013-08-28 05:49:39 +0000 | [diff] [blame] | 65 | db3 eval { |
mistachkin | 3741827 | 2013-08-28 05:49:39 +0000 | [diff] [blame] | 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} |
| 76 | |
| 77 | db3 close |
| 78 | # puts " Database exists \{[exists_win32_path $fileName]\}" |
| 79 | |
| 80 | sqlite3 db3 $fileName -vfs win32-longpath |
| 81 | |
mistachkin | 4013875 | 2013-12-09 21:48:49 +0000 | [diff] [blame] | 82 | do_test 1.5 { |
mistachkin | 70e9ffa | 2013-08-28 07:42:43 +0000 | [diff] [blame] | 83 | db3 eval { |
| 84 | PRAGMA journal_mode = WAL; |
| 85 | } |
| 86 | } {wal} |
| 87 | |
mistachkin | 4013875 | 2013-12-09 21:48:49 +0000 | [diff] [blame] | 88 | do_test 1.6 { |
mistachkin | 3741827 | 2013-08-28 05:49:39 +0000 | [diff] [blame] | 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} |
| 99 | |
| 100 | db3 close |
| 101 | # puts " Database exists \{[exists_win32_path $fileName]\}" |
| 102 | |
| 103 | do_delete_win32_file $fileName |
| 104 | # puts " Files remaining \{[find_win32_file $longPath(3)\\*]\}" |
| 105 | |
| 106 | do_remove_win32_dir $longPath(3) |
| 107 | do_remove_win32_dir $longPath(2) |
| 108 | do_remove_win32_dir $longPath(1) |
| 109 | |
| 110 | finish_test |