aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.4.0/libjava/testsuite/libjava.jar/jar.exp
blob: 65565832e79a4764b009042d8cebfcc2916fd349 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# Tests for .jar files.

# Compile a single .jar file to an executable.
# Returns 0 on failure.
proc gcj_jar_link {jarfile mainclass} {
}

proc gcj_jar_compile_one {jarfile mainclass} {
  set base [file rootname [file tail $jarfile]]
  set out [file rootname $jarfile].out

  if {! [gcj_link $base $mainclass [list $jarfile]]} {
    return
  }

  gcj_invoke $base $out {}
}

proc gcj_jar_interpret {jarfile} {
  global INTERPRETER srcdir

  set gij [libjava_find_gij]
  # libjava_find_gij will return "" if it couldn't find the
  # program; in this case we want to skip the test.
  if {$INTERPRETER != "yes" || $gij == ""} {
    untested "$jarfile execution - gij test"
    untested "$jarfile output - gij test"
    return
  }

  set opts(_) {}
  set out [file rootname $jarfile].out
  libjava_invoke $jarfile "gij test" opts $gij {} $out \
      "" -jar $jarfile
}

proc gcj_jar_run {} {
  global srcdir subdir env
  foreach jar [lsort [glob -nocomplain ${srcdir}/${subdir}/*.jar]] {
    set xff [file rootname $jar].xfail
    set main {}
    set interp 1
    foreach item [libjava_read_xfail $xff] {
      if {[string match main=* $item]} {
	set main [string range $item 5 end]
	break
      } elseif {$item == "no-interpret"} {
	set interp 0
      }
    }

    gcj_jar_compile_one $jar $main
    if {$interp} {
      gcj_jar_interpret $jar
    }
  }
    # When we succeed we remove all our clutter.
    eval gcj_cleanup [glob -nocomplain -- ${main}.*] [list $main ]

    # Reset CLASSPATH that we do not look into testsuite/libjava.jar for *.jar
    # files which do not belong to the libgcj itself.
    set env(CLASSPATH) ""

    return 1
}

gcj_jar_run