roku_builder 4.25.4 → 4.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/intergration/roku_builder/test_helper.rb +2 -3
- data/intergration/roku_builder/test_profiler.rb +1 -1
- data/lib/roku_builder/config_parser.rb +4 -5
- data/lib/roku_builder/device_manager.rb +100 -0
- data/lib/roku_builder/plugins/core.rb +3 -1
- data/lib/roku_builder/plugins/indentation_inspector.rb +2 -2
- data/lib/roku_builder/plugins/inspector.rb +36 -26
- data/lib/roku_builder/plugins/line_inspector.rb +27 -6
- data/lib/roku_builder/plugins/linker.rb +29 -22
- data/lib/roku_builder/plugins/loader.rb +30 -11
- data/lib/roku_builder/plugins/monitor.rb +19 -17
- data/lib/roku_builder/plugins/navigator.rb +40 -34
- data/lib/roku_builder/plugins/packager.rb +109 -92
- data/lib/roku_builder/plugins/profiler.rb +24 -15
- data/lib/roku_builder/plugins/tester.rb +15 -13
- data/lib/roku_builder/util.rb +39 -17
- data/lib/roku_builder/version.rb +1 -1
- data/lib/roku_builder.rb +3 -19
- data/roku_builder.gemspec +3 -2
- data/test/roku_builder/plugins/test_analyzer.rb +19 -10
- data/test/roku_builder/plugins/test_core.rb +2 -3
- data/test/roku_builder/plugins/test_inspector.rb +48 -8
- data/test/roku_builder/plugins/test_linker.rb +66 -10
- data/test/roku_builder/plugins/test_loader.rb +44 -15
- data/test/roku_builder/plugins/test_monitor.rb +33 -16
- data/test/roku_builder/plugins/test_navigator.rb +55 -14
- data/test/roku_builder/plugins/test_packager.rb +118 -34
- data/test/roku_builder/plugins/test_profiler.rb +153 -78
- data/test/roku_builder/plugins/test_tester.rb +20 -5
- data/test/roku_builder/test_device_manager.rb +187 -0
- data/test/roku_builder/test_files/analyzer_test/dont_use_hello_world.json +11 -0
- data/test/roku_builder/test_files/analyzer_test/linter_positive_match.json +13 -0
- data/test/roku_builder/test_helper.rb +6 -0
- data/test/roku_builder/test_roku_builder.rb +5 -42
- metadata +27 -6
@@ -10,9 +10,12 @@ module RokuBuilder
|
|
10
10
|
RokuBuilder.setup_plugins
|
11
11
|
register_plugins(Packager)
|
12
12
|
@requests = []
|
13
|
+
@device_manager = Minitest::Mock.new
|
13
14
|
end
|
14
15
|
def teardown
|
15
16
|
@requests.each {|req| remove_request_stub(req)}
|
17
|
+
@device_manager.verify
|
18
|
+
clean_device_locks()
|
16
19
|
end
|
17
20
|
def test_packager_parse_options_long
|
18
21
|
parser = OptionParser.new
|
@@ -61,6 +64,10 @@ module RokuBuilder
|
|
61
64
|
end
|
62
65
|
def test_packager_package_failed
|
63
66
|
config, options = build_config_options_objects(PackagerTest, {package: true, stage: "production"}, false)
|
67
|
+
device = RokuBuilder::Device.new("roku", config.raw[:devices][:roku])
|
68
|
+
@device_manager.expect(:reserve_device, device, no_lock: false)
|
69
|
+
@device_manager.expect(:release_device, nil, [device])
|
70
|
+
|
64
71
|
@requests.push(stub_request(:post, "http://192.168.0.100:8060/keypress/Home").
|
65
72
|
to_return(status: 200, body: "", headers: {}))
|
66
73
|
@requests.push(stub_request(:post, "http://192.168.0.100/plugin_install").
|
@@ -68,8 +75,10 @@ module RokuBuilder
|
|
68
75
|
@requests.push(stub_request(:post, "http://192.168.0.100/plugin_package").
|
69
76
|
to_return(status: 200, body: "Failed: Error.", headers: {}))
|
70
77
|
packager = Packager.new(config: config)
|
71
|
-
|
72
|
-
|
78
|
+
RokuBuilder.stub(:device_manager, @device_manager) do
|
79
|
+
assert_raises ExecutionError do
|
80
|
+
packager.package(options: options)
|
81
|
+
end
|
73
82
|
end
|
74
83
|
end
|
75
84
|
def test_packager_package
|
@@ -88,9 +97,13 @@ module RokuBuilder
|
|
88
97
|
@requests.push(stub_request(:get, "http://192.168.0.100/pkgs/pkg_url").
|
89
98
|
to_return(status: 200, body: body, headers: {}))
|
90
99
|
|
91
|
-
|
100
|
+
device = RokuBuilder::Device.new("roku", config.raw[:devices][:roku])
|
101
|
+
@device_manager.expect(:reserve_device, device, no_lock: false)
|
102
|
+
@device_manager.expect(:release_device, nil, [device])
|
103
|
+
|
104
|
+
loader.expect(:sideload, nil, options: Hash, device: device)
|
92
105
|
io.expect(:write, nil, ["package_body"])
|
93
|
-
inspector.expect(:inspect, nil,
|
106
|
+
inspector.expect(:inspect, nil, options: Hash, device: device)
|
94
107
|
|
95
108
|
logger.expect(:debug, nil, [String])
|
96
109
|
io.expect(:each_line, nil)
|
@@ -101,12 +114,14 @@ module RokuBuilder
|
|
101
114
|
Logger.class_variable_set(:@@instance, logger)
|
102
115
|
packager = Packager.new(config: config)
|
103
116
|
dev_id = Proc.new {"#{Random.rand(999999999999)}"}
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
packager.
|
117
|
+
RokuBuilder.stub(:device_manager, @device_manager) do
|
118
|
+
Loader.stub(:new, loader) do
|
119
|
+
Time.stub(:now, Time.at(0)) do
|
120
|
+
File.stub(:open, nil, io) do
|
121
|
+
Inspector.stub(:new, inspector) do
|
122
|
+
packager.stub(:dev_id, dev_id) do
|
123
|
+
packager.package(options: options)
|
124
|
+
end
|
110
125
|
end
|
111
126
|
end
|
112
127
|
end
|
@@ -126,6 +141,10 @@ module RokuBuilder
|
|
126
141
|
config[:projects][:project1][:stages][:production][:squash] = true
|
127
142
|
config, options = build_config_options_objects(PackagerTest, {package: true, stage: "production", inspect_package: true, verbose: true}, false, config)
|
128
143
|
|
144
|
+
device = RokuBuilder::Device.new("roku", config.raw[:devices][:roku])
|
145
|
+
@device_manager.expect(:reserve_device, device, no_lock: false)
|
146
|
+
@device_manager.expect(:release_device, nil, [device])
|
147
|
+
|
129
148
|
@requests.push(stub_request(:post, "http://192.168.0.100/plugin_inspect").
|
130
149
|
to_return(status: 200, body: "", headers: {}).times(2))
|
131
150
|
body = "<a href=\"pkgs\">pkg_url</a>"
|
@@ -135,10 +154,10 @@ module RokuBuilder
|
|
135
154
|
@requests.push(stub_request(:get, "http://192.168.0.100/pkgs/pkg_url").
|
136
155
|
to_return(status: 200, body: body, headers: {}))
|
137
156
|
|
138
|
-
loader.expect(:sideload, nil,
|
139
|
-
loader.expect(:squash, nil,
|
157
|
+
loader.expect(:sideload, nil, options: Hash, device: device)
|
158
|
+
loader.expect(:squash, nil, options: Hash, device: device)
|
140
159
|
io.expect(:write, nil, ["package_body"])
|
141
|
-
inspector.expect(:inspect, nil,
|
160
|
+
inspector.expect(:inspect, nil, options: Hash, device: device)
|
142
161
|
|
143
162
|
logger.expect(:debug, nil, [String])
|
144
163
|
io.expect(:each_line, nil)
|
@@ -149,12 +168,14 @@ module RokuBuilder
|
|
149
168
|
Logger.class_variable_set(:@@instance, logger)
|
150
169
|
packager = Packager.new(config: config)
|
151
170
|
dev_id = Proc.new {"#{Random.rand(999999999999)}"}
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
packager.
|
171
|
+
RokuBuilder.stub(:device_manager, @device_manager) do
|
172
|
+
Loader.stub(:new, loader) do
|
173
|
+
Time.stub(:now, Time.at(0)) do
|
174
|
+
File.stub(:open, nil, io) do
|
175
|
+
Inspector.stub(:new, inspector) do
|
176
|
+
packager.stub(:dev_id, dev_id) do
|
177
|
+
packager.package(options: options)
|
178
|
+
end
|
158
179
|
end
|
159
180
|
end
|
160
181
|
end
|
@@ -171,8 +192,16 @@ module RokuBuilder
|
|
171
192
|
to_return(status: 200, body: body, headers: {}))
|
172
193
|
|
173
194
|
config = build_config_options_objects(PackagerTest, {key: true, stage: "production"}, false)[0]
|
195
|
+
|
196
|
+
device = RokuBuilder::Device.new("roku", config.raw[:devices][:roku])
|
197
|
+
@device_manager.expect(:reserve_device, device, no_lock: false)
|
198
|
+
@device_manager.expect(:release_device, nil, [device])
|
199
|
+
|
174
200
|
packager = Packager.new(config: config)
|
175
|
-
dev_id =
|
201
|
+
dev_id = nil
|
202
|
+
RokuBuilder.stub(:device_manager, @device_manager) do
|
203
|
+
dev_id = packager.dev_id
|
204
|
+
end
|
176
205
|
|
177
206
|
assert_equal "dev_id", dev_id
|
178
207
|
end
|
@@ -182,8 +211,15 @@ module RokuBuilder
|
|
182
211
|
to_return(status: 200, body: body, headers: {}))
|
183
212
|
|
184
213
|
config = build_config_options_objects(PackagerTest, {key: true, stage: "production"}, false)[0]
|
214
|
+
device = RokuBuilder::Device.new("roku", config.raw[:devices][:roku])
|
215
|
+
@device_manager.expect(:reserve_device, device, no_lock: false)
|
216
|
+
@device_manager.expect(:release_device, nil, [device])
|
217
|
+
|
185
218
|
packager = Packager.new(config: config)
|
186
|
-
dev_id =
|
219
|
+
dev_id = nil
|
220
|
+
RokuBuilder.stub(:device_manager, @device_manager) do
|
221
|
+
dev_id = packager.dev_id
|
222
|
+
end
|
187
223
|
|
188
224
|
assert_equal "dev_id", dev_id
|
189
225
|
end
|
@@ -195,10 +231,16 @@ module RokuBuilder
|
|
195
231
|
logger.expect(:debug, nil) {|s| s =~ /\d* -> \d*/}
|
196
232
|
dev_id = Proc.new {"#{Random.rand(999999999999)}"}
|
197
233
|
config, options = build_config_options_objects(PackagerTest, {key: true, stage: "production"}, false)
|
234
|
+
device = RokuBuilder::Device.new("roku", config.raw[:devices][:roku])
|
235
|
+
@device_manager.expect(:reserve_device, device, no_lock: false)
|
236
|
+
@device_manager.expect(:release_device, nil, [device])
|
237
|
+
|
198
238
|
packager = Packager.new(config: config)
|
199
239
|
Logger.class_variable_set(:@@instance, logger)
|
200
|
-
|
201
|
-
packager.
|
240
|
+
RokuBuilder.stub(:device_manager, @device_manager) do
|
241
|
+
packager.stub(:dev_id, dev_id) do
|
242
|
+
packager.key(options: options)
|
243
|
+
end
|
202
244
|
end
|
203
245
|
end
|
204
246
|
|
@@ -210,9 +252,32 @@ module RokuBuilder
|
|
210
252
|
logger.expect(:debug, nil) {|s| s =~ /\d* -> \d*/}
|
211
253
|
dev_id = Proc.new {"#{Random.rand(999999999999)}"}
|
212
254
|
config, options = build_config_options_objects(PackagerTest, {key: true, stage: "production"}, false)
|
255
|
+
device = RokuBuilder::Device.new("roku", config.raw[:devices][:roku])
|
256
|
+
@device_manager.expect(:reserve_device, device, no_lock: false)
|
257
|
+
@device_manager.expect(:release_device, nil, [device])
|
258
|
+
|
213
259
|
packager = Packager.new(config: config)
|
214
260
|
Logger.class_variable_set(:@@instance, logger)
|
215
|
-
|
261
|
+
RokuBuilder.stub(:device_manager, @device_manager) do
|
262
|
+
packager.stub(:dev_id, dev_id) do
|
263
|
+
packager.key(options: options)
|
264
|
+
end
|
265
|
+
end
|
266
|
+
end
|
267
|
+
|
268
|
+
def test_packager_key_same_device
|
269
|
+
config, options = build_config_options_objects(PackagerTest, {key: true, stage: "production"}, false)
|
270
|
+
device = RokuBuilder::Device.new("roku", config.raw[:devices][:roku])
|
271
|
+
@device_manager.expect(:reserve_device, device, no_lock: false)
|
272
|
+
@device_manager.expect(:release_device, nil, [device])
|
273
|
+
|
274
|
+
body = "<p> Your Dev ID: <font face=\"Courier\">dev_id</font> </p>"
|
275
|
+
@requests.push(stub_request(:get, "http://192.168.0.100/plugin_package").
|
276
|
+
to_return(status: 200, body: body, headers: {}))
|
277
|
+
@requests.push(stub_request(:post, "http://192.168.0.100/plugin_inspect").
|
278
|
+
to_return(status: 200, body: "", headers: {}))
|
279
|
+
packager = Packager.new(config: config)
|
280
|
+
RokuBuilder.stub(:device_manager, @device_manager) do
|
216
281
|
packager.key(options: options)
|
217
282
|
end
|
218
283
|
end
|
@@ -230,9 +295,15 @@ module RokuBuilder
|
|
230
295
|
connection.expect(:close, nil, [])
|
231
296
|
|
232
297
|
config = build_config_options_objects(PackagerTest, {genkey: true}, false)[0]
|
298
|
+
device = RokuBuilder::Device.new("roku", config.raw[:devices][:roku])
|
299
|
+
@device_manager.expect(:reserve_device, device, no_lock: false)
|
300
|
+
@device_manager.expect(:release_device, nil, [device])
|
301
|
+
|
233
302
|
packager = Packager.new(config: config)
|
234
|
-
|
235
|
-
|
303
|
+
RokuBuilder.stub(:device_manager, @device_manager) do
|
304
|
+
Net::Telnet.stub(:new, connection) do
|
305
|
+
packager.send(:generate_new_key)
|
306
|
+
end
|
236
307
|
end
|
237
308
|
end
|
238
309
|
|
@@ -240,18 +311,22 @@ module RokuBuilder
|
|
240
311
|
config = good_config(PackagerTest)
|
241
312
|
config[:projects][:project1][:stages][:production].delete(:key)
|
242
313
|
config, options = build_config_options_objects(PackagerTest, {key: true, stage: "production"}, false, config)
|
314
|
+
device = RokuBuilder::Device.new("roku", config.raw[:devices][:roku])
|
315
|
+
@device_manager.expect(:reserve_device, device, no_lock: false)
|
316
|
+
@device_manager.expect(:release_device, nil, [device])
|
317
|
+
|
243
318
|
packager = Packager.new(config: config)
|
244
319
|
dev_id = Proc.new {"#{Random.rand(999999999999)}"}
|
245
320
|
assert_raises ExecutionError do
|
246
|
-
|
247
|
-
packager.
|
321
|
+
RokuBuilder.stub(:device_manager, @device_manager) do
|
322
|
+
packager.stub(:dev_id, dev_id) do
|
323
|
+
packager.key(options: options)
|
324
|
+
end
|
248
325
|
end
|
249
326
|
end
|
250
327
|
end
|
251
328
|
|
252
329
|
def test_packager_genkey
|
253
|
-
loader = Minitest::Mock.new
|
254
|
-
loader.expect(:sideload, nil, [Hash])
|
255
330
|
|
256
331
|
body = "<a href=\"pkgs\">pkg_url</a>"
|
257
332
|
@requests.push(stub_request(:post, "http://192.168.0.100/plugin_package").
|
@@ -259,13 +334,22 @@ module RokuBuilder
|
|
259
334
|
@requests.push(stub_request(:get, "http://192.168.0.100/pkgs/pkg_url").
|
260
335
|
to_return(status: 200, body: "", headers: {}))
|
261
336
|
config, options = build_config_options_objects(PackagerTest, {genkey: true}, false)
|
337
|
+
|
338
|
+
device = RokuBuilder::Device.new("roku", config.raw[:devices][:roku])
|
339
|
+
@device_manager.expect(:reserve_device, device, no_lock: false)
|
340
|
+
@device_manager.expect(:release_device, nil, [device])
|
341
|
+
|
342
|
+
loader = Minitest::Mock.new
|
343
|
+
loader.expect(:sideload, nil, options: Hash)
|
344
|
+
|
262
345
|
packager = Packager.new(config: config)
|
263
|
-
|
264
|
-
|
265
|
-
packager.
|
346
|
+
RokuBuilder.stub(:device_manager, @device_manager) do
|
347
|
+
Loader.stub(:new, loader) do
|
348
|
+
packager.stub(:generate_new_key, ["password", "dev_id"]) do
|
349
|
+
packager.genkey(options: options)
|
350
|
+
end
|
266
351
|
end
|
267
352
|
end
|
268
|
-
|
269
353
|
loader.verify
|
270
354
|
end
|
271
355
|
end
|
@@ -11,6 +11,10 @@ module RokuBuilder
|
|
11
11
|
unless RokuBuilder.plugins.include?(Profiler)
|
12
12
|
RokuBuilder.register_plugin(Profiler)
|
13
13
|
end
|
14
|
+
@device_manager = Minitest::Mock.new
|
15
|
+
end
|
16
|
+
def teardown
|
17
|
+
@device_manager.verify
|
14
18
|
end
|
15
19
|
def test_profiler_parse_options_long
|
16
20
|
parser = OptionParser.new
|
@@ -23,12 +27,16 @@ module RokuBuilder
|
|
23
27
|
def test_profiler_node_tracking
|
24
28
|
options = {profile: "stats"}
|
25
29
|
config, options = build_config_options_objects(ProfilerTest, options, false)
|
30
|
+
device = RokuBuilder::Device.new("roku", config.raw[:devices][:roku])
|
31
|
+
@device_manager.expect(:reserve_device, device, no_lock: true)
|
32
|
+
@device_manager.expect(:release_device, nil, [device])
|
33
|
+
|
26
34
|
waitfor = Proc.new do |telnet_config, &blk|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
35
|
+
assert_equal(/.+/, telnet_config["Match"])
|
36
|
+
assert_equal(1, telnet_config["Timeout"])
|
37
|
+
txt = "<All_Nodes><NodeA /><NodeB /><NodeC><NodeD /></NodeC></All_Nodes>\n"
|
38
|
+
blk.call(txt)
|
39
|
+
true
|
32
40
|
end
|
33
41
|
count = 0
|
34
42
|
read_stub = Proc.new do |size|
|
@@ -43,10 +51,12 @@ module RokuBuilder
|
|
43
51
|
connection.expect(:waitfor, nil, &waitfor)
|
44
52
|
connection.expect(:close, nil)
|
45
53
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
54
|
+
RokuBuilder.stub(:device_manager, @device_manager) do
|
55
|
+
Net::Telnet.stub(:new, connection) do
|
56
|
+
profiler.stub(:printf, nil) do
|
57
|
+
STDIN.stub(:read, read_stub) do
|
58
|
+
profiler.node_tracking(options: options)
|
59
|
+
end
|
50
60
|
end
|
51
61
|
end
|
52
62
|
end
|
@@ -56,12 +66,16 @@ module RokuBuilder
|
|
56
66
|
def test_profiler_stats
|
57
67
|
options = {profile: "stats"}
|
58
68
|
config, options = build_config_options_objects(ProfilerTest, options, false)
|
69
|
+
device = RokuBuilder::Device.new("roku", config.raw[:devices][:roku])
|
70
|
+
@device_manager.expect(:reserve_device, device, no_lock: true)
|
71
|
+
@device_manager.expect(:release_device, nil, [device])
|
72
|
+
|
59
73
|
waitfor = Proc.new do |telnet_config, &blk|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
74
|
+
assert_equal(/.+/, telnet_config["Match"])
|
75
|
+
assert_equal(1, telnet_config["Timeout"])
|
76
|
+
txt = "<All_Nodes><NodeA /><NodeB /><NodeC><NodeD /></NodeC></All_Nodes>\n"
|
77
|
+
blk.call(txt)
|
78
|
+
true
|
65
79
|
end
|
66
80
|
connection = Minitest::Mock.new
|
67
81
|
profiler = Profiler.new(config: config)
|
@@ -70,9 +84,11 @@ module RokuBuilder
|
|
70
84
|
connection.expect(:waitfor, nil, &waitfor)
|
71
85
|
connection.expect(:close, nil)
|
72
86
|
|
73
|
-
|
74
|
-
|
75
|
-
profiler.
|
87
|
+
RokuBuilder.stub(:device_manager, @device_manager) do
|
88
|
+
Net::Telnet.stub(:new, connection) do
|
89
|
+
profiler.stub(:printf, nil) do
|
90
|
+
profiler.profile(options: options)
|
91
|
+
end
|
76
92
|
end
|
77
93
|
end
|
78
94
|
|
@@ -81,12 +97,16 @@ module RokuBuilder
|
|
81
97
|
def test_profiler_all
|
82
98
|
options = {profile: "all"}
|
83
99
|
config, options = build_config_options_objects(ProfilerTest, options, false)
|
100
|
+
device = RokuBuilder::Device.new("roku", config.raw[:devices][:roku])
|
101
|
+
@device_manager.expect(:reserve_device, device, no_lock: true)
|
102
|
+
@device_manager.expect(:release_device, nil, [device])
|
103
|
+
|
84
104
|
waitfor = Proc.new do |telnet_config, &blk|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
105
|
+
assert_equal(/.+/, telnet_config["Match"])
|
106
|
+
assert_equal(1, telnet_config["Timeout"])
|
107
|
+
txt = "<All_Nodes><NodeA /><NodeB /><NodeC><NodeD /></NodeC></All_Nodes>\n"
|
108
|
+
blk.call(txt)
|
109
|
+
true
|
90
110
|
end
|
91
111
|
connection = Minitest::Mock.new
|
92
112
|
profiler = Profiler.new(config: config)
|
@@ -95,9 +115,11 @@ module RokuBuilder
|
|
95
115
|
connection.expect(:waitfor, nil, &waitfor)
|
96
116
|
connection.expect(:close, nil)
|
97
117
|
|
98
|
-
|
99
|
-
|
100
|
-
profiler.
|
118
|
+
RokuBuilder.stub(:device_manager, @device_manager) do
|
119
|
+
Net::Telnet.stub(:new, connection) do
|
120
|
+
profiler.stub(:print, nil) do
|
121
|
+
profiler.profile(options: options)
|
122
|
+
end
|
101
123
|
end
|
102
124
|
end
|
103
125
|
|
@@ -106,12 +128,16 @@ module RokuBuilder
|
|
106
128
|
def test_profiler_roots
|
107
129
|
options = {profile: "roots"}
|
108
130
|
config, options = build_config_options_objects(ProfilerTest, options, false)
|
131
|
+
device = RokuBuilder::Device.new("roku", config.raw[:devices][:roku])
|
132
|
+
@device_manager.expect(:reserve_device, device, no_lock: true)
|
133
|
+
@device_manager.expect(:release_device, nil, [device])
|
134
|
+
|
109
135
|
waitfor = Proc.new do |telnet_config, &blk|
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
136
|
+
assert_equal(/.+/, telnet_config["Match"])
|
137
|
+
assert_equal(1, telnet_config["Timeout"])
|
138
|
+
txt = "<Root_Nodes><NodeA /><NodeB /><NodeC><NodeD /></NodeC></Root_Nodes>\n"
|
139
|
+
blk.call(txt)
|
140
|
+
true
|
115
141
|
end
|
116
142
|
connection = Minitest::Mock.new
|
117
143
|
profiler = Profiler.new(config: config)
|
@@ -120,9 +146,11 @@ module RokuBuilder
|
|
120
146
|
connection.expect(:waitfor, nil, &waitfor)
|
121
147
|
connection.expect(:close, nil)
|
122
148
|
|
123
|
-
|
124
|
-
|
125
|
-
profiler.
|
149
|
+
RokuBuilder.stub(:device_manager, @device_manager) do
|
150
|
+
Net::Telnet.stub(:new, connection) do
|
151
|
+
profiler.stub(:print, nil) do
|
152
|
+
profiler.profile(options: options)
|
153
|
+
end
|
126
154
|
end
|
127
155
|
end
|
128
156
|
connection.verify
|
@@ -130,12 +158,16 @@ module RokuBuilder
|
|
130
158
|
def test_profiler_node
|
131
159
|
options = {profile: "nodeId"}
|
132
160
|
config, options = build_config_options_objects(ProfilerTest, options, false)
|
161
|
+
device = RokuBuilder::Device.new("roku", config.raw[:devices][:roku])
|
162
|
+
@device_manager.expect(:reserve_device, device, no_lock: true)
|
163
|
+
@device_manager.expect(:release_device, nil, [device])
|
164
|
+
|
133
165
|
waitfor = Proc.new do |telnet_config, &blk|
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
166
|
+
assert_equal(/.+/, telnet_config["Match"])
|
167
|
+
assert_equal(1, telnet_config["Timeout"])
|
168
|
+
txt = "<nodeId><NodeA /><NodeB /><NodeC><NodeD /></NodeC></nodeId>\n"
|
169
|
+
blk.call(txt)
|
170
|
+
true
|
139
171
|
end
|
140
172
|
connection = Minitest::Mock.new
|
141
173
|
profiler = Profiler.new(config: config)
|
@@ -144,9 +176,11 @@ module RokuBuilder
|
|
144
176
|
connection.expect(:waitfor, nil, &waitfor)
|
145
177
|
connection.expect(:close, nil)
|
146
178
|
|
147
|
-
|
148
|
-
|
149
|
-
profiler.
|
179
|
+
RokuBuilder.stub(:device_manager, @device_manager) do
|
180
|
+
Net::Telnet.stub(:new, connection) do
|
181
|
+
profiler.stub(:print, nil) do
|
182
|
+
profiler.profile(options: options)
|
183
|
+
end
|
150
184
|
end
|
151
185
|
end
|
152
186
|
connection.verify
|
@@ -154,12 +188,16 @@ module RokuBuilder
|
|
154
188
|
def test_profiler_images
|
155
189
|
options = {profile: "images"}
|
156
190
|
config, options = build_config_options_objects(ProfilerTest, options, false)
|
191
|
+
device = RokuBuilder::Device.new("roku", config.raw[:devices][:roku])
|
192
|
+
@device_manager.expect(:reserve_device, device, no_lock: true)
|
193
|
+
@device_manager.expect(:release_device, nil, [device])
|
194
|
+
|
157
195
|
waitfor = Proc.new do |telnet_config, &blk|
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
196
|
+
assert_equal(/.+/, telnet_config["Match"])
|
197
|
+
assert_equal(1, telnet_config["Timeout"])
|
198
|
+
txt = " RoGraphics instance\n0x234 1 2 3 4\nAvailable memory\n"
|
199
|
+
blk.call(txt)
|
200
|
+
true
|
163
201
|
end
|
164
202
|
connection = Minitest::Mock.new
|
165
203
|
profiler = Profiler.new(config: config)
|
@@ -168,9 +206,11 @@ module RokuBuilder
|
|
168
206
|
connection.expect(:waitfor, nil, &waitfor)
|
169
207
|
connection.expect(:close, nil)
|
170
208
|
|
171
|
-
|
172
|
-
|
173
|
-
profiler.
|
209
|
+
RokuBuilder.stub(:device_manager, @device_manager) do
|
210
|
+
Net::Telnet.stub(:new, connection) do
|
211
|
+
profiler.stub(:print, nil) do
|
212
|
+
profiler.profile(options: options)
|
213
|
+
end
|
174
214
|
end
|
175
215
|
end
|
176
216
|
|
@@ -180,12 +220,16 @@ module RokuBuilder
|
|
180
220
|
def test_profiler_memmory
|
181
221
|
options = {profile: "memmory"}
|
182
222
|
config, options = build_config_options_objects(ProfilerTest, options, false)
|
223
|
+
device = RokuBuilder::Device.new("roku", config.raw[:devices][:roku])
|
224
|
+
@device_manager.expect(:reserve_device, device, no_lock: true)
|
225
|
+
@device_manager.expect(:release_device, nil, [device])
|
226
|
+
|
183
227
|
waitfor = Proc.new do |telnet_config, &blk|
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
228
|
+
assert_equal(/.+/, telnet_config["Match"])
|
229
|
+
assert_equal(1, telnet_config["Timeout"])
|
230
|
+
txt = " RoGraphics instance 0x123\nAvailable memory 123 used 456 max 579\n"
|
231
|
+
blk.call(txt)
|
232
|
+
true
|
189
233
|
end
|
190
234
|
print_count = 0
|
191
235
|
print_stub = Proc.new do |message|
|
@@ -216,9 +260,11 @@ module RokuBuilder
|
|
216
260
|
connection.expect(:puts, nil, &puts_stub)
|
217
261
|
connection.expect(:close, nil)
|
218
262
|
|
219
|
-
|
220
|
-
|
221
|
-
profiler.
|
263
|
+
RokuBuilder.stub(:device_manager, @device_manager) do
|
264
|
+
Net::Telnet.stub(:new, connection) do
|
265
|
+
profiler.stub(:print, print_stub) do
|
266
|
+
profiler.profile(options: options)
|
267
|
+
end
|
222
268
|
end
|
223
269
|
end
|
224
270
|
|
@@ -228,15 +274,19 @@ module RokuBuilder
|
|
228
274
|
def test_profiler_textures
|
229
275
|
options = {profile: "textures"}
|
230
276
|
config, options = build_config_options_objects(ProfilerTest, options, false)
|
277
|
+
device = RokuBuilder::Device.new("roku", config.raw[:devices][:roku])
|
278
|
+
@device_manager.expect(:reserve_device, device, no_lock: true)
|
279
|
+
@device_manager.expect(:release_device, nil, [device])
|
280
|
+
|
231
281
|
waitfor = Proc.new do |telnet_config, &blk|
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
282
|
+
assert_equal(/.+/, telnet_config["Match"])
|
283
|
+
assert_equal(1, telnet_config["Timeout"])
|
284
|
+
txt = "*******\ntexture\n"
|
285
|
+
blk.call(txt)
|
286
|
+
true
|
237
287
|
end
|
238
288
|
timeout = Proc.new do |telnet_config, &blk|
|
239
|
-
|
289
|
+
raise ::Net::ReadTimeout
|
240
290
|
end
|
241
291
|
connection = Minitest::Mock.new
|
242
292
|
profiler = Profiler.new(config: config)
|
@@ -246,9 +296,11 @@ module RokuBuilder
|
|
246
296
|
connection.expect(:waitfor, nil, &timeout)
|
247
297
|
connection.expect(:close, nil)
|
248
298
|
|
249
|
-
|
250
|
-
|
251
|
-
profiler.
|
299
|
+
RokuBuilder.stub(:device_manager, @device_manager) do
|
300
|
+
Net::Telnet.stub(:new, connection) do
|
301
|
+
profiler.stub(:print, nil) do
|
302
|
+
profiler.profile(options: options)
|
303
|
+
end
|
252
304
|
end
|
253
305
|
end
|
254
306
|
|
@@ -257,19 +309,30 @@ module RokuBuilder
|
|
257
309
|
def test_profiler_devlog
|
258
310
|
options = {devlog: "rendezvous", devlog_function: "on"}
|
259
311
|
config, options = build_config_options_objects(ProfilerTest, options, false)
|
312
|
+
device = RokuBuilder::Device.new("roku", config.raw[:devices][:roku])
|
313
|
+
@device_manager.expect(:reserve_device, device, no_lock: true)
|
314
|
+
@device_manager.expect(:release_device, nil, [device])
|
260
315
|
|
261
316
|
connection = Minitest::Mock.new
|
262
317
|
connection.expect(:puts, nil, ["enhanced_dev_log rendezvous on\n"])
|
263
318
|
|
264
319
|
profiler = Profiler.new(config: config)
|
265
|
-
|
266
|
-
|
320
|
+
RokuBuilder.stub(:device_manager, @device_manager) do
|
321
|
+
Net::Telnet.stub(:new, connection) do
|
322
|
+
profiler.stub(:print, nil) do
|
323
|
+
profiler.devlog(options: options)
|
324
|
+
end
|
325
|
+
end
|
267
326
|
end
|
268
327
|
connection.verify
|
269
328
|
end
|
270
329
|
def test_profiler_sgperf
|
271
330
|
options = {sgperf: true}
|
272
331
|
config, options = build_config_options_objects(ProfilerTest, options, false)
|
332
|
+
device = RokuBuilder::Device.new("roku", config.raw[:devices][:roku])
|
333
|
+
@device_manager.expect(:reserve_device, device, no_lock: true)
|
334
|
+
@device_manager.expect(:release_device, nil, [device])
|
335
|
+
|
273
336
|
profiler = Profiler.new(config: config)
|
274
337
|
|
275
338
|
connection = Object.new
|
@@ -298,11 +361,15 @@ module RokuBuilder
|
|
298
361
|
raise Net::ReadTimeout
|
299
362
|
}
|
300
363
|
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
364
|
+
RokuBuilder.stub(:device_manager, @device_manager) do
|
365
|
+
Net::Telnet.stub(:new, connection) do
|
366
|
+
connection.stub(:puts, puts_stub) do
|
367
|
+
txt = ">>thread node calls: create 0 + op 24 @ 100.0% rendezvous"
|
368
|
+
connection.stub(:waitfor, waitfor, txt) do
|
369
|
+
profiler.stub(:print, nil) do
|
370
|
+
profiler.sgperf(options: options)
|
371
|
+
end
|
372
|
+
end
|
306
373
|
end
|
307
374
|
end
|
308
375
|
end
|
@@ -315,6 +382,10 @@ module RokuBuilder
|
|
315
382
|
def test_profiler_sgperf_multi_lines
|
316
383
|
options = {sgperf: true}
|
317
384
|
config, options = build_config_options_objects(ProfilerTest, options, false)
|
385
|
+
device = RokuBuilder::Device.new("roku", config.raw[:devices][:roku])
|
386
|
+
@device_manager.expect(:reserve_device, device, no_lock: true)
|
387
|
+
@device_manager.expect(:release_device, nil, [device])
|
388
|
+
|
318
389
|
profiler = Profiler.new(config: config)
|
319
390
|
|
320
391
|
connection = Object.new
|
@@ -357,11 +428,15 @@ module RokuBuilder
|
|
357
428
|
call_count += 1
|
358
429
|
}
|
359
430
|
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
profiler.stub(:
|
364
|
-
profiler.
|
431
|
+
RokuBuilder.stub(:device_manager, @device_manager) do
|
432
|
+
Net::Telnet.stub(:new, connection) do
|
433
|
+
connection.stub(:puts, connection_puts) do
|
434
|
+
profiler.stub(:get_command_response, command_response) do
|
435
|
+
profiler.stub(:puts, profiler_puts) do
|
436
|
+
profiler.stub(:print, nil) do
|
437
|
+
profiler.sgperf(options: options)
|
438
|
+
end
|
439
|
+
end
|
365
440
|
end
|
366
441
|
end
|
367
442
|
end
|