зеркало из https://github.com/github/ruby.git
Run in separate process/pgrp [Bug #13609]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58959 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
01ebc04fa2
Коммит
eee4dee0a2
|
@ -4,18 +4,20 @@ describe "Process.setpriority" do
|
|||
# Needs a valid version written for Linux
|
||||
platform_is :darwin do
|
||||
it "sets the scheduling priority for a specified process" do
|
||||
p = Process.getpriority(Process::PRIO_PROCESS, 0)
|
||||
Process.setpriority(mock_int(Process::PRIO_PROCESS),
|
||||
mock_int(0),
|
||||
mock_int(p + 1)).should == 0
|
||||
Process.getpriority(Process::PRIO_PROCESS, 0).should == (p + 1)
|
||||
if Process.uid == 0
|
||||
Process.setpriority(Process::PRIO_PROCESS, 0, p).should == 0
|
||||
else
|
||||
lambda {
|
||||
Process.setpriority(Process::PRIO_PROCESS, 0, p)
|
||||
}.should raise_error(Errno::EACCES)
|
||||
priority = Process.getpriority(Process::PRIO_PROCESS, 0)
|
||||
IO.popen('-') do |f|
|
||||
if f
|
||||
pr = Integer(f.gets)
|
||||
Integer(f.gets).should == 0
|
||||
Integer(f.gets).should == (pr+1)
|
||||
else
|
||||
pr = Process.getpriority(Process::PRIO_PROCESS, 0)
|
||||
p pr
|
||||
p Process.setpriority(Process::PRIO_PROCESS, 0, (pr + 1))
|
||||
p Process.getpriority(Process::PRIO_PROCESS, 0)
|
||||
end
|
||||
end
|
||||
Process.getpriority(Process::PRIO_PROCESS, 0).should == priority
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -23,26 +25,21 @@ describe "Process.setpriority" do
|
|||
# whack with either permission errors or just the wrong value
|
||||
platform_is_not :darwin, :freebsd, :windows do
|
||||
it "sets the scheduling priority for a specified process group" do
|
||||
pr = Process.getpriority(Process::PRIO_PGRP, 0)
|
||||
|
||||
Process.setpriority(Process::PRIO_PGRP, 0, pr + 1).should == 0
|
||||
Process.getpriority(Process::PRIO_PGRP, 0).should == (pr + 1)
|
||||
if Process.uid == 0
|
||||
Process.setpriority(Process::PRIO_PGRP, 0, pr).should == 0
|
||||
else
|
||||
# EACCESS is not always raised. It's a stupid OS behavior.
|
||||
ok = false
|
||||
begin
|
||||
Process.setpriority(Process::PRIO_PGRP, 0, pr)
|
||||
ok = true
|
||||
rescue Errno::EACCES
|
||||
ok = true
|
||||
rescue Object
|
||||
ok = false
|
||||
priority = Process.getpriority(Process::PRIO_PGRP, 0)
|
||||
IO.popen('-') do |f|
|
||||
if f
|
||||
pr = Integer(f.gets)
|
||||
Integer(f.gets).should == 0
|
||||
Integer(f.gets).should == (pr+1)
|
||||
else
|
||||
Process.setpgrp
|
||||
pr = Process.getpriority(Process::PRIO_PGRP, 0)
|
||||
p pr
|
||||
p Process.setpriority(Process::PRIO_PGRP, 0, pr + 1)
|
||||
p Process.getpriority(Process::PRIO_PGRP, 0)
|
||||
end
|
||||
|
||||
ok.should == true
|
||||
end
|
||||
Process.getpriority(Process::PRIO_PGRP, 0).should == priority
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче