summaryrefslogtreecommitdiff
path: root/test/test_syslog.rb
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-05-29 14:59:24 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-05-29 14:59:24 +0000
commitce0c2b2170f4fd562b1019e325638649def9d924 (patch)
tree0c9663f5f85a441000a27d3778c57e2661215db8 /test/test_syslog.rb
parent1a956cea38a659e94ba87e59098788829b15aaa1 (diff)
test/test_syslog.rb: Close fds.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46235 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/test_syslog.rb')
-rwxr-xr-xtest/test_syslog.rb82
1 files changed, 41 insertions, 41 deletions
diff --git a/test/test_syslog.rb b/test/test_syslog.rb
index 1fb0aff..e079d71 100755
--- a/test/test_syslog.rb
+++ b/test/test_syslog.rb
@@ -120,52 +120,52 @@ class TestSyslog < Test::Unit::TestCase
end
def test_log
- stderr = IO::pipe
-
- pid = fork {
- stderr[0].close
- STDERR.reopen(stderr[1])
- stderr[1].close
-
- options = Syslog::LOG_PERROR | Syslog::LOG_NDELAY
-
- Syslog.open("syslog_test", options) { |sl|
- sl.log(Syslog::LOG_NOTICE, "test1 - hello, %s!", "world")
- sl.notice("test1 - hello, %s!", "world")
+ IO.pipe {|stderr|
+ pid = fork {
+ stderr[0].close
+ STDERR.reopen(stderr[1])
+ stderr[1].close
+
+ options = Syslog::LOG_PERROR | Syslog::LOG_NDELAY
+
+ Syslog.open("syslog_test", options) { |sl|
+ sl.log(Syslog::LOG_NOTICE, "test1 - hello, %s!", "world")
+ sl.notice("test1 - hello, %s!", "world")
+ }
+
+ Syslog.open("syslog_test", options | Syslog::LOG_PID) { |sl|
+ sl.log(Syslog::LOG_CRIT, "test2 - pid")
+ sl.crit("test2 - pid")
+ }
+ exit!
}
- Syslog.open("syslog_test", options | Syslog::LOG_PID) { |sl|
- sl.log(Syslog::LOG_CRIT, "test2 - pid")
- sl.crit("test2 - pid")
+ stderr[1].close
+ Process.waitpid(pid)
+
+ # 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 {
+ re = syslog_line_regex("syslog_test", "test1 - hello, world!")
+ line = stderr[0].gets
+ m = re.match(line)
+ assert_not_nil(m)
+ if m[1]
+ # pid is written regardless of LOG_PID on OS X 10.7+
+ assert_equal(pid, m[1].to_i)
+ end
}
- exit!
- }
- stderr[1].close
- Process.waitpid(pid)
-
- # 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 {
- re = syslog_line_regex("syslog_test", "test1 - hello, world!")
- line = stderr[0].gets
- m = re.match(line)
- assert_not_nil(m)
- if m[1]
- # pid is written regardless of LOG_PID on OS X 10.7+
+ 2.times {
+ re = syslog_line_regex("syslog_test", "test2 - pid")
+ line = stderr[0].gets
+ m = re.match(line)
+ assert_not_nil(m)
+ assert_not_nil(m[1])
assert_equal(pid, m[1].to_i)
- end
- }
-
- 2.times {
- re = syslog_line_regex("syslog_test", "test2 - pid")
- line = stderr[0].gets
- m = re.match(line)
- assert_not_nil(m)
- assert_not_nil(m[1])
- assert_equal(pid, m[1].to_i)
+ }
}
end