Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/tests/lib/libc/gen/posix_spawn Fix broken test: we can't ass...



details:   https://anonhg.NetBSD.org/src/rev/20bae709cd00
branches:  trunk
changeset: 828603:20bae709cd00
user:      christos <christos%NetBSD.org@localhost>
date:      Thu Dec 21 03:31:43 2017 +0000

description:
Fix broken test: we can't assume that the current schedule priority range
will overlap with the requested scheduler range, so get the new scheduler
range, and then try to find a different priority. If that fails (to find
a different scheduling range), give up here.

diffstat:

 tests/lib/libc/gen/posix_spawn/t_spawnattr.c |  27 +++++++++++++--------------
 1 files changed, 13 insertions(+), 14 deletions(-)

diffs (68 lines):

diff -r 6093191366f3 -r 20bae709cd00 tests/lib/libc/gen/posix_spawn/t_spawnattr.c
--- a/tests/lib/libc/gen/posix_spawn/t_spawnattr.c      Wed Dec 20 15:22:14 2017 +0000
+++ b/tests/lib/libc/gen/posix_spawn/t_spawnattr.c      Thu Dec 21 03:31:43 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: t_spawnattr.c,v 1.2 2017/12/18 13:18:23 christos Exp $ */
+/* $NetBSD: t_spawnattr.c,v 1.3 2017/12/21 03:31:43 christos Exp $ */
 
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -45,11 +45,8 @@
 #define MAX(a, b)      (a) > (b) ? (a) : (b)
 #define MIN(a, b)      (a) > (b) ? (b) : (a)
 
-static int get_different_scheduler(void);
-static int get_different_priority(void);
-
 static int
-get_different_scheduler()
+get_different_scheduler(void)
 {
        /*
         * We don't want to use SCHED_OTHER because it does not have
@@ -69,14 +66,12 @@
 }
 
 static int
-get_different_priority()
+get_different_priority(int scheduler)
 {
-       int scheduler, max, min, new, priority;
+       int min, max, new, priority;
        struct sched_param param;
 
-       /* get current schedule policy */
-       scheduler = sched_getscheduler(0);
-
+       /* Get the priority range for the new scheduler */
        max = sched_get_priority_max(scheduler);
        min = sched_get_priority_min(scheduler);
 
@@ -84,10 +79,13 @@
        priority = param.sched_priority;
        
        /* new schedule policy */
-       new = (priority + 1);
-       if (new > max)
-               new = min;
+       for (new = min; new <= max; new++)
+               if (priority != new)
+                       break;
        
+       ATF_REQUIRE_MSG(priority != new, "could not find different priority");
+       printf("min %d max %d for scheduler %d, returning %d\n",
+           min, max, scheduler, new);
        return new;
 }
 
@@ -120,8 +118,9 @@
        posix_spawnattr_init(&attr);
 
        scheduler = get_different_scheduler();
-       priority = get_different_priority();
+       priority = get_different_priority(scheduler);
        sp.sched_priority = priority;
+       printf("using scheduler %d, priority %d\n", scheduler, priority);
        
        sigemptyset(&sig);
        sigaddset(&sig, SIGUSR1);



Home | Main Index | Thread Index | Old Index