summaryrefslogtreecommitdiff
path: root/src/DrawResources/mdltest
blob: 236bdefcb337ed6e319c11f64479110c88b40d44 (plain)
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
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
#!/bin/sh
# The next line is executed by /bin/sh, but not Tcl \
  exec tclsh $0 ${1+"$@"}



#
#  suite au passage a tk4.1 on a plus besoin des references
#  a TCL-1-1
#
# batch test command
##########################################################
#
#  initialisation de  env(STATION)  
#                     env(WBCONTAINER)
#                     env(WBROOT)      
#

#package require Tk

puts $env(DRAWHOME)
source $env(DRAWHOME)/InitEnvironment.tcl

source $env(DRAWHOME)/Tests.tcl

# xab : 22/11/96  : on a encore besoin des 3 variables d'environement
#                   WBCONTAINER
#                   WBROOT
#                   STATION
#   usage
#
proc help {} {
    global resultRoot masterRoot testRoot
    puts {mdltest -h -hc -c -l -x executable -t testdir -r resultdir -m masterdir UL function test}
    puts ""
    puts "Run & compare modeling team tests."
    puts ""
    puts "-hc help on comparisons"
    puts "-l  only list the tests"
    puts "-c  performs only the comparisons"
    puts "-o  executable is run once for all tests"
    puts ""
    puts "-x executable : to run the test"
    puts "   none        use the executable TUL for each UL"
    puts "   -x compare  performs only the comparisons"
    puts "   -x list     only list the tests"
    puts ""
    puts "-t testdir   : root of the test hierarchy"
    puts "   default   : $testRoot"
    puts ""
    puts "-r resultdir : to store the results, or source for comparisons"
    puts "   default   : $resultRoot"
    puts "   must be a writable directory"
    puts ""
    puts "-m masterdir : reference results for comparisons"
    puts "   default   : $masterRoot"
    puts ""
    puts "UL function test : performs this test"
    puts "UL function      : performs all tests for this function"
    puts "UL               : performs all tests for all functions of this UL"
    puts "                 : performs all test"
    puts ""
    puts "UL function Test can be patterns (quote to protect from csh)"
    puts "example : mdltest -l '*' '*curve*'"
    puts ""
    exit
}
proc helpcomp {} {
    global theErrors
    puts ""
    puts "Result of comparisons"
    puts "====================="
    puts ""
    puts "For each test a status line is displayed of the following format"
    puts ""
    puts "xUL Function Test     Result Log XWD"
    puts ""
    puts "x is a single caracter : "
    puts "  ' ' : means no problem"
    puts "  '-' : means no result fro the test"
    puts "  '*' : means error detected or difference with the master"
    puts ""
    puts "Result is the status of the log file analysis : "
    foreach err $theErrors {
	puts "  [lindex $err 1] : means [lindex $err 2]"
    }
    puts ""
    puts "Log is the result of the logfile comparisons"
    puts "  OK    : means no differences"
    puts "  NO    : means no master logfile to compare with"
    puts "  DIFF  : means differences"
    puts ""
    puts "XWD is the result of the image comparisons"
    puts "  OK    : means no differences"
    puts "  NO    : means no master images to compare with"
    puts "  DIFF  : means differences"


    exit
}

# analyze arguments

set more 1
while {$more} {
    set more 1
    set shift 2
    switch -exact a[lindex $argv 0] {
	"a-x"     {set theExec    [lindex $argv 1]}
	"a-t"     {set testRoot   [lindex $argv 1]}
	"a-r"     {set resultRoot [lindex $argv 1]}
	"a-m"     {set masterRoot [lindex $argv 1]}
	"a-l"     {set theExec "list"; set shift 1;}
	"a-c"     {set theExec "compare"; set shift 1;}
	"a-o"     {set themode "samedraw"; set shift 1;}
	"a-hc"    {helpcomp}
	"a-h"     {help}
	default   {set more 0}
    }
    if $more {set argv [lrange $argv $shift end]}
}

puts ""
puts "Executable       : $theExec"
puts "Test   Directory : $testRoot"
puts "Result Directory : $resultRoot"
puts "Master Directory : $masterRoot"

if {![file isdirectory $resultRoot]} {
    puts "$resultRoot is not a directory"
    exit
}

set UL       "*"  
set Function "*"
set Test     "*"

if {[llength $argv] >= 1} {set UL       [lindex $argv 0]}
if {[llength $argv] >= 2} {set Function [lindex $argv 1]}
if {[llength $argv] >= 3} {set Test     [lindex $argv 2]}

puts ""
puts "UL       : $UL"
puts "Function : $Function"
puts "Test     : $Test"

init

# used to compute length for formatting the result
set l 0

if { $themode == "samedraw" } {
    set theDraw     ""
    set FILTRE      "/tmp/FILTRE[pid]"
    set DIFF        "/tmp/DIFF[pid]"
    set RESULT      "/tmp/RESULT[pid]"
    set PREVIOUS    "/tmp/PREVIOUS[pid]"
    set TEMP        "/tmp/TEMP[pid]"
    #on compile le Diff et le Filtre a Diff
    if { [catch { eval "exec $env(MDLTEST_COMPIL) $env(DRAWHOME)/Filtre.c -c -o ${FILTRE}.o" } mes] } { puts $mes }
    if { [catch { eval "exec $env(MDLTEST_COMPIL) ${FILTRE}.o -o $FILTRE" } mes] } { puts $mes }
    if { [catch { eval "exec $env(MDLTEST_COMPIL) $env(DRAWHOME)/DIFF.c -c -o ${DIFF}.o" } mes] } { puts $mes }
    if { [catch { eval "exec $env(MDLTEST_COMPIL) ${DIFF}.o -o $DIFF" } mes] } { puts $mes }
}

while {$theUL != ""} {
    if {! [string match $UL $theUL] }            {nextUL; continue;}
    if {! [string match $Function $theFunction]} {nextFunction; continue;}
    if {[string match $Test $theTest]} {
	if [file readable $testRoot/$theUL/$theFunction/$theTest] {
	    if {$theExec == "list"} {
		puts "$theUL $theFunction $theTest"
	    } else {
		if {$theExec != "compare"} runTest
		set l2 [string length "$theUL $theFunction $theTest"]
		if {$l2 > $l} {set l $l2}
	    }
	} else {
	    puts "Test does not exist : $theUL $theFunction $theTest"
	}
    }
    nextTest
}

# Pour les tests effectues dans 1 seul exe, on sort!!
if { $themode == "samedraw" } { 
    catch { send $theDraw "exit" } 
}


# do the comparisons


if {$theExec    == "list"} exit
if {$masterRoot == ""}     exit

set count 1
incr l 4

init

puts ""
while {$theUL != ""} {
    if {! [string match $UL $theUL] }            {nextUL; continue;}
    if {! [string match $Function $theFunction]} {nextFunction; continue;}
    if {[string match $Test $theTest]} {
	if [file readable $testRoot/$theUL/$theFunction/$theTest] {
	    if {$count == 1} {
		set s "  UL Function Test"
		puts -nonewline $s
		for {set i [string length $s]} {$i <= $l} {incr i} {puts -nonewline " "}
		puts $theStatusHeader
	    }
	    incr count
	    set s "$theStatus $theUL $theFunction $theTest :"
	    puts -nonewline $s
	    for {set i [string length $s]} {$i <= $l} {incr i} {puts -nonewline " "}
	    puts $theStatusLine
	}
    }
    nextTest
}

# destruction de la petite fenetre merdique.
catch { destroy . }

#on vire le Diff et le Filtre a Diff
if { $themode == "samedraw" } {
    catch { unlink $FILTRE } 
    catch { unlink ${FILTRE}.o } 
    catch { unlink $DIFF } 
    catch { unlink ${DIFF}.o } 
    catch { unlink $RESULT } 
    catch { unlink $PREVIOUS } 
    catch { unlink $TEMP } 
}