| 1 | # Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation.
|
|---|
| 2 | # Written by Tom Tromey <[email protected]>.
|
|---|
| 3 | # Incorporate Mauve into libjava's DejaGNU test suite framework.
|
|---|
| 4 |
|
|---|
| 5 | # FIXME: should be able to compile from source as well as from .class.
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 | # Compute list of files to compile. Returns list of all files
|
|---|
| 9 | # representing classes that must be tested. Result parameter `uses'
|
|---|
| 10 | # maps source file names onto list of objects required for link.
|
|---|
| 11 | proc mauve_compute_uses {aName} {
|
|---|
| 12 | upvar $aName uses
|
|---|
| 13 | global env runtests
|
|---|
| 14 |
|
|---|
| 15 | set fd [open classes r]
|
|---|
| 16 | set line [read $fd]
|
|---|
| 17 | close $fd
|
|---|
| 18 |
|
|---|
| 19 | foreach item [split $line] {
|
|---|
| 20 | if {$item == ""} then {
|
|---|
| 21 | continue
|
|---|
| 22 | }
|
|---|
| 23 | set item [join [split $item .] /].java
|
|---|
| 24 |
|
|---|
| 25 | # User might have specified "mauve.exp=something.java".
|
|---|
| 26 | if {! [runtest_file_p $runtests $item]} {
|
|---|
| 27 | continue
|
|---|
| 28 | }
|
|---|
| 29 |
|
|---|
| 30 | # Look for Uses line in source file.
|
|---|
| 31 | set fd [open $env(MAUVEDIR)/$item r]
|
|---|
| 32 | set ufiles [list $item]
|
|---|
| 33 | set dir [file dirname $item]
|
|---|
| 34 | while {[gets $fd sline] != -1} {
|
|---|
| 35 | if {[regsub -- {^// Uses:} $sline {} sline]} then {
|
|---|
| 36 | foreach uf [split $sline] {
|
|---|
| 37 | if {$uf != ""} then {
|
|---|
| 38 | lappend ufiles $dir/$uf
|
|---|
| 39 | }
|
|---|
| 40 | }
|
|---|
| 41 | }
|
|---|
| 42 | }
|
|---|
| 43 | close $fd
|
|---|
| 44 |
|
|---|
| 45 | set uses($item) {}
|
|---|
| 46 | foreach file $ufiles {
|
|---|
| 47 | set file [file rootname $file].o
|
|---|
| 48 | lappend uses($item) $file
|
|---|
| 49 | }
|
|---|
| 50 | }
|
|---|
| 51 |
|
|---|
| 52 | return [lsort [array names uses]]
|
|---|
| 53 | }
|
|---|
| 54 |
|
|---|
| 55 | # Run all the Mauve tests. Return 1 on success, 0 on any failure. If
|
|---|
| 56 | # the tests are skipped, that is treated like success.
|
|---|
| 57 | proc test_mauve {} {
|
|---|
| 58 | global srcdir objdir subdir env
|
|---|
| 59 |
|
|---|
| 60 | if {! [info exists env(MAUVEDIR)]} then {
|
|---|
| 61 | verbose "MAUVEDIR not set; not running Mauve tests"
|
|---|
| 62 | return 1
|
|---|
| 63 | }
|
|---|
| 64 |
|
|---|
| 65 | # Run in subdir so we don't overwrite our own Makefile.
|
|---|
| 66 | catch {system "rm -rf mauve-build"}
|
|---|
| 67 | file mkdir mauve-build
|
|---|
| 68 | # Some weirdness to set srcdir correctly.
|
|---|
| 69 | set here [pwd]
|
|---|
| 70 | cd $srcdir
|
|---|
| 71 | set full_srcdir [pwd]
|
|---|
| 72 | cd $here/mauve-build
|
|---|
| 73 |
|
|---|
| 74 | global env
|
|---|
| 75 | global GCJ_UNDER_TEST
|
|---|
| 76 | global TOOL_EXECUTABLE
|
|---|
| 77 |
|
|---|
| 78 | if ![info exists GCJ_UNDER_TEST] {
|
|---|
| 79 | if [info exists TOOL_EXECUTABLE] {
|
|---|
| 80 | set GCJ_UNDER_TEST $TOOL_EXECUTABLE;
|
|---|
| 81 | } else {
|
|---|
| 82 | if [info exists env(GCJ)] {
|
|---|
| 83 | set GCJ_UNDER_TEST env(GCJ)
|
|---|
| 84 | } else {
|
|---|
| 85 | set GCJ_UNDER_TEST "[find_gcj]"
|
|---|
| 86 | }
|
|---|
| 87 | }
|
|---|
| 88 | }
|
|---|
| 89 |
|
|---|
| 90 | # Append -B and -I so that libgcj.spec and libgcj.zip are found
|
|---|
| 91 | # before they're installed.
|
|---|
| 92 | set env(GCJ) "$GCJ_UNDER_TEST -B$objdir/../ -I$objdir/../libgcj.jar"
|
|---|
| 93 |
|
|---|
| 94 | if {[catch {
|
|---|
| 95 | system "$env(MAUVEDIR)/configure --with-gcj 2>&1"
|
|---|
| 96 | } msg]} then {
|
|---|
| 97 | fail "Mauve configure"
|
|---|
| 98 | verbose "configure failed with $msg"
|
|---|
| 99 | return 0
|
|---|
| 100 | }
|
|---|
| 101 | pass "Mauve configure"
|
|---|
| 102 |
|
|---|
| 103 | # Copy appropriate tags file locally.
|
|---|
| 104 | set fd [open $full_srcdir/../mauve-libgcj r]
|
|---|
| 105 | set c [read $fd]
|
|---|
| 106 | close $fd
|
|---|
| 107 | set fd [open mauve-libgcj w]
|
|---|
| 108 | puts -nonewline $fd $c
|
|---|
| 109 | close $fd
|
|---|
| 110 |
|
|---|
| 111 | catch {system "ln -s $full_srcdir/libjava.mauve/xfails xfails"}
|
|---|
| 112 |
|
|---|
| 113 | if {[catch {
|
|---|
| 114 | system "make KEYS=libgcj classes.stamp 2>&1"
|
|---|
| 115 | } msg]} then {
|
|---|
| 116 | fail "Mauve build"
|
|---|
| 117 | verbose "build failed with $msg"
|
|---|
| 118 | return 0
|
|---|
| 119 | }
|
|---|
| 120 | pass "Mauve build"
|
|---|
| 121 |
|
|---|
| 122 | set srcfile $full_srcdir/$subdir/DejaGNUTestHarness.java
|
|---|
| 123 | if {! [bytecompile_file $srcfile [pwd] $env(MAUVEDIR):[pwd]]} then {
|
|---|
| 124 | fail "Compile DejaGNUTestHarness.java"
|
|---|
| 125 | return 0
|
|---|
| 126 | }
|
|---|
| 127 | pass "Compile DejaGNUTestHarness.java"
|
|---|
| 128 |
|
|---|
| 129 | # Compute list of files to test, and also all files to build.
|
|---|
| 130 | set choices [mauve_compute_uses uses]
|
|---|
| 131 |
|
|---|
| 132 | # Compute flags to use to do the build.
|
|---|
| 133 | set compile_args [libjava_arguments]
|
|---|
| 134 | set link_args [concat [libjava_arguments link] \
|
|---|
| 135 | [list "additional_flags=--main=DejaGNUTestHarness"]]
|
|---|
| 136 |
|
|---|
| 137 | set ok 1
|
|---|
| 138 | set objlist {}
|
|---|
| 139 | foreach base {DejaGNUTestHarness gnu/testlet/SimpleTestHarness gnu/testlet/TestHarness gnu/testlet/Testlet gnu/testlet/ResourceNotFoundException gnu/testlet/config} {
|
|---|
| 140 | set file $base.class
|
|---|
| 141 | set obj $base.o
|
|---|
| 142 | set x [prune_warnings \
|
|---|
| 143 | [target_compile [pwd]/$file $obj object $compile_args]]
|
|---|
| 144 | if {$x != ""} then {
|
|---|
| 145 | fail "Compile $obj"
|
|---|
| 146 | set ok 0
|
|---|
| 147 | } else {
|
|---|
| 148 | pass "Compile $obj"
|
|---|
| 149 | }
|
|---|
| 150 | lappend objlist $obj
|
|---|
| 151 | }
|
|---|
| 152 | if {! $ok} then {
|
|---|
| 153 | return 0
|
|---|
| 154 | }
|
|---|
| 155 |
|
|---|
| 156 | set proc_ok 1
|
|---|
| 157 | set Executable DejaGNUTestHarness
|
|---|
| 158 | foreach file $choices {
|
|---|
| 159 | # Turn `java/lang/Foo.java' into `java.lang.Foo'.
|
|---|
| 160 | set class [file rootname $file]
|
|---|
| 161 | regsub -all -- / $class . class
|
|---|
| 162 |
|
|---|
| 163 | set ok 1
|
|---|
| 164 | foreach obj $uses($file) {
|
|---|
| 165 | if {! [file exists $obj]} then {
|
|---|
| 166 | verbose "compiling $obj for test of $class"
|
|---|
| 167 | set srcfile [file rootname $obj].class
|
|---|
| 168 | set x [prune_warnings \
|
|---|
| 169 | [target_compile [pwd]/$srcfile $obj object $compile_args]]
|
|---|
| 170 | if {$x != ""} then {
|
|---|
| 171 | fail "Compile $obj for $class"
|
|---|
| 172 | set ok 0
|
|---|
| 173 | break
|
|---|
| 174 | }
|
|---|
| 175 | pass "Compile $obj for $class"
|
|---|
| 176 | }
|
|---|
| 177 | }
|
|---|
| 178 | if {! $ok} then {
|
|---|
| 179 | set proc_ok 0
|
|---|
| 180 | continue
|
|---|
| 181 | }
|
|---|
| 182 |
|
|---|
| 183 | set x [prune_warnings [target_compile [concat $uses($file) $objlist] \
|
|---|
| 184 | $Executable executable $link_args]]
|
|---|
| 185 | if {$x != ""} then {
|
|---|
| 186 | set proc_ok 0
|
|---|
| 187 | fail "Link for $class"
|
|---|
| 188 | continue
|
|---|
| 189 | }
|
|---|
| 190 | pass "Link for $class"
|
|---|
| 191 |
|
|---|
| 192 | set result [libjava_load [pwd]/DejaGNUTestHarness \
|
|---|
| 193 | "$env(MAUVEDIR) $class" ""]
|
|---|
| 194 |
|
|---|
| 195 | # Extract pass/failure info from output.
|
|---|
| 196 | foreach line [split [lindex $result 1] \n] {
|
|---|
| 197 | if {[regexp -- {^(PASS|FAIL|XFAIL|XPASS): (.*)$} $line ignore what msg]} then {
|
|---|
| 198 | if {$what == "XFAIL" || $what == "XPASS"} then {
|
|---|
| 199 | setup_xfail *-*-*
|
|---|
| 200 | }
|
|---|
| 201 | if {$what == "PASS" || $what == "XPASS"} then {
|
|---|
| 202 | pass $msg
|
|---|
| 203 | } else {
|
|---|
| 204 | set proc_ok 0
|
|---|
| 205 | fail $msg
|
|---|
| 206 | }
|
|---|
| 207 | }
|
|---|
| 208 | }
|
|---|
| 209 | }
|
|---|
| 210 |
|
|---|
| 211 | return $proc_ok
|
|---|
| 212 | }
|
|---|
| 213 |
|
|---|
| 214 | # Run all the Mauve tests in a sim environment. In this case, the
|
|---|
| 215 | # program cannot use argv[] because there's no way to pass in the
|
|---|
| 216 | # command line, so tha name of the class to test is substituted by
|
|---|
| 217 | # patching the source of the DejaGNUTestHarness. Return 1 on success,
|
|---|
| 218 | # 0 on any failure. If the tests are skipped, that is treated like
|
|---|
| 219 | # success.
|
|---|
| 220 | proc test_mauve_sim {} {
|
|---|
| 221 | global srcdir subdir env
|
|---|
| 222 |
|
|---|
| 223 | if {! [info exists env(MAUVEDIR)]} then {
|
|---|
| 224 | verbose "MAUVEDIR not set; not running Mauve tests"
|
|---|
| 225 | return 1
|
|---|
| 226 | }
|
|---|
| 227 |
|
|---|
| 228 | # Run in subdir so we don't overwrite our own Makefile.
|
|---|
| 229 | catch {system "rm -rf mauve-build"}
|
|---|
| 230 | file mkdir mauve-build
|
|---|
| 231 | # Some weirdness to set srcdir correctly.
|
|---|
| 232 | set here [pwd]
|
|---|
| 233 | cd $srcdir
|
|---|
| 234 | set full_srcdir [pwd]
|
|---|
| 235 | cd $here/mauve-build
|
|---|
| 236 |
|
|---|
| 237 | if {[catch {
|
|---|
| 238 | system "$env(MAUVEDIR)/configure --with-gcj 2>&1"
|
|---|
| 239 | } msg]} then {
|
|---|
| 240 | fail "Mauve configure"
|
|---|
| 241 | verbose "configure failed with $msg"
|
|---|
| 242 | return 0
|
|---|
| 243 | }
|
|---|
| 244 | pass "Mauve configure"
|
|---|
| 245 |
|
|---|
| 246 | # Copy appropriate tags file locally.
|
|---|
| 247 | set fd [open $full_srcdir/../mauve-libgcj r]
|
|---|
| 248 | set c [read $fd]
|
|---|
| 249 | close $fd
|
|---|
| 250 | set fd [open mauve-libgcj w]
|
|---|
| 251 | puts -nonewline $fd $c
|
|---|
| 252 | close $fd
|
|---|
| 253 |
|
|---|
| 254 | catch {system "ln -s $full_srcdir/libjava.mauve/xfails xfails"}
|
|---|
| 255 |
|
|---|
| 256 | if {[catch {
|
|---|
| 257 | system "make KEYS=libgcj classes.stamp 2>&1"
|
|---|
| 258 | } msg]} then {
|
|---|
| 259 | fail "Mauve build"
|
|---|
| 260 | verbose "build failed with $msg"
|
|---|
| 261 | return 0
|
|---|
| 262 | }
|
|---|
| 263 | pass "Mauve build"
|
|---|
| 264 |
|
|---|
| 265 | # Compute list of files to test, and also all files to build.
|
|---|
| 266 | set choices [mauve_compute_uses uses]
|
|---|
| 267 |
|
|---|
| 268 | # Compute flags to use to do the build.
|
|---|
| 269 | set compile_args [libjava_arguments]
|
|---|
| 270 | set link_args [concat [libjava_arguments link] \
|
|---|
| 271 | [list "additional_flags=--main=DejaGNUTestHarness"]]
|
|---|
| 272 |
|
|---|
| 273 | set ok 1
|
|---|
| 274 | set objlist {}
|
|---|
| 275 | foreach base {gnu/testlet/SimpleTestHarness gnu/testlet/TestHarness \
|
|---|
| 276 | gnu/testlet/Testlet gnu/testlet/ResourceNotFoundException \
|
|---|
| 277 | gnu/testlet/config} {
|
|---|
| 278 | set file $base.class
|
|---|
| 279 | set obj $base.o
|
|---|
| 280 | set x [prune_warnings \
|
|---|
| 281 | [target_compile [pwd]/$file $obj object $compile_args]]
|
|---|
| 282 | if {$x != ""} then {
|
|---|
| 283 | fail "Compile $obj"
|
|---|
| 284 | set ok 0
|
|---|
| 285 | } else {
|
|---|
| 286 | pass "Compile $obj"
|
|---|
| 287 | }
|
|---|
| 288 | lappend objlist $obj
|
|---|
| 289 | }
|
|---|
| 290 | if {! $ok} then {
|
|---|
| 291 | return 0
|
|---|
| 292 | }
|
|---|
| 293 |
|
|---|
| 294 | lappend objlist gnu/testlet/DejaGNUTestHarness.o
|
|---|
| 295 |
|
|---|
| 296 | set proc_ok 1
|
|---|
| 297 | set Executable DejaGNUTestHarness
|
|---|
| 298 | foreach file $choices {
|
|---|
| 299 | # Turn `java/lang/Foo.java' into `java.lang.Foo'.
|
|---|
| 300 |
|
|---|
| 301 | set class [file rootname $file]
|
|---|
| 302 | regsub -all -- / $class . class
|
|---|
| 303 |
|
|---|
| 304 | set ok 1
|
|---|
| 305 | foreach obj $uses($file) {
|
|---|
| 306 | if {! [file exists $obj]} then {
|
|---|
| 307 | verbose "compiling $obj for test of $class"
|
|---|
| 308 | set srcfile [file rootname $obj].class
|
|---|
| 309 | set x [prune_warnings \
|
|---|
| 310 | [target_compile [pwd]/$srcfile $obj object $compile_args]]
|
|---|
| 311 | if {$x != ""} then {
|
|---|
| 312 | fail "Compile $obj for $class"
|
|---|
| 313 | set ok 0
|
|---|
| 314 | break
|
|---|
| 315 | }
|
|---|
| 316 | pass "Compile $obj for $class"
|
|---|
| 317 | }
|
|---|
| 318 | }
|
|---|
| 319 | if {! $ok} then {
|
|---|
| 320 | set proc_ok 0
|
|---|
| 321 | continue
|
|---|
| 322 | }
|
|---|
| 323 |
|
|---|
| 324 | set infile $full_srcdir/$subdir/DejaGNUTestHarness.java
|
|---|
| 325 | set srcfile DejaGNUTestHarness.java
|
|---|
| 326 | set f [open $infile r]
|
|---|
| 327 | set d [open gnu/testlet/$srcfile w]
|
|---|
| 328 | while {[gets $f line] >= 0} {
|
|---|
| 329 | if [regexp {harness\.runtest \(args\[1\]\)} $line] then {
|
|---|
| 330 | regsub {args\[1\]} $line "\"$class\"" out
|
|---|
| 331 | } else {
|
|---|
| 332 | set out $line
|
|---|
| 333 | }
|
|---|
| 334 | puts $d $out
|
|---|
| 335 | }
|
|---|
| 336 | close $f
|
|---|
| 337 | close $d
|
|---|
| 338 |
|
|---|
| 339 | if {! [bytecompile_file [pwd]/gnu/testlet/$srcfile [pwd]/gnu/testlet \
|
|---|
| 340 | $env(MAUVEDIR):[pwd]]} then {
|
|---|
| 341 | fail "Compile DejaGNUTestHarness.java"
|
|---|
| 342 | return 0
|
|---|
| 343 | }
|
|---|
| 344 |
|
|---|
| 345 | set x [prune_warnings \
|
|---|
| 346 | [target_compile gnu/testlet/DejaGNUTestHarness.class \
|
|---|
| 347 | gnu/testlet/DejaGNUTestHarness.o object $compile_args]]
|
|---|
| 348 | if {$x != ""} then {
|
|---|
| 349 | fail "Compile DejaGNUTestHarness.java"
|
|---|
| 350 | set proc_ok 0
|
|---|
| 351 | continue
|
|---|
| 352 | }
|
|---|
| 353 |
|
|---|
| 354 | set x [prune_warnings [target_compile [concat $uses($file) $objlist] \
|
|---|
| 355 | $Executable executable $link_args]]
|
|---|
| 356 | if {$x != ""} then {
|
|---|
| 357 | set proc_ok 0
|
|---|
| 358 | fail "Link for $class"
|
|---|
| 359 | continue
|
|---|
| 360 | }
|
|---|
| 361 | pass "Link for $class"
|
|---|
| 362 |
|
|---|
| 363 | set result [libjava_load [pwd]/DejaGNUTestHarness \
|
|---|
| 364 | "$env(MAUVEDIR) $class" ""]
|
|---|
| 365 |
|
|---|
| 366 | # Extract pass/failure info from output.
|
|---|
| 367 | foreach line [split [lindex $result 1] \n] {
|
|---|
| 368 | if {[regexp -- {^(PASS|FAIL|XFAIL|XPASS): (.*)$} $line ignore what msg]} then {
|
|---|
| 369 | if {$what == "XFAIL" || $what == "XPASS"} then {
|
|---|
| 370 | setup_xfail *-*-*
|
|---|
| 371 | }
|
|---|
| 372 | if {$what == "PASS" || $what == "XPASS"} then {
|
|---|
| 373 | pass $msg
|
|---|
| 374 | } else {
|
|---|
| 375 | set proc_ok 0
|
|---|
| 376 | fail $msg
|
|---|
| 377 | }
|
|---|
| 378 | }
|
|---|
| 379 | }
|
|---|
| 380 | }
|
|---|
| 381 |
|
|---|
| 382 | return $proc_ok
|
|---|
| 383 | }
|
|---|
| 384 |
|
|---|
| 385 | proc gcj_run_mauve_tests {} {
|
|---|
| 386 | # The test_mauve* procs will change the current directory. It's
|
|---|
| 387 | # simpler to fix this up here than to keep track of this in the
|
|---|
| 388 | # procs.
|
|---|
| 389 | set here [pwd]
|
|---|
| 390 | if { [board_info target exists is_simulator] } {
|
|---|
| 391 | set r [test_mauve_sim]
|
|---|
| 392 | } else {
|
|---|
| 393 | set r [test_mauve]
|
|---|
| 394 | }
|
|---|
| 395 | cd $here
|
|---|
| 396 |
|
|---|
| 397 | if {$r} {
|
|---|
| 398 | # No need to keep the build around. FIXME: this knows how the
|
|---|
| 399 | # tests work. This whole file could use a rewrite.
|
|---|
| 400 | system "rm -rf mauve-build"
|
|---|
| 401 | }
|
|---|
| 402 | }
|
|---|
| 403 |
|
|---|
| 404 | gcj_run_mauve_tests
|
|---|