diff options
author | Brian Jones <cbj@gnu.org> | 1998-06-20 22:59:00 +0000 |
---|---|---|
committer | Brian Jones <cbj@gnu.org> | 1998-06-20 22:59:00 +0000 |
commit | 71541b3b44f86dc742c586865dab87b43d9144d5 (patch) | |
tree | 38df02e459d7b04089c604ea324706ec0f452dea | |
parent | 6a189385beb466e65cc1c0afd8704bfd41787fe1 (diff) | |
download | classpath-71541b3b44f86dc742c586865dab87b43d9144d5.tar.gz |
initial checkin
-rw-r--r-- | testsuite/lib/java.exp | 212 |
1 files changed, 212 insertions, 0 deletions
diff --git a/testsuite/lib/java.exp b/testsuite/lib/java.exp new file mode 100644 index 000000000..e12272675 --- /dev/null +++ b/testsuite/lib/java.exp @@ -0,0 +1,212 @@ +# +# Author: Petter Reinholdtsen <pere@td.org.uit.no> +# +# Java regression tester for DejaGNU +# + +load_lib target.exp + +# +# Compile and run all available java source +# +proc test-java-source { } { + global srcdir + global subdir + global runtests + + # Find all Java-files + foreach src [lsort [glob -nocomplain $srcdir/$subdir/*.java]] { + # If we're only testing specific files and this isn't one of them, + # skip it. + if ![runtest_file_p $runtests $src] then { + continue + } + + java-compile-execute $src + } + + # Find all jasmin (java assambler) files + foreach src [lsort [glob -nocomplain $srcdir/$subdir/*.j]] { + # If we're only testing specific files and this isn't one of them, + # skip it. + if ![runtest_file_p $runtests $src] then { + continue + } + + jasmin-assemble-execute $src + } +} + +# +# Compile #args +# +proc java-compile { args } { + set src $args + set output "" + set options "" + set comp_output [javac-target-compile "$src" "$output" executable $options]; +} + +# +# Assemble #args +# +proc jasmin-assemble { args } { + set src $args + set output "" + set options "" + set comp_output [jasmin-target-assemble "$src" "$output" executable $options]; +} + +# +# Compile $args and execute java class runtime_test +# +proc java-compile-execute { args } { + global srcdir + global subdir + + set comp_output [java-compile $args] + if ![regexp "^$" $comp_output] { + # Do not care about kaffes stupid messages + #fail $args + #print "$comp_output" + #return + } + + global JAVA + set java $JAVA + + set classpath [getenv CLASSPATH] + setenv CLASSPATH "${srcdir}/$subdir:$classpath" + + # XXX There must be a better way to get basename + catch {exec basename $args .java} basename + catch {exec $java $basename} run_output + exec rm -f "${srcdir}/$subdir/$basename.class" + + set lines "" + foreach line [split $run_output \n] { + if [regexp "PASSED:.*" $line] { + if ![regexp "^$" $lines] { + fail "$args $lines" + } + pass "$args $line" + } else { + if [regexp "FAILED:.*" $line] { + fail "$args $line" + } else { + # Accumulate "wild" lines + if ![regexp "^$" $lines] { + set lines "$lines\n $line" + } else { + set lines "$line" + } + } + } + } + if ![regexp "^$" $lines] { + fail "$args $lines" + } + + # Reset CLASSPATH + setenv CLASSPATH "$classpath" + + return; +} + +# +# Compile $args and execute java class runtime_test +# +proc jasmin-assemble-execute { args } { + global srcdir + global subdir + + set comp_output [jasmin-assemble $args] + if ![regexp "^$" $comp_output] { + #fail $args + #print "$comp_output" + #return + } + + # XXX Should use some default value + global JAVA + set java $JAVA + + set classpath [getenv CLASSPATH] + setenv CLASSPATH "${srcdir}/$subdir:$classpath" + + # XXX There must be a better way to get basename + catch {exec basename $args .j} basename + catch {exec $java $basename} run_output + exec rm -f "${srcdir}/$subdir/$basename.class" + + set lines "" + foreach line [split $run_output \n] { + if [regexp "PASSED:.*" $line] { + if ![regexp "^$" $lines] { + fail "$args $lines" + } + pass "$args $line" + } else { + if [regexp "FAILED:.*" $line] { + fail "$args $line" + } else { + # Accumulate "wild" lines + if ![regexp "^$" $lines] { + set lines "$lines\n $line" + } else { + set lines "$line" + } + } + } + } + if ![regexp "^$" $lines] { + fail "$args $lines" + } + + # Reset CLASSPATH + setenv CLASSPATH "$classpath" + + return; +} + +# +# Compile java source +# +proc javac-target-compile { source dest type options } { +# XXX Do it the simple way - should use target_compile + + global JAVAC + set javac $JAVAC + + catch {exec $javac $source} comp_output + return $comp_output + +# set options "" +# lappend options "compiler=javac" +# lappend options "additional_flags=-g" +# lappend options "libs=" +# lappend options "ldflags=" +# return [target_compile $source $dest $type $options] +} + +# +# Compile jasmin (java assambly) source +# +proc jasmin-target-assemble { source dest type options } { + global srcdir + global subdir +# XXX Do it the simple way - should use target_compile + + global JAVA + set java $JAVA + + catch {exec $java jasmin.Main -d $srcdir/$subdir $source} comp_output + + return comp_output; +# set options "" +# lappend options "compiler=javac" +# lappend options "additional_flags=-g" +# lappend options "libs=" +# lappend options "ldflags=" +# return [target_compile $source $dest $type $options] +} |