Merge from mainline.
[official-gcc.git] / libjava / classpath / testsuite / lib / java.exp
blobe12272675b235d0564f0059ecfb6ce53cadc3ee8
2 # Author: Petter Reinholdtsen <pere@td.org.uit.no>
4 # Java regression tester for DejaGNU
7 load_lib target.exp
10 # Compile and run all available java source
12 proc test-java-source { } {
13 global srcdir
14 global subdir
15 global runtests
17 # Find all Java-files
18 foreach src [lsort [glob -nocomplain $srcdir/$subdir/*.java]] {
19 # If we're only testing specific files and this isn't one of them,
20 # skip it.
21 if ![runtest_file_p $runtests $src] then {
22 continue
25 java-compile-execute $src
28 # Find all jasmin (java assambler) files
29 foreach src [lsort [glob -nocomplain $srcdir/$subdir/*.j]] {
30 # If we're only testing specific files and this isn't one of them,
31 # skip it.
32 if ![runtest_file_p $runtests $src] then {
33 continue
36 jasmin-assemble-execute $src
41 # Compile #args
43 proc java-compile { args } {
44 set src $args
45 set output ""
46 set options ""
47 set comp_output [javac-target-compile "$src" "$output" executable $options];
51 # Assemble #args
53 proc jasmin-assemble { args } {
54 set src $args
55 set output ""
56 set options ""
57 set comp_output [jasmin-target-assemble "$src" "$output" executable $options];
61 # Compile $args and execute java class runtime_test
63 proc java-compile-execute { args } {
64 global srcdir
65 global subdir
67 set comp_output [java-compile $args]
68 if ![regexp "^$" $comp_output] {
69 # Do not care about kaffes stupid messages
70 #fail $args
71 #print "$comp_output"
72 #return
75 global JAVA
76 set java $JAVA
78 set classpath [getenv CLASSPATH]
79 setenv CLASSPATH "${srcdir}/$subdir:$classpath"
81 # XXX There must be a better way to get basename
82 catch {exec basename $args .java} basename
83 catch {exec $java $basename} run_output
84 exec rm -f "${srcdir}/$subdir/$basename.class"
86 set lines ""
87 foreach line [split $run_output \n] {
88 if [regexp "PASSED:.*" $line] {
89 if ![regexp "^$" $lines] {
90 fail "$args $lines"
92 pass "$args $line"
93 } else {
94 if [regexp "FAILED:.*" $line] {
95 fail "$args $line"
96 } else {
97 # Accumulate "wild" lines
98 if ![regexp "^$" $lines] {
99 set lines "$lines\n $line"
100 } else {
101 set lines "$line"
106 if ![regexp "^$" $lines] {
107 fail "$args $lines"
110 # Reset CLASSPATH
111 setenv CLASSPATH "$classpath"
113 return;
117 # Compile $args and execute java class runtime_test
119 proc jasmin-assemble-execute { args } {
120 global srcdir
121 global subdir
123 set comp_output [jasmin-assemble $args]
124 if ![regexp "^$" $comp_output] {
125 #fail $args
126 #print "$comp_output"
127 #return
130 # XXX Should use some default value
131 global JAVA
132 set java $JAVA
134 set classpath [getenv CLASSPATH]
135 setenv CLASSPATH "${srcdir}/$subdir:$classpath"
137 # XXX There must be a better way to get basename
138 catch {exec basename $args .j} basename
139 catch {exec $java $basename} run_output
140 exec rm -f "${srcdir}/$subdir/$basename.class"
142 set lines ""
143 foreach line [split $run_output \n] {
144 if [regexp "PASSED:.*" $line] {
145 if ![regexp "^$" $lines] {
146 fail "$args $lines"
148 pass "$args $line"
149 } else {
150 if [regexp "FAILED:.*" $line] {
151 fail "$args $line"
152 } else {
153 # Accumulate "wild" lines
154 if ![regexp "^$" $lines] {
155 set lines "$lines\n $line"
156 } else {
157 set lines "$line"
162 if ![regexp "^$" $lines] {
163 fail "$args $lines"
166 # Reset CLASSPATH
167 setenv CLASSPATH "$classpath"
169 return;
173 # Compile java source
175 proc javac-target-compile { source dest type options } {
176 # XXX Do it the simple way - should use target_compile
178 global JAVAC
179 set javac $JAVAC
181 catch {exec $javac $source} comp_output
182 return $comp_output
184 # set options ""
185 # lappend options "compiler=javac"
186 # lappend options "additional_flags=-g"
187 # lappend options "libs="
188 # lappend options "ldflags="
189 # return [target_compile $source $dest $type $options]
193 # Compile jasmin (java assambly) source
195 proc jasmin-target-assemble { source dest type options } {
196 global srcdir
197 global subdir
198 # XXX Do it the simple way - should use target_compile
200 global JAVA
201 set java $JAVA
203 catch {exec $java jasmin.Main -d $srcdir/$subdir $source} comp_output
205 return comp_output;
206 # set options ""
207 # lappend options "compiler=javac"
208 # lappend options "additional_flags=-g"
209 # lappend options "libs="
210 # lappend options "ldflags="
211 # return [target_compile $source $dest $type $options]