Diff
Not logged in

Differences From Artifact [9bcb4b98ea]:

To Artifact [e7328feb7c]:


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# This file contains a collection of tests for the procedures in the file
# tclEvent.c, which includes the "update", and "vwait" Tcl
# commands.  Sourcing this file into Tcl runs the tests and generates
# output for errors.  No output means no errors were found.
#
# Copyright (c) 1995-1997 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.
#
# RCS: @(#) $Id: event.test,v 1.20 2002/07/10 11:56:44 dgp Exp $

package require tcltest 2
namespace import -force ::tcltest::*

testConstraint testfilehandler [llength [info commands testfilehandler]]
testConstraint testexithandler [llength [info commands testexithandler]]
testConstraint testfilewait [llength [info commands testfilewait]]











|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# This file contains a collection of tests for the procedures in the file
# tclEvent.c, which includes the "update", and "vwait" Tcl
# commands.  Sourcing this file into Tcl runs the tests and generates
# output for errors.  No output means no errors were found.
#
# Copyright (c) 1995-1997 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.
#
# RCS: @(#) $Id: event.test,v 1.20.2.1 2006/11/28 16:29:47 kennykb Exp $

package require tcltest 2
namespace import -force ::tcltest::*

testConstraint testfilehandler [llength [info commands testfilehandler]]
testConstraint testexithandler [llength [info commands testexithandler]]
testConstraint testfilewait [llength [info commands testfilewait]]
582
583
584
585
586
587
588

















































































































































































































589
590
591
592
593
594
    set result ""
    lappend result [testfilewait $f readable 100]
    lappend result [testfilewait $f readable -1]
    close $f
    set result
} {{} readable}


















































































































































































































# cleanup
foreach i [after info] {
    after cancel $i
}
::tcltest::cleanupTests
return







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>






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
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
    set result ""
    lappend result [testfilewait $f readable 100]
    lappend result [testfilewait $f readable -1]
    close $f
    set result
} {{} readable}


test event-14.1 {Tcl_WaitForFile procedure, readable, big fd} \
    -constraints {testfilehandler unix} \
    -setup {
	set chanList {}
	for {set i 0} {$i < 32} {incr i} {
	    lappend chanList [open /dev/null r]
	}
    } \
    -body {
	foreach i [after info] {
	    after cancel $i
	}
	after 100 set x timeout
	testfilehandler close
	testfilehandler create 1 off off
	set x "no timeout"
	set result [testfilehandler wait 1 readable 0]
	update
	testfilehandler close
	list $result $x
    } \
    -result {{} {no timeout}} \
    -cleanup {
	foreach chan $chanList {close $chan}
    }

test event-14.2 {Tcl_WaitForFile procedure, readable, big fd} \
    -constraints {testfilehandler unix} \
    -setup {
	set chanList {}
	for {set i 0} {$i < 32} {incr i} {
	    lappend chanList [open /dev/null r]
	}
    } \
    -body {
	foreach i [after info] {
	    after cancel $i
	}
	after 100 set x timeout
	testfilehandler close
	testfilehandler create 1 off off
	set x "no timeout"
	set result [testfilehandler wait 1 readable 100]
	update
	testfilehandler close
	list $result $x
    } \
    -result {{} timeout} \
    -cleanup {
	foreach chan $chanList {close $chan}
    }

test event-14.3 {Tcl_WaitForFile procedure, readable, big fd} \
    -constraints {testfilehandler unix} \
    -setup {
	set chanList {}
	for {set i 0} {$i < 32} {incr i} {
	    lappend chanList [open /dev/null r]
	}
    } \
    -body {
	foreach i [after info] {
	    after cancel $i
	}
	after 100 set x timeout
	testfilehandler close
	testfilehandler create 1 off off
	testfilehandler fillpartial 1
	set x "no timeout"
	set result [testfilehandler wait 1 readable 100]
	update
	testfilehandler close
	list $result $x
    } \
    -result {readable {no timeout}} \
    -cleanup {
	foreach chan $chanList {close $chan}
    }

test event-14.4 {Tcl_WaitForFile procedure, writable, big fd} \
    -constraints {testfilehandler unix nonPortable} \
    -setup {
	set chanList {}
	for {set i 0} {$i < 32} {incr i} {
	    lappend chanList [open /dev/null r]
	}
    } \
    -body {
	foreach i [after info] {
	    after cancel $i
	}
	after 100 set x timeout
	testfilehandler close
	testfilehandler create 1 off off
	testfilehandler fill 1
	set x "no timeout"
	set result [testfilehandler wait 1 writable 0]
	update
	testfilehandler close
	list $result $
    } \
    -result {{} {no timeout}} \
    -cleanup {
	foreach chan $chanList {close $chan}
    }

test event-14.5 {Tcl_WaitForFile procedure, writable, big fd} \
    -constraints {testfilehandler unix nonPortable} \
    -setup {
	set chanList {}
	for {set i 0} {$i < 32} {incr i} {
	    lappend chanList [open /dev/null r]
	}
    } \
    -body {
	foreach i [after info] {
	    after cancel $i
	}
	after 100 set x timeout
	testfilehandler close
	testfilehandler create 1 off off
	testfilehandler fill 1
	set x "no timeout"
	set result [testfilehandler wait 1 writable 100]
	update
	testfilehandler close
	list $result $x
    } \
    -result {{} timeout} \
    -cleanup {
	foreach chan $chanList {close $chan}
    }

test event-14.6 {Tcl_WaitForFile procedure, writable, big fd} \
    -constraints {testfilehandler unix} \
    -setup {
	set chanList {}
	for {set i 0} {$i < 32} {incr i} {
	    lappend chanList [open /dev/null r]
	}
    } \
    -body {
	foreach i [after info] {
	    after cancel $i
	}
	after 100 set x timeout
	testfilehandler close
	testfilehandler create 1 off off
	set x "no timeout"
	set result [testfilehandler wait 1 writable 100]
	update
	testfilehandler close
	list $result $x
    } \
    -result {writable {no timeout}} \
    -cleanup {
	foreach chan $chanList {close $chan}
    }

test event-14.7 {Tcl_WaitForFile, don't call other event handlers, big fd} \
    -constraints {testfilehandler unix} \
    -setup {
	set chanList {}
	for {set i 0} {$i < 32} {incr i} {
	    lappend chanList [open /dev/null r]
	}
    } \
    -body {
	foreach i [after info] {
	    after cancel $i
	}
	after 100 lappend x timeout
	after idle lappend x idle
	testfilehandler close
	testfilehandler create 1 off off
	set x ""
	set result [list [testfilehandler wait 1 readable 200] $x]
	update
	testfilehandler close
	lappend result $x
    } \
    -result {{} {} {timeout idle}} \
    -cleanup {
	foreach chan $chanList {close $chan}
    }


test event-14.8 {Tcl_WaitForFile procedure, waiting indefinitely, big fd} \
    -constraints {testfilewait unix} \
    -body {
	set f [open "|sleep 2" r]
	set result ""
	lappend result [testfilewait $f readable 100]
	lappend result [testfilewait $f readable -1]
	close $f
	set result
    } \
    -setup {
	set chanList {}
	for {set i 0} {$i < 32} {incr i} {
	    lappend chanList [open /dev/null r]
	}
    } \
    -result {{} readable} \
    -cleanup {
	foreach chan $chanList {close $chan}
    }

# cleanup
foreach i [after info] {
    after cancel $i
}
::tcltest::cleanupTests
return