]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/lib/java.exp
Update years in copyright notice for the GDB files.
[thirdparty/binutils-gdb.git] / gdb / testsuite / lib / java.exp
1 # This test code is part of GDB, the GNU debugger.
2
3 # Copyright 1998-2013 Free Software Foundation, Inc.
4
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 load_lib "libgloss.exp"
19
20 # GCJ_UNDER_TEST is the compiler under test.
21
22 global tmpdir
23
24 if ![info exists tmpdir] {
25 set tmpdir "/tmp"
26 }
27
28 set java_initialized 0
29
30 #
31 # Build the status wrapper library as needed.
32 #
33 proc java_init { args } {
34 global wrapper_file;
35 global wrap_compile_flags;
36 global java_initialized
37 global GCJ_UNDER_TEST
38 global TOOL_EXECUTABLE
39 global env
40
41 if { $java_initialized == 1 } { return; }
42
43 if ![info exists GCJ_UNDER_TEST] {
44 if [info exists TOOL_EXECUTABLE] {
45 set GCJ_UNDER_TEST $TOOL_EXECUTABLE;
46 } else {
47 if { [info exists env(GCJ)] && $env(GCJ) != "" } {
48 set GCJ_UNDER_TEST $env(GCJ)
49 } else {
50 global tool_root_dir
51 global target_alias
52
53 if ![is_remote host] {
54 set file [lookfor_file $tool_root_dir gcj];
55 if { $file == "" } {
56 set file [lookfor_file $tool_root_dir gcc/gcj];
57 }
58 if { $file != "" } {
59 set CC "$file -B[file dirname $file]/ --specs=$tool_root_dir/$target_alias/libjava/libgcj-test.spec";
60 } else {
61 set CC [transform gcj];
62 }
63 } else {
64 set CC [transform gcj]
65 }
66 set GCJ_UNDER_TEST $CC
67 }
68 }
69 }
70
71 set wrapper_file "";
72 set wrap_compile_flags "";
73 if [target_info exists needs_status_wrapper] {
74 set result [build_wrapper "testglue.o"];
75 if { $result != "" } {
76 set wrapper_file [lindex $result 0];
77 set wrap_compile_flags [lindex $result 1];
78 } else {
79 warning "Status wrapper failed to build."
80 }
81 }
82
83 set java_initialized 1
84 }
85
86 #
87 # Run the test specified by srcfile and resultfile. compile_args and
88 # exec_args are options telling this proc how to work.
89 #
90 proc compile_java_from_source { srcfile binfile compile_args } {
91 global GCJ_UNDER_TEST
92 global java_initialized
93
94 if { $java_initialized != 1 } { java_init }
95
96 set args "compiler=$GCJ_UNDER_TEST"
97 lappend args "additional_flags=--main=[file rootname [file tail $srcfile]]"
98 if { $compile_args != "" } {
99 lappend args "additional_flags=$compile_args"
100 }
101
102 set result [target_compile $srcfile ${binfile} executable $args]
103 gdb_compile_test $srcfile $result
104 return $result
105 }
106
107 # Auxiliary function to set the language to java.
108 # The result is 1 (true) for success, 0 (false) for failure.
109
110 proc set_lang_java {} {
111 if [gdb_test_no_output "set language java"] {
112 return 0
113 }
114 if [gdb_test "show language" ".* source language is \"java\"." \
115 "set language to \"java\""] {
116 return 0
117 }
118 return 1;
119 }
120
121 # Local Variables:
122 # tcl-indent-level:4
123 # End: