4 # Copyright (C) 2002-2024 Free Software Foundation, Inc.
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <https://www.gnu.org/licenses/>.
19 .
"${srcdir=.}/tests/init.sh"; path_prepend_ .
/src
47 # Require that this test be run at 'nice' level 0.
49 if test "$niceness" = 0; then
52 skip_
"this test must be run at nice level 0"
59 test $args = empty
&& args
=''
60 test x
$args = xLAST
&& break
61 args
=$
(echo x
$args|
tr : ' '|
sed 's/^x//')
62 if test "$VERBOSE" = yes; then
63 #echo "testing \$(nice $args nice\) = $expected_result ..."
64 echo "test $test_name... " |
tr -d '\n'
66 test x$
(nice
$args nice
2> /dev
/null
) = x
$expected_result \
67 && ok
=ok || ok
=FAIL fail
=1
68 test "$VERBOSE" = yes && echo $ok
72 # Test negative niceness - command must be run whether or not change happens.
73 if test x$
(nice
-n -1 nice
2> /dev
/null
) = x0
; then
74 # unprivileged user - warn about failure to change
75 nice
-n -1 true
2> err || fail
=1
76 compare
/dev
/null err
&& fail
=1
77 mv err exp || framework_failure_
78 nice
--1 true
2> err || fail
=1
79 compare exp err || fail
=1
80 # Failure to write advisory message is fatal. Buggy through coreutils 8.0.
81 if test -w /dev
/full
&& test -c /dev
/full
; then
82 returns_
125 nice
-n -1 nice
> out
2> /dev
/full || fail
=1
83 compare
/dev
/null out || fail
=1
86 # superuser - change succeeds
87 nice
-n -1 nice
2> err || fail
=1
88 compare
/dev
/null err || fail
=1
89 test x$
(nice
-n -1 nice
) = x-1 || fail
=1
90 test x$
(nice
--1 nice
) = x-1 || fail
=1