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 | |
863f782a |
25 | if { [checkplatform -windows] } { |
607a96d4 |
26 | if {[regexp -nocase {jdk} $env(PATH)] || [regexp -nocase {java} $env(PATH)]} { |
863f782a |
27 | set Java "java" |
607a96d4 |
28 | } else { |
863f782a |
29 | puts "Warning: environment variable PATH doesn't contain path to Java" |
607a96d4 |
30 | } |
31 | } else { |
32 | catch {set Java $env(JAVAHOME)/bin/java} |
607a96d4 |
33 | } |
34 | |
35 | set SchemaFile "" |
36 | |
37 | proc SaveToFile { aD aFile } { |
38 | upvar $aD D |
39 | global FileSuffix ValidatorCheck |
40 | catch {[file delete ${aFile}]} |
191082ac |
41 | SaveAs D $aFile |
607a96d4 |
42 | if { [file exists $aFile] } { |
43 | if { $FileSuffix == "xml" && $ValidatorCheck} { |
44 | ValidateXml $aFile |
45 | } else { |
46 | puts "Validation of XML file by XSD schema is not provided." |
47 | } |
48 | } else { |
49 | puts "Error : There is no ${aFile} file" |
50 | } |
51 | catch {[file attributes ${aFile} -permissions 0777]} |
52 | } |
53 | |
54 | proc ValidateXml { aFile } { |
55 | global Validator Java SchemaFile |
56 | if { ![info exists Java] } { |
57 | puts "Error : Java is not exists" |
58 | return |
59 | } |
60 | set isValidInfo "" |
61 | set ValCommand "exec $Java -jar $Validator $SchemaFile ${aFile}" |
62 | set isValid [catch {set isValidInfo [eval $ValCommand]}] |
63 | puts $isValidInfo |
64 | if { ![regexp "the document is valid" ${isValidInfo}] } { |
65 | puts "Error : File is not valid" |
66 | } |
67 | } |