cosmos 4.4.0-java → 4.5.1-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.dockerignore +2 -0
- data/.gitignore +1 -0
- data/.travis.yml +6 -6
- data/Dockerfile +70 -0
- data/Manifest.txt +37 -2
- data/README.md +9 -0
- data/Rakefile +55 -5
- data/appveyor.yml +18 -8
- data/autohotkey/config/tools/cmd_sequence/cmd_sequence.txt +2 -0
- data/autohotkey/lib/cmd_sequence_exporter.rb +52 -0
- data/autohotkey/procedures/collect.rb +2 -2
- data/autohotkey/procedures/collect_util.rb +1 -1
- data/autohotkey/procedures/script_test.rb +1 -1
- data/autohotkey/tools/CmdSenderAHK2 +18 -0
- data/autohotkey/tools/cmd_extractor.ahk +11 -9
- data/autohotkey/tools/cmd_sender.ahk +35 -7
- data/autohotkey/tools/cmd_sender2.ahk +4 -0
- data/autohotkey/tools/cmd_sequence.ahk +22 -9
- data/autohotkey/tools/config_editor.ahk +4 -4
- data/autohotkey/tools/data_viewer.ahk +1 -1
- data/autohotkey/tools/limits_monitor.ahk +1 -1
- data/autohotkey/tools/packet_viewer.ahk +1 -1
- data/autohotkey/tools/script_runner.ahk +1 -1
- data/autohotkey/tools/test_runner2.ahk +1 -1
- data/autohotkey/tools/tlm_grapher.ahk +1 -1
- data/autohotkey/tools/tlm_grapher3.ahk +1 -1
- data/autohotkey/tools/tlm_viewer.ahk +1 -1
- data/autohotkey/tools/tlm_viewer2.ahk +1 -1
- data/autohotkey/tools/tlm_viewer5.ahk +1 -1
- data/bin/cstol_converter +1 -1
- data/bin/rubysloc +73 -28
- data/bin/xtce_converter +1 -1
- data/cosmos.gemspec +2 -2
- data/data/config/command_modifiers.yaml +16 -1
- data/data/config/interface_modifiers.yaml +3 -2
- data/data/config/param_item_modifiers.yaml +5 -0
- data/data/config/system.yaml +110 -23
- data/data/config/telemetry_modifiers.yaml +16 -1
- data/data/crc.txt +416 -411
- data/demo/Rakefile +4 -4
- data/demo/config/dart/Gemfile +1 -6
- data/demo/config/data/crc.txt +233 -232
- data/demo/config/system/system.txt +17 -6
- data/demo/config/system/system2.txt +17 -6
- data/demo/config/system/system_alt_ports.txt +17 -6
- data/demo/config/targets/INST/cmd_tlm/inst_cmds.txt +4 -4
- data/demo/config/targets/INST/cmd_tlm/inst_tlm.txt +4 -0
- data/demo/config/targets/INST/cmd_tlm/inst_tlm_override.txt +12 -0
- data/demo/config/targets/INST/lib/sim_inst.rb +2 -2
- data/demo/config/targets/INST/target.txt +1 -0
- data/demo/config/tools/handbook_creator/default_toc.xsl +59 -59
- data/demo/procedures/cosmos_api_test.rb +8 -8
- data/ext/cosmos/ext/buffered_file/buffered_file.c +2 -2
- data/ext/cosmos/ext/config_parser/config_parser.c +1 -2
- data/ext/cosmos/ext/line_graph/line_graph.c +53 -94
- data/ext/cosmos/ext/platform/platform.c +56 -21
- data/ext/cosmos/ext/polynomial_conversion/polynomial_conversion.c +4 -8
- data/ext/cosmos/ext/structure/structure.c +12 -0
- data/extensions/vscode/.gitignore +4 -0
- data/extensions/vscode/.vscode/launch.json +32 -0
- data/extensions/vscode/.vscode/settings.json +13 -0
- data/extensions/vscode/.vscode/tasks.json +79 -0
- data/extensions/vscode/License.txt +879 -0
- data/extensions/vscode/README.md +9 -0
- data/extensions/vscode/client/License.txt +879 -0
- data/extensions/vscode/client/README.md +39 -0
- data/extensions/vscode/client/cosmos.configuration.json +23 -0
- data/extensions/vscode/client/images/icon.png +0 -0
- data/extensions/vscode/client/package-lock.json +414 -0
- data/extensions/vscode/client/package.json +105 -0
- data/extensions/vscode/client/src/extension.ts +132 -0
- data/extensions/vscode/client/src/screen_preview.rb +25 -0
- data/extensions/vscode/client/syntaxes/cosmos.tmLanguage.json +219 -0
- data/extensions/vscode/client/tsconfig.json +17 -0
- data/extensions/vscode/package-lock.json +26 -0
- data/extensions/vscode/package.json +35 -0
- data/extensions/vscode/server/License.txt +879 -0
- data/extensions/vscode/server/package-lock.json +236 -0
- data/extensions/vscode/server/package.json +29 -0
- data/extensions/vscode/server/src/server.ts +59 -0
- data/extensions/vscode/server/tsconfig.json +16 -0
- data/install/Rakefile +4 -4
- data/install/config/dart/Gemfile +2 -7
- data/install/config/data/crc.txt +137 -137
- data/install/config/system/system.txt +17 -6
- data/install/config/tools/handbook_creator/default_toc.xsl +59 -59
- data/lib/cosmos/config/config_parser.rb +2 -10
- data/lib/cosmos/core_ext/class.rb +10 -0
- data/lib/cosmos/core_ext/time.rb +5 -3
- data/lib/cosmos/dart/config/boot.rb +1 -1
- data/lib/cosmos/dart/config/database.yml +2 -0
- data/lib/cosmos/dart/examples/dart_decom_client.rb +1 -1
- data/lib/cosmos/dart/lib/dart_common.rb +12 -5
- data/lib/cosmos/dart/lib/dart_constants.rb +15 -0
- data/lib/cosmos/dart/lib/dart_decom_query.rb +5 -6
- data/lib/cosmos/dart/lib/dart_decommutator.rb +64 -54
- data/lib/cosmos/dart/lib/dart_master_query.rb +71 -0
- data/lib/cosmos/dart/lib/dart_reducer_worker_thread.rb +165 -134
- data/lib/cosmos/dart/processes/dart.rb +4 -2
- data/lib/cosmos/dart/processes/dart_decom_server.rb +3 -3
- data/lib/cosmos/dart/processes/dart_ingester.rb +38 -1
- data/lib/cosmos/dart/processes/dart_master.rb +44 -0
- data/lib/cosmos/dart/processes/dart_util.rb +115 -0
- data/lib/cosmos/dart/spec/dart/dart_database_cleaner_spec.rb +2 -2
- data/lib/cosmos/gui/qt.rb +10 -10
- data/lib/cosmos/gui/qt_tool.rb +17 -12
- data/lib/cosmos/gui/text/completion_text_edit.rb +2 -0
- data/lib/cosmos/gui/widgets/dart_meta_frame.rb +22 -3
- data/lib/cosmos/interfaces/dart_status_interface.rb +1 -1
- data/lib/cosmos/interfaces/linc_interface.rb +3 -3
- data/lib/cosmos/interfaces/protocols/burst_protocol.rb +1 -1
- data/lib/cosmos/interfaces/protocols/crc_protocol.rb +1 -1
- data/lib/cosmos/interfaces/protocols/length_protocol.rb +5 -0
- data/lib/cosmos/interfaces/protocols/template_protocol.rb +3 -3
- data/lib/cosmos/interfaces/serial_interface.rb +7 -1
- data/lib/cosmos/interfaces/stream_interface.rb +1 -1
- data/lib/cosmos/interfaces/tcpip_server_interface.rb +16 -16
- data/lib/cosmos/io/io_multiplexer.rb +6 -2
- data/lib/cosmos/io/json_drb.rb +5 -5
- data/lib/cosmos/io/json_drb_object.rb +7 -2
- data/lib/cosmos/io/json_drb_rack.rb +25 -5
- data/lib/cosmos/io/json_rpc.rb +1 -1
- data/lib/cosmos/io/posix_serial_driver.rb +60 -22
- data/lib/cosmos/io/serial_driver.rb +11 -8
- data/lib/cosmos/io/win32_serial_driver.rb +31 -3
- data/lib/cosmos/packet_logs/packet_log_reader.rb +2 -2
- data/lib/cosmos/packets/packet.rb +9 -9
- data/lib/cosmos/packets/packet_config.rb +27 -9
- data/lib/cosmos/packets/parsers/xtce_converter.rb +10 -10
- data/lib/cosmos/packets/parsers/xtce_parser.rb +3 -0
- data/lib/cosmos/packets/structure.rb +35 -5
- data/lib/cosmos/packets/structure_item.rb +5 -1
- data/lib/cosmos/packets/telemetry.rb +7 -1
- data/lib/cosmos/script/api_shared.rb +18 -1
- data/lib/cosmos/script/extract.rb +1 -1
- data/lib/cosmos/script/script.rb +4 -11
- data/lib/cosmos/streams/serial_stream.rb +11 -6
- data/lib/cosmos/system/system.rb +155 -57
- data/lib/cosmos/tools/cmd_sender/cmd_param_table_item_delegate.rb +15 -0
- data/lib/cosmos/tools/cmd_sender/cmd_params.rb +382 -0
- data/lib/cosmos/tools/cmd_sender/cmd_sender.rb +29 -318
- data/lib/cosmos/tools/cmd_sequence/cmd_sequence.rb +14 -17
- data/lib/cosmos/tools/cmd_sequence/sequence_item.rb +38 -331
- data/lib/cosmos/tools/cmd_sequence/sequence_list.rb +16 -11
- data/lib/cosmos/tools/cmd_tlm_server/api.rb +10 -8
- data/lib/cosmos/tools/cmd_tlm_server/cmd_tlm_server.rb +2 -2
- data/lib/cosmos/tools/cmd_tlm_server/cmd_tlm_server_gui.rb +1 -0
- data/lib/cosmos/tools/cmd_tlm_server/gui/logging_tab.rb +1 -1
- data/lib/cosmos/tools/cmd_tlm_server/interface_thread.rb +29 -26
- data/lib/cosmos/tools/cmd_tlm_server/limits_groups_background_task.rb +1 -1
- data/lib/cosmos/tools/cmd_tlm_server/router_thread.rb +5 -0
- data/lib/cosmos/tools/config_editor/config_editor.rb +34 -3
- data/lib/cosmos/tools/config_editor/config_editor_frame.rb +8 -9
- data/lib/cosmos/tools/config_editor/system_config_dialog.rb +158 -0
- data/lib/cosmos/tools/handbook_creator/handbook_creator.rb +1 -1
- data/lib/cosmos/tools/handbook_creator/handbook_creator_config.rb +1 -1
- data/lib/cosmos/tools/script_runner/script_runner_frame.rb +7 -4
- data/lib/cosmos/tools/test_runner/test.rb +6 -3
- data/lib/cosmos/tools/test_runner/test_runner.rb +6 -6
- data/lib/cosmos/tools/tlm_extractor/tlm_extractor.rb +3 -3
- data/lib/cosmos/tools/tlm_extractor/tlm_extractor_config.rb +1 -4
- data/lib/cosmos/tools/tlm_extractor/tlm_extractor_processor.rb +20 -16
- data/lib/cosmos/tools/tlm_grapher/tabbed_plots_tool/tabbed_plots_dart_thread.rb +21 -17
- data/lib/cosmos/tools/tlm_grapher/tlm_grapher.rb +18 -11
- data/lib/cosmos/tools/tlm_viewer/tlm_viewer.rb +17 -6
- data/lib/cosmos/tools/tlm_viewer/widgets/canvasdot_widget.rb +2 -0
- data/lib/cosmos/top_level.rb +1 -1
- data/lib/cosmos/utilities/ruby_lex_utils.rb +34 -30
- data/lib/cosmos/utilities/simulated_target.rb +1 -1
- data/lib/cosmos/version.rb +5 -5
- data/lib/cosmos/win32/excel.rb +23 -17
- data/run_gui_tests.bat +1 -0
- data/spec/core_ext/class_spec.rb +54 -0
- data/spec/core_ext/socket_spec.rb +1 -1
- data/spec/core_ext/time_spec.rb +4 -0
- data/spec/install/yaml_docs_spec.rb +26 -6
- data/spec/interfaces/linc_interface_spec.rb +1 -1
- data/spec/interfaces/protocols/length_protocol_spec.rb +39 -0
- data/spec/interfaces/serial_interface_spec.rb +1 -5
- data/spec/io/json_drb_rack_spec.rb +166 -0
- data/spec/io/json_drb_spec.rb +14 -0
- data/spec/io/json_rpc_spec.rb +4 -5
- data/spec/io/posix_serial_driver_spec.rb +81 -0
- data/spec/io/win32_serial_driver_spec.rb +33 -3
- data/spec/packet_logs/packet_log_reader_spec.rb +36 -37
- data/spec/packets/structure_spec.rb +52 -2
- data/spec/packets/telemetry_spec.rb +29 -1
- data/spec/script/extract_spec.rb +4 -1
- data/spec/system/system_spec.rb +111 -3
- data/spec/tools/cmd_tlm_server/api_spec.rb +12 -12
- data/spec/tools/cmd_tlm_server/background_tasks_spec.rb +2 -2
- data/spec/tools/cmd_tlm_server/interface_thread_spec.rb +4 -3
- data/spec/tools/cmd_tlm_server/router_thread_spec.rb +2 -3
- data/spec/utilities/logger_spec.rb +3 -3
- data/spec/utilities/message_log_spec.rb +6 -3
- data/tasks/gemfile_stats.rake +22 -13
- data/test/performance/Rakefile +4 -4
- data/test/performance/config/data/crc.txt +67 -48
- metadata +44 -9
- data/demo/outputs/dart/logs/README.txt +0 -1
- data/lib/cosmos/dart/Gemfile +0 -69
data/spec/io/json_drb_spec.rb
CHANGED
@@ -200,6 +200,20 @@ module Cosmos
|
|
200
200
|
sleep(0.1)
|
201
201
|
end
|
202
202
|
|
203
|
+
it "processes success requests with uppercase" do
|
204
|
+
class MyServer5
|
205
|
+
def my_method(param)
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
209
|
+
@json.start_service('127.0.0.1', 7777, MyServer5.new)
|
210
|
+
request_data = JsonRpcRequest.new('MY_METHOD', 'param', 1).to_json
|
211
|
+
_, error_code = @json.process_request(request_data, Time.now)
|
212
|
+
expect(error_code).to eq nil
|
213
|
+
@json.stop_service
|
214
|
+
sleep(0.1)
|
215
|
+
end
|
216
|
+
|
203
217
|
it "does not allow dangerous methods" do
|
204
218
|
@json.start_service('127.0.0.1', 7777, self)
|
205
219
|
request_data = JsonRpcRequest.new('send', 'param', 1).to_json
|
data/spec/io/json_rpc_spec.rb
CHANGED
@@ -238,25 +238,25 @@ module Cosmos
|
|
238
238
|
|
239
239
|
it "reports an error if there is no 'result' or 'error' key" do
|
240
240
|
json = JsonRpcResponse.new(10).as_json
|
241
|
-
expect { JsonRpcResponse.from_json(json.to_json) }.to raise_error(
|
241
|
+
expect { JsonRpcResponse.from_json(json.to_json) }.to raise_error(/Invalid JSON-RPC 2.0 Response/)
|
242
242
|
end
|
243
243
|
|
244
244
|
it "reports an error if the version isn't 2.0" do
|
245
245
|
json = JsonRpcResponse.new(10).as_json
|
246
246
|
json['jsonrpc'] = "1.1"
|
247
247
|
json['result'] = "true"
|
248
|
-
expect { JsonRpcResponse.from_json(json.to_json) }.to raise_error(
|
248
|
+
expect { JsonRpcResponse.from_json(json.to_json) }.to raise_error(/Invalid JSON-RPC 2.0 Response/)
|
249
249
|
end
|
250
250
|
|
251
251
|
it "reports an error if there is both a 'result' and 'error' key" do
|
252
252
|
json = JsonRpcResponse.new(10).as_json
|
253
253
|
json['result'] = "true"
|
254
254
|
json['error'] = {"code"=>-1, "message"=>"error"}
|
255
|
-
expect { JsonRpcResponse.from_json(json.to_json) }.to raise_error(
|
255
|
+
expect { JsonRpcResponse.from_json(json.to_json) }.to raise_error(/Invalid JSON-RPC 2.0 Response/)
|
256
256
|
end
|
257
257
|
|
258
258
|
it "reports an error if it is not json" do
|
259
|
-
expect { JsonRpcResponse.from_json(Object.new) }.to raise_error(
|
259
|
+
expect { JsonRpcResponse.from_json(Object.new) }.to raise_error(/Invalid JSON-RPC 2.0 Response/)
|
260
260
|
end
|
261
261
|
|
262
262
|
it "reports an error if the error hash is bad" do
|
@@ -268,4 +268,3 @@ module Cosmos
|
|
268
268
|
|
269
269
|
end
|
270
270
|
end
|
271
|
-
|
@@ -0,0 +1,81 @@
|
|
1
|
+
# encoding: ascii-8bit
|
2
|
+
|
3
|
+
# Copyright 2014 Ball Aerospace & Technologies Corp.
|
4
|
+
# All Rights Reserved.
|
5
|
+
#
|
6
|
+
# This program is free software; you can modify and/or redistribute it
|
7
|
+
# under the terms of the GNU General Public License
|
8
|
+
# as published by the Free Software Foundation; version 3 with
|
9
|
+
# attribution addendums as found in the LICENSE.txt
|
10
|
+
|
11
|
+
if RbConfig::CONFIG['target_os'] !~ /mswin|mingw|cygwin/i and RUBY_ENGINE == 'ruby' and !ENV['TRAVIS']
|
12
|
+
|
13
|
+
require 'spec_helper'
|
14
|
+
require 'cosmos/io/posix_serial_driver'
|
15
|
+
|
16
|
+
module Cosmos
|
17
|
+
|
18
|
+
describe PosixSerialDriver do
|
19
|
+
describe "instance" do
|
20
|
+
it "enforces the baud rate to a known value" do
|
21
|
+
expect { PosixSerialDriver.new('/dev/ttyS0',10,:NONE) }.to raise_error(ArgumentError, "Invalid baud rate: 10")
|
22
|
+
end
|
23
|
+
|
24
|
+
it "supports even, odd, or no parity" do
|
25
|
+
expect { PosixSerialDriver.new('/dev/ttyS0',9600,:EVEN).close }.to_not raise_error
|
26
|
+
expect { PosixSerialDriver.new('/dev/ttyS0',9600,:ODD).close }.to_not raise_error
|
27
|
+
expect { PosixSerialDriver.new('/dev/ttyS0',9600,:NONE).close }.to_not raise_error
|
28
|
+
expect { PosixSerialDriver.new('/dev/ttyS0',9600,:BLAH) }.to raise_error(ArgumentError, "Invalid parity: BLAH")
|
29
|
+
end
|
30
|
+
|
31
|
+
it "supports 1 or 2 stop bits" do
|
32
|
+
expect { PosixSerialDriver.new('/dev/ttyS0',9600,:NONE,1).close }.to_not raise_error
|
33
|
+
expect { PosixSerialDriver.new('/dev/ttyS0',9600,:NONE,2).close }.to_not raise_error
|
34
|
+
expect { PosixSerialDriver.new('/dev/ttyS0',9600,:NONE,3) }.to raise_error(ArgumentError, "Invalid stop bits: 3")
|
35
|
+
end
|
36
|
+
|
37
|
+
it "supports 5-8 data bits" do
|
38
|
+
(5..8).each do |data_bits|
|
39
|
+
driver = PosixSerialDriver.new('/dev/ttyS0',9600,:NONE,1,10,nil,:NONE,data_bits)
|
40
|
+
handle = driver.instance_variable_get(:@handle)
|
41
|
+
expect(handle.tcgetattr.cflag & Termios::CSIZE).to eq(Termios.const_get("CS#{data_bits}"))
|
42
|
+
driver.close
|
43
|
+
end
|
44
|
+
expect { PosixSerialDriver.new('/dev/ttyS0',9600,:NONE,1,10,nil,:NONE,9) }.to raise_error(ArgumentError, "Invalid data bits: 9")
|
45
|
+
end
|
46
|
+
|
47
|
+
it "sets arbitrary Posix structure elements" do
|
48
|
+
driver = PosixSerialDriver.new('/dev/ttyS0',9600,:NONE,1,10,nil,:NONE,8)
|
49
|
+
handle = driver.instance_variable_get(:@handle)
|
50
|
+
# Verify non of the things we're going to set are already set
|
51
|
+
expect(handle.tcgetattr.iflag & Termios::IGNBRK).to eq(0)
|
52
|
+
expect(handle.tcgetattr.oflag & Termios::OPOST).to eq(0)
|
53
|
+
expect(handle.tcgetattr.cflag & Termios::CLOCAL).to eq(Termios::CLOCAL) # We set this by default
|
54
|
+
expect(handle.tcgetattr.lflag & Termios::ECHO).to eq(0)
|
55
|
+
expect(handle.tcgetattr.cc[Termios::VMIN]).to eq(1)
|
56
|
+
driver.close
|
57
|
+
# When setting a field the "1" is optional. When clearing a field the "0" is required.
|
58
|
+
# Entries in the "cc" special characters field are automatically converted to integers if they are numbers
|
59
|
+
struct = [["iflag", "IGNBRK"], ["oflag", "OPOST", "1"], ["cflag", "CLOCAL", "0"], ["lflag", "ECHO"], ["cc", "VMIN", "2"]]
|
60
|
+
driver = PosixSerialDriver.new('/dev/ttyS0',9600,:NONE,1,10,nil,:NONE,8,struct)
|
61
|
+
handle = driver.instance_variable_get(:@handle)
|
62
|
+
expect(handle.tcgetattr.iflag & Termios::IGNBRK).to eq(Termios::IGNBRK)
|
63
|
+
expect(handle.tcgetattr.oflag & Termios::OPOST).to eq(Termios::OPOST)
|
64
|
+
expect(handle.tcgetattr.cflag & Termios::CLOCAL).to eq(0)
|
65
|
+
expect(handle.tcgetattr.lflag & Termios::ECHO).to eq(Termios::ECHO)
|
66
|
+
expect(handle.tcgetattr.cc[Termios::VMIN]).to eq(2)
|
67
|
+
driver.close
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
describe "close, closed?" do
|
72
|
+
it "closes the handle" do
|
73
|
+
driver = PosixSerialDriver.new('/dev/ttyS0',9600)
|
74
|
+
expect(driver.closed?).to be false
|
75
|
+
driver.close
|
76
|
+
expect(driver.closed?).to be true
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
@@ -19,7 +19,8 @@ if RUBY_ENGINE == 'ruby' or Gem.win_platform?
|
|
19
19
|
before(:each) do
|
20
20
|
allow(Win32).to receive(:create_file).and_return(Object.new)
|
21
21
|
state = double("comm_state")
|
22
|
-
|
22
|
+
@dcb_struct = {}
|
23
|
+
allow(state).to receive(:write) { |key, value| @dcb_struct[key] = value }
|
23
24
|
allow(Win32).to receive(:get_comm_state).and_return(state)
|
24
25
|
allow(Win32).to receive(:set_comm_state)
|
25
26
|
allow(Win32).to receive(:set_comm_timeouts)
|
@@ -34,12 +35,14 @@ if RUBY_ENGINE == 'ruby' or Gem.win_platform?
|
|
34
35
|
expect { Win32SerialDriver.new('COM1',9600,:EVEN) }.to_not raise_error
|
35
36
|
expect { Win32SerialDriver.new('COM1',9600,:ODD) }.to_not raise_error
|
36
37
|
expect { Win32SerialDriver.new('COM1',9600,:NONE) }.to_not raise_error
|
38
|
+
expect(@dcb_struct["Parity"]).to_not be_nil # Simply check that Parity was set
|
37
39
|
expect { Win32SerialDriver.new('COM1',9600,:BLAH) }.to raise_error(ArgumentError, "Invalid parity: BLAH")
|
38
40
|
end
|
39
41
|
|
40
42
|
it "supports 1 or 2 stop bits" do
|
41
43
|
expect { Win32SerialDriver.new('COM1',9600,:NONE,1) }.to_not raise_error
|
42
44
|
expect { Win32SerialDriver.new('COM1',9600,:NONE,2) }.to_not raise_error
|
45
|
+
expect(@dcb_struct["StopBits"]).to_not be_nil # Simply check that StopBits was set
|
43
46
|
expect { Win32SerialDriver.new('COM1',9600,:NONE,3) }.to raise_error(ArgumentError, "Invalid stop bits: 3")
|
44
47
|
end
|
45
48
|
|
@@ -49,6 +52,35 @@ if RUBY_ENGINE == 'ruby' or Gem.win_platform?
|
|
49
52
|
expect { Win32SerialDriver.new('COM1',9600,:NONE,1,10,nil,0.01,1000,:NONE,7) }.to_not raise_error
|
50
53
|
expect { Win32SerialDriver.new('COM1',9600,:NONE,1,10,nil,0.01,1000,:NONE,8) }.to_not raise_error
|
51
54
|
expect { Win32SerialDriver.new('COM1',9600,:NONE,1,10,nil,0.01,1000,:NONE,9) }.to raise_error(ArgumentError, "Invalid data bits: 9")
|
55
|
+
expect(@dcb_struct["ByteSize"]).to_not be_nil # Simply check that ByteSize was set
|
56
|
+
end
|
57
|
+
|
58
|
+
it "sets arbitrary Windows DCB structure elements" do
|
59
|
+
Win32SerialDriver.new('COM1',9600,:NONE,1,10,nil,0.01,1000,:NONE,8)
|
60
|
+
expect(@dcb_struct["fOutxDsrFlow"]).to be_nil # This isn't set by default
|
61
|
+
expect(@dcb_struct["Parity"]).to eq(0)
|
62
|
+
# Set a new variable in the Windows DCB struct and override the :NONE parity
|
63
|
+
# We pass them in as strings because that's how they're parsed
|
64
|
+
struct = [["fOutxDsrFlow", "1"], ["Parity", "4"]]
|
65
|
+
Win32SerialDriver.new('COM1',9600,:NONE,1,10,nil,0.01,1000,:NONE,8,struct)
|
66
|
+
expect(@dcb_struct["fOutxDsrFlow"]).to eq(1)
|
67
|
+
expect(@dcb_struct["Parity"]).to eq(4)
|
68
|
+
end
|
69
|
+
|
70
|
+
it "calculates the correct timeouts" do
|
71
|
+
Win32::BAUD_RATES.each do |baud|
|
72
|
+
(5..8).each do |data_bits|
|
73
|
+
(1..2).each do |stop_bits|
|
74
|
+
[:EVEN, :ODD, :NONE].each do |parity|
|
75
|
+
# data_bits + 1 start bit + stop bits + potentially a parity bit
|
76
|
+
symbols = data_bits + 1 + stop_bits + (parity == :NONE ? 0 : 1)
|
77
|
+
delay = 1000.0 / (baud.to_f / symbols)
|
78
|
+
expect(Win32).to receive(:set_comm_timeouts).with(anything, 0xFFFFFFFF,0,0,delay.ceil,1000)
|
79
|
+
Win32SerialDriver.new('COM1',baud,parity,stop_bits,10,nil,0.01,1000,:NONE,data_bits)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
52
84
|
end
|
53
85
|
end
|
54
86
|
|
@@ -92,8 +124,6 @@ if RUBY_ENGINE == 'ruby' or Gem.win_platform?
|
|
92
124
|
expect { driver.read }.to raise_error(Timeout::Error)
|
93
125
|
end
|
94
126
|
end
|
95
|
-
|
96
127
|
end
|
97
128
|
end
|
98
|
-
|
99
129
|
end
|
@@ -23,7 +23,10 @@ module Cosmos
|
|
23
23
|
plw = PacketLogWriter.new(:CMD,nil,true,nil,10000000,nil,false)
|
24
24
|
@cmd_packets = []
|
25
25
|
pkt = System.commands.packet("SYSTEM","STARTLOGGING").clone
|
26
|
-
|
26
|
+
# Avoid precision errors by rounding to nearest second and then add 1 to ensure
|
27
|
+
# the time is AFTER the initial META packet with the current time
|
28
|
+
@time = Time.now.round + 1
|
29
|
+
pkt.received_time = @time
|
27
30
|
pkt.write('label','PKT1')
|
28
31
|
plw.write(pkt)
|
29
32
|
@cmd_packet_length = pkt.length
|
@@ -43,7 +46,7 @@ module Cosmos
|
|
43
46
|
plw = PacketLogWriter.new(:TLM,nil,true,nil,10000000,nil,false)
|
44
47
|
@tlm_packets = []
|
45
48
|
pkt = System.telemetry.packet("SYSTEM","LIMITS_CHANGE").clone
|
46
|
-
pkt.received_time =
|
49
|
+
pkt.received_time = @time
|
47
50
|
pkt.write('PACKET','PKT1')
|
48
51
|
plw.write(pkt)
|
49
52
|
@tlm_packet_length = pkt.length
|
@@ -121,7 +124,7 @@ module Cosmos
|
|
121
124
|
file.write [pkt.buffer.length].pack('N')
|
122
125
|
file.write pkt.buffer
|
123
126
|
end
|
124
|
-
expect(@plr.open(filename)).to eql
|
127
|
+
expect(@plr.open(filename)[0]).to eql false
|
125
128
|
pkt1 = @plr.read
|
126
129
|
expect(pkt1.target_name).to eql 'TGT1'
|
127
130
|
expect(pkt1.packet_name).to eql 'PKT1'
|
@@ -149,7 +152,7 @@ module Cosmos
|
|
149
152
|
file.write [pkt.buffer.length].pack('N')
|
150
153
|
file.write pkt.buffer
|
151
154
|
end
|
152
|
-
expect(@plr.open(filename)).to eql
|
155
|
+
expect(@plr.open(filename)[0]).to eql false
|
153
156
|
pkt1 = @plr.read
|
154
157
|
expect(pkt1.target_name).to eql 'TGT1'
|
155
158
|
expect(pkt1.packet_name).to eql 'PKT1'
|
@@ -203,7 +206,7 @@ module Cosmos
|
|
203
206
|
end
|
204
207
|
|
205
208
|
# Corrupt the second config
|
206
|
-
second_config_path = System.instance.
|
209
|
+
second_config_path = System.instance.public_send(:find_configuration, second_config_name)
|
207
210
|
md5 = File.basename(second_config_path, '.*')
|
208
211
|
Zip::File.open(second_config_path) do |zip|
|
209
212
|
zip.file.rename(File.join(md5, 'system.txt'), File.join(md5, 'system2.txt'))
|
@@ -239,10 +242,11 @@ module Cosmos
|
|
239
242
|
expect(packet_offsets).to eql [PacketLogReader::COSMOS4_HEADER_LENGTH, PacketLogReader::COSMOS4_HEADER_LENGTH + meta_header_length + meta_length, PacketLogReader::COSMOS4_HEADER_LENGTH + meta_header_length + meta_length + header_length + @cmd_packet_length, PacketLogReader::COSMOS4_HEADER_LENGTH + meta_header_length + meta_length + (header_length + @cmd_packet_length) * 2]
|
240
243
|
|
241
244
|
expect(@plr.open(Dir[File.join(@log_path,"*cmd.bin")][0])).to eql [true, nil]
|
242
|
-
pkt = @plr.read_at_offset(packet_offsets[2])
|
245
|
+
pkt = @plr.read_at_offset(packet_offsets[2]) # Grab the second STARTLOGGING (META is 0)
|
243
246
|
expect(pkt.target_name).to eql "SYSTEM"
|
244
247
|
expect(pkt.packet_name).to eql "STARTLOGGING"
|
245
|
-
expect(pkt.
|
248
|
+
expect(pkt.read('LABEL')).to eql "PKT2"
|
249
|
+
expect(pkt.received_time).to eql @time + 1
|
246
250
|
@plr.close
|
247
251
|
end
|
248
252
|
|
@@ -257,10 +261,11 @@ module Cosmos
|
|
257
261
|
expect(packet_offsets).to eql [PacketLogReader::COSMOS4_HEADER_LENGTH, PacketLogReader::COSMOS4_HEADER_LENGTH + meta_header_length + meta_length, PacketLogReader::COSMOS4_HEADER_LENGTH + meta_header_length + meta_length + header_length + @tlm_packet_length, PacketLogReader::COSMOS4_HEADER_LENGTH + meta_header_length + meta_length + (header_length + @tlm_packet_length) * 2]
|
258
262
|
|
259
263
|
expect(@plr.open(Dir[File.join(@log_path,"*tlm.bin")][0])).to eql [true, nil]
|
260
|
-
pkt = @plr.read_at_offset(packet_offsets[2])
|
264
|
+
pkt = @plr.read_at_offset(packet_offsets[2]) # Grab the second LIMITS_CHANGE (META is 0)
|
261
265
|
expect(pkt.target_name).to eql "SYSTEM"
|
262
266
|
expect(pkt.packet_name).to eql "LIMITS_CHANGE"
|
263
|
-
expect(pkt.
|
267
|
+
expect(pkt.read('PACKET')).to eql "PKT2"
|
268
|
+
expect(pkt.received_time).to eql @time + 1
|
264
269
|
@plr.close
|
265
270
|
end
|
266
271
|
end
|
@@ -415,9 +420,8 @@ module Cosmos
|
|
415
420
|
end
|
416
421
|
|
417
422
|
it "returns all packets if the start time is before all" do
|
418
|
-
time = Time.new(2000,1,31,12,30,16)
|
419
423
|
index = 0
|
420
|
-
@plr.each(Dir[File.join(@log_path,"*cmd.bin")][0], true, time) do |packet|
|
424
|
+
@plr.each(Dir[File.join(@log_path,"*cmd.bin")][0], true, @time) do |packet|
|
421
425
|
next if packet.packet_name == 'META'
|
422
426
|
expect(packet.target_name).to eql @cmd_packets[index].target_name
|
423
427
|
expect(packet.packet_name).to eql @cmd_packets[index].packet_name
|
@@ -429,51 +433,48 @@ module Cosmos
|
|
429
433
|
end
|
430
434
|
|
431
435
|
it "returns no packets if the start time is after all" do
|
432
|
-
time = Time.new(2030,2,1,12,30,16)
|
433
436
|
index = 0
|
434
|
-
@plr.each(Dir[File.join(@log_path,"*tlm.bin")][0], true, time) do |packet|
|
437
|
+
@plr.each(Dir[File.join(@log_path,"*tlm.bin")][0], true, @time + 100) do |packet|
|
435
438
|
index += 1
|
436
439
|
end
|
437
440
|
expect(index).to eql 0
|
438
441
|
end
|
439
442
|
|
440
443
|
it "returns all packets after a start time" do
|
441
|
-
time = Time.new(2020,1,31,12,30,16)
|
442
444
|
index = 0
|
443
|
-
@plr.each(Dir[File.join(@log_path,"*cmd.bin")][0], true, time) do |packet|
|
444
|
-
|
445
|
-
expect(packet.
|
446
|
-
expect(packet.
|
447
|
-
expect(packet.
|
445
|
+
@plr.each(Dir[File.join(@log_path,"*cmd.bin")][0], true, @time) do |packet|
|
446
|
+
next if packet.packet_name == 'META'
|
447
|
+
expect(packet.target_name).to eql @cmd_packets[index].target_name
|
448
|
+
expect(packet.packet_name).to eql @cmd_packets[index].packet_name
|
449
|
+
expect(packet.received_time).to eql @cmd_packets[index].received_time
|
450
|
+
expect(packet.read('LABEL')).to eql @cmd_packets[index].read('LABEL')
|
448
451
|
index += 1
|
449
452
|
end
|
450
|
-
expect(index).to eql
|
453
|
+
expect(index).to eql 3
|
451
454
|
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
expect(packet.target_name).to eql @tlm_packets[index
|
456
|
-
expect(packet.packet_name).to eql @tlm_packets[index
|
457
|
-
expect(packet.received_time).to eql @tlm_packets[index
|
458
|
-
expect(packet.read('PACKET')).to eql @tlm_packets[index
|
455
|
+
index = 1 # @time + 1
|
456
|
+
@plr.each(Dir[File.join(@log_path,"*tlm.bin")][0], true, @time + 1) do |packet|
|
457
|
+
next if packet.packet_name == 'META'
|
458
|
+
expect(packet.target_name).to eql @tlm_packets[index].target_name
|
459
|
+
expect(packet.packet_name).to eql @tlm_packets[index].packet_name
|
460
|
+
expect(packet.received_time).to eql @tlm_packets[index].received_time
|
461
|
+
expect(packet.read('PACKET')).to eql @tlm_packets[index].read('PACKET')
|
459
462
|
index += 1
|
460
463
|
end
|
461
|
-
expect(index).to eql
|
464
|
+
expect(index).to eql 3
|
462
465
|
end
|
463
466
|
|
464
467
|
it "returns no packets if the end time is before all" do
|
465
|
-
time = Time.new(2000,1,31,12,30,16)
|
466
468
|
index = 0
|
467
|
-
@plr.each(Dir[File.join(@log_path,"*tlm.bin")][0], true, nil, time) do |packet|
|
469
|
+
@plr.each(Dir[File.join(@log_path,"*tlm.bin")][0], true, nil, @time - 10) do |packet|
|
468
470
|
index += 1
|
469
471
|
end
|
470
472
|
expect(index).to eql 0
|
471
473
|
end
|
472
474
|
|
473
475
|
it "returns all packets if the end time is after all" do
|
474
|
-
time = Time.new(2030,2,1,12,30,16)
|
475
476
|
index = 0
|
476
|
-
@plr.each(Dir[File.join(@log_path,"*cmd.bin")][0], true, nil, time) do |packet|
|
477
|
+
@plr.each(Dir[File.join(@log_path,"*cmd.bin")][0], true, nil, @time + 10) do |packet|
|
477
478
|
next if packet.packet_name == 'META'
|
478
479
|
expect(packet.target_name).to eql @cmd_packets[index].target_name
|
479
480
|
expect(packet.packet_name).to eql @cmd_packets[index].packet_name
|
@@ -485,9 +486,8 @@ module Cosmos
|
|
485
486
|
end
|
486
487
|
|
487
488
|
it "returns all packets before an end time" do
|
488
|
-
time = Time.new(2020,1,31,12,30,16)
|
489
489
|
index = 0
|
490
|
-
@plr.each(Dir[File.join(@log_path,"*cmd.bin")][0], true, nil, time) do |packet|
|
490
|
+
@plr.each(Dir[File.join(@log_path,"*cmd.bin")][0], true, nil, @time) do |packet|
|
491
491
|
next if packet.packet_name == 'META'
|
492
492
|
expect(packet.target_name).to eql @cmd_packets[index].target_name
|
493
493
|
expect(packet.packet_name).to eql @cmd_packets[index].packet_name
|
@@ -495,11 +495,10 @@ module Cosmos
|
|
495
495
|
expect(packet.read('LABEL')).to eql @cmd_packets[index].read('LABEL')
|
496
496
|
index += 1
|
497
497
|
end
|
498
|
-
expect(index).to eql
|
498
|
+
expect(index).to eql 1
|
499
499
|
|
500
|
-
time = Time.new(2020,2,1,12,30,16)
|
501
500
|
index = 0
|
502
|
-
@plr.each(Dir[File.join(@log_path,"*tlm.bin")][0], true, nil, time) do |packet|
|
501
|
+
@plr.each(Dir[File.join(@log_path,"*tlm.bin")][0], true, nil, @time + 1) do |packet|
|
503
502
|
next if packet.packet_name == 'META'
|
504
503
|
expect(packet.target_name).to eql @tlm_packets[index].target_name
|
505
504
|
expect(packet.packet_name).to eql @tlm_packets[index].packet_name
|
@@ -185,6 +185,8 @@ module Cosmos
|
|
185
185
|
expect(@s.defined_length).to eql 1
|
186
186
|
si = StructureItem.new("test1",0,16,:INT,:BIG_ENDIAN)
|
187
187
|
@s.define(si)
|
188
|
+
expect(@s.items.length).to eql 1
|
189
|
+
expect(@s.sorted_items.length).to eql 1
|
188
190
|
expect(@s.sorted_items[0].name).to eql "TEST1"
|
189
191
|
expect(@s.items["TEST1"].bit_size).to eql 16
|
190
192
|
expect(@s.items["TEST1"].data_type).to eql :INT
|
@@ -290,6 +292,56 @@ module Cosmos
|
|
290
292
|
end
|
291
293
|
end
|
292
294
|
|
295
|
+
describe "delete_item" do
|
296
|
+
before(:each) do
|
297
|
+
@s = Structure.new(:BIG_ENDIAN)
|
298
|
+
@s.define_item("test1", 0, 8, :UINT)
|
299
|
+
end
|
300
|
+
|
301
|
+
it "removes the item and leaves a hole" do
|
302
|
+
@s.append_item("test2", 16, :UINT)
|
303
|
+
expect(@s.defined_length).to eql 3
|
304
|
+
@s.delete_item("test1")
|
305
|
+
expect { @s.get_item("test1") }.to raise_error(ArgumentError, "Unknown item: test1")
|
306
|
+
expect(@s.defined_length).to eql 3
|
307
|
+
expect(@s.items["TEST1"]).to be_nil
|
308
|
+
expect(@s.items["TEST2"]).not_to be_nil
|
309
|
+
expect(@s.sorted_items.length).to eql 1
|
310
|
+
expect(@s.sorted_items[0]).to eql(@s.get_item("test2"))
|
311
|
+
buffer = "\x01\x02\x03"
|
312
|
+
expect(@s.read("test2", :RAW, buffer)).to eql 0x0203
|
313
|
+
end
|
314
|
+
|
315
|
+
it "allows new items to be defined in place" do
|
316
|
+
@s.append_item("test2", 16, :UINT)
|
317
|
+
@s.append_item("test3", 8, :UINT)
|
318
|
+
expect(@s.defined_length).to eql 4
|
319
|
+
# Delete the first 2 items, note a 3 byte hole now exists
|
320
|
+
@s.delete_item("test1")
|
321
|
+
@s.delete_item("test2")
|
322
|
+
expect(@s.defined_length).to eql 4
|
323
|
+
expect(@s.items.length).to eql 1
|
324
|
+
expect(@s.sorted_items.length).to eql 1
|
325
|
+
# Fill the hole and overlap the last byte
|
326
|
+
@s.define_item("test4", 0, 16, :UINT)
|
327
|
+
@s.define_item("test5", 16, 16, :UINT)
|
328
|
+
@s.define_item("test6", 32, 32, :UINT)
|
329
|
+
buffer = "\x01\x02\x03\x04\x05\x06\x07\x08"
|
330
|
+
expect(@s.read("test4", :RAW, buffer)).to eql 0x0102
|
331
|
+
expect(@s.read("test5", :RAW, buffer)).to eql 0x0304
|
332
|
+
expect(@s.read("test6", :RAW, buffer)).to eql 0x05060708
|
333
|
+
# test3 is still defined
|
334
|
+
expect(@s.read("test3", :RAW, buffer)).to eql 0x04
|
335
|
+
expect(@s.items.length).to eql 4
|
336
|
+
expect(@s.sorted_items.length).to eql 4
|
337
|
+
# Check that everything is sorted correctly
|
338
|
+
expect(@s.sorted_items[0].name).to eql "TEST4"
|
339
|
+
expect(@s.sorted_items[1].name).to eql "TEST5"
|
340
|
+
expect(@s.sorted_items[2].name).to eql "TEST3"
|
341
|
+
expect(@s.sorted_items[3].name).to eql "TEST6"
|
342
|
+
end
|
343
|
+
end
|
344
|
+
|
293
345
|
describe "read_item" do
|
294
346
|
it "complains if no buffer given" do
|
295
347
|
s = Structure.new
|
@@ -601,7 +653,5 @@ module Cosmos
|
|
601
653
|
expect { s.test1 }.to raise_error(ArgumentError, "Unknown item: test1")
|
602
654
|
end
|
603
655
|
end
|
604
|
-
|
605
656
|
end # describe Structure
|
606
|
-
|
607
657
|
end
|
@@ -596,6 +596,34 @@ module Cosmos
|
|
596
596
|
end
|
597
597
|
end
|
598
598
|
|
599
|
+
describe "all_item_strings" do
|
600
|
+
it "returns hidden TGT,PKT,ITEMs in the system" do
|
601
|
+
@tlm.packet("TGT1","PKT1").hidden = true
|
602
|
+
@tlm.packet("TGT1","PKT2").disabled = true
|
603
|
+
default = @tlm.all_item_strings() # Return only those not hidden or disabled
|
604
|
+
strings = @tlm.all_item_strings(true) # Return everything, even hidden & disabled
|
605
|
+
expect(default).to_not eq strings
|
606
|
+
# Spot check the default
|
607
|
+
expect(default).to include("TGT2 PKT1 ITEM1")
|
608
|
+
expect(default).to include("TGT2 PKT1 ITEM2")
|
609
|
+
expect(default).to_not include("TGT1 PKT1 ITEM1") # hidden
|
610
|
+
expect(default).to_not include("TGT1 PKT2 ITEM1") # disabled
|
611
|
+
|
612
|
+
items = {}
|
613
|
+
# Built from the before(:each) section
|
614
|
+
items['TGT1 PKT1'] = %w(ITEM1 ITEM2 ITEM3 ITEM4)
|
615
|
+
items['TGT1 PKT2'] = %w(ITEM1 ITEM2)
|
616
|
+
items['TGT2 PKT1'] = %w(ITEM1 ITEM2)
|
617
|
+
items.each do |tgt_pkt, items|
|
618
|
+
Packet::RESERVED_ITEM_NAMES.each do |item|
|
619
|
+
expect(strings).to include("#{tgt_pkt} #{item}")
|
620
|
+
end
|
621
|
+
items.each do |item|
|
622
|
+
expect(strings).to include("#{tgt_pkt} #{item}")
|
623
|
+
end
|
624
|
+
end
|
625
|
+
end
|
626
|
+
end
|
627
|
+
|
599
628
|
end
|
600
629
|
end
|
601
|
-
|
data/spec/script/extract_spec.rb
CHANGED
@@ -148,6 +148,10 @@ module Cosmos
|
|
148
148
|
expect(extract_fields_from_check_text("TARGET PACKET ITEM < 5")).to eql(['TARGET', 'PACKET', 'ITEM', '< 5'])
|
149
149
|
end
|
150
150
|
|
151
|
+
it "should support target packet items named the same" do
|
152
|
+
expect(extract_fields_from_check_text("TEST TEST TEST == 5")).to eql(['TEST', 'TEST', 'TEST', '== 5'])
|
153
|
+
end
|
154
|
+
|
151
155
|
it "should complain about trying to do an = comparison" do
|
152
156
|
expect { extract_fields_from_check_text("TARGET PACKET ITEM = 5") }.to raise_error(/ERROR: Use/)
|
153
157
|
end
|
@@ -160,4 +164,3 @@ module Cosmos
|
|
160
164
|
|
161
165
|
end
|
162
166
|
end
|
163
|
-
|
data/spec/system/system_spec.rb
CHANGED
@@ -45,7 +45,7 @@ module Cosmos
|
|
45
45
|
describe "instance" do
|
46
46
|
it "creates default ports" do
|
47
47
|
# Don't check the actual port numbers but just that they exist
|
48
|
-
expect(System.ports.keys).to eql %w(CTS_API TLMVIEWER_API CTS_PREIDENTIFIED CTS_CMD_ROUTER REPLAY_API REPLAY_PREIDENTIFIED REPLAY_CMD_ROUTER DART_DECOM
|
48
|
+
expect(System.ports.keys).to eql %w(CTS_API TLMVIEWER_API CTS_PREIDENTIFIED CTS_CMD_ROUTER REPLAY_API REPLAY_PREIDENTIFIED REPLAY_CMD_ROUTER DART_STREAM DART_DECOM DART_MASTER)
|
49
49
|
end
|
50
50
|
|
51
51
|
it "creates default paths" do
|
@@ -349,7 +349,7 @@ module Cosmos
|
|
349
349
|
# Try loading something that doesn't exist
|
350
350
|
# It should fail and reload the original configuration
|
351
351
|
name, err = System.load_configuration("BLAH")
|
352
|
-
expect(err).to eql
|
352
|
+
expect(err.message).to eql "Unable to find configuration: BLAH"
|
353
353
|
expect(name).to eql original_config_name
|
354
354
|
|
355
355
|
# Now load the second configuration. It shouldn't have the most
|
@@ -359,7 +359,7 @@ module Cosmos
|
|
359
359
|
expect(System.telemetry.packets('SYSTEM').keys).not_to include "TEST2"
|
360
360
|
|
361
361
|
# Now remove system.txt from the third configuration and try to load it again to cause an error
|
362
|
-
#third_config_path = System.instance.
|
362
|
+
#third_config_path = System.instance.public_send(:find_configuration, third_config_name)
|
363
363
|
#FileUtils.mv File.join(third_config_path, 'system.txt'), File.join(third_config_path, 'system2.txt')
|
364
364
|
#result, err = System.load_configuration(third_config_name)
|
365
365
|
#expect(result).to eql original_config_name
|
@@ -703,6 +703,114 @@ module Cosmos
|
|
703
703
|
end
|
704
704
|
end
|
705
705
|
|
706
|
+
context "with ALLOW_ROUTER_COMMANDING" do
|
707
|
+
it "takes 0 parameters" do
|
708
|
+
tf = Tempfile.new('unittest')
|
709
|
+
tf.puts("ALLOW_ROUTER_COMMANDING BLAH TRUE")
|
710
|
+
tf.close
|
711
|
+
expect { System.instance.process_file(tf.path) }.to raise_error(ConfigParser::Error, /Too many parameters for ALLOW_ROUTER_COMMANDING./)
|
712
|
+
tf.unlink
|
713
|
+
end
|
714
|
+
|
715
|
+
it "allows router commanding" do
|
716
|
+
tf = Tempfile.new('unittest')
|
717
|
+
tf.puts("ALLOW_ROUTER_COMMANDING")
|
718
|
+
tf.close
|
719
|
+
expect(System.allow_router_commanding).to be false
|
720
|
+
System.instance.process_file(tf.path)
|
721
|
+
expect(System.allow_router_commanding).to be true
|
722
|
+
tf.unlink
|
723
|
+
end
|
724
|
+
|
725
|
+
it "it disallows router commanding if not present" do
|
726
|
+
tf = Tempfile.new('unittest')
|
727
|
+
|
728
|
+
tf.close
|
729
|
+
expect(System.allow_router_commanding).to be false
|
730
|
+
System.instance.process_file(tf.path)
|
731
|
+
expect(System.allow_router_commanding).to be false
|
732
|
+
tf.unlink
|
733
|
+
end
|
734
|
+
end
|
735
|
+
|
736
|
+
context "with X_CSRF_TOKEN" do
|
737
|
+
it "takes 1 parameters" do
|
738
|
+
tf = Tempfile.new('unittest')
|
739
|
+
tf.puts("X_CSRF_TOKEN")
|
740
|
+
tf.close
|
741
|
+
expect { System.instance.process_file(tf.path) }.to raise_error(ConfigParser::Error, /Not enough parameters for X_CSRF_TOKEN./)
|
742
|
+
tf.unlink
|
743
|
+
|
744
|
+
tf = Tempfile.new('unittest')
|
745
|
+
tf.puts("X_CSRF_TOKEN localhost true")
|
746
|
+
tf.close
|
747
|
+
expect { System.instance.process_file(tf.path) }.to raise_error(ConfigParser::Error, /Too many parameters for X_CSRF_TOKEN./)
|
748
|
+
tf.unlink
|
749
|
+
end
|
750
|
+
|
751
|
+
it "updates the CSRF token" do
|
752
|
+
tf = Tempfile.new('unittest')
|
753
|
+
tf.puts("X_CSRF_TOKEN ExtraSpecial")
|
754
|
+
tf.close
|
755
|
+
expect(System.x_csrf_token).to eql "SuperSecret"
|
756
|
+
System.instance.process_file(tf.path)
|
757
|
+
expect(System.x_csrf_token).to eql "ExtraSpecial"
|
758
|
+
tf.unlink
|
759
|
+
end
|
760
|
+
end
|
761
|
+
|
762
|
+
context "with ALLOW_HOST" do
|
763
|
+
it "takes 1 parameters" do
|
764
|
+
tf = Tempfile.new('unittest')
|
765
|
+
tf.puts("ALLOW_HOST")
|
766
|
+
tf.close
|
767
|
+
expect { System.instance.process_file(tf.path) }.to raise_error(ConfigParser::Error, /Not enough parameters for ALLOW_HOST./)
|
768
|
+
tf.unlink
|
769
|
+
|
770
|
+
tf = Tempfile.new('unittest')
|
771
|
+
tf.puts("ALLOW_HOST localhost true")
|
772
|
+
tf.close
|
773
|
+
expect { System.instance.process_file(tf.path) }.to raise_error(ConfigParser::Error, /Too many parameters for ALLOW_HOST./)
|
774
|
+
tf.unlink
|
775
|
+
end
|
776
|
+
|
777
|
+
it "adds to allowed hosts" do
|
778
|
+
tf = Tempfile.new('unittest')
|
779
|
+
tf.puts("ALLOW_HOST 1.2.3.4:8888")
|
780
|
+
tf.close
|
781
|
+
expect(System.allowed_hosts).to_not include("1.2.3.4:8888")
|
782
|
+
System.instance.process_file(tf.path)
|
783
|
+
expect(System.allowed_hosts).to include("1.2.3.4:8888")
|
784
|
+
tf.unlink
|
785
|
+
end
|
786
|
+
end
|
787
|
+
|
788
|
+
context "with ALLOW_ORIGIN" do
|
789
|
+
it "takes 1 parameters" do
|
790
|
+
tf = Tempfile.new('unittest')
|
791
|
+
tf.puts("ALLOW_ORIGIN")
|
792
|
+
tf.close
|
793
|
+
expect { System.instance.process_file(tf.path) }.to raise_error(ConfigParser::Error, /Not enough parameters for ALLOW_ORIGIN./)
|
794
|
+
tf.unlink
|
795
|
+
|
796
|
+
tf = Tempfile.new('unittest')
|
797
|
+
tf.puts("ALLOW_ORIGIN localhost true")
|
798
|
+
tf.close
|
799
|
+
expect { System.instance.process_file(tf.path) }.to raise_error(ConfigParser::Error, /Too many parameters for ALLOW_ORIGIN./)
|
800
|
+
tf.unlink
|
801
|
+
end
|
802
|
+
|
803
|
+
it "adds to allowed origins" do
|
804
|
+
tf = Tempfile.new('unittest')
|
805
|
+
tf.puts("ALLOW_ORIGIN 1.2.3.4:8888")
|
806
|
+
tf.close
|
807
|
+
expect(System.allowed_origins).to_not include("1.2.3.4:8888")
|
808
|
+
System.instance.process_file(tf.path)
|
809
|
+
expect(System.allowed_origins).to include("1.2.3.4:8888")
|
810
|
+
tf.unlink
|
811
|
+
end
|
812
|
+
end
|
813
|
+
|
706
814
|
context "with ALLOW_ACCESS" do
|
707
815
|
it "takes 1 parameters" do
|
708
816
|
tf = Tempfile.new('unittest')
|