Skip to content

Commit

Permalink
Merge pull request #8 from BallAerospace/bugfix/7-make-unit-tests-pas…
Browse files Browse the repository at this point in the history
…s-consistently

Bugfix/7 make unit tests pass consistently
  • Loading branch information
ryanmelt committed Jan 6, 2015
2 parents ebe8d73 + 9cb5244 commit f19556d
Show file tree
Hide file tree
Showing 23 changed files with 261 additions and 153 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
language: ruby
sudo: false
cache: bundler
rvm:
- 2.0.0
- 2.1.3
Expand Down
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
1 change: 1 addition & 0 deletions lib/cosmos/tools/cmd_tlm_server/cmd_tlm_server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ def stop
@routers.stop
@interfaces.stop
@packet_logging.shutdown
@message_log.stop if @message_log

@json_drb = nil
end
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
4 changes: 2 additions & 2 deletions spec/core_ext/math_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@

describe "sin_squared" do
it "should calculate sin squared" do
sin_squared(10).should eql (sin(10)**2)
sin_squared(10).should be_within(0.00000001).of(sin(10)**2)
end
end

describe "cos_squared" do
it "should calculate cos squared" do
cos_squared(10).should eql (cos(10)**2)
cos_squared(10).should be_within(0.00000001).of(cos(10)**2)
end
end

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
6 changes: 6 additions & 0 deletions spec/io/json_drb_object_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def my_method(param)
obj.my_method(10).should eql 20
obj.disconnect
json.stop_service
sleep(0.1)
end

it "should raise an exception if the remote connection can't be made" do
Expand All @@ -42,7 +43,9 @@ def my_method(param)
allow(TCPSocket).to receive(:new) { raise "Error" }
obj = JsonDRbObject.new("localhost", 7777)
expect { obj.my_method(10) }.to raise_error(DRb::DRbConnError)
obj.disconnect
json.stop_service
sleep(0.1)
end

it "should retry the request and then raise an exception" do
Expand All @@ -59,6 +62,7 @@ def my_method(param)
expect { obj.my_method(10) }.to raise_error(DRb::DRbConnError)
obj.disconnect
json.stop_service
sleep(0.1)
end

it "should raise an exception if the remote method returns an error" do
Expand All @@ -69,6 +73,7 @@ def my_method(param)
expect { obj.method_missing(:send) }.to raise_error(/Cannot call unauthorized methods/)
obj.disconnect
json.stop_service
sleep(0.1)
end

it "should handle the remote not returning a response" do
Expand All @@ -85,6 +90,7 @@ def my_method(param)
expect { obj.my_method(10) }.to raise_error(DRb::DRbConnError)
obj.disconnect
json.stop_service
sleep(0.1)
end

end
Expand Down
18 changes: 18 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 All @@ -86,6 +89,7 @@ module Cosmos
@json.thread.alive?.should be_truthy
expect { @json.start_service('127.0.0.1', 7777, self) }.to raise_error(/Error binding to port/)
@json.stop_service
sleep(0.1)
end

it "should rescue listen thread exceptions" do
Expand All @@ -95,6 +99,7 @@ module Cosmos
socket = TCPSocket.open('127.0.0.1',7777)
sleep 0.1
@json.stop_service
sleep(0.1)

stdout.string.should match /JsonDRb listen thread unexpectedly died/
end
Expand All @@ -110,7 +115,9 @@ module Cosmos
socket = TCPSocket.open('127.0.0.1',7777)
sleep 0.1
socket.eof?.should be_truthy
socket.close
@json.stop_service
sleep(0.1)
end
end

Expand All @@ -127,6 +134,7 @@ module Cosmos
socket.close
sleep 0.1
@json.stop_service
sleep(0.1)
end

it "should process success requests" do
Expand All @@ -146,6 +154,7 @@ def my_method(param)
socket.close
sleep 0.1
@json.stop_service
sleep(0.1)
end

it "should process bad methods" do
Expand All @@ -165,6 +174,7 @@ class MyServer2
socket.close
sleep 0.1
@json.stop_service
sleep(0.1)
end

it "should process bad parameters" do
Expand All @@ -186,6 +196,7 @@ def my_method(param1, param2)
socket.close
sleep 0.1
@json.stop_service
sleep(0.1)
end

it "should handle method exceptions" do
Expand All @@ -208,6 +219,7 @@ def my_method(param)
socket.close
sleep 0.1
@json.stop_service
sleep(0.1)
end

it "should not allow dangerous methods" do
Expand All @@ -224,6 +236,7 @@ def my_method(param)
socket.close
sleep 0.1
@json.stop_service
sleep(0.1)
end

it "should handle an invalid JsonDRB request" do
Expand All @@ -242,6 +255,7 @@ def my_method(param)
socket.close
sleep 0.1
@json.stop_service
sleep(0.1)
end
end

Expand All @@ -262,7 +276,9 @@ def my_method(param)
end
end
JsonDRb.send_data(socket, "\x00")
socket.close
@json.stop_service
sleep(0.1)
end

it "should eventually timeout if the socket blocks" do
Expand All @@ -275,7 +291,9 @@ def my_method(param)
end
allow(IO).to receive(:select) { nil }
expect { JsonDRb.send_data(socket, "\x00", 2) }.to raise_error(Timeout::Error)
socket.close
@json.stop_service
sleep(0.1)
end
end

Expand Down
Loading

0 comments on commit f19556d

Please sign in to comment.