added support for the original "make chech-cdtest"
[deliverable/binutils-gdb.git] / ld / testsuite / lib / ld.exp
1 #
2 # default_ld_version
3 # extract and print the version number of ld
4 #
5 proc default_ld_version { ld } {
6 if { [file exists $ld] == 0 } then {
7 error "$ld does not exist"
8 exit 1
9 }
10
11 set tmp [exec $ld --version]
12 regexp "version.*$" $tmp version
13
14 if [info exists version] then {
15 clone_output "$ld $version\n"
16 }
17 }
18
19 #
20 # default_ld_relocate
21 # link an object using relocation
22 #
23 proc default_ld_relocate { ld target objects } {
24
25 global HOSTING_EMU
26
27 if { [file exists $ld] == 0 } then {
28 error "$ld does not exist"
29 exit 1
30 }
31
32 send_log "### EXEC \"$ld $HOSTING_EMU -o $target -r $objects\"\n"
33 verbose "### EXEC \"$ld $HOSTING_EMU -o $target -r $objects\""
34
35 catch "exec $ld $HOSTING_EMU -o $target -r $objects" exec_output
36 if ![string match "" $exec_output] then {
37 send_log "$exec_output\n"
38 verbose "$exec_output"
39 }
40 }
41
42
43 #
44 # default_ld_link
45 # link a program using ld
46 #
47 proc default_ld_link { ld target objects } {
48
49 global BFDLIB
50 global LIBIBERTY
51 global HOSTING_EMU
52 global HOSTING_CRT0
53 global HOSTING_LIBS
54
55 set objs "$HOSTING_CRT0 $objects"
56 set libs "$BFDLIB $LIBIBERTY $HOSTING_LIBS"
57
58 if { [file exists $ld] == 0 } then {
59 error "$ld does not exist"
60 exit 1
61 }
62
63 send_log "### EXEC \"$ld $HOSTING_EMU -o $target $objs $libs\"\n"
64 verbose "### EXEC \"$ld $HOSTING_EMU -o $target $objs $libs\""
65
66 catch "exec $ld $HOSTING_EMU -o $target $objs $libs" exec_output
67 if ![string match "" $exec_output] then {
68 send_log "$exec_output\n"
69 verbose "$exec_output"
70 }
71 }
72
73 #
74 # default_ld_compile
75 # compile an object using cc
76 #
77 proc default_ld_compile { cc source object } {
78 global CFLAGS
79 global srcdir
80 global subdir
81
82 if {[which $cc] == 0} then {
83 error "$cc does not exist"
84 exit 1
85 }
86
87 send_log "$cc $CFLAGS -I$srcdir/$subdir -c $source -o $object\n"
88 verbose "### EXEC \"$cc $CFLAGS -I$srcdir/$subdir -c $source -o $object\""
89
90 catch "exec $cc $CFLAGS -I$srcdir/$subdir -c $source -o $object" exec_output
91 if ![string match "" $exec_output] then {
92 send_log "$exec_output\n"
93 verbose "$exec_output"
94 }
95 }
96
97 #
98 # simple_diff
99 # compares two files line-by-line
100 # returns differences if exist
101 # returns null if file(s) cannot be opened
102 #
103 proc simple_diff { file_1 file_2 } {
104 global target
105
106 set eof -1
107 set differences 0
108
109 if [file exists $file_1] then {
110 set file_a [open $file_1 r]
111 } else {
112 warning "$file_1 doesn't exist"
113 return
114 }
115
116 if [file exists $file_2] then {
117 set file_b [open $file_2 r]
118 } else {
119 fail "$file_2 doesn't exist"
120 return
121 }
122
123 verbose "### Diff'ing: $file_1 $file_2\n" 2
124
125 while { [gets $file_a line] != $eof } {
126 if [regexp "^#.*$" $line] then {
127 continue
128 } else {
129 lappend list_a $line
130 }
131 }
132 close $file_a
133
134 while { [gets $file_b line] != $eof } {
135 if [regexp "^#.*$" $line] then {
136 continue
137 } else {
138 lappend list_b $line
139 }
140 }
141 close $file_b
142
143 for { set i 0 } { $i < [llength $list_a] } { incr i } {
144 set line_a [lindex $list_a $i]
145 set line_b [lindex $list_b $i]
146
147 verbose "\t$file_1: $i: $line_a\n" 3
148 verbose "\t$file_2: $i: $line_b\n" 3
149 if [string compare $line_a $line_b] then {
150 fail "Test: $target"
151 set differences 1
152
153 verbose "\t$file_1: $i: $line_a\n" 1
154 verbose "\t$file_2: $i: $line_b\n" 1
155
156 send_log "\t$file_1: $i: $line_a\n"
157 send_log "\t$file_2: $i: $line_b\n"
158 }
159 }
160
161 if $differences<1 then {
162 pass "Test: $target"
163 }
164 }
165
166
This page took 0.033088 seconds and 4 git commands to generate.