From 6e068c971d4d68e96851bdd09fc5cf541b9ed607 Mon Sep 17 00:00:00 2001 From: Michael Santos Date: Fri, 12 Dec 2014 16:54:25 -0500 Subject: [PATCH] setpriority test: Linux fix when RLIMIT_NICE set Linux has a resource limit for scheduling priority. If the value is 0, processes that have increased their nice value (i.e., set it to a positive integer between 0 and 20) may not decrease it. If the value is 20, the user may decrease the process priority back to 0. Uniformly test for this resource limit across all OS'es (even though only linux seems to support it) and set it down to 0 for the test. --- test/alcove_tests.erl | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/alcove_tests.erl b/test/alcove_tests.erl index 2b3b379..93abf0b 100644 --- a/test/alcove_tests.erl +++ b/test/alcove_tests.erl @@ -558,6 +558,17 @@ priority(#state{os = {unix,_}, pid = Drv}) -> Prio0 = alcove:getpriority(Drv, [Fork0,Fork1], prio_process, 0), ok = alcove:setpriority(Drv, [Fork0,Fork1], prio_process, 0, 10), Prio1 = alcove:getpriority(Drv, [Fork0,Fork1], prio_process, 0), + + case alcove:getrlimit(Drv, [Fork0,Fork1], rlimit_nice) of + {error,einval} -> + ok; + {ok, #alcove_rlimit{cur = Cur}} when Cur =:= 0 -> + ok; + {ok, #alcove_rlimit{}} -> + alcove:setrlimit(Drv, [Fork0,Fork1], rlimit_nice, + #alcove_rlimit{cur = 0, max = 0}) + end, + ok = alcove:setuid(Drv, [Fork0,Fork1], 65534), Eacces = alcove:setpriority(Drv, [Fork0,Fork1], prio_process, 0, 1),