mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Move spec/rubyspec to spec/ruby for consistency
* Other ruby implementations use the spec/ruby directory. [Misc #13792] [ruby-core:82287] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59979 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
75bfc6440d
commit
1d15d5f080
4370 changed files with 0 additions and 0 deletions
54
spec/ruby/core/process/groups_spec.rb
Normal file
54
spec/ruby/core/process/groups_spec.rb
Normal file
|
@ -0,0 +1,54 @@
|
|||
require File.expand_path('../../../spec_helper', __FILE__)
|
||||
|
||||
describe "Process.groups" do
|
||||
platform_is_not :windows do
|
||||
it "gets an Array of the gids of groups in the supplemental group access list" do
|
||||
groups = `id -G`.scan(/\d+/).map { |i| i.to_i }
|
||||
gid = Process.gid
|
||||
|
||||
expected = (groups.sort - [gid]).sort
|
||||
actual = (Process.groups - [gid]).sort
|
||||
actual.should == expected
|
||||
end
|
||||
|
||||
# NOTE: This is kind of sketchy.
|
||||
it "sets the list of gids of groups in the supplemental group access list" do
|
||||
groups = Process.groups
|
||||
if Process.uid == 0
|
||||
Process.groups = []
|
||||
Process.groups.should == []
|
||||
Process.groups = groups
|
||||
Process.groups.sort.should == groups.sort
|
||||
else
|
||||
platform_is :aix do
|
||||
# setgroups() is not part of the POSIX standard,
|
||||
# so its behavior varies from OS to OS. AIX allows a non-root
|
||||
# process to set the supplementary group IDs, as long as
|
||||
# they are presently in its supplementary group IDs.
|
||||
# The order of the following tests matters.
|
||||
# After this process executes "Process.groups = []"
|
||||
# it should no longer be able to set any supplementary
|
||||
# group IDs, even if it originally belonged to them.
|
||||
# It should only be able to set its primary group ID.
|
||||
Process.groups = groups
|
||||
Process.groups.sort.should == groups.sort
|
||||
Process.groups = []
|
||||
Process.groups.should == []
|
||||
Process.groups = [ Process.gid ]
|
||||
Process.groups.should == [ Process.gid ]
|
||||
supplementary = groups - [ Process.gid ]
|
||||
if supplementary.length > 0
|
||||
lambda { Process.groups = supplementary }.should raise_error(Errno::EPERM)
|
||||
end
|
||||
end
|
||||
platform_is_not :aix do
|
||||
lambda { Process.groups = [] }.should raise_error(Errno::EPERM)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "Process.groups=" do
|
||||
it "needs to be reviewed for spec completeness"
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue