OSDN Git Service

2002-05-06 David.Billinghurst <David.Billinghurst@riotinto.com>
[pf3gnuchains/gcc-fork.git] / libjava / testsuite / lib / libjava.exp
1 # Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation
2
3 load_lib "libgloss.exp"
4
5 # GCJ_UNDER_TEST is the compiler under test.
6
7 global tmpdir
8
9 if ![info exists tmpdir] {
10     set tmpdir "/tmp"
11 }
12
13 # This is like `target_compile' but it does some surgery to work
14 # around stupid DejaGNU bugs.  In particular DejaGNU has very poor
15 # quoting, so for instance a `$' will be re-evaluated at spawn time.
16 # We don't want that.
17 proc libjava_tcompile {source destfile type options} {
18     # This strange-looking expression really does quote the `$'.
19     regsub -all -- {\$} $source {\$} source
20     regsub -all -- {\$} $destfile {\$} destfile
21     return [target_compile $source $destfile $type $options]
22 }
23
24 # Read an `xfail' file if it exists.  Returns a list of xfail tokens.
25 proc libjava_read_xfail {file} {
26     if {! [file exists $file]} {
27         return ""
28     }
29     set fd [open $file r]
30     set tokens [string trim [read $fd]]
31     close $fd
32     return $tokens
33 }
34
35 # Find a particular executable.  FIXME: this relies on DejaGnu
36 # internals.  These should probably be exposed in a better way.
37 proc libjava_find_program {prog} {
38     global tool_root_dir
39
40     set file [lookfor_file $tool_root_dir $prog]
41     if { $file == "" } {
42         set file [lookfor_file $tool_root_dir gcc/$prog];
43     }
44     if {$file == ""} {
45         set file $prog
46     }
47     return $file
48 }
49
50 # Find `jv-scan'.
51 proc find_jvscan {} {
52     return [libjava_find_program jv-scan]
53 }
54
55 # Find `gcjh'.
56 proc find_gcjh {} {
57     return [libjava_find_program gcjh]
58 }
59
60 proc find_javac {} {
61     global SUN_JAVAC GCJ_UNDER_TEST env
62     # If JDK doesn't run on your platform but some other
63     # JDK-compatible javac does, you may set SUN_JAVAC to point to it.
64     # One of the most important properties of a SUN_JAVAC is that it
65     # must create class-files even for classes that have not been
66     # specified in the command line, but that were needed to compile
67     # those that have.  For example, Pizza won't do it, but you can
68     # use `kaffe sun.tools.javac.Main', if you have Sun's classes.zip
69     # in the kaffe's default search path.
70     if {![info exists SUN_JAVAC]} {
71         if {[info exists env(SUN_JAVAC)]} {
72             set SUN_JAVAC $env(SUN_JAVAC)
73         } else {
74             set SUN_JAVAC "$GCJ_UNDER_TEST -C"
75         }
76     }
77     return $SUN_JAVAC
78 }
79
80 proc bytecompile_file { file objdir {classpath {}} } {
81     global env
82     set dirname [file dirname $file]
83
84     set javac [find_javac]
85     if {$classpath != ""} then {
86         set env(CLASSPATH) $classpath
87     }
88     set here [pwd]
89     cd $dirname
90     if {[catch {
91         set q [eval exec "$javac [list $file] -d $objdir 2>@ stdout"]
92     } msg]} then {
93         verbose "couldn't compile $file: $msg"
94         set r 0
95     } else {
96         set r 1
97     }
98     cd $here
99     return $r
100 }
101
102 set libjava_initialized 0
103
104 #
105 # Build the status wrapper library as needed.
106 #
107 proc libjava_init { args } {
108     global wrapper_file;
109     global wrap_compile_flags;
110     global libjava_initialized libjava_uses_threads
111     global GCJ_UNDER_TEST
112     global TOOL_EXECUTABLE
113     global original_ld_library_path
114     global env objdir
115     global env gcc_version
116
117     if { $libjava_initialized == 1 } { return; }
118
119     if ![info exists GCJ_UNDER_TEST] {
120         if [info exists TOOL_EXECUTABLE] {
121             set GCJ_UNDER_TEST $TOOL_EXECUTABLE;
122         } else {
123             if [info exists env(GCJ)] {
124                 set GCJ_UNDER_TEST $env(GCJ)
125             } else {
126                 set GCJ_UNDER_TEST "[find_gcj]"
127             }
128         }
129     }
130
131     # Determine the version so we can find the libgcj jar file.
132     set text [eval exec "$GCJ_UNDER_TEST --version 2>@ stdout"]
133     regexp -- "gcj \[^ \]+ (\[^ \]+) .*" $text ignore gcc_version
134     verbose "jar file is libgcj-$gcc_version.jar"
135
136     # FIXME: This finds libgcj.spec for the default multilib.
137     # If thread models differ between multilibs, this has to be moved
138     # to libjava_arguments
139     set specdir [libjava_find_spec]
140
141     # The -B is so we find libgcj.spec.
142     set text [eval exec "$GCJ_UNDER_TEST -B$specdir -v 2>@ stdout"]
143     regexp -- "Thread model: (\[^\n\]+)\n" $text ignore model
144     set libjava_uses_threads [expr {! ($model == "no"
145                                        || $model == "none"
146                                        || $model == "single")}]
147
148     # Always set encoding used by gcj.
149     append GCJ_UNDER_TEST " --encoding=UTF-8"
150
151     if [info exists env(LD_LIBRARY_PATH)] {
152         set original_ld_library_path $env(LD_LIBRARY_PATH)
153     } else {
154         if [info exists env(SHLIB_PATH)] {
155             set original_ld_library_path $env(SHLIB_PATH)
156         } else {
157             set original_ld_library_path ""
158         }
159     }
160
161     set wrapper_file "";
162     set wrap_compile_flags "";
163     if [target_info exists needs_status_wrapper] {
164         set result [build_wrapper "testglue.o"];
165         if { $result != "" } {
166             set wrapper_file [lindex $result 0];
167             set wrap_compile_flags [lindex $result 1];
168         } else {
169             warning "Status wrapper failed to build."
170         }
171     }
172
173     set libjava_initialized 1
174 }
175
176 # Find a library.  We know where libtool puts the actual libraries,
177 # and we look there.  The implementation is fairly hacky.  We can't
178 # compile with -nodefaultlibs, because that will also eliminate the
179 # system libraries we need.  In order to have gcj still work, it must
180 # find the appropriate libraries so we must add -L options for their
181 # paths.  However we can't simply use those libraries; we still need
182 # libtool for linking.
183 # Don't return the the lib${name}.la files here, since this causes the
184 # libraries to be linked twice: once as lib${name}.so and another time
185 # via gcj's implicit -l${name}.  This is both unnecessary and causes the
186 # Solaris ld to warn: attempted multiple inclusion of file.  This warning
187 # is not ignored by the dejagnu framework and cannot be disabled.
188 proc libjava_find_lib {dir name} {
189     global base_dir
190     set gp [get_multilibs]
191     foreach sub {.libs _libs} {
192         if {$gp != ""} {
193             if {[file exists $gp/$dir/$sub/lib${name}.a]} then {
194                 # Just return the `-L' option.  The library itself
195                 # will be picked up via the spec file.
196                 return "-L$gp/$dir/$sub"
197             }
198         }
199         # Just return the `-L' option.  The library itself will be
200         # picked up via the spec file.
201         set lib [findfile $base_dir/../../$dir/$sub/lib${name}.a \
202                    "-L$base_dir/../../$dir/$sub" \
203                    ""]
204         if {$lib != ""} {
205             return $lib
206         }
207     }
208     return ""
209 }
210
211 # Find libgcj.spec.  We need to use the file corresponding to the multilib
212 # under test since they might differ.  Append a trailing slash since this
213 # is used with -B.
214 proc libjava_find_spec {} {
215     global objdir
216     set gp [get_multilibs]
217
218     if {[file exists $gp/libjava/libgcj.spec]} then {
219         return "$gp/libjava/"
220     }
221     return "$objdir/../"
222 }
223
224 # Remove a bunch of files.
225 proc gcj_cleanup {args} {
226     foreach file $args {
227         if {[string match *.o $file]} {
228             verbose "removing [file rootname $file].lo"
229             file delete -force [file rootname $file].lo
230         }
231         file delete -force -- $file
232         verbose "removing $file"
233     }
234     # It is simplest to do this instead of trying to figure out what
235     # bits in .libs ought to be removed.
236     catch {system "rm -rf .libs"}
237 }
238
239 # Compute arguments needed for compiler.  MODE is a libtool mode:
240 # either compile or link.
241 proc libjava_arguments {{mode compile}} {
242     global base_dir
243     global LIBJAVA
244     global LIBGC
245     global LIBQTHREADS
246     global LIBZ
247     global srcdir subdir objdir
248     global TOOL_OPTIONS
249     global GCJ_UNDER_TEST
250     global tmpdir
251     global runtests
252     global env
253     global tool_root_dir
254     global gcc_version
255
256     if [info exists LIBJAVA] {
257         set libjava $LIBJAVA;
258     } else {
259         set libjava [libjava_find_lib libjava gcj]
260     }
261
262     if [info exists LIBGC] {
263         set libgc $LIBGC;
264     } else {
265         set libgc [libjava_find_lib boehm-gc gcjgc]
266     }
267
268     if [info exists LIBQTHREADS] {
269         set libqthreads $LIBQTHREADS
270     } else {
271         set libqthreads [libjava_find_lib qthreads gcjcoop]
272     }
273
274     if [info exists LIBZ] {
275         set libz $LIBZ
276     } else {
277         set libz [libjava_find_lib zlib zgcj]
278     }
279
280     # FIXME: there's no way to determine whether -lpthread is
281     # required.  We should get this info from configure, or it should
282     # just be in the compiler driver.
283
284     verbose "using LIBJAVA = $libjava" 2
285     verbose "using LIBGC = $libgc" 2
286     verbose "using LIBQTHREADS = $libqthreads" 2
287     verbose "using LIBZ = $libz" 2
288     set args ""
289
290     # Basically we want to build up a colon separated path list from
291     # the value of $libjava.
292
293     set lpath {}
294     foreach dir [list $libjava $libgc $libz] {
295         foreach item [split $dir " "] {
296             switch -glob -- $item {
297                 "-L*" {
298                     lappend lpath [string range $item 2 end]
299                 }
300             }
301         }
302     }
303
304     # Finally, add the gcc build directory so that we can find the
305     # shared libgcc.  This, like much of dejagnu, is hideous.
306     set gccdir [lookfor_file $tool_root_dir gcc/libgcc_s.so]
307     if {$gccdir != ""} {
308         lappend lpath [file dirname $gccdir]
309     }
310
311     set ld_library_path [join $lpath :]
312
313     # That's enough to make things work for the normal case.
314     # If we wanted to handle an arbitrary value of libjava,
315     # then we'd have to do a lot more work.
316
317     # Set variables the dynamic linker looks at.
318     global original_ld_library_path
319     setenv LD_LIBRARY_PATH "$ld_library_path:$original_ld_library_path"
320     setenv SHLIB_PATH "$ld_library_path:$original_ld_library_path"
321
322     verbose "LD_LIBRARY_PATH = $env(LD_LIBRARY_PATH)"
323
324     # Set the CLASSPATH environment variable
325     verbose "CLASSPATH is .:$srcdir/$subdir:$objdir:$objdir/../libgcj-$gcc_version.jar"
326     global env
327     set env(CLASSPATH) ".:$srcdir/$subdir:$objdir:$objdir/../libgcj-$gcc_version.jar"
328
329     if {$mode == "link"} {
330         global wrapper_file wrap_compile_flags;
331         lappend args "additional_flags=$wrap_compile_flags";
332         lappend args "libs=$wrapper_file";
333         lappend args "libs=$libjava";
334         lappend args "libs=$libgc";
335         lappend args "libs=$libqthreads"
336         lappend args "libs=$libz"
337         lappend args debug
338     }
339
340     if { [target_info needs_status_wrapper]!="" && [info exists gluefile] } {
341         lappend args "libs=${gluefile}"
342         lappend args "ldflags=$wrap_flags"
343     }
344
345     if [info exists TOOL_OPTIONS] {
346         lappend args "additional_flags=$TOOL_OPTIONS"
347     }
348
349     # Determine libgcj.spec corresponding to multilib under test.
350     set specdir [libjava_find_spec]
351
352     # Search for libtool.  We need it to link.
353     set found_compiler 0
354     set d [absolute $objdir]
355     foreach x {. .. ../.. ../../..} {
356         if {[file exists $d/$x/libtool]} then {
357             # We have to run silently to avoid DejaGNU lossage.
358             lappend args \
359               "compiler=$d/$x/libtool --silent --tag=GCJ --mode=$mode $GCJ_UNDER_TEST -B$specdir"
360             set found_compiler 1
361             break
362         }
363     }
364     if {! $found_compiler} {
365         # Append -B$specdir so that we find libgcj.spec before it
366         # is installed.
367         lappend args "compiler=$GCJ_UNDER_TEST -B$specdir"
368     }
369
370     # Avoid libtool wrapper scripts when possible.
371     if {$mode == "link"} {
372         lappend args "additional_flags=-no-install"
373     }
374
375     return $args
376 }
377
378 # Link a bunch of objects into a program.  MAIN is the name of the
379 # class holding `main'.  Return 0 on failure.
380 proc gcj_link {program main files {options {}}} {
381     set arguments [libjava_arguments link]
382     if {[llength $options]} {
383         eval lappend arguments $options
384     }
385     lappend arguments "additional_flags=--main=$main"
386     set x [prune_warnings [libjava_tcompile $files $program executable \
387                              $arguments]]
388     if {$x != ""} {
389         verbose "link failure: $x" 2
390         fail "linking $program"
391         setup_xfail "*-*-*"
392         fail "running $program"
393         return 0
394     }
395
396     pass "linking $program"
397     return 1
398 }
399
400 #
401 # Run the test specified by srcfile and resultfile. compile_args and
402 # exec_args are options telling this proc how to work.
403 #
404 proc test_libjava_from_source { options srcfile compile_args inpfile resultfile exec_args } {
405     global base_dir
406     global LIBJAVA
407     global LIBGC
408     global srcdir subdir objdir
409     global TOOL_OPTIONS
410     global GCJ_UNDER_TEST
411     global tmpdir
412     global runtests
413
414     # Make opts into an array.
415     set opts(_) x
416     unset opts(_)
417     foreach item $exec_args {
418         set opts($item) x
419     }
420
421     # If we need threads and we don't have them then set the `no-exec'
422     # flag.  This is case is also handled specially later.
423     if {[info exists opts(need-threads)]} {
424         global libjava_uses_threads
425         if {! $libjava_uses_threads} {
426             set opts(no-exec) x
427         }
428     }
429
430     set errname [file rootname [file tail $srcfile]]
431     if {! [runtest_file_p $runtests $errname]} {
432         return
433     }
434
435     if {[info exists opts(no-link)]} {
436         set mode compile
437     } else {
438         set mode link
439     }
440     set args [libjava_arguments $mode]
441     if {! [info exists opts(no-link)]} {
442         # Add the --main flag
443         lappend args "additional_flags=--main=[file rootname [file tail $srcfile]]"
444         if { $compile_args != "" } {
445             lappend args "additional_flags=$compile_args"
446         }
447     }
448
449     regsub "^.*/(\[^/.\]+)\[.\]\[^/]*$" "$srcfile" "\\1" out
450     set executable "${objdir}/$out"
451     if {[info exists opts(no-link)]} {
452         append executable ".o"
453         set target object
454     } else {
455         # DOS/win32 targets default to .exe if no suffix is given
456         # We then try to delete a file that doesn't exist.  It is
457         # simpler to add the suffix everywhere.
458         append executable ".exe"
459         set target executable
460     }
461     if { $compile_args != "" } {
462         set errname "$errname $compile_args"
463     }
464
465     set removeList [list $executable]
466
467     set x [prune_warnings \
468              [libjava_tcompile $srcfile "$executable" $target $args]]
469     if {[info exists opts(xfail-gcj)]} {
470         setup_xfail *-*-*
471     }
472     if { $x != "" } {
473         verbose "target_compile failed: $x" 2
474
475         if {[info exists opts(shouldfail)]} {
476             pass "$errname compilation from source"
477             eval gcj_cleanup $removeList
478             return
479         }
480
481         fail "$errname compilation from source"
482         if {[info exists opts(xfail-gcj)]
483             || ! [info exists opts(no-exec)]
484             || [info exists opts(need-threads)]} {
485             untested "$errname execution from source compiled test"
486             untested "$errname output from source compiled test"
487         }
488         return
489     }
490     if {[info exists opts(shouldfail)]} {
491         fail "$errname compilation from source"
492         return
493     }
494     pass "$errname compilation from source"
495
496     if {[info exists opts(no-exec)]} {
497         if {[info exists opts(need-threads)]} {
498             # This means we wanted to try to run it but we couldn't
499             # because threads aren't supported.  So we have to
500             # generate an `untested'.
501             untested "$errname execution from source compiled test"
502             untested "$errname output from source compiled test"
503         }
504         eval gcj_cleanup $removeList
505         return
506     }
507     if {[info exists opts(no-link)]} {
508         eval gcj_cleanup $removeList
509         return
510     }
511
512     set result [libjava_load $executable "" "$inpfile"];
513     set status [lindex $result 0];
514     set output [lindex $result 1];
515     if {[info exists opts(xfail-exec)]} then {
516         setup_xfail *-*-*
517     }
518     $status "$errname execution from source compiled test"
519     if { $status != "pass" } {
520         untested "$errname output from source compiled test"
521         return;
522     }
523
524     verbose "resultfile is $resultfile"
525     set id [open $resultfile r];
526     set expected ""
527     append expected [read $id];
528     regsub -all "\r" "$output" "" output;
529     regsub "\n*$" $expected "" expected
530     regsub "\n*$" $output "" output
531     regsub "^\n*" $expected "" expected
532     regsub "^\n*" $output "" output
533     regsub -all "\[ \t\]\[ \t\]*" $expected " " expected
534     regsub -all "\[ \t\]*\n\n*" $expected "\n" expected
535     regsub -all "\[ \t\]\[ \t\]*" $output " " output
536     regsub -all "\[ \t\]*\n\n*" $output "\n" output
537     verbose "expected is $expected"
538     verbose "actual is $output"
539     set passed 0;
540     if {$options == "regexp_match"} {
541         if [regexp $expected $output] {
542             set passed 1;
543         }
544     } else {
545         if { $expected == $output } {
546             set passed 1;
547         }
548     }
549     if {[info exists opts(xfail-output)]} {
550         setup_xfail *-*-*
551     }
552     if {[info exists opts(xfail-source-output)]} {
553         setup_xfail *-*-*
554     }
555     if { $passed == 1 } {
556         pass "$errname output from source compiled test"
557         eval gcj_cleanup $removeList
558     } else {
559         fail "$errname output from source compiled test"
560     }
561     close $id;
562 }
563
564 #
565 # Run the test specified by srcfile and resultfile. compile_args and
566 # exec_args are options telling this proc how to work.
567 #
568 proc test_libjava_from_javac { options srcfile compile_args inpfile resultfile exec_args } {
569     global base_dir
570     global LIBJAVA
571     global LIBGC
572     global srcdir subdir objdir
573     global TOOL_OPTIONS
574     global GCJ_UNDER_TEST
575     global tmpdir
576     global runtests
577
578     # Make opts into an array.
579     set opts(_) x
580     unset opts(_)
581     foreach item $exec_args {
582         set opts($item) x
583     }
584
585     # If we need threads and we don't have them then set the `no-exec'
586     # flag.  This is case is also handled specially later.
587     if {[info exists opts(need-threads)]} {
588         global libjava_uses_threads
589         if {! $libjava_uses_threads} {
590             set opts(no-exec) x
591         }
592     }
593     set errname [file rootname [file tail $srcfile]]
594     if {! [runtest_file_p $runtests $errname]} {
595         return
596     }
597
598     # bytecompile files with Sun's compiler for now.
599     set bc_ok [bytecompile_file $srcfile $objdir]
600
601     set javac [find_javac]
602     # This is an ugly heuristic but it will have to do.
603     if {[string match *gcj* $javac]} {
604         set tag gcjC
605     } else {
606         set tag javac
607     }
608     if {[info exists opts(xfail-$tag)]} {
609         setup_xfail *-*-*
610     }
611     if {! $bc_ok} then {
612         if {[info exists opts(shouldfail)]} {
613             pass "$errname byte compilation"
614             return
615         }
616         fail "$errname byte compilation"
617         untested "$errname compilation from bytecode"
618         if {! [info exists opts(no-exec)]
619             || [info exists opts(need-threads)]} {
620             untested "$errname execution from bytecode->native test"
621             untested "$errname output from bytecode->native test"
622         }
623         return
624     }
625     if {[info exists opts(shouldfail)]} {
626         fail "$errname byte compilation"
627         return
628     }
629     pass "$errname byte compilation"
630
631     set removeList {}
632
633     # Find name to use for --main, and name of all class files.
634     set jvscan [find_jvscan]
635     verbose "jvscan is $jvscan"
636     set main_name [string trim \
637                      [prune_warnings \
638                         [lindex [local_exec "$jvscan --encoding=UTF-8 $srcfile --print-main" "" "" 300] 1]]]
639     verbose "main name is $main_name"
640     set class_out [string trim \
641                      [prune_warnings \
642                         [lindex [local_exec "$jvscan --encoding=UTF-8 $srcfile --list-class" "" "" 300] 1]]]
643     verbose "class list is $class_out"
644
645     if {[string match "*parse error*" $main_name]
646         || [string match "*parse error*" $class_out]} {
647         untested "$errname compilation from bytecode"
648         if {! [info exists opts(no-exec)]
649             || [info exists opts(need-threads)]} {
650             untested "$errname execution from bytecode->native test"
651             untested "$errname output from bytecode->native test"
652         }
653         return
654     }
655
656     # Turn "a b" into "a.class b.class".
657     # Also, turn "foo.bar" into "foo/bar.class".
658     set class_files {}
659     foreach file [split [string trim $class_out]] {
660         set file [join [split $file .] /]
661         lappend class_files $objdir/$file.class
662     }
663
664     eval lappend removeList $class_files
665
666     # Usually it is an error for a test program not to have a `main'
667     # method.  However, for no-exec tests it is ok.  Treat no-link
668     # like no-exec here.
669     if {[info exists opts(no-link)]} {
670         set opts(no-exec) x
671     }
672     set largs {}
673
674     if {[info exists opts(no-exec)]} {
675         set type object
676         set mode compile
677     } elseif {$main_name == ""} {
678         perror "No `main' given in program $errname"
679         return
680     } else {
681         set type executable
682         lappend largs "additional_flags=--main=$main_name"
683         set executable "${objdir}/$main_name"
684         set mode link
685     }
686
687     # Initial arguments.
688     set args [libjava_arguments $mode]
689     eval lappend args $largs
690
691     if { $compile_args != "" } {
692         lappend args "additional_flags=$compile_args"
693     }
694
695     if { $compile_args != "" } {
696         set errname "$errname $compile_args"
697     }
698
699     verbose "compilation command = $args" 2
700     # When compiling and not linking, we have to build each .o
701     # separately.  We do this because DejaGNU's target_compile won't
702     # accept an empty "destfile" argument when the mode is "compile".
703     if {$mode == "compile"} {
704         foreach c_file $class_files {
705             set executable [file rootname [file tail $c_file]].o
706             set x [prune_warnings \
707                      [libjava_tcompile $c_file "$executable" $type $args]]
708             lappend removeList $executable
709             if {$x != ""} {
710                 break
711             }
712         }
713     } else {
714         # This is so evil: we de-listify CLASS_FILES so that we can
715         # turn around and quote the `$' in it for the shell.  I really
716         # hate DejaGNU.  It is so !@#$!@# unpredictable.
717         set hack ""
718         foreach stupid $class_files {
719             set hack "$hack $stupid"
720         }
721         lappend removeList $executable
722         set x [prune_warnings \
723                  [libjava_tcompile $hack "$executable" $type $args]]
724     }
725     if {[info exists opts(xfail-byte)]} {
726         setup_xfail *-*-*
727     }
728     if { $x != "" } {
729         verbose "target_compile failed: $x" 2
730         fail "$errname compilation from bytecode"
731         if {! [info exists opts(no-exec)]
732             || [info exists opts(need-threads)]} {
733             untested "$errname execution from bytecode->native test"
734             untested "$errname output from bytecode->native test"
735         }
736         return;
737     }
738     pass "$errname compilation from bytecode"
739
740     if {[info exists opts(no-exec)]} {
741         if {[info exists opts(need-threads)]} {
742             untested "$errname execution from bytecode->native test"
743             untested "$errname output from bytecode->native test"
744         }
745         eval gcj_cleanup $removeList
746         return
747     }
748
749     set result [libjava_load $executable "" "$inpfile"];
750     set status [lindex $result 0];
751     set output [lindex $result 1];
752     if {[info exists opts(xfail-exec)]} {
753         setup_xfail *-*-*
754     }
755     $status "$errname execution from bytecode->native test"
756     if { $status != "pass" } {
757         untested "$errname output from bytecode->native test"
758         return
759     }
760
761     verbose "resultfile is $resultfile"
762     set id [open $resultfile r];
763     set expected ""
764     append expected [read $id];
765     regsub -all "\r" "$output" "" output;
766     regsub "\n*$" $expected "" expected
767     regsub "\n*$" $output "" output
768     regsub "^\n*" $expected "" expected
769     regsub "^\n*" $output "" output
770     regsub -all "\[ \t\]\[ \t\]*" $expected " " expected
771     regsub -all "\[ \t\]*\n\n*" $expected "\n" expected
772     regsub -all "\[ \t\]\[ \t\]*" $output " " output
773     regsub -all "\[ \t\]*\n\n*" $output "\n" output
774     verbose "expected is $expected"
775     verbose "actual is $output"
776     set passed 0;
777     if {[info exists opts(xfail-output)]} {
778         setup_xfail *-*-*
779     }
780     if {[info exists opts(xfail-byte-output)]} {
781         setup_xfail *-*-*
782     }
783     if {$options == "regexp_match"} {
784         if [regexp $expected $output] {
785             set passed 1;
786         }
787     } else {
788         if { $expected == $output } {
789             set passed 1;
790         }
791     }
792     if { $passed == 1 } {
793         pass "$errname output from bytecode->native test"
794         eval gcj_cleanup $removeList
795     } else {
796         fail "$errname output from bytecode->native test"
797     }
798     close $id;
799 }
800
801 #
802 # Run the test specified by srcfile and resultfile. compile_args and
803 # exec_args are options telling this proc how to work.
804 #   `no-link'     don't try to link the program
805 #   `no-exec'     don't try to run the test
806 #   `xfail-gcj'   compilation from source will fail
807 #   `xfail-javac' compilation with javac will fail
808 #   `xfail-gcjC'  compilation with gcj -C will fail
809 #   `shouldfail'  compilation from source is supposed to fail
810 #                 This is different from xfail, which marks a known
811 #                 failure that we just havne't fixed.
812 #                 A compilation marked this way should fail with any
813 #                 front end.
814 #   `xfail-byte'  compilation from bytecode will fail
815 #   `xfail-exec'  exec will fail
816 #   `xfail-output'
817 #                 output will be wrong
818 #   `xfail-byte-output'
819 #                 output will be wrong when compiled from bytecode
820 #   `xfail-source-output'
821 #                 output will be wrong when compiled from source code
822 #   `need-threads'
823 #                 test relies on thread support
824 #
825 proc test_libjava { options srcfile compile_args inpfile resultfile exec_args } {
826     test_libjava_from_source $options $srcfile $compile_args $inpfile $resultfile $exec_args
827     test_libjava_from_javac $options $srcfile $compile_args $inpfile $resultfile $exec_args
828  }
829
830 #
831 # libjava_version -- extract and print the version number of libjavap
832 #
833 proc default_libjava_version {} {
834 }
835
836 proc default_libjava_start { } {
837 }
838
839 # On IRIX 6, we have to set variables akin to LD_LIBRARY_PATH, but
840 # called LD_LIBRARYN32_PATH (for the N32 ABI) and LD_LIBRARY64_PATH
841 # (for the 64-bit ABI).  The right way to do this would be to modify
842 # unix.exp -- but that's not an option since it's part of DejaGNU
843 # proper, so we do it here, by trickery.  We really only need to do 
844 # this on IRIX, but it shouldn't hurt to do it anywhere else.
845
846 proc ${tool}_set_ld_library_path { name element op } {
847   setenv LD_LIBRARYN32_PATH [getenv LD_LIBRARY_PATH]
848   setenv LD_LIBRARY64_PATH [getenv LD_LIBRARY_PATH]
849 }
850
851 trace variable env(LD_LIBRARY_PATH) w ${tool}_set_ld_library_path
852
853 # Local Variables:
854 # tcl-indent-level:4
855 # End: