sl@0: # This file tests the tclWinTime.c file. sl@0: # sl@0: # This file contains a collection of tests for one or more of the Tcl sl@0: # built-in commands. Sourcing this file into Tcl runs the tests and sl@0: # generates output for errors. No output means no errors were found. sl@0: # sl@0: # Copyright (c) 1997 Sun Microsystems, Inc. sl@0: # Copyright (c) 1998-1999 by Scriptics Corporation. sl@0: # sl@0: # See the file "license.terms" for information on usage and redistribution sl@0: # of this file, and for a DISCLAIMER OF ALL WARRANTIES. sl@0: # sl@0: # RCS: @(#) $Id: winTime.test,v 1.8.2.1 2003/04/12 20:11:34 kennykb Exp $ sl@0: sl@0: if {[lsearch [namespace children] ::tcltest] == -1} { sl@0: package require tcltest sl@0: namespace import -force ::tcltest::* sl@0: } sl@0: sl@0: testConstraint testwinclock [llength [info commands testwinclock]] sl@0: sl@0: # The next two tests will crash on Windows if the check for negative sl@0: # clock values is not done properly. sl@0: sl@0: test winTime-1.1 {TclpGetDate} {pcOnly} { sl@0: set ::env(TZ) JST-9 sl@0: set result [clock format -1 -format %Y] sl@0: unset ::env(TZ) sl@0: set result sl@0: } {1970} sl@0: test winTime-1.2 {TclpGetDate} {pcOnly} { sl@0: set ::env(TZ) PST8 sl@0: set result [clock format 1 -format %Y] sl@0: unset ::env(TZ) sl@0: set result sl@0: } {1969} sl@0: sl@0: # Next test tries to make sure that the Tcl clock stays in step sl@0: # with the Windows clock. 30 sec really isn't enough, sl@0: # but how much time does a tester have patience for? sl@0: sl@0: test winTime-2.1 {Synchronization of Tcl and Windows clocks} {testwinclock} { sl@0: # May fail due to OS/hardware discrepancies. See: sl@0: # http://support.microsoft.com/default.aspx?scid=kb;en-us;274323 sl@0: set failed {} sl@0: set ok 1 sl@0: foreach start_sec [testwinclock] break sl@0: while { 1 } { sl@0: foreach { sys_sec sys_usec tcl_sec tcl_usec } [testwinclock] break sl@0: set diff [expr { $tcl_sec - $sys_sec sl@0: + 1.0e-6 * ( $tcl_usec - $sys_usec ) }] sl@0: if { abs($diff) > 0.06 } { sl@0: set failed "Tcl clock differs from system clock by $diff sec" sl@0: break sl@0: } else { sl@0: testwinsleep 1 sl@0: } sl@0: if { $sys_sec - $start_sec >= 30 } break sl@0: } sl@0: set failed sl@0: } {} sl@0: sl@0: # cleanup sl@0: ::tcltest::cleanupTests sl@0: return