This queue is for tickets about the BSD-Resource CPAN distribution.

Report information
The Basics
Id:
13130
Status:
resolved
Priority:
Low/Low
Queue:

People
Owner:
Nobody in particular
Requestors:
at [...] altlinux.org
Cc:
AdminCc:

BugTracker
Severity:
(no value)
Broken in:
1.24
Fixed in:
(no value)

Attachments
perl-BSD-Resource-1.24-alt-tests-prio-nice.patch



Subject: getpriority.t and setpriority.t assume priority = 0
Hello, getpriority.t and setpriority.t assume the default priority = 0, which may or may not hold. (For example, many build systems use nice(1) for their batch jobs; so I've got test suite failures when trying to rebuild my perl-BSD-Resource rpm package). The idea is that you can use nice(1) output to find out current priority before running tests. Please see the attached patch. Now "make test", "nice make test", and even "nice nice make test" work fine for me. (System that do not have /bin/nice will simply got it 0, so it's not gonna be a problem.) -- Alexey Tourbin ALT Linux Team
--- BSD-Resource-1.24/t/getpriority.t~ 1997-04-08 10:54:17 +0400 +++ BSD-Resource-1.24/t/getpriority.t 2005-06-07 03:49:35 +0400 @@ -11,7 +11,7 @@ print "1..3\n"; # AIX without BSD libs has 0..39 priorities, not -20..20. -$okpriopat = $Config{'osname'} eq 'aix' ? '0|19' : '0'; +$okpriopat = $Config{'osname'} eq 'aix' ? '0|19' : `nice` + 0; $okpriopat = "^($okpriopat)"; --- BSD-Resource-1.24/t/setpriority.t~ 1997-04-08 10:55:29 +0400 +++ BSD-Resource-1.24/t/setpriority.t 2005-06-07 04:03:58 +0400 @@ -8,40 +8,38 @@ print "1..3\n"; -$gotlower = setpriority(PRIO_PROCESS, 0, 5); +$nice = getpriority(PRIO_PROCESS, 0); +print "# nice = $nice\n" if ($debug); -print "# gotlower = $gotlower\n" if ($debug); - -# we must use getpriority() to find out whether setpriority() really worked - -$lowerprio = getpriority(PRIO_PROCESS, 0); - -print "# lowerprio = $lowerprio\n" if ($debug); - -$fail = (not $gotlower or not $lowerprio == 5); - -print 'not ' - if ($fail); +if ($nice < 15) { # only works if nice is not exhausted + $gotlower = setpriority(PRIO_PROCESS, 0, $nice + 5); + print "# gotlower = $gotlower\n" if ($debug); + $lowerprio = getpriority(PRIO_PROCESS, 0); + print "# lowerprio = $lowerprio\n" if ($debug); + $fail = (not $gotlower or not $lowerprio == $nice + 5); + print 'not ' + if ($fail); +} else { + $lowerprio = $nice; + $fail = 0; +} print "ok 1\n"; if ($fail) { print "# syserr = '$!' (",$!+0,"), ruid = $<, euid = $>\n"; print "# gotlower = $gotlower, lowerprio = $lowerprio\n"; } -$gotlower = setpriority(); - -print "# gotlower = $gotlower\n" if ($debug); - -# we must use getpriority() to find out whether setpriority() really worked - -$lowerprio = getpriority(); - -print "# lowerprio = $lowerprio\n" if ($debug); - -$fail = (not $gotlower or not $lowerprio == 10); - -print 'not ' - if ($fail); +if ($lowerprio < 10) { # only works if lowerprio is not exhausted + $gotlower = setpriority(); + print "# gotlower = $gotlower\n" if ($debug); + $lowerprio = getpriority(); + print "# lowerprio = $lowerprio\n" if ($debug); + $fail = (not $gotlower or not $lowerprio == 10); + print 'not ' + if ($fail); +} else { + $fail = 0; +} print "ok 2\n"; if ($fail) { print "# syserr = '$!' (",$!+0,"), ruid = $<, euid = $>\n";
[guest - Mon Jun 6 20:45:12 2005]:
Show quoted text
> Hello, > > getpriority.t and setpriority.t assume the default priority = 0, which > may or may not hold. (For example, many build systems use nice(1) for > their batch jobs; so I've got test suite failures when trying to > rebuild > my perl-BSD-Resource rpm package). > > The idea is that you can use nice(1) output to find out current > priority > before running tests. Please see the attached patch. Now "make > test", > "nice make test", and even "nice nice make test" work fine for me. > (System that do not have /bin/nice will simply got it 0, so it's not > gonna be a problem.)
This +$okpriopat = $Config{'osname'} eq 'aix' ? '0|19' : `nice` + 0; assumes a GNU nice(1). Here is a sampling of what happens elsewhere: AIX: (no output) Mac OS X: usage: nice [ -n increment ] utility [ argument ...] Solaris: nice: usage: nice [-n increment] utility [argument ...] Tru64: nice: usage: nice [-n priority] command [argument ...]
Please see BSD::Resource 1.25.
With BSD-Resource 1.28 this should be fixed.


This service runs on Request Tracker, is sponsored by The Perl Foundation, and maintained by Best Practical Solutions.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.