From da2d3610f9a00aff0dce0a6bc7037d9df4253124 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Wed, 23 Dec 2020 07:42:19 +0000 Subject: Fix testcase for [548cd945d6]: Consistant error-code if creating link fails on all platforms. On Win10 disable the testcase, because latest Win10 in "Developer Mode" _can_ create symbolic links to files. --- tests/fCmd.test | 12 +++++++----- win/tclWinFile.c | 6 +++--- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/tests/fCmd.test b/tests/fCmd.test index 046fa17..61c9b5d 100644 --- a/tests/fCmd.test +++ b/tests/fCmd.test @@ -24,7 +24,7 @@ testConstraint testsetplatform [llength [info commands testsetplatform]] testConstraint testchmod [llength [info commands testchmod]] testConstraint winVista 0 testConstraint win2000orXP 0 -testConstraint win10 0 +testConstraint winLessThan10 0 # Don't know how to determine this constraint correctly testConstraint notNetworkFilesystem 0 testConstraint reg 0 @@ -67,8 +67,8 @@ if {[testConstraint unix]} { # Also used in winFCmd... if {[testConstraint win] && [testConstraint nt]} { if {$::tcl_platform(osVersion) >= 5.0} { - if {$::tcl_platform(osVersion) >= 10.0} { - testConstraint win10 1 + if {$::tcl_platform(osVersion) < 10.0} { + testConstraint winLessThan10 1 } if {$::tcl_platform(osVersion) >= 6.0} { testConstraint winVista 1 @@ -2359,13 +2359,15 @@ test fCmd-28.7 {file link: source already exists} -setup { } -returnCodes error -cleanup { cd [workingDirectory] } -result {could not create new link "abc.file": that path already exists} -test fCmd-28.8 {file link} -constraints {linkFile win10} -setup { +# In Windows 10 developer mode, we _can_ create symbolic links to files! +test fCmd-28.8 {file link} -constraints {linkFile} -setup { cd [temporaryDirectory] } -body { file link -symbolic abc.link abc.file } -cleanup { + file delete -force abc.link cd [workingDirectory] -} -result abc.file +} -returnCodes error -result {could not create new link "abc.link" pointing to "abc.file": invalid argument} test fCmd-28.9 {file link: success with file} -constraints {linkFile} -setup { cd [temporaryDirectory] file delete -force abc.link diff --git a/win/tclWinFile.c b/win/tclWinFile.c index 6aacde6..fba82d7 100644 --- a/win/tclWinFile.c +++ b/win/tclWinFile.c @@ -268,7 +268,7 @@ WinLink( /* * Can't symlink files. */ - Tcl_SetErrno(ENOTDIR); + Tcl_SetErrno(EINVAL); } else if (tclWinProcs.createSymbolicLink(linkSourcePath, linkTargetPath, 0x2 /* SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE */)) { /* @@ -276,9 +276,9 @@ WinLink( */ return 0; + } else { + TclWinConvertError(GetLastError()); } - - TclWinConvertError(GetLastError()); } else { Tcl_SetErrno(ENODEV); } -- cgit v0.12 From a1c17947a68b03c30749dc651fe7fa0d1712ada8 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Wed, 23 Dec 2020 07:44:27 +0000 Subject: (cherry-pick): Repair flaws exposed by debugging test run. --- tests/chanio.test | 4 ++-- tests/safe.test | 3 +++ tests/socket.test | 8 ++++---- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/tests/chanio.test b/tests/chanio.test index 28da530..5381a88 100644 --- a/tests/chanio.test +++ b/tests/chanio.test @@ -6497,10 +6497,10 @@ test chan-io-50.5 {testing handler deletion vs reentrant calls} -setup { set u recursive lappend z "del calling recursive" set timer [after 50 lappend z timeout] - set mode [test servicemode 1] + set mode [testservicemode 1] vwait z after cancel $timer - test servicemode $mode + testservicemode $mode lappend z "del after update" } } diff --git a/tests/safe.test b/tests/safe.test index 1c27c1e..e4c3442 100644 --- a/tests/safe.test +++ b/tests/safe.test @@ -174,6 +174,8 @@ test safe-4.6 {safe::interpDelete, indirectly} -setup { # A replacement test using example files is "safe-9.8". # Tests 5.* test the example files before using them to test safe interpreters. +unset -nocomplain path + test safe-5.1 {example tclIndex commands, test in parent interpreter} -setup { set tmpAutoPath $::auto_path lappend ::auto_path [file join $TestsDir auto0 auto1] [file join $TestsDir auto0 auto2] @@ -1659,6 +1661,7 @@ test safe-16.8 {Bug 3529949: defang ~user in paths used by AliasGlob (2)} -setup # cleanup set ::auto_path $SaveAutoPath unset SaveAutoPath TestsDir PathMapp +unset -nocomplain path rename mapList {} rename mapAndSortList {} ::tcltest::cleanupTests diff --git a/tests/socket.test b/tests/socket.test index b590fc7..0dfff53 100644 --- a/tests/socket.test +++ b/tests/socket.test @@ -1841,7 +1841,7 @@ proc transf_test {{testmode transfer} {maxIter 1000} {maxTime 10000}} { set ::count [expr {$maxIter / 4 * 3 - 1}]; # bypass 3/4 iterations } } - tcltest::DebugPuts 1 "== test \[$::localhost\]:$port $testmode ==" + tcltest::DebugPuts 2 "== test \[$::localhost\]:$port $testmode ==" set ::parent [thread::id] # helper thread creating async connection and initiating transfer (detach) to parent: set ::helper [thread::create] @@ -1869,7 +1869,7 @@ proc transf_test {{testmode transfer} {maxIter 1000} {maxTime 10000}} { } # parent proc commiting transfer attempt (attach) and checking acquire was successful: proc transf_parent {fd args} { - tcltest::DebugPuts 1 "** trma / $::count ** $args **" + tcltest::DebugPuts 2 "** trma / $::count ** $args **" thread::attach $fd if {"parent-close" in $::testmode} {;# to test close during connect set ::count $::count @@ -1896,7 +1896,7 @@ proc transf_test {{testmode transfer} {maxIter 1000} {maxTime 10000}} { break } if {[incr ::count] >= $maxIter} break - tcltest::DebugPuts 1 "** iter / $::count **" + tcltest::DebugPuts 2 "** iter / $::count **" thread::send -async $::helper [list iteration nr $::count] } update @@ -1905,7 +1905,7 @@ proc transf_test {{testmode transfer} {maxIter 1000} {maxTime 10000}} { catch {after cancel $tout} if {$srvsock ne {}} {close $srvsock} if {[info exists ::helper]} {thread::release -wait $::helper} - tcltest::DebugPuts 1 "== stop / $::count ==" + tcltest::DebugPuts 2 "== stop / $::count ==" unset -nocomplain ::count ::testmode ::parent ::helper } } -- cgit v0.12