2003-01-13 01:22:20 +01:00
|
|
|
# Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation.
|
1999-04-07 16:42:40 +02:00
|
|
|
# Written by Tom Tromey <tromey@cygnus.com>.
|
|
|
|
# Incorporate Mauve into libjava's DejaGNU test suite framework.
|
|
|
|
|
|
|
|
# FIXME: should be able to compile from source as well as from .class.
|
|
|
|
|
|
|
|
|
|
|
|
# Compute list of files to compile. Returns list of all files
|
|
|
|
# representing classes that must be tested. Result parameter `uses'
|
|
|
|
# maps source file names onto list of objects required for link.
|
|
|
|
proc mauve_compute_uses {aName} {
|
|
|
|
upvar $aName uses
|
2000-01-03 21:18:19 +01:00
|
|
|
global env runtests
|
1999-04-07 16:42:40 +02:00
|
|
|
|
|
|
|
set fd [open classes r]
|
|
|
|
set line [read $fd]
|
|
|
|
close $fd
|
|
|
|
|
|
|
|
foreach item [split $line] {
|
|
|
|
if {$item == ""} then {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
set item [join [split $item .] /].java
|
|
|
|
|
2000-01-03 21:18:19 +01:00
|
|
|
# User might have specified "mauve.exp=something.java".
|
|
|
|
if {! [runtest_file_p $runtests $item]} {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
1999-04-07 16:42:40 +02:00
|
|
|
# Look for Uses line in source file.
|
|
|
|
set fd [open $env(MAUVEDIR)/$item r]
|
|
|
|
set ufiles [list $item]
|
|
|
|
set dir [file dirname $item]
|
|
|
|
while {[gets $fd sline] != -1} {
|
|
|
|
if {[regsub -- {^// Uses:} $sline {} sline]} then {
|
|
|
|
foreach uf [split $sline] {
|
|
|
|
if {$uf != ""} then {
|
|
|
|
lappend ufiles $dir/$uf
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
close $fd
|
|
|
|
|
|
|
|
set uses($item) {}
|
|
|
|
foreach file $ufiles {
|
|
|
|
set file [file rootname $file].o
|
|
|
|
lappend uses($item) $file
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return [lsort [array names uses]]
|
|
|
|
}
|
|
|
|
|
2002-11-01 20:32:21 +01:00
|
|
|
# Find Mauve sources. At end, env(MAUVEDIR) points to sources.
|
|
|
|
# Returns 0 if sources not found, 1 otherwise.
|
|
|
|
proc find_mauve_sources {} {
|
|
|
|
global env srcdir
|
|
|
|
|
|
|
|
if {[info exists env(MAUVEDIR)]} {
|
|
|
|
return 1
|
|
|
|
} elseif {[file isdirectory $srcdir/libjava.mauve/mauve]} {
|
|
|
|
set env(MAUVEDIR) $srcdir/libjava.mauve/mauve
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
2001-06-09 00:12:28 +02:00
|
|
|
# Run all the Mauve tests. Return 1 on success, 0 on any failure. If
|
|
|
|
# the tests are skipped, that is treated like success.
|
1999-04-07 16:42:40 +02:00
|
|
|
proc test_mauve {} {
|
1999-08-01 01:52:52 +02:00
|
|
|
global srcdir objdir subdir env
|
1999-04-07 16:42:40 +02:00
|
|
|
|
2002-11-01 20:32:21 +01:00
|
|
|
if {! [find_mauve_sources]} then {
|
1999-04-07 16:42:40 +02:00
|
|
|
verbose "MAUVEDIR not set; not running Mauve tests"
|
2001-06-09 00:12:28 +02:00
|
|
|
return 1
|
1999-04-07 16:42:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
# Run in subdir so we don't overwrite our own Makefile.
|
|
|
|
catch {system "rm -rf mauve-build"}
|
|
|
|
file mkdir mauve-build
|
|
|
|
# Some weirdness to set srcdir correctly.
|
|
|
|
set here [pwd]
|
|
|
|
cd $srcdir
|
|
|
|
set full_srcdir [pwd]
|
|
|
|
cd $here/mauve-build
|
|
|
|
|
2003-01-13 01:22:20 +01:00
|
|
|
global env libgcj_jar
|
|
|
|
global GCJ_UNDER_TEST
|
|
|
|
global TOOL_EXECUTABLE
|
|
|
|
|
|
|
|
if ![info exists GCJ_UNDER_TEST] {
|
|
|
|
if [info exists TOOL_EXECUTABLE] {
|
|
|
|
set GCJ_UNDER_TEST $TOOL_EXECUTABLE;
|
|
|
|
} else {
|
|
|
|
if [info exists env(GCJ)] {
|
|
|
|
set GCJ_UNDER_TEST env(GCJ)
|
|
|
|
} else {
|
|
|
|
set GCJ_UNDER_TEST "[find_gcj]"
|
|
|
|
}
|
1999-08-01 01:52:52 +02:00
|
|
|
}
|
2003-01-13 01:22:20 +01:00
|
|
|
}
|
1999-08-01 01:52:52 +02:00
|
|
|
|
2003-01-13 01:22:20 +01:00
|
|
|
# Append -B and -I so that libgcj.spec and libgcj.jar are found
|
|
|
|
# before they're installed.
|
|
|
|
set env(GCJ) "$GCJ_UNDER_TEST -B$objdir/../ -I$libgcj_jar"
|
1999-08-01 01:52:52 +02:00
|
|
|
|
2000-05-17 17:48:44 +02:00
|
|
|
if {[catch {
|
2002-03-26 21:51:19 +01:00
|
|
|
system "$env(MAUVEDIR)/configure --with-gcj 2>&1"
|
2000-05-17 17:48:44 +02:00
|
|
|
} msg]} then {
|
1999-04-07 16:42:40 +02:00
|
|
|
fail "Mauve configure"
|
|
|
|
verbose "configure failed with $msg"
|
2001-06-09 00:12:28 +02:00
|
|
|
return 0
|
1999-04-07 16:42:40 +02:00
|
|
|
}
|
|
|
|
pass "Mauve configure"
|
|
|
|
|
|
|
|
# Copy appropriate tags file locally.
|
|
|
|
set fd [open $full_srcdir/../mauve-libgcj r]
|
|
|
|
set c [read $fd]
|
|
|
|
close $fd
|
|
|
|
set fd [open mauve-libgcj w]
|
|
|
|
puts -nonewline $fd $c
|
|
|
|
close $fd
|
|
|
|
|
2001-02-08 13:04:57 +01:00
|
|
|
catch {system "ln -s $full_srcdir/libjava.mauve/xfails xfails"}
|
|
|
|
|
2000-05-17 17:48:44 +02:00
|
|
|
if {[catch {
|
|
|
|
system "make KEYS=libgcj classes.stamp 2>&1"
|
|
|
|
} msg]} then {
|
1999-04-07 16:42:40 +02:00
|
|
|
fail "Mauve build"
|
|
|
|
verbose "build failed with $msg"
|
2001-06-09 00:12:28 +02:00
|
|
|
return 0
|
1999-04-07 16:42:40 +02:00
|
|
|
}
|
|
|
|
pass "Mauve build"
|
|
|
|
|
|
|
|
set srcfile $full_srcdir/$subdir/DejaGNUTestHarness.java
|
|
|
|
if {! [bytecompile_file $srcfile [pwd] $env(MAUVEDIR):[pwd]]} then {
|
|
|
|
fail "Compile DejaGNUTestHarness.java"
|
2001-06-09 00:12:28 +02:00
|
|
|
return 0
|
1999-04-07 16:42:40 +02:00
|
|
|
}
|
|
|
|
pass "Compile DejaGNUTestHarness.java"
|
|
|
|
|
|
|
|
# Compute list of files to test, and also all files to build.
|
|
|
|
set choices [mauve_compute_uses uses]
|
|
|
|
|
|
|
|
# Compute flags to use to do the build.
|
|
|
|
set compile_args [libjava_arguments]
|
1999-05-03 14:48:34 +02:00
|
|
|
set link_args [concat [libjava_arguments link] \
|
1999-04-07 16:42:40 +02:00
|
|
|
[list "additional_flags=--main=DejaGNUTestHarness"]]
|
|
|
|
|
|
|
|
set ok 1
|
|
|
|
set objlist {}
|
|
|
|
foreach base {DejaGNUTestHarness gnu/testlet/SimpleTestHarness gnu/testlet/TestHarness gnu/testlet/Testlet gnu/testlet/ResourceNotFoundException gnu/testlet/config} {
|
|
|
|
set file $base.class
|
|
|
|
set obj $base.o
|
2002-12-13 06:00:15 +01:00
|
|
|
set x [libjava_prune_warnings \
|
2000-05-17 17:48:44 +02:00
|
|
|
[target_compile [pwd]/$file $obj object $compile_args]]
|
|
|
|
if {$x != ""} then {
|
1999-04-07 16:42:40 +02:00
|
|
|
fail "Compile $obj"
|
|
|
|
set ok 0
|
|
|
|
} else {
|
|
|
|
pass "Compile $obj"
|
|
|
|
}
|
|
|
|
lappend objlist $obj
|
|
|
|
}
|
|
|
|
if {! $ok} then {
|
2001-06-09 00:12:28 +02:00
|
|
|
return 0
|
1999-04-07 16:42:40 +02:00
|
|
|
}
|
|
|
|
|
2001-06-09 00:12:28 +02:00
|
|
|
set proc_ok 1
|
1999-04-07 16:42:40 +02:00
|
|
|
set Executable DejaGNUTestHarness
|
|
|
|
foreach file $choices {
|
|
|
|
# Turn `java/lang/Foo.java' into `java.lang.Foo'.
|
|
|
|
set class [file rootname $file]
|
|
|
|
regsub -all -- / $class . class
|
|
|
|
|
|
|
|
set ok 1
|
|
|
|
foreach obj $uses($file) {
|
|
|
|
if {! [file exists $obj]} then {
|
|
|
|
verbose "compiling $obj for test of $class"
|
|
|
|
set srcfile [file rootname $obj].class
|
2002-12-13 06:00:15 +01:00
|
|
|
set x [libjava_prune_warnings \
|
2000-05-17 17:48:44 +02:00
|
|
|
[target_compile [pwd]/$srcfile $obj object $compile_args]]
|
|
|
|
if {$x != ""} then {
|
1999-04-07 16:42:40 +02:00
|
|
|
fail "Compile $obj for $class"
|
|
|
|
set ok 0
|
|
|
|
break
|
|
|
|
}
|
|
|
|
pass "Compile $obj for $class"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if {! $ok} then {
|
2001-06-09 00:12:28 +02:00
|
|
|
set proc_ok 0
|
1999-04-07 16:42:40 +02:00
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
2002-12-13 06:00:15 +01:00
|
|
|
set x [libjava_prune_warnings \
|
|
|
|
[target_compile [concat $uses($file) $objlist] \
|
|
|
|
$Executable executable $link_args]]
|
2000-05-17 17:48:44 +02:00
|
|
|
if {$x != ""} then {
|
2001-06-09 00:12:28 +02:00
|
|
|
set proc_ok 0
|
1999-04-07 16:42:40 +02:00
|
|
|
fail "Link for $class"
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
pass "Link for $class"
|
|
|
|
|
|
|
|
set result [libjava_load [pwd]/DejaGNUTestHarness \
|
|
|
|
"$env(MAUVEDIR) $class" ""]
|
|
|
|
|
|
|
|
# Extract pass/failure info from output.
|
|
|
|
foreach line [split [lindex $result 1] \n] {
|
2001-02-08 13:04:57 +01:00
|
|
|
if {[regexp -- {^(PASS|FAIL|XFAIL|XPASS): (.*)$} $line ignore what msg]} then {
|
|
|
|
if {$what == "XFAIL" || $what == "XPASS"} then {
|
|
|
|
setup_xfail *-*-*
|
|
|
|
}
|
|
|
|
if {$what == "PASS" || $what == "XPASS"} then {
|
1999-04-07 16:42:40 +02:00
|
|
|
pass $msg
|
|
|
|
} else {
|
2001-06-09 00:12:28 +02:00
|
|
|
set proc_ok 0
|
1999-04-07 16:42:40 +02:00
|
|
|
fail $msg
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2001-06-09 00:12:28 +02:00
|
|
|
|
|
|
|
return $proc_ok
|
1999-04-07 16:42:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
# Run all the Mauve tests in a sim environment. In this case, the
|
|
|
|
# program cannot use argv[] because there's no way to pass in the
|
|
|
|
# command line, so tha name of the class to test is substituted by
|
2001-06-09 00:12:28 +02:00
|
|
|
# patching the source of the DejaGNUTestHarness. Return 1 on success,
|
|
|
|
# 0 on any failure. If the tests are skipped, that is treated like
|
|
|
|
# success.
|
1999-04-07 16:42:40 +02:00
|
|
|
proc test_mauve_sim {} {
|
|
|
|
global srcdir subdir env
|
|
|
|
|
2002-11-01 20:32:21 +01:00
|
|
|
if {! [find_mauve_sources]} then {
|
1999-04-07 16:42:40 +02:00
|
|
|
verbose "MAUVEDIR not set; not running Mauve tests"
|
2001-06-09 00:12:28 +02:00
|
|
|
return 1
|
1999-04-07 16:42:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
# Run in subdir so we don't overwrite our own Makefile.
|
|
|
|
catch {system "rm -rf mauve-build"}
|
|
|
|
file mkdir mauve-build
|
|
|
|
# Some weirdness to set srcdir correctly.
|
|
|
|
set here [pwd]
|
|
|
|
cd $srcdir
|
|
|
|
set full_srcdir [pwd]
|
|
|
|
cd $here/mauve-build
|
|
|
|
|
2000-05-17 17:48:44 +02:00
|
|
|
if {[catch {
|
|
|
|
system "$env(MAUVEDIR)/configure --with-gcj 2>&1"
|
|
|
|
} msg]} then {
|
1999-04-07 16:42:40 +02:00
|
|
|
fail "Mauve configure"
|
|
|
|
verbose "configure failed with $msg"
|
2001-06-09 00:12:28 +02:00
|
|
|
return 0
|
1999-04-07 16:42:40 +02:00
|
|
|
}
|
|
|
|
pass "Mauve configure"
|
|
|
|
|
|
|
|
# Copy appropriate tags file locally.
|
|
|
|
set fd [open $full_srcdir/../mauve-libgcj r]
|
|
|
|
set c [read $fd]
|
|
|
|
close $fd
|
|
|
|
set fd [open mauve-libgcj w]
|
|
|
|
puts -nonewline $fd $c
|
|
|
|
close $fd
|
|
|
|
|
2001-02-08 13:04:57 +01:00
|
|
|
catch {system "ln -s $full_srcdir/libjava.mauve/xfails xfails"}
|
|
|
|
|
2000-05-17 17:48:44 +02:00
|
|
|
if {[catch {
|
|
|
|
system "make KEYS=libgcj classes.stamp 2>&1"
|
|
|
|
} msg]} then {
|
1999-04-07 16:42:40 +02:00
|
|
|
fail "Mauve build"
|
|
|
|
verbose "build failed with $msg"
|
2001-06-09 00:12:28 +02:00
|
|
|
return 0
|
1999-04-07 16:42:40 +02:00
|
|
|
}
|
|
|
|
pass "Mauve build"
|
|
|
|
|
|
|
|
# Compute list of files to test, and also all files to build.
|
|
|
|
set choices [mauve_compute_uses uses]
|
|
|
|
|
|
|
|
# Compute flags to use to do the build.
|
|
|
|
set compile_args [libjava_arguments]
|
1999-05-03 14:48:34 +02:00
|
|
|
set link_args [concat [libjava_arguments link] \
|
1999-04-07 16:42:40 +02:00
|
|
|
[list "additional_flags=--main=DejaGNUTestHarness"]]
|
|
|
|
|
|
|
|
set ok 1
|
|
|
|
set objlist {}
|
|
|
|
foreach base {gnu/testlet/SimpleTestHarness gnu/testlet/TestHarness \
|
|
|
|
gnu/testlet/Testlet gnu/testlet/ResourceNotFoundException \
|
|
|
|
gnu/testlet/config} {
|
|
|
|
set file $base.class
|
|
|
|
set obj $base.o
|
2002-12-13 06:00:15 +01:00
|
|
|
set x [libjava_prune_warnings \
|
2000-05-17 17:48:44 +02:00
|
|
|
[target_compile [pwd]/$file $obj object $compile_args]]
|
|
|
|
if {$x != ""} then {
|
1999-04-07 16:42:40 +02:00
|
|
|
fail "Compile $obj"
|
|
|
|
set ok 0
|
|
|
|
} else {
|
|
|
|
pass "Compile $obj"
|
|
|
|
}
|
|
|
|
lappend objlist $obj
|
|
|
|
}
|
|
|
|
if {! $ok} then {
|
2001-06-09 00:12:28 +02:00
|
|
|
return 0
|
1999-04-07 16:42:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
lappend objlist gnu/testlet/DejaGNUTestHarness.o
|
|
|
|
|
2001-06-09 00:12:28 +02:00
|
|
|
set proc_ok 1
|
1999-04-07 16:42:40 +02:00
|
|
|
set Executable DejaGNUTestHarness
|
|
|
|
foreach file $choices {
|
|
|
|
# Turn `java/lang/Foo.java' into `java.lang.Foo'.
|
|
|
|
|
|
|
|
set class [file rootname $file]
|
|
|
|
regsub -all -- / $class . class
|
|
|
|
|
|
|
|
set ok 1
|
|
|
|
foreach obj $uses($file) {
|
|
|
|
if {! [file exists $obj]} then {
|
|
|
|
verbose "compiling $obj for test of $class"
|
|
|
|
set srcfile [file rootname $obj].class
|
2002-12-13 06:00:15 +01:00
|
|
|
set x [libjava_prune_warnings \
|
2000-05-17 17:48:44 +02:00
|
|
|
[target_compile [pwd]/$srcfile $obj object $compile_args]]
|
|
|
|
if {$x != ""} then {
|
1999-04-07 16:42:40 +02:00
|
|
|
fail "Compile $obj for $class"
|
|
|
|
set ok 0
|
|
|
|
break
|
|
|
|
}
|
|
|
|
pass "Compile $obj for $class"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if {! $ok} then {
|
2001-06-09 00:12:28 +02:00
|
|
|
set proc_ok 0
|
1999-04-07 16:42:40 +02:00
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
|
|
|
set infile $full_srcdir/$subdir/DejaGNUTestHarness.java
|
|
|
|
set srcfile DejaGNUTestHarness.java
|
|
|
|
set f [open $infile r]
|
|
|
|
set d [open gnu/testlet/$srcfile w]
|
|
|
|
while {[gets $f line] >= 0} {
|
|
|
|
if [regexp {harness\.runtest \(args\[1\]\)} $line] then {
|
|
|
|
regsub {args\[1\]} $line "\"$class\"" out
|
|
|
|
} else {
|
|
|
|
set out $line
|
|
|
|
}
|
|
|
|
puts $d $out
|
|
|
|
}
|
|
|
|
close $f
|
|
|
|
close $d
|
|
|
|
|
|
|
|
if {! [bytecompile_file [pwd]/gnu/testlet/$srcfile [pwd]/gnu/testlet \
|
|
|
|
$env(MAUVEDIR):[pwd]]} then {
|
|
|
|
fail "Compile DejaGNUTestHarness.java"
|
2001-06-09 00:12:28 +02:00
|
|
|
return 0
|
1999-04-07 16:42:40 +02:00
|
|
|
}
|
|
|
|
|
2002-12-13 06:00:15 +01:00
|
|
|
set x [libjava_prune_warnings \
|
2000-05-17 17:48:44 +02:00
|
|
|
[target_compile gnu/testlet/DejaGNUTestHarness.class \
|
|
|
|
gnu/testlet/DejaGNUTestHarness.o object $compile_args]]
|
|
|
|
if {$x != ""} then {
|
1999-04-07 16:42:40 +02:00
|
|
|
fail "Compile DejaGNUTestHarness.java"
|
2001-06-09 00:12:28 +02:00
|
|
|
set proc_ok 0
|
1999-04-07 16:42:40 +02:00
|
|
|
continue
|
2001-06-09 00:12:28 +02:00
|
|
|
}
|
1999-04-07 16:42:40 +02:00
|
|
|
|
2002-12-13 06:00:15 +01:00
|
|
|
set x [libjava_prune_warnings \
|
|
|
|
[target_compile [concat $uses($file) $objlist] \
|
|
|
|
$Executable executable $link_args]]
|
2000-05-17 17:48:44 +02:00
|
|
|
if {$x != ""} then {
|
2001-06-09 00:12:28 +02:00
|
|
|
set proc_ok 0
|
1999-04-07 16:42:40 +02:00
|
|
|
fail "Link for $class"
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
pass "Link for $class"
|
|
|
|
|
|
|
|
set result [libjava_load [pwd]/DejaGNUTestHarness \
|
|
|
|
"$env(MAUVEDIR) $class" ""]
|
|
|
|
|
|
|
|
# Extract pass/failure info from output.
|
|
|
|
foreach line [split [lindex $result 1] \n] {
|
2001-02-08 13:04:57 +01:00
|
|
|
if {[regexp -- {^(PASS|FAIL|XFAIL|XPASS): (.*)$} $line ignore what msg]} then {
|
|
|
|
if {$what == "XFAIL" || $what == "XPASS"} then {
|
|
|
|
setup_xfail *-*-*
|
|
|
|
}
|
|
|
|
if {$what == "PASS" || $what == "XPASS"} then {
|
1999-04-07 16:42:40 +02:00
|
|
|
pass $msg
|
|
|
|
} else {
|
2001-06-09 00:12:28 +02:00
|
|
|
set proc_ok 0
|
1999-04-07 16:42:40 +02:00
|
|
|
fail $msg
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2001-06-09 00:12:28 +02:00
|
|
|
|
|
|
|
return $proc_ok
|
1999-04-07 16:42:40 +02:00
|
|
|
}
|
|
|
|
|
2001-06-09 00:12:28 +02:00
|
|
|
proc gcj_run_mauve_tests {} {
|
|
|
|
# The test_mauve* procs will change the current directory. It's
|
|
|
|
# simpler to fix this up here than to keep track of this in the
|
|
|
|
# procs.
|
|
|
|
set here [pwd]
|
|
|
|
if { [board_info target exists is_simulator] } {
|
|
|
|
set r [test_mauve_sim]
|
|
|
|
} else {
|
|
|
|
set r [test_mauve]
|
|
|
|
}
|
|
|
|
cd $here
|
|
|
|
|
|
|
|
if {$r} {
|
|
|
|
# No need to keep the build around. FIXME: this knows how the
|
|
|
|
# tests work. This whole file could use a rewrite.
|
|
|
|
system "rm -rf mauve-build"
|
|
|
|
}
|
1999-04-07 16:42:40 +02:00
|
|
|
}
|
2001-06-09 00:12:28 +02:00
|
|
|
|
|
|
|
gcj_run_mauve_tests
|