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 file is testing that SQLite can follow symbolic links.
15 set testdir [file dirname $argv0]
16 source $testdir/tester.tcl
17 set testprefix symlink2
19 # This only runs on Windows.
20 if {$::tcl_platform(platform)!="windows"} {
25 proc createWin32Symlink { link target } {
26 exec -- $::env(ComSpec) /c mklink \
27 [file nativename $link] [file nativename $target]
31 proc deleteWin32Symlink { link } {
32 exec -- $::env(ComSpec) /c del [file nativename $link]
36 proc canCreateWin32Symlink {} {
37 set link [file join $::testdir lnk[pid].sym]
38 if {[file exists $link]} { return 0 }
39 set target [info nameofexecutable]
40 if {[catch {createWin32Symlink $link $target}] == 0} {
41 deleteWin32Symlink $link
47 # Creating symlinks may require administrator privileges on Windows.
48 if {![canCreateWin32Symlink]} {
53 # Ensure that test.db has been created.
56 CREATE TABLE t1(x, y);
57 INSERT INTO t1 VALUES(1,9999);
61 createWin32Symlink link.db test.db
73 execsql { SELECT x, y FROM t1; } db
78 execsql { SELECT x, y FROM t1; } db2
82 sqlite3 db3 test.db -nofollow true
83 execsql { SELECT x, y FROM t1; } db3
92 sqlite3 db4 link.db -nofollow true
93 execsql { SELECT x, y FROM t1; } db4
95 } {1 {unable to open database file}}
101 deleteWin32Symlink link.db
113 execsql { SELECT x, y FROM t1; } db