summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/mini/test.rb86
1 files changed, 51 insertions, 35 deletions
diff --git a/lib/mini/test.rb b/lib/mini/test.rb
index 53715ef08..e19029c46 100644
--- a/lib/mini/test.rb
+++ b/lib/mini/test.rb
@@ -12,6 +12,7 @@
module Mini
class Assertion < Exception; end
+ class Skip < Assertion; end
MINI_DIR = File.expand_path("../..", __FILE__)
@@ -89,14 +90,15 @@ module Mini
end
def assert_instance_of cls, obj, msg = nil
- msg = message(msg) { "Expected #{mu_pp(obj)} to be an instance of #{cls}" }
+ msg = message(msg) { "Expected #{mu_pp(obj)} to be an instance of #{cls}, not #{obj.class}" }
flip = (Module === obj) && ! (Module === cls) # HACK for specs
obj, cls = cls, obj if flip
assert cls === obj, msg
end
def assert_kind_of cls, obj, msg = nil # TODO: merge with instance_of
- msg = message(msg) { "Expected #{mu_pp(obj)} to be a kind of #{cls}" }
+ msg = message(msg) {
+ "Expected #{mu_pp(obj)} to be a kind of #{cls}, not #{obj.class}" }
flip = (Module === obj) && ! (Module === cls) # HACK for specs
obj, cls = cls, obj if flip
assert obj.kind_of?(cls), msg
@@ -104,7 +106,7 @@ module Mini
def assert_match exp, act, msg = nil
msg = message(msg) { "Expected #{mu_pp(act)} to match #{mu_pp(exp)}" }
- assert_respond_to(act, :"=~")
+ assert_respond_to act, :"=~"
(exp = /#{exp}/) if String === exp && String === act
assert act =~ exp, msg
end
@@ -126,31 +128,36 @@ module Mini
yield
should_raise = true
rescue Exception => e
- assert_includes exp, e.class
- exception_details(e, "<#{mu_pp(exp)}> exception expected, not")
+ assert_includes(exp, e.class, exception_details(e, "<#{mu_pp(exp)}> exception expected, not"))
return e
end
exp = exp.first if exp.size == 1
- fail "#{mu_pp(exp)} expected but nothing was raised." if should_raise
+ flunk "#{mu_pp(exp)} expected but nothing was raised." if should_raise
end
def assert_respond_to obj, meth, msg = nil
- msg = message(msg) { "Expected #{mu_pp(obj)} to respond to #{meth}" }
+ msg = message(msg) {
+ "Expected #{mu_pp(obj)} (#{obj.class}) to respond to ##{meth}"
+ }
flip = (Symbol === obj) && ! (Symbol === meth) # HACK for specs
obj, meth = meth, obj if flip
assert obj.respond_to?(meth), msg
end
def assert_same exp, act, msg = nil
- msg = message(msg) { "Expected #{mu_pp(act)} to be the same as #{mu_pp(exp)}" }
+ msg = message(msg) {
+ data = [mu_pp(act), act.object_id, mu_pp(exp), exp.object_id]
+ "Expected %s (0x%x) to be the same as %s (0x%x)" % data
+ }
assert exp.equal?(act), msg
end
- def assert_send send_ary, msg = nil
+ def assert_send send_ary, m = nil
recv, msg, *args = send_ary
- msg = message(msg) { "Expected ##{msg} on #{mu_pp(recv)} to return true" }
- assert recv.__send__(msg, *args), msg
+ m = message(m) {
+ "Expected #{mu_pp(recv)}.#{msg}(*#{mu_pp(args)}) to return true" }
+ assert recv.__send__(msg, *args), m
end
def assert_throws sym, msg = nil
@@ -189,13 +196,11 @@ module Mini
"#{msg}\nClass: <#{e.class}>\nMessage: <#{e.message.inspect}>\n---Backtrace---\n#{Mini::filter_backtrace(e.backtrace).join("\n")}\n---------------"
end
- def fail msg = nil
+ def flunk msg = nil
msg ||= "Epic Fail!"
assert false, msg
end
- alias :flunk :fail
-
def message msg = nil, &default
proc {
if msg then
@@ -286,12 +291,18 @@ module Mini
msg = message(msg) { "Expected #{mu_pp(act)} to not be the same as #{mu_pp(exp)}" }
refute exp.equal?(act), msg
end
+
+ def skip msg = nil
+ msg ||= "Skipped, no message given"
+ raise Mini::Skip, msg
+ end
end
class Test
VERSION = "1.3.0"
- attr_reader :report, :failures, :errors
+ attr_accessor :report, :failures, :errors, :skips
+ attr_accessor :test_count, :assertion_count
@@installed_at_exit ||= false
@@out = $stdout
@@ -299,7 +310,7 @@ module Mini
def self.autorun
at_exit {
exit_code = Mini::Test.new.run(ARGV)
- exit exit_code if exit_code
+ exit false if exit_code
} unless @@installed_at_exit
@@installed_at_exit = true
end
@@ -308,34 +319,39 @@ module Mini
@@out = stream
end
+ def location e
+ e.backtrace.find { |s|
+ s !~ /in .(assert|refute|flunk|pass|fail|raise)/
+ }.sub(/:in .*$/, '')
+ end
+
def puke klass, meth, e
- if Mini::Assertion === e then
- @failures += 1
-
- loc = e.backtrace.find { |s| s !~ /in .(assert|refute|flunk|pass|fail|raise)/ }
- loc.sub!(/:in .*$/, '')
-
- @report << "Failure:\n#{meth}(#{klass}) [#{loc}]:\n#{e.message}\n"
- 'F'
- else
- @errors += 1
- bt = Mini::filter_backtrace(e.backtrace).join("\n ")
- e = "Error:\n#{meth}(#{klass}):\n#{e.class}: #{e.message}\n #{bt}\n"
- @report << e
- 'E'
- end
+ e = case e
+ when Mini::Skip then
+ @skips += 1
+ "Skipped:\n#{meth}(#{klass}) [#{location e}]:\n#{e.message}\n"
+ when Mini::Assertion then
+ @failures += 1
+ "Failure:\n#{meth}(#{klass}) [#{location e}]:\n#{e.message}\n"
+ else
+ @errors += 1
+ bt = Mini::filter_backtrace(e.backtrace).join("\n ")
+ "Error:\n#{meth}(#{klass}):\n#{e.class}: #{e.message}\n #{bt}\n"
+ end
+ @report << e
+ e[0, 1]
end
def initialize
@report = []
- @errors = @failures = 0
+ @errors = @failures = @skips = 0
@verbose = false
end
##
# Top level driver, controls all output and filtering.
- def run args
+ def run args = []
@verbose = args.delete('-v')
filter = if args.first =~ /^(-n|--name)$/ then
@@ -360,8 +376,8 @@ module Mini
@@out.puts
- format = "%d tests, %d assertions, %d failures, %d errors"
- @@out.puts format % [@test_count, @assertion_count, failures, errors]
+ format = "%d tests, %d assertions, %d failures, %d errors, %d skips"
+ @@out.puts format % [test_count, assertion_count, failures, errors, skips]
return failures + errors if @test_count > 0 # or return nil...
end
8' href='#n388'>388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><title>rsyslog vs. syslog-ng - a comparison</title>

</head>
<body>
<h1>rsyslog vs. syslog-ng</h1>
<p><small><i>Written by <a href="http://www.gerhards.net/rainer">Rainer Gerhards</a>
(2008-04-08)</i></small></p>
<p>We have often been asked about a comparison sheet between
rsyslog and syslog-ng. Unfortunately, I do not know much about
syslog-ng, I did not even use it once. Also, there seems to be no
comprehensive feature sheet available for syslog-ng (that recently
changed, see below). So I started this
comparison, but it probably is not complete. For sure, I miss some
syslog-ng features. This is not an attempt to let rsyslog shine more
than it should. I just used the <a href="features.html">rsyslog
feature sheet</a> as a starting point, simply because it was
available. If you would like to add anything to the chart, or correct
it, please simply <a href="mailto:rgerhards@adiscon.com">drop
me a line</a>. I would love to see a real honest and up-to-date
comparison sheet, so please don't be shy ;)</p>
<table border="1">
<tbody>
<tr>
<td valign="top"><b>Feature</b></td>
<td valign="top"><b>rsyslog</b></td>
<td valign="top"><b>syslog-ng</b></td>
</tr>
<tr>
<td colspan="3" valign="top"><br>
<b>Input Sources</b><br>
</td>
</tr>
<tr>
<td valign="top">UNIX domain socket</td>
<td valign="top">yes</td>
<td valign="top">yes</td>
<td></td>
</tr>
<tr>
<td valign="top">UDP</td>
<td valign="top">yes</td>
<td valign="top">yes</td>
<td></td>
</tr>
<tr>
<td valign="top">TCP</td>
<td valign="top">yes</td>
<td valign="top">yes</td>
<td></td>
</tr>
<tr>
<td valign="top"><a href="http://www.librelp.com">RELP</a></td>
<td valign="top">yes</td>
<td valign="top">no</td>
<td></td>
</tr>
<tr>
<td valign="top">RFC 3195/BEEP</td>
<td valign="top">yes (via <a href="im3195.html">im3195</a>)</td>
<td valign="top">no</td>
<td></td>
</tr>
<tr>
<td valign="top">kernel log</td>
<td valign="top">yes</td>
<td valign="top">yes</td>
<td></td>
</tr>
<tr>
<td valign="top">file</td>
<td valign="top">yes</td>
<td valign="top">yes</td>
<td></td>
</tr>
<tr>
<td valign="top">mark message generator as an
optional input</td>
<td valign="top">yes</td>
<td valign="top">no (?)</td>
<td></td>
</tr>
<tr>
<td valign="top">Windows Event Log</td>
<td valign="top">via <a href="http://www.eventreporter.com">EventReporter</a>
or <a href="http://www.mwagent.com">MonitorWare Agent</a>
(both commercial software)</td>
<td valign="top">via separate Windows agent, paid
edition only</td>
</tr>
<tr>
<td colspan="3" valign="top"><b><br>
Network (Protocol) Support</b><br>
</td>
</tr>
<tr>
<td valign="top">support for (plain) tcp based syslog</td>
<td valign="top">yes</td>
<td valign="top">yes</td>
</tr>
<tr>
<td valign="top">support for GSS-API</td>
<td valign="top">yes</td>
<td valign="top">no (?)</td>
</tr>
<tr>
<td valign="top">ability to limit the allowed
network senders (syslog ACLs)</td>
<td valign="top">yes</td>
<td valign="top">yes (?)</td>
</tr>
<tr>
<td valign="top">support for syslog-transport-tls
based framing on syslog/tcp connections</td>
<td valign="top">yes</td>
<td valign="top">no (?)</td>
</tr>
<tr>
<td valign="top">udp syslog</td>
<td valign="top">yes</td>
<td valign="top">yes</td>
</tr>
<tr>
<td valign="top">syslog over RELP<br>
truly reliable message delivery (<a href="http://rgerhards.blogspot.com/2008/04/on-unreliability-of-plain-tcp-syslog.html">Why
is plain tcp syslog not reliable?</a>)</td>
<td valign="top">yes</td>
<td valign="top">no</td>
</tr>
<tr>
<td valign="top">on the wire (zlib) message
compression</td>
<td valign="top">yes</td>
<td valign="top">no (?)</td>
</tr>
<tr>
<td valign="top">support for receiving messages via
reliable <a href="http://www.monitorware.com/Common/en/glossary/rfc3195.php">RFC
3195</a> delivery</td>
<td valign="top">yes</td>
<td valign="top">no</td>
</tr>
<tr>
<td valign="top">support for <a href="rsyslog_stunnel.html">ssl-protected
syslog</a> </td>
<td valign="top"><a href="rsyslog_stunnel.html">via
stunnel</a></td>
<td valign="top">via stunnel<br>
paid edition natively</td>
</tr>
<tr>
<td valign="top">support for IETF's new
syslog-protocol draft</td>
<td valign="top">yes</td>
<td valign="top">no</td>
</tr>
<tr>
<td valign="top">support for IPv6</td>
<td valign="top">yes</td>
<td valign="top">yes</td>
</tr>
<tr>
<td valign="top">native ability to send SNMP traps</td>
<td valign="top">yes</td>
<td valign="top">?</td>
</tr>
<tr>
<td valign="top">ability to preserve the original
hostname in NAT environments and relay chains</td>
<td valign="top">yes</td>
<td valign="top">yes</td>
</tr>
<tr>
<td colspan="3" valign="top"><br>
<b>Message Filtering</b><br>
</td>
</tr>
<tr>
<td valign="top">Filtering for syslog facility and
priority</td>
<td valign="top">yes</td>
<td valign="top">yes</td>
<td></td>
</tr>
<tr>
<td valign="top">Filtering for hostname</td>
<td valign="top">yes</td>
<td valign="top">yes</td>
<td></td>
</tr>
<tr>
<td valign="top">Filtering for application</td>
<td valign="top">yes</td>
<td valign="top">yes</td>
<td></td>
</tr>
<tr>
<td valign="top">Filtering for message contents</td>
<td valign="top">yes</td>
<td valign="top">yes</td>
<td></td>
</tr>
<tr>
<td valign="top">Filtering for sending IP address</td>
<td valign="top">yes</td>
<td valign="top">yes</td>
<td></td>
</tr>
<tr>
<td valign="top">ability to filter on any other
message
field not mentioned above
(including substrings and the like)</td>
<td valign="top">yes</td>
<td valign="top">no</td>
</tr>
<tr>
<td>support for complex filters, using full boolean algebra
with and/or/not operators and parenthesis</td>
<td>yes</td>
<td>yes</td>
</tr>
<tr>
<td>Support for reusable filters: specify a filter once and
use it in multiple selector lines</td>
<td>no</td>
<td>yes</td>
</tr>
<tr>
<td>support for arbritrary complex arithmetic and string
expressions inside filters</td>
<td>yes</td>
<td>no</td>
</tr>
<tr>
<td valign="top">ability to use regular expressions
in filters</td>
<td valign="top">yes</td>
<td valign="top">yes</td>
</tr>
<tr>
<td valign="top">support for discarding messages
based on filters</td>
<td valign="top">yes</td>
<td valign="top">yes</td>
<td></td>
</tr>
<tr>
<td valign="top">powerful BSD-style hostname and
program name blocks for easy multi-host support</td>
<td valign="top">yes</td>
<td valign="top">no</td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td colspan="3" valign="top"><br>
<b>Supported Database Outputs</b><br>
</td>
</tr>
<tr>
<td valign="top">MySQL</td>
<td valign="top"><a href="rsyslog_mysql.html">yes</a>
(native ommysql,&nbsp;<a href="omlibdbi.html">omlibdbi</a>)</td>
<td valign="top">yes (via libdibi)</td>
</tr>
<tr>
<td valign="top">PostgreSQL</td>
<td valign="top">yes (native ompgsql,&nbsp;<a href="omlibdbi.html">omlibdbi</a>)</td>
<td valign="top">yes (via libdibi)</td>
</tr>
<tr>
<td valign="top">Oracle</td>
<td valign="top">yes (<a href="omlibdbi.html">omlibdbi</a>)</td>
<td valign="top">yes (via libdibi)</td>
</tr>
<tr>
<td valign="top">SQLite</td>
<td valign="top">yes (<a href="omlibdbi.html">omlibdbi</a>)</td>
<td valign="top">yes (via libdibi)</td>
</tr>
<tr>
<td valign="top">Microsoft SQL (Open TDS)</td>
<td valign="top">yes (<a href="omlibdbi.html">omlibdbi</a>)</td>
<td valign="top">no (?)</td>
</tr>
<tr>
<td valign="top">Sybase (Open TDS)</td>
<td valign="top">yes (<a href="omlibdbi.html">omlibdbi</a>)</td>
<td valign="top">no (?)</td>
</tr>
<tr>
<td valign="top">Firebird/Interbase</td>
<td valign="top">yes (<a href="omlibdbi.html">omlibdbi</a>)</td>
<td valign="top">no (?)</td>
</tr>
<tr>
<td valign="top">Ingres</td>
<td valign="top">yes (<a href="omlibdbi.html">omlibdbi</a>)</td>
<td valign="top">no (?)</td>
</tr>
<tr>
<td valign="top">mSQL</td>
<td valign="top">yes (<a href="omlibdbi.html">omlibdbi</a>)</td>
<td valign="top">no (?)</td>
</tr>
<tr>
<td colspan="3" valign="top"><br>
<b>Enterprise Features</b><br>
</td>
</tr>
<tr>
<td valign="top">support for on-demand on-disk
spooling of messages</td>
<td valign="top">yes</td>
<td valign="top">paid edition only</td>
</tr>
<tr>
<td valign="top">ability to limit disk space used
by spool files</td>
<td valign="top">yes</td>
<td valign="top">yes</td>
</tr>
<tr>
<td valign="top">each action can use its own,
independant
set of spool files</td>
<td valign="top">yes</td>
<td valign="top">no</td>
</tr>
<tr>
<td valign="top">different sets of spool files can
be placed on different disk</td>
<td valign="top">yes</td>
<td valign="top">no</td>
</tr>
<tr>
<td valign="top">ability to process spooled
messages only during a configured timeframe (e.g. process messages only
during off-peak hours, during peak hours they are enqueued only)</td>
<td valign="top"><a href="http://wiki.rsyslog.com/index.php/OffPeakHours">yes</a><br>
(can independently be configured for the main queue and each action
queue)</td>
<td valign="top">no</td>
</tr>
<tr>
<td valign="top">ability to configure backup
syslog/database servers </td>
<td valign="top">yes</td>
<td valign="top">no</td>
</tr>
<tr>
<td>Professional Support</td>
<td><a href="professional_support.html">yes</a></td>
<td>yes</td>
</tr>
<tr>
<td colspan="3" valign="top"><br>
<b>Config File</b><br>
</td>
</tr>
<tr>
<td valign="top">config file format</td>
<td valign="top">compatible to legacy syslogd but
ugly</td>
<td valign="top">clean but not backwards compatible</td>
</tr>
<tr>
<td valign="top">ability to include config file from
within other config files</td>
<td valign="top">yes</td>
<td valign="top">no</td>
</tr>
<tr>
<td height="25" valign="top">ability to
include all config files
existing in a specific directory</td>
<td height="25" valign="top">yes</td>
<td height="25" valign="top">no</td>
</tr>
<tr>
<td colspan="3" valign="top"><br>
<b>Extensibility</b><br>
</td>
</tr>
<tr>
<td valign="top">Functionality split in separately
loadable
modules</td>
<td valign="top">yes</td>
<td valign="top">no</td>
</tr>
<tr>
<td valign="top">Support for third-party input
plugins</td>
<td valign="top">yes</td>
<td valign="top">no</td>
</tr>
<tr>
</tr>
<tr>
<td valign="top">Support for third-party output
plugins</td>
<td valign="top">yes</td>
<td valign="top">no</td>
</tr>
<tr>
<td colspan="3" valign="top"><br>
<b>Other Features</b><br>
</td>
</tr>
<tr>
</tr>
<tr>
<td valign="top">ability to generate file names and
directories (log targets) dynamically</td>
<td valign="top">yes</td>
<td valign="top">yes</td>
</tr>
<tr>
<td valign="top">control of log output format,
including ability to present channel and priority as visible log data</td>
<td valign="top">yes</td>
<td valign="top">not sure...</td>
</tr>
<tr><td valign="top">native ability to send mail messages</td>
<td valign="top">yes (<a href="ommail.html">ommail</a>, introduced in 3.17.0)</td>
<td valign="top">not sure...</td>
</tr>
<tr>
<td valign="top">good timestamp format control; at a
minimum, ISO 8601/RFC 3339 second-resolution UTC zone</td>
<td valign="top">yes</td>
<td valign="top">yes</td>
</tr>
<tr>
<td valign="top">ability to reformat message
contents and work with substrings</td>
<td valign="top">yes</td>
<td valign="top">I think yes</td>
</tr>
<tr>
<td valign="top">support for log files larger than
2gb</td>
<td valign="top">yes</td>
<td valign="top">yes</td>
</tr>
<tr>
<td valign="top">support for log file size
limitation
and automatic rollover command execution</td>
<td valign="top">yes</td>
<td valign="top">yes</td>
</tr>
<tr>
<td valign="top">support for running multiple
syslogd instances on a single machine</td>
<td valign="top">yes</td>
<td valign="top">? (but I think yes)</td>
</tr>
<tr>
<td valign="top">ability to execute shell scripts on
received messages</td>
<td valign="top">yes</td>
<td valign="top">yes</td>
</tr>
<tr>
<td valign="top">ability to pipe messages to a
continously running program</td>
<td valign="top">no</td>
<td valign="top">yes</td>
</tr>
<tr>
<td valign="top">massively multi-threaded for
tomorrow's multi-core machines</td>
<td valign="top">yes</td>
<td valign="top">no (only multithreaded with
database destinations)</td>
</tr>
<tr>
<td valign="top">ability to control repeated line
reduction ("last message repeated n times") on a per selector-line basis</td>
<td valign="top">yes</td>
<td valign="top">yes (?)</td>
</tr>
<tr>
<td valign="top">supports multiple actions per
selector/filter condition</td>
<td valign="top">yes</td>
<td valign="top">yes</td>
<td></td>
</tr>
<tr>
<td valign="top">web interface</td>
<td valign="top"><a href="http://www.phplogcon.org">phpLogCon</a><br>
[also works with <a href="http://freshmeat.net/projects/php-syslog-ng/">
php-syslog-ng</a>]</td>
<td valign="top"><a href="http://freshmeat.net/projects/php-syslog-ng/">
php-syslog-ng</a></td>
</tr>
<tr>
<td valign="top">using text files as input source</td>
<td valign="top">yes</td>
<td valign="top">yes</td>
</tr>
<tr>
<td valign="top">rate-limiting output actions</td>
<td valign="top">yes</td>
<td valign="top">yes</td>
</tr>
<tr>
<td valign="top">discard low-priority messages under
system stress</td>
<td valign="top">yes</td>
<td valign="top">no (?)</td>
</tr>
<tr>
<td height="43" valign="top">flow control
(slow down message reception when system is busy)</td>
<td height="43" valign="top">yes (advanced,
with multiple ways to slow down inputs depending on individual input
capabilities, based on watermarks)</td>
<td height="43" valign="top">yes (limited?