[tracker-miners: 1/2] tests: fix sched test under non glibc platforms




commit 5258a8e706d300a3a97e1f9cb71ad6981cf35e56
Author: Rasmus Thomsen <oss cogitri dev>
Date:   Mon Oct 5 19:24:16 2020 +0200

    tests: fix sched test under non glibc platforms
    
    As mentioned in https://gitlab.gnome.org/GNOME/tracker/-/issues/170,
    glibc's sched_setscheduler is rather broken and pthread functionality
    should be used instead. musl only exposes a stub for sched_setscheduler
    for this reason. tracker already correctly sets the scheduler via pthread,
    but it didn't adjust the tests and as such the tests still failed on musl.

 tests/libtracker-miners-common/tracker-sched-test.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
---
diff --git a/tests/libtracker-miners-common/tracker-sched-test.c 
b/tests/libtracker-miners-common/tracker-sched-test.c
index 9cb8d7fdf..20d926c1a 100644
--- a/tests/libtracker-miners-common/tracker-sched-test.c
+++ b/tests/libtracker-miners-common/tracker-sched-test.c
@@ -35,7 +35,13 @@ static gboolean
 scheduler_is (gint scheduler)
 {
 #ifdef __linux__
-        return (sched_getscheduler (0) == scheduler);
+        int policy;
+        struct sched_param param;
+
+        if (pthread_getschedparam (pthread_self (), &policy, &param) != 0) {
+                g_assert_not_reached ();
+        }
+        return (policy == scheduler);
 #else
         return TRUE;
 #endif


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]