- Expanded test cases

This commit is contained in:
koennecke
2009-02-03 08:11:59 +00:00
parent 7663b4e88b
commit 9d4d09854e
7 changed files with 265 additions and 21 deletions

View File

@ -11,9 +11,9 @@ proc SICSValue {command} {
return [string trim [lindex $l 1]]
}
#-----------------------------------------------------------------------------
proc compareValue {is should} {
proc compareValue {is should {delta .01} } {
if {[string is double $is] == 1} {
if {abs($should - $is) > .01} {
if {abs($should - $is) > $delta} {
error "Bad compare is: $is, should $should"
}
} else {
@ -23,6 +23,18 @@ proc compareValue {is should} {
}
return OK
}
#-----------------------------------------------------------------------------
proc compareMultiValue {is should {delta .01} } {
set l1 [split [string trim $is]]
set l2 [split [string trim $should]]
if {[llength $l1 ] != [llength $l2]} {
error "List length mismatch in compareMultiValue"
}
for {set i 0} {$i < [llength $l1]} {incr i } {
compareValue [lindex $l1 $i] [lindex $l2 $i] $delta
}
return OK
}
#------------------------------------------------------------------------------
proc testPar {name testval priv } {
config rights Spy Spy
@ -41,6 +53,24 @@ proc testPar {name testval priv } {
eval $name $value
return "OK"
}
#------------------------------------------------------------------------------
proc testMultiPar {name testval priv} {
config rights Spy Spy
set value [SICSValue $name]
set res [eval $name $testval]
if {[string first ERROR $res] < 0} {
error "Managed to set parameter even if not allowed"
}
config rights $priv $priv
set res [eval $name $testval]
if {[string first ERROR $res] >= 0} {
error "Setting parameter failed with $res"
}
set readback [SICSValue $name]
compareMultiValue $readback $testval
eval $name $value
return "OK"
}
#-------------------------------------------------------------------------------
proc testROPar {name val} {
config rights Mugger Mugger
@ -48,9 +78,13 @@ proc testROPar {name val} {
compareValue $value $val
catch {$name [expr $val + 1]} msg
set value [SICSValue $name]
compareValue $value $val
set status [catch {compareValue $value $val} msg]
config rights Spy Spy
return OK
if {$status == 0} {
error "Was able to change read-only parameter name"
} else {
return OK
}
}
#------------------------------------------------------------------------------
proc testDrive {name value priv} {