2
This file is part of PulseAudio.
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.
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.
14
You should have received a copy of the GNU Lesser General Public
15
License along with PulseAudio; if not, see <http://www.gnu.org/licenses/>.
30
#include <pulse/mainloop.h>
33
#include <pulse/mainloop-signal.h>
36
#include <daemon/cpulimit.h>
38
/* A simple example for testing the cpulimit subsystem */
44
static void func(pa_mainloop_api *m, pa_signal_event *e, int sig, void *userdata) {
48
if ((now - start) >= 30) {
50
fprintf(stderr, "Test failed\n");
58
START_TEST (cpulimit_test) {
61
m = pa_mainloop_new();
62
fail_unless(m != NULL);
64
pa_cpu_limit_init(pa_mainloop_get_api(m));
69
pa_signal_init(pa_mainloop_get_api(m));
70
pa_signal_new(SIGUSR1, func, NULL);
72
pa_mainloop_run(m, NULL);
79
if ((now - start) >= 30) {
80
fprintf(stderr, "Test failed\n");
93
int main(int argc, char *argv[]) {
99
s = suite_create("CPU Limit");
100
tc = tcase_create("cpulimit");
101
tcase_add_test(tc, cpulimit_test);
102
suite_add_tcase(s, tc);
104
sr = srunner_create(s);
105
srunner_run_all(sr, CK_NORMAL);
106
failed = srunner_ntests_failed(sr);
109
return (failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;