Handle getting/setting niceness/priority correctly on FreeBSD vs NetBSD
This might be fallout from PR: 189821 Submitted by: pho Sponsored by: EMC / Isilon Storage Division
This commit is contained in:
parent
9ae31714cf
commit
6fc3b00f80
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=272909
@ -93,7 +93,11 @@ ATF_TC_HEAD(nice_priority, tc)
|
||||
|
||||
ATF_TC_BODY(nice_priority, tc)
|
||||
{
|
||||
#if defined(__FreeBSD__)
|
||||
int i, pri, pri2, nic;
|
||||
#else
|
||||
int i, pri, nic;
|
||||
#endif
|
||||
pid_t pid;
|
||||
int sta;
|
||||
|
||||
@ -106,8 +110,10 @@ ATF_TC_BODY(nice_priority, tc)
|
||||
pri = getpriority(PRIO_PROCESS, 0);
|
||||
ATF_REQUIRE(errno == 0);
|
||||
|
||||
#if defined(__NetBSD__)
|
||||
if (nic != pri)
|
||||
atf_tc_fail("nice(3) and getpriority(2) conflict");
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Also verify that the nice(3) values
|
||||
@ -119,10 +125,18 @@ ATF_TC_BODY(nice_priority, tc)
|
||||
if (pid == 0) {
|
||||
|
||||
errno = 0;
|
||||
#if defined(__FreeBSD__)
|
||||
pri = getpriority(PRIO_PROCESS, 0);
|
||||
#else
|
||||
pri2 = getpriority(PRIO_PROCESS, 0);
|
||||
#endif
|
||||
ATF_REQUIRE(errno == 0);
|
||||
|
||||
#if defined(__FreeBSD__)
|
||||
if (pri != pri2)
|
||||
#else
|
||||
if (nic != pri)
|
||||
#endif
|
||||
_exit(EXIT_FAILURE);
|
||||
|
||||
_exit(EXIT_SUCCESS);
|
||||
@ -161,7 +175,11 @@ ATF_TC_HEAD(nice_thread, tc)
|
||||
ATF_TC_BODY(nice_thread, tc)
|
||||
{
|
||||
pthread_t tid[5];
|
||||
#if defined(__FreeBSD__)
|
||||
int pri, rv, val;
|
||||
#else
|
||||
int rv, val;
|
||||
#endif
|
||||
size_t i;
|
||||
|
||||
/*
|
||||
@ -173,7 +191,12 @@ ATF_TC_BODY(nice_thread, tc)
|
||||
val = nice(i);
|
||||
ATF_REQUIRE(val != -1);
|
||||
|
||||
#if defined(__FreeBSD__)
|
||||
pri = getpriority(PRIO_PROCESS, 0);
|
||||
rv = pthread_create(&tid[i], NULL, threadfunc, &pri);
|
||||
#else
|
||||
rv = pthread_create(&tid[i], NULL, threadfunc, &val);
|
||||
#endif
|
||||
ATF_REQUIRE(rv == 0);
|
||||
|
||||
rv = pthread_join(tid[i], NULL);
|
||||
|
Loading…
Reference in New Issue
Block a user