diff options
author | Deng Zhengrong <dzrongg@gmail.com> | 2012-07-28 21:34:58 +0800 |
---|---|---|
committer | Arun Raghavan <arun.raghavan@collabora.co.uk> | 2012-08-20 07:05:59 +0530 |
commit | 5f8c22e6f193c0f5fb1bf689e0751b19c53d9f2d (patch) | |
tree | 08f9319258f3ba8af9a55593f0fcdf8ef862bccf /src/tests/cpulimit-test.c | |
parent | dbf176acbdc4a6dccdd870348cdedf7a9d8d963d (diff) |
tests: modify cpulimit-test to use 'check' framework
Diffstat (limited to 'src/tests/cpulimit-test.c')
-rw-r--r-- | src/tests/cpulimit-test.c | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/src/tests/cpulimit-test.c b/src/tests/cpulimit-test.c index 8bd03417a..8988c1ad2 100644 --- a/src/tests/cpulimit-test.c +++ b/src/tests/cpulimit-test.c @@ -27,6 +27,8 @@ #include <stdio.h> #include <signal.h> +#include <check.h> + #include <pulse/mainloop.h> #ifdef TEST2 @@ -48,17 +50,18 @@ static void func(pa_mainloop_api *m, pa_signal_event *e, int sig, void *userdata if ((now - start) >= 30) { m->quit(m, 1); fprintf(stderr, "Test failed\n"); + fail(); } else raise(SIGUSR1); } #endif -int main(int argc, char *argv[]) { +START_TEST (cpulimit_test) { pa_mainloop *m; m = pa_mainloop_new(); - assert(m); + fail_unless(m != NULL); pa_cpu_limit_init(pa_mainloop_get_api(m)); @@ -77,6 +80,7 @@ int main(int argc, char *argv[]) { if ((now - start) >= 30) { fprintf(stderr, "Test failed\n"); + fail(); break; } } @@ -85,6 +89,24 @@ int main(int argc, char *argv[]) { pa_cpu_limit_done(); pa_mainloop_free(m); +} +END_TEST - return 0; +int main(int argc, char *argv[]) { + int failed = 0; + Suite *s; + TCase *tc; + SRunner *sr; + + s = suite_create("CPU Limit"); + tc = tcase_create("cpulimit"); + tcase_add_test(tc, cpulimit_test); + suite_add_tcase(s, tc); + + sr = srunner_create(s); + srunner_run_all(sr, CK_NORMAL); + failed = srunner_ntests_failed(sr); + srunner_free(sr); + + return (failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE; } |