/
breakpoint_test.rb
168 lines (142 loc) · 5.52 KB
/
breakpoint_test.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
require File.join(File.dirname(__FILE__), '..', '..', 'test_helper')
class MonitorBreakpointOperationTest < Test::Unit::TestCase
context "#breakpoint" do
setup do
@monitor = Antiquitas::Monitor.new
end
context "no address" do
should "print out the breakpoints, sorted by address" do
bp = Antiquitas::Monitor::Breakpoint.new(0x0080)
bp2 = Antiquitas::Monitor::Breakpoint.new(0x0040)
mock(@monitor).puts(bp)
mock(@monitor).puts(bp2)
@monitor.breakpoints << bp
@monitor.breakpoints << bp2
@monitor.breakpoint
end
end
context "with address" do
setup do
@address = 0x69
end
context "no current breakpoint with address" do
should "create a new breakpoint with the address and add it to the list" do
@monitor.breakpoint(:address => @address)
assert_equal 1, @monitor.breakpoints.length
assert_equal @address, @monitor.breakpoints.first.address
end
end
context "current breakpoint with address, no condition" do
setup do
@monitor.breakpoint(:address => @address)
end
context "breakpoint enabled" do
should "disable the breakpoint, but not remove it" do
assert_equal true, @monitor.breakpoints.first.enabled
@monitor.breakpoint(:address => @address)
assert_equal 1, @monitor.breakpoints.length
assert_equal @address, @monitor.breakpoints.first.address
assert !@monitor.breakpoints.first.enabled
end
end
context "breakpoint disabled" do
setup do
@monitor.breakpoints.first.enabled = false
end
should "enable the breakpoint" do
@monitor.breakpoint(:address => @address)
assert_equal 1, @monitor.breakpoints.length
assert_equal @address, @monitor.breakpoints.first.address
assert @monitor.breakpoints.first.enabled
end
end
end
context "current breakpoint with address and condition" do
setup do
@monitor.breakpoint(:address => @address, :condition => "@flag[:Z] == 1")
end
context "breakpoint enabled" do
should "disable the breakpoint, but not remove it" do
assert_equal true, @monitor.breakpoints.first.enabled
@monitor.breakpoint(:address => @address)
assert_equal 1, @monitor.breakpoints.length
assert_equal @address, @monitor.breakpoints.first.address
assert !@monitor.breakpoints.first.enabled
end
end
context "breakpoint disabled" do
setup do
@monitor.breakpoints.first.enabled = false
end
should "enable the breakpoint" do
@monitor.breakpoint(:address => @address)
assert_equal 1, @monitor.breakpoints.length
assert_equal @address, @monitor.breakpoints.first.address
assert @monitor.breakpoints.first.enabled
end
end
end
end
context "with address and condition" do
setup do
@address = 0x69
@condition = "@foo = bar"
end
context "no current breakpoint with address" do
should "create a new breakpoint with the address and condition and add it to the list" do
@monitor.breakpoint(:address => @address, :condition => @condition)
assert_equal 1, @monitor.breakpoints.length
assert_equal @address, @monitor.breakpoints.first.address
assert_equal @condition, @monitor.breakpoints.first.condition
end
end
context "current breakpoint with address, no condition" do
setup do
@monitor.breakpoint(:address => @address)
@monitor.breakpoint(:address => @address, :condition => @condition)
end
should "set the condition on the breakpoint to the passed value" do
assert_equal @condition, @monitor.breakpoints.first.condition
end
should "not change the breakpoint's enabled status" do
assert @monitor.breakpoints.first.enabled
end
end
context "current breakpoint with address and different condition" do
setup do
@monitor.breakpoint(:address => @address, :condition => "foo == bar")
@monitor.breakpoint(:address => @address, :condition => @condition)
end
should "set the condition on the breakpoint to the passed value" do
assert_equal @condition, @monitor.breakpoints.first.condition
end
should "not change the breakpoint's enabled status" do
assert @monitor.breakpoints.first.enabled
end
end
context "current breakpoint with address and same condition" do
setup do
@monitor.breakpoint(:address => @address, :condition => @condition)
end
context "breakpoint enabled" do
setup do
@monitor.breakpoints.first.enabled = true
@monitor.breakpoint(:address => @address, :condition => @condition)
end
should "disable the breakpoint" do
assert !@monitor.breakpoints.first.enabled
end
end
context "breakpoint disabled" do
setup do
@monitor.breakpoints.first.enabled = false
@monitor.breakpoint(:address => @address, :condition => @condition)
end
should "enable the breakpoint" do
assert @monitor.breakpoints.first.enabled
end
end
end
end
end
end