Command checkplatform was created.
All test cases were updated.
Global variable os_type was eliminated.
New option -osx (MacOS) for procedure checkplatform was added.
Here:
* *BugNumber* is the bug ID in the tracker. For example: #12345.
-* *ListOfPlatforms* is a list of platforms, at which the bug is reproduced (Linux, Windows, MacOS, or All). Note that the platform name is custom for the OCCT test system; it corresponds to the value of environment variable *os_type* defined in DRAW.
+* *ListOfPlatforms* is a list of platforms, at which the bug is reproduced (Linux, Windows, MacOS, or All). Note that the platform name is custom for the OCCT test system; Use procedure *checkplatform* to get the platform name.
Example:
~~~~~
-Draw[2]> puts $env(os_type)
-windows
+Draw[2]> checkplatform
+Windows
~~~~~
* RegularExpression is a regular expression, which should be matched against the line indicating the problem in the script output.
puts "Error: Maximal deflection is too big"
}
}
+
+help checkplatform {
+ Return name of current platform if no options are given.
+
+ Use: checkplatform [options...]
+ Allowed options are:
+ -windows : return 1 if current platform is 'Windows', overwise return 0
+ -linux : return 1 if current platform is 'Linux', overwise return 0
+ -osx : return 1 if current platform is 'MacOS X', overwise return 0
+
+ Only one option can be used at once.
+ If no option is given, procedure will return the name of current platform.
+}
+proc checkplatform {args} {
+ set check_for_windows false
+ set check_for_linux false
+ set check_for_macosx false
+
+ set options {{"-windows" check_for_windows 0}
+ {"-linux" check_for_linux 0}
+ {"-osx" check_for_macosx 0}}
+
+ _check_args ${args} ${options} "checkplatform"
+
+ if { [regexp "indows" $::tcl_platform(os)] } {
+ set current_platform Windows
+ } elseif { $::tcl_platform(os) == "Linux" } {
+ set current_platform Linux
+ } elseif { $::tcl_platform(os) == "Darwin" } {
+ set current_platform MacOS
+ }
+
+ # no args are given
+ if { !${check_for_windows} && !${check_for_linux} && !${check_for_macosx}} {
+ return ${current_platform}
+ }
+
+ # check usage of proc checkplatform
+ if { [expr [string is true ${check_for_windows}] + [string is true ${check_for_linux}] + [string is true ${check_for_macosx}] ] > 1} {
+ error "Error: wrong usage of command checkplatform, only single option can be used at once"
+ }
+
+ # checking for Windows platform
+ if { ${check_for_windows} && ${current_platform} == "Windows" } {
+ return 1
+ }
+
+ # checking for Mac OS X platforms
+ if { ${check_for_linux} && ${current_platform} == "Linux" } {
+ return 1
+ }
+
+ # checking for Mac OS X platforms
+ if { ${check_for_macosx} && ${current_platform} == "MacOS" } {
+ return 1
+ }
+
+ # current platform is not equal to given as argument platform, return false
+ return 0
+}
# check if line defines specific treatment of some messages
if [regexp -nocase {^[ \s]*TODO ([^:]*):(.*)$} $line res platforms pattern] {
if { ! [regexp -nocase {\mAll\M} $platforms] &&
- ! [regexp -nocase "\\m$env(os_type)\\M" $platforms] } {
+ ! [regexp -nocase "\\m[checkplatform]\\M" $platforms] } {
lappend html_log [_html_highlight IGNORE $line]
continue ;# TODO statement is for another platform
}
}
if [regexp -nocase {^[ \s]*REQUIRED ([^:]*):[ \s]*(.*)$} $line res platforms pattern] {
if { ! [regexp -nocase {\mAll\M} $platforms] &&
- ! [regexp -nocase "\\m$env(os_type)\\M" $platforms] } {
+ ! [regexp -nocase "\\m[checkplatform]\\M" $platforms] } {
lappend html_log [_html_highlight IGNORE $line]
continue ;# REQUIRED statement is for another platform
}
return
}
-# define custom platform name
-proc _tests_platform_def {} {
- global env tcl_platform
-
- if [info exists env(os_type)] { return }
- set env(os_type) $tcl_platform(platform)
- if { $tcl_platform(os) == "Linux" } {
- set env(os_type) Linux
- }
- if { $tcl_platform(os) == "Darwin" } {
- set env(os_type) MacOS
- }
-}
-_tests_platform_def
-
# Auxiliary procedure to split path specification (usually defined by
# environment variable) into list of directories or files
proc _split_path {pathspec} {
set format PDF
-
-if { [string compare $tcl_platform(platform) "windows"] != 0 } {
- set size 144401
-} else {
+if { [checkplatform -windows] } {
set size 154489
+} else {
+ set size 144401
}
puts "There is not ${FileName2} file"
#
- if { [string compare $tcl_platform(platform) "windows"] == 0 } {
+ if { [checkplatform -windows] } {
puts "OS = Windows NT"
set status 1
}
} else {
puts "There is not ${FileName3} file"
#
- if { [string compare $tcl_platform(platform) "windows"] == 0 } {
+ if { [checkplatform -windows] } {
puts "OS = Windows NT"
} else {
puts "OS = Unix"
set BugNumber OCC23852
-set OS_platform $tcl_platform(platform)
-puts "OS = ${OS_platform}"
-
-if { [string compare ${OS_platform} "windows"] == 0 } {
+if { [checkplatform -windows] } {
# Windows, #1
set OSD_Path "\\\\Server\\Shared\\Folder\\File.Extension"
puts "${BugNumber}, Extension, #2: Error"
}
-}
-
-if { [string compare ${OS_platform} "unix"] == 0 } {
+} else {
# Linux
set OSD_Path "//Server/Shared/Folder/File.Extension"
puts "OSD_Path = ${OSD_Path}"
set result2 [lindex ${result} 1]
set CurrentDirectory [pwd]
set UpTrek "[file join [file dirname [file dirname ${CurrentDirectory}]] [file tail ${CurrentDirectory}]]"
- if { [string compare $tcl_platform(platform) "windows"] != 0} {
- set res1 [ string range $result1 1 [expr [string length $result1] -3 ] ]
- set res2 [ string range $result2 1 [expr [string length $result2] -3 ] ]
- } else {
+ if { [checkplatform -windows] } {
set res1 [ string range $result1 3 [expr [string length $result1] -2 ] ]
set res2 [ string range $result2 3 [expr [string length $result2] -2 ] ]
set CurrentDirectory [ string range $CurrentDirectory 2 [expr [string length $CurrentDirectory] -1 ]]
set UpTrek [ string range $UpTrek 2 [expr [string length $UpTrek] -1 ]]
+ } else {
+ set res1 [ string range $result1 1 [expr [string length $result1] -3 ] ]
+ set res2 [ string range $result2 1 [expr [string length $result2] -3 ] ]
}
if {[string compare ${res1} "${CurrentDirectory}"] == 0} {
puts "OCC309: OK 1"
-set env(os_type) $tcl_platform(platform)
-if {[string compare $env(os_type) "windows"] != 0 } {
+if { ![checkplatform -windows] } {
puts "TODO ?OCC12345 MacOS: \\*\\* Exception"
puts "TODO ?OCC12345 MacOS: An exception was caught"
puts "TODO ?OCC12345 MacOS: TEST INCOMPLETE"
regexp {CPU user time: ([-0-9.+eE]+) seconds} $q2 full z
puts "$z"
-if { [string compare $tcl_platform(platform) "windows"] == 0 } {
+if { [checkplatform -windows] } {
puts "OS = Windows NT"
set max_time 0.5
} else {
#
regexp {CPU user time: ([-0-9.+eE]+) seconds} $q1 full t1
puts "$t1"
-if { [string compare $tcl_platform(platform) "windows"] == 0 } {
+if { [checkplatform -windows] } {
puts "OS = Windows NT"
set max_time1 20
} else {
#
regexp {CPU user time: ([-0-9.+eE]+) seconds} $q2 full t2
puts "$t2"
-if { [string compare $tcl_platform(platform) "windows"] == 0 } {
+if { [checkplatform -windows] } {
puts "OS = Windows NT"
set max_time2 20
} else {
regexp {CPU user time: ([-0-9.+eE]+) seconds} $chrono_info full CPU_time
puts "Elapsed time is: $CPU_time"
-set currentOS $tcl_platform(os)
-if {[string compare $currentOS "Windows NT"] == 0} {
+if { [checkplatform -windows] } {
if {[regexp {Debug mode} [dversion]]} {
# initial CPU_time for WINDOWS in DEBUG mode is 90 sec
puts "Checking WINDOWS performance in debug mode..."
puts "Done!"
}
}
-}
-if {[string compare $currentOS "Linux"] == 0} {
+} else {
if {[regexp {Debug mode} [dversion]]} {
# initial CPU_time for LINUX in DEBUG mode is 90 sec
puts "Checking LINUX performance in debug mode..."
}
dchrono cr stop
-if { [string compare $tcl_platform(platform) "windows"] == 0 } {
+if { [checkplatform -windows] } {
set max_time 7.5
} else {
set max_time 4.5
set Deflection 1.
catch {incmesh result ${Deflection} }
-if { [string compare $tcl_platform(platform) "windows"] == 0 } {
+if { [checkplatform -windows] } {
set good_tri 96265
set good_nod 71339
set good_defl 27.956052399907215
checkprops result -s 1.40193e+07
checknbshapes result -vertex 372 -edge 369 -wire 2 -face 1 -shell 0 -solid 0 -compsolid 0 -compound 1 -shape 745
-if {[string compare $tcl_platform(platform) "windows"] == 0} {
+if { [checkplatform -windows] } {
puts "windows"
set Good_CPU_user_time 0.
} else {
restore [locate_data_file OCC567a.draw] s1
restore [locate_data_file OCC567b.draw] s2
-if { [string compare $tcl_platform(platform) "windows"] == 0 } {
+if { [checkplatform -windows] } {
puts "OS = Windows NT"
set N_repeat 10
} else {
regexp {CPU user time: ([-0-9.+eE]+) seconds} $chrono_info full CPU_time
puts "Elapsed time is: $CPU_time"
-# Check current OS
-set currentOS $tcl_platform(os)
-
# Check prformance on Windows
-if {[string compare $currentOS "Windows NT"] == 0} {
+if { [checkplatform -windows] } {
if {[regexp {Debug mode} [dversion]]} {
# DEBUG mode
# initial CPU_time for WINDOWS in DEBUG mode is 410 ((186+19)*2) sec
puts "Done!"
}
}
-}
-
-# Check performance on Linux
-if {[string compare $currentOS "Linux"] == 0} {
+} else {
if {[regexp {Debug mode} [dversion]]} {
# DEBUG mode
# initial CPU_time for LINUX in DEBUG mode is 900 sec
regexp {CPU user time: ([-0-9.+eE]+) seconds} $chrono_info full CPU_time
puts "Elapsed time is: $CPU_time"
-# Check current OS
-set currentOS $tcl_platform(os)
-
# Check prformance on Windows
-if {[string compare $currentOS "Windows NT"] == 0} {
+if { [checkplatform -windows] } {
if {[regexp {Debug mode} [dversion]]} {
# DEBUG mode
# initial CPU_time for WINDOWS in DEBUG mode is 1208 ((549+55)*2) sec
puts "Done!"
}
}
-}
-
-# Check performance on Linux
-if {[string compare $currentOS "Linux"] == 0} {
+} else {
if {[regexp {Debug mode} [dversion]]} {
# DEBUG mode
# initial CPU_time for LINUX in DEBUG mode is 1500 sec
vexport ${aFile} PDF
-if { [string compare $tcl_platform(platform) "windows"] != 0 } {
- set refsize 144401
-} else {
+if { [checkplatform -windows] } {
set refsize 153993
+} else {
+ set refsize 144401
}
if { [file exists ${aFile}] } {
vexport ${aFile} PDF
-if { [string compare $tcl_platform(platform) "windows"] != 0 } {
- set refsize 10107
-} else {
+if { [checkplatform -windows] } {
set refsize 10131
+} else {
+ set refsize 10107
}
if { [file exists ${aFile}] } {
vexport ${aFile} PS
-if { [string compare $tcl_platform(platform) "windows"] != 0 } {
- set refsize 10386
-} else {
+if { [checkplatform -windows] } {
set refsize 10410
+} else {
+ set refsize 10386
}
if { [file exists ${aFile}] } {
vexport ${aFile} EPS
-if { [string compare $tcl_platform(platform) "windows"] != 0 } {
- set refsize 10330
-} else {
+if { [checkplatform -windows] } {
set refsize 10354
+} else {
+ set refsize 10330
}
if { [file exists ${aFile}] } {
vexport ${aFile} SVG
-if { [string compare $tcl_platform(platform) "windows"] != 0 } {
- set refsize 14207
-} else {
+if { [checkplatform -windows] } {
set refsize 14091
+} else {
+ set refsize 14207
}
if { [file exists ${aFile}] } {
vexport ${aFile} PGF
-if { [string compare $tcl_platform(platform) "windows"] != 0 } {
- set refsize 20438
-} else {
+if { [checkplatform -windows] } {
set refsize 20810
+} else {
+ set refsize 20438
}
if { [file exists ${aFile}] } {
vsetdispmode 1
vfit
-if { [string compare $tcl_platform(platform) "windows"] == 0 } {
- set good_tri 6114
- set good_nod 3080
- set good_defl 0.50050406431775729
+if { [checkplatform -windows] } {
+ set good_tri 6114
+ set good_nod 3080
+ set good_defl 0.50050406431775729
} else {
set good_tri 6148
set good_nod 3097
set result24 [regexp "$Yellow" [vreadpixel $x5 $y5 rgb]]
set result25 [regexp "$Yellow" [vreadpixel $x6 $y6 rgb]]
-set env(os_type) $tcl_platform(platform)
-if { [string compare $env(os_type) "windows"] != 0 } {
+if { ![checkplatform -windows] } {
set result31 [regexp "$Cyan" [vreadpixel $x2 $y2 rgb]]
if { $result31 == 0 } {
set IsFaulty 1
vaxo
vzbufftrihedron
-if { [array get env os_type] != "" } {
- set os $env(os_type)
-}
-if { [string compare $os "windows"] != 0 } {
- # Linux platform
- set ok_color "GRAY85"
-} else {
+if { [checkplatform -windows] } {
# Windows platform
set ok_color "GRAY52"
+} else {
+ # Linux platform
+ set ok_color "GRAY85"
}
set bug_info [vreadpixel 71 350 rgb name]
# Just run multiple conversions of the shape to and from diferent formats and
# check that the result is good shape with expected area
-set anOS $tcl_platform(os)
-if { ${anOS} == "Linux" } {
+if { [checkplatform -linux] } {
dlocale LC_ALL fr_FR
} else {
dlocale LC_ALL French
if { [string compare $command chamf_sequence] == 0 } {
puts "TODO #22909 ALL: Error: The tests should be reviewed"
puts "Error: The tests should be reviewed."
- set env(os_type) $tcl_platform(platform)
set nf 0
- if { [string compare ${env(os_type)} "windows"] != 0 } {
+ if { ![checkplatform -windows] } {
if { [string compare $group dist_dist] == 0 } {
set nf 2
} elseif { [string compare $group equal_dist] == 0 } {
}
}
- if { [string compare ${env(os_type)} "windows"] == 0} {
+ if { [checkplatform -windows] } {
if {[string compare $group dist_dist] == 0 || [string compare $group equal_dist] == 0 } {
set nf 2
}
}
- if { [string compare ${env(os_type)} "MacOS"] == 0 } {
+ if { [checkplatform -osx] } {
if { [string compare $group dist_dist] == 0 } {
puts "TODO OCC24156 MacOS: chamfer is not done. compute of chamfer failed"
set nf 8
}
if { $nf != 0 } {
- #puts "TODO OCC22909 $env(os_type):Faulty shapes in variables faulty_1 to faulty_$nf"
+ #puts "TODO OCC22909 [checkplatform]:Faulty shapes in variables faulty_1 to faulty_$nf"
puts "TODO OCC22909 ALL:Faulty shapes in variables faulty_1 to faulty_"
}
}
# test for command getsource
# check that path returned for command pload is as expected
-set env(os_type) $tcl_platform(platform)
-if { [string compare $env(os_type) "windows"] == 0 } {
+if { [checkplatform -windows] } {
set expected src/Draw/Draw_PloadCommands.cxx
} else {
set expected /src/Draw/Draw_PloadCommands.cxx
set TheFileName shading_055.brep
-set env(os_type) $tcl_platform(os)
if { [string compare $command "shading"] == 0 } {
set nb 62
}
}
set bug_cross "OCC22687"
-set nbcross($env(os_type)) $nb
+set nbcross([checkplatform]) $nb
set nbt 8
set nbl 8
set nbn 83
- set nbwithouttri($env(os_type)) $nbt
- set nbfree($env(os_type)) $nbl
- set nbfreenodes($env(os_type)) $nbn
+ set nbwithouttri([checkplatform]) $nbt
+ set nbfree([checkplatform]) $nbl
+ set nbfreenodes([checkplatform]) $nbn
} else {
set bug_withouttri "OCC23105"
##set nbt 14
set nbt 8
set nbn 60
set nbl 12
- set nbwithouttri($env(os_type)) $nbt
- set nbfree($env(os_type)) $nbl
- set nbfreenodes($env(os_type)) $nbn
+ set nbwithouttri([checkplatform]) $nbt
+ set nbfree([checkplatform]) $nbl
+ set nbfreenodes([checkplatform]) $nbn
}
set libname TKSTEP
-switch -nocase $env(os_type) {
+switch -nocase [checkplatform] {
windows {set libname ${libname}.dll}
linux {set libname lib${libname}.so}
macos {set libname lib${libname}.dylib}
}
lappend values "$diff_cl"
-if { [string compare $tcl_platform(platform) "windows"] != 0 } {
- set check_values { 1.2363286058767904
- 2.7537414143534
- 1.5596260162601621
- 3.937043746844462
- 1.2133020329576465
- 1.2164522569168656
- 1.2495457282327385
- 0.10352433841051313
- 0.45175659293697572
- }
-} else {
+if { [checkplatform -windows] } {
set check_values { 1.383409071179103
5.1472531605899908
5.55719377028335395
0.21983563611646603
}
if { [regexp {64} [dversion]] } {
- set check_values { 1.5
- 5.2
- 5.7
- 5.7
- 1.7
- 1.3
- 1.6
- 0.4
- 0.4
+ set check_values { 1.5
+ 5.2
+ 5.7
+ 5.7
+ 1.7
+ 1.3
+ 1.6
+ 0.4
+ 0.4
+ }
+ }
+} else {
+ set check_values { 1.2363286058767904
+ 2.7537414143534
+ 1.5596260162601621
+ 3.937043746844462
+ 1.2133020329576465
+ 1.2164522569168656
+ 1.2495457282327385
+ 0.10352433841051313
+ 0.45175659293697572
}
- }
}
+
set index 0
foreach key $keys {
set value [lindex $values $index]
}
}
-if { [string compare $tcl_platform(platform) "windows"] != 0 } {
- set check_values { 0.1540285
- 0.1286995
- 0.1607561
- 0.3624441
- }
-} else {
+if { [checkplatform -windows] } {
set check_values { 0.018136771
0.008694706
0.019123649
0.784462745
}
+} else {
+ set check_values { 0.1540285
+ 0.1286995
+ 0.1607561
+ 0.3624441
+ }
}
set index 0
}
}
-if { [string compare $tcl_platform(platform) "windows"] != 0 } {
- set check_values { 0.1549615
- 0.1290805
- 0.1602191
- 0.3487175
- }
-} else {
+if { [checkplatform -windows] } {
set check_values { 0.017762852
0.008435507
0.018746851
0.079263713
}
+} else {
+ set check_values { 0.1549615
+ 0.1290805
+ 0.1602191
+ 0.3487175
+ }
}
set index 0
set WorkDirectory $imagedir
-set env(os_type) $tcl_platform(platform)
-if { [regexp "indows" $env(os_type)] } {
+if { [checkplatform -windows] } {
if {[regexp -nocase {jdk} $env(PATH)] || [regexp -nocase {java} $env(PATH)]} {
- set Java "java"
+ set Java "java"
} else {
- puts "Warning: environment variable PATH doesn't contain path to Java"
+ puts "Warning: environment variable PATH doesn't contain path to Java"
}
} else {
catch {set Java $env(JAVAHOME)/bin/java}