1# Copyright 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
2
3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by
5# the Free Software Foundation; either version 3 of the License, or
6# (at your option) any later version.
7#
8# This program is distributed in the hope that it will be useful,
9# but WITHOUT ANY WARRANTY; without even the implied warranty of
10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11# GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License
14# along with this program.  If not, see <http://www.gnu.org/licenses/>.
15
16if $tracelevel then {
17    strace $tracelevel
18}
19
20
21set testfile start
22set srcfile ${testfile}.c
23set binfile ${objdir}/${subdir}/${testfile}
24if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
25    untested "Couldn't compile test program"
26    return -1
27}
28
29# Get things started.
30
31gdb_exit
32gdb_start
33gdb_reinitialize_dir $srcdir/$subdir
34gdb_load ${binfile}
35
36# Do not run the inferior as the purpose of this testcase is to test
37# the behavior of the "set language" command when there is no inferior.
38
39# Check the language after the binary has been loaded.  It should be
40# "auto; currently c".
41gdb_test "show lang" \
42         "The current source language is \"auto; currently c\"\\." \
43         "show lang after loading binary"
44
45# Now, switch the language to a specific language, instead of leaving it
46# on auto.
47gdb_test_no_output "set lang ada" \
48         "forcing the language to ada"
49
50# Verify that the language is now "ada".
51gdb_test "show lang" \
52         "The current source language is \"ada\"\\." \
53         "show lang after switching language to ada"
54
55# Then, switch back to auto...
56gdb_test_no_output "set lang auto" \
57         "switching the language back to auto"
58
59# ... And verify that the language mode is back to auto *and* that
60# the selected language is C.
61
62gdb_test "show lang" \
63         "The current source language is \"auto; currently c\"\\." \
64         "show lang after having switched back to auto"
65
66
67