Files
metasploit-gs/test/lib/msftest.rb
T

42 lines
1.4 KiB
Ruby
Raw Normal View History

## This class consists of assert helper methods for regexing logs
##
2010-10-26 06:05:24 +00:00
## $Id$
$:.unshift(File.expand_path(File.dirname(__FILE__)))
2010-07-16 22:36:42 +00:00
require 'regexr'
require 'test/unit'
2010-07-20 06:38:29 +00:00
2010-10-26 06:05:24 +00:00
class MsfTestCase < Test::Unit::TestCase
2010-07-16 22:36:42 +00:00
def assert_complete(data,first,last)
2010-11-12 03:13:05 +00:00
@regexr = Regexr.new(true)
assert_not_nil @regexr.verify_start(data,first), "The start string " + data.split("\n").first + " did not match the expected string: " + first
assert_not_nil @regexr.verify_end(data,last), "The end string " + data.split("\n").last + " did not match the expected string: " + last
2010-07-16 22:36:42 +00:00
end
def assert_all_successes(data, regex_strings)
2010-11-12 03:13:05 +00:00
@regexr = Regexr.new(true)
if regex_strings
regex_strings.each { |regex_string|
puts "Making sure " + regex_string + " is included."
assert_true @regexr.ensure_exists_in_data(data,regex_string), "The string " + regex_string + " was not found in the data."
}
end
2010-07-16 22:36:42 +00:00
end
2010-11-12 03:13:05 +00:00
def scan_for_errors(data)
scan_for_failures(data,['exception'],[])
end
def assert_no_failures(data, regex_strings, exception_strings)
2010-11-12 03:13:05 +00:00
@regexr = Regexr.new(true)
if regex_strings
regex_strings.each { |regex_string|
puts "Making sure " + regex_string + " isn't included."
assert_true @regexr.ensure_doesnt_exist_in_data_unless(data,regex_string,exception_strings), "The string " + regex_string + " was found in the the data, and no exception was found."
}
end
end
2010-07-16 22:36:42 +00:00
end