0024223: Review of unstable test cases
[occt.git] / tests / xml / begin
CommitLineData
607a96d4 1pload TOPTEST
2pload DCAF
3
4cpulimit 300
5
6set ValidatorCheck 0
7
8if { [info exists env(CSF_ValidatorPath)] != 0 } {
9 if {[file exists $env(CSF_ValidatorPath)]} {
10 set ValidatorCheck 1
11 set Validator $env(CSF_ValidatorPath)
12 }
13}
14
15if { [info exists imagedir] == 0 } {
16 set imagedir .
17}
18
19if { [info exists test_image ] == 0 } {
20 set test_image photo
21}
22
23set WorkDirectory $imagedir
24
25set os "ALL"
26if {[array get env os_type] != ""} {
27 set os $env(os_type)
28}
29
b432670a 30if { [regexp "indows" $os] } {
607a96d4 31 if {[regexp -nocase {jdk} $env(PATH)] || [regexp -nocase {java} $env(PATH)]} {
32 set Java "java"
33 } else {
34 puts "Warning: environment variable PATH doesn't contain path to Java"
35 }
36} else {
37 catch {set Java $env(JAVAHOME)/bin/java}
607a96d4 38}
39
40set SchemaFile ""
41
42proc SaveToFile { aD aFile } {
43 upvar $aD D
44 global FileSuffix ValidatorCheck
45 catch {[file delete ${aFile}]}
46 SaveAs D $aFile
47 if { [file exists $aFile] } {
48 if { $FileSuffix == "xml" && $ValidatorCheck} {
49 ValidateXml $aFile
50 } else {
51 puts "Validation of XML file by XSD schema is not provided."
52 }
53 } else {
54 puts "Error : There is no ${aFile} file"
55 }
56 catch {[file attributes ${aFile} -permissions 0777]}
57}
58
59proc ValidateXml { aFile } {
60 global Validator Java SchemaFile
61 if { ![info exists Java] } {
62 puts "Error : Java is not exists"
63 return
64 }
65 set isValidInfo ""
66 set ValCommand "exec $Java -jar $Validator $SchemaFile ${aFile}"
67 set isValid [catch {set isValidInfo [eval $ValCommand]}]
68 puts $isValidInfo
69 if { ![regexp "the document is valid" ${isValidInfo}] } {
70 puts "Error : File is not valid"
71 }
72}