special.exp 2.5 KB

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