cosmos 4.0.3-java → 4.1.0-java

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 +12 -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
@@ -17,12 +17,12 @@ module Cosmos
17
17
  describe "initialize" do
18
18
  it "initializes local variables" do
19
19
  b1 = BackgroundTask.new
20
- expect(b1.name).to eq "Background Task 1"
20
+ expect(b1.name).to match(/Background Task \d+/)
21
21
  expect(b1.thread).to be_nil
22
22
  expect(b1.status).to eq ''
23
23
  expect(b1.stopped).to eq false
24
24
  b2 = BackgroundTask.new
25
- expect(b2.name).to eq "Background Task 2"
25
+ expect(b2.name).to match(/Background Task \d+/)
26
26
  expect(b1.thread).to be_nil
27
27
  expect(b1.status).to eq ''
28
28
  expect(b2.stopped).to eq false
@@ -48,42 +48,26 @@ module Cosmos
48
48
  tf.close
49
49
  config = CmdTlmServerConfig.new(tf.path)
50
50
  bt = BackgroundTasks.new(config)
51
- if RUBY_ENGINE == 'ruby'
52
- expect(Thread.list.length).to eql(1) # RSpec main thread
53
- else
54
- expect(Thread.list.length).to eql(2) # RSpec main thread
55
- end
51
+ expect(running_threads.length).to eql(1) # RSpec main thread
56
52
  expect(bt.instance_variable_get("@threads").length).to eq 0
57
53
 
58
54
  capture_io do |stdout|
59
55
  bt.start_all
60
56
  sleep 0.2
61
- if RUBY_ENGINE == 'ruby'
62
- expect(Thread.list.length).to eql(3)
63
- else
64
- expect(Thread.list.length).to eql(4)
65
- end
57
+ expect(running_threads.length).to eql(3)
66
58
  expect(bt.instance_variable_get("@threads").compact.length).to eq 2
67
59
  expect(stdout.string).to match "BG0 START"
68
60
  expect(stdout.string).to match "BG2 START"
69
61
 
70
62
  bt.start(1)
71
63
  sleep 0.1
72
- if RUBY_ENGINE == 'ruby'
73
- expect(Thread.list.length).to eql(4)
74
- else
75
- expect(Thread.list.length).to eql(5)
76
- end
64
+ expect(running_threads.length).to eql(4)
77
65
  expect(bt.instance_variable_get("@threads").compact.length).to eq 3
78
66
  expect(stdout.string).to match "BG1 START"
79
67
 
80
68
  bt.stop_all
81
69
  sleep 0.2
82
- if RUBY_ENGINE == 'ruby'
83
- expect(Thread.list.length).to eql(1)
84
- else
85
- expect(Thread.list.length).to eql(2)
86
- end
70
+ expect(running_threads.length).to eql(1)
87
71
  expect(bt.instance_variable_get("@threads").compact.length).to eq 0
88
72
  expect(stdout.string).to match "BG0 STOP"
89
73
  expect(stdout.string).to match "BG1 STOP"
@@ -102,79 +86,67 @@ module Cosmos
102
86
  tf.close
103
87
  config = CmdTlmServerConfig.new(tf.path)
104
88
  bt = BackgroundTasks.new(config)
105
- if RUBY_ENGINE == 'ruby'
106
- expect(Thread.list.length).to eql(1) # RSpec main thread
107
- else
108
- expect(Thread.list.length).to eql(2) # RSpec main thread
109
- end
89
+ expect(running_threads.length).to eql(1) # RSpec main thread
110
90
  expect(bt.instance_variable_get("@threads").length).to eq 0
111
91
 
112
92
  capture_io do |stdout|
93
+ expect { bt.start(3) }.to raise_error(/No task at index 3/)
94
+
113
95
  bt.start(2)
114
96
  sleep 0.1
115
- if RUBY_ENGINE == 'ruby'
116
- expect(Thread.list.length).to eql(2)
117
- else
118
- expect(Thread.list.length).to eql(3)
119
- end
97
+ expect(running_threads.length).to eql(2)
120
98
  expect(bt.instance_variable_get("@threads")[2].alive?).to eq true
121
99
  expect(bt.instance_variable_get("@threads").compact.length).to eq 1
122
100
  expect(stdout.string).to match "BG2 START"
123
101
 
124
102
  bt.start(1)
125
103
  sleep 0.1
126
- if RUBY_ENGINE == 'ruby'
127
- expect(Thread.list.length).to eql(3)
128
- else
129
- expect(Thread.list.length).to eql(4)
130
- end
104
+ expect(running_threads.length).to eql(3)
131
105
  expect(bt.instance_variable_get("@threads")[1].alive?).to eq true
132
106
  expect(bt.instance_variable_get("@threads").compact.length).to eq 2
133
107
  expect(stdout.string).to match "BG1 START"
134
108
 
135
109
  bt.start(0)
136
110
  sleep 0.1
137
- if RUBY_ENGINE == 'ruby'
138
- expect(Thread.list.length).to eql(4)
139
- else
140
- expect(Thread.list.length).to eql(5)
141
- end
111
+ expect(running_threads.length).to eql(4)
142
112
  expect(bt.instance_variable_get("@threads")[0].alive?).to eq true
143
113
  expect(bt.instance_variable_get("@threads").compact.length).to eq 3
144
114
  expect(stdout.string).to match "BG0 START"
145
115
 
116
+ bt.start(2) # Should do nothing since the task is already started
117
+ sleep 0.1
118
+ expect(running_threads.length).to eql(4)
119
+ expect(bt.instance_variable_get("@threads").compact.length).to eq 3
120
+ expect(stdout.string).to match "BG0 START" # No change
121
+
146
122
  bt.stop(1)
147
123
  sleep 0.2
148
- if RUBY_ENGINE == 'ruby'
149
- expect(Thread.list.length).to eql(3)
150
- else
151
- expect(Thread.list.length).to eql(4)
152
- end
124
+ expect(running_threads.length).to eql(3)
153
125
  expect(bt.instance_variable_get("@threads")[1]).to be_nil
154
126
  expect(bt.instance_variable_get("@threads").compact.length).to eq 2
155
127
  expect(stdout.string).to match "BG1 STOP"
156
128
 
157
129
  bt.stop(0)
158
130
  sleep 0.2
159
- if RUBY_ENGINE == 'ruby'
160
- expect(Thread.list.length).to eql(2)
161
- else
162
- expect(Thread.list.length).to eql(3)
163
- end
131
+ expect(running_threads.length).to eql(2)
164
132
  expect(bt.instance_variable_get("@threads")[0]).to be_nil
165
133
  expect(bt.instance_variable_get("@threads").compact.length).to eq 1
166
134
  expect(stdout.string).to match "BG0 STOP"
167
135
 
168
136
  bt.stop(2)
169
137
  sleep 0.2
170
- if RUBY_ENGINE == 'ruby'
171
- expect(Thread.list.length).to eql(1)
172
- else
173
- expect(Thread.list.length).to eql(2)
174
- end
138
+ expect(running_threads.length).to eql(1)
175
139
  expect(bt.instance_variable_get("@threads")[2]).to be_nil
176
140
  expect(bt.instance_variable_get("@threads").compact.length).to eq 0
177
141
  expect(stdout.string).to match "BG2 STOP"
142
+
143
+ bt.stop(0) # Should be safe to stop something already stopped
144
+ sleep 0.2
145
+ expect(running_threads.length).to eql(1)
146
+ expect(bt.instance_variable_get("@threads").compact.length).to eq 0
147
+ expect(stdout.string).to match "BG2 STOP" # No change
148
+
149
+ expect { bt.stop(3) }.to raise_error(/No task at index 3/)
178
150
  end
179
151
  tf.unlink
180
152
  end
@@ -185,37 +157,21 @@ module Cosmos
185
157
  tf.close
186
158
  config = CmdTlmServerConfig.new(tf.path)
187
159
  bt = BackgroundTasks.new(config)
188
- if RUBY_ENGINE == 'ruby'
189
- expect(Thread.list.length).to eql(1) # RSpec main thread
190
- else
191
- expect(Thread.list.length).to eql(2) # RSpec main thread
192
- end
160
+ expect(running_threads.length).to eql(1) # RSpec main thread
193
161
  expect(bt.instance_variable_get("@threads").length).to eq 0
194
162
 
195
163
  capture_io do |stdout|
196
164
  bt.start_all
197
165
  # 2 because the RSpec main thread plus the background task
198
- if RUBY_ENGINE == 'ruby'
199
- expect(Thread.list.length).to eql(2)
200
- else
201
- expect(Thread.list.length).to eql(3)
202
- end
166
+ expect(running_threads.length).to eql(2)
203
167
  sleep 1.1 # Allow the thread to crash
204
- if RUBY_ENGINE == 'ruby'
205
- expect(Thread.list.length).to eql(1)
206
- else
207
- expect(Thread.list.length).to eql(2)
208
- end
168
+ expect(running_threads.length).to eql(1)
209
169
  expect(bt.instance_variable_get("@threads").length).to eq 1
210
170
  expect(bt.instance_variable_get("@threads")[0].alive?).to eq false
211
171
 
212
172
  bt.stop_all
213
173
  sleep 0.2
214
- if RUBY_ENGINE == 'ruby'
215
- expect(Thread.list.length).to eql(1)
216
- else
217
- expect(Thread.list.length).to eql(2)
218
- end
174
+ expect(running_threads.length).to eql(1)
219
175
  expect(bt.instance_variable_get("@threads").length).to eq 0
220
176
 
221
177
  expect(stdout.string).to match "unexpectedly died"
@@ -46,7 +46,7 @@ module Cosmos
46
46
  end
47
47
 
48
48
  @keywords = %w(TITLE PACKET_LOG_WRITER AUTO_INTERFACE_TARGETS INTERFACE_TARGET INTERFACE ROUTER)
49
- @interface_keywords = %w(DONT_CONNECT DONT_RECONNECT RECONNECT_DELAY DISABLE_DISCONNECT LOG DONT_LOG TARGET PROTOCOL)
49
+ @interface_keywords = %w(DONT_CONNECT DONT_RECONNECT RECONNECT_DELAY DISABLE_DISCONNECT LOG_RAW OPTION LOG DONT_LOG TARGET PROTOCOL)
50
50
  end
51
51
 
52
52
  after(:all) do
@@ -75,9 +75,9 @@ module Cosmos
75
75
  end
76
76
 
77
77
  @interface_keywords.each do |keyword|
78
- next if %w(DONT_CONNECT DONT_RECONNECT DISABLE_DISCONNECT DONT_LOG).include? keyword
78
+ next if %w(DONT_CONNECT DONT_RECONNECT DISABLE_DISCONNECT DONT_LOG LOG_RAW).include? keyword
79
79
  tf = Tempfile.new('unittest')
80
- tf.puts "INTERFACE CtsConfigTestInterface cts_config_test_interface.rb"
80
+ tf.puts "INTERFACE CTSSPEC_INT cts_config_test_interface.rb"
81
81
  tf.puts keyword
82
82
  tf.close
83
83
  expect { CmdTlmServerConfig.new(tf.path) }.to raise_error(ConfigParser::Error, /Not enough parameters for #{keyword}./)
@@ -120,8 +120,8 @@ module Cosmos
120
120
  tf.close
121
121
  config = CmdTlmServerConfig.new(tf.path)
122
122
  expect(config.packet_log_writer_pairs.keys).to eql ["DEFAULT","MY_WRITER"]
123
- expect(config.packet_log_writer_pairs["DEFAULT"].cmd_log_writer.logging_enabled).to be true
124
- expect(config.packet_log_writer_pairs["MY_WRITER"].cmd_log_writer.logging_enabled).to be false
123
+ expect(config.packet_log_writer_pairs["DEFAULT"].cmd_log_writer.logging_enabled).to eq true
124
+ expect(config.packet_log_writer_pairs["MY_WRITER"].cmd_log_writer.logging_enabled).to eq false
125
125
  tf.unlink
126
126
  config.packet_log_writer_pairs.each do |name, plwp|
127
127
  plwp.cmd_log_writer.shutdown
@@ -159,6 +159,57 @@ module Cosmos
159
159
  expect(config.interfaces.keys).to eql %w(INST_INT SYSTEM_INT)
160
160
  tf.unlink
161
161
  end
162
+
163
+ it "allows interfaces to be previously defined by INTERFACE_TARGET" do
164
+ # Stub out the CmdTlmServer
165
+ allow(CmdTlmServer).to receive_message_chain(:instance, :subscribe_limits_events)
166
+
167
+ tf = Tempfile.new('unittest')
168
+ tf.puts 'INTERFACE_TARGET INST'
169
+ tf.puts 'AUTO_INTERFACE_TARGETS'
170
+ tf.close
171
+ config = CmdTlmServerConfig.new(tf.path)
172
+ expect(config.interfaces.keys).to eql %w(INST_INT SYSTEM_INT)
173
+ tf.unlink
174
+ end
175
+
176
+ it "allows interfaces to be previously defined by INTERFACE" do
177
+ # Stub out the CmdTlmServer
178
+ allow(CmdTlmServer).to receive_message_chain(:instance, :subscribe_limits_events)
179
+
180
+ tf = Tempfile.new('unittest')
181
+ tf.puts 'INTERFACE INST_INT simulated_target_interface.rb sim_inst.rb'
182
+ tf.puts ' TARGET INST'
183
+ tf.puts 'AUTO_INTERFACE_TARGETS'
184
+ tf.close
185
+ config = CmdTlmServerConfig.new(tf.path)
186
+ expect(config.interfaces.keys).to eql %w(INST_INT SYSTEM_INT)
187
+ tf.unlink
188
+ end
189
+
190
+ it "complains about target name substitution" do
191
+ System.class_eval('@@instance = nil')
192
+ # Save system.txt
193
+ system_file = File.join(Cosmos::USERPATH,'config','system','system.txt')
194
+ FileUtils.mv system_file, Cosmos::USERPATH
195
+
196
+ # Create another system.txt with target name substitution
197
+ File.open(system_file,'w') do |file|
198
+ file.puts 'DECLARE_TARGET INST'
199
+ file.puts 'DECLARE_TARGET INST INST2'
200
+ end
201
+
202
+ tf = Tempfile.new('unittest')
203
+ tf.puts 'AUTO_INTERFACE_TARGETS'
204
+ tf.close
205
+ expect { CmdTlmServerConfig.new(tf.path) }.to raise_error(ConfigParser::Error, /Cannot use AUTO_INTERFACE_TARGETS with target name substitutions/)
206
+ tf.unlink
207
+
208
+ # Restore system.txt
209
+ FileUtils.mv File.join(Cosmos::USERPATH, 'system.txt'),
210
+ File.join(Cosmos::USERPATH,'config','system')
211
+ System.class_eval('@@instance = nil')
212
+ end
162
213
  end
163
214
 
164
215
  context "with INTERFACE_TARGET" do
@@ -187,6 +238,16 @@ module Cosmos
187
238
  tf.unlink
188
239
  end
189
240
 
241
+ it "complains if the target is already mapped to an interface" do
242
+ tf = Tempfile.new('unittest')
243
+ tf.puts 'INTERFACE INST_INT simulated_target_interface.rb sim_inst.rb'
244
+ tf.puts ' TARGET INST'
245
+ tf.puts 'INTERFACE_TARGET INST'
246
+ tf.close
247
+ expect { CmdTlmServerConfig.new(tf.path) }.to raise_error(ConfigParser::Error, /Target INST already mapped to interface INST_INT/)
248
+ tf.unlink
249
+ end
250
+
190
251
  it "processes an interface" do
191
252
  tf = Tempfile.new('unittest')
192
253
  tf.puts 'INTERFACE_TARGET INST'
@@ -200,7 +261,7 @@ module Cosmos
200
261
  context "with DONT_CONNECT" do
201
262
  it "complains about too many parameters" do
202
263
  tf = Tempfile.new('unittest')
203
- tf.puts "INTERFACE CtsConfigTestInterface cts_config_test_interface.rb"
264
+ tf.puts "INTERFACE CTSSPEC_INT cts_config_test_interface.rb"
204
265
  tf.puts 'DONT_CONNECT TRUE'
205
266
  tf.close
206
267
  expect { CmdTlmServerConfig.new(tf.path) }.to raise_error(ConfigParser::Error, /Too many parameters for DONT_CONNECT./)
@@ -209,11 +270,11 @@ module Cosmos
209
270
 
210
271
  it "sets the interface to not connect on startup" do
211
272
  tf = Tempfile.new('unittest')
212
- tf.puts "INTERFACE CtsConfigTestInterface cts_config_test_interface.rb"
273
+ tf.puts "INTERFACE CTSSPEC_INT cts_config_test_interface.rb"
213
274
  tf.puts 'DONT_CONNECT'
214
275
  tf.close
215
276
  config = CmdTlmServerConfig.new(tf.path)
216
- expect(config.interfaces['CTSCONFIGTESTINTERFACE'].connect_on_startup).to be false
277
+ expect(config.interfaces['CTSSPEC_INT'].connect_on_startup).to eq false
217
278
  tf.unlink
218
279
  end
219
280
  end
@@ -221,7 +282,7 @@ module Cosmos
221
282
  context "with DONT_RECONNECT" do
222
283
  it "complains about too many parameters" do
223
284
  tf = Tempfile.new('unittest')
224
- tf.puts "INTERFACE CtsConfigTestInterface cts_config_test_interface.rb"
285
+ tf.puts "INTERFACE CTSSPEC_INT cts_config_test_interface.rb"
225
286
  tf.puts 'DONT_RECONNECT TRUE'
226
287
  tf.close
227
288
  expect { CmdTlmServerConfig.new(tf.path) }.to raise_error(ConfigParser::Error, /Too many parameters for DONT_RECONNECT./)
@@ -230,11 +291,11 @@ module Cosmos
230
291
 
231
292
  it "sets the interface to not auto reconnect" do
232
293
  tf = Tempfile.new('unittest')
233
- tf.puts "INTERFACE CtsConfigTestInterface cts_config_test_interface.rb"
294
+ tf.puts "INTERFACE CTSSPEC_INT cts_config_test_interface.rb"
234
295
  tf.puts 'DONT_RECONNECT'
235
296
  tf.close
236
297
  config = CmdTlmServerConfig.new(tf.path)
237
- expect(config.interfaces['CTSCONFIGTESTINTERFACE'].auto_reconnect).to be false
298
+ expect(config.interfaces['CTSSPEC_INT'].auto_reconnect).to eq false
238
299
  tf.unlink
239
300
  end
240
301
  end
@@ -242,7 +303,7 @@ module Cosmos
242
303
  context "with RECONNECT_DELAY" do
243
304
  it "complains about too many parameters" do
244
305
  tf = Tempfile.new('unittest')
245
- tf.puts "INTERFACE CtsConfigTestInterface cts_config_test_interface.rb"
306
+ tf.puts "INTERFACE CTSSPEC_INT cts_config_test_interface.rb"
246
307
  tf.puts 'RECONNECT_DELAY 5.0 TRUE'
247
308
  tf.close
248
309
  expect { CmdTlmServerConfig.new(tf.path) }.to raise_error(ConfigParser::Error, /Too many parameters for RECONNECT_DELAY./)
@@ -251,11 +312,11 @@ module Cosmos
251
312
 
252
313
  it "sets the delay between reconnect tries" do
253
314
  tf = Tempfile.new('unittest')
254
- tf.puts "INTERFACE CtsConfigTestInterface cts_config_test_interface.rb"
315
+ tf.puts "INTERFACE CTSSPEC_INT cts_config_test_interface.rb"
255
316
  tf.puts 'RECONNECT_DELAY 5.0'
256
317
  tf.close
257
318
  config = CmdTlmServerConfig.new(tf.path)
258
- expect(config.interfaces['CTSCONFIGTESTINTERFACE'].reconnect_delay).to eql 5.0
319
+ expect(config.interfaces['CTSSPEC_INT'].reconnect_delay).to eql 5.0
259
320
  tf.unlink
260
321
  end
261
322
  end
@@ -263,7 +324,7 @@ module Cosmos
263
324
  context "with DISABLE_DISCONNECT" do
264
325
  it "complains about too many parameters" do
265
326
  tf = Tempfile.new('unittest')
266
- tf.puts "INTERFACE CtsConfigTestInterface cts_config_test_interface.rb"
327
+ tf.puts "INTERFACE CTSSPEC_INT cts_config_test_interface.rb"
267
328
  tf.puts 'DISABLE_DISCONNECT TRUE'
268
329
  tf.close
269
330
  expect { CmdTlmServerConfig.new(tf.path) }.to raise_error(ConfigParser::Error, /Too many parameters for DISABLE_DISCONNECT./)
@@ -272,11 +333,44 @@ module Cosmos
272
333
 
273
334
  it "sets the interface to not allow disconnects" do
274
335
  tf = Tempfile.new('unittest')
275
- tf.puts "INTERFACE CtsConfigTestInterface cts_config_test_interface.rb"
336
+ tf.puts "INTERFACE CTSSPEC_INT cts_config_test_interface.rb"
276
337
  tf.puts 'DISABLE_DISCONNECT'
277
338
  tf.close
278
339
  config = CmdTlmServerConfig.new(tf.path)
279
- expect(config.interfaces['CTSCONFIGTESTINTERFACE'].disable_disconnect).to be true
340
+ expect(config.interfaces['CTSSPEC_INT'].disable_disconnect).to eq true
341
+ tf.unlink
342
+ end
343
+ end
344
+
345
+ context "with LOG_RAW" do
346
+ it "create a raw logger on the interface" do
347
+ tf = Tempfile.new('unittest')
348
+ tf.puts "INTERFACE CTSSPEC_INT cts_config_test_interface.rb"
349
+ tf.puts 'LOG_RAW'
350
+ tf.close
351
+ config = CmdTlmServerConfig.new(tf.path)
352
+ expect(config.interfaces['CTSSPEC_INT'].raw_logger_pair).to be_a RawLoggerPair
353
+ expect(config.interfaces['CTSSPEC_INT'].raw_logger_pair.read_logger).to be_a RawLogger
354
+ expect(config.interfaces['CTSSPEC_INT'].raw_logger_pair.write_logger).to be_a RawLogger
355
+ tf.unlink
356
+ end
357
+
358
+ it "creates a customized raw logger on the interface" do
359
+ tf = Tempfile.new('unittest')
360
+ tf.puts "INTERFACE CTSSPEC_INT cts_config_test_interface.rb"
361
+ tf.puts "LOG_RAW raw_logger true 1000 'C:/logs'"
362
+ tf.close
363
+ config = CmdTlmServerConfig.new(tf.path)
364
+ read_logger = config.interfaces['CTSSPEC_INT'].raw_logger_pair.read_logger
365
+ expect(read_logger.orig_name).to eq "CTSSPEC_INT"
366
+ expect(read_logger.instance_variable_get("@logging_enabled")).to eq true
367
+ expect(read_logger.instance_variable_get("@cycle_size")).to eq 1000
368
+ expect(read_logger.instance_variable_get("@log_directory")).to eq "C:/logs"
369
+ write_logger = config.interfaces['CTSSPEC_INT'].raw_logger_pair.write_logger
370
+ expect(write_logger.orig_name).to eq "CTSSPEC_INT"
371
+ expect(write_logger.instance_variable_get("@logging_enabled")).to eq true
372
+ expect(write_logger.instance_variable_get("@cycle_size")).to eq 1000
373
+ expect(write_logger.instance_variable_get("@log_directory")).to eq "C:/logs"
280
374
  tf.unlink
281
375
  end
282
376
  end
@@ -284,7 +378,7 @@ module Cosmos
284
378
  context "with OPTION" do
285
379
  it "complains about too few parameters" do
286
380
  tf = Tempfile.new('unittest')
287
- tf.puts "INTERFACE CtsConfigTestInterface cts_config_test_interface.rb"
381
+ tf.puts "INTERFACE CTSSPEC_INT cts_config_test_interface.rb"
288
382
  tf.puts 'OPTION TRUE'
289
383
  tf.close
290
384
  expect { CmdTlmServerConfig.new(tf.path) }.to raise_error(ConfigParser::Error, /Not enough parameters for OPTION./)
@@ -293,11 +387,11 @@ module Cosmos
293
387
 
294
388
  it "sets the interface to listen on a specific address" do
295
389
  tf = Tempfile.new('unittest')
296
- tf.puts "INTERFACE CtsConfigTestInterface cts_config_test_interface.rb"
390
+ tf.puts "INTERFACE CTSSPEC_INT cts_config_test_interface.rb"
297
391
  tf.puts 'OPTION LISTEN_ADDRESS 127.0.0.1'
298
392
  tf.close
299
393
  config = CmdTlmServerConfig.new(tf.path)
300
- expect(config.interfaces['CTSCONFIGTESTINTERFACE'].options['LISTEN_ADDRESS']).to eql(['127.0.0.1'])
394
+ expect(config.interfaces['CTSSPEC_INT'].options['LISTEN_ADDRESS']).to eql(['127.0.0.1'])
301
395
  tf.unlink
302
396
  end
303
397
  end
@@ -305,7 +399,7 @@ module Cosmos
305
399
  context "with LOG" do
306
400
  it "complains about too many parameters" do
307
401
  tf = Tempfile.new('unittest')
308
- tf.puts "INTERFACE CtsConfigTestInterface cts_config_test_interface.rb"
402
+ tf.puts "INTERFACE CTSSPEC_INT cts_config_test_interface.rb"
309
403
  tf.puts 'LOG PacketLogWriter TRUE'
310
404
  tf.close
311
405
  expect { CmdTlmServerConfig.new(tf.path) }.to raise_error(ConfigParser::Error, /Too many parameters for LOG./)
@@ -314,7 +408,7 @@ module Cosmos
314
408
 
315
409
  it "complains about unknown log writers" do
316
410
  tf = Tempfile.new('unittest')
317
- tf.puts "INTERFACE CtsConfigTestInterface cts_config_test_interface.rb"
411
+ tf.puts "INTERFACE CTSSPEC_INT cts_config_test_interface.rb"
318
412
  tf.puts 'LOG MyLogWriter'
319
413
  tf.close
320
414
  expect { CmdTlmServerConfig.new(tf.path) }.to raise_error(ConfigParser::Error, /Unknown packet log writer: MYLOGWRITER/)
@@ -323,21 +417,21 @@ module Cosmos
323
417
 
324
418
  it "adds a packet log writer to the interface" do
325
419
  tf = Tempfile.new('unittest')
326
- tf.puts "INTERFACE CtsConfigTestInterface cts_config_test_interface.rb"
420
+ tf.puts "INTERFACE CTSSPEC_INT cts_config_test_interface.rb"
327
421
  tf.puts 'LOG DEFAULT'
328
422
  tf.close
329
423
  config = CmdTlmServerConfig.new(tf.path)
330
- expect(config.interfaces['CTSCONFIGTESTINTERFACE'].packet_log_writer_pairs.length).to eql 1
424
+ expect(config.interfaces['CTSSPEC_INT'].packet_log_writer_pairs.length).to eql 1
331
425
  tf.unlink
332
426
 
333
427
  tf = Tempfile.new('unittest')
334
428
  tf.puts 'PACKET_LOG_WRITER MY_WRITER packet_log_writer.rb'
335
- tf.puts "INTERFACE CtsConfigTestInterface cts_config_test_interface.rb"
429
+ tf.puts "INTERFACE CTSSPEC_INT cts_config_test_interface.rb"
336
430
  tf.puts 'LOG DEFAULT'
337
431
  tf.puts 'LOG MY_WRITER'
338
432
  tf.close
339
433
  config = CmdTlmServerConfig.new(tf.path)
340
- expect(config.interfaces['CTSCONFIGTESTINTERFACE'].packet_log_writer_pairs.length).to eql 2
434
+ expect(config.interfaces['CTSSPEC_INT'].packet_log_writer_pairs.length).to eql 2
341
435
  tf.unlink
342
436
  end
343
437
  end
@@ -345,7 +439,7 @@ module Cosmos
345
439
  context "with DONT_LOG" do
346
440
  it "complains about too many parameters" do
347
441
  tf = Tempfile.new('unittest')
348
- tf.puts "INTERFACE CtsConfigTestInterface cts_config_test_interface.rb"
442
+ tf.puts "INTERFACE CTSSPEC_INT cts_config_test_interface.rb"
349
443
  tf.puts 'DONT_LOG TRUE'
350
444
  tf.close
351
445
  expect { CmdTlmServerConfig.new(tf.path) }.to raise_error(ConfigParser::Error, /Too many parameters for DONT_LOG./)
@@ -354,11 +448,11 @@ module Cosmos
354
448
 
355
449
  it "removes loggers from the interface" do
356
450
  tf = Tempfile.new('unittest')
357
- tf.puts "INTERFACE CtsConfigTestInterface cts_config_test_interface.rb"
451
+ tf.puts "INTERFACE CTSSPEC_INT cts_config_test_interface.rb"
358
452
  tf.puts 'DONT_LOG'
359
453
  tf.close
360
454
  config = CmdTlmServerConfig.new(tf.path)
361
- expect(config.interfaces['CTSCONFIGTESTINTERFACE'].packet_log_writer_pairs.length).to eql 0
455
+ expect(config.interfaces['CTSSPEC_INT'].packet_log_writer_pairs.length).to eql 0
362
456
  tf.unlink
363
457
  end
364
458
  end
@@ -366,7 +460,7 @@ module Cosmos
366
460
  context "with TARGET" do
367
461
  it "complains about too many parameters" do
368
462
  tf = Tempfile.new('unittest')
369
- tf.puts "INTERFACE CtsConfigTestInterface cts_config_test_interface.rb"
463
+ tf.puts "INTERFACE CTSSPEC_INT cts_config_test_interface.rb"
370
464
  tf.puts 'TARGET TEST TRUE'
371
465
  tf.close
372
466
  expect { CmdTlmServerConfig.new(tf.path) }.to raise_error(ConfigParser::Error, /Too many parameters for TARGET./)
@@ -375,10 +469,20 @@ module Cosmos
375
469
 
376
470
  it "complains about unknown targets" do
377
471
  tf = Tempfile.new('unittest')
378
- tf.puts "INTERFACE CtsConfigTestInterface cts_config_test_interface.rb"
472
+ tf.puts "INTERFACE TEST_INT cts_config_test_interface.rb"
379
473
  tf.puts 'TARGET BLAH'
380
474
  tf.close
381
- expect { CmdTlmServerConfig.new(tf.path) }.to raise_error(ConfigParser::Error, /Unknown target BLAH mapped to interface CTSCONFIGTESTINTERFACE/)
475
+ expect { CmdTlmServerConfig.new(tf.path) }.to raise_error(ConfigParser::Error, /Unknown target BLAH mapped to interface TEST_INT/)
476
+ tf.unlink
477
+ end
478
+
479
+ it "complains if the target is already mapped" do
480
+ tf = Tempfile.new('unittest')
481
+ tf.puts "INTERFACE TEST_INT cts_config_test_interface.rb"
482
+ tf.puts 'TARGET TEST'
483
+ tf.puts 'TARGET TEST'
484
+ tf.close
485
+ expect { CmdTlmServerConfig.new(tf.path) }.to raise_error(ConfigParser::Error, /Target TEST already mapped to interface TEST_INT/)
382
486
  tf.unlink
383
487
  end
384
488
  end
@@ -386,7 +490,7 @@ module Cosmos
386
490
  context "with PROTOCOL" do
387
491
  it "requires two parameters" do
388
492
  tf = Tempfile.new('unittest')
389
- tf.puts "INTERFACE CtsConfigTestInterface cts_config_test_interface.rb"
493
+ tf.puts "INTERFACE CTSSPEC_INT cts_config_test_interface.rb"
390
494
  tf.puts 'PROTOCOL'
391
495
  tf.close
392
496
  expect { CmdTlmServerConfig.new(tf.path) }.to raise_error(ConfigParser::Error, /Not enough parameters for PROTOCOL/)
@@ -395,7 +499,7 @@ module Cosmos
395
499
 
396
500
  it "requires a READ, WRITE, or READ_WRITE descriptor" do
397
501
  tf = Tempfile.new('unittest')
398
- tf.puts "INTERFACE CtsConfigTestInterface cts_config_test_interface.rb"
502
+ tf.puts "INTERFACE CTSSPEC_INT cts_config_test_interface.rb"
399
503
  tf.puts 'PROTOCOL BLAH cts_config_test_protocol.rb'
400
504
  tf.close
401
505
  expect { CmdTlmServerConfig.new(tf.path) }.to raise_error(ConfigParser::Error, /Invalid protocol type: BLAH/)
@@ -404,85 +508,94 @@ module Cosmos
404
508
 
405
509
  it "requires a protocol filename or class" do
406
510
  tf = Tempfile.new('unittest')
407
- tf.puts "INTERFACE CtsConfigTestInterface cts_config_test_interface.rb"
511
+ tf.puts "INTERFACE CTSSPEC_INT cts_config_test_interface.rb"
408
512
  tf.puts 'PROTOCOL READ'
409
513
  tf.close
410
514
  expect { CmdTlmServerConfig.new(tf.path) }.to raise_error(ConfigParser::Error, /Not enough parameters for PROTOCOL/)
411
515
  tf.unlink
412
516
  end
413
517
 
518
+ it "complains about filenames or classes which aren't found" do
519
+ tf = Tempfile.new('unittest')
520
+ tf.puts "INTERFACE CTSSPEC_INT cts_config_test_interface.rb"
521
+ tf.puts 'PROTOCOL READ this_is_not_a_file.rb'
522
+ tf.close
523
+ expect { CmdTlmServerConfig.new(tf.path) }.to raise_error(ConfigParser::Error, /Unable to require this_is_not_a_file.rb/)
524
+ tf.unlink
525
+ end
526
+
414
527
  it "instantiates via the file name" do
415
528
  tf = Tempfile.new('unittest')
416
- tf.puts "INTERFACE CtsConfigTestInterface cts_config_test_interface.rb"
529
+ tf.puts "INTERFACE CTSSPEC_INT cts_config_test_interface.rb"
417
530
  tf.puts 'PROTOCOL READ cts_config_test_protocol.rb'
418
531
  tf.close
419
532
  config = CmdTlmServerConfig.new(tf.path)
420
- expect(config.interfaces['CTSCONFIGTESTINTERFACE'].read_protocols[0].class).to be CtsConfigTestProtocol
533
+ expect(config.interfaces['CTSSPEC_INT'].read_protocols[0].class).to eq CtsConfigTestProtocol
421
534
  tf.unlink
422
535
  end
423
536
 
424
537
  it "instantiates via the class name" do
425
538
  tf = Tempfile.new('unittest')
426
- tf.puts "INTERFACE CtsConfigTestInterface cts_config_test_interface.rb"
539
+ tf.puts "INTERFACE CTSSPEC_INT cts_config_test_interface.rb"
427
540
  tf.puts 'PROTOCOL READ CtsConfigTestProtocol'
428
541
  tf.close
429
542
  config = CmdTlmServerConfig.new(tf.path)
430
- expect(config.interfaces['CTSCONFIGTESTINTERFACE'].read_protocols[0].class).to be CtsConfigTestProtocol
543
+ expect(config.interfaces['CTSSPEC_INT'].read_protocols[0].class).to eq CtsConfigTestProtocol
431
544
  tf.unlink
432
545
  end
433
546
 
434
547
  it "appends to the list of READ protocols" do
435
548
  tf = Tempfile.new('unittest')
436
- tf.puts "INTERFACE CtsConfigTestInterface cts_config_test_interface.rb"
549
+ tf.puts "INTERFACE CTSSPEC_INT cts_config_test_interface.rb"
437
550
  tf.puts 'PROTOCOL READ OverrideProtocol'
438
551
  tf.puts 'PROTOCOL READ CtsConfigTestProtocol'
439
552
  tf.close
440
553
  config = CmdTlmServerConfig.new(tf.path)
441
- read_protocols = config.interfaces['CTSCONFIGTESTINTERFACE'].read_protocols
442
- expect(read_protocols[0].class).to be OverrideProtocol
443
- expect(read_protocols[1].class).to be CtsConfigTestProtocol
444
- expect(config.interfaces['CTSCONFIGTESTINTERFACE'].write_protocols).to be_empty
554
+ read_protocols = config.interfaces['CTSSPEC_INT'].read_protocols
555
+ expect(read_protocols[0].class).to eq OverrideProtocol
556
+ expect(read_protocols[1].class).to eq CtsConfigTestProtocol
557
+ expect(config.interfaces['CTSSPEC_INT'].write_protocols).to be_empty
445
558
  tf.unlink
446
559
  end
447
560
 
448
561
  it "prepends to the list of WRITE protocols" do
449
562
  tf = Tempfile.new('unittest')
450
- tf.puts "INTERFACE CtsConfigTestInterface cts_config_test_interface.rb"
563
+ tf.puts "INTERFACE CTSSPEC_INT cts_config_test_interface.rb"
451
564
  tf.puts 'PROTOCOL WRITE OverrideProtocol'
452
565
  tf.puts 'PROTOCOL WRITE CtsConfigTestProtocol'
453
566
  tf.close
454
567
  config = CmdTlmServerConfig.new(tf.path)
455
- write_protocols = config.interfaces['CTSCONFIGTESTINTERFACE'].write_protocols
456
- expect(write_protocols[0].class).to be CtsConfigTestProtocol
457
- expect(write_protocols[1].class).to be OverrideProtocol
458
- expect(config.interfaces['CTSCONFIGTESTINTERFACE'].read_protocols).to be_empty
568
+ write_protocols = config.interfaces['CTSSPEC_INT'].write_protocols
569
+ expect(write_protocols[0].class).to eq CtsConfigTestProtocol
570
+ expect(write_protocols[1].class).to eq OverrideProtocol
571
+ expect(config.interfaces['CTSSPEC_INT'].read_protocols).to be_empty
459
572
  tf.unlink
460
573
  end
461
574
 
462
575
  it "adds to both with READ_WRITE" do
463
576
  tf = Tempfile.new('unittest')
464
- tf.puts "INTERFACE CtsConfigTestInterface cts_config_test_interface.rb"
577
+ tf.puts "INTERFACE CTSSPEC_INT cts_config_test_interface.rb"
465
578
  tf.puts 'PROTOCOL READ_WRITE OverrideProtocol'
466
579
  tf.puts 'PROTOCOL READ_WRITE CtsConfigTestProtocol'
467
580
  tf.close
468
581
  config = CmdTlmServerConfig.new(tf.path)
469
- read_protocols = config.interfaces['CTSCONFIGTESTINTERFACE'].read_protocols
470
- write_protocols = config.interfaces['CTSCONFIGTESTINTERFACE'].write_protocols
471
- expect(read_protocols[0].class).to be OverrideProtocol
472
- expect(read_protocols[1].class).to be CtsConfigTestProtocol
473
- expect(write_protocols[0].class).to be CtsConfigTestProtocol
474
- expect(write_protocols[1].class).to be OverrideProtocol
582
+ read_protocols = config.interfaces['CTSSPEC_INT'].read_protocols
583
+ write_protocols = config.interfaces['CTSSPEC_INT'].write_protocols
584
+ expect(read_protocols[0].class).to eq OverrideProtocol
585
+ expect(read_protocols[1].class).to eq CtsConfigTestProtocol
586
+ expect(write_protocols[0].class).to eq CtsConfigTestProtocol
587
+ expect(write_protocols[1].class).to eq OverrideProtocol
475
588
  tf.unlink
476
589
  end
477
590
 
478
591
  it "stores initialization parameters" do
479
592
  tf = Tempfile.new('unittest')
480
- tf.puts "INTERFACE CtsConfigTestInterface cts_config_test_interface.rb"
593
+ tf.puts "INTERFACE CTSSPEC_INT cts_config_test_interface.rb"
481
594
  tf.puts 'PROTOCOL READ cts_config_test_protocol.rb PARAM1 20'
482
595
  tf.close
483
596
  config = CmdTlmServerConfig.new(tf.path)
484
- pinfo = config.interfaces['CTSCONFIGTESTINTERFACE'].protocol_info[0]
485
- expect(pinfo[0]).to be CtsConfigTestProtocol
597
+ pinfo = config.interfaces['CTSSPEC_INT'].protocol_info[0]
598
+ expect(pinfo[0]).to eq CtsConfigTestProtocol
486
599
  expect(pinfo[1]).to eq ['PARAM1', '20']
487
600
  expect(pinfo[2]).to eq :READ
488
601
  tf.unlink
@@ -492,10 +605,10 @@ module Cosmos
492
605
  context "with two interfaces with the same name" do
493
606
  it "complains about duplicate interface names" do
494
607
  tf = Tempfile.new('unittest')
495
- tf.puts "INTERFACE CtsConfigTestInterface cts_config_test_interface.rb"
496
- tf.puts "INTERFACE CtsConfigTestInterface cts_config_test_interface.rb"
608
+ tf.puts "INTERFACE CTSSPEC_INT cts_config_test_interface.rb"
609
+ tf.puts "INTERFACE CTSSPEC_INT cts_config_test_interface.rb"
497
610
  tf.close
498
- expect { CmdTlmServerConfig.new(tf.path) }.to raise_error(ConfigParser::Error, /Interface 'CTSCONFIGTESTINTERFACE' defined twice/)
611
+ expect { CmdTlmServerConfig.new(tf.path) }.to raise_error(ConfigParser::Error, /Interface 'CTSSPEC_INT' defined twice/)
499
612
  tf.unlink
500
613
  end
501
614
  end
@@ -544,17 +657,17 @@ module Cosmos
544
657
  it "complains if the interface is undefined" do
545
658
  tf = Tempfile.new('unittest')
546
659
  tf.puts 'ROUTER ROUTER cts_config_test_interface.rb'
547
- tf.puts 'ROUTE CTSCONFIGTESTINTERFACE'
660
+ tf.puts 'ROUTE CTSSPEC_INT'
548
661
  tf.close
549
- expect { CmdTlmServerConfig.new(tf.path) }.to raise_error(ConfigParser::Error, /Unknown interface CTSCONFIGTESTINTERFACE mapped to router ROUTER/)
662
+ expect { CmdTlmServerConfig.new(tf.path) }.to raise_error(ConfigParser::Error, /Unknown interface CTSSPEC_INT mapped to router ROUTER/)
550
663
  tf.unlink
551
664
  end
552
665
 
553
666
  it "creates the route" do
554
667
  tf = Tempfile.new('unittest')
555
- tf.puts "INTERFACE CtsConfigTestInterface cts_config_test_interface.rb"
668
+ tf.puts "INTERFACE CTSSPEC_INT cts_config_test_interface.rb"
556
669
  tf.puts 'ROUTER ROUTER cts_config_test_interface.rb'
557
- tf.puts 'ROUTE CTSCONFIGTESTINTERFACE'
670
+ tf.puts 'ROUTE CTSSPEC_INT'
558
671
  tf.close
559
672
  config = CmdTlmServerConfig.new(tf.path)
560
673
  expect(config.routers['ROUTER'].interfaces[0]).to be_a CtsConfigTestInterface
@@ -593,11 +706,14 @@ module Cosmos
593
706
  tf = Tempfile.new('unittest')
594
707
  tf.puts 'BACKGROUND_TASK cts_config_test_background_task_no_args.rb'
595
708
  tf.puts 'BACKGROUND_TASK cts_config_test_background_task_args.rb 1 2 3'
709
+ tf.puts ' STOPPED'
596
710
  tf.close
597
711
  config = CmdTlmServerConfig.new(tf.path)
598
712
  expect(config.background_tasks.length).to eql 2
599
713
  expect(config.background_tasks[0]).to be_a CtsConfigTestBackgroundTaskNoArgs
714
+ expect(config.background_tasks[0].stopped).to be false
600
715
  expect(config.background_tasks[1]).to be_a CtsConfigTestBackgroundTaskArgs
716
+ expect(config.background_tasks[1].stopped).to be true
601
717
  tf.unlink
602
718
 
603
719
  File.delete background_task_no_args_file
@@ -605,6 +721,23 @@ module Cosmos
605
721
  end
606
722
  end
607
723
 
724
+ context "with COLLECT_METADATA" do
725
+ it "indicates metadata should be collected" do
726
+ tf = Tempfile.new('unittest')
727
+ tf.close
728
+ config = CmdTlmServerConfig.new(tf.path)
729
+ expect(config.metadata).to be false
730
+ tf.unlink
731
+
732
+ tf = Tempfile.new('unittest')
733
+ tf.puts 'COLLECT_METADATA'
734
+ tf.close
735
+ config = CmdTlmServerConfig.new(tf.path)
736
+ expect(config.metadata).to be true
737
+ tf.unlink
738
+ end
739
+ end
740
+
608
741
  end
609
742
  end
610
743
  end