summaryrefslogtreecommitdiffstats
path: root/tests/socket.test
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2011-09-11 20:02:33 (GMT)
committerdgp <dgp@users.sourceforge.net>2011-09-11 20:02:33 (GMT)
commit0316c6eff20ff2d18f2b47d72f9d83fa497d5731 (patch)
treebc72f984eeb1350819af6ef790ea3b1cc152e5d4 /tests/socket.test
parentcc91390bcaad5838a55714ae8994b24be476efca (diff)
downloadtcl-0316c6eff20ff2d18f2b47d72f9d83fa497d5731.zip
tcl-0316c6eff20ff2d18f2b47d72f9d83fa497d5731.tar.gz
tcl-0316c6eff20ff2d18f2b47d72f9d83fa497d5731.tar.bz2
3390699 Convert [testthread] use to Thread package use in socket_*-13.1.
Eliminates a memory leak in `make valgrind`.
Diffstat (limited to 'tests/socket.test')
-rw-r--r--tests/socket.test29
1 files changed, 10 insertions, 19 deletions
diff --git a/tests/socket.test b/tests/socket.test
index 0ea0eb5..58eb3ee 100644
--- a/tests/socket.test
+++ b/tests/socket.test
@@ -63,8 +63,8 @@
package require tcltest 2
namespace import -force ::tcltest::*
-# Some tests require the testthread and exec commands
-testConstraint testthread [llength [info commands testthread]]
+# Some tests require the Thread package or exec command
+testConstraint thread [expr {0 == [catch {package require Thread 2.6}]}]
testConstraint exec [llength [info commands exec]]
# Produce a random port number in the Dynamic/Private range
@@ -1672,9 +1672,9 @@ test socket_$af-12.3 {testing inheritance of accepted sockets} -setup {
catch {close $p}
} -result {accepted socket was not inherited}
-test socket_$af-13.1 {Testing use of shared socket between two threads} -setup {
- threadReap
- set path(script) [makeFile [string map [list @localhost@ $localhost] {
+test socket_$af-13.1 {Testing use of shared socket between two threads} -body {
+ # create a thread
+ set serverthread [thread::create -preserved [string map [list @localhost@ $localhost] {
set f [socket -server accept -myaddr @localhost@ 0]
set listen [lindex [fconfigure $f -sockname] 2]
proc accept {s a p} {
@@ -1696,15 +1696,8 @@ test socket_$af-13.1 {Testing use of shared socket between two threads} -setup {
set i 0
vwait x
close $f
- # thread cleans itself up.
- testthread exit
- }] script]
-} -constraints [list socket supported_$af testthread] -body {
- # create a thread
- set serverthread [testthread create [list source $path(script) ] ]
- update
- set port [testthread send $serverthread {set listen}]
- update
+ }]]
+ set port [thread::send $serverthread {set listen}]
set s [socket $localhost $port]
fconfigure $s -buffering line
catch {
@@ -1712,11 +1705,9 @@ test socket_$af-13.1 {Testing use of shared socket between two threads} -setup {
gets $s result
}
close $s
- update
- append result " " [threadReap]
-} -cleanup {
- removeFile script
-} -result {hello 1}
+ thread::release $serverthread
+ append result " " [llength [thread::names]]
+} -result {hello 1} -constraints [list socket supported_$af thread]
# ----------------------------------------------------------------------