-
Notifications
You must be signed in to change notification settings - Fork 5
/
pftest.tcl
119 lines (95 loc) · 2.9 KB
/
pftest.tcl
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
set sig_digits 6
proc pftestIsEqual {a b message} {
set pf_eps 1e-5
if [ expr abs($a - $b) > $pf_eps ] {
puts "FAILED : $message $a is not equal to $b"
return 0
} {
return 1
}
}
proc eps {{base 1}} {
set eps 1e-20
while {$base-$eps==$base} {
set eps [expr {$eps+1e-22}]
}
set eps [expr {$eps+1e-22}]
}
proc pftestFile {file message sig_digits} {
if [file exists $file] {
if [file exists correct_output/$file] {
set correct [pfload correct_output/$file]
set new [pfload $file]
set diff [pfmdiff $new $correct $sig_digits]
if {[string length $diff] != 0 } {
set mSigDigs [lindex $diff 0]
set maxAbsDiff [lindex $diff 1]
set i [lindex $mSigDigs 0]
set j [lindex $mSigDigs 1]
set k [lindex $mSigDigs 2]
puts "FAILED : $message"
puts [format "\tMinimum significant digits at (% 3d, % 3d, % 3d) = %2d"\
$i $j $k [lindex $mSigDigs 3]]
puts [format "\tCorrect value %e" [pfgetelt $correct $i $j $k]]
puts [format "\tComputed value %e" [pfgetelt $new $i $j $k]]
set elt_diff [expr abs([pfgetelt $correct $i $j $k] - [pfgetelt $new $i $j $k])]
puts [format "\tDifference %e" $elt_diff]
puts [format "\tMaximum absolute difference = %e" $maxAbsDiff]
return 0
} {
return 1
}
} {
puts "FAILED : regression check output file <correct_output/$file> does not exist"
}
} {
puts "FAILED : output file <$file> not created"
return 0
}
}
proc pftestFileWithAbs {file message sig_digits abs_value} {
if [file exists $file] {
set correct [pfload correct_output/$file]
set new [pfload $file]
set diff [pfmdiff $new $correct $sig_digits]
if {[string length $diff] != 0 } {
set mSigDigs [lindex $diff 0]
set maxAbsDiff [lindex $diff 1]
set i [lindex $mSigDigs 0]
set j [lindex $mSigDigs 1]
set k [lindex $mSigDigs 2]
set elt_diff [expr abs([pfgetelt $correct $i $j $k] - [pfgetelt $new $i $j $k])]
if [expr $elt_diff > $abs_value] {
puts "FAILED : $message"
puts [format "\tMinimum significant digits at (% 3d, % 3d, % 3d) = %2d"\
$i $j $k [lindex $mSigDigs 3]]
puts [format "\tCorrect value %e" [pfgetelt $correct $i $j $k]]
puts [format "\tComputed value %e" [pfgetelt $new $i $j $k]]
puts [format "\tDifference %e" $elt_diff]
puts [format "\tMaximum absolute difference = %e" $maxAbsDiff]
return 0
}
}
return 1
} {
puts "FAILED : output file <$file> not created"
return 0
}
}
proc pftestParseAndEvaluateOutputForTCL {file} {
if [file exists $file] {
if [catch {open $file r} fileID] {
puts "FAILED : output file <$file> could not be read"
} {
while { [gets $fileID line] >= 0} {
if [regexp {(.*)tcl:\s*(.*)} $line match header tcl_statement] {
uplevel $tcl_statement
}
}
close $fileID
}
} {
puts "FAILED : output file <$file> not created"
return 1
}
}