diff options
author | Micah Anderson <micah@leap.se> | 2014-09-15 16:32:22 -0400 |
---|---|---|
committer | Micah Anderson <micah@leap.se> | 2014-09-15 16:33:38 -0400 |
commit | 027b26f0a1eda93b203d095c9ea2a83e51f90c12 (patch) | |
tree | 609a70dfb1e6ad94504e499e1e240479eb90e05f | |
parent | 0df84cf7987c3047ecc0353e8d29c2c38437a5a2 (diff) | |
parent | 72bad39f8a21c3be33b17134d2e3ca11f5e0d58f (diff) |
tests: add 'ignore' command to tests
Change-Id: I8ac3b6edd6a0cf7eae5486d61d1680765a8fad13
-rwxr-xr-x | bin/run_tests | 20 | ||||
-rw-r--r-- | tests/white-box/network.rb | 39 |
2 files changed, 36 insertions, 23 deletions
diff --git a/bin/run_tests b/bin/run_tests index 2ee027f4..4a5801ac 100755 --- a/bin/run_tests +++ b/bin/run_tests @@ -41,6 +41,7 @@ end ## # this class is raised if a test file wants to be skipped entirely. +# (to skip an individual test, MiniTest::Skip is used instead) class SkipTest < Exception end @@ -62,6 +63,8 @@ end class LeapTest < MiniTest::Unit::TestCase class Pass < MiniTest::Assertion end + class Ignore < MiniTest::Assertion + end def initialize(name) super(name) @@ -101,6 +104,13 @@ class LeapTest < MiniTest::Unit::TestCase end # + # Called when the test should be silently ignored. + # + def ignore + raise LeapTest::Ignore + end + + # # the default fail() is part of the kernel and it just throws a runtime exception. for tests, # we want the same behavior as assert(false) # @@ -332,6 +342,7 @@ class LeapRunner < MiniTest::Unit def initialize @passes = 0 @warnings = 0 + @ignores = 0 super end @@ -372,9 +383,12 @@ class LeapRunner < MiniTest::Unit case e when MiniTest::Skip then @skips += 1 - #if @verbose - report_line("SKIP", klass, meth, e, e.message) - #end + report_line("SKIP", klass, meth, e, e.message) + when LeapTest::Ignore then + @ignores += 1 + if @verbose + report_line("IGNORE", klass, meth, e, e.message) + end when LeapTest::Pass then @passes += 1 report_line("PASS", klass, meth) diff --git a/tests/white-box/network.rb b/tests/white-box/network.rb index 118861a7..0d98c314 100644 --- a/tests/white-box/network.rb +++ b/tests/white-box/network.rb @@ -26,32 +26,31 @@ class Network < LeapTest # connect: "127.0.0.1:5984" # def test_02_Is_stunnel_running? - if $node['stunnel'] - good_stunnel_pids = [] - $node['stunnel']['clients'].each do |stunnel_type, stunnel_configs| - stunnel_configs.each do |stunnel_name, stunnel_conf| - config_file_name = "/etc/stunnel/#{stunnel_name}.conf" - processes = pgrep(config_file_name) - assert_equal 6, processes.length, "There should be six stunnel processes running for `#{config_file_name}`" - good_stunnel_pids += processes.map{|ps| ps[:pid]} - assert port = stunnel_conf['accept_port'], 'Field `accept_port` must be present in `stunnel` property.' - assert_tcp_socket('localhost', port) - end - end - $node['stunnel']['servers'].each do |stunnel_name, stunnel_conf| + ignore unless $node['stunnel'] + good_stunnel_pids = [] + $node['stunnel']['clients'].each do |stunnel_type, stunnel_configs| + stunnel_configs.each do |stunnel_name, stunnel_conf| config_file_name = "/etc/stunnel/#{stunnel_name}.conf" processes = pgrep(config_file_name) assert_equal 6, processes.length, "There should be six stunnel processes running for `#{config_file_name}`" good_stunnel_pids += processes.map{|ps| ps[:pid]} - assert accept_port = stunnel_conf['accept_port'], "Field `accept` must be present in property `stunnel.servers.#{stunnel_name}`" - assert_tcp_socket('localhost', accept_port) - assert connect_port = stunnel_conf['connect_port'], "Field `connect` must be present in property `stunnel.servers.#{stunnel_name}`" - assert_tcp_socket('localhost', connect_port) + assert port = stunnel_conf['accept_port'], 'Field `accept_port` must be present in `stunnel` property.' + assert_tcp_socket('localhost', port) end - all_stunnel_pids = pgrep('/usr/bin/stunnel').collect{|process| process[:pid]}.uniq - assert_equal good_stunnel_pids.sort, all_stunnel_pids.sort, "There should not be any extra stunnel processes that are not configured in /etc/stunnel" - pass end + $node['stunnel']['servers'].each do |stunnel_name, stunnel_conf| + config_file_name = "/etc/stunnel/#{stunnel_name}.conf" + processes = pgrep(config_file_name) + assert_equal 6, processes.length, "There should be six stunnel processes running for `#{config_file_name}`" + good_stunnel_pids += processes.map{|ps| ps[:pid]} + assert accept_port = stunnel_conf['accept_port'], "Field `accept` must be present in property `stunnel.servers.#{stunnel_name}`" + assert_tcp_socket('localhost', accept_port) + assert connect_port = stunnel_conf['connect_port'], "Field `connect` must be present in property `stunnel.servers.#{stunnel_name}`" + assert_tcp_socket('localhost', connect_port) + end + all_stunnel_pids = pgrep('/usr/bin/stunnel').collect{|process| process[:pid]}.uniq + assert_equal good_stunnel_pids.sort, all_stunnel_pids.sort, "There should not be any extra stunnel processes that are not configured in /etc/stunnel" + pass end def test_03_Is_shorewall_running? |