607a96d4 |
1 | pload TOPTEST |
2 | pload DCAF |
3 | |
4 | cpulimit 300 |
5 | |
6 | set ValidatorCheck 0 |
7 | |
8 | if { [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 | |
15 | if { [info exists imagedir] == 0 } { |
16 | set imagedir . |
17 | } |
18 | |
19 | if { [info exists test_image ] == 0 } { |
20 | set test_image photo |
21 | } |
22 | |
23 | set WorkDirectory $imagedir |
24 | |
25 | set os "ALL" |
26 | if {[array get env os_type] != ""} { |
27 | set os $env(os_type) |
28 | } |
29 | |
30 | if { [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 | |
42 | set SchemaFile "" |
43 | |
44 | proc 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 | |
61 | proc 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 | } |