CoolFace
Modelpublic

AryaWu/sqlite

sourceHugging Faceupdated 9mo agoView on Hugging Face
0likes
symlink2.test119 linesDownload Raw Back to test
1# 2019 November 182#3# The author disclaims copyright to this source code.  In place of4# 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.  The12# focus of this file is testing that SQLite can follow symbolic links.13#14 15set testdir [file dirname $argv0]16source $testdir/tester.tcl17set testprefix symlink218 19# This only runs on Windows.20if {$::tcl_platform(platform) ne "windows"} {21  finish_test22  return23}24 25proc createWin32Symlink { link target } {26  exec -- $::env(ComSpec) /c mklink \27      [file nativename $link] [file nativename $target]28  return ""29}30 31proc deleteWin32Symlink { link } {32  exec -- $::env(ComSpec) /c del [file nativename $link]33  return ""34}35 36proc 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 $link42    return 143  }44  return 045}46 47# Creating symlinks may require administrator privileges on Windows.48if {![canCreateWin32Symlink]} {49  finish_test50  return51}52 53# Ensure that test.db has been created.54#55do_execsql_test 1.0 {56  CREATE TABLE t1(x, y);57  INSERT INTO t1 VALUES(1,9999);58}59 60forcedelete link.db61do_test 2.0 {62  createWin32Symlink link.db test.db63} {}64 65do_test 2.1 {66  file exists test.db67} {1}68 69do_test 2.2 {70  file exists link.db71} {1}72 73do_test 3.1 {74  execsql { SELECT x, y FROM t1; } db75} {1 9999}76 77do_test 3.2 {78  sqlite3 db2 link.db79  execsql { SELECT x, y FROM t1; } db280} {1 9999}81 82do_test 3.3 {83  sqlite3 db3 test.db -nofollow true84  execsql { SELECT x, y FROM t1; } db385} {1 9999}86 87do_test 3.4 {88  db3 close89} {}90 91# The -nofollow option does not work on Windows92do_test 3.5 {93  list [catch {94    sqlite3 db4 link.db -nofollow true95    execsql { SELECT x, y FROM t1; } db496  } res] $res97} {0 {1 9999}}98 99catch {db4 close}100 101do_test 4.0 {102  db2 close103  deleteWin32Symlink link.db104} {}105 106do_test 4.1 {107  file exists test.db108} {1}109 110do_test 4.2 {111  file exists link.db112} {0}113 114do_test 5.1 {115  execsql { SELECT x, y FROM t1; } db116} {1 9999}117 118finish_test119