Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Work in progress converting tests from [testthread cancel] to [thread::cancel] |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
558725498319a9083a1d81a0fbfd6465 |
User & Date: | dgp 2011-11-01 18:53:11 |
Context
2011-11-03
| ||
14:37 |
* unix/tclUnixCompat.c (TclpGetPwNam, TclpGetPwUid, TclpGetGrNam) (TclpGetGrGid): Use the elaborat...check-in: ed2b08e566 user: dkf tags: trunk | |
2011-11-01
| ||
18:53 | Work in progress converting tests from [testthread cancel] to [thread::cancel] check-in: 5587254983 user: dgp tags: trunk | |
14:39 | merge mark check-in: 8fe91a8e59 user: dgp tags: trunk | |
Changes
Changes to tests/thread.test.
︙ | ︙ | |||
8 9 10 11 12 13 14 | # Copyright (c) 1998-1999 by Scriptics Corporation. # Copyright (c) 2006-2008 by Joe Mistachkin. All rights reserved. # # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. if {[lsearch [namespace children] ::tcltest] == -1} { | | | | 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | # Copyright (c) 1998-1999 by Scriptics Corporation. # Copyright (c) 2006-2008 by Joe Mistachkin. All rights reserved. # # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. if {[lsearch [namespace children] ::tcltest] == -1} { package require tcltest 2.2 namespace import -force ::tcltest::* } # Some tests require the testthread command testConstraint testthread [expr {[info commands testthread] != {}}] testConstraint thread [expr {0 == [catch {package require Thread 2.7}]}] testConstraint notValgrind [expr {![testConstraint valgrind]}] proc ThreadError {id info} { global threadId threadError set threadId $id set threadError $info |
︙ | ︙ | |||
55 56 57 58 59 60 61 | after 1 } testthread errorproc ThreadError return [llength [testthread names]] } } | < < < < < < | 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | after 1 } testthread errorproc ThreadError return [llength [testthread names]] } } test thread-1.3 {Tcl_ThreadObjCmd: initial thread list} {thread} { llength [thread::names] } 1 test thread-1.4 {Tcl_ThreadObjCmd: thread create } {thread} { set serverthread [thread::create -preserved] set numthreads [llength [thread::names]] thread::release $serverthread |
︙ | ︙ | |||
89 90 91 92 93 94 95 | } {1} test thread-1.6 {Tcl_ThreadObjCmd: thread exit} {thread} { thread::create {{*}{}} update after 10 llength [thread::names] } {1} | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 | } {1} test thread-1.6 {Tcl_ThreadObjCmd: thread exit} {thread} { thread::create {{*}{}} update after 10 llength [thread::names] } {1} test thread-1.13 {Tcl_ThreadObjCmd: send args} {thread} { set serverthread [thread::create -preserved] set five [thread::send $serverthread {set x 5}] thread::release $serverthread set five } 5 test thread-1.15 {Tcl_ThreadObjCmd: wait} {thread} { set serverthread [thread::create -preserved {set z 5 ; thread::wait}] set five [thread::send $serverthread {set z}] thread::release $serverthread set five } 5 # The tests above also cover: # TclCreateThread, except when pthread_create fails # NewThread, safe and regular # ThreadErrorProc, except for printing to standard error test thread-2.1 {ListUpdateInner and ListRemove} {thread} { |
︙ | ︙ | |||
253 254 255 256 257 258 259 | } unset x } thread::release -wait $serverthread } 0 # TIP #285: Script cancellation support | | > > > > > > | > > | > > > > > > > > > | | | | > > > > | | > > | > > > | > > | > > > > > > > > > | > | | > > > > > > > > | > < | | | | | < | < | < | < | > > | | < > | > < | | | | | < | < | < | < | > > | | < > | > < | | | | | < | < | < | < | > > | | | > > | > | < | | | | | < | < | < | < | > > | | | > > | > < | | | | < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < < | < | < | < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < | | | > > | > | < | | | | | < | < | < | < | > > | | < > | > < | | | | | < | < | < | < | > > | | < > | > < | | | | > | > | | > > > > > > > > | > > > > > > > > | > | > > | < | > > | | < > | > < | | | | | < | < | < | < | < < | > > > > | > > > > | | | | | | | < > > | | | | < | < | < | < | > > | | < > | > | < | | | | | < | < | < | < | > > | | < > | > | < | > > > > | | | < | | | | | > > | | < > | > | < | | | | | | | < | < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | | 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 | } unset x } thread::release -wait $serverthread } 0 # TIP #285: Script cancellation support test thread-7.4 {cancel: pure bytecode loop} -constraints {thread} -setup { unset -nocomplain ::threadError ::threadId ::threadIdStarted } -body { set serverthread [thread::create -joinable \ [string map [list %ID% [thread::id]] { proc foobar {} { if {![info exists foo]} then { # signal the primary thread that we are ready # to be canceled now (we are running). thread::send %ID% [list set ::threadIdStarted [thread::id]] set foo 1 } while {1} { # No bytecode at all here... } } foobar }]] # wait for other thread to signal "ready to cancel" vwait ::threadIdStarted set res [thread::cancel $serverthread] vwait ::threadId thread::join $serverthread list $res [expr {$::threadIdStarted == $serverthread}] \ [expr {$::threadId == $serverthread}] \ [lindex [split $::threadError \n] 0] } -cleanup { unset -nocomplain ::threadError ::threadId ::threadIdStarted } -result {{} 1 1 {eval canceled}} test thread-7.5 {cancel: pure inside-command loop} -constraints {thread} -setup { unset -nocomplain ::threadError ::threadId ::threadIdStarted } -body { set serverthread [thread::create -joinable \ [string map [list %ID% [thread::id]] { proc foobar {} { if {![info exists foo]} then { # signal the primary thread that we are ready # to be canceled now (we are running). thread::send %ID% [list set ::threadIdStarted [thread::id]] set foo 1 } set while while $while {1} { # No bytecode at all here... } } foobar }]] # wait for other thread to signal "ready to cancel" vwait threadIdStarted set res [thread::cancel $serverthread] vwait threadId thread::join $serverthread list $res [expr {$::threadIdStarted == $serverthread}] \ [expr {$::threadId == $serverthread}] \ [lindex [split $::threadError \n] 0] } -cleanup { unset -nocomplain ::threadError ::threadId ::threadIdStarted } -result {{} 1 1 {eval canceled}} test thread-7.6 {cancel: pure bytecode loop -unwind} -constraints {thread} -setup { unset -nocomplain ::threadError ::threadId ::threadIdStarted } -body { set serverthread [thread::create -joinable \ [string map [list %ID% [thread::id]] { proc foobar {} { if {![info exists foo]} then { # signal the primary thread that we are ready # to be canceled now (we are running). thread::send %ID% [list set ::threadIdStarted [thread::id]] set foo 1 } while {1} { # No bytecode at all here... } } foobar }]] # wait for other thread to signal "ready to cancel" vwait threadIdStarted set res [thread::cancel -unwind $serverthread] vwait threadId thread::join $serverthread list $res [expr {$::threadIdStarted == $serverthread}] \ [expr {$::threadId == $serverthread}] \ [lindex [split $::threadError \n] 0] } -cleanup { unset -nocomplain ::threadError ::threadId ::threadIdStarted } -result {{} 1 1 {eval unwound}} test thread-7.7 {cancel: pure inside-command loop -unwind} -constraints thread -setup { unset -nocomplain ::threadError ::threadId ::threadIdStarted } -body { set serverthread [thread::create -joinable \ [string map [list %ID% [thread::id]] { proc foobar {} { if {![info exists foo]} then { # signal the primary thread that we are ready # to be canceled now (we are running). thread::send %ID% [list set ::threadIdStarted [thread::id]] set foo 1 } set while while $while {1} { # No bytecode at all here... } } foobar }]] # wait for other thread to signal "ready to cancel" vwait threadIdStarted set res [thread::cancel -unwind $serverthread] vwait threadId thread::join $serverthread list $res [expr {$::threadIdStarted == $serverthread}] \ [expr {$::threadId == $serverthread}] \ [lindex [split $::threadError \n] 0] } -cleanup { unset -nocomplain ::threadError ::threadId ::threadIdStarted } -result {{} 1 1 {eval unwound}} test thread-7.8 {cancel: pure bytecode loop custom result} -constraints thread -setup { unset -nocomplain ::threadError ::threadId ::threadIdStarted } -body { set serverthread [thread::create -joinable \ [string map [list %ID% [thread::id]] { proc foobar {} { if {![info exists foo]} then { # signal the primary thread that we are ready # to be canceled now (we are running). thread::send %ID% [list set ::threadIdStarted [thread::id]] set foo 1 } while {1} { # No bytecode at all here... } } foobar }]] # wait for other thread to signal "ready to cancel" vwait threadIdStarted set res [thread::cancel $serverthread "the eval was canceled"] vwait threadId thread::join $serverthread list $res [expr {$::threadIdStarted == $serverthread}] \ [expr {$::threadId == $serverthread}] \ [lindex [split $::threadError \n] 0] } -cleanup { unset -nocomplain ::threadError ::threadId ::threadIdStarted } -result {{} 1 1 {the eval was canceled}} test thread-7.9 {cancel: pure inside-command loop custom result} -constraints { thread } -setup { unset -nocomplain ::threadError ::threadId ::threadIdStarted } -body { set serverthread [thread::create -joinable \ [string map [list %ID% [thread::id]] { proc foobar {} { if {![info exists foo]} then { # signal the primary thread that we are ready # to be canceled now (we are running). thread::send %ID% [list set ::threadIdStarted [thread::id]] set foo 1 } set while while $while {1} { # No bytecode at all here... } } foobar }]] # wait for other thread to signal "ready to cancel" vwait threadIdStarted set res [thread::cancel $serverthread "the eval was canceled"] vwait threadId thread::join $serverthread list $res [expr {$::threadIdStarted == $serverthread}] \ [expr {$::threadId == $serverthread}] \ [lindex [split $::threadError \n] 0] } -cleanup { unset -nocomplain ::threadError ::threadId ::threadIdStarted } -result {{} 1 1 {the eval was canceled}} test thread-7.10 {cancel: pure bytecode loop custom result -unwind} -constraints { thread } -setup { unset -nocomplain ::threadError ::threadId ::threadIdStarted } -body { set serverthread [thread::create -joinable \ [string map [list %ID% [thread::id]] { proc foobar {} { if {![info exists foo]} then { # signal the primary thread that we are ready # to be canceled now (we are running). thread::send %ID% [list set ::threadIdStarted [thread::id]] set foo 1 } while {1} { # No bytecode at all here... } } foobar }]] # wait for other thread to signal "ready to cancel" vwait threadIdStarted set res [thread::cancel -unwind $serverthread "the eval was unwound"] vwait threadId thread::join $serverthread list $res [expr {$::threadIdStarted == $serverthread}] \ [expr {$::threadId == $serverthread}] \ [lindex [split $::threadError \n] 0] } -cleanup { unset -nocomplain ::threadError ::threadId ::threadIdStarted } -result {{} 1 1 {the eval was unwound}} test thread-7.11 {cancel: pure inside-command loop custom result -unwind} -constraints { thread } -setup { unset -nocomplain ::threadError ::threadId ::threadIdStarted } -body { set serverthread [thread::create -joinable \ [string map [list %ID% [thread::id]] { proc foobar {} { if {![info exists foo]} then { # signal the primary thread that we are ready # to be canceled now (we are running). thread::send %ID% [list set ::threadIdStarted [thread::id]] set foo 1 } set while while $while {1} { # No bytecode at all here... } } foobar }]] # wait for other thread to signal "ready to cancel" vwait threadIdStarted set res [thread::cancel -unwind $serverthread "the eval was unwound"] vwait threadId thread::join $serverthread list $res [expr {$::threadIdStarted == $serverthread}] \ [expr {$::threadId == $serverthread}] \ [lindex [split $::threadError \n] 0] } -cleanup { unset -nocomplain ::threadError ::threadId ::threadIdStarted } -result {{} 1 1 {the eval was unwound}} test thread-7.12 {cancel: after} -constraints thread -setup { unset -nocomplain ::threadError ::threadId ::threadIdStarted } -body { set serverthread [thread::create -joinable \ [string map [list %ID% [thread::id]] { if {![info exists foo]} then { # signal the primary thread that we are ready # to be canceled now (we are running). thread::send %ID% [list set ::threadIdStarted [thread::id]] set foo 1 } after 30000 }]] # wait for other thread to signal "ready to cancel" vwait threadIdStarted set res [thread::cancel $serverthread] vwait threadId thread::join $serverthread list $res [expr {$::threadIdStarted == $serverthread}] \ [expr {$::threadId == $serverthread}] \ [lindex [split $::threadError \n] 0] } -cleanup { unset -nocomplain ::threadError ::threadId ::threadIdStarted } -result {{} 1 1 {eval canceled}} test thread-7.13 {cancel: after -unwind} -constraints thread -setup { unset -nocomplain ::threadError ::threadId ::threadIdStarted } -body { set serverthread [thread::create -joinable \ [string map [list %ID% [thread::id]] { if {![info exists foo]} then { # signal the primary thread that we are ready # to be canceled now (we are running). thread::send %ID% [list set ::threadIdStarted [thread::id]] set foo 1 } after 30000 }]] # wait for other thread to signal "ready to cancel" vwait threadIdStarted set res [thread::cancel -unwind $serverthread] vwait threadId thread::join $serverthread list $res [expr {$::threadIdStarted == $serverthread}] \ [expr {$::threadId == $serverthread}] \ [lindex [split $::threadError \n] 0] } -cleanup { unset -nocomplain ::threadError ::threadId ::threadIdStarted } -result {{} 1 1 {eval unwound}} test thread-7.14 {cancel: vwait} -constraints thread -setup { unset -nocomplain ::threadError ::threadId ::threadIdStarted } -body { set serverthread [thread::create -joinable \ [string map [list %ID [thread::id]] { if {![info exists foo]} then { # signal the primary thread that we are ready # to be canceled now (we are running). thread::send %ID% [list set ::threadIdStarted [thread::id]] set foo 1 } vwait forever }]] # wait for other thread to signal "ready to cancel" vwait threadIdStarted set res [thread::cancel $serverthread] vwait threadId thread::join $serverthread list $res [expr {$::threadIdStarted == $serverthread}] \ [expr {$::threadId == $serverthread}] \ [lindex [split $::threadError \n] 0] } -cleanup { unset -nocomplain ::threadError ::threadId ::threadIdStarted } -result {{} 1 1 {eval canceled}} test thread-7.15 {cancel: vwait -unwind} -constraints thread -setup { unset -nocomplain ::threadError ::threadId ::threadIdStarted } -body { set serverthread [thread::create -joinable \ [string map [list %ID% [thread::id]] { if {![info exists foo]} then { # signal the primary thread that we are ready # to be canceled now (we are running). thread::send %ID% [list set ::threadIdStarted [thread::id]] set foo 1 } vwait forever }]] # wait for other thread to signal "ready to cancel" vwait threadIdStarted set res [thread::cancel -unwind $serverthread] vwait threadId thread::join $serverthread list $res [expr {$::threadIdStarted == $serverthread}] \ [expr {$::threadId == $serverthread}] \ [lindex [split $::threadError \n] 0] } -cleanup { unset -nocomplain ::threadError ::threadId ::threadIdStarted } -result {{} 1 1 {eval unwound}} test thread-7.16 {cancel: expr} -constraints thread -setup { unset -nocomplain ::threadError ::threadId ::threadIdStarted } -body { set serverthread [thread::create -joinable \ [string map [list %ID [thread::id]] { set i [interp create] $i eval "package require -exact Thread [package present Thread]" $i eval { if {![info exists foo]} then { # signal the primary thread that we are ready # to be canceled now (we are running). thread::send %ID% [list set ::threadIdStarted [thread::id]] set foo 1 } expr {[while {1} {incr x}]} } }]] # wait for other thread to signal "ready to cancel" vwait threadIdStarted set res [thread::cancel $serverthread] vwait threadId thread::join $serverthread list $res [expr {$::threadIdStarted == $serverthread}] \ [expr {$::threadId == $serverthread}] \ [lindex [split $::threadError \n] 0] } -cleanup { unset -nocomplain ::threadError ::threadId ::threadIdStarted } -result {{} 1 1 {eval canceled}} test thread-7.17 {cancel: expr -unwind} -constraints thread -setup { unset -nocomplain ::threadError ::threadId ::threadIdStarted } -body { set serverthread [thread::create -joinable \ [string map [list %ID% [thread::id]] { set i [interp create] $i eval "package require -exact Thread [package present Thread]" $i eval { if {![info exists foo]} then { # signal the primary thread that we are ready # to be canceled now (we are running). thread::send %ID% [list set ::threadIdStarted [thread::id]] set foo 1 } expr {[while {1} {incr x}]} } }]] # wait for other thread to signal "ready to cancel" vwait threadIdStarted set res [thread::cancel -unwind $serverthread] vwait threadId thread::join $serverthread list $res [expr {$::threadIdStarted == $serverthread}] \ [expr {$::threadId == $serverthread}] \ [lindex [split $::threadError \n] 0] } -cleanup { unset -nocomplain ::threadError ::threadId ::threadIdStarted } -result {{} 1 1 {eval unwound}} test thread-7.18 {cancel: expr bignum} -constraints thread -setup { unset -nocomplain ::threadError ::threadId ::threadIdStarted } -body { set serverthread [thread::create -joinable \ [string map [list %ID% [thread::id]] { set i [interp create] $i eval "package require -exact Thread [package present Thread]" $i eval { if {![info exists foo]} then { # signal the primary thread that we are ready # to be canceled now (we are running). thread::send %ID% [list set ::threadIdStarted [thread::id]] set foo 1 } # # TODO: This will not cancel because libtommath # does not check Tcl_Canceled. # expr {2**99999} } }]] # wait for other thread to signal "ready to cancel" vwait threadIdStarted set res [thread::cancel $serverthread] after 1000 {set ::threadId timeout} vwait threadId thread::join $serverthread list $res [expr {$::threadIdStarted == $serverthread}] \ [expr {[info exists ::threadId] ? \ $::threadId == $serverthread : 0}] \ [expr {[info exists ::threadError] ? \ [lindex [split $::threadError \n] 0] : "" }] } -cleanup { unset -nocomplain ::threadError ::threadId ::threadIdStarted } -result {{} 1 0 {}} test thread-7.19 {cancel: expr bignum -unwind} -constraints thread -setup { unset -nocomplain ::threadError ::threadId ::threadIdStarted } -body { set serverthread [thread::create -joinable \ [string map [list %ID% [thread::id]] { set i [interp create] $i eval "package require -exact Thread [package present Thread]" $i eval { if {![info exists foo]} then { # signal the primary thread that we are ready # to be canceled now (we are running). thread::send %ID% [list set ::threadIdStarted [thread::id]] set foo 1 } # # TODO: This will not cancel because libtommath # does not check Tcl_Canceled. # expr {2**99999} } }]] # wait for other thread to signal "ready to cancel" vwait threadIdStarted set res [thread::cancel -unwind $serverthread] after 1000 {set ::threadId timeout} vwait threadId thread::join $serverthread list $res [expr {$::threadIdStarted == $serverthread}] \ [expr {[info exists ::threadId] ? \ $::threadId == $serverthread : 0}] \ [expr {[info exists ::threadError] ? \ [lindex [split $::threadError \n] 0] : "" }] } -cleanup { unset -nocomplain ::threadError ::threadId ::threadIdStarted } -result {{} 1 0 {}} test thread-7.20 {cancel: subst} {testthread} { threadReap unset -nocomplain ::threadError ::threadId ::threadIdStarted set serverthread [testthread create -joinable { set i [interp create] interp alias $i testthread {} testthread $i eval { |
︙ | ︙ |
Changes to tests/unixNotfy.test.
1 2 3 4 5 6 7 8 9 10 11 12 | # This file contains tests for tclUnixNotfy.c. # # This file contains a collection of tests for one or more of the Tcl # built-in commands. Sourcing this file into Tcl runs the tests and # generates output for errors. No output means no errors were found. # # Copyright (c) 1997 by Sun Microsystems, Inc. # Copyright (c) 1998-1999 by Scriptics Corporation. # # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. | < < < < < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | # This file contains tests for tclUnixNotfy.c. # # This file contains a collection of tests for one or more of the Tcl # built-in commands. Sourcing this file into Tcl runs the tests and # generates output for errors. No output means no errors were found. # # Copyright (c) 1997 by Sun Microsystems, Inc. # Copyright (c) 1998-1999 by Scriptics Corporation. # # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. if {[lsearch [namespace children] ::tcltest] == -1} { package require tcltest 2 namespace import -force ::tcltest::* } # When run in a Tk shell, these tests hang. testConstraint noTk [expr {0 != [catch {package present Tk}]}] testConstraint thread [expr {0 == [catch {package require Thread 2.6}]}] # Darwin always uses a threaded notifier testConstraint unthreaded [expr { (![info exist tcl_platform(threaded)] || !$tcl_platform(threaded)) && $tcl_platform(os) ne "Darwin" }] # The next two tests will hang if threads are enabled because the notifier |
︙ | ︙ |