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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gdb-6.8/] [gdb/] [testsuite/] [gdb.base/] [ifelse.exp] - Blame information for rev 178

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

Line No. Rev Author Line
1 24 jeremybenn
# Copyright 2006, 2007, 2008 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 3 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, see .
15
 
16
# This test checks that the if .. else .. end construct works and may
17
# contain empty bodies without crashing.
18
 
19
if $tracelevel then {
20
    strace $tracelevel
21
}
22
 
23
gdb_exit
24
gdb_start
25
 
26
# First test that the if command works with an empty body
27
# Test with different conditions because the body is ignored
28
# if it is not executed.
29
 
30
#    with true condition
31
set message "if 1 with empty body"
32
gdb_test_multiple "if 1\nend" $message {
33
    -re "$gdb_prompt $" {pass $message}
34
    eof {
35
        fail "$message (crashed)"
36
        gdb_exit
37
        gdb_start
38
    }
39
}
40
 
41
#    with false condition
42
set message "if 0 with empty body"
43
gdb_test_multiple "if 0\nend" $message {
44
    -re "$gdb_prompt $" {pass $message}
45
    eof {
46
        fail "$message (crashed)"
47
        gdb_exit
48
        gdb_start
49
    }
50
}
51
 
52
# Second, do the same tests with an empty else body.
53
# This fails in GDB <=6.5
54
 
55
# Unfortunately it was an uninitialised memory problem so
56
# sometimes it just works. Preceed it with an if else end with
57
# bodies and hopefully the memory with be dirty and the problem
58
# will show itself (this works at time of writing).
59
 
60
gdb_test "if 1\necho true\\n\nelse\necho false\\n\nend" "true" ""
61
 
62
#    with true condition
63
set message "if 1 .. else with empty body"
64
gdb_test_multiple "if 1\nelse\nend" $message {
65
    -re "$gdb_prompt $" {pass $message}
66
    eof {
67
        fail "$message (crashed)"
68
        gdb_exit
69
        gdb_start
70
    }
71
}
72
 
73
# dirty memory
74
gdb_test "if 1\necho true\\n\nelse\necho false\\n\nend" "true" ""
75
 
76
#    with false condition
77
set message "if 0 .. else with empty body"
78
gdb_test_multiple "if 0\nelse\nend" $message {
79
    -re "$gdb_prompt $" {pass $message}
80
    eof {
81
        fail "$message (crashed)"
82
        gdb_exit
83
        gdb_start
84
    }
85
}
86
 
87
gdb_test "set confirm off" "" ""
88
 
89
# Test that a define with an empty else can be replaced.
90
# If there is memory corruption then free will fail.
91
# dirty memory
92
gdb_test "if 1\necho true\\n\nelse\necho false\\n\nend" "true" ""
93
# create
94
gdb_test "define abc\nif 1\nelse\nend\nend" "" "create define with empty else"
95
# call (note that condition is 1 so should pass)
96
gdb_test "abc" "" "call original define"
97
# replace
98
set message "replace define with if .. else with empty body"
99
gdb_test_multiple "define abc\necho got here\\n\nend" $message {
100
    -re "$gdb_prompt $" {pass $message}
101
    eof {fail "$message (crashed)"}
102
}
103
# call
104
gdb_test "abc" "got here" "call replacement define"

powered by: WebSVN 2.1.0

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