From 7d372e352c15438139acfac6dce5317fd23e6e1e Mon Sep 17 00:00:00 2001 From: Ben Walton Date: Thu, 24 Mar 2011 15:50:11 +0100 Subject: [PATCH 1/2] Use LOG_PID instead of LOG_PERROR in Syslog.open test LOG_PERROR isn't a POSIX option for syslog, so it fails on platforms that don't define it. Solaris 9 and 10 are examples of this. Use LOG_PID instead. Signed-off-by: Ben Walton --- test/test_syslog.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/test_syslog.rb b/test/test_syslog.rb index e9fc375c9026aa..2c7a451d445718 100644 --- a/test/test_syslog.rb +++ b/test/test_syslog.rb @@ -43,10 +43,11 @@ def test_open Syslog.close # given parameters - Syslog.open("foo", Syslog::LOG_NDELAY | Syslog::LOG_PERROR, Syslog::LOG_DAEMON) + options = Syslog::LOG_NDELAY | Syslog::LOG_PID + Syslog.open("foo", options, Syslog::LOG_DAEMON) assert_equal('foo', Syslog.ident) - assert_equal(Syslog::LOG_NDELAY | Syslog::LOG_PERROR, Syslog.options) + assert_equal(options, Syslog.options) assert_equal(Syslog::LOG_DAEMON, Syslog.facility) Syslog.close From fd060320dcd9cffbe5ba9b581e0ec96144fd62dc Mon Sep 17 00:00:00 2001 From: Ben Walton Date: Thu, 24 Mar 2011 16:43:41 +0100 Subject: [PATCH 2/2] Skip syslog tests that rely on LOG_PERROR unless it's defined Instead of checking looking at the platform to determine if the tests relying on LOG_PERROR should be run, look for the definition of the constant as this will be robust against all platforms as long as the underlying syslog.c code sets it up correctly. This specifically addresses failures on Solaris 9. Signed-off-by: Ben Walton --- test/test_syslog.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/test_syslog.rb b/test/test_syslog.rb index 2c7a451d445718..375ff2fe30a33c 100644 --- a/test/test_syslog.rb +++ b/test/test_syslog.rb @@ -135,8 +135,9 @@ def test_log stderr[1].close Process.waitpid(pid) - # LOG_PERROR is not yet implemented on Cygwin. - return if RUBY_PLATFORM =~ /cygwin/ + # LOG_PERROR is not implemented on Cygwin or Solaris. Only test + # these on systems that define it. + return unless Syslog.const_defined?(:LOG_PERROR) 2.times { assert_equal("syslog_test: test1 - hello, world!\n", stderr[0].gets)