Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:michals
ruby2.7
0011-tests-add-a-few-more-tests-for-select.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0011-tests-add-a-few-more-tests-for-select.patch of Package ruby2.7
From 3ba58cb13c129554d96e3d5463c406a687e2c08e Mon Sep 17 00:00:00 2001 From: Michal Suchanek <msuchanek@suse.de> Date: Sat, 7 Mar 2020 02:26:55 +0100 Subject: [PATCH 11/12] tests: add a few more tests for select. - test select throws BADFD exception and select_with_poll does not - test result of selecting pipes to a running and exited process Signed-off-by: Michal Suchanek <msuchanek@suse.de> --- test/ruby/test_io.rb | 60 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb index c66446d2e839..729b05de3f2c 100644 --- a/test/ruby/test_io.rb +++ b/test/ruby/test_io.rb @@ -23,6 +23,10 @@ def have_close_on_exec? def have_nonblock? IO.method_defined?("nonblock=") end + + def have_poll? + IO.respond_to? :select_with_poll + end end include Feature @@ -3947,6 +3951,62 @@ def test_select_leak end; end + def test_select_raise + require 'fcntl' + + fd = STDERR.fcntl(Fcntl::F_DUPFD) + io = IO.for_fd(fd, mode: 'w') + io2 = IO.for_fd(fd, mode: 'w') + + io2.close + + assert_raise(Errno::EBADF) {select [io], [io], [io]} + end + + def test_poll_no_raise + require 'fcntl' + + fd = STDERR.fcntl(Fcntl::F_DUPFD) + io = IO.for_fd(fd, mode: 'w') + io2 = IO.for_fd(fd, mode: 'w') + + io2.close + + assert_equal [[],[],[],[io]], (IO.select_with_poll [io], [io], [io], [io]) + end if have_poll? + + def startcmd *cmd + spawn_in, pipe_in = IO.pipe + pipe_out, spawn_out = IO.pipe + pipe_err, spawn_err = IO.pipe + pid = spawn(*cmd, :err=>spawn_err, :out=>spawn_out, :in=>spawn_in, :close_others=>true) + [spawn_in, spawn_out, spawn_err].each{|fd| fd.close} + [[pipe_in, pipe_out, pipe_err],pid] + end + + def endcmd stuff + fds, pid = stuff + fds.each{|fd| fd.close rescue nil} + Process.waitpid pid + end + + def test_select_cat + stuff = startcmd *%w(cat) + fds = stuff[0] + assert_equal [[],[fds[0]],[]], (IO.select fds, fds, fds, 0) + assert_equal [[],[fds[0]],[],[]], (IO.select_with_poll fds, fds, fds, fds, 0) if have_poll? + endcmd stuff + end + + def test_select_uname + stuff = startcmd *%w(uname -a) + fds = stuff[0] + sleep 0.1 + assert_equal [[fds[0],fds[1],fds[2]],[fds[0]],[]], (IO.select fds, fds, fds, 0) + assert_equal [[fds[1]],[fds[0]],[],[fds[0],fds[1],fds[2]]], (IO.select_with_poll fds, fds, fds, fds, 0) if have_poll? + endcmd stuff + end + def test_external_encoding_index IO.pipe {|r, w| assert_raise(TypeError) {Marshal.dump(r)} -- 2.26.2
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor