OSDN Git Service

2009-08-12 Andrew Haley <aph@redhat.com>
[pf3gnuchains/gcc-fork.git] / libjava / testsuite / libjava.jvmti / jvmti.exp
1 # Tests for JVMTI code.
2
3 # Compile a single C++ file and produce a .o file.  OPTIONS is a list
4 # of options to pass to the compiler.  Returns 0 on failure, 1 on
5 # success.
6 proc gcj_jvmti_compile_cxx_to_o {file {options {}}} {
7   global srcdir
8   global objdir
9
10   set name [file rootname [file tail $file]]
11   set oname ${name}.o
12
13   # Find the generated header.
14   lappend options "additional_flags=-g -I. -I.. -fdollars-in-identifiers"
15   # Find libgcj headers.
16   lappend options "additional_flags=-I$srcdir/.."
17   # Find jvmti.h, jvmti_md.h, jvmti-int.h, jvm.h requirements
18   lappend options "additional_flags=-I$srcdir/../include -I$srcdir/../classpath/include -I$objdir/../include -I$objdir/../../boehm-gc/include "
19   # ARM C++ emits an ABI warning for varargs.
20   if { [istarget "arm*"] } {
21       lappend options "additional_flags=-Wno-abi"
22   }
23
24   set x [libjava_prune_warnings \
25            [target_compile $file $oname object $options]]
26   if {$x != ""} {
27     verbose "target_compile failed: $x" 2
28     fail "[file tail $file] compilation"
29     return 0
30   }
31
32   pass "[file tail $file] compilation"
33   return 1
34 }
35
36 # Build header files given name of .java file.  Return 0 on failure.
37 proc gcj_jvmti_build_headers {file} {
38   global libgcj_jar
39
40   set gcjh [find_gcjh]
41
42   # Currently we only build a header file for the main class from the
43   # .java file.  If we need more than this, we'll have to figure
44   # something out.
45   set file [file rootname [file tail $file]]
46
47   set x [string trim [libjava_prune_warnings \
48                         [lindex [local_exec "$gcjh -cni -force -classpath .:$libgcj_jar $file" "" "" 300] 1]]]
49   if {$x != ""} {
50     verbose "local_exec failed: $x" 2
51     fail "$file header generation"
52     return 0
53   }
54
55   pass "$file header generation"
56   return 1
57 }
58
59 # Do all the work for a single JVMTI test.  Return 0 on failure.
60 proc gcj_jvmti_test_one {file} {
61   global runtests
62
63   # The base name.  We use it for several purposes.
64   set main [file rootname [file tail $file]]
65   if {! [runtest_file_p $runtests $main]} {
66     # Simply skip it.
67     return 1
68   }
69
70 #   if {! [bytecompile_file $file [pwd]]} {
71 #     fail "bytecompile $file"
72 #     # FIXME - should use `untested' on all remaining tests.
73 #     # But that is hard.
74 #     return 0
75 #   }
76 #   pass "bytecompile $file"
77
78 #   if {! [gcj_jvmti_build_headers $file]} {
79 #     # FIXME
80 #     return 0
81 #   }
82
83   set cfile [file join [file dirname $file] nat$main.cc]
84   if {! [gcj_jvmti_compile_cxx_to_o $cfile]} {
85     # FIXME
86     return 0
87   }
88
89   if {! [gcj_link $main $main [list $file nat$main.o]]} {
90     # FIXME
91     return 0
92   }
93
94   if {! [gcj_invoke $main [file rootname $file].out {}]} {
95     # FIXME
96     return 0
97   }
98
99   # When we succeed we remove all our clutter.
100   eval gcj_cleanup [glob -nocomplain -- ${main}.*] [list $main nat$main.o]
101
102   return 1
103 }
104
105 # Run the JVMTI tests.
106 proc gcj_jvmti_run {} {
107   global srcdir subdir
108   global build_triplet host_triplet
109
110   # For now we only test JVMTI on native builds.
111   if {$build_triplet == $host_triplet} {
112     catch { lsort [glob -nocomplain ${srcdir}/${subdir}/*.jar] } srcfiles
113
114     foreach x $srcfiles {
115       gcj_jvmti_test_one $x
116     }
117   } else {
118     verbose "JVMTI tests not run in cross-compilation environment"
119   }
120 }
121
122 gcj_jvmti_run