OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libjava/] [testsuite/] [lib/] [libjava.exp] - Blame information for rev 765

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.