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