1 # Copyright (c) 1999-2012 OPEN CASCADE SAS
3 # The content of this file is subject to the Open CASCADE Technology Public
4 # License Version 6.5 (the "License"). You may not use the content of this file
5 # except in compliance with the License. Please obtain a copy of the License
6 # at http://www.opencascade.org and read it completely before using this file.
8 # The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
9 # main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
11 # The Original Code and all software distributed under the License is
12 # distributed on an "AS IS" basis, without warranty of any kind, and the
13 # Initial Developer hereby disclaims all such warranties, including without
14 # limitation, any warranties of merchantability, fitness for a particular
15 # purpose or non-infringement. Please see the License for the specific terms
16 # and conditions governing the rights and limitations under the License.
19 # tclsh tools to browse tests
21 # xab : 22-Mar-96 rajout de floatDifference pour eviter des diffs
22 # en fonction de la tolerance DiffTestTolerance
23 # pmn : 25-Sept-96 masterRoot sans reference explicite a gti
24 # (pour une utilisation Aixoise)
25 # xab : 12-Nov-996 nouveau trap dans les comptes rendus
26 # INV par checkshape ou checktopshape
27 # xab : 22/11/96 : on a encore besoin des 3 variables d'environement
31 # xab : 10-Mar-97 : string compare au lieu de != dans les diffs
33 ####################################################
35 ####################################################
39 { nomatch "NOLOGFILE" "no result for the test"}
40 { nomatch "OK " "no error and no difference"}
41 { nomatch "NO " "no error and no master file to compare"}
42 { nomatch "NOEND " "abnormal termination"}
43 { "An exception was caught" "CATCH " "an exception was caught"}
44 { "segv" "SEGV " "segmentation violation"}
45 { "ERROR" "ERROR " "user generated error"}
46 { "NYI" "NYI " "This test is not yet implemented"}
47 { "Cpu Limit Exceeded" "CPULIM " "CPU limit exceeded"}
48 { "BRepCheck_" "INV " "invalid result"}
51 ####################################################
53 ####################################################
54 set DiffTestTolerance 1.0e-6
56 set theStation $env(STATION)
58 if {$theStation=="wnt"} {
59 set ExeMachinePath drv\\DFLT\\$env(STATION)
60 set exePath $env(WBROOT)\\prod
61 # set testRoot $env(WBCONTAINER)\\test
62 set testRoot $env(WBCONTAINER)
63 set resultRoot $env(WBROOT)\\work\\result$env(STATION)
64 set masterRoot $env(WBROOT)\\work\\master
66 set ExeMachinePath drv/DFLT/$env(STATION)
67 set ExePath $env(WBROOT)/$env(STATION)/bin
68 set testRoot $env(WBCONTAINER)
69 set resultRoot $env(WBROOT)/work/result$env(STATION)
70 set masterRoot $env(WBROOT)/work/master
72 puts "$testRoot et $env(WBCONTAINER) "
74 ## customize default values, if "setenv" has been set by AQ Team -plb/13feb97-
76 foreach el1 [array names env] {
77 if { [ string compare $el1 "DRAW_TEST_ROOT" ] == 0 } {
78 set testRoot $env($el1)
79 } elseif { [ string compare $el1 "DRAW_TEST_RESULT" ] == 0 } {
80 set resultRoot $env($el1)
81 } elseif { [ string compare $el1 "DRAW_TEST_MASTER" ] == 0 } {
82 set masterRoot $env($el1)
93 # name of Draw process to send
108 set theMasterXWDFiles {}
110 set theStatusHeader "Result LOG XWD"
117 ####################################################
118 # List from a directory
119 ####################################################
121 # match what is not a test
123 "^(Applet_GridTest|modeles|scripts|data|bin|help|begin.*|begin_wnt|end.*|grid|executables|readme|image|save|read.me|photo.*|.*~|#.*#)$"
125 proc mkListTests root {
126 global testRegExp Wok theStation env
129 if {$theStation=="wnt"} {
130 foreach f [exec $env(WOKHOME)\\lib\\wnt\\ls.exe $root] {
132 if [regexp $testRegExp $f] continue
136 foreach f [glob -nocomplain $root/*] {
138 if [regexp $testRegExp $f] continue
145 ####################################################
146 # Junky Heuristic to compare numbers in tests
147 ####################################################
149 proc floatDifference { line1 line2 } {
150 global DiffTestTolerance
152 for { set ii 1 } { $ii <= 3 } { incr ii } {
153 for { set jj 1 } { $jj <= 3 } { incr jj } {
154 set number($ii,$jj) 0.0e0
157 if { [regexp { ([0-9]+\.[0-9]+e-([0-9]+))|([0-9]+\.[0-9]*)} $line1 number(1,1) number(1,2) number(1,3) ] } {
158 if { [regexp { ([0-9]+\.[0-9]+e-([0-9]+))|([0-9]+\.[0-9]*)} $line2 number(2,1) number(2,2) number(2,3) ] } {
159 for { set ii 1 } { $ii <= 3 } { incr ii } {
160 if { $number(1,$ii) != "" && $number(2,$ii) != "" } {
161 if { [ regexp {\.} $number(1,$ii) ] && [ regexp {\.} $number(2,$ii) ] } {
163 set diff [ expr $number(1,$ii) - $number(2,$ii) ]
164 set diff [ expr abs($diff) ]
165 if { $diff > $DiffTestTolerance } {
177 # scabreux mais donne de bon resultat
187 ####################################################
188 # compute the current test status
189 ####################################################
191 proc computeStatus {} {
192 global testRoot resultRoot masterRoot
193 global theUL theFunction theTest
194 global theLog theMasterLog theXWDFiles theMasterXWDFiles
195 global theErrors theStatus theStatusLine theErrorLines theDiffs
197 set hasresult [file readable $theLog]
200 set theStatusLine "NOLOGFILE"
205 set hasmaster [file readable $theMasterLog]
207 # analyse the log file and compare to the master
215 if $hasmaster {set g [open $theMasterLog]}
216 set moremaster $hasmaster
219 while {[gets $f line] >= 0} {
221 # difference with master
223 if {[gets $g mline] >= 0} {
224 # compare the two lines
225 if { [ string compare $line $mline ] } {
226 if { [ floatDifference $mline $line ] } {
227 lappend diffs $curline
231 # the master file is finished
233 lappend ldiff $curline
238 foreach err $theErrors {
239 if [regexp [lindex $err 0] $line] {
240 if {[llength $errorlines] == 0} {set error [lindex $err 1]}
241 lappend errorlines $curline
245 # check for end of test
246 if [regexp "TEST COMPLETED" $line] {
252 if $hasmaster {close $g}
255 set statusline $error
258 set statusline "NOEND "
266 if [llength $diffs] {
267 append statusline " DIFF"
270 append statusline " OK "
273 append statusline " NO "
278 if [llength $theXWDFiles] {
279 # here we should compare the XWD files
280 if [llength $theMasterXWDFiles] {
281 append statusline " OK "
283 append statusline " NO "
286 append statusline " NOXWD "
291 set theStatus $status
292 set theStatusLine $statusline
293 set theErrorLines $errorlines
297 ####################################################
298 # trace on variables to update the lists
299 ####################################################
301 trace variable theUL w theULProc
302 proc theULProc {name element op} {
303 global theUL testRoot listFunction
306 # Met a jour la liste des fonctions
310 set listFunction [mkListTests $testRoot/$theUL]
314 trace variable theFunction w theFunctionProc
315 proc theFunctionProc {name element op} {
316 global testRoot theUL theFunction listTest
319 # Met a jour la liste des tests
320 if {$theFunction == ""} {
323 set listTest [mkListTests $testRoot/$theUL/$theFunction]
327 trace variable theTest w theTestProc
328 proc theTestProc {name element op} {
329 global resultRoot masterRoot theUL theFunction theTest
330 global theLog theMasterLog theXWDFiles theMasterXWDFiles
333 if {$theStation=="wnt"} {
335 # update the result variables
336 set theLog $resultRoot\\$theUL\\$theFunction\\$theTest.log
337 set theMasterLog $masterRoot\\$theUL\\$theFunction\\$theTest.log
341 $resultRoot\\$theUL\\$theFunction\\${theTest}.*.xwd.Z]
343 set theMasterXWDFiles \
345 $masterRoot\\$theUL\\$theFunction\\${theTest}.*.xwd.Z]
347 # update the result variables
348 set theLog $resultRoot/$theUL/$theFunction/$theTest.log
349 set theMasterLog $masterRoot/$theUL/$theFunction/$theTest.log
353 $resultRoot/$theUL/$theFunction/${theTest}.*.xwd.Z]
355 set theMasterXWDFiles \
357 $masterRoot/$theUL/$theFunction/${theTest}.*.xwd.Z]
364 trace variable listUL w listULProc
365 proc listULProc {name element op} {
367 if [llength $listUL] {
368 set theUL [lindex $listUL 0]
374 trace variable listFunction w listFunctionProc
375 proc listFunctionProc {name element op} {
376 global listFunction theFunction
377 if [llength $listFunction] {
378 set theFunction [lindex $listFunction 0]
384 trace variable listTest w listTestProc
385 proc listTestProc {name element op} {
386 global listTest theTest
387 if [llength $listTest] {
388 set theTest [lindex $listTest 0]
394 ####################################################
395 # procedure to change test
396 ####################################################
400 set l [llength $listUL]
402 set i [lsearch $listUL $theUL]
405 set theUL [lindex $listUL $i]
412 proc nextFunction {} {
413 global listFunction theFunction
414 set l [llength $listFunction]
416 set i [lsearch $listFunction $theFunction]
419 set theFunction [lindex $listFunction $i]
427 global listTest theTest
428 set l [llength $listTest]
430 set i [lsearch $listTest $theTest]
433 set theTest [lindex $listTest $i]
440 proc nextWithResult {} {
441 global theUL theTest theStatus
444 if {$theUL == ""} break
445 if {$theTest == ""} continue
446 if {$theStatus == "-"} continue
451 proc nextWithError {} {
452 global theStatus theUL
455 if {$theUL == ""} break
456 if {$theStatus == "*"} break
460 ####################################################
461 # run the current Test
462 ####################################################
465 global themode theDraw Drawid
466 global RESULT PREVIOUS TEMP DIFF FILTRE
467 global testRoot resultRoot theExec theLog
468 global theUL theFunction theTest
469 global ExePath ExeMachinePath
470 global theStation theTmp theDrawHome theTmp1
471 global cmdexec protect
472 global testRootNT env
475 puts " theUL $theUL theFunction $theFunction test $theTest "
476 puts "thest == $theStation"
478 if {$theTest == ""} return
484 if {$theStation=="wnt"} {
485 set exe "${ExePath}\\T${theUL}\\${ExeMachinePath}\\T${theUL}"
487 set exe "${ExePath}/T${theUL}"
491 if {![file exists $resultRoot]} {
492 if {$theStation=="wnt"} {
493 set stat1 [catch {file mkdir $resultRoot} iscreated ]
494 # [exec $cmdexec $resultRoot]
496 catch {exec mkdir $resultRoot}
497 catch {exec chmod 777 $resultRoot}
503 if {![file isdirectory $resultRoot/$theUL]} {
504 if { $theStation == "wnt" } {
505 set statpop [catch {file mkdir $resultRoot/$theUL} erreurfile ]
506 if { $statpop != 0 } { puts "erreurfile == $erreurfile " }
507 # [exec $cmdexec $protect $theUL]
509 catch {exec mkdir $resultRoot/$theUL}
510 catch {exec chmod 777 $resultRoot/$theUL}
514 cd $resultRoot/$theUL
516 if {![file isdirectory $resultRoot/$theUL/$theFunction]} {
517 if {$theStation=="wnt"} {
518 set stat1 [catch {file mkdir $resultRoot/$theUL/$theFunction} iscreated ]
519 if {$stat1 != 0 } { puts "iscreated == $iscreated " }
520 # [exec $cmdexec $protect $theUL]
522 catch {exec mkdir $resultRoot/$theUL/$theFunction}
523 catch {exec chmod 777 $resultRoot/$theUL/$theFunction}
526 cd $resultRoot/$theUL/$theFunction
529 if {$theStation=="wnt"} {
530 catch {file delete $theLog}
532 catch {exec rm -f $theLog}
535 foreach f [glob -nocomplain ${theTest}.*.xwd.Z] {catch {exec $cmdexec $del $f}}
538 if {$theStation=="wnt"} {
539 set f $resultRoot/$theUL/$theFunction/${theTest}[pid]
540 set f1 $resultRoot/$theUL/$theFunction/${theTest}[pid]
543 set f /tmp/theTest[pid]
546 ## send current infos in "begin" script for customize by AQ Team -plb/14feb97-
547 puts $ff "set testinfos(resultRoot) $resultRoot"
548 puts $ff "set testinfos(theUL) $theUL"
549 puts $ff "set testinfos(theFunction) $theFunction"
550 puts $ff "set testinfos(theTest) $theTest"
551 if {$themode == "samedraw"} {
552 puts $ff "cd $resultRoot/$theUL/$theFunction"
557 puts "testRoot $testRoot"
559 cd $resultRoot/$theUL/$theFunction
561 if {$theStation=="wnt"} {
562 set fff $resultRoot/$theUL/$theFunction/${theTest}[pid]-pop
563 set fpop [open $fff w]
564 for_file line $f1 { puts $fpop $line }
565 for_file line $testRoot/begin { puts $fpop $line }
566 if {[file exist $testRoot/$theUL/begin_wnt ] } {
567 for_file line $testRoot/$theUL/begin_wnt { puts $fpop $line }
569 if {[file exist $testRoot/$theUL/$theFunction/begin_wnt]} {
570 for_file line $testRoot/$theUL/$theFunction/begin_wnt { puts $fpop $line }
572 if {[file exist $testRoot/$theUL/$theFunction/begin]} {
573 for_file line $testRoot/$theUL/$theFunction/begin { puts $fpop $line }
576 for_file line $testRoot/$theUL/$theFunction/$theTest { puts $fpop $line }
577 if { [ file exists $testRoot/$theUL/end ] } {
578 for_file line $testRoot/$theUL/end { puts $fpop $line }
580 if { [ file exists $testRoot/end ] } {
581 for_file line $testRoot/end { puts $fpop $line }
584 if {[file exist $resultRoot/$theUL/$theFunction/${theTest}[pid] ] } {
585 file delete $resultRoot/$theUL/$theFunction/${theTest}[pid]
593 $testRoot/$theUL/begin \
594 $testRoot/$theUL/$theFunction/begin \
595 $testRoot/$theUL/$theFunction/$theTest \
596 $testRoot/$theUL/$theFunction/end \
597 $testRoot/$theUL/end \
600 set testroot $testRoot
602 if {$theStation=="wnt"} {
603 set f3 $resultRoot/$theUL/$theFunction/${theTest}.log
604 if { [file exists $f3] } { file delete $f3 }
605 puts "l'executable == $exe"
606 puts "testRoot == $testRoot"
608 #puts "output == $f3"
609 catch { exec $exe -f $f1 -o $f3 } popstatus
613 if {$themode != "samedraw" } {
614 catch { exec $exe -f $f >& ${theTest}.log }
616 # the draw est il toujours valide ?
617 set myList [winfo interps]
619 for {set i 0} { $i < [expr [llength $myList]] } { incr i } {
620 set p [lindex $myList $i]
621 if {$p == $theDraw} {set DrawExists "1"}
623 if { $DrawExists == "0"} {
624 puts "Pas de Draw, on en lance un !!"
626 while { $DrawExists == "0"} {
627 set myList [winfo interps]
628 set mylen [llength $myList]
629 while { [catch { exec $theExec -l >& $RESULT & } message] } {
633 # On espere avoir lance un draw, on recupere son nom
634 # comme on peut. La methode utilisee est extremement
635 # plantatoire, il faudrait pouvoir trouver le numero
638 while { $myList == [winfo interps] && [expr $i] < 20 } {
643 if { [expr $i] < 20 } {
646 set newList [winfo interps]
647 set newlen [llength $newList]
651 for {set i 0} { $i < [expr $newlen] && !$DrawExists } { incr i } {
653 set theDraw [lindex $newList $i]
654 for {set j 0} { $j < [expr $mylen]} {incr j} {
655 set p [lindex $myList $j]
656 if { $p == $theDraw} {
663 puts "nouvelle appli : $theDraw"
665 puts "echec creation nouveau Draw, on recommence"
667 if { [catch { exec kill -9 $Drawid } mes] } {
670 puts "le process etait bien la, mais le Draw n est pas venu!?!"
675 exec cp $RESULT $PREVIOUS
677 if { [catch {send $theDraw "source $f"} mes]} {
679 puts "on tue le Draw"
681 if { [catch { exec kill -9 $Drawid } mes] } { puts $mes }
684 catch {exec $DIFF $PREVIOUS $RESULT > $TEMP}
685 catch {exec cat $TEMP | $FILTRE >> ${theTest}.log}
691 if {$theStation=="wnt"} {
692 catch {file delete $f1}
694 catch {exec rm -f $f}
697 if { $theStation == "wnt" } {
698 catch {exec $cmdexec attrib ${theTest}.log}
700 catch { exec chmod 666 ${theTest}.log }
705 foreach f [glob -nocomplain photo*] {
706 set g $theTest.[string range $f 5 end].xwd
708 if {$theStation=="wnt"} {
709 catch {exec $cmdexec $move $f $g}
711 catch { exec mv -f $f $g }
713 catch {exec compress $g}
714 if {$theStation=="wnt"} {
715 catch { exec $cmdexec attrib $g.Z }
717 catch { exec chmod 666 $g.Z }
725 ####################################################
726 # send the current test
727 # to the process $theDraw
728 ####################################################
731 global testRoot resultRoot theExec theLog theDraw
732 global theUL theFunction theTest
735 if {$theTest == ""} return
737 puts "Sending $theUL $theFunction $theTest to $theDraw"
738 if {$theStation=="wnt"} {
739 set f $resultRoot\\\\$theUL\\\\$theFunction\\\\${theTest}[pid]
740 set f1 $resultRoot\\\\$theUL\\\\$theFunction\\\\${theTest}[pid]
741 set f2 $resultRoot\\\\$theUL\\\\$theFunction\\\\${theTest}.log
744 #set ff2 [open $f2 w]
745 puts $ff "set testroot $testRootNT"
747 set f /tmp/theTest[pid]
749 puts $ff "set testroot $testRoot"
752 ## send current infos in "begin" script for customize by AQ Team -plb/14feb97-
753 puts $ff "set testinfos(resultRoot) $resultRoot"
754 puts $ff "set testinfos(theUL) $theUL"
755 puts $ff "set testinfos(theFunction) $theFunction"
756 puts $ff "set testinfos(theTest) $theTest"
759 if {$theStation=="wnt"} {
760 set stat1 [catch {exec cmd /C copy /A \ $f1 + $testRoot\\begin + $testRoot\\$theUL\\begin_wnt + $testRoot\\$theUL\\$theFunction\\begin + $testRoot\\$theUL\\$theFunction\\$theTest + $testRoot\\$theUL\\$theFunction\\end + $testRoot\\$theUL\\end + $testRoot\\end + $f1} myerro]
761 send $theDraw "source $f1"
764 $testRoot/$theUL/begin \
765 $testRoot/$theUL/$theFunction/begin \
766 $testRoot/$theUL/$theFunction/$theTest \
767 $testRoot/$theUL/$theFunction/end \
768 $testRoot/$theUL/end >> $f}
769 send $theDraw "source $f"
773 ####################################################
774 # clear result, copy master
775 ####################################################
777 proc clearResult {} {
778 global theTest theLog theXWDFiles
779 catch {exec rm -f $theLog}
780 foreach f $theXWDFiles {catch {exec rm -f $f}}
788 global theLog theXWDFiles
789 global theMasterLog theMasterXWDFiles
790 global masterRoot theUL theFunction theTest
792 catch {exec rm -f $theMasterLog}
793 foreach f $theMasterXWDFiles {catch {exec rm -f $f}}
795 if {![file isdirectory $masterRoot/$theUL]} {
796 if {$theStation=="wnt"} {
799 #catch {exec $cmdexec mkdir $masterRoot\\$theUL}
800 #catch {exec $cmdexec $protect $masterRoot\\$theUL}
802 catch {exec mkdir $masterRoot/$theUL}
803 catch {exec chmod 777 $masterRoot/$theUL}
807 if {![file isdirectory $masterRoot/$theUL/$theFunction]} {
808 if {$theStation=="wnt"} {
810 file mkdir $theFunction
811 #catch {exec $cmdexec mkdir $masterRoot\\$theUL\\$theFunction}
812 #catch {exec $cmdexec $protect $masterRoot\\$theUL\\$theFunction}
814 catch {exec mkdir $masterRoot/$theUL/$theFunction}
815 catch {exec chmod 777 $masterRoot/$theUL/$theFunction}
819 if {$theStation=="wnt"} {set d $masterRoot\\$theUL\\$theFunction
820 } else {set d $masterRoot/$theUL/$theFunction}
821 if [file readable $theLog] {catch {exec cp $theLog $d}}
822 foreach f $theXWDFiles {catch {exec cp $f $d}}
828 ####################################################
829 # Make the initial list of UL
830 ####################################################
833 global listUL testRoot
834 set listUL [mkListTests $testRoot]