diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-10-09 08:13:29 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-10-09 08:13:29 +0000 |
commit | dd83dd6bda20f701ce637031532be14a165f1de1 (patch) | |
tree | 3003c4898f2717c1f40290da361a1ec4aa12715e /test | |
parent | 0bf06ff434c0e4a88616c1c7d5be2c5f76978db4 (diff) | |
download | ruby-dd83dd6bda20f701ce637031532be14a165f1de1.tar.gz |
process.c: uid gid exec options
* process.c (rb_execarg_addopt, rb_execarg_run_options): add :uid and
:gid options. [ruby-core:47414] [Feature #6975]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37124 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_process.rb | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/test/ruby/test_process.rb b/test/ruby/test_process.rb index 134797c2ad..e8c4cfa7d9 100644 --- a/test/ruby/test_process.rb +++ b/test/ruby/test_process.rb @@ -1478,6 +1478,50 @@ class TestProcess < Test::Unit::TestCase assert_nothing_raised { IO.popen([*TRUECOMMAND, :new_pgroup=>true]) {} } end + def test_execopts_uid + feature6975 = '[ruby-core:47414]' + + [30000, [ENV["USER"], Process.uid]].each do |user, uid| + assert_nothing_raised(feature6975) do + begin + system(*TRUECOMMAND, uid: user) + rescue Errno::EPERM, NotImplementedError + end + end + + uid = "#{uid || user}" + assert_nothing_raised(feature6975) do + begin + u = IO.popen([RUBY, "-e", "print Process.uid", uid: user], &:read) + assert_equal(uid, u, feature6975) + rescue Errno::EPERM, NotImplementedError + end + end + end + end + + def test_execopts_gid + feature6975 = '[ruby-core:47414]' + + [30000, *Process.groups.map {|g| g = Etc.getgrgid(g); [g.name, g.gid]}].each do |group, gid| + assert_nothing_raised(feature6975) do + begin + system(*TRUECOMMAND, gid: group) + rescue Errno::EPERM, NotImplementedError + end + end + + gid = "#{gid || group}" + assert_nothing_raised(feature6975) do + begin + g = IO.popen([RUBY, "-e", "print Process.gid", gid: group], &:read) + assert_equal(gid, g, feature6975) + rescue Errno::EPERM, NotImplementedError + end + end + end + end + def test_sigpipe system(RUBY, "-e", "") with_pipe {|r, w| |