]> code.delx.au - pulseaudio/blob - polyp/cpulimit-test.c
Make the whole stuff LGPL only
[pulseaudio] / polyp / cpulimit-test.c
1 /* $Id$ */
2
3 /***
4 This file is part of polypaudio.
5
6 polypaudio is free software; you can redistribute it and/or modify
7 it under the terms of the GNU Lesser General Public License as published
8 by the Free Software Foundation; either version 2 of the License,
9 or (at your option) any later version.
10
11 polypaudio is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public License
17 along with polypaudio; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19 USA.
20 ***/
21
22 #include <assert.h>
23 #include <sys/time.h>
24 #include <stdlib.h>
25 #include <stdio.h>
26 #include <signal.h>
27
28 #include "cpulimit.h"
29 #include "mainloop.h"
30
31 #ifdef TEST2
32 #include "mainloop-signal.h"
33 #endif
34
35 static time_t start;
36
37 #ifdef TEST2
38
39 static void func(struct pa_mainloop_api *m, struct pa_signal_event *e, int sig, void *userdata) {
40 time_t now;
41 time(&now);
42
43 if ((now - start) >= 30) {
44 m->quit(m, 1);
45 fprintf(stderr, "Test failed\n");
46 } else
47 raise(SIGUSR1);
48 }
49
50 #endif
51
52 int main() {
53 struct pa_mainloop *m;
54
55 m = pa_mainloop_new();
56 assert(m);
57
58 pa_cpu_limit_init(pa_mainloop_get_api(m));
59
60 time(&start);
61
62 #ifdef TEST2
63 pa_signal_init(pa_mainloop_get_api(m));
64 pa_signal_new(SIGUSR1, func, NULL);
65 raise(SIGUSR1);
66 pa_mainloop_run(m, NULL);
67 pa_signal_done();
68 #else
69 for (;;) {
70 time_t now;
71 time(&now);
72
73 if ((now - start) >= 30) {
74 fprintf(stderr, "Test failed\n");
75 break;
76 }
77 }
78 #endif
79
80 pa_cpu_limit_done();
81
82 pa_mainloop_free(m);
83
84 return 0;
85 }