OSDN Git Service

* public snapshot of sid simulator
[pf3gnuchains/pf3gnuchains3x.git] / sid / component / testsuite / sidcomp.cfgroot / badconf.exp
1 proc sid_check_err {filename} {
2     global spawn_id
3     global TOOL_OPTIONS
4     global prefix
5     global srcdir
6     global test
7
8     set build_ltldpath [join [glob "../*"] ":"]
9     set install_ltldpath "$prefix/lib/sidcomp"
10     set ltldpath ":$build_ltldpath:$install_ltldpath:"
11
12     if {[string match "*static*" $TOOL_OPTIONS]} then {
13         set mksidconf [sid_find_file "mksidconf"]
14         system $mksidconf -static $file
15         regsub "(.*).conf" $file {./\1} sid
16         regsub "(.*).conf" $file {\1.sconf} file
17     } else {
18         set sid [sid_find_file "sid" "sid.exe"]
19     }
20
21     global timeout
22     set last_timeout $timeout
23     set timeout 30
24     set expfile [open "$srcdir/sidcomp.cfgroot/$filename.expect" r]
25     catch {exec env SID_LIBRARY_PATH=$ltldpath $sid "$srcdir/sidcomp.cfgroot/$filename.badconf"} result
26
27     set output [split $result \n]
28     for {set i 0} {$i < [llength $output] } {incr i} {
29        set line [lindex $output $i]
30         if {[string first $filename $line] != "-1"} {
31             set wholeline [split $line /]
32             set linelength [llength $wholeline]
33             set startindex [lsearch $wholeline $filename*]
34             set resultline [lindex $wholeline $startindex]
35             #             set lastindex [expr $linelength - 1]
36             if {$startindex != [expr $linelength -1] } then {
37                 for {set j [expr $startindex + 1]} {$j < $linelength } {incr j} { 
38                     append resultline /[lindex $wholeline $j]
39                 }
40             }
41             #            gets rid of the path
42             if { [gets $expfile  expectline] >= 0 } then {
43                 if {[string match $expectline $resultline] == "0"} then {
44                     fail "$test - mismatch on line [expr $i + 1]\n  expected $expectline\n  result   $resultline"
45                     close $expfile
46                     return
47                 }
48             } else {
49                 warning "can't get next line in expected file"
50                 fail $test; return
51             }  
52         }
53     }
54     close $expfile
55     verbose "$test - matched $i lines"
56     if { $i == [llength $output] } then { pass $test }
57     set timeout $last_timeout
58 }
59
60
61 foreach file [glob -nocomplain "$srcdir/sidcomp.cfgroot/*.badconf"] {
62    set wholepath [split $file /]
63    set name [lindex $wholepath [expr [llength $wholepath] -1 ]]
64    set conffile [lindex [split $name .] 0]
65    set test "testing sid with bad config file $conffile.badconf"
66    set id [sid_check_err $conffile]
67 }