0023619: Integration of test grid "xml" into the new testing system
[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
30if { [regexp "indows" $os ] == 1 } {
31 set env(CSF_TestDataPath) "$env(CSF_TestDataPath);$env(CASROOT)"
32 if {[regexp -nocase {jdk} $env(PATH)] || [regexp -nocase {java} $env(PATH)]} {
33 set Java "java"
34 } else {
35 puts "Warning: environment variable PATH doesn't contain path to Java"
36 }
37} else {
38 catch {set Java $env(JAVAHOME)/bin/java}
39 set env(CSF_TestDataPath) "$env(CSF_TestDataPath):$env(CASROOT)"
40}
41
42set SchemaFile ""
43
44proc SaveToFile { aD aFile } {
45 upvar $aD D
46 global FileSuffix ValidatorCheck
47 catch {[file delete ${aFile}]}
48 SaveAs D $aFile
49 if { [file exists $aFile] } {
50 if { $FileSuffix == "xml" && $ValidatorCheck} {
51 ValidateXml $aFile
52 } else {
53 puts "Validation of XML file by XSD schema is not provided."
54 }
55 } else {
56 puts "Error : There is no ${aFile} file"
57 }
58 catch {[file attributes ${aFile} -permissions 0777]}
59}
60
61proc ValidateXml { aFile } {
62 global Validator Java SchemaFile
63 if { ![info exists Java] } {
64 puts "Error : Java is not exists"
65 return
66 }
67 set isValidInfo ""
68 set ValCommand "exec $Java -jar $Validator $SchemaFile ${aFile}"
69 set isValid [catch {set isValidInfo [eval $ValCommand]}]
70 puts $isValidInfo
71 if { ![regexp "the document is valid" ${isValidInfo}] } {
72 puts "Error : File is not valid"
73 }
74}