cosmos 4.0.3 → 4.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (123) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +5 -5
  3. data/Manifest.txt +11 -1
  4. data/README.md +3 -2
  5. data/Rakefile +18 -4
  6. data/appveyor.yml +19 -0
  7. data/cosmos.gemspec +14 -3
  8. data/data/config/cmd_tlm_server.yaml +3 -0
  9. data/data/crc.txt +63 -60
  10. data/demo/config/targets/INST/cmd_tlm_server.txt +1 -0
  11. data/demo/config/targets/INST/cmd_tlm_server2.txt +7 -0
  12. data/demo/config/tools/cmd_sequence/cmd_sequence.txt +2 -0
  13. data/demo/config/tools/cmd_tlm_server/cmd_tlm_server.txt +8 -12
  14. data/demo/config/tools/cmd_tlm_server/cmd_tlm_server2.txt +7 -9
  15. data/demo/lib/cmd_sequence_exporter.rb +52 -0
  16. data/demo/lib/example_background_task.rb +1 -0
  17. data/demo/procedures/replay_test.rb +32 -0
  18. data/ext/cosmos/ext/structure/structure.c +39 -3
  19. data/install/config/tools/cmd_tlm_server/cmd_tlm_server.txt +1 -0
  20. data/install/config/tools/launcher/launcher.txt +2 -0
  21. data/lib/cosmos/config/config_parser.rb +2 -0
  22. data/lib/cosmos/core_ext/io.rb +89 -60
  23. data/lib/cosmos/gui/qt.rb +5 -8
  24. data/lib/cosmos/gui/qt_tool.rb +8 -8
  25. data/lib/cosmos/gui/text/ruby_editor.rb +12 -12
  26. data/lib/cosmos/gui/utilities/script_module_gui.rb +9 -9
  27. data/lib/cosmos/gui/widgets/realtime_button_bar.rb +18 -17
  28. data/lib/cosmos/interfaces/protocols/fixed_protocol.rb +2 -2
  29. data/lib/cosmos/interfaces/protocols/template_protocol.rb +3 -0
  30. data/lib/cosmos/interfaces/udp_interface.rb +27 -14
  31. data/lib/cosmos/io/buffered_file.rb +0 -1
  32. data/lib/cosmos/io/json_drb.rb +134 -214
  33. data/lib/cosmos/io/json_drb_object.rb +22 -61
  34. data/lib/cosmos/io/json_drb_rack.rb +79 -0
  35. data/lib/cosmos/io/json_rpc.rb +27 -0
  36. data/lib/cosmos/io/udp_sockets.rb +102 -58
  37. data/lib/cosmos/packets/commands.rb +1 -1
  38. data/lib/cosmos/packets/structure.rb +1 -1
  39. data/lib/cosmos/packets/structure_item.rb +37 -5
  40. data/lib/cosmos/script/cmd_tlm_server.rb +76 -2
  41. data/lib/cosmos/script/replay.rb +60 -0
  42. data/lib/cosmos/script/script.rb +20 -2
  43. data/lib/cosmos/script/scripting.rb +9 -9
  44. data/lib/cosmos/script/tools.rb +14 -0
  45. data/lib/cosmos/system/system.rb +185 -92
  46. data/lib/cosmos/system/target.rb +1 -1
  47. data/lib/cosmos/tools/cmd_sequence/cmd_sequence.rb +44 -4
  48. data/lib/cosmos/tools/cmd_sequence/sequence_item.rb +4 -0
  49. data/lib/cosmos/tools/cmd_sequence/sequence_list.rb +7 -0
  50. data/lib/cosmos/tools/cmd_tlm_server/api.rb +347 -20
  51. data/lib/cosmos/tools/cmd_tlm_server/background_tasks.rb +3 -0
  52. data/lib/cosmos/tools/cmd_tlm_server/cmd_tlm_server.rb +329 -111
  53. data/lib/cosmos/tools/cmd_tlm_server/cmd_tlm_server_config.rb +13 -0
  54. data/lib/cosmos/tools/cmd_tlm_server/cmd_tlm_server_gui.rb +261 -95
  55. data/lib/cosmos/tools/cmd_tlm_server/gui/interfaces_tab.rb +46 -35
  56. data/lib/cosmos/tools/cmd_tlm_server/gui/logging_tab.rb +18 -8
  57. data/lib/cosmos/tools/cmd_tlm_server/gui/packets_tab.rb +39 -28
  58. data/lib/cosmos/tools/cmd_tlm_server/gui/replay_tab.rb +242 -0
  59. data/lib/cosmos/tools/cmd_tlm_server/gui/status_tab.rb +24 -8
  60. data/lib/cosmos/tools/cmd_tlm_server/gui/targets_tab.rb +18 -6
  61. data/lib/cosmos/tools/cmd_tlm_server/limits_groups_background_task.rb +5 -4
  62. data/lib/cosmos/tools/cmd_tlm_server/replay_backend.rb +375 -0
  63. data/lib/cosmos/tools/cmd_tlm_server/routers.rb +10 -2
  64. data/lib/cosmos/tools/data_viewer/data_viewer.rb +40 -5
  65. data/lib/cosmos/tools/handbook_creator/handbook_creator_config.rb +18 -20
  66. data/lib/cosmos/tools/launcher/launcher_config.rb +5 -16
  67. data/lib/cosmos/tools/limits_monitor/limits_monitor.rb +65 -39
  68. data/lib/cosmos/tools/packet_viewer/packet_viewer.rb +19 -0
  69. data/lib/cosmos/tools/replay/replay.rb +5 -505
  70. data/lib/cosmos/tools/script_runner/script_audit.rb +1 -0
  71. data/lib/cosmos/tools/script_runner/script_runner.rb +3 -4
  72. data/lib/cosmos/tools/script_runner/script_runner_config.rb +3 -4
  73. data/lib/cosmos/tools/script_runner/script_runner_frame.rb +44 -23
  74. data/lib/cosmos/tools/test_runner/results_writer.rb +4 -0
  75. data/lib/cosmos/tools/test_runner/test_runner.rb +0 -3
  76. data/lib/cosmos/tools/tlm_grapher/tabbed_plots_tool/tabbed_plots_realtime_thread.rb +6 -2
  77. data/lib/cosmos/tools/tlm_grapher/tabbed_plots_tool/tabbed_plots_tool.rb +26 -1
  78. data/lib/cosmos/tools/tlm_viewer/screen.rb +24 -1
  79. data/lib/cosmos/tools/tlm_viewer/tlm_viewer.rb +25 -0
  80. data/lib/cosmos/tools/tlm_viewer/tlm_viewer_config.rb +24 -14
  81. data/lib/cosmos/top_level.rb +34 -24
  82. data/lib/cosmos/utilities/csv.rb +60 -8
  83. data/lib/cosmos/version.rb +5 -5
  84. data/spec/config/config_parser_spec.rb +10 -1
  85. data/spec/core_ext/socket_spec.rb +4 -2
  86. data/spec/gui/utilities/script_module_gui_spec.rb +102 -0
  87. data/spec/install/config/data/data.txt +1 -0
  88. data/spec/install/config/targets/INST/cmd_tlm/inst_cmds.txt +2 -0
  89. data/spec/interfaces/cmd_tlm_server_interface_spec.rb +1 -2
  90. data/spec/interfaces/protocols/template_protocol_spec.rb +72 -2
  91. data/spec/interfaces/serial_interface_spec.rb +1 -1
  92. data/spec/interfaces/udp_interface_spec.rb +14 -0
  93. data/spec/io/buffered_file_spec.rb +37 -0
  94. data/spec/io/json_drb_object_spec.rb +2 -15
  95. data/spec/io/json_drb_spec.rb +61 -121
  96. data/spec/io/udp_sockets_spec.rb +42 -2
  97. data/spec/packet_logs/packet_log_reader_spec.rb +5 -2
  98. data/spec/packets/binary_accessor_spec.rb +1 -1
  99. data/spec/packets/packet_item_spec.rb +1 -1
  100. data/spec/packets/structure_item_spec.rb +5 -6
  101. data/spec/script/cmd_tlm_server_spec.rb +39 -4
  102. data/spec/script/commands_disconnect_spec.rb +1 -1
  103. data/spec/script/commands_spec.rb +2 -1
  104. data/spec/script/scripting_spec.rb +18 -3
  105. data/spec/script/telemetry_spec.rb +5 -0
  106. data/spec/spec_helper.rb +43 -26
  107. data/spec/streams/tcpip_socket_stream_spec.rb +2 -2
  108. data/spec/system/system_spec.rb +11 -9
  109. data/spec/system/target_spec.rb +3 -0
  110. data/spec/tools/cmd_tlm_server/api_spec.rb +543 -29
  111. data/spec/tools/cmd_tlm_server/background_task_spec.rb +2 -2
  112. data/spec/tools/cmd_tlm_server/background_tasks_spec.rb +31 -75
  113. data/spec/tools/cmd_tlm_server/cmd_tlm_server_config_spec.rb +199 -66
  114. data/spec/tools/cmd_tlm_server/cmd_tlm_server_spec.rb +85 -9
  115. data/spec/tools/cmd_tlm_server/interface_thread_spec.rb +29 -127
  116. data/spec/tools/cmd_tlm_server/router_thread_spec.rb +10 -50
  117. data/spec/tools/launcher/launcher_config_spec.rb +1 -1
  118. data/spec/tools/table_manager/table_item_spec.rb +1 -1
  119. data/spec/tools/table_manager/tablemanager_core_spec.rb +4 -4
  120. data/spec/top_level/top_level_spec.rb +151 -3
  121. data/spec/utilities/csv_spec.rb +24 -5
  122. metadata +61 -9
  123. data/lib/cosmos/tools/replay/replay_server.rb +0 -91
@@ -83,20 +83,12 @@ module Cosmos
83
83
  expect(CmdTlmServer.json_drb.method_whitelist).to include('stop_logging')
84
84
  expect(CmdTlmServer.json_drb.method_whitelist).to include('stop_cmd_log')
85
85
  expect(CmdTlmServer.json_drb.method_whitelist).to include('stop_tlm_log')
86
- threads = Thread.list.length
87
- cts.start # Call start again ... it should do nothing
88
- expect(CmdTlmServer.json_drb.method_whitelist).to include('start_logging')
89
- expect(CmdTlmServer.json_drb.method_whitelist).to include('stop_logging')
90
- expect(CmdTlmServer.json_drb.method_whitelist).to include('stop_cmd_log')
91
- expect(CmdTlmServer.json_drb.method_whitelist).to include('stop_tlm_log')
92
86
  ensure
93
87
  cts.stop
94
88
  sleep 0.2
95
89
  end
96
90
 
97
- expect_any_instance_of(PacketLogging).to receive(:start)
98
- # Now start the server in production mode
99
- cts.start(true)
91
+ cts = CmdTlmServer.new(CmdTlmServer::DEFAULT_CONFIG_FILE, true)
100
92
  begin
101
93
  # Verify we disabled the ability to stop logging
102
94
  expect(CmdTlmServer.json_drb.method_whitelist).to include('start_logging')
@@ -201,6 +193,11 @@ module Cosmos
201
193
  end
202
194
 
203
195
  describe "self.subscribe_limits_events" do
196
+ it "rejects bad queue sizes" do
197
+ expect{ CmdTlmServer.subscribe_limits_events(0) }.to raise_error(ArgumentError)
198
+ expect{ CmdTlmServer.subscribe_limits_events(true) }.to raise_error(ArgumentError)
199
+ end
200
+
204
201
  it "subscribes to limits events" do
205
202
  allow(System).to receive_message_chain(:telemetry,:stale).and_return([])
206
203
  allow(System).to receive_message_chain(:telemetry,:limits_change_callback=)
@@ -306,9 +303,14 @@ module Cosmos
306
303
 
307
304
  describe "self.subscribe_packet_data" do
308
305
  it "rejects bad queue sizes" do
306
+ expect{ CmdTlmServer.subscribe_packet_data([["SYSTEM","LIMITS_CHANGE"]], 0) }.to raise_error(ArgumentError)
309
307
  expect{ CmdTlmServer.subscribe_packet_data([["SYSTEM","LIMITS_CHANGE"]], true) }.to raise_error(ArgumentError)
310
308
  end
311
309
 
310
+ it "rejects bad packet lists" do
311
+ expect{ CmdTlmServer.subscribe_packet_data(["SYSTEM","LIMITS_CHANGE"]) }.to raise_error(ArgumentError, /packets must be nested array/)
312
+ end
313
+
312
314
  it "subscribes to packets" do
313
315
  cts = CmdTlmServer.new
314
316
  id = CmdTlmServer.subscribe_packet_data([["SYSTEM","LIMITS_CHANGE"]])
@@ -400,6 +402,80 @@ module Cosmos
400
402
  end
401
403
  end
402
404
 
405
+ describe "self.get_packet_data" do
406
+ it "raises an error if the queue is empty and non_block" do
407
+ cts = CmdTlmServer.new
408
+ id = CmdTlmServer.subscribe_packet_data([["SYSTEM","LIMITS_CHANGE"]])
409
+
410
+ expect { CmdTlmServer.get_packet_data(id, true) }.to raise_error(ThreadError)
411
+ cts.stop
412
+ sleep 0.2
413
+ end
414
+
415
+ it "works in disconnect mode" do
416
+ cts = CmdTlmServer.new(CmdTlmServer::DEFAULT_CONFIG_FILE, false, true)
417
+ id = CmdTlmServer.subscribe_packet_data([["SYSTEM","LIMITS_CHANGE"]])
418
+ buffer,tgt,pkt,tv_sec,tv_usec,cnt = CmdTlmServer.get_packet_data(id, true)
419
+ expect(buffer).not_to be_nil
420
+ expect(tgt).to eql "SYSTEM"
421
+ expect(pkt).to eql "LIMITS_CHANGE"
422
+ end
423
+ end
424
+
425
+ describe "self.subscribe_server_messages" do
426
+ it "rejects bad queue sizes" do
427
+ expect{ CmdTlmServer.subscribe_server_messages(0) }.to raise_error(ArgumentError)
428
+ expect{ CmdTlmServer.subscribe_server_messages(true) }.to raise_error(ArgumentError)
429
+ end
430
+
431
+ it "subscribes to server messages" do
432
+ cts = CmdTlmServer.new
433
+ id = CmdTlmServer.subscribe_server_messages()
434
+ cts.post_server_message("This is a test")
435
+ cts.post_server_message("Another test")
436
+ message = CmdTlmServer.get_server_message(id, true)
437
+ expect(message).to eql "This is a test"
438
+ message = CmdTlmServer.get_server_message(id, true)
439
+ expect(message).to eql "Another test"
440
+
441
+ cts.stop
442
+ sleep 0.2
443
+ end
444
+
445
+ it "deletes queues after the max packets is reached" do
446
+ cts = CmdTlmServer.new
447
+ id = CmdTlmServer.subscribe_server_messages(2)
448
+ cts.post_server_message("One message")
449
+ message = CmdTlmServer.get_server_message(id, true)
450
+ expect(message).to eql "One message"
451
+
452
+ # Fill the queue
453
+ 1001.times { cts.post_server_message("Message") }
454
+
455
+ # Try to get another message
456
+ expect { CmdTlmServer.get_server_message(id) }.to raise_error("Server message queue with id #{id} not found")
457
+
458
+ cts.stop
459
+ sleep 0.2
460
+ end
461
+ end
462
+
463
+ describe "self.subscribe_server_messages" do
464
+ it "unsubscribes to messages" do
465
+ cts = CmdTlmServer.new
466
+ id = CmdTlmServer.subscribe_server_messages(2)
467
+ cts.post_server_message("One message")
468
+ message = CmdTlmServer.get_server_message(id, true)
469
+ expect(message).to eql "One message"
470
+
471
+ CmdTlmServer.unsubscribe_server_messages(id)
472
+ cts.post_server_message("Two message")
473
+ expect { CmdTlmServer.get_server_message(id) }.to raise_error("Server message queue with id #{id} not found")
474
+ cts.stop
475
+ sleep 0.2
476
+ end
477
+ end
478
+
403
479
  describe "self.get_packet_data" do
404
480
  it "raises an error if the queue is empty and non_block" do
405
481
  cts = CmdTlmServer.new
@@ -59,18 +59,10 @@ module Cosmos
59
59
  thread = InterfaceThread.new(@interface)
60
60
  thread.start
61
61
  sleep 0.1
62
- if RUBY_ENGINE == 'ruby'
63
- expect(Thread.list.length).to eql(2)
64
- else
65
- expect(Thread.list.length).to eql(3)
66
- end
62
+ expect(running_threads.length).to eql(2)
67
63
  thread.stop
68
64
  sleep 0.2
69
- if RUBY_ENGINE == 'ruby'
70
- expect(Thread.list.length).to eql(1)
71
- else
72
- expect(Thread.list.length).to eql(2)
73
- end
65
+ expect(running_threads.length).to eql(1)
74
66
 
75
67
  expect(stdout.string).to match "Connection Failed: RuntimeError : ConnectError"
76
68
  end
@@ -80,10 +72,9 @@ module Cosmos
80
72
  capture_io do |stdout|
81
73
  allow(@interface).to receive(:connected?).and_return(false)
82
74
  allow(@interface).to receive(:connect) { raise "ConnectError" }
83
- # Make the reconnect_delay be slightly longer than half of 0.1 which is
84
- # how long the test is waiting after calling start. This allows us to
85
- # see the error twice.
86
- @interface.reconnect_delay = 0.15
75
+ # Make the reconnect_delay be 0.2 so we see the initial error and a
76
+ # reconnect error during the 0.3 sleep after starting the thread
77
+ @interface.reconnect_delay = 0.2
87
78
  thread = InterfaceThread.new(@interface)
88
79
  error_count = 0
89
80
  thread.connection_failed_callback = Proc.new do |error|
@@ -91,19 +82,11 @@ module Cosmos
91
82
  error_count += 1
92
83
  end
93
84
  thread.start
94
- sleep 0.2
95
- if RUBY_ENGINE == 'ruby'
96
- expect(Thread.list.length).to eql(2)
97
- else
98
- expect(Thread.list.length).to eql(3)
99
- end
85
+ sleep 0.3
86
+ expect(running_threads.length).to eql(2)
100
87
  thread.stop
101
- sleep 0.2
102
- if RUBY_ENGINE == 'ruby'
103
- expect(Thread.list.length).to eql(1)
104
- else
105
- expect(Thread.list.length).to eql(2)
106
- end
88
+ sleep 0.1
89
+ expect(running_threads.length).to eql(1)
107
90
  expect(error_count).to eql 2
108
91
 
109
92
  expect(stdout.string).not_to match "Connection Failed: ConnectError"
@@ -115,18 +98,10 @@ module Cosmos
115
98
  thread = InterfaceThread.new(@interface)
116
99
  thread.start
117
100
  sleep 0.1
118
- if RUBY_ENGINE == 'ruby'
119
- expect(Thread.list.length).to eql(2)
120
- else
121
- expect(Thread.list.length).to eql(3)
122
- end
101
+ expect(running_threads.length).to eql(2)
123
102
  thread.stop
124
103
  sleep 0.2
125
- if RUBY_ENGINE == 'ruby'
126
- expect(Thread.list.length).to eql(1)
127
- else
128
- expect(Thread.list.length).to eql(2)
129
- end
104
+ expect(running_threads.length).to eql(1)
130
105
 
131
106
  expect(stdout.string).to match "Connection Success"
132
107
  end
@@ -141,18 +116,10 @@ module Cosmos
141
116
  end
142
117
  thread.start
143
118
  sleep 0.1
144
- if RUBY_ENGINE == 'ruby'
145
- expect(Thread.list.length).to eql(2)
146
- else
147
- expect(Thread.list.length).to eql(3)
148
- end
119
+ expect(running_threads.length).to eql(2)
149
120
  thread.stop
150
121
  sleep 0.2
151
- if RUBY_ENGINE == 'ruby'
152
- expect(Thread.list.length).to eql(1)
153
- else
154
- expect(Thread.list.length).to eql(2)
155
- end
122
+ expect(running_threads.length).to eql(1)
156
123
  expect(callback_called).to be true
157
124
 
158
125
  expect(stdout.string).not_to match "Connection Success"
@@ -169,18 +136,10 @@ module Cosmos
169
136
  thread = InterfaceThread.new(@interface)
170
137
  thread.start
171
138
  sleep 0.1
172
- if RUBY_ENGINE == 'ruby'
173
- expect(Thread.list.length).to eql(2)
174
- else
175
- expect(Thread.list.length).to eql(3)
176
- end
139
+ expect(running_threads.length).to eql(2)
177
140
  thread.stop
178
141
  sleep 0.2
179
- if RUBY_ENGINE == 'ruby'
180
- expect(Thread.list.length).to eql(1)
181
- else
182
- expect(Thread.list.length).to eql(2)
183
- end
142
+ expect(running_threads.length).to eql(1)
184
143
 
185
144
  expect(stdout.string).to match "Connection Lost"
186
145
  end
@@ -199,18 +158,10 @@ module Cosmos
199
158
  sleep 1
200
159
  # Since we set auto_reconnect to false we shouldn't see the interface
201
160
  # thread because it will be killed
202
- if RUBY_ENGINE == 'ruby'
203
- expect(Thread.list.length).to eql(1)
204
- else
205
- expect(Thread.list.length).to eql(2)
206
- end
161
+ expect(running_threads.length).to eql(1)
207
162
  thread.stop
208
163
  sleep 0.2
209
- if RUBY_ENGINE == 'ruby'
210
- expect(Thread.list.length).to eql(1)
211
- else
212
- expect(Thread.list.length).to eql(2)
213
- end
164
+ expect(running_threads.length).to eql(1)
214
165
  expect(callback_called).to be true
215
166
 
216
167
  expect(stdout.string).not_to match "Connection Lost"
@@ -223,18 +174,10 @@ module Cosmos
223
174
  thread = InterfaceThread.new(@interface)
224
175
  thread.start
225
176
  sleep 0.1
226
- if RUBY_ENGINE == 'ruby'
227
- expect(Thread.list.length).to eql(2)
228
- else
229
- expect(Thread.list.length).to eql(3)
230
- end
177
+ expect(running_threads.length).to eql(2)
231
178
  thread.stop
232
179
  sleep 0.2
233
- if RUBY_ENGINE == 'ruby'
234
- expect(Thread.list.length).to eql(1)
235
- else
236
- expect(Thread.list.length).to eql(2)
237
- end
180
+ expect(running_threads.length).to eql(1)
238
181
  expect(stdout.string).to match "ReadError"
239
182
  end
240
183
  end
@@ -249,18 +192,10 @@ module Cosmos
249
192
  thread = InterfaceThread.new(@interface)
250
193
  thread.start
251
194
  sleep 0.1
252
- if RUBY_ENGINE == 'ruby'
253
- expect(Thread.list.length).to eql(2)
254
- else
255
- expect(Thread.list.length).to eql(3)
256
- end
195
+ expect(running_threads.length).to eql(2)
257
196
  thread.stop
258
197
  sleep 0.2
259
- if RUBY_ENGINE == 'ruby'
260
- expect(Thread.list.length).to eql(1)
261
- else
262
- expect(Thread.list.length).to eql(2)
263
- end
198
+ expect(running_threads.length).to eql(1)
264
199
 
265
200
  expect(stdout.string).to match "ECONNRESET"
266
201
  end
@@ -304,18 +239,10 @@ module Cosmos
304
239
  thread = InterfaceThread.new(@interface)
305
240
  thread.start
306
241
  sleep 0.1
307
- if RUBY_ENGINE == 'ruby'
308
- expect(Thread.list.length).to eql(2)
309
- else
310
- expect(Thread.list.length).to eql(3)
311
- end
242
+ expect(running_threads.length).to eql(2)
312
243
  thread.stop
313
244
  sleep 0.2
314
- if RUBY_ENGINE == 'ruby'
315
- expect(Thread.list.length).to eql(1)
316
- else
317
- expect(Thread.list.length).to eql(2)
318
- end
245
+ expect(running_threads.length).to eql(1)
319
246
 
320
247
  expect(stdout.string).to match "Unknown 2 byte packet"
321
248
  end
@@ -330,18 +257,10 @@ module Cosmos
330
257
  thread.start
331
258
  sleep 0.1
332
259
 
333
- if RUBY_ENGINE == 'ruby'
334
- expect(Thread.list.length).to eql(2)
335
- else
336
- expect(Thread.list.length).to eql(3)
337
- end
260
+ expect(running_threads.length).to eql(2)
338
261
  thread.stop
339
262
  sleep 0.2
340
- if RUBY_ENGINE == 'ruby'
341
- expect(Thread.list.length).to eql(1)
342
- else
343
- expect(Thread.list.length).to eql(2)
344
- end
263
+ expect(running_threads.length).to eql(1)
345
264
  expect(stdout.string).to match "Received unknown identified telemetry: BOB SMITH"
346
265
  end
347
266
  end
@@ -357,18 +276,10 @@ module Cosmos
357
276
  thread = InterfaceThread.new(@interface)
358
277
  thread.start
359
278
  sleep 0.1
360
- if RUBY_ENGINE == 'ruby'
361
- expect(Thread.list.length).to eql(2)
362
- else
363
- expect(Thread.list.length).to eql(3)
364
- end
279
+ expect(running_threads.length).to eql(2)
365
280
  thread.stop
366
281
  sleep 0.2
367
- if RUBY_ENGINE == 'ruby'
368
- expect(Thread.list.length).to eql(1)
369
- else
370
- expect(Thread.list.length).to eql(2)
371
- end
282
+ expect(running_threads.length).to eql(1)
372
283
 
373
284
  expect(stdout.string).to match "Problem writing to router"
374
285
  end
@@ -379,21 +290,12 @@ module Cosmos
379
290
  allow(writer).to receive_message_chain(:tlm_log_writer,:write)
380
291
  @interface.packet_log_writer_pairs = [writer]
381
292
  thread = InterfaceThread.new(@interface)
382
- threads = Thread.list.length
383
293
  thread.start
384
294
  sleep 0.1
385
- if RUBY_ENGINE == 'ruby'
386
- expect(Thread.list.length).to eql(2)
387
- else
388
- expect(Thread.list.length).to eql(3)
389
- end
295
+ expect(running_threads.length).to eql(2)
390
296
  thread.stop
391
297
  sleep 0.2
392
- if RUBY_ENGINE == 'ruby'
393
- expect(Thread.list.length).to eql(1)
394
- else
395
- expect(Thread.list.length).to eql(2)
396
- end
298
+ expect(running_threads.length).to eql(1)
397
299
  end
398
300
 
399
301
  end
@@ -39,18 +39,10 @@ module Cosmos
39
39
  capture_io do |stdout|
40
40
  thread.start
41
41
  sleep 0.2
42
- if RUBY_ENGINE == 'ruby'
43
- expect(Thread.list.length).to eql(2)
44
- else
45
- expect(Thread.list.length).to eql(3)
46
- end
42
+ expect(running_threads.length).to eql(2)
47
43
  thread.stop
48
44
  sleep 0.5
49
- if RUBY_ENGINE == 'ruby'
50
- expect(Thread.list.length).to eql(1)
51
- else
52
- expect(Thread.list.length).to eql(2)
53
- end
45
+ expect(running_threads.length).to eql(1)
54
46
  expect(stdout.string).to match "disconnected interface"
55
47
  end
56
48
  end
@@ -65,18 +57,10 @@ module Cosmos
65
57
  capture_io do |stdout|
66
58
  thread.start
67
59
  sleep 0.2
68
- if RUBY_ENGINE == 'ruby'
69
- expect(Thread.list.length).to eql(2)
70
- else
71
- expect(Thread.list.length).to eql(3)
72
- end
60
+ expect(running_threads.length).to eql(2)
73
61
  thread.stop
74
62
  sleep 0.5
75
- if RUBY_ENGINE == 'ruby'
76
- expect(Thread.list.length).to eql(1)
77
- else
78
- expect(Thread.list.length).to eql(2)
79
- end
63
+ expect(running_threads.length).to eql(1)
80
64
  expect(stdout.string).to match "Error routing command"
81
65
  end
82
66
  end
@@ -97,18 +81,10 @@ module Cosmos
97
81
  capture_io do |stdout|
98
82
  thread.start
99
83
  sleep 0.2
100
- if RUBY_ENGINE == 'ruby'
101
- expect(Thread.list.length).to eql(2)
102
- else
103
- expect(Thread.list.length).to eql(3)
104
- end
84
+ expect(running_threads.length).to eql(2)
105
85
  thread.stop
106
86
  sleep 0.5
107
- if RUBY_ENGINE == 'ruby'
108
- expect(Thread.list.length).to eql(1)
109
- else
110
- expect(Thread.list.length).to eql(2)
111
- end
87
+ expect(running_threads.length).to eql(1)
112
88
  expect(stdout.string).to match "Received unknown identified command: BOB SMITH"
113
89
  end
114
90
  end
@@ -133,18 +109,10 @@ module Cosmos
133
109
  capture_io do |stdout|
134
110
  thread.start
135
111
  sleep 0.2
136
- if RUBY_ENGINE == 'ruby'
137
- expect(Thread.list.length).to eql(2)
138
- else
139
- expect(Thread.list.length).to eql(3)
140
- end
112
+ expect(running_threads.length).to eql(2)
141
113
  thread.stop
142
114
  sleep 0.5
143
- if RUBY_ENGINE == 'ruby'
144
- expect(Thread.list.length).to eql(1)
145
- else
146
- expect(Thread.list.length).to eql(2)
147
- end
115
+ expect(running_threads.length).to eql(1)
148
116
  expect(stdout.string).to match "Received unknown identified command: BOB SMITH"
149
117
  end
150
118
  expect(target).to have_received(:interface).at_least(2).times #and_return(@interface)
@@ -170,18 +138,10 @@ module Cosmos
170
138
  capture_io do |stdout|
171
139
  thread.start
172
140
  sleep 0.2
173
- if RUBY_ENGINE == 'ruby'
174
- expect(Thread.list.length).to eql(2)
175
- else
176
- expect(Thread.list.length).to eql(3)
177
- end
141
+ expect(running_threads.length).to eql(2)
178
142
  thread.stop
179
143
  sleep 0.5
180
- if RUBY_ENGINE == 'ruby'
181
- expect(Thread.list.length).to eql(1)
182
- else
183
- expect(Thread.list.length).to eql(2)
184
- end
144
+ expect(running_threads.length).to eql(1)
185
145
  expect(stdout.string).to match "target with no interface"
186
146
  end
187
147
  end