libjava.exp (libjava_find_lib): Add dylib to the shared library extensions.
[official-gcc.git] / libjava / testsuite / lib / libjava.exp
blob421b3d25b6733528dd019711226cb27a0552e745
1 # Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation
3 proc load_gcc_lib { filename } {
4 global srcdir
5 load_file $srcdir/../../gcc/testsuite/lib/$filename
8 load_lib libgloss.exp
9 load_gcc_lib target-libpath.exp
11 # GCJ_UNDER_TEST is the compiler under test.
13 global tmpdir
15 if ![info exists tmpdir] {
16 set tmpdir "/tmp"
19 # This is like `prune_warnings', but it also prunes away a warning
20 # from the bytecode front end that we don't care about.
21 proc libjava_prune_warnings {text} {
22 set text [prune_warnings $text]
23 set tlist [split $text \n]
24 set len [llength $tlist]
25 for {set i [expr {$len - 1}]} {$i >= 2} {incr i -1} {
26 if {[string match "*unreachable bytecode*" [lindex $tlist $i]]} {
27 # Delete this line, all other unreachable warnings and the previous
28 # two lines containing the method and class.
29 set j [expr {$i - 1}]
30 while {[string match "*unreachable bytecode*" [lindex $tlist $j]]} {
31 incr j -1
33 incr j -1
34 set tlist [lreplace $tlist $j $i]
35 set i $j
38 return [join $tlist \n]
41 # This is like `target_compile' but it does some surgery to work
42 # around stupid DejaGNU bugs. In particular DejaGNU has very poor
43 # quoting, so for instance a `$' will be re-evaluated at spawn time.
44 # We don't want that.
45 proc libjava_tcompile {source destfile type options} {
46 # This strange-looking expression really does quote the `$'.
47 regsub -all -- {\$} $source {\$} source
48 regsub -all -- {\$} $destfile {\$} destfile
49 return [target_compile $source $destfile $type $options]
52 # Read an `xfail' file if it exists. Returns a list of xfail tokens.
53 proc libjava_read_xfail {file} {
54 if {! [file exists $file]} {
55 return ""
57 set fd [open $file r]
58 set tokens [string trim [read $fd]]
59 close $fd
60 return $tokens
63 # Find a particular executable. FIXME: this relies on DejaGnu
64 # internals. These should probably be exposed in a better way.
65 proc libjava_find_program {prog} {
66 global tool_root_dir
68 set file [lookfor_file $tool_root_dir $prog]
69 if { $file == "" } {
70 set file [lookfor_file $tool_root_dir gcc/$prog];
72 if {$file == ""} {
73 set file $prog
75 return $file
78 # Find `jv-scan'.
79 proc find_jvscan {} {
80 return [libjava_find_program jv-scan]
83 # Find `gcjh'.
84 proc find_gcjh {} {
85 return [libjava_find_program gcjh]
88 proc find_javac {} {
89 global SUN_JAVAC GCJ_UNDER_TEST env libgcj_jar
90 # If JDK doesn't run on your platform but some other
91 # JDK-compatible javac does, you may set SUN_JAVAC to point to it.
92 # One of the most important properties of a SUN_JAVAC is that it
93 # must create class-files even for classes that have not been
94 # specified in the command line, but that were needed to compile
95 # those that have. For example, Pizza won't do it, but you can
96 # use `kaffe sun.tools.javac.Main', if you have Sun's classes.zip
97 # in the kaffe's default search path.
98 if {![info exists SUN_JAVAC]} {
99 if {[info exists env(SUN_JAVAC)]} {
100 set SUN_JAVAC $env(SUN_JAVAC)
101 } else {
102 set SUN_JAVAC "$GCJ_UNDER_TEST -C -I$libgcj_jar"
105 return $SUN_JAVAC
108 proc bytecompile_file { file objdir {classpath {}} } {
109 global env
110 set dirname [file dirname $file]
112 set javac [find_javac]
113 if {$classpath != ""} then {
114 set env(CLASSPATH) $classpath
116 set here [pwd]
117 cd $dirname
118 send_log "byte compile: $javac -g [list $file] -d $objdir 2>@ stdout\n"
119 if {[catch {
120 set q [eval exec "$javac -g [list $file] -d $objdir 2>@ stdout"]
121 } msg]} then {
122 send_log "couldn't compile $file: $msg\n"
123 set r 0
124 } else {
125 set r 1
127 cd $here
128 return $r
131 set libjava_initialized 0
134 # Build the status wrapper library as needed.
136 proc libjava_init { args } {
137 global wrapper_file;
138 global wrap_compile_flags;
139 global libjava_initialized libjava_uses_threads
140 global GCJ_UNDER_TEST
141 global TOOL_EXECUTABLE
142 global env objdir
143 global env libgcj_jar
144 global tool_root_dir
145 global libjava_libgcc_s_path
146 global target_triplet
148 # We set LC_ALL and LANG to C so that we get the same error messages as expected.
149 setenv LC_ALL C
150 setenv LANG C
152 if { $libjava_initialized == 1 } { return; }
154 if ![info exists GCJ_UNDER_TEST] {
155 if [info exists TOOL_EXECUTABLE] {
156 set GCJ_UNDER_TEST $TOOL_EXECUTABLE;
157 } else {
158 if [info exists env(GCJ)] {
159 set GCJ_UNDER_TEST $env(GCJ)
160 } else {
161 set GCJ_UNDER_TEST "[find_gcj]"
166 # Find the libgcj jar file.
167 set libgcj_jar [glob $objdir/../libgcj-*.jar]
168 verbose "jar file is $libgcj_jar"
170 # FIXME: This finds libgcj.spec for the default multilib.
171 # If thread models differ between multilibs, this has to be moved
172 # to libjava_arguments
173 set specdir [libjava_find_spec]
175 # The -B is so we find libgcj.spec.
176 set text [eval exec "$GCJ_UNDER_TEST -B$specdir -v 2>@ stdout"]
177 regexp -- "Thread model: (\[^\n\]+)\n" $text ignore model
178 set libjava_uses_threads [expr {! ($model == "no"
179 || $model == "none"
180 || $model == "single")}]
182 # Always set encoding used by gcj.
183 append GCJ_UNDER_TEST " --encoding=UTF-8"
185 set wrapper_file "";
186 set wrap_compile_flags "";
187 if [target_info exists needs_status_wrapper] {
188 set result [build_wrapper "testglue.o"];
189 if { $result != "" } {
190 set wrapper_file [lindex $result 0];
191 set wrap_compile_flags [lindex $result 1];
192 } else {
193 warning "Status wrapper failed to build."
197 # Finally, add the gcc build directory so that we can find the
198 # shared libgcc. This, like much of dejagnu, is hideous.
199 set libjava_libgcc_s_path {}
201 if { [istarget "*-*-darwin*"] } {
202 set so_extension "dylib"
203 } else {
204 set so_extension "so"
206 set gccdir [lookfor_file $tool_root_dir gcc/libgcc_s.${so_extension}]
207 if {$gccdir != ""} {
208 set gccdir [file dirname $gccdir]
209 lappend libjava_libgcc_s_path $gccdir
210 verbose "libjava_libgcc_s_path = $libjava_libgcc_s_path"
211 set compiler ${gccdir}/xgcc
212 if { [is_remote host] == 0 && [which $compiler] != 0 } {
213 foreach i "[exec $compiler --print-multi-lib]" {
214 set mldir ""
215 regexp -- "\[a-z0-9=/\.-\]*;" $i mldir
216 set mldir [string trimright $mldir "\;@"]
217 if { "$mldir" == "." } {
218 continue
220 if { [llength [glob -nocomplain ${gccdir}/${mldir}/libgcc_s*.${so_extension}.*]] >= 1 } {
221 lappend libjava_libgcc_s_path "${gccdir}/${mldir}"
227 set libjava_initialized 1
230 # Find a library. We know where libtool puts the actual libraries,
231 # and we look there. The implementation is fairly hacky. We can't
232 # compile with -nodefaultlibs, because that will also eliminate the
233 # system libraries we need. In order to have gcj still work, it must
234 # find the appropriate libraries so we must add -L options for their
235 # paths. However we can't simply use those libraries; we still need
236 # libtool for linking.
237 # Don't return the the lib${name}.la files here, since this causes the
238 # libraries to be linked twice: once as lib${name}.so/dylib and another time
239 # via gcj's implicit -l${name}. This is both unnecessary and causes the
240 # Solaris ld to warn: attempted multiple inclusion of file. This warning
241 # is not ignored by the dejagnu framework and cannot be disabled.
242 proc libjava_find_lib {dir name} {
243 global base_dir
244 set gp [get_multilibs]
245 foreach extension {so dll dylib a} {
246 foreach sub {.libs _libs} {
247 if {$gp != ""} {
248 if {[file exists $gp/$dir/$sub/lib${name}.${extension}]} then {
249 # Just return the `-L' option. The library itself
250 # will be picked up via the spec file.
251 return "-L$gp/$dir/$sub"
254 # Just return the `-L' option. The library itself will be
255 # picked up via the spec file.
256 set lib [findfile \
257 $base_dir/../../$dir/$sub/lib${name}.${extension} \
258 "-L$base_dir/../../$dir/$sub" \
260 if {$lib != ""} {
261 return $lib
265 return ""
268 # Find libgcj.spec. We need to use the file corresponding to the multilib
269 # under test since they might differ. Append a trailing slash since this
270 # is used with -B.
271 proc libjava_find_spec {} {
272 global objdir
273 return "$objdir/../"
276 # Find `gij'. Return empty string if not found.
277 proc libjava_find_gij {} {
278 global base_dir objdir
280 set gijdir [lookfor_file [get_multilibs] libjava];
281 # Fall back if get_multilibs fails.
282 if {$gijdir == ""} {
283 set gijdir "$objdir/.."
285 if {! [file exists $gijdir/gij]} {
286 return ""
288 return $gijdir/gij
291 # Remove a bunch of files.
292 proc gcj_cleanup {args} {
293 foreach file $args {
294 if {[string match *.o $file]} {
295 verbose "removing [file rootname $file].lo"
296 file delete -force [file rootname $file].lo
298 file delete -force -- $file
299 verbose "removing $file"
301 # It is simplest to do this instead of trying to figure out what
302 # bits in .libs ought to be removed.
303 catch {system "rm -rf .libs"}
306 # Compute arguments needed for compiler. MODE is a libtool mode:
307 # either compile or link.
308 proc libjava_arguments {{mode compile}} {
309 global base_dir
310 global LIBJAVA
311 global srcdir subdir objdir
312 global TOOL_OPTIONS
313 global GCJ_UNDER_TEST
314 global tmpdir
315 global runtests
316 global env
317 global tool_root_dir
318 global libgcj_jar
319 global libjava_libgcc_s_path
320 global libjava_ld_library_path
321 global ld_library_path
322 global target_triplet
324 if [info exists LIBJAVA] {
325 set libjava $LIBJAVA;
326 } else {
327 set libjava [libjava_find_lib libjava gcj]
330 verbose "using LIBJAVA = $libjava" 2
331 set args ""
333 # Basically we want to build up a colon separated path list from
334 # the value of $libjava.
336 set lpath "."
337 foreach dir [list $libjava] {
338 foreach item [split $dir " "] {
339 switch -glob -- $item {
340 "-L*" {
341 lappend lpath [string range $item 2 end]
347 set lpath [concat $lpath $libjava_libgcc_s_path]
348 verbose "lpath = $lpath ; libgcc_s_path = $libjava_libgcc_s_path"
349 set ld_library_path [join $lpath :]
350 set libjava_ld_library_path "$ld_library_path"
352 # That's enough to make things work for the normal case.
353 # If we wanted to handle an arbitrary value of libjava,
354 # then we'd have to do a lot more work.
356 set_ld_library_path_env_vars
357 if [info exists env(LD_LIBRARY_PATH)] {
358 verbose "LD_LIBRARY_PATH = $env(LD_LIBRARY_PATH)"
361 # Determine CLASSPATH separator
362 if { [string match "i?86-pc-mingw32*" $target_triplet] } {
363 set sep ";"
364 } else {
365 set sep ":"
368 # Set the CLASSPATH environment variable
369 global env
370 set env(CLASSPATH) \
371 [join [list . $srcdir/$subdir $objdir $libgcj_jar] $sep]
372 verbose "CLASSPATH is $env(CLASSPATH)"
374 if {$mode == "link"} {
375 global wrapper_file wrap_compile_flags
376 lappend args "additional_flags=$wrap_compile_flags"
377 lappend args "libs=$wrapper_file"
378 lappend args "libs=$libjava"
379 lappend args debug
382 if { [target_info needs_status_wrapper]!="" && [info exists gluefile] } {
383 lappend args "libs=${gluefile}"
384 lappend args "ldflags=$wrap_flags"
387 if [info exists TOOL_OPTIONS] {
388 lappend args "additional_flags=$TOOL_OPTIONS"
391 # Determine libgcj.spec corresponding to multilib under test.
392 set specdir [libjava_find_spec]
394 # Search for libtool. We need it to link.
395 set found_compiler 0
396 set d [absolute $objdir]
397 foreach x {. .. ../.. ../../..} {
398 if {[file exists $d/$x/libtool]} then {
399 # We have to run silently to avoid DejaGNU lossage.
400 lappend args \
401 "compiler=$d/$x/libtool --silent --tag=GCJ --mode=$mode $GCJ_UNDER_TEST -B$specdir"
402 set found_compiler 1
403 break
406 if {! $found_compiler} {
407 # Append -B$specdir so that we find libgcj.spec before it
408 # is installed.
409 lappend args "compiler=$GCJ_UNDER_TEST -B$specdir"
412 # Avoid libtool wrapper scripts when possible.
413 # but not if libtool warnings results in FAILs
414 if {$mode == "link"} {
415 if {! [istarget "*-*-cygwin*"] && ! [istarget "*-*-mingw*"] } {
416 lappend args "additional_flags=-no-install"
418 if { [istarget "*-*-darwin*"] } {
419 lappend args "additional_flags=-bind_at_load"
420 lappend args "additional_flags=-multiply_defined suppress"
424 return $args
427 # Link a bunch of objects into a program. MAIN is the name of the
428 # class holding `main'. Return 0 on failure.
429 proc gcj_link {program main files {options {}}} {
430 set arguments [libjava_arguments link]
431 if {[llength $options]} {
432 eval lappend arguments $options
434 lappend arguments "additional_flags=--main=$main"
435 set x [libjava_prune_warnings \
436 [libjava_tcompile $files $program executable $arguments]]
437 if {$x != ""} {
438 verbose "link failure: $x" 2
439 fail "linking $program"
440 setup_xfail "*-*-*"
441 fail "running $program"
442 return 0
445 pass "linking $program"
446 return 1
449 # Invoke the program and see what happens. Return 0 on failure.
450 proc gcj_invoke {program expectFile ld_library_additions} {
451 global env
452 global libjava_ld_library_path
453 global ld_library_path
455 set ld_library_path "$libjava_ld_library_path"
456 if {[llength $ld_library_additions] > 0} {
457 append ld_library_path :[join $ld_library_additions :]
460 set_ld_library_path_env_vars
461 if [info exists env(LD_LIBRARY_PATH)] {
462 verbose "LD_LIBRARY_PATH=$env(LD_LIBRARY_PATH)"
465 set result [libjava_load ./$program]
466 set status [lindex $result 0]
467 set output [lindex $result 1]
469 # Restore setting
470 restore_ld_library_path_env_vars
472 if {$status != "pass"} {
473 verbose "got $output"
474 fail "$program run"
475 untested "$program output"
476 return 0
479 set id [open $expectFile r]
480 set expected [read $id]
481 close $id
483 if {! [string compare $output $expected]} {
484 pass "$program output"
485 return 1
486 } else {
487 fail "$program output"
488 return 0
492 # Invoke a program and check its output. EXECUTABLE is the program;
493 # ARGS are the arguments to the program. Returns 1 if tests passed
494 # (or things were left untested), 0 otherwise.
495 proc libjava_invoke {errname testName optName executable inpfile resultfile
496 ld_library_additions args} {
497 global env
498 global libjava_ld_library_path
499 global ld_library_path
501 set ld_library_path "$libjava_ld_library_path"
502 if {[llength $ld_library_additions] > 0} {
503 append ld_library_path :[join $ld_library_additions :]
506 set_ld_library_path_env_vars
507 if [info exists env(LD_LIBRARY_PATH)] {
508 verbose "LD_LIBRARY_PATH=$env(LD_LIBRARY_PATH)"
511 upvar $optName opts
513 if {[info exists opts(no-exec)]} {
514 if {[info exists opts(need-threads)]} {
515 # This means we wanted to try to run it but we couldn't
516 # because threads aren't supported. So we have to
517 # generate an `untested'.
518 untested "$errname execution - $testName"
519 untested "$errname output - $testName"
521 return 1
524 set result [libjava_load $executable $args "$inpfile"]
525 set status [lindex $result 0]
526 set output [lindex $result 1]
528 # Restore LD_LIBRARY_PATH setting.
529 restore_ld_library_path_env_vars
531 if {[info exists opts(xfail-exec)]} then {
532 setup_xfail *-*-*
534 $status "$errname execution - $testName"
535 if { $status != "pass" } {
536 untested "$errname output - $testName"
537 return 0
540 verbose "resultfile is $resultfile"
541 set id [open $resultfile r]
542 set expected ""
543 append expected [read $id]
544 regsub -all "\r" "$output" "" output
545 regsub "\n*$" $expected "" expected
546 regsub "\n*$" $output "" output
547 regsub "^\n*" $expected "" expected
548 regsub "^\n*" $output "" output
549 regsub -all "\[ \t\]\[ \t\]*" $expected " " expected
550 regsub -all "\[ \t\]*\n\n*" $expected "\n" expected
551 regsub -all "\[ \t\]\[ \t\]*" $output " " output
552 regsub -all "\[ \t\]*\n\n*" $output "\n" output
553 verbose "expected is $expected"
554 verbose "actual is $output"
555 set passed 0
556 if {[info exists opts(regexp_match)]} {
557 if [regexp $expected $output] {
558 set passed 1
560 } else {
561 if { $expected == $output } {
562 set passed 1
565 if {[info exists opts(xfail-output)]} {
566 setup_xfail *-*-*
568 if { $passed == 1 } {
569 pass "$errname output - $testName"
570 } else {
571 fail "$errname output - $testName"
573 close $id
575 return $passed
579 # Run the test specified by srcfile and resultfile. compile_args and
580 # exec_args are options telling this proc how to work.
582 proc test_libjava_from_source { options srcfile compile_args inpfile resultfile exec_args } {
583 global base_dir
584 global srcdir subdir objdir
585 global TOOL_OPTIONS
586 global GCJ_UNDER_TEST
587 global tmpdir
588 global runtests
590 # Make opts into an array.
591 set opts(_) x
592 unset opts(_)
593 foreach item $exec_args {
594 set opts($item) x
597 # If we need threads and we don't have them then set the `no-exec'
598 # flag. This is case is also handled specially later.
599 if {[info exists opts(need-threads)]} {
600 global libjava_uses_threads
601 if {! $libjava_uses_threads} {
602 set opts(no-exec) x
606 set errname [file rootname [file tail $srcfile]]
607 if {! [runtest_file_p $runtests $errname]} {
608 return
611 if {[info exists opts(no-link)]} {
612 set mode compile
613 } else {
614 set mode link
616 set args [libjava_arguments $mode]
617 if {! [info exists opts(no-link)]} {
618 # Add the --main flag
619 lappend args "additional_flags=--main=[file rootname [file tail $srcfile]]"
620 if { $compile_args != "" } {
621 lappend args "additional_flags=$compile_args"
625 regsub "^.*/(\[^/.\]+)\[.\]\[^/]*$" "$srcfile" "\\1" out
626 set executable "${objdir}/$out"
627 if {[info exists opts(no-link)]} {
628 append executable ".o"
629 set target object
630 } else {
631 # DOS/win32 targets default to .exe if no suffix is given
632 # We then try to delete a file that doesn't exist. It is
633 # simpler to add the suffix everywhere.
634 append executable ".exe"
635 set target executable
637 if { $compile_args != "" } {
638 set errname "$errname $compile_args"
641 set removeList [list $executable]
643 set x [libjava_prune_warnings \
644 [libjava_tcompile $srcfile "$executable" $target $args]]
645 if {[info exists opts(xfail-gcj)]} {
646 setup_xfail *-*-*
648 if { $x != "" } {
649 verbose "target_compile failed: $x" 2
651 if {[info exists opts(shouldfail)]} {
652 pass "$errname compilation from source"
653 eval gcj_cleanup $removeList
654 return
657 fail "$errname compilation from source"
658 if {[info exists opts(xfail-gcj)]
659 || ! [info exists opts(no-exec)]
660 || [info exists opts(need-threads)]} {
661 untested "$errname execution from source compiled test"
662 untested "$errname output from source compiled test"
664 return
666 if {[info exists opts(shouldfail)]} {
667 fail "$errname compilation from source"
668 return
670 pass "$errname compilation from source"
672 # Set up the options the way they are expected by libjava_invoke.
673 if {[info exists opts(xfail-source-output)]} {
674 set opts(xfail-output) x
676 if {[libjava_invoke $errname "source compiled test" opts $executable \
677 $inpfile $resultfile ""]} {
678 # Everything ok, so clean up.
679 eval gcj_cleanup $removeList
684 # Run the test specified by srcfile and resultfile. compile_args and
685 # exec_args are options telling this proc how to work.
687 proc test_libjava_from_javac { options srcfile compile_args inpfile resultfile exec_args } {
688 global base_dir
689 global srcdir subdir objdir
690 global TOOL_OPTIONS
691 global GCJ_UNDER_TEST
692 global tmpdir
693 global runtests
694 global INTERPRETER
696 # Make opts into an array.
697 set opts(_) x
698 unset opts(_)
699 foreach item $exec_args {
700 set opts($item) x
703 # If we need threads and we don't have them then set the `no-exec'
704 # flag. This is case is also handled specially later.
705 if {[info exists opts(need-threads)]} {
706 global libjava_uses_threads
707 if {! $libjava_uses_threads} {
708 set opts(no-exec) x
711 set errname [file rootname [file tail $srcfile]]
712 if {! [runtest_file_p $runtests $errname]} {
713 return
716 # bytecompile files with Sun's compiler for now.
717 set bc_ok [bytecompile_file $srcfile $objdir]
719 set javac [find_javac]
720 # This is an ugly heuristic but it will have to do.
721 if {[string match *gcj* $javac]} {
722 set tag gcjC
723 } else {
724 set tag javac
726 if {[info exists opts(xfail-$tag)]} {
727 setup_xfail *-*-*
729 if {! $bc_ok} then {
730 if {[info exists opts(shouldfail)]} {
731 pass "$errname byte compilation"
732 return
734 fail "$errname byte compilation"
735 untested "$errname compilation from bytecode"
736 if {! [info exists opts(no-exec)]
737 || [info exists opts(need-threads)]} {
738 untested "$errname execution from bytecode->native test"
739 untested "$errname output from bytecode->native test"
741 return
743 if {[info exists opts(shouldfail)]} {
744 fail "$errname byte compilation"
745 return
747 pass "$errname byte compilation"
749 set removeList {}
751 # Find name to use for --main, and name of all class files.
752 set jvscan [find_jvscan]
753 verbose "jvscan is $jvscan"
754 set main_name [string trim \
755 [libjava_prune_warnings \
756 [lindex [local_exec "$jvscan --encoding=UTF-8 $srcfile --print-main" "" "" 300] 1]]]
757 verbose "main name is $main_name"
758 set class_out [string trim \
759 [libjava_prune_warnings \
760 [lindex [local_exec "$jvscan --encoding=UTF-8 $srcfile --list-class" "" "" 300] 1]]]
761 verbose "class list is $class_out"
763 if {[string match "*parse error*" $main_name]
764 || [string match "*parse error*" $class_out]} {
765 untested "$errname compilation from bytecode"
766 if {! [info exists opts(no-exec)]
767 || [info exists opts(need-threads)]} {
768 untested "$errname execution from bytecode->native test"
769 untested "$errname output from bytecode->native test"
771 return
774 # Turn "a b" into "a.class b.class".
775 # Also, turn "foo.bar" into "foo/bar.class".
776 set class_files {}
777 foreach file [split [string trim $class_out]] {
778 set file [join [split $file .] /]
779 lappend class_files $objdir/$file.class
782 eval lappend removeList $class_files
784 # Usually it is an error for a test program not to have a `main'
785 # method. However, for no-exec tests it is ok. Treat no-link
786 # like no-exec here.
787 if {[info exists opts(no-link)]} {
788 set opts(no-exec) x
790 set largs {}
792 if {[info exists opts(no-exec)]} {
793 set type object
794 set mode compile
795 } elseif {$main_name == ""} {
796 perror "No `main' given in program $errname"
797 return
798 } else {
799 set type executable
800 lappend largs "additional_flags=--main=$main_name"
801 # DOS/win32 targets default to .exe if no suffix is given
802 # We then try to delete a file that doesn't exist. It is
803 # simpler to add the suffix everywhere.
804 set executable "${objdir}/${main_name}.exe"
805 set mode link
808 # We purposely ignore errors here; we still want to run the other
809 # appropriate tests.
810 set gij [libjava_find_gij]
811 # libjava_find_gij will return "" if it couldn't find the
812 # program; in this case we want to skip the test.
813 if {$INTERPRETER == "yes" && $gij != ""} {
814 libjava_invoke $errname "gij test" opts $gij \
815 $inpfile $resultfile "" $main_name
818 # Initial arguments.
819 set args [libjava_arguments $mode]
820 eval lappend args $largs
822 if { $compile_args != "" } {
823 lappend args "additional_flags=$compile_args"
826 if { $compile_args != "" } {
827 set errname "$errname $compile_args"
830 verbose "compilation command = $args" 2
831 # When compiling and not linking, we have to build each .o
832 # separately. We do this because DejaGNU's target_compile won't
833 # accept an empty "destfile" argument when the mode is "compile".
834 if {$mode == "compile"} {
835 foreach c_file $class_files {
836 set executable [file rootname [file tail $c_file]].o
837 # Don't write files which contain $ chars.
838 regsub -all "\\$" $executable "\^" executable
839 set x [libjava_prune_warnings \
840 [libjava_tcompile '$c_file' "$executable" $type $args]]
841 lappend removeList $executable
842 if {$x != ""} {
843 break
846 } else {
847 # This is so evil: we de-listify CLASS_FILES so that we can
848 # turn around and quote the `$' in it for the shell. I really
849 # hate DejaGNU. It is so !@#$!@# unpredictable.
850 set hack ""
851 foreach stupid $class_files {
852 set hack "$hack $stupid"
854 lappend removeList $executable
855 set x [libjava_prune_warnings \
856 [libjava_tcompile $hack "$executable" $type $args]]
858 if {[info exists opts(xfail-byte)]} {
859 setup_xfail *-*-*
861 if { $x != "" } {
862 verbose "target_compile failed: $x" 2
863 fail "$errname compilation from bytecode"
864 if {! [info exists opts(no-exec)]
865 || [info exists opts(need-threads)]} {
866 untested "$errname execution from bytecode->native test"
867 untested "$errname output from bytecode->native test"
869 return;
871 pass "$errname compilation from bytecode"
873 # Set up the options the way they are expected by libjava_invoke.
874 if {[info exists opts(xfail-byte-output)]} {
875 set opts(xfail-output) x
877 if {[libjava_invoke $errname "bytecode->native test" opts $executable \
878 $inpfile $resultfile ""]} {
879 # Everything ok, so clean up.
880 eval gcj_cleanup $removeList
885 # Run the test specified by srcfile and resultfile. compile_args and
886 # exec_args are options telling this proc how to work.
887 # `no-link' don't try to link the program
888 # `no-exec' don't try to run the test
889 # `xfail-gcj' compilation from source will fail
890 # `xfail-javac' compilation with javac will fail
891 # `xfail-gcjC' compilation with gcj -C will fail
892 # `shouldfail' compilation from source is supposed to fail
893 # This is different from xfail, which marks a known
894 # failure that we just haven't fixed.
895 # A compilation marked this way should fail with any
896 # front end.
897 # `xfail-byte' compilation from bytecode will fail
898 # `xfail-exec' exec will fail
899 # `xfail-output'
900 # output will be wrong
901 # `xfail-byte-output'
902 # output will be wrong when compiled from bytecode
903 # `xfail-source-output'
904 # output will be wrong when compiled from source code
905 # `need-threads'
906 # test relies on thread support
908 proc test_libjava { options srcfile compile_args inpfile resultfile exec_args } {
909 test_libjava_from_source $options $srcfile $compile_args $inpfile $resultfile $exec_args
910 test_libjava_from_javac $options $srcfile $compile_args $inpfile $resultfile $exec_args
914 # libjava_version -- extract and print the version number of libjavap
916 proc default_libjava_version {} {
919 proc default_libjava_start { } {
922 # Local Variables:
923 # tcl-indent-level:4
924 # End: