OSDN Git Service

* testsuite/libjava.special/special.exp (gcj_special_pr21115):
[pf3gnuchains/gcc-fork.git] / libjava / testsuite / libjava.special / special.exp
1 # Special test cases.  These require tricky build procedures.
2
3 proc gcj_special_pr21115 {} {
4   global srcdir subdir env
5
6   # ---- PR 21115 -------------------------------------------------------
7
8   if {! [bytecompile_file ${srcdir}/${subdir}/pr21115I.java [pwd]]} {
9     fail "bytecompile ${srcdir}/${subdir}/libjava.special/pr21115I.java"
10     # FIXME - should use `untested' on all remaining tests.
11     # But that is hard.
12     return 0
13   }
14   pass "bytecompile pr21115I.java"
15
16   if {! [gcj_link pr21115 pr21115 [list ${srcdir}/${subdir}/pr21115.java]]} {
17     fail "compiling/linking pr21115.java"
18     # FIXME
19     return 0
20   }
21
22   if {! [gcj_invoke pr21115 ${srcdir}/${subdir}/pr21115.out ""]} {
23     # FIXME
24     return 0
25   }
26
27   return 1
28 }
29
30 # Write a .java file and bytecompile it.  Return 0 on failure.
31 proc gcj_write_and_byte_compile {name contents} {
32   set fd [open $name w]
33   puts $fd $contents
34   close $fd
35
36   if {! [bytecompile_file $name [pwd]]} {
37     fail "bytecompile $name"
38     # FIXME - should use `untested' on all remaining tests.
39     # But that is hard.
40     return 0
41   }
42   pass "bytecompile $name"
43   return 1
44 }
45
46 # Check that BC-compiled code lazily throws IllegalAccessError.
47 proc gcj_special_lazy_illegal_access {} {
48   global srcdir subdir env
49
50   # Write and compile the initial files.
51   if {! [gcj_write_and_byte_compile LazyA.java {
52     public class LazyA {
53       public static void m() { }
54     }
55   }]} {
56     return 0
57   }
58   if {! [gcj_write_and_byte_compile LazyB.java {
59     public class LazyB {
60       public static void m() { }
61       public static void main(String[] args) { }
62     }
63   }]} {
64     return 0
65   }
66
67   # Create the expected output file.
68   set fd [open Lazy.out w]
69   close $fd
70
71   # Now recompile LazyA with different access for m().
72   if {! [gcj_write_and_byte_compile LazyA.java {
73     public class LazyA {
74       private static void m() { }
75     }
76   }]} {
77     return 0
78   }
79
80   # Link and run... this should still work, since we don't actually
81   # try to call LazyA.m().
82   if {! [gcj_link Lazy LazyB {LazyA.class LazyB.class} \
83            additional_flags=-findirect-dispatch]} {
84     fail "compiling/linking pr21115.java"
85     # FIXME
86     return 0
87   }
88
89   if {! [gcj_invoke Lazy Lazy.out ""]} {
90     # FIXME
91     return 0
92   }
93
94   return 1
95 }
96
97 gcj_special_pr21115
98 gcj_special_lazy_illegal_access