Skip to content

Commit

Permalink
Resolve inconsistent failures in specs. Remove windows quotes from CO…
Browse files Browse the repository at this point in the history
…NTRIBUTING.txt. Remove warning in platform.c
  • Loading branch information
ryanmelt committed Jan 5, 2015
1 parent 5c05da1 commit 9cb5244
Show file tree
Hide file tree
Showing 19 changed files with 217 additions and 150 deletions.
10 changes: 5 additions & 5 deletions CONTRIBUTING.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ https://docs.google.com/forms/d/1ppnHUSXtY1GRTNPIyUaB1OYHbW5Ca67GFMgMRPBG8u0/vie

INTRODUCTION

In order to establish the intellectual property license granted with Contributions from any person or entity, Ball Aerospace & Technologies Corp. (Ball Aerospace) must have a signed Ball Aerospace COSMOS Software� Contributor License Agreement (Ball CLA) on file for each Contributor, indicating agreement to the license terms set forth below. The Ball CLA is intended for your protection as a Contributor as well as for the protection of Ball Aerospace and the user community of Ball Aerospace COSMOS Software� distributed by Ball Aerospace (COSMOS Software). Be advised that this Ball CLA does not change your rights to use your own Contributions for any other purpose.
In order to establish the intellectual property license granted with Contributions from any person or entity, Ball Aerospace & Technologies Corp. ("Ball Aerospace") must have a signed Ball Aerospace COSMOS Software� Contributor License Agreement ("Ball CLA") on file for each Contributor, indicating agreement to the license terms set forth below. The Ball CLA is intended for your protection as a Contributor as well as for the protection of Ball Aerospace and the user community of Ball Aerospace COSMOS Software� distributed by Ball Aerospace ("COSMOS Software"). Be advised that this Ball CLA does not change your rights to use your own Contributions for any other purpose.

LICENSE AGREEMENT

The Contributor accepts and agrees to the following terms and conditions for all present and future Contributions submitted to Ball Aerospace for inclusion in the COSMOS Software. Except for the license granted herein to Ball Aerospace and the users of the COSMOS Software, you reserve all rights, title, and interest in and to your Contributions.

1. Definitions.

�Contribution� shall mean any original work of authorship, including any modification or addition to an existing work, that has been submitted for inclusion in, or documentation of, the COSMOS Software, where such work originates from a Contributor or from some entity acting on behalf of a Contributor. For the purposes of this definition, a Contribution shall be considered to have been �submitted� when any form of electronic, verbal, or written communication is sent to Ball Aerospace, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by or on behalf of Ball Aerospace for the purpose of discussing or improving the COSMOS Software or its documentation, but excluding communications that are conspicuously marked or otherwise designated in writing as �Not a Contribution.� Any Contribution submitted to Ball Aerospace for the COSMOS Software shall be subject to the terms and conditions of this license, without any additional terms or conditions, unless you explicitly state otherwise in your submission.
"Contribution" shall mean any original work of authorship, including any modification or addition to an existing work, that has been submitted for inclusion in, or documentation of, the COSMOS Software, where such work originates from a Contributor or from some entity acting on behalf of a Contributor. For the purposes of this definition, a Contribution shall be considered to have been "submitted" when any form of electronic, verbal, or written communication is sent to Ball Aerospace, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by or on behalf of Ball Aerospace for the purpose of discussing or improving the COSMOS Software or its documentation, but excluding communications that are conspicuously marked or otherwise designated in writing as "Not a Contribution." Any Contribution submitted to Ball Aerospace for the COSMOS Software shall be subject to the terms and conditions of this license, without any additional terms or conditions, unless you explicitly state otherwise in your submission.

Contributor (also referred to herein as you and your) shall mean any individual or legal entity who is the copyright holder, or a legal entity authorized by the copyright holder, who has entered into this Agreement with Ball Aerospace and voluntarily submitted a Contribution to the COSMOS Software. For legal entities, the entity making a Contribution and all other entities that control, are controlled by, or are under common control with that entity are considered to be a single Contributor. For the purposes of this definition, control shall mean: (i) the power, direct or indirect, to cause the direction and management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares of such entity, or (iii) beneficial ownership of such entity.
"Contributor" (also referred to herein as "you" and "your") shall mean any individual or legal entity who is the copyright holder, or a legal entity authorized by the copyright holder, who has entered into this Agreement with Ball Aerospace and voluntarily submitted a Contribution to the COSMOS Software. For legal entities, the entity making a Contribution and all other entities that control, are controlled by, or are under common control with that entity are considered to be a single Contributor. For the purposes of this definition, "control" shall mean: (i) the power, direct or indirect, to cause the direction and management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares of such entity, or (iii) beneficial ownership of such entity.

2. Grant of Copyright License.

Expand All @@ -33,11 +33,11 @@ You hereby represent that each Contribution you submit is your original creation

6. Submissions on Behalf of Third Parties.

Should you wish to submit work that is not your original creation, you may submit it to Ball Aerospace for inclusion in the COSMOS Software separately from any Contribution. The process for submitting such material is as follows: (i) completely identify the details regarding the source of the material being submitted; (ii) fully describe any legal restrictions (including, but not limited to, patents, copyrights, trademarks, and license agreements) to which material being submitted is subject as far as you are personally aware; and (iii) conspicuously mark the material being submitted as: Submitted on behalf of a third party: [named here].
Should you wish to submit work that is not your original creation, you may submit it to Ball Aerospace for inclusion in the COSMOS Software separately from any Contribution. The process for submitting such material is as follows: (i) completely identify the details regarding the source of the material being submitted; (ii) fully describe any legal restrictions (including, but not limited to, patents, copyrights, trademarks, and license agreements) to which material being submitted is subject as far as you are personally aware; and (iii) conspicuously mark the material being submitted as: "Submitted on behalf of a third party: [named here]."

7. Provision of Support for Contributions.

You are not expected to provide support for your Contributions, except to the extent you desire to provide support. You may provide support gratuitously, for a fee, or not at all. Your Contributions are provided on an AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
You are not expected to provide support for your Contributions, except to the extent you desire to provide support. You may provide support gratuitously, for a fee, or not at all. Your Contributions are provided on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.

8. Obligation to Maintain Accuracy of Representations.

Expand Down
3 changes: 1 addition & 2 deletions ext/cosmos/ext/platform/platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,8 @@ static VALUE segfault(VALUE self) {
* Initialize methods for Platform specific C code
*/
void Init_platform (void) {
VALUE ruby_version = rb_const_get(rb_cObject, rb_intern("RUBY_VERSION"));

#ifdef _WIN32
VALUE ruby_version = rb_const_get(rb_cObject, rb_intern("RUBY_VERSION"));
char* rversion = RSTRING_PTR(ruby_version);
if ((rversion[0] == '2') && (rversion[2] == '0')) {
LoadLibraryA("exchndl20.dll");
Expand Down
2 changes: 1 addition & 1 deletion spec/core_ext/io_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

describe "fast_select" do
before(:all) do
@server = TCPServer.open(23456)
@server = TCPServer.new('127.0.0.1', 23456)
end
after(:all) do
@server.close
Expand Down
3 changes: 3 additions & 0 deletions spec/interfaces/interface_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ module Cosmos
i2.read_queue_size.should eql 0 # does not get copied
i2.write_queue_size.should eql 0 # does not get copied
i2.interfaces.should eql [5,6]

i.thread.kill
i.thread.join
end
end

Expand Down
2 changes: 2 additions & 0 deletions spec/interfaces/udp_interface_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ module Cosmos
sleep 0.1
thread.stop?.should be_truthy
thread.kill
thread.join
end

it "should stop the read thread if there is an IOError" do
Expand All @@ -121,6 +122,7 @@ module Cosmos
sleep 0.1
thread.stop?.should be_truthy
thread.kill
thread.join
end

it "should count the packets received" do
Expand Down
3 changes: 3 additions & 0 deletions spec/io/json_drb_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,13 @@ module Cosmos
@json.thread.should be_nil
system_exit_count = $system_exit_count
@json.start_service('blah', 7777, self)
thread = @json.thread
$system_exit_count.should eql(system_exit_count + 1)
sleep 0.1

stdout.string.should match /listen thread/
@json.stop_service
sleep(0.1)
end

Dir[File.join(Cosmos::USERPATH,"*_exception.txt")].each do |file|
Expand Down
30 changes: 15 additions & 15 deletions spec/io/tcpip_server_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ module Cosmos
sleep 0.2
expect { server.connect }.to raise_error(/Error binding/)
server.disconnect
sleep(0.1)
sleep(0.2)
end

it "should create a listener thread for the read port" do
Expand Down Expand Up @@ -99,7 +99,7 @@ module Cosmos
sleep 0.2
server.disconnect
socket.close
sleep(0.1)
sleep(0.2)

stdout.string.should match /Tcpip server listen thread unexpectedly died/
end
Expand All @@ -111,7 +111,7 @@ module Cosmos
server = TcpipServer.new(8888,nil,nil,nil,'Burst')
server.read.should be_nil
server.disconnect
sleep(0.1)
sleep(0.2)
end

#~ it "should block if no data is available" do
Expand All @@ -137,7 +137,7 @@ module Cosmos
sleep 0.2
server.num_clients.should eql 0
socket.close
sleep(0.1)
sleep(0.2)
end

it "should check the client against the ACL" do
Expand All @@ -156,7 +156,7 @@ module Cosmos
server.disconnect
sleep 0.2
socket.close
sleep(0.1)
sleep(0.2)

stdout.string.should match /Tcpip server rejected connection/
end
Expand All @@ -178,7 +178,7 @@ module Cosmos
sleep 0.2
server.num_clients.should eql 0
socket.close
sleep(0.1)
sleep(0.2)

stdout.string.should match /Tcpip server read thread unexpectedly died/
end
Expand All @@ -198,7 +198,7 @@ module Cosmos
sleep 0.2
server.disconnect
socket.close
sleep(0.1)
sleep(0.2)

stdout.string.should match /Tcpip server read thread unexpectedly died/
end
Expand Down Expand Up @@ -233,7 +233,7 @@ module Cosmos
sleep 0.2
server.num_clients.should eql 0
socket.close
sleep(0.1)
sleep(0.2)
end

it "should log an error if the write thread dies" do
Expand All @@ -257,7 +257,7 @@ def write_thread_hook(packet)
server.num_clients.should eql 0
server.disconnect
socket.close
sleep(0.1)
sleep(0.2)

stdout.string.should match /Tcpip server write thread unexpectedly died/
end
Expand All @@ -279,7 +279,7 @@ def write_thread_hook(packet)
server.num_clients.should eql 0
server.disconnect
socket.close
sleep(0.1)
sleep(0.2)

stdout.string.should match /Tcpip server lost write connection/
end
Expand All @@ -293,11 +293,11 @@ def write_thread_hook(packet)

server = TcpipServer.new(8888,8889,nil,nil,'Burst')
server.connect
sleep 0.2
sleep 0.5

socket1 = TCPSocket.open("127.0.0.1",8888)
socket2 = TCPSocket.open("127.0.0.1",8889)
sleep 0.2
sleep 0.5
server.num_clients.should eql 2
packet = Packet.new("TGT","PKT")
packet.buffer = "\x01\x02\x03\x04"
Expand All @@ -308,7 +308,7 @@ def write_thread_hook(packet)
server.disconnect
socket1.close
socket2.close
sleep(0.1)
sleep(0.2)

stdout.string.should match /Tcpip server lost write connection/
end
Expand All @@ -320,7 +320,7 @@ def write_thread_hook(packet)
server = TcpipServer.new(8888,nil,nil,nil,'Burst')
server.read_queue_size.should eql 0
server.disconnect
sleep(0.1)
sleep(0.2)
end
end

Expand All @@ -329,7 +329,7 @@ def write_thread_hook(packet)
server = TcpipServer.new(nil,8889,nil,nil,'Burst')
server.write_queue_size.should eql 0
server.disconnect
sleep(0.1)
sleep(0.2)
end
end

Expand Down
36 changes: 25 additions & 11 deletions spec/packet_logs/packet_log_writer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,33 +32,37 @@ module Cosmos
it "should create a command log writer" do
plw = PacketLogWriter.new(:CMD,nil,true,nil,10000000,nil,false)
plw.write(Packet.new('',''))
plw.stop
plw.shutdown
expect(Dir[File.join(@log_path,"*.bin")][-1]).to match("_cmd.bin")
sleep(0.1)
end

it "should create a telemetry log writer" do
plw = PacketLogWriter.new(:TLM,nil,true,nil,10000000,nil,false)
plw.write(Packet.new('',''))
plw.stop
plw.shutdown
expect(Dir[File.join(@log_path,"*.bin")][-1]).to match("_tlm.bin")
sleep(0.1)
end

it "should use log_name in the filename" do
plw = PacketLogWriter.new(:TLM,'test',true,nil,10000000,nil,false)

plw.write(Packet.new('',''))
plw.stop
plw.shutdown
expect(Dir[File.join(@log_path,"*.bin")][-1]).to match("testtlm.bin")
sleep(0.1)
end

it "should use the log directory" do
plw = PacketLogWriter.new(:TLM,'packet_log_writer_spec_',true,nil,10000000,Cosmos::USERPATH,false)
plw.write(Packet.new('',''))
plw.stop
plw.shutdown
expect(Dir[File.join(Cosmos::USERPATH,"*packet_log_writer_spec*")][-1]).to match("_tlm.bin")
Dir[File.join(Cosmos::USERPATH,"*packet_log_writer_spec*")].each do |file|
File.delete file
end
sleep(0.1)
end
end

Expand All @@ -68,21 +72,23 @@ module Cosmos
pkt = Packet.new('tgt','pkt')
pkt.buffer = "\x01\x02\x03\x04"
plw.write(pkt)
plw.stop
plw.shutdown
data = nil
File.open(Dir[File.join(@log_path,"*.bin")][-1],'rb') do |file|
data = file.read
end
data[-4..-1].should eql "\x01\x02\x03\x04"
sleep(0.1)
end

it "should not write packets if logging is disabled" do
plw = PacketLogWriter.new(:TLM,nil,false,nil,10000000,nil,false)
pkt = Packet.new('tgt','pkt')
pkt.buffer = "\x01\x02\x03\x04"
plw.write(pkt)
plw.stop
plw.shutdown
Dir[File.join(@log_path,"*.bin")].should be_empty
sleep(0.1)
end

it "should cycle the log when it a size" do
Expand All @@ -98,7 +104,8 @@ module Cosmos
# This write pushs us past 200 so we should start a new file
plw.write(pkt)
Dir[File.join(@log_path,"*.bin")].length.should eql 2
plw.stop
plw.shutdown
sleep(0.1)
end

it "should cycle the log after a set time" do
Expand Down Expand Up @@ -126,10 +133,11 @@ module Cosmos
log1_seconds = files[0].split('_')[-3].to_i * 60 + files[0].split('_')[-2].to_i
log2_seconds = files[1].split('_')[-3].to_i * 60 + files[1].split('_')[-2].to_i
(log2_seconds - log1_seconds).should be_within(2).of(3)
plw.stop
plw.shutdown
# Monkey patch the constant back to the default
PacketLogWriter.__send__(:remove_const,:CYCLE_TIME_INTERVAL)
PacketLogWriter.const_set(:CYCLE_TIME_INTERVAL, 2)
sleep(0.1)
end

it "should write asynchronously to a log" do
Expand All @@ -146,6 +154,7 @@ module Cosmos
end
data[-4..-1].should eql "\x01\x02\x03\x04"
plw.shutdown
sleep(0.1)
end

it "should handle errors creating the log file" do
Expand All @@ -159,6 +168,7 @@ module Cosmos
plw.stop
stdout.string.should match "Error opening"
plw.shutdown
sleep(0.1)
end
end

Expand All @@ -173,6 +183,7 @@ module Cosmos
plw.stop
stdout.string.should match "Error closing"
plw.shutdown
sleep(0.1)
end
end
end
Expand All @@ -182,25 +193,28 @@ module Cosmos
plw = PacketLogWriter.new(:TLM,nil,false,nil,10000000,nil,false)
plw.start
plw.write(Packet.new('',''))
plw.stop
plw.shutdown
file = Dir[File.join(@log_path,"*.bin")][-1]
File.size(file).should_not eql 0
sleep(0.1)
end

it "should add a label to the log file" do
plw = PacketLogWriter.new(:TLM,nil,false,nil,10000000,nil,false)
plw.start('test')
plw.write(Packet.new('',''))
plw.stop
plw.shutdown
expect(Dir[File.join(@log_path,"*.bin")][-1]).to match("_tlm_test.bin")
sleep(0.1)
end

it "should ignore bad label formats" do
plw = PacketLogWriter.new(:TLM,nil,false,nil,10000000,nil,false)
plw.start('my_test')
plw.write(Packet.new('',''))
plw.stop
plw.shutdown
expect(Dir[File.join(@log_path,"*.bin")][-1]).to match("_tlm.bin")
sleep(0.1)
end
end

Expand Down
5 changes: 4 additions & 1 deletion spec/script/script_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,22 @@ module Cosmos
allow_any_instance_of(Interface).to receive(:read)

@server = CmdTlmServer.new
shutdown_cmd_tlm()
initialize_script_module()
sleep 0.1
end

after(:each) do
@server.stop
shutdown_cmd_tlm()
sleep(0.1)
end

describe "cmd" do
it "should send a command" do
capture_io do |stdout|
cmd("INST ABORT")
stdout.string.should match /cmd\(\'INST ABORT\'\)/
stdout.string.should match /cmd\(\'INST ABORT\'\)/ #'
end
end

Expand Down
Loading

0 comments on commit 9cb5244

Please sign in to comment.