OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [insight/] [gdb/] [testsuite/] [gdb.base/] [arithmet.exp] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 578 markom
# Copyright 1998, 1999, 2001 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 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
# Please email any bugs, comments, and/or additions to this file to:
18
# bug-gdb@prep.ai.mit.edu
19
 
20
# This file was written by Elena Zannoni (ezannoni@cygnus.com)
21
# Rewritten to use gdb_test by Michael Chastain (chastain@redhat.com)
22
 
23
# This file is part of the gdb testsuite
24
#
25
# tests for correctness of arithmetic operators, associativity and precedence
26
# with integer type variables
27
#
28
 
29
if $tracelevel then {
30
        strace $tracelevel
31
        }
32
 
33
#
34
# test running programs
35
#
36
set prms_id 0
37
set bug_id 0
38
 
39
set testfile "int-type"
40
set srcfile ${testfile}.c
41
set binfile ${objdir}/${subdir}/${testfile}
42
 
43
if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-w}] != "" } {
44
     gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
45
    }
46
 
47
gdb_exit
48
gdb_start
49
gdb_reinitialize_dir $srcdir/$subdir
50
gdb_load ${binfile}
51
 
52
 
53
#
54
# set it up at a breakpoint so we can play with the variable values
55
#
56
 
57
if ![runto_main] then {
58
    perror "couldn't run to breakpoint"
59
    continue
60
}
61
 
62
#
63
# test expressions with "int" types
64
#
65
 
66
gdb_test "set variable x=14" ""
67
gdb_test "set variable y=2"  ""
68
gdb_test "set variable z=2"  ""
69
gdb_test "set variable w=3"  ""
70
 
71
gdb_test "print x" "14"
72
gdb_test "print y"  "2"
73
gdb_test "print z"  "2"
74
gdb_test "print w"  "3"
75
 
76
gdb_test "print x+y" "16"
77
gdb_test "print x-y" "12"
78
gdb_test "print x*y" "28"
79
gdb_test "print x/y"  "7"
80
gdb_test "print x%y"  "0"
81
 
82
#  x  y  z  w
83
# 14  2  2  3
84
 
85
# Test associativity of +, -, *, % ,/
86
 
87
gdb_test "print x+y+z" "18"
88
gdb_test "print x-y-z" "10"
89
gdb_test "print x*y*z" "56"
90
gdb_test "print x/y/z"  "3"
91
gdb_test "print x%y%z"  "0"
92
 
93
# test precedence rules on pairs of arithmetic operators
94
 
95
gdb_test "set variable x=10" ""
96
gdb_test "set variable y=4"  ""
97
gdb_test "set variable z=2"  ""
98
 
99
#  x  y  z  w
100
# 10  4  2  3
101
 
102
gdb_test "print x+y-z" "12"
103
gdb_test "print x+y*z" "18"
104
 
105
#  x  y  z  w
106
# 10  4  3  3
107
 
108
gdb_test "set variable z=3"  ""
109
gdb_test "print x+y%z" "11"
110
gdb_test "print x+y/z" "11"
111
 
112
#  x  y  z  w
113
# 10  4  2  3
114
 
115
gdb_test "set variable z=2"  ""
116
gdb_test "print x-y*z"  "2"
117
gdb_test "print x-y%z" "10"
118
gdb_test "print x-y/z"  "8"
119
gdb_test "print x*y/z" "20"
120
 
121
#  x  y  z  w
122
# 10  4  3  3
123
 
124
gdb_test "set variable z=3"  ""
125
gdb_test "print x*y%z"  "1"
126
gdb_test "print x/y%z"  "2"
127
 
128
# test use of parentheses to enforce different order of evaluation
129
 
130
gdb_test "print x-(y+z)"  "3"
131
gdb_test "print x/(y*z)"  "0"
132
gdb_test "print x-(y/z)"  "9"
133
gdb_test "print (x+y)*z" "42"

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.