summaryrefslogtreecommitdiffstats
path: root/tests/unixInit.test
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unixInit.test')
-rw-r--r--tests/unixInit.test225
1 files changed, 126 insertions, 99 deletions
diff --git a/tests/unixInit.test b/tests/unixInit.test
index a4a9249..003dd00 100644
--- a/tests/unixInit.test
+++ b/tests/unixInit.test
@@ -10,43 +10,34 @@
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-package require tcltest 2
+package require tcltest 2.2
namespace import -force ::tcltest::*
unset -nocomplain path
-if {[info exists env(TCL_LIBRARY)]} {
- set oldlibrary $env(TCL_LIBRARY)
- unset env(TCL_LIBRARY)
-}
catch {set oldlang $env(LANG)}
set env(LANG) C
-test unixInit-1.1 {TclpInitPlatform: ignore SIGPIPE} {unixOnly stdio} {
+test unixInit-1.1 {TclpInitPlatform: ignore SIGPIPE} {unix stdio} {
set x {}
-
# Watch out for a race condition here. If tcltest is too slow to start
# then we'll kill it before it has a chance to set up its signal handler.
-
set f [open "|[list [interpreter]]" w+]
puts $f "puts hi"
flush $f
gets $f
exec kill -PIPE [pid $f]
lappend x [catch {close $f}]
-
set f [open "|[list [interpreter]]" w+]
puts $f "puts hi"
flush $f
gets $f
exec kill [pid $f]
lappend x [catch {close $f}]
-
set x
} {0 1}
-
# This test is really a test of code in tclUnixChan.c, but the
# channels are set up as part of initialisation of the interpreter so
# the test seems to me to fit here as well as anywhere else.
-test unixInit-1.2 {initialisation: standard channel type deduction} {unixOnly stdio} {
+test unixInit-1.2 {initialisation: standard channel type deduction} {unix stdio} {
# pipe1 is a connection to a server that reports what port it
# starts on, and delivers a constant string to the first client to
# connect to that port before exiting.
@@ -57,7 +48,7 @@ test unixInit-1.2 {initialisation: standard channel type deduction} {unixOnly st
close $channel
exit
}
- puts [fconfigure [socket -server accept 0] -sockname]
+ puts [fconfigure [socket -server accept -myaddr 127.0.0.1 0] -sockname]
vwait forever \
}
# Note the backslash above; this is important to make sure that the
@@ -72,16 +63,13 @@ test unixInit-1.2 {initialisation: standard channel type deduction} {unixOnly st
# as a socket. Which is what this test is all about.
set pipe2 [open "|[list [interpreter] <@$sock]" r]
set result [gets $pipe2]
-
# Clear any pending data; stops certain kinds of (non-important) errors
fconfigure $pipe1 -blocking 0; gets $pipe1
fconfigure $pipe2 -blocking 0; gets $pipe2
-
# Close the pipes and the socket.
close $pipe2
close $pipe1
catch {close $sock}
-
# Can't use normal comparison, as hostname varies due to some
# installations having a messed up /etc/hosts file.
if {
@@ -94,76 +82,100 @@ test unixInit-1.2 {initialisation: standard channel type deduction} {unixOnly st
}
} {OK}
-proc getlibpath [list [list program [interpreter]]] {
- set f [open "|[list $program]" w+]
- fconfigure $f -buffering none
- puts $f {puts $tcl_libPath; exit}
- set path [gets $f]
- close $f
- return $path
-}
+# The unixInit-2.* tests were written to test the internal routine,
+# TclpInitLibraryPath. That routine no longer does the things it used
+# to do so those tests are obsolete. Skip them.
-# Some tests require the testgetdefenc command
+skip [concat [skip] unixInit-2.*]
-testConstraint testgetdefenc [llength [info commands testgetdefenc]]
-
-test unixInit-2.0 {TclpInitLibraryPath: setting tclDefaultEncodingDir} \
- {unixOnly testgetdefenc} {
+test unixInit-2.0 {TclpInitLibraryPath: setting tclDefaultEncodingDir} {
set origDir [testgetdefenc]
testsetdefenc slappy
set path [testgetdefenc]
testsetdefenc $origDir
set path
} {slappy}
-test unixInit-2.1 {TclpInitLibraryPath: value of installLib, developLib} \
- {unixOnly stdio} {
+test unixInit-2.1 {TclpInitLibraryPath: value of installLib, developLib} -setup {
+ unset -nocomplain oldlibrary
+ if {[info exists env(TCL_LIBRARY)]} {
+ set oldlibrary $env(TCL_LIBRARY)
+ unset env(TCL_LIBRARY)
+ }
+} -body {
set path [getlibpath]
-
set installLib lib/tcl[info tclversion]
set developLib tcl[info patchlevel]/library
set prefix [file dirname [file dirname [interpreter]]]
-
set x {}
lappend x [string compare [lindex $path 0] $prefix/$installLib]
lappend x [string compare [lindex $path 4] [file dirname $prefix]/$developLib]
set x
-} {0 0}
-test unixInit-2.2 {TclpInitLibraryPath: TCL_LIBRARY} {unixOnly stdio} {
- # ((str != NULL) && (str[0] != '\0'))
-
+} -cleanup {
+ if {[info exists oldlibrary]} {
+ set env(TCL_LIBRARY) $oldlibrary
+ unset oldlibrary
+ }
+} -result {0 0}
+test unixInit-2.2 {TclpInitLibraryPath: TCL_LIBRARY} -setup {
+ unset -nocomplain oldlibrary
+ if {[info exists env(TCL_LIBRARY)]} {
+ set oldlibrary $env(TCL_LIBRARY)
+ }
+} -body {
+ # ((str != NULL) && (str[0] != '\0'))
set env(TCL_LIBRARY) sparkly
set path [getlibpath]
unset env(TCL_LIBRARY)
-
lindex $path 0
-} "sparkly"
-test unixInit-2.3 {TclpInitLibraryPath: TCL_LIBRARY wrong version} \
- {unixOnly stdio} {
+} -cleanup {
+ if {[info exists oldlibrary]} {
+ set env(TCL_LIBRARY) $oldlibrary
+ unset oldlibrary
+ }
+} -result "sparkly"
+test unixInit-2.3 {TclpInitLibraryPath: TCL_LIBRARY wrong version} -setup {
+ unset -nocomplain oldlibrary
+ if {[info exists env(TCL_LIBRARY)]} {
+ set oldlibrary $env(TCL_LIBRARY)
+ }
+} -body {
# ((pathc > 0) && (strcasecmp(installLib + 4, pathv[pathc - 1]) != 0))
-
set env(TCL_LIBRARY) /a/b/tcl1.7
set path [getlibpath]
unset env(TCL_LIBRARY)
-
lrange $path 0 1
-} [list /a/b/tcl1.7 /a/b/tcl[info tclversion]]
-test unixInit-2.4 {TclpInitLibraryPath: TCL_LIBRARY: INTL} \
- {unixOnly stdio} {
+} -cleanup {
+ if {[info exists oldlibrary]} {
+ set env(TCL_LIBRARY) $oldlibrary
+ unset oldlibrary
+ }
+} -result [list /a/b/tcl1.7 /a/b/tcl[info tclversion]]
+test unixInit-2.4 {TclpInitLibraryPath: TCL_LIBRARY: INTL} -setup {
+ if {[info exists env(TCL_LIBRARY)]} {
+ set oldlibrary $env(TCL_LIBRARY)
+ }
+} -body {
# Child process translates env variable from native encoding.
-
set env(TCL_LIBRARY) "\xa7"
set x [lindex [getlibpath] 0]
unset env(TCL_LIBRARY)
unset env(LANG)
-
set x
-} "\xa7"
-test unixInit-2.5 {TclpInitLibraryPath: compiled-in library path} \
- {emptyTest unixOnly} {
+} -cleanup {
+ if {[info exists oldlibrary]} {
+ set env(TCL_LIBRARY) $oldlibrary
+ unset oldlibrary
+ }
+} -result "\xa7"
+test unixInit-2.5 {TclpInitLibraryPath: compiled-in library path} {
# cannot test
} {}
-test unixInit-2.6 {TclpInitLibraryPath: executable relative} \
- {unixOnly stdio} {
+test unixInit-2.6 {TclpInitLibraryPath: executable relative} -setup {
+ unset -nocomplain oldlibrary
+ if {[info exists env(TCL_LIBRARY)]} {
+ set oldlibrary $env(TCL_LIBRARY)
+ }
+ set env(TCL_LIBRARY) [info library]
makeDirectory tmp
makeDirectory [file join tmp sparkly]
makeDirectory [file join tmp sparkly bin]
@@ -172,19 +184,23 @@ test unixInit-2.6 {TclpInitLibraryPath: executable relative} \
makeDirectory [file join tmp sparkly lib]
makeDirectory [file join tmp sparkly lib tcl[info tclversion]]
makeFile {} [file join tmp sparkly lib tcl[info tclversion] init.tcl]
-
- set x [lrange [getlibpath [file join [temporaryDirectory] tmp sparkly \
- bin tcltest]] 0 1]
+} -body {
+ lrange [getlibpath [file join [temporaryDirectory] tmp sparkly \
+ bin tcltest]] 1 2
+} -cleanup {
removeFile [file join tmp sparkly lib tcl[info tclversion] init.tcl]
removeDirectory [file join tmp sparkly lib tcl[info tclversion]]
removeDirectory [file join tmp sparkly lib]
removeDirectory [file join tmp sparkly bin]
removeDirectory [file join tmp sparkly]
removeDirectory tmp
- set x
-} [list [temporaryDirectory]/tmp/sparkly/lib/tcl[info tclversion] [temporaryDirectory]/tmp/lib/tcl[info tclversion]]
-test unixInit-2.7 {TclpInitLibraryPath: compiled-in library path} \
- {emptyTest unixOnly} {
+ unset env(TCL_LIBRARY)
+ if {[info exists oldlibrary]} {
+ set env(TCL_LIBRARY) $oldlibrary
+ unset oldlibrary
+ }
+} -result [list [temporaryDirectory]/tmp/sparkly/lib/tcl[info tclversion] [temporaryDirectory]/tmp/lib/tcl[info tclversion]]
+test unixInit-2.7 {TclpInitLibraryPath: compiled-in library path} {
# would need test command to get defaultLibDir and compare it to
# [lindex $auto_path end]
} {}
@@ -194,10 +210,12 @@ test unixInit-2.7 {TclpInitLibraryPath: compiled-in library path} \
# these tests need paths near the "root" of the file system to present
# themselves.
#
-testConstraint noSparkly [expr {![file exists [file join /tmp sparkly]]}]
-testConstraint noTmpInstall [expr {![file exists \
- [file join /tmp lib tcl[info tclversion]]]}]
-test unixInit-2.8 {TclpInitLibraryPath: all absolute pathtype} {unix noSparkly noTmpInstall} {
+test unixInit-2.8 {TclpInitLibraryPath: all absolute pathtype} -setup {
+ unset -nocomplain oldlibrary
+ if {[info exists env(TCL_LIBRARY)]} {
+ set oldlibrary $env(TCL_LIBRARY)
+ }
+ set env(TCL_LIBRARY) [info library]
# Checking for Bug 219416
# When a program that embeds the Tcl library, like tcltest, is
# installed near the "root" of the file system, there was a problem
@@ -217,7 +235,6 @@ test unixInit-2.8 {TclpInitLibraryPath: all absolute pathtype} {unix noSparkly n
file delete -force /tmp/lib/tcl[info tclversion]
file mkdir /tmp/sparkly
file copy [interpreter] /tmp/sparkly/tcltest
-
# Keep any existing /tmp/lib directory
set deletelib 1
if {[file exists /tmp/lib]} {
@@ -227,47 +244,60 @@ test unixInit-2.8 {TclpInitLibraryPath: all absolute pathtype} {unix noSparkly n
file delete -force /tmp/lib
}
}
-
# For a successful Tcl_Init, we need a [source]-able init.tcl in
# ../lib/tcl$version relative to the executable.
file mkdir /tmp/lib/tcl[info tclversion]
close [open /tmp/lib/tcl[info tclversion]/init.tcl w]
-
+} -body {
# Check that all directories in the library path are absolute pathnames
set allAbsolute 1
foreach dir [getlibpath /tmp/sparkly/tcltest] {
set allAbsolute [expr {$allAbsolute \
&& [string equal absolute [file pathtype $dir]]}]
}
-
+ set allAbsolute
+} -cleanup {
# Clean up temporary installation
file delete -force /tmp/sparkly
file delete -force /tmp/lib/tcl[info tclversion]
if {$deletelib} {file delete -force /tmp/lib}
- set allAbsolute
-} 1
-testConstraint noTmpBuild [expr {![file exists [file join /tmp library]]}]
-test unixInit-2.9 {TclpInitLibraryPath: paths relative to executable} {unix noSparkly noTmpBuild} {
+ unset env(TCL_LIBRARY)
+ if {[info exists oldlibrary]} {
+ set env(TCL_LIBRARY) $oldlibrary
+ unset oldlibrary
+ }
+} -result 1
+test unixInit-2.9 {TclpInitLibraryPath: paths relative to executable} -setup {
# Checking for Bug 438014
+ unset -nocomplain oldlibrary
+ if {[info exists env(TCL_LIBRARY)]} {
+ set oldlibrary $env(TCL_LIBRARY)
+ }
+ set env(TCL_LIBRARY) [info library]
file delete -force /tmp/sparkly
file delete -force /tmp/library
file mkdir /tmp/sparkly
file copy [interpreter] /tmp/sparkly/tcltest
-
file mkdir /tmp/library/
close [open /tmp/library/init.tcl w]
-
- set x [lrange [getlibpath /tmp/sparkly/tcltest] 0 4]
-
+} -body {
+ lrange [getlibpath /tmp/sparkly/tcltest] 1 5
+} -cleanup {
file delete -force /tmp/sparkly
file delete -force /tmp/library
- set x
-} [list /tmp/lib/tcl[info tclversion] /lib/tcl[info tclversion] \
+ unset env(TCL_LIBRARY)
+ if {[info exists oldlibrary]} {
+ set env(TCL_LIBRARY) $oldlibrary
+ unset oldlibrary
+ }
+} -result [list /tmp/lib/tcl[info tclversion] /lib/tcl[info tclversion] \
/tmp/library /library /tcl[info patchlevel]/library]
-
-test unixInit-2.10 {TclpInitLibraryPath: executable relative} -constraints {
- unixOnly stdio
-} -setup {
+test unixInit-2.10 {TclpInitLibraryPath: executable relative} -setup {
+ unset -nocomplain oldlibrary
+ if {[info exists env(TCL_LIBRARY)]} {
+ set oldlibrary $env(TCL_LIBRARY)
+ }
+ set env(TCL_LIBRARY) [info library]
set tmpDir [makeDirectory tmp]
set sparklyDir [makeDirectory sparkly $tmpDir]
set execPath [file join [makeDirectory bin $sparklyDir] tcltest]
@@ -279,9 +309,9 @@ test unixInit-2.10 {TclpInitLibraryPath: executable relative} -constraints {
cd $libDir
} -body {
# Checking for Bug 832657
- set x [lrange [getlibpath [file join .. bin tcltest]] 2 3]
+ set x [lrange [getlibpath [file join .. bin tcltest]] 3 4]
foreach p $x {
- lappend y [file normalize $p]
+ lappend y [file normalize $p]
}
set y
} -cleanup {
@@ -300,30 +330,31 @@ test unixInit-2.10 {TclpInitLibraryPath: executable relative} -constraints {
unset tmpDir
removeDirectory tmp
unset x p y
+ unset env(TCL_LIBRARY)
+ if {[info exists oldlibrary]} {
+ set env(TCL_LIBRARY) $oldlibrary
+ unset oldlibrary
+ }
} -result [list [file join [temporaryDirectory] tmp sparkly library] \
[file join [temporaryDirectory] tmp library] ]
test unixInit-3.1 {TclpSetInitialEncodings} -constraints {
- unixOnly stdio
+ unix stdio
} -body {
set env(LANG) C
-
set f [open "|[list [interpreter]]" w+]
fconfigure $f -buffering none
puts $f {puts [encoding system]; exit}
set enc [gets $f]
close $f
unset env(LANG)
-
set enc
} -match regexp -result [expr {
($tcl_platform(os) eq "Darwin") ? "^utf-8$" : "^iso8859-15?$"}]
-
-test unixInit-3.2 {TclpSetInitialEncodings} {unixOnly stdio} {
+test unixInit-3.2 {TclpSetInitialEncodings} {unix stdio} {
set env(LANG) japanese
catch {set oldlc_all $env(LC_ALL)}
set env(LC_ALL) japanese
-
set f [open "|[list [interpreter]]" w+]
fconfigure $f -buffering none
puts $f {puts [encoding system]; exit}
@@ -332,7 +363,6 @@ test unixInit-3.2 {TclpSetInitialEncodings} {unixOnly stdio} {
unset env(LANG)
unset env(LC_ALL)
catch {set env(LC_ALL) $oldlc_all}
-
set validEncodings [list euc-jp]
if {[string match HP-UX $tcl_platform(os)]} {
# Some older HP-UX systems need us to accept this as valid
@@ -343,23 +373,22 @@ test unixInit-3.2 {TclpSetInitialEncodings} {unixOnly stdio} {
expr {[lsearch -exact $validEncodings $enc] < 0}
} 0
-test unixInit-4.1 {TclpSetVariables} {unixOnly} {
+test unixInit-4.1 {TclpSetVariables} {unix} {
# just make sure they exist
-
set a [list $tcl_library $tcl_pkgPath $tcl_platform(os)]
set a [list $tcl_platform(osVersion) $tcl_platform(machine)]
set tcl_platform(platform)
} "unix"
-test unixInit-5.1 {Tcl_Init} {emptyTest unixOnly} {
+test unixInit-5.1 {Tcl_Init} {emptyTest unix} {
# test initScript
} {}
-test unixInit-6.1 {Tcl_SourceRCFile} {emptyTest unixOnly} {
+test unixInit-6.1 {Tcl_SourceRCFile} {emptyTest unix} {
} {}
test unixInit-7.1 {closed standard channel: Bug 772288} -constraints {
- unixOnly stdio
+ unix stdio
} -body {
set tclsh [interpreter]
set crash [makeFile {puts [open /dev/null]} crash.tcl]
@@ -374,11 +403,9 @@ test unixInit-7.1 {closed standard channel: Bug 772288} -constraints {
} -returnCodes 0
# cleanup
-if {[info exists oldlibrary]} {
- set env(TCL_LIBRARY) $oldlibrary
-}
catch {unset env(LANG)}
catch {set env(LANG) $oldlang}
unset -nocomplain path
::tcltest::cleanupTests
return
+