mirror of
https://github.com/cliffe/SecGen.git
synced 2026-02-21 19:28:02 +00:00
Test faiures read exit code instead of "FAILED" or "PASSED" strings
This commit is contained in:
@@ -19,17 +19,20 @@ class PostProvisionTest
|
||||
attr_accessor :json_inputs
|
||||
attr_accessor :port
|
||||
attr_accessor :outputs
|
||||
attr_accessor :all_tests_passed
|
||||
|
||||
def initialize
|
||||
self.system_ip = get_system_ip
|
||||
self.json_inputs = get_json_inputs
|
||||
self.port = get_port
|
||||
self.outputs = []
|
||||
self.all_tests_passed = true
|
||||
end
|
||||
|
||||
def run
|
||||
test_module
|
||||
puts self.outputs
|
||||
exit(1) unless all_tests_passed
|
||||
end
|
||||
|
||||
def test_module
|
||||
@@ -47,7 +50,7 @@ class PostProvisionTest
|
||||
self.outputs << "PASSED: Port #{self.port} is open at #{get_system_ip} (#{get_system_name})!"
|
||||
else
|
||||
self.outputs << "FAILED: Port #{self.port} is closed at #{get_system_ip} (#{get_system_name})!"
|
||||
exit(1)
|
||||
self.all_tests_passed = false
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -6,12 +6,12 @@ class NTPTest < PostProvisionTest
|
||||
self.module_name = 'ntp'
|
||||
self.module_path = get_module_path(__FILE__)
|
||||
super
|
||||
self.port = 12
|
||||
self.port = 123
|
||||
end
|
||||
|
||||
def test_module
|
||||
super
|
||||
test_ntp_query #TODO
|
||||
test_ntp_query
|
||||
end
|
||||
|
||||
def test_ntp_query
|
||||
@@ -19,8 +19,8 @@ class NTPTest < PostProvisionTest
|
||||
time_response = Net::NTP.get(system_ip, port).time
|
||||
self.outputs << "PASSED: NTP responded on UDP port #{port} with #{time_response}"
|
||||
rescue Errno::ECONNREFUSED
|
||||
self.outputs << "FAILED: unable to connect to #{module_name} on UDP port #{port} "
|
||||
exit(1)
|
||||
self.outputs << "FAILED: unable to connect to #{module_name} on UDP port #{port}"
|
||||
self.all_tests_passed = false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -358,7 +358,7 @@ def post_provision_tests(project_dir)
|
||||
tests_passed = false
|
||||
Print.err test_output[:stdout].join("\n")
|
||||
Print.err "Post provision tests contained failures!"
|
||||
Print.err test_output[:stderr].join("\n")
|
||||
Print.err test_output[:stderr].join("\n") if test_output[:stderr].length > 0
|
||||
else
|
||||
Print.info test_output[:stdout].join("\n")
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user