From: Michael Chastain Date: Sat, 23 Jun 2001 05:22:46 +0000 (+0000) Subject: 2001-06-22 Michael Chastain X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=b4127474dc299137263682431108e1a021d6dbb4;p=binutils-gdb.git 2001-06-22 Michael Chastain * gdb.base/arithmet.exp: Use gdb_test instead of send_gdb/gdb_expect. This is operationally compatible with the previous version. --- diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 3a36f34c978..7710d10f403 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2001-06-22 Michael Chastain + + * gdb.base/arithmet.exp: Use gdb_test instead of send_gdb/gdb_expect. + This is operationally compatible with the previous version. + 2001-06-13 Jim Blandy * lib/gdb.exp (gdb_test): Doc fix. diff --git a/gdb/testsuite/gdb.base/arithmet.exp b/gdb/testsuite/gdb.base/arithmet.exp index 16f2cda7f42..57afc8d7cf2 100644 --- a/gdb/testsuite/gdb.base/arithmet.exp +++ b/gdb/testsuite/gdb.base/arithmet.exp @@ -1,4 +1,4 @@ -# Copyright 1998, 1999 Free Software Foundation, Inc. +# Copyright 1998, 1999, 2001 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 @@ -18,6 +18,7 @@ # bug-gdb@prep.ai.mit.edu # This file was written by Elena Zannoni (ezannoni@cygnus.com) +# Rewritten to use gdb_test by Michael Chastain (chastain@redhat.com) # This file is part of the gdb testsuite # @@ -62,314 +63,71 @@ if ![runto_main] then { # test expressions with "int" types # -gdb_test "set variable x=14" "" "set variable x=14" -gdb_test "set variable y=2" "" "set variable y=2" -gdb_test "set variable z=2" "" "set variable z=2" -gdb_test "set variable w=3" "" "set variable w=3" - -send_gdb "print x\n" -gdb_expect { - -re ".*14.*$gdb_prompt $" { - pass "print value of x" - } - -re ".*$gdb_prompt $" { fail "print value of x" } - timeout { fail "(timeout) print value of x" } - } - - -send_gdb "print y\n" -gdb_expect { - -re ".*2.*$gdb_prompt $" { - pass "print value of y" - } - -re ".*$gdb_prompt $" { fail "print value of y" } - timeout { fail "(timeout) print value of y" } - } - -send_gdb "print z\n" -gdb_expect { - -re ".*2.*$gdb_prompt $" { - pass "print value of z" - } - -re ".*$gdb_prompt $" { fail "print value of z" } - timeout { fail "(timeout) print value of z" } - } - -send_gdb "print w\n" -gdb_expect { - -re ".*3.*$gdb_prompt $" { - pass "print value of w" - } - -re ".*$gdb_prompt $" { fail "print value of w" } - timeout { fail "(timeout) print value of w" } - } - - - -send_gdb "print x+y\n" -gdb_expect { - -re ".*16.*$gdb_prompt $" { - pass "print value of x+y" - } - -re ".*$gdb_prompt $" { fail "print value of x+y" } - timeout { fail "(timeout) print value of x+y" } - } - -send_gdb "print x-y\n" -gdb_expect { - -re ".*12.*$gdb_prompt $" { - pass "print value of x-y" - } - -re ".*$gdb_prompt $" { fail "print value of x-y" } - timeout { fail "(timeout) print value of x-y" } - } - -send_gdb "print x*y\n" -gdb_expect { - -re ".*28.*$gdb_prompt $" { - pass "print value of x*y" - } - -re ".*$gdb_prompt $" { fail "print value of x*y" } - timeout { fail "(timeout) print value of x*y" } - } - -send_gdb "print x/y\n" -gdb_expect { - -re ".*7.*$gdb_prompt $" { - pass "print value of x/y" - } - -re ".*$gdb_prompt $" { fail "print value of x/y" } - timeout { fail "(timeout) print value of x/y" } - } - -send_gdb "print x%y\n" -gdb_expect { - -re ".*0.*$gdb_prompt $" { - pass "print value of x%y" - } - -re ".*$gdb_prompt $" { fail "print value of x%y" } - timeout { fail "(timeout) print value of x%y" } - } - - +gdb_test "set variable x=14" "" +gdb_test "set variable y=2" "" +gdb_test "set variable z=2" "" +gdb_test "set variable w=3" "" + +gdb_test "print x" "14" +gdb_test "print y" "2" +gdb_test "print z" "2" +gdb_test "print w" "3" + +gdb_test "print x+y" "16" +gdb_test "print x-y" "12" +gdb_test "print x*y" "28" +gdb_test "print x/y" "7" +gdb_test "print x%y" "0" + +# x y z w +# 14 2 2 3 # Test associativity of +, -, *, % ,/ - -send_gdb "print x+y+z\n" -gdb_expect { - -re ".*18.*$gdb_prompt $" { - pass "print value of x+y" - } - -re ".*$gdb_prompt $" { fail "print value of x+y" } - timeout { fail "(timeout) print value of x+y" } - } - -send_gdb "print x-y-z\n" -gdb_expect { - -re ".*10.*$gdb_prompt $" { - pass "print value of x-y" - } - -re ".*$gdb_prompt $" { fail "print value of x-y" } - timeout { fail "(timeout) print value of x-y" } - } - -send_gdb "print x*y*z\n" -gdb_expect { - -re ".*56.*$gdb_prompt $" { - pass "print value of x*y" - } - -re 8".*$gdb_prompt $" { fail "print value of x*y" } - timeout { fail "(timeout) print value of x*y" } - } - -send_gdb "print x/y/z\n" -gdb_expect { - -re ".*3.*$gdb_prompt $" { - pass "print value of x/y" - } - -re ".*$gdb_prompt $" { fail "print value of x/y" } - timeout { fail "(timeout) print value of x/y" } - } - -send_gdb "print x%y%z\n" -gdb_expect { - -re ".*0.*$gdb_prompt $" { - pass "print value of x%y" - } - -re ".*$gdb_prompt $" { fail "print value of x%y" } - timeout { fail "(timeout) print value of x%y" } - } - +gdb_test "print x+y+z" "18" +gdb_test "print x-y-z" "10" +gdb_test "print x*y*z" "56" +gdb_test "print x/y/z" "3" +gdb_test "print x%y%z" "0" # test precedence rules on pairs of arithmetic operators -gdb_test "set variable x=10" "" "set variable x" -gdb_test "set variable y=4" "" "set variable y" -gdb_test "set variable z=2" "" "set variable z" - - - -# x y z -# 10 4 2 -send_gdb "print x+y-z\n" -gdb_expect { - -re ".*12.*$gdb_prompt $" { - pass "print value of x+y-z" - } - -re ".*$gdb_prompt $" { fail "print value of x+y-z" } - timeout { fail "(timeout) print value of x+y-z" } - } - -# 10 4 2 -send_gdb "print x+y*z\n" -gdb_expect { - -re ".*18.*$gdb_prompt $" { - pass "print value of x+y*z" - } - -re ".*$gdb_prompt $" { fail "print value of x+y*z" } - timeout { fail "(timeout) print value of x+y*z" } - } - - -gdb_test "set variable z=3" "" "set variable z" - - -# 10 4 3 -send_gdb "print x+y%z\n" -gdb_expect { - -re ".*11.*$gdb_prompt $" { - pass "print value of x+y%z" - } - -re ".*$gdb_prompt $" { fail "print value of x+y%z" } - timeout { fail "(timeout) print value of x+y%z" } - } - - -# 10 4 3 -send_gdb "print x+y/z\n" -gdb_expect { - -re ".*11.*$gdb_prompt $" { - pass "print value of x+y/z" - } - -re ".*$gdb_prompt $" { fail "print value of x+y/z" } - timeout { fail "(timeout) print value of x+y/z" } - } - -gdb_test "set variable z=2" "" " set variable z" - - -# 10 4 2 -send_gdb "print x-y*z\n" -gdb_expect { - -re ".*2.*$gdb_prompt $" { - pass "print value of x-y*z" - } - -re ".*$gdb_prompt $" { fail "print value of x-y*z" } - timeout { fail "(timeout) print value of x-y*z" } - } - -# 10 4 2 -send_gdb "print x-y%z\n" -gdb_expect { - -re ".*10.*$gdb_prompt $" { - pass "print value of x-y%z" - } - -re ".*$gdb_prompt $" { fail "print value of x-y%z" } - timeout { fail "(timeout) print value of x-y%z" } - } - - -# 10 4 2 -send_gdb "print x-y/z\n" -gdb_expect { - -re ".*8.*$gdb_prompt $" { - pass "print value of x-y/z" - } - -re ".*$gdb_prompt $" { fail "print value of x-y/z" } - timeout { fail "(timeout) print value of x-y/z" } - } - -# 10 4 2 -send_gdb "print x*y/z\n" -gdb_expect { - -re ".*20.*$gdb_prompt $" { - pass "print value of x*y/z" - } - -re ".*$gdb_prompt $" { fail "print value of x*y/z" } - timeout { fail "(timeout) print value of x*y/z" } - } - -gdb_test "set variable z=3" "" "set z to 3" - -# 10 4 3 -send_gdb "print x*y%z\n" -gdb_expect { - -re ".*1.*$gdb_prompt $" { - pass "print value of x*y%z" - } - -re ".*$gdb_prompt $" { fail "print value of x*y%z" } - timeout { fail "(timeout) print value of x*y%z" } - } - -# 10 4 3 -send_gdb "print x/y%z\n" -gdb_expect { - -re ".*2\r\n$gdb_prompt $" { - pass "print value of x/y%z" - } - -re ".*$gdb_prompt $" { fail "print value of x/y%z" } - timeout { fail "(timeout) print value of x/y%z" } - } - - - -# test use of parenthesis to enforce different order of evaluation - -# 10 4 3 -send_gdb "print x-(y+z)\n" -gdb_expect { - -re ".*3\r\n$gdb_prompt $" { - pass "print value of x-(y+z)" - } - -re ".*$gdb_prompt $" { fail "print value of x-(y+z)" } - timeout { fail "(timeout) print value of x-(y+z)" } - } - +gdb_test "set variable x=10" "" +gdb_test "set variable y=4" "" +gdb_test "set variable z=2" "" -# 10 4 3 -send_gdb "print x/(y*z)\n" -gdb_expect { - -re ".*0\r\n$gdb_prompt $" { - pass "print value of x/(y*z)" - } - -re ".*$gdb_prompt $" { fail "print value of x/(y*z)" } - timeout { fail "(timeout) print value of x/(y*z)" } - } +# x y z w +# 10 4 2 3 -# 10 4 3 -send_gdb "print x-(y/z)\n" -gdb_expect { - -re ".*9\r\n$gdb_prompt $" { - pass "print value of x-(y/z)" - } - -re ".*$gdb_prompt $" { fail "print value of x-(y/z)" } - timeout { fail "(timeout) print value of x-(y/z)" } - } +gdb_test "print x+y-z" "12" +gdb_test "print x+y*z" "18" +# x y z w +# 10 4 3 3 -# 10 4 3 -send_gdb "print (x+y)*z\n" -gdb_expect { - -re ".*42\r\n$gdb_prompt $" { - pass "print value of (x+y)*z" - } - -re ".*$gdb_prompt $" { fail "print value of (x+y)*z" } - timeout { fail "(timeout) print value of (x+y)*z" } - } +gdb_test "set variable z=3" "" +gdb_test "print x+y%z" "11" +gdb_test "print x+y/z" "11" +# x y z w +# 10 4 2 3 +gdb_test "set variable z=2" "" +gdb_test "print x-y*z" "2" +gdb_test "print x-y%z" "10" +gdb_test "print x-y/z" "8" +gdb_test "print x*y/z" "20" +# x y z w +# 10 4 3 3 +gdb_test "set variable z=3" "" +gdb_test "print x*y%z" "1" +gdb_test "print x/y%z" "2" +# test use of parentheses to enforce different order of evaluation +gdb_test "print x-(y+z)" "3" +gdb_test "print x/(y*z)" "0" +gdb_test "print x-(y/z)" "9" +gdb_test "print (x+y)*z" "42"