OSDN Git Service

PR libgcj/27171:
[pf3gnuchains/gcc-fork.git] / libjava / testsuite / libjava.mauve / mauve.exp
index e98eeb8..03bbed9 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (C) 1998, 1999 Cygnus Solutions.
+# Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation.
 # Written by Tom Tromey <tromey@cygnus.com>.
 # Incorporate Mauve into libjava's DejaGNU test suite framework.
 
@@ -46,19 +46,52 @@ proc mauve_compute_uses {aName} {
     foreach file $ufiles {
       set file [file rootname $file].o
       lappend uses($item) $file
+      # Now add all inner classes
+      foreach inner [glob -nocomplain [file rootname $file]$*.class] {
+       # Prevent excessive escaping by replacing $ with a ^ in the .o name
+       set inner [file rootname $inner].o
+       regsub -all "\\$" $inner "\^" inner
+       lappend uses($item) $inner
+      }
     }
   }
 
   return [lsort [array names uses]]
 }
 
-# Run all the Mauve tests.
+# 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
+}
+
+# Find all the harness files and return a list of them, with no
+# suffix.
+proc mauve_find_harness_files {} {
+  set result {}
+  foreach file [glob -nocomplain -- *.class gnu/testlet/*.class] {
+    lappend result [file root $file]
+  }
+  return $result
+}
+
+# Run all the Mauve tests.  Return 1 on success, 0 on any failure.  If
+# the tests are skipped, that is treated like success.
 proc test_mauve {} {
   global srcdir objdir subdir env
 
-  if {! [info exists env(MAUVEDIR)]} then {
+  if {! [find_mauve_sources]} then {
     verbose "MAUVEDIR not set; not running Mauve tests"
-    return
+    return 1
   }
 
   # Run in subdir so we don't overwrite our own Makefile.
@@ -70,30 +103,33 @@ proc test_mauve {} {
   set full_srcdir [pwd]
   cd $here/mauve-build
 
-    global env
-    global GCJ_UNDER_TEST
-    global TOOL_EXECUTABLE
+  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]"
-           }
-       }
+  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]"
+      }
     }
+  }
 
-    # Append -B and -I so that libgcj.spec and libgcj.zip are found
-    # before they're installed.
-    set env(GCJ) "$GCJ_UNDER_TEST -B$objdir/../ -I$objdir/../libgcj.zip"
+  # Append -B and -I so that libgcj.spec and libgcj.jar are found
+  # before they're installed.
+  # Append -Wno-deprecated since Mauve tests lots of deprecated stuff.
+  set env(GCJ) "$GCJ_UNDER_TEST -Wno-deprecated -B$objdir/../ -I$libgcj_jar"
 
-  if {[catch {system "$env(MAUVEDIR)/configure --with-gcj"} msg]} then {
+  if {[catch {
+    system "$env(MAUVEDIR)/configure --with-gcj 2>&1"
+  } msg]} then {
     fail "Mauve configure"
     verbose "configure failed with $msg"
-    return
+    return 0
   }
   pass "Mauve configure"
 
@@ -105,17 +141,21 @@ proc test_mauve {} {
   puts -nonewline $fd $c
   close $fd
 
-  if {[catch {system "make KEYS=libgcj classes.stamp"} msg]} then {
+  catch {system "ln -s $full_srcdir/libjava.mauve/xfails xfails"}
+
+  if {[catch {
+    system "make KEYS=libgcj classes.stamp 2>&1"
+  } msg]} then {
     fail "Mauve build"
     verbose "build failed with $msg"
-    return
+    return 0
   }
   pass "Mauve build"
 
   set srcfile $full_srcdir/$subdir/DejaGNUTestHarness.java
   if {! [bytecompile_file $srcfile [pwd] $env(MAUVEDIR):[pwd]]} then {
     fail "Compile DejaGNUTestHarness.java"
-    return
+    return 0
   }
   pass "Compile DejaGNUTestHarness.java"
 
@@ -127,12 +167,20 @@ proc test_mauve {} {
   set link_args [concat [libjava_arguments link] \
                   [list "additional_flags=--main=DejaGNUTestHarness"]]
 
+  if {[string match "*libtool*" $compile_args]} {
+    set objext lo
+  } else {
+    set objext o
+  }
+
   set ok 1
   set objlist {}
-  foreach base {DejaGNUTestHarness gnu/testlet/SimpleTestHarness gnu/testlet/TestHarness gnu/testlet/Testlet gnu/testlet/ResourceNotFoundException gnu/testlet/config} {
+  foreach base [mauve_find_harness_files] {
     set file $base.class
-    set obj $base.o
-    if {[target_compile [pwd]/$file $obj object $compile_args] != ""} then {
+    set obj $base.$objext
+    set x [libjava_prune_warnings \
+            [target_compile [pwd]/$file $obj object $compile_args]]
+    if {$x != ""} then {
       fail "Compile $obj"
       set ok 0
     } else {
@@ -141,9 +189,10 @@ proc test_mauve {} {
     lappend objlist $obj
   }
   if {! $ok} then {
-    return
+    return 0
   }
 
+  set proc_ok 1
   set Executable DejaGNUTestHarness
   foreach file $choices {
     # Turn `java/lang/Foo.java' into `java.lang.Foo'.
@@ -151,12 +200,18 @@ proc test_mauve {} {
     regsub -all -- / $class . class
 
     set ok 1
+    set this_olist {}
     foreach obj $uses($file) {
+      set obj [file rootname $obj].$objext
+      lappend this_olist $obj
       if {! [file exists $obj]} then {
        verbose "compiling $obj for test of $class"
+       # The .class file does contain a $, but we can quote it between "'"s.
        set srcfile [file rootname $obj].class
-       if {[target_compile [pwd]/$srcfile $obj object $compile_args]
-           != ""} then {
+       regsub -all "\\^" $srcfile "\$" srcfile
+       set x [libjava_prune_warnings \
+                [libjava_tcompile '[pwd]/$srcfile' $obj object $compile_args]]
+       if {$x != ""} then {
          fail "Compile $obj for $class"
          set ok 0
          break
@@ -165,11 +220,15 @@ proc test_mauve {} {
       }
     }
     if {! $ok} then {
+      set proc_ok 0
       continue
     }
 
-    if {[target_compile [concat $uses($file) $objlist] \
-          $Executable executable $link_args] != ""} then {
+    set x [libjava_prune_warnings \
+            [libjava_tcompile [concat $this_olist $objlist] \
+               $Executable executable $link_args]]
+    if {$x != ""} then {
+      set proc_ok 0
       fail "Link for $class"
       continue
     }
@@ -178,40 +237,37 @@ proc test_mauve {} {
     set result [libjava_load [pwd]/DejaGNUTestHarness \
                  "$env(MAUVEDIR) $class" ""]
 
-    # Test for an exception thrown in the test harness itself.  This
-    # isn't enough to test for all faults in the test harness, but
-    # it's better than nothing.
-    set output [lindex $result 1];
-    if [regexp "Exception: " $output] then {
-      fail $output
-      continue
-    }
-
-    pass "Execute for $class"
-
     # Extract pass/failure info from output.
     foreach line [split [lindex $result 1] \n] {
-      if {[regexp -- {^(PASS|FAIL): (.*)$} $line ignore what msg]} then {
-       if {$what == "PASS"} then {
+      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 {
          pass $msg
        } else {
+         set proc_ok 0
          fail $msg
        }
       }
     }
   }
+
+  return $proc_ok
 }
 
 # 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
-# patching the source of the DejaGNUTestHarness.
+# patching the source of the DejaGNUTestHarness.  Return 1 on success,
+# 0 on any failure.  If the tests are skipped, that is treated like
+# success.
 proc test_mauve_sim {} {
   global srcdir subdir env
 
-  if {! [info exists env(MAUVEDIR)]} then {
+  if {! [find_mauve_sources]} then {
     verbose "MAUVEDIR not set; not running Mauve tests"
-    return
+    return 1
   }
 
   # Run in subdir so we don't overwrite our own Makefile.
@@ -223,10 +279,12 @@ proc test_mauve_sim {} {
   set full_srcdir [pwd]
   cd $here/mauve-build
 
-  if {[catch {system "$env(MAUVEDIR)/configure --with-gcj"} msg]} then {
+  if {[catch {
+    system "$env(MAUVEDIR)/configure --with-gcj 2>&1"
+  } msg]} then {
     fail "Mauve configure"
     verbose "configure failed with $msg"
-    return
+    return 0
   }
   pass "Mauve configure"
 
@@ -238,10 +296,14 @@ proc test_mauve_sim {} {
   puts -nonewline $fd $c
   close $fd
 
-  if {[catch {system "make KEYS=libgcj classes.stamp"} msg]} then {
+  catch {system "ln -s $full_srcdir/libjava.mauve/xfails xfails"}
+
+  if {[catch {
+    system "make KEYS=libgcj classes.stamp 2>&1"
+  } msg]} then {
     fail "Mauve build"
     verbose "build failed with $msg"
-    return
+    return 0
   }
   pass "Mauve build"
 
@@ -255,12 +317,12 @@ proc test_mauve_sim {} {
 
   set ok 1
   set objlist {}
-  foreach base {gnu/testlet/SimpleTestHarness gnu/testlet/TestHarness \
-                 gnu/testlet/Testlet gnu/testlet/ResourceNotFoundException \
-                 gnu/testlet/config} {
+  foreach base [mauve_find_harness_files] {
     set file $base.class
     set obj $base.o
-    if {[target_compile [pwd]/$file $obj object $compile_args] != ""} then {
+    set x [libjava_prune_warnings \
+            [target_compile [pwd]/$file $obj object $compile_args]]
+    if {$x != ""} then {
       fail "Compile $obj"
       set ok 0
     } else {
@@ -269,11 +331,10 @@ proc test_mauve_sim {} {
     lappend objlist $obj
   }
   if {! $ok} then {
-    return
+    return 0
   }
 
-  lappend objlist gnu/testlet/DejaGNUTestHarness.o
-
+  set proc_ok 1
   set Executable DejaGNUTestHarness
   foreach file $choices {
     # Turn `java/lang/Foo.java' into `java.lang.Foo'.
@@ -286,8 +347,9 @@ proc test_mauve_sim {} {
       if {! [file exists $obj]} then {
        verbose "compiling $obj for test of $class"
        set srcfile [file rootname $obj].class
-       if {[target_compile [pwd]/$srcfile $obj object $compile_args]
-           != ""} then {
+       set x [libjava_prune_warnings \
+                [target_compile [pwd]/$srcfile $obj object $compile_args]]
+       if {$x != ""} then {
          fail "Compile $obj for $class"
          set ok 0
          break
@@ -296,6 +358,7 @@ proc test_mauve_sim {} {
       }
     }
     if {! $ok} then {
+      set proc_ok 0
       continue
     }
 
@@ -317,18 +380,23 @@ proc test_mauve_sim {} {
     if {! [bytecompile_file [pwd]/gnu/testlet/$srcfile [pwd]/gnu/testlet \
               $env(MAUVEDIR):[pwd]]} then {
        fail "Compile DejaGNUTestHarness.java"
-       return
+       return 0
     }
 
-    if {[target_compile gnu/testlet/DejaGNUTestHarness.class \
-           gnu/testlet/DejaGNUTestHarness.o object $compile_args]
-      != ""} then {
+    set x [libjava_prune_warnings \
+            [target_compile DejaGNUTestHarness.class \
+               DejaGNUTestHarness.o object $compile_args]]
+    if {$x != ""} then {
        fail "Compile DejaGNUTestHarness.java"
+        set proc_ok 0
        continue
-      }
+    }
 
-    if {[target_compile [concat $uses($file) $objlist] \
-          $Executable executable $link_args] != ""} then {
+    set x [libjava_prune_warnings \
+            [target_compile [concat $uses($file) $objlist] \
+               $Executable executable $link_args]]
+    if {$x != ""} then {
+      set proc_ok 0
       fail "Link for $class"
       continue
     }
@@ -337,36 +405,42 @@ proc test_mauve_sim {} {
     set result [libjava_load [pwd]/DejaGNUTestHarness \
                  "$env(MAUVEDIR) $class" ""]
 
-    # Test for an exception thrown in the test harness itself.  This
-    # isn't enough to test for all faults in the test harness, but
-    # it's better than nothing.
-    set output [lindex $result 1];
-    if [regexp "Exception: " $output] then {
-      fail $output
-      continue
-    }
-
-    pass "Execute for $class"
-
     # Extract pass/failure info from output.
     foreach line [split [lindex $result 1] \n] {
-      if {[regexp -- {^(PASS|FAIL): (.*)$} $line ignore what msg]} then {
-       if {$what == "PASS"} then {
+      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 {
          pass $msg
        } else {
+         set proc_ok 0
          fail $msg
        }
       }
     }
   }
+
+  return $proc_ok
 }
 
-# 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] } {
-    test_mauve_sim
-} else {
-    test_mauve
+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"
+  }
 }
-cd $here
+
+gcj_run_mauve_tests