source: trunk/src/gcc/libjava/testsuite/lib/libjava.exp@ 604

Last change on this file since 604 was 2, checked in by bird, 23 years ago

Initial revision

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