Copyright updates for 2007.
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / bfp-test.exp
CommitLineData
6aba47ca 1# Copyright 2005, 2007 Free Software Foundation, Inc.
f34502bc
WZ
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 2 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, write to the Free Software
15# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
16
17# This file is part of the gdb testsuite. It is intended to test that
18# gdb could correctly handle floating point constant with a suffix.
19
20if $tracelevel {
21 strace $tracelevel
22}
23
24set testfile "bfp-test"
25set srcfile ${testfile}.c
26set binfile ${objdir}/${subdir}/${testfile}
27if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
28 untested "Couldn't compile ${srcfile}"
29 return -1
30}
31
32gdb_exit
33gdb_start
34gdb_reinitialize_dir $srcdir/$subdir
35gdb_load ${binfile}
36
37if ![runto_main] then {
38 perror "couldn't run to breakpoint"
39 continue
40}
41
42# Run to the breakpoint at return.
43gdb_breakpoint [gdb_get_line_number "return"]
44gdb_continue_to_breakpoint "return"
45
46# Print the original value of b32, b64 and b128.
47gdb_test "print b32" ".*1 = 1\.5.*" "The original value of b32 is 1.5"
48gdb_test "print b64" ".*2 = 2\.25.*" "The original value of b64 is 2.25"
49gdb_test "print b128" ".*3 = 3\.375.*" "The original value of b128 is 3.375"
50
51# Test that gdb could correctly recognize float constant expression with a suffix.
52gdb_test "print b32=-1.5f" ".*4 = -1\.5.*" "Try to change b32 to -1.5 with 'print b32=-1.5f'"
53gdb_test "print b64=-2.25f" ".*5 = -2\.25.*" "Try to change b64 to -2.25 with 'print b64=-2.25f'"
54gdb_test "print b128=-3.375l" ".*6 = -3\.375.*" "Try to change b128 to -3.375 with 'print b128=-3.375l'"
55
56# Test that gdb could handle the above correctly with "set var" command.
57set test "set variable b32 = 10.5f"
58gdb_test_multiple "set var b32=10.5f" "$test" {
59 -re "$gdb_prompt $" {
60 pass "$test"
61 }
e52b687c 62 -re "Invalid number.*$gdb_prompt $" {
f34502bc
WZ
63 fail "$test (do not recognize 10.5f)"
64 }
65}
66
67set test "set variable b64 = 20.25f"
68gdb_test_multiple "set var b64=20.25f" "$test" {
69 -re "$gdb_prompt $" {
70 pass "$test"
71 }
e52b687c 72 -re "Invalid number.*$gdb_prompt $" {
f34502bc
WZ
73 fail "$test (do not recognize 20.25f)"
74 }
75}
76
77set test "set variable b128 = 30.375l"
78gdb_test_multiple "set var b128=30.375l" "$test" {
79 -re "$gdb_prompt $" {
80 pass "$test"
81 }
e52b687c 82 -re "Invalid number.*$gdb_prompt $" {
f34502bc
WZ
83 fail "$test (do not recognize 30.375l)"
84 }
85}
86
87gdb_test "print b32" ".*7 = 10\.5.*" "The value of b32 is changed to 10.5"
88gdb_test "print b64" ".*8 = 20\.25.*" "The value of b64 is changed to 20.25"
89gdb_test "print b128" ".*9 = 30\.375.*" "The value of b128 is changed to 30.375"
90
91# Test that gdb could handle invalid suffix correctly.
92
93set test "set variable b32 = 100.5a"
94gdb_test_multiple "set var b32=100.5a" "$test" {
e52b687c 95 -re "Invalid number.*$gdb_prompt $" {
f34502bc
WZ
96 pass "$test"
97 }
98 -re "$gdb_prompt $" {
99 fail "$test (do not report error on invalid suffix)"
100 }
101}
102
103set test "set variable b64 = 200.25x"
104gdb_test_multiple "set var b64=200.25x" "$test" {
e52b687c 105 -re "Invalid number.*$gdb_prompt $" {
f34502bc
WZ
106 pass "$test"
107 }
108 -re "$gdb_prompt $" {
109 fail "$test (do not report error on invalid suffix)"
110 }
111}
112
113set test "set variable b128 = 300.375fl"
114gdb_test_multiple "set var b128=300.375fl" "$test" {
e52b687c 115 -re "Invalid number.*$gdb_prompt $" {
f34502bc
WZ
116 pass "$test"
117 }
118 -re "$gdb_prompt $" {
119 fail "$test (do not report error on invalid suffix)"
120 }
121}
122
123set test "set variable b128 = 300.375fff"
124gdb_test_multiple "set var b128=300.375fff" "$test" {
e52b687c 125 -re "Invalid number.*$gdb_prompt $" {
f34502bc
WZ
126 pass "$test"
127 }
128 -re "$gdb_prompt $" {
129 fail "$test (do not report error on invalid suffix)"
130 }
131}
This page took 0.11003 seconds and 4 git commands to generate.