aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/eina/src/tests/eina_test_sched.c
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/eina/src/tests/eina_test_sched.c')
-rw-r--r--libraries/eina/src/tests/eina_test_sched.c85
1 files changed, 85 insertions, 0 deletions
diff --git a/libraries/eina/src/tests/eina_test_sched.c b/libraries/eina/src/tests/eina_test_sched.c
new file mode 100644
index 0000000..ff83a7e
--- /dev/null
+++ b/libraries/eina/src/tests/eina_test_sched.c
@@ -0,0 +1,85 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2008 Cedric Bail
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 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 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifdef HAVE_CONFIG_H
20# include "config.h"
21#endif
22
23#if defined(EFL_HAVE_THREADS) && defined __linux__
24#include <pthread.h>
25#include <errno.h>
26#include <sys/resource.h>
27#endif
28
29#include "eina_suite.h"
30#include "Eina.h"
31
32#if defined(EFL_HAVE_THREADS) && defined __linux__
33
34/*
35 * TODO: Test if RT priorities are right. However, make check should be run as
36 * root.
37 */
38
39static void *
40_thread_run(void *arg __UNUSED__)
41{
42 int niceval = getpriority(PRIO_PROCESS, 0);
43 int niceval2;
44 eina_sched_prio_drop();
45
46 niceval2 = getpriority(PRIO_PROCESS, 0);
47 fail_if((niceval2 != 19) && (niceval2 != niceval+5));
48
49 return NULL;
50}
51
52START_TEST(eina_test_sched_prio_drop)
53{
54 int niceval = getpriority(PRIO_PROCESS, 0);
55 int niceval2;
56 pthread_t tid;
57
58 eina_init();
59
60 pthread_create(&tid, NULL, _thread_run, NULL);
61
62 niceval2 = getpriority(PRIO_PROCESS, 0);
63 /* niceness of main thread should not have changed */
64 fail_if(niceval2 != niceval);
65
66 pthread_join(tid, NULL);
67 /* niceness of main thread should not have changed */
68 fail_if(niceval2 != niceval);
69
70 eina_shutdown();
71}
72END_TEST
73#else
74START_TEST(eina_test_sched_prio_drop)
75{
76 fprintf(stderr, "scheduler priority is not supported by your configuration.\n");
77}
78END_TEST
79#endif
80
81void
82eina_test_sched(TCase *tc)
83{
84 tcase_add_test(tc, eina_test_sched_prio_drop);
85}