This is the mail archive of the java-patches@sourceware.cygnus.com mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Patch: no-link support for test suite


I'm committing the appended patch.  It adds a `no-link' option to the
test suite code so that particular tests can be compiled and not
linked.  Some of the newly added tests require this.

This patch also fixes a bug that could occur when the classes in a
file were actually in a package other than the default.

1999-07-14  Tom Tromey  <tromey@cygnus.com>

	* libjava.compile/G19990217_02.no-link: New file.
	* libjava.compile/test.exp: Look for `.no-link' file.
	* lib/libjava.exp (test_libjava_from_source): Added `no-link'
	option.
	(test_libjava_from_javac): Likewise.  Also, handle package
	information from class name when creating class file name.

Tom

Index: lib/libjava.exp
===================================================================
RCS file: /cvs/java/libgcj/libjava/testsuite/lib/libjava.exp,v
retrieving revision 1.9
diff -u -r1.9 libjava.exp
--- libjava.exp	1999/07/06 15:38:06	1.9
+++ libjava.exp	1999/07/15 16:04:21
@@ -233,6 +233,7 @@
 #
 # Run the test specified by srcfile and resultfile. compile_args and
 # exec_args are options telling this proc how to work.
+#   `no-link'     don't try to link the program
 #   `no-exec'     don't try to run the test
 #   `xfail-gcj'   compilation from source will fail
 #   `xfail-javac' compilation with javac will fail
@@ -264,20 +265,33 @@
         return
     }
 
-    set args [libjava_arguments link]
-    # Add the --main flag
-    lappend args "additional_flags=--main=[file rootname [file tail $srcfile]]"
-    if { $compile_args != "" } {
-	lappend args "additional_flags=$compile_args"
+    if {[info exists opts(no-link)]} {
+	set mode compile
+    } else {
+	set mode link
+    }
+    set args [libjava_arguments $mode]
+    if {! [info exists opts(no-link)]} {
+	# Add the --main flag
+	lappend args "additional_flags=--main=[file rootname [file tail $srcfile]]"
+	if { $compile_args != "" } {
+	    lappend args "additional_flags=$compile_args"
+	}
     }
 
     regsub "^.*/(\[^/.\]+)\[.\]\[^/]*$" "$srcfile" "\\1" out
     set executable "${objdir}/$out"
+    if {[info exists opts(no-link)]} {
+	append executable ".o"
+	set target object
+    } else {
+	set target executable
+    }
     if { $compile_args != "" } {
 	set errname "$errname $compile_args"
     }
 
-    set x [target_compile $srcfile "$executable" executable $args]
+    set x [target_compile $srcfile "$executable" $target $args]
     if {[info exists opts(xfail-gcj)]} {
 	setup_xfail *-*-*
     }
@@ -294,7 +308,8 @@
     }
     pass "$errname compilation from source"
 
-    if {[info exists opts(no-exec)]} {
+    if {[info exists opts(no-exec)]
+	|| [info exists opts(no-link)]} {
 	return
     }
 
@@ -352,6 +367,7 @@
 #
 # Run the test specified by srcfile and resultfile. compile_args and
 # exec_args are options telling this proc how to work.
+#   `no-link'     don't try to link the program
 #   `no-exec' don't try to run the test
 #   `xfail-gcj'   compilation from source will fail
 #   `xfail-javac' compilation with javac will fail
@@ -422,14 +438,20 @@
 	  [list $objdir/[file rootname [file tail $srcfile]].class]
     } else {
 	# Turn "a b" into "a.class b.class".
+	# Also, turn "foo.bar" into "foo/bar.class".
 	set class_files {}
         foreach file [split [string trim $class_out]] {
+	    set file [join [split $file .] /]
 	    lappend class_files $objdir/$file.class
 	}
     }
 
     # Usually it is an error for a test program not to have a `main'
-    # method.  However, for no-exec tests it is ok.
+    # method.  However, for no-exec tests it is ok.  Treat no-link
+    # like no-exec here.
+    if {[info exists opts(no-link)]} {
+	set opts(no-exec) x
+    }
     set largs {}
     if {$main_name == ""} {
 	if {! [info exists opts(no-exec)]} {
@@ -437,7 +459,6 @@
 	    return
 	} else {
 	    set type object
-	    set executable [file rootname [file tail $srcfile]].o
 	    set mode compile
 	}
     } else {
@@ -460,7 +481,20 @@
     }
 
     verbose "compilation command = $args" 2
-    set x [target_compile $class_files "$executable" $type $args]
+    # When compiling and not linking, we have to build each .o
+    # separately.  We do this because DejaGNU's target_compile won't
+    # accept an empty "destfile" argument when the mode is "compile".
+    if {$mode == "compile"} {
+	foreach c_file $class_files {
+	    set executable [file rootname [file tail $c_file]].o
+	    set x [target_compile $c_file "$executable" $type $args]
+	    if {$x != ""} {
+		break
+	    }
+	}
+    } else {
+	set x [target_compile $class_files "$executable" $type $args]
+    }
     if {[info exists opts(xfail-byte)]} {
 	setup_xfail *-*-*
     }
@@ -535,6 +569,7 @@
 #
 # Run the test specified by srcfile and resultfile. compile_args and
 # exec_args are options telling this proc how to work.
+#   `no-link'     don't try to link the program
 #   `no-exec' don't try to run the test
 #   `xfail-gcj'   compilation from source will fail
 #   `xfail-javac' compilation with javac will fail
Index: libjava.compile/G19990217_02.no-link
===================================================================
RCS file: G19990217_02.no-link
diff -N G19990217_02.no-link
--- /dev/null	Sat Dec  5 20:30:03 1998
+++ G19990217_02.no-link	Thu Jul 15 09:04:21 1999
@@ -0,0 +1 @@
+Don't link me
Index: libjava.compile/test.exp
===================================================================
RCS file: /cvs/java/libgcj/libjava/testsuite/libjava.compile/test.exp,v
retrieving revision 1.2
diff -u -r1.2 test.exp
--- test.exp	1999/07/06 15:38:07	1.2
+++ test.exp	1999/07/15 16:04:21
@@ -6,6 +6,9 @@
 set prefix ""
 foreach x $srcfiles {
     set args [libjava_read_xfail [file rootname $x].xfail]
+    if {[file exists [file rootname $x].no-link]} {
+	lappend args no-link
+    }
     lappend args no-exec
 
     test_libjava $options "$x" "" "" "" $args

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]