tracker-0.16.2/tests/libtracker-common/tracker-sched-test.c

No issues found

 1 /*
 2  * Copyright (C) 2011, Nokia <ivan.frade@nokia.com>
 3  *
 4  * This library is free software; you can redistribute it and/or
 5  * modify it under the terms of the GNU General Public
 6  * License as published by the Free Software Foundation; either
 7  * version 2 of the License, or (at your option) any later version.
 8  *
 9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  * Boston, MA  02110-1301, USA.
18  */
19 #include "config.h"
20 
21 #include <glib.h>
22 #include <glib-object.h>
23 #include <libtracker-common/tracker-sched.h>
24 
25 #ifdef __linux__
26 #include <linux/sched.h>
27 #endif
28 
29 
30 #include <sched.h>
31 #include <errno.h>
32 
33 
34 static gboolean
35 scheduler_is (gint scheduler)
36 {
37 #ifdef __linux__
38         return (sched_getscheduler (0) == scheduler);
39 #else
40         return TRUE;
41 #endif
42 }
43 
44 static void
45 test_sched_set_and_get (void)
46 {
47         g_assert (scheduler_is (SCHED_OTHER));
48         g_assert (tracker_sched_idle ());
49 #ifdef __linux__
50         g_assert (scheduler_is (SCHED_IDLE));
51 #endif
52 }
53 
54 
55 gint
56 main (gint argc, gchar **argv)
57 {
58         g_test_init (&argc, &argv, NULL);
59 
60         g_test_add_func ("/libtracker-common/sched/set_and_get",
61                          test_sched_set_and_get);
62 
63         return g_test_run ();
64 }