OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [gnu-src/] [gdb-7.1/] [gdb/] [testsuite/] [gdb.base/] [arithmet.exp] - Blame information for rev 252

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 227 jeremybenn
# Copyright 1998, 1999, 2001, 2007, 2008, 2009, 2010
2
# Free Software Foundation, Inc.
3
 
4
# This program is free software; you can redistribute it and/or modify
5
# it under the terms of the GNU General Public License as published by
6
# the Free Software Foundation; either version 3 of the License, or
7
# (at your option) any later version.
8
#
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
# GNU General Public License for more details.
13
#
14
# You should have received a copy of the GNU General Public License
15
# along with this program.  If not, see .
16
 
17
# This file was written by Elena Zannoni (ezannoni@cygnus.com)
18
# Rewritten to use gdb_test by Michael Chastain (chastain@redhat.com)
19
 
20
# This file is part of the gdb testsuite
21
#
22
# tests for correctness of arithmetic operators, associativity and precedence
23
# with integer type variables
24
#
25
 
26
if $tracelevel then {
27
        strace $tracelevel
28
        }
29
 
30
#
31
# test running programs
32
#
33
set prms_id 0
34
set bug_id 0
35
 
36
set testfile "int-type"
37
set srcfile ${testfile}.c
38
set binfile ${objdir}/${subdir}/${testfile}
39
 
40
if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } {
41
     untested arithmet.exp
42
     return -1
43
    }
44
 
45
gdb_exit
46
gdb_start
47
gdb_reinitialize_dir $srcdir/$subdir
48
gdb_load ${binfile}
49
 
50
 
51
#
52
# set it up at a breakpoint so we can play with the variable values
53
#
54
 
55
if ![runto_main] then {
56
    perror "couldn't run to breakpoint"
57
    continue
58
}
59
 
60
#
61
# test expressions with "int" types
62
#
63
 
64
gdb_test "set variable x=14" ""
65
gdb_test "set variable y=2"  ""
66
gdb_test "set variable z=2"  ""
67
gdb_test "set variable w=3"  ""
68
 
69
gdb_test "print x" "14"
70
gdb_test "print y"  "2"
71
gdb_test "print z"  "2"
72
gdb_test "print w"  "3"
73
 
74
gdb_test "print x+y" "16"
75
gdb_test "print x-y" "12"
76
gdb_test "print x*y" "28"
77
gdb_test "print x/y"  "7"
78
gdb_test "print x%y"  "0"
79
 
80
#  x  y  z  w
81
# 14  2  2  3
82
 
83
# Test associativity of +, -, *, % ,/
84
 
85
gdb_test "print x+y+z" "18"
86
gdb_test "print x-y-z" "10"
87
gdb_test "print x*y*z" "56"
88
gdb_test "print x/y/z"  "3"
89
gdb_test "print x%y%z"  "0"
90
 
91
# test precedence rules on pairs of arithmetic operators
92
 
93
gdb_test "set variable x=10" ""
94
gdb_test "set variable y=4"  ""
95
 
96
#  x  y  z  w
97
# 10  4  2  3
98
 
99
gdb_test "print x+y-z" "12"
100
gdb_test "print x+y*z" "18"
101
gdb_test "print x+y%w" "11"
102
gdb_test "print x+y/w" "11"
103
gdb_test "print x-y*z"  "2"
104
gdb_test "print x-y%z" "10"
105
gdb_test "print x-y/z"  "8"
106
gdb_test "print x*y/z" "20"
107
gdb_test "print x*y%w"  "1"
108
gdb_test "print x/y%w"  "2"
109
 
110
# test use of parentheses to enforce different order of evaluation
111
 
112
gdb_test "print x-(y+w)"  "3"
113
gdb_test "print x/(y*w)"  "0"
114
gdb_test "print x-(y/w)"  "9"
115
gdb_test "print (x+y)*w" "42"

powered by: WebSVN 2.1.0

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