This commit was manufactured by cvs2svn to create branch 'gdb_7_0-branch'.
[external/binutils.git] / gdb / testsuite / gdb.base / exprs.exp
index 925a902..711c72e 100644 (file)
@@ -1,9 +1,9 @@
-#   Copyright (C) 1988, 1990, 1991, 1992, 1994, 1997, 2000 Free
-#   Software Foundation, Inc.
+#   Copyright 1988, 1990, 1991, 1992, 1994, 1995, 1996, 1997, 1998, 2000,
+#   2001, 2003, 2007, 2008, 2009 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
+# the Free Software Foundation; either version 3 of the License, or
 # (at your option) any later version.
 #
 # This program is distributed in the hope that it will be useful,
 # 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.  
-
-# Please email any bugs, comments, and/or additions to this file to:
-# bug-gdb@prep.ai.mit.edu
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 # This file was written by Rob Savoye. (rob@cygnus.com)
 
@@ -34,7 +30,8 @@ set testfile "exprs"
 set srcfile ${testfile}.c
 set binfile ${objdir}/${subdir}/${testfile}
 if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
-     gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
+     untested exprs.exp
+     return -1
 }
 
 if [get_compiler_info ${binfile}] {
@@ -98,14 +95,8 @@ test_expr "set variable v_unsigned_char=127" "print v_unsigned_char != 0" "\\$\[
 test_expr "set variable v_unsigned_char=127" "print v_unsigned_char < 0" "\\$\[0-9\]* = $false"  "print v_unsigned_char < 127" "\\$\[0-9\]* = $false"  "print unsigned char <"
 test_expr "set variable v_unsigned_char=127" "print v_unsigned_char > 0" "\\$\[0-9\]* = $true"  "print v_unsigned_char > 127" "\\$\[0-9\]* = $false"  "print unsigned char >"
 # make char a minus
-# FIXME:  gdb mishandles the cast (unsigned char) on the i960, so I've
-# set up an expected failure for this case.
-setup_xfail "i960-*-*" 1821
-test_expr "set variable v_unsigned_char=~0" "print v_unsigned_char == 0" "\\$\[0-9\]* = $false"  "print v_unsigned_char == ~0" "\\$\[0-9\]* = $false"  "print v_unsigned_char == (unsigned char)~0" "\\$\[0-9\]* = $true"  "print unsigned char == (~0)"
-# FIXME:  gdb mishandles the cast (unsigned char) on the i960, so I've
-# set up an expected failure for this case.
-setup_xfail "i960-*-*" 1821
-test_expr "set variable v_unsigned_char=~0" "print v_unsigned_char != 0" "\\$\[0-9\]* = $true"  "print v_unsigned_char != (unsigned char)~0" "\\$\[0-9\]* = $false"  "print unsigned char != (~0)"
+test_expr "set variable v_unsigned_char=~0" "print v_unsigned_char == 0" "\\$\[0-9\]* = $false"  "print v_unsigned_char == ~0" "\\$\[0-9\]* = $false"  "print v_unsigned_char == (unsigned char)~0" "\\$\[0-9\]* = $true" "print unsigned char == (~0)"
+test_expr "set variable v_unsigned_char=~0" "print v_unsigned_char != 0" "\\$\[0-9\]* = $true"  "print v_unsigned_char != (unsigned char)~0" "\\$\[0-9\]* = $false"  "print v_unsigned_char != ~0" "\\$\[0-9\]* = $true" "print unsigned char != (~0)"
 test_expr "set variable v_unsigned_char=~0" "print v_unsigned_char < 0" "\\$\[0-9\]* = $false"  "print v_unsigned_char < 127" "\\$\[0-9\]* = $false"  "print unsigned char < (~0)"
 test_expr "set variable v_unsigned_char=~0" "print v_unsigned_char > 0" "\\$\[0-9\]* = $true"  "print v_unsigned_char > 127" "\\$\[0-9\]* = $true"  "print unsigned char > (~0)"
 #
@@ -140,7 +131,7 @@ test_expr "set variable v_unsigned_short=0x7FFF" "print v_unsigned_short != 0" "
 test_expr "set variable v_unsigned_short=0x7FFF" "print v_unsigned_short < 0" "\\$\[0-9\]* = $false"  "print v_unsigned_short < 0x7FFF" "\\$\[0-9\]* = $false"  "print unsigned short <"
 test_expr "set variable v_unsigned_short=0x7FFF" "print v_unsigned_short > 0" "\\$\[0-9\]* = $true"  "print v_unsigned_short > 0x7FFF" "\\$\[0-9\]* = $false"  "print unsigned short >"
 # make short a minus
-test_expr "set variable v_unsigned_short=~0" "print v_unsigned_short == 0" "\\$\[0-9\]* = $false"  "print v_unsigned_short == ~0" "\\$\[0-9\]* = $false"  "print v_unsigned_short == (unsigned short)~0" "\\$\[0-9\]* = $true"  "print unsigned short == (~0)"
+test_expr "set variable v_unsigned_short=~0" "print v_unsigned_short == 0" "\\$\[0-9\]* = $false"  "print sizeof (v_unsigned_short) < sizeof (~0) && v_unsigned_short == ~0" "\\$\[0-9\]* = $false"  "print v_unsigned_short == (unsigned short)~0" "\\$\[0-9\]* = $true"  "print unsigned short == (~0)"
 test_expr "set variable v_unsigned_short=~0" "print v_unsigned_short != 0" "\\$\[0-9\]* = $true"  "print v_unsigned_short != (unsigned short)~0" "\\$\[0-9\]* = $false"  "print unsigned short != (~0)"
 test_expr "set variable v_unsigned_short=~0" "print v_unsigned_short < 0" "\\$\[0-9\]* = $false"  "print v_unsigned_short < 0x7FFF" "\\$\[0-9\]* = $false"  "print unsigned short < (~0)"
 test_expr "set variable v_unsigned_short=~0" "print v_unsigned_short > 0" "\\$\[0-9\]* = $true"  "print v_unsigned_short > 0x7FFF" "\\$\[0-9\]* = $true"  "print unsigned short > (~0)"
@@ -238,11 +229,11 @@ test_expr "set variable v_unsigned_long = 0" "print (void*)v_unsigned_long" "\\$
 #
 send_gdb "print sizeof (long long) > sizeof (long)\n"
 gdb_expect {
-    -re "\\$\[0-9\]* = $true" {
+    -re "\\$\[0-9\]* = $true.*$gdb_prompt" {
        set ok 1
        pass "sizeof (long long) > sizeof (long) (true)"
     }
-    -re "\\$\[0-9\]* = $false" {
+    -re "\\$\[0-9\]* = $false.*$gdb_prompt" {
        set ok 0
        pass "sizeof (long long) > sizeof (long) (false)"
     }
@@ -257,3 +248,14 @@ gdb_test "print (void*) ((long long) (unsigned long) -1 + 1)" \
 if [expr ! $ok] { setup_xfail "*-*-*" }
 gdb_test "print (void*) (~((long long)(unsigned long) -1) - 1)" \
        "warning: value truncated.*" "truncate (void*) 0xffffffff00000000 - 1"
+
+# String concatentation.
+test_expr "print \"x\" \"y\"" "\\$\[0-9\]* = \"xy\""
+test_expr "print \"x\" \"y\" \"z\"" "\\$\[0-9\]* = \"xyz\""
+
+# Enum formatting tests.
+test_expr "print red" "\\$\[0-9\]* = red"
+gdb_test "set output-radix 8" ""
+test_expr "print red" "\\$\[0-9\]* = red"
+test_expr "print/d red" "\\$\[0-9\]* = 0"
+gdb_test "set output-radix 10" ""