| # |
| # 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] |
| } |