bluetooth: Remove commented out code.
[profile/ivi/pulseaudio-panda.git] / src / tests / cpulimit-test.c
1 /***
2   This file is part of PulseAudio.
3
4   PulseAudio is free software; you can redistribute it and/or modify
5   it under the terms of the GNU Lesser General Public License as
6   published by the Free Software Foundation; either version 2.1 of the
7   License, or (at your option) any later version.
8
9   PulseAudio is distributed in the hope that it will be useful, but
10   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 Lesser General Public
15   License along with PulseAudio; if not, write to the Free Software
16   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
17   USA.
18 ***/
19
20 #ifdef HAVE_CONFIG_H
21 #include <config.h>
22 #endif
23
24 #include <assert.h>
25 #include <time.h>
26 #include <stdlib.h>
27 #include <stdio.h>
28 #include <signal.h>
29
30 #include <pulse/mainloop.h>
31
32 #ifdef TEST2
33 #include <pulse/mainloop-signal.h>
34 #endif
35
36 #include <daemon/cpulimit.h>
37
38 /* A simple example for testing the cpulimit subsystem */
39
40 static time_t start;
41
42 #ifdef TEST2
43
44 static void func(pa_mainloop_api *m, pa_signal_event *e, int sig, void *userdata) {
45     time_t now;
46     time(&now);
47
48     if ((now - start) >= 30) {
49         m->quit(m, 1);
50         fprintf(stderr, "Test failed\n");
51     } else
52         raise(SIGUSR1);
53 }
54
55 #endif
56
57 int main(int argc, char *argv[]) {
58     pa_mainloop *m;
59
60     m = pa_mainloop_new();
61     assert(m);
62
63     pa_cpu_limit_init(pa_mainloop_get_api(m));
64
65     time(&start);
66
67 #ifdef TEST2
68     pa_signal_init(pa_mainloop_get_api(m));
69     pa_signal_new(SIGUSR1, func, NULL);
70     raise(SIGUSR1);
71     pa_mainloop_run(m, NULL);
72     pa_signal_done();
73 #else
74     for (;;) {
75         time_t now;
76         time(&now);
77
78         if ((now - start) >= 30) {
79             fprintf(stderr, "Test failed\n");
80             break;
81         }
82     }
83 #endif
84
85     pa_cpu_limit_done();
86
87     pa_mainloop_free(m);
88
89     return 0;
90 }