aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite
diff options
context:
space:
mode:
authorWu Zhou <woodzltc@cn.ibm.com>2005-09-20 09:01:14 +0000
committerWu Zhou <woodzltc@cn.ibm.com>2005-09-20 09:01:14 +0000
commitf34502bcd6f6a6ca045204df46c7a30483bc75dc (patch)
treea7a95fada328d12e642a418f01a7a968b0c5668e /gdb/testsuite
parent42969d33cb6f40b9dba99fdfdf448e553677dde3 (diff)
downloadgdb-f34502bcd6f6a6ca045204df46c7a30483bc75dc.zip
gdb-f34502bcd6f6a6ca045204df46c7a30483bc75dc.tar.gz
gdb-f34502bcd6f6a6ca045204df46c7a30483bc75dc.tar.bz2
* bfp-test.c: New file.
* bfp-test.exp: New testcase.
Diffstat (limited to 'gdb/testsuite')
-rw-r--r--gdb/testsuite/ChangeLog5
-rw-r--r--gdb/testsuite/gdb.base/bfp-test.c34
-rw-r--r--gdb/testsuite/gdb.base/bfp-test.exp131
3 files changed, 170 insertions, 0 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index e791be2..be05d41 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,5 +1,10 @@
2005-09-20 Wu Zhou <woodzltc@cn.ibm.com>
+ * bfp-test.c: New file.
+ * bfp-test.exp: New testcase.
+
+2005-09-20 Wu Zhou <woodzltc@cn.ibm.com>
+
* gdb.fortran/subarray.exp: New testcase to test the evaluation
of subarray and substring variable.
* gdb.fortran/subarray.f: New source file for the test of subarray
diff --git a/gdb/testsuite/gdb.base/bfp-test.c b/gdb/testsuite/gdb.base/bfp-test.c
new file mode 100644
index 0000000..da2716f
--- /dev/null
+++ b/gdb/testsuite/gdb.base/bfp-test.c
@@ -0,0 +1,34 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2005 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ 02111-1307, USA. */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+float b32;
+double b64;
+long double b128;
+
+int main()
+{
+ b32 = 1.5f;
+ b64 = 2.25;
+ b128 = 3.375l;
+
+ return 0;
+}
diff --git a/gdb/testsuite/gdb.base/bfp-test.exp b/gdb/testsuite/gdb.base/bfp-test.exp
new file mode 100644
index 0000000..43bf187
--- /dev/null
+++ b/gdb/testsuite/gdb.base/bfp-test.exp
@@ -0,0 +1,131 @@
+# Copyright 2005 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+# This file is part of the gdb testsuite. It is intended to test that
+# gdb could correctly handle floating point constant with a suffix.
+
+if $tracelevel {
+ strace $tracelevel
+}
+
+set testfile "bfp-test"
+set srcfile ${testfile}.c
+set binfile ${objdir}/${subdir}/${testfile}
+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
+ untested "Couldn't compile ${srcfile}"
+ return -1
+}
+
+gdb_exit
+gdb_start
+gdb_reinitialize_dir $srcdir/$subdir
+gdb_load ${binfile}
+
+if ![runto_main] then {
+ perror "couldn't run to breakpoint"
+ continue
+}
+
+# Run to the breakpoint at return.
+gdb_breakpoint [gdb_get_line_number "return"]
+gdb_continue_to_breakpoint "return"
+
+# Print the original value of b32, b64 and b128.
+gdb_test "print b32" ".*1 = 1\.5.*" "The original value of b32 is 1.5"
+gdb_test "print b64" ".*2 = 2\.25.*" "The original value of b64 is 2.25"
+gdb_test "print b128" ".*3 = 3\.375.*" "The original value of b128 is 3.375"
+
+# Test that gdb could correctly recognize float constant expression with a suffix.
+gdb_test "print b32=-1.5f" ".*4 = -1\.5.*" "Try to change b32 to -1.5 with 'print b32=-1.5f'"
+gdb_test "print b64=-2.25f" ".*5 = -2\.25.*" "Try to change b64 to -2.25 with 'print b64=-2.25f'"
+gdb_test "print b128=-3.375l" ".*6 = -3\.375.*" "Try to change b128 to -3.375 with 'print b128=-3.375l'"
+
+# Test that gdb could handle the above correctly with "set var" command.
+set test "set variable b32 = 10.5f"
+gdb_test_multiple "set var b32=10.5f" "$test" {
+ -re "$gdb_prompt $" {
+ pass "$test"
+ }
+ -re "Invalid number" {
+ fail "$test (do not recognize 10.5f)"
+ }
+}
+
+set test "set variable b64 = 20.25f"
+gdb_test_multiple "set var b64=20.25f" "$test" {
+ -re "$gdb_prompt $" {
+ pass "$test"
+ }
+ -re "Invalid number" {
+ fail "$test (do not recognize 20.25f)"
+ }
+}
+
+set test "set variable b128 = 30.375l"
+gdb_test_multiple "set var b128=30.375l" "$test" {
+ -re "$gdb_prompt $" {
+ pass "$test"
+ }
+ -re "Invalid number" {
+ fail "$test (do not recognize 30.375l)"
+ }
+}
+
+gdb_test "print b32" ".*7 = 10\.5.*" "The value of b32 is changed to 10.5"
+gdb_test "print b64" ".*8 = 20\.25.*" "The value of b64 is changed to 20.25"
+gdb_test "print b128" ".*9 = 30\.375.*" "The value of b128 is changed to 30.375"
+
+# Test that gdb could handle invalid suffix correctly.
+
+set test "set variable b32 = 100.5a"
+gdb_test_multiple "set var b32=100.5a" "$test" {
+ -re "Invalid number" {
+ pass "$test"
+ }
+ -re "$gdb_prompt $" {
+ fail "$test (do not report error on invalid suffix)"
+ }
+}
+
+set test "set variable b64 = 200.25x"
+gdb_test_multiple "set var b64=200.25x" "$test" {
+ -re "Invalid number" {
+ pass "$test"
+ }
+ -re "$gdb_prompt $" {
+ fail "$test (do not report error on invalid suffix)"
+ }
+}
+
+set test "set variable b128 = 300.375fl"
+gdb_test_multiple "set var b128=300.375fl" "$test" {
+ -re "Invalid number" {
+ pass "$test"
+ }
+ -re "$gdb_prompt $" {
+ fail "$test (do not report error on invalid suffix)"
+ }
+}
+
+set test "set variable b128 = 300.375fff"
+gdb_test_multiple "set var b128=300.375fff" "$test" {
+ -re "Invalid number" {
+ pass "$test"
+ }
+ -re "$gdb_prompt $" {
+ fail "$test (do not report error on invalid suffix)"
+ }
+}